diff --git a/backend/app/main.py b/backend/app/main.py index a02df1681..81bf57e2c 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -83,7 +83,6 @@ from backend.app.core.config import APP_VERSION, settings as app_settings from backend.app.core.database import async_session, engine, init_db from backend.app.core.tasks import spawn_background_task from backend.app.core.websocket import ws_manager -from backend.app.models.smart_plug import SmartPlug from backend.app.services import print_dispatch_context from backend.app.services.archive import ArchiveService, peek_plate_index_in_3mf, swap_plate_suffix from backend.app.services.archive_purge import archive_purge_service @@ -98,6 +97,7 @@ from backend.app.services.bambu_ftp import ( with_ftp_retry, ) from backend.app.services.bambu_mqtt import PrinterState +from backend.app.services.energy_plug import energy_plug_candidates, select_energy_reading from backend.app.services.github_backup import github_backup_service from backend.app.services.ha_sensor_manager import ha_sensor_manager from backend.app.services.homeassistant import homeassistant_service @@ -896,21 +896,30 @@ async def _record_energy_start(archive, printer_id: int, db, *, context: str = " """ _logger = logging.getLogger(__name__) try: - plug_result = await db.execute(select(SmartPlug).where(SmartPlug.printer_id == printer_id)) - plug = plug_result.scalar_one_or_none() - if not plug: + candidates = await energy_plug_candidates(db, printer_id) + if not candidates: _logger.info("[ENERGY] No smart plug for printer %s (archive %s)", printer_id, archive.id) return False - energy = await _get_plug_energy(plug, db) - if not energy or energy.get("total") is None: - _logger.warning("[ENERGY] No 'total' in energy response for archive %s", archive.id) + selected = await select_energy_reading(candidates, _get_plug_energy, db) + if selected is None: + # Naming the plugs matters here: with several linked to one printer + # this is the difference between "the meter is offline" and "you + # linked only accessories" (#2859). + _logger.warning( + "[ENERGY] No plug on printer %s reports a lifetime energy counter for archive %s (tried: %s)", + printer_id, + archive.id, + ", ".join(plug.name for plug in candidates), + ) return False + plug, energy = selected archive.energy_start_kwh = float(energy["total"]) await db.commit() _logger.info( - "[ENERGY] Recorded starting energy%s for archive %s: %s kWh", + "[ENERGY] Recorded starting energy%s for archive %s from plug '%s': %s kWh", f" ({context})" if context else "", archive.id, + plug.name, energy["total"], ) return True @@ -6345,17 +6354,23 @@ async def on_print_complete(printer_id: int, data: dict): logger.info("[ENERGY-BG] No start kWh recorded for archive %s", archive_id) return - plug_result = await db.execute(select(SmartPlug).where(SmartPlug.printer_id == printer_id)) - plug = plug_result.scalar_one_or_none() - if plug is None: + candidates = await energy_plug_candidates(db, printer_id) + if not candidates: logger.info("[ENERGY-BG] No smart plug for printer %s", printer_id) return - energy = await _get_plug_energy(plug, db) - logger.info("[ENERGY-BG] Energy response: %s", energy) - if not energy or energy.get("total") is None: - logger.warning("[ENERGY-BG] No 'total' in energy response") + # Same ordering as the start reading, so the delta below is + # against the counter that produced `starting_kwh` (#2859). + selected = await select_energy_reading(candidates, _get_plug_energy, db) + if selected is None: + logger.warning( + "[ENERGY-BG] No plug on printer %s reports a lifetime energy counter (tried: %s)", + printer_id, + ", ".join(plug.name for plug in candidates), + ) return + plug, energy = selected + logger.info("[ENERGY-BG] Energy response from plug '%s': %s", plug.name, energy) energy_used = round(energy["total"] - starting_kwh, 4) logger.info("[ENERGY-BG] Per-print energy: %s kWh", energy_used) diff --git a/backend/app/services/energy_plug.py b/backend/app/services/energy_plug.py new file mode 100644 index 000000000..e3ef67d88 --- /dev/null +++ b/backend/app/services/energy_plug.py @@ -0,0 +1,104 @@ +"""Which of a printer's plugs measures its energy? (#2859) + +Per-print energy is the delta of one plug's lifetime counter between print start +and print end, so both readings have to come from the same plug. The two call +sites used to assume a printer had exactly one: they selected every plug with +``SmartPlug.printer_id == printer_id`` and then called ``scalar_one_or_none()``. + +Nothing enforces that assumption. The plug API rejects a second *Tasmota* plug +on a printer and deliberately allows any number of Home Assistant entities -- +"allow multiple per printer (for different automations)" -- which is how a +filter fan, a dry box or a lights script ends up linked beside the printer's own +plug. On those installs the query returned two rows, ``scalar_one_or_none()`` +raised, the print-start handler caught it as just another failure and logged a +warning, and no archive on that printer ever carried an energy figure again. It +was silent because the print-end handler then reports "no start kWh recorded", +which reads exactly like "this printer has no plug". + +The rule below picks the printer's own plug without asking the user to nominate +one. ``controls_printer_power`` (#2629) already means "this plug really feeds +the printer" rather than an accessory that merely follows the print cycle, so it +ranks above one that does not, and the id breaks ties so the start and end +readings agree on the answer. The decisive test in practice is the last one: a +candidate has to actually report a lifetime counter to be chosen, and accessory +plugs are usually switch-only, so they drop out with nothing configured. + +Deliberately *not* enforced: one plug per printer. Bambuddy dropped the UNIQUE +constraint on ``smart_plugs.printer_id`` on purpose, and the flag defaults to on +for every existing plug, so clearing it to make it unique would change which +plugs may mark a printer offline on auto-off (#2629) -- not this module's +business. + +Equally deliberate: nothing is excluded, only ranked. A printer with one linked +plug used it whatever it was, and must keep doing so, so a disabled row or a +script still gets its turn once the plausible candidates have declined. +""" + +from __future__ import annotations + +from collections.abc import Awaitable, Callable + +from sqlalchemy import select +from sqlalchemy.ext.asyncio import AsyncSession + +from backend.app.models.smart_plug import SmartPlug + +# Reads a plug's energy dict, or None when the device did not answer. Injected +# rather than imported so this module stays independent of the plug-type +# dispatch that lives with the callers. +EnergyReader = Callable[[SmartPlug, AsyncSession], Awaitable[dict | None]] + + +def _is_script_entity(plug: SmartPlug) -> bool: + """A Home Assistant ``script.*`` entity linked to a printer for automation. + + Stored as plugs so they can follow the print cycle (see + ``trigger_associated_scripts``), but a script has nothing to meter. + """ + return bool(plug.plug_type == "homeassistant" and plug.ha_entity_id and plug.ha_entity_id.startswith("script.")) + + +def _rank(plug: SmartPlug) -> tuple: + """Sort key: least surprising source of a printer's meter first. + + Ranking rather than filtering, deliberately. A printer with exactly one + linked row behaved the same before this module existed whatever that row + was -- disabled, a script, an accessory -- and it has to keep behaving that + way, so nothing is excluded outright and every rejection is left to the one + test that cannot be wrong: does it actually report a counter. + """ + return ( + _is_script_entity(plug), + not plug.enabled, + not plug.controls_printer_power, + plug.id, + ) + + +async def energy_plug_candidates(db: AsyncSession, printer_id: int | None) -> list[SmartPlug]: + """Plugs on *printer_id* that could supply its energy counter, best first.""" + if printer_id is None: + # `printer_id == None` compiles to `IS NULL`, which would return every + # plug linked to no printer at all and bill a print against whichever + # one happened to answer. Callers are typed `int`, so this is a guard + # against a future one rather than a live path. + return [] + result = await db.execute(select(SmartPlug).where(SmartPlug.printer_id == printer_id)) + return sorted(result.scalars().all(), key=_rank) + + +async def select_energy_reading( + candidates: list[SmartPlug], + read_energy: EnergyReader, + db: AsyncSession, +) -> tuple[SmartPlug, dict] | None: + """First candidate that actually reports a lifetime counter, with its reading. + + Returns the reading alongside the plug so the caller does not poll twice -- + the value that decided the choice is the value it needs. + """ + for plug in candidates: + energy = await read_energy(plug, db) + if energy and energy.get("total") is not None: + return plug, energy + return None diff --git a/backend/tests/unit/test_energy_plug_selection_2859.py b/backend/tests/unit/test_energy_plug_selection_2859.py new file mode 100644 index 000000000..5cff8e920 --- /dev/null +++ b/backend/tests/unit/test_energy_plug_selection_2859.py @@ -0,0 +1,306 @@ +"""Energy tracking with more than one plug linked to a printer (#2859). + +The reporter had two Home Assistant plugs on a P1S -- its own plug plus a dry +box he wanted to switch from the printer card -- and no archive on that printer +ever carried an energy figure, while his single-plug X2D was fine. Both energy +call sites selected every plug for the printer and then called +``scalar_one_or_none()``, which raises on two rows; the print-start handler +caught that as an ordinary failure, so ``energy_start_kwh`` was never written +and the print-end handler reported "no start kWh recorded" -- indistinguishable +from having no plug at all. +""" + +from types import SimpleNamespace +from unittest.mock import AsyncMock, patch + +import pytest + +from backend.app.services.energy_plug import energy_plug_candidates, select_energy_reading + + +def _plug(plug_id: int, name: str, *, power: bool = True, ha_entity_id: str | None = None) -> SimpleNamespace: + return SimpleNamespace( + id=plug_id, + name=name, + controls_printer_power=power, + plug_type="homeassistant" if ha_entity_id else "tasmota", + ha_entity_id=ha_entity_id, + ) + + +class TestCandidateOrdering: + """Ordering has to be stable: the print-end delta is only meaningful if it + reads the same counter the print-start reading came from.""" + + @pytest.mark.asyncio + async def test_no_plugs_for_printer(self, db_session, printer_factory): + printer = await printer_factory() + + assert await energy_plug_candidates(db_session, printer.id) == [] + + @pytest.mark.asyncio + async def test_single_plug_is_the_candidate(self, db_session, printer_factory, smart_plug_factory): + printer = await printer_factory() + plug = await smart_plug_factory(name="P1S Power", printer_id=printer.id) + + candidates = await energy_plug_candidates(db_session, printer.id) + + assert [c.id for c in candidates] == [plug.id] + + @pytest.mark.asyncio + async def test_power_plug_sorts_ahead_of_earlier_accessory(self, db_session, printer_factory, smart_plug_factory): + printer = await printer_factory() + accessory = await smart_plug_factory( + name="Dry Box", + plug_type="homeassistant", + printer_id=printer.id, + controls_printer_power=False, + ) + power = await smart_plug_factory( + name="P1S Power", + plug_type="homeassistant", + printer_id=printer.id, + controls_printer_power=True, + ) + + candidates = await energy_plug_candidates(db_session, printer.id) + + assert [c.id for c in candidates] == [power.id, accessory.id] + + @pytest.mark.asyncio + async def test_ties_break_by_id(self, db_session, printer_factory, smart_plug_factory): + """`controls_printer_power` defaults to on, so two plugs claiming it is + the normal case rather than a misconfiguration.""" + printer = await printer_factory() + first = await smart_plug_factory(name="First", plug_type="homeassistant", printer_id=printer.id) + second = await smart_plug_factory(name="Second", plug_type="homeassistant", printer_id=printer.id) + + candidates = await energy_plug_candidates(db_session, printer.id) + + assert [c.id for c in candidates] == [first.id, second.id] + + @pytest.mark.asyncio + async def test_other_printers_plugs_are_not_candidates(self, db_session, printer_factory, smart_plug_factory): + mine = await printer_factory(name="P1S") + theirs = await printer_factory(name="X2D") + plug = await smart_plug_factory(name="P1S Power", printer_id=mine.id) + await smart_plug_factory(name="X2D Power", printer_id=theirs.id) + + candidates = await energy_plug_candidates(db_session, mine.id) + + assert [c.id for c in candidates] == [plug.id] + + @pytest.mark.asyncio + async def test_unlinked_plug_is_not_a_candidate(self, db_session, printer_factory, smart_plug_factory): + printer = await printer_factory() + await smart_plug_factory(name="Bench Plug", printer_id=None) + + assert await energy_plug_candidates(db_session, printer.id) == [] + + @pytest.mark.asyncio + async def test_no_printer_matches_nothing(self, db_session, smart_plug_factory): + """`printer_id == None` would compile to `IS NULL` and hand back every + unlinked plug, so a print could be billed against a bench plug.""" + await smart_plug_factory(name="Bench Plug", printer_id=None) + + assert await energy_plug_candidates(db_session, None) == [] + + @pytest.mark.asyncio + async def test_disabled_plug_sorts_last(self, db_session, printer_factory, smart_plug_factory): + printer = await printer_factory() + retired = await smart_plug_factory( + name="Retired Plug", + plug_type="homeassistant", + printer_id=printer.id, + enabled=False, + ) + live = await smart_plug_factory(name="P1S Power", plug_type="homeassistant", printer_id=printer.id) + + candidates = await energy_plug_candidates(db_session, printer.id) + + assert [c.id for c in candidates] == [live.id, retired.id] + + @pytest.mark.asyncio + async def test_only_plug_is_used_even_when_disabled(self, db_session, printer_factory, smart_plug_factory): + """Ranking, not filtering: a printer whose single plug is disabled + tracked energy before this module existed and has to keep doing so.""" + printer = await printer_factory() + retired = await smart_plug_factory(name="Retired Plug", printer_id=printer.id, enabled=False) + + candidates = await energy_plug_candidates(db_session, printer.id) + + assert [c.id for c in candidates] == [retired.id] + + @pytest.mark.asyncio + async def test_home_assistant_script_sorts_last(self, db_session, printer_factory, smart_plug_factory): + """A `script.*` entity is linked for the automation triggers and has + nothing to meter, so it is asked only if nothing else answers.""" + printer = await printer_factory() + script = await smart_plug_factory( + name="Notify Script", + plug_type="homeassistant", + ha_entity_id="script.notify_done", + printer_id=printer.id, + ) + plug = await smart_plug_factory( + name="P1S Power", + plug_type="homeassistant", + ha_entity_id="switch.p1s", + printer_id=printer.id, + enabled=False, + ) + + candidates = await energy_plug_candidates(db_session, printer.id) + + # Even disabled, a real switch outranks a script. + assert [c.id for c in candidates] == [plug.id, script.id] + + +class TestSelectEnergyReading: + @pytest.mark.asyncio + async def test_picks_the_plug_that_reports_a_counter(self): + """The decisive test in practice: an accessory is usually switch-only, + so it drops out without the user configuring anything.""" + dry_box = _plug(1, "Dry Box") + printer_plug = _plug(2, "P1S Power") + + async def read(plug, _db): + return {"power": 3.0} if plug is dry_box else {"power": 120.0, "total": 41.5} + + selected = await select_energy_reading([dry_box, printer_plug], read, db=None) + + assert selected is not None + plug, energy = selected + assert plug is printer_plug + assert energy["total"] == 41.5 + + @pytest.mark.asyncio + async def test_stops_at_the_first_usable_reading(self): + first = _plug(1, "P1S Power") + second = _plug(2, "Dry Box") + seen = [] + + async def read(plug, _db): + seen.append(plug.name) + return {"total": 1.0} + + selected = await select_energy_reading([first, second], read, db=None) + + assert selected[0] is first + assert seen == ["P1S Power"] + + @pytest.mark.asyncio + async def test_unreachable_plug_does_not_end_the_search(self): + offline = _plug(1, "Offline") + printer_plug = _plug(2, "P1S Power") + + async def read(plug, _db): + return None if plug is offline else {"total": 7.0} + + selected = await select_energy_reading([offline, printer_plug], read, db=None) + + assert selected[0] is printer_plug + + @pytest.mark.asyncio + async def test_zero_is_a_reading(self): + """A freshly reset counter is a perfectly good baseline; treating 0 as + missing would drop the first print after a plug replacement.""" + plug = _plug(1, "P1S Power") + + selected = await select_energy_reading([plug], AsyncMock(return_value={"total": 0.0}), db=None) + + assert selected is not None + assert selected[1]["total"] == 0.0 + + @pytest.mark.asyncio + async def test_none_when_nothing_reports_a_counter(self): + async def read(_plug, _db): + return {"power": 3.0, "total": None} + + assert await select_energy_reading([_plug(1, "Dry Box")], read, db=None) is None + + @pytest.mark.asyncio + async def test_none_for_an_empty_candidate_list(self): + assert await select_energy_reading([], AsyncMock(), db=None) is None + + +class TestRecordEnergyStart: + """The reported failure, end to end.""" + + @pytest.mark.asyncio + async def test_two_plugs_no_longer_lose_the_start_reading( + self, db_session, printer_factory, smart_plug_factory, archive_factory + ): + printer = await printer_factory() + await smart_plug_factory( + name="Dry Box", + plug_type="homeassistant", + printer_id=printer.id, + controls_printer_power=False, + ) + await smart_plug_factory( + name="P1S Power", + plug_type="homeassistant", + printer_id=printer.id, + controls_printer_power=True, + ) + archive = await archive_factory(printer.id) + + from backend.app.main import _record_energy_start + + async def read(plug, _db): + return {"power": 120.0, "total": 41.5} if plug.name == "P1S Power" else {"power": 2.0} + + with patch("backend.app.main._get_plug_energy", side_effect=read): + recorded = await _record_energy_start(archive, printer.id, db_session) + + assert recorded is True + assert archive.energy_start_kwh == 41.5 + + @pytest.mark.asyncio + async def test_single_plug_is_unchanged(self, db_session, printer_factory, smart_plug_factory, archive_factory): + printer = await printer_factory() + await smart_plug_factory(name="X2D Power", printer_id=printer.id) + archive = await archive_factory(printer.id) + + from backend.app.main import _record_energy_start + + with patch("backend.app.main._get_plug_energy", AsyncMock(return_value={"total": 12.25})): + recorded = await _record_energy_start(archive, printer.id, db_session) + + assert recorded is True + assert archive.energy_start_kwh == 12.25 + + @pytest.mark.asyncio + async def test_no_plug_records_nothing(self, db_session, printer_factory, archive_factory): + printer = await printer_factory() + archive = await archive_factory(printer.id) + + from backend.app.main import _record_energy_start + + recorded = await _record_energy_start(archive, printer.id, db_session) + + assert recorded is False + assert archive.energy_start_kwh is None + + @pytest.mark.asyncio + async def test_names_the_plugs_it_tried_when_none_measures( + self, db_session, printer_factory, smart_plug_factory, archive_factory, capture_logs + ): + """ "No plug reports energy" and "no plug at all" used to log the same + way, which is what made this invisible for the reporter.""" + printer = await printer_factory() + await smart_plug_factory(name="Dry Box", plug_type="homeassistant", printer_id=printer.id) + await smart_plug_factory(name="Chamber Light", plug_type="homeassistant", printer_id=printer.id) + archive = await archive_factory(printer.id) + + from backend.app.main import _record_energy_start + + with patch("backend.app.main._get_plug_energy", AsyncMock(return_value={"power": 1.0})): + recorded = await _record_energy_start(archive, printer.id, db_session) + + assert recorded is False + assert archive.energy_start_kwh is None + logged = "\n".join(record.getMessage() for record in capture_logs.get_warnings()) + assert "Dry Box" in logged + assert "Chamber Light" in logged diff --git a/frontend/src/pages/SettingsPage.tsx b/frontend/src/pages/SettingsPage.tsx index dc984af97..b1a6c4bbf 100644 --- a/frontend/src/pages/SettingsPage.tsx +++ b/frontend/src/pages/SettingsPage.tsx @@ -378,14 +378,19 @@ export function SettingsPage() { for (const { plug, status } of statuses) { // For MQTT plugs, consider reachable if we have power data const hasMqttData = plug.plug_type === 'mqtt' && (status?.energy?.power != null); - const isReachable = (status?.reachable || hasMqttData) && status?.energy; + // Reachability is about the device answering, not about it measuring + // anything. Requiring `status.energy` here counted a perfectly online + // switch-only plug -- no power sensor, so the backend leaves `energy` + // null -- as offline, and the counter labelled "plugs online" quietly + // reported "plugs reporting energy" instead (#2859). + const isReachable = status?.reachable || hasMqttData; if (isReachable) { reachableCount++; - if (status.energy?.power != null) totalPower += status.energy.power; - if (status.energy?.today != null) totalToday += status.energy.today; - if (status.energy?.yesterday != null) totalYesterday += status.energy.yesterday; - if (status.energy?.total != null) totalLifetime += status.energy.total; + if (status?.energy?.power != null) totalPower += status.energy.power; + if (status?.energy?.today != null) totalToday += status.energy.today; + if (status?.energy?.yesterday != null) totalYesterday += status.energy.yesterday; + if (status?.energy?.total != null) totalLifetime += status.energy.total; } } diff --git a/static/assets/index-Q-Fl-YCy.js b/static/assets/index-CXdmGala.js similarity index 96% rename from static/assets/index-Q-Fl-YCy.js rename to static/assets/index-CXdmGala.js index c31ff912d..a8e6b88e4 100644 --- a/static/assets/index-Q-Fl-YCy.js +++ b/static/assets/index-CXdmGala.js @@ -4381,7 +4381,7 @@ ${t.slice(l+2)}`,d+=1;else break}t.push({indent:l,number:parseInt(s,10),content: "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,G.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,G.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,G.jsxs)(Q,{onClick:p,disabled:u.isPending,children:[u.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(ys,{className:`w-4 h-4`}),e(`common.save`)||`Save`]}),(0,G.jsxs)(Q,{variant:`secondary`,onClick:()=>f.mutate(),disabled:f.isPending,children:[f.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Yl,{className:`w-4 h-4`}),e(`settings.ldap.testConnection`)||`Test Connection`]})]})]})})]})]})}function S8({value:e,onChange:t,placeholder:n,maxLength:r=6}){return(0,G.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 C8({codes:e,onDone:t}){let{t:n}=U(),[r,i]=(0,y.useState)(!1);return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`div`,{className:`bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/30 rounded-lg p-4`,children:(0,G.jsx)(`p`,{className:`text-amber-700 dark:text-amber-400 text-sm font-medium`,children:n(`settings.twoFa.backupCodesWarning`)})}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:e.map((e,t)=>(0,G.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,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(e.join(` -`)),i(!0),setTimeout(()=>i(!1),2e3)},className:`flex items-center gap-2`,children:[(0,G.jsx)(zs,{className:`w-4 h-4`}),n(r?`common.copied`:`common.copy`)]}),(0,G.jsx)(Q,{variant:`primary`,size:`sm`,onClick:t,className:`flex-1`,children:n(`settings.twoFa.savedCodes`)})]})]})}function NHe({onDone:e}){let{t}=U(),n=so(),{showToast:r}=zd(),[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}=K({queryKey:[`totp-setup`],queryFn:()=>Z.setupTOTP(),staleTime:1/0}),m=q({mutationFn:e=>Z.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,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(Rl,{className:`w-6 h-6 animate-spin text-bambu-green`})}):i===`qr`?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:t(`settings.twoFa.setupInstructions`)}),(0,G.jsx)(`div`,{className:`flex justify-center`,children:(0,G.jsx)(`img`,{src:`data:image/png;base64,${f.qr_code_b64}`,alt:`TOTP QR Code`,className:`w-48 h-48 rounded-lg`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:t(`settings.twoFa.manualEntry`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 bg-bambu-dark-secondary rounded-lg px-3 py-2`,children:[(0,G.jsx)(`code`,{className:`text-white text-xs font-mono flex-1 break-all`,children:u?f.secret:`••••••••••••••••`}),(0,G.jsx)(`button`,{onClick:()=>d(!u),className:`text-bambu-gray hover:text-white`,children:u?(0,G.jsx)(tc,{className:`w-4 h-4`}):(0,G.jsx)(nc,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(f.secret)},className:`text-bambu-gray hover:text-white`,children:(0,G.jsx)(zs,{className:`w-4 h-4`})})]})]}),(0,G.jsx)(Q,{variant:`primary`,className:`w-full`,onClick:()=>a(`confirm`),children:t(`settings.twoFa.scannedContinue`)})]}):i===`confirm`?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:t(`settings.twoFa.enterCodeToConfirm`)}),(0,G.jsx)(S8,{value:o,onChange:s,placeholder:`000000`}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>a(`qr`),className:`flex-1`,children:t(`common.back`)}),(0,G.jsx)(Q,{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,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`h3`,{className:`text-white font-medium`,children:t(`settings.twoFa.backupCodesTitle`)}),(0,G.jsx)(C8,{codes:c,onDone:e})]})}function PHe(){let{t:e}=U(),t=so(),{showToast:n}=zd(),{user:r}=Td(),[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}=K({queryKey:[`2fa-status`],queryFn:()=>Z.get2FAStatus()}),{data:k}=K({queryKey:[`oidc-links`],queryFn:()=>Z.getOIDCLinks()}),A=q({mutationFn:()=>Z.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=q({mutationFn:()=>Z.confirmEnableEmailOTP(g,v),onSuccess:()=>{t.invalidateQueries({queryKey:[`2fa-status`]}),_(null),b(``),n(e(`settings.twoFa.emailOtpEnabled`),`success`)},onError:e=>n(e.message,`error`)}),M=q({mutationFn:e=>Z.disableEmailOTP(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`2fa-status`]}),S(!1),w(``),n(e(`settings.twoFa.emailOtpDisabled`),`success`)},onError:e=>n(e.message,`error`)}),N=q({mutationFn:e=>Z.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=q({mutationFn:e=>Z.regenerateBackupCodes(e),onSuccess:e=>{t.invalidateQueries({queryKey:[`2fa-status`]}),l(!1),p(``),h(e.backup_codes)},onError:()=>n(e(`settings.twoFa.invalidCode`),`error`)}),F=q({mutationFn:e=>Z.deleteOIDCLink(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-links`]}),n(e(`settings.twoFa.oidcUnlinked`),`success`)},onError:e=>n(e.message,`error`)});if(O)return(0,G.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,G.jsx)(Rl,{className:`w-6 h-6 animate-spin text-bambu-green`})});let I=!!r?.email;return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(jd,{id:`card-2fa-totp`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center ${D?.totp_enabled?`bg-green-100 dark:bg-green-500/20`:`bg-gray-500/20`}`,children:(0,G.jsx)(uu,{className:`w-5 h-5 ${D?.totp_enabled?`text-green-600 dark:text-green-400`:`text-gray-400`}`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.twoFa.totpTitle`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:e(`settings.twoFa.totpDesc`)})]}),(0,G.jsx)(`div`,{className:`ml-auto`,children:D?.totp_enabled?(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-green-700 dark:text-green-400 text-sm font-medium`,children:[(0,G.jsx)(tu,{className:`w-4 h-4`}),` `,e(`common.enabled`)]}):(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-gray text-sm`,children:[(0,G.jsx)(nu,{className:`w-4 h-4`}),` `,e(`common.disabled`)]})})]})}),(0,G.jsx)(Nd,{children:i?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsx)(`h4`,{className:`text-white font-medium`,children:e(`settings.twoFa.setupAuthApp`)}),(0,G.jsx)(`button`,{onClick:()=>{a(!1),t.removeQueries({queryKey:[`totp-setup`]})},className:`text-bambu-gray hover:text-white`,children:(0,G.jsx)(Qu,{className:`w-5 h-5`})})]}),(0,G.jsx)(NHe,{onDone:()=>{a(!1),t.removeQueries({queryKey:[`totp-setup`]})}})]}):o?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.disableConfirmHint`)}),(0,G.jsx)(S8,{value:u,onChange:d,placeholder:`000000 or XXXXXXXX`,maxLength:8}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{s(!1),d(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,G.jsx)(Q,{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,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.regenBackupHint`)}),(0,G.jsx)(S8,{value:f,onChange:p,placeholder:`000000 or XXXXXXXX`,maxLength:8}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{l(!1),p(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,G.jsx)(Q,{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,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`h4`,{className:`text-white font-medium`,children:e(`settings.twoFa.newBackupCodes`)}),(0,G.jsx)(C8,{codes:m,onDone:()=>h(null)})]}):(0,G.jsx)(`div`,{className:`space-y-3`,children:D?.totp_enabled?(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray-light`,children:[(0,G.jsx)(Vc,{className:`w-4 h-4`}),e(`settings.twoFa.backupCodesRemaining`,{count:D.backup_codes_remaining})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>l(!0),className:`flex items-center gap-2`,children:[(0,G.jsx)(Rl,{className:`w-4 h-4`}),e(`settings.twoFa.regenBackup`)]}),(0,G.jsxs)(Q,{variant:`danger`,size:`sm`,onClick:()=>s(!0),className:`flex items-center gap-2`,children:[(0,G.jsx)(Au,{className:`w-4 h-4`}),e(`settings.twoFa.disableTotp`)]})]}):(0,G.jsxs)(Q,{variant:`primary`,onClick:()=>a(!0),className:`flex items-center gap-2`,children:[(0,G.jsx)(uu,{className:`w-4 h-4`}),e(`settings.twoFa.setupTotp`)]})})})]}),(0,G.jsxs)(jd,{id:`card-2fa-emailotp`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center ${D?.email_otp_enabled?`bg-green-100 dark:bg-green-500/20`:`bg-gray-500/20`}`,children:(0,G.jsx)(tl,{className:`w-5 h-5 ${D?.email_otp_enabled?`text-green-600 dark:text-green-400`:`text-gray-400`}`})}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.twoFa.emailOtpTitle`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:I?e(`settings.twoFa.emailOtpDesc`,{email:r?.email}):e(`settings.twoFa.emailOtpNoEmail`)})]}),(0,G.jsx)(`div`,{className:`ml-auto`,children:D?.email_otp_enabled?(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-green-700 dark:text-green-400 text-sm font-medium`,children:[(0,G.jsx)(tu,{className:`w-4 h-4`}),` `,e(`common.enabled`)]}):(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-gray text-sm`,children:[(0,G.jsx)(nu,{className:`w-4 h-4`}),` `,e(`common.disabled`)]})})]})}),(0,G.jsx)(Nd,{children:I?g?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.emailSetupEnterCode`)}),(0,G.jsx)(S8,{value:v,onChange:b,placeholder:`000000`}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{_(null),b(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,G.jsx)(Q,{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,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.emailDisablePasswordHint`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.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,G.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,G.jsx)(tc,{className:`w-5 h-5`}):(0,G.jsx)(nc,{className:`w-5 h-5`})})]}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{S(!1),w(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,G.jsx)(Q,{variant:`danger`,className:`flex-1`,disabled:!C||M.isPending,onClick:()=>M.mutate(C),children:M.isPending?e(`common.saving`):e(`settings.twoFa.disableEmailOtp`)})]})]}):(0,G.jsx)(`div`,{className:`flex gap-3`,children:D?.email_otp_enabled?(0,G.jsxs)(Q,{variant:`danger`,size:`sm`,onClick:()=>S(!0),className:`flex items-center gap-2`,children:[(0,G.jsx)(Au,{className:`w-4 h-4`}),e(`settings.twoFa.disableEmailOtp`)]}):(0,G.jsxs)(Q,{variant:`primary`,disabled:!I||A.isPending,onClick:()=>A.mutate(),className:`flex items-center gap-2`,children:[(0,G.jsx)(tl,{className:`w-4 h-4`}),A.isPending?e(`common.saving`):e(`settings.twoFa.enableEmailOtp`)]})}):(0,G.jsx)(`p`,{className:`text-amber-700 dark:text-amber-400 text-sm`,children:e(`settings.twoFa.addEmailFirst`)})})]}),k&&k.length>0&&(0,G.jsxs)(jd,{id:`card-2fa-linked`,children:[(0,G.jsxs)(Md,{children:[(0,G.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.twoFa.linkedAccounts`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:e(`settings.twoFa.linkedAccountsDesc`)})]}),(0,G.jsx)(Nd,{children:(0,G.jsx)(`div`,{className:`space-y-3`,children:k.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between py-2 border-b border-bambu-dark-tertiary last:border-0`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm font-medium`,children:e.provider_name}),e.provider_email&&(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:e.provider_email})]}),(0,G.jsx)(Q,{variant:`danger`,size:`sm`,onClick:()=>F.mutate(e.provider_id),disabled:F.isPending,children:(0,G.jsx)(Au,{className:`w-4 h-4`})})]},e.id))})})]})]})}var FHe={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,is_autologin:!1};function w8({initial:e,isEdit:t=!1,groups:n=[],onSave:r,onCancel:i,isPending:a}){let{t:o}=U(),[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,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:o(`settings.oidc.form.requireEmailVerifiedWarning`)}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.name`),` `,(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:`*`})]}),(0,G.jsx)(`input`,{className:f,value:s.name,onChange:e=>d(`name`,e.target.value),placeholder:`Google`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.issuerUrl`),` `,(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:`*`})]}),(0,G.jsx)(`input`,{className:f,value:s.issuer_url,onChange:e=>d(`issuer_url`,e.target.value),placeholder:`https://accounts.google.com`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.clientId`),` `,(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:`*`})]}),(0,G.jsx)(`input`,{className:f,value:s.client_id,onChange:e=>d(`client_id`,e.target.value),placeholder:`your-client-id`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.clientSecret`),!t&&(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:` *`}),t&&(0,G.jsxs)(`span`,{className:`text-bambu-gray text-xs ml-1`,children:[`(`,o(`settings.oidc.form.secretHint`),`)`]})]}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:p,children:o(`settings.oidc.form.scopes`)}),(0,G.jsx)(`input`,{className:f,value:s.scopes,onChange:e=>d(`scopes`,e.target.value),placeholder:`openid email profile`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:p,children:o(`settings.oidc.form.iconUrl`)}),(0,G.jsx)(`input`,{className:f,value:s.icon_url??``,onChange:e=>d(`icon_url`,e.target.value===``?null:e.target.value),placeholder:`https://...`})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-6 pt-2`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(EU,{checked:s.is_enabled??!0,onChange:e=>d(`is_enabled`,e)}),(0,G.jsx)(`span`,{className:`text-white text-sm`,children:o(`settings.oidc.form.enabled`)})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(EU,{checked:s.auto_create_users??!1,onChange:e=>d(`auto_create_users`,e)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm`,children:o(`settings.oidc.form.autoCreate`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:o(`settings.oidc.form.autoCreateDesc`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer w-full`,children:[(0,G.jsx)(EU,{checked:s.auto_link_existing_accounts??!1,onChange:e=>d(`auto_link_existing_accounts`,e)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm`,children:o(`settings.oidc.form.autoLink`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:o(`settings.oidc.form.autoLinkDesc`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer w-full`,children:[(0,G.jsx)(EU,{checked:g,onChange:e=>d(`require_email_verified`,e),disabled:h}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm`,children:o(`settings.oidc.form.requireEmailVerified`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:_})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer w-full`,children:[(0,G.jsx)(EU,{checked:s.is_autologin??!1,onChange:e=>d(`is_autologin`,e)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm`,children:o(`settings.oidc.form.autologin`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:o(`settings.oidc.form.autologinDesc`)})]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:p,children:o(`settings.oidc.form.emailClaim`)}),(0,G.jsx)(`input`,{className:f,value:s.email_claim,onChange:e=>d(`email_claim`,e.target.value||`email`),placeholder:o(`settings.oidc.form.emailClaimPlaceholder`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:o(`settings.oidc.form.emailClaimDesc`)}),h&&s.email_claim!==`email`&&(0,G.jsx)(`p`,{className:`text-yellow-700 dark:text-yellow-400 text-xs mt-1`,children:o(`settings.oidc.form.emailClaimCustomClaimAutoLinkWarning`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:p,children:o(`settings.oidc.form.defaultGroup`)}),(0,G.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,G.jsx)(`option`,{value:``,children:o(`settings.oidc.form.defaultGroupViewersFallback`)}),n.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:o(`settings.oidc.form.defaultGroupDesc`)})]}),(0,G.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:i,className:`flex-1`,children:o(`common.cancel`)}),(0,G.jsx)(Q,{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 IHe({provider:e}){let[t,n]=(0,y.useState)(!1);return e.has_icon&&!t?(0,G.jsx)(`img`,{src:Z.oidcProviderIconUrl(e.id),alt:e.name,className:`w-8 h-8 rounded object-contain`,onError:()=>n(!0)}):(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,G.jsx)(Ec,{className:`w-4 h-4 text-bambu-gray`})})}function LHe(){let{t:e}=U(),t=so(),{showToast:n}=zd(),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(null),{data:l,isLoading:u}=K({queryKey:[`oidc-providers-all`],queryFn:()=>Z.getOIDCProvidersAll()}),{data:d=[]}=K({queryKey:[`groups`],queryFn:()=>Z.getGroups()}),f=q({mutationFn:e=>Z.createOIDCProvider(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-providers-all`]}),i(!1),n(e(`settings.oidc.created`),`success`)},onError:e=>n(e.message,`error`)}),p=q({mutationFn:({id:e,data:t})=>Z.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=q({mutationFn:e=>Z.deleteOIDCProvider(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-providers-all`]}),c(null),n(e(`settings.oidc.deleted`),`success`)},onError:e=>n(e.message,`error`)}),h=q({mutationFn:e=>Z.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=q({mutationFn:e=>Z.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,G.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,G.jsx)(Rl,{className:`w-6 h-6 animate-spin text-bambu-green`})}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(jd,{id:`card-oidc`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.oidc.title`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:e(`settings.oidc.desc`)})]}),!r&&(0,G.jsxs)(Q,{variant:`primary`,size:`sm`,onClick:()=>i(!0),className:`flex items-center gap-2`,children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),e(`settings.oidc.addProvider`)]})]})}),r&&(0,G.jsx)(Nd,{children:(0,G.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:[(0,G.jsx)(`h4`,{className:`text-white font-medium mb-4`,children:e(`settings.oidc.newProvider`)}),(0,G.jsx)(w8,{initial:FHe,groups:d,onSave:e=>f.mutate(e),onCancel:()=>i(!1),isPending:f.isPending})]})})]}),l&&l.length===0&&!r&&(0,G.jsx)(jd,{id:`card-oidc-empty`,children:(0,G.jsx)(Nd,{children:(0,G.jsxs)(`div`,{className:`text-center py-8 space-y-3`,children:[(0,G.jsx)(Ec,{className:`w-12 h-12 text-bambu-gray mx-auto`}),(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`settings.oidc.empty`)}),(0,G.jsxs)(Q,{variant:`primary`,size:`sm`,onClick:()=>i(!0),className:`inline-flex items-center gap-2`,children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),e(`settings.oidc.addProvider`)]})]})})}),l?.map(t=>(0,G.jsxs)(jd,{children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(IHe,{provider:t}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h4`,{className:`text-white font-medium`,children:t.name}),t.is_enabled?(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-green-700 dark:text-green-400 bg-green-50 dark:bg-green-400/10 px-2 py-0.5 rounded-full`,children:[(0,G.jsx)(us,{className:`w-3 h-3`}),` `,e(`common.enabled`)]}):(0,G.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,G.jsx)(Qu,{className:`w-3 h-3`}),` `,e(`common.disabled`)]}),t.is_env_managed&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-bambu-green`,children:[(0,G.jsx)(Qc,{className:`w-3 h-3`}),` `,e(`settings.environmentManagedLabel`)]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 text-bambu-gray text-xs mt-0.5`,children:[(0,G.jsx)(ec,{className:`w-3 h-3`}),(0,G.jsx)(`span`,{children:t.issuer_url})]})]}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:!t.is_env_managed&&(0,G.jsxs)(G.Fragment,{children:[t.icon_url&&(0,G.jsx)(Q,{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,G.jsx)(Rl,{className:`w-4 h-4 ${h.isPending?`animate-spin`:``}`})}),t.has_icon&&(0,G.jsx)(Q,{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,G.jsx)(Ic,{className:`w-4 h-4`})}),(0,G.jsx)(EU,{checked:t.is_enabled,onChange:()=>_(t),disabled:p.isPending}),(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>o(a===t.id?null:t.id),"data-testid":`edit-provider-${t.id}`,children:(0,G.jsx)(Tl,{className:`w-4 h-4`})}),(0,G.jsx)(Q,{variant:`danger`,size:`sm`,onClick:()=>c(t),"data-testid":`delete-provider-${t.id}`,children:(0,G.jsx)(Au,{className:`w-4 h-4`})})]})})]})}),a===t.id&&(0,G.jsx)(Nd,{children:(0,G.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:(0,G.jsx)(w8,{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,is_autologin:t.is_autologin},onSave:e=>p.mutate({id:t.id,data:e}),onCancel:()=>o(null),isPending:p.isPending})})}),a!==t.id&&(0,G.jsx)(Nd,{children:(0,G.jsxs)(`dl`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-x-6 gap-y-2 text-sm`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.clientId`)}),(0,G.jsx)(`dd`,{className:`text-white font-mono truncate`,children:t.client_id})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.scopes`)}),(0,G.jsx)(`dd`,{className:`text-white`,children:t.scopes})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.autoCreate`)}),(0,G.jsx)(`dd`,{className:t.auto_create_users?`text-green-700 dark:text-green-400`:`text-bambu-gray`,children:t.auto_create_users?e(`common.yes`):e(`common.no`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.autoLink`)}),(0,G.jsx)(`dd`,{className:t.auto_link_existing_accounts?`text-green-700 dark:text-green-400`:`text-bambu-gray`,children:t.auto_link_existing_accounts?e(`common.yes`):e(`common.no`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.emailClaim`)}),(0,G.jsx)(`dd`,{className:`text-white font-mono`,children:t.email_claim})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.requireEmailVerified`)}),(0,G.jsx)(`dd`,{className:t.require_email_verified?`text-green-700 dark:text-green-400`:`text-red-700 dark:text-red-400`,children:t.require_email_verified?e(`common.yes`):e(`common.no`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.defaultGroup`)}),(0,G.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,G.jsx)(Xd,{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 T8=new Map;function E8(e){T8.set(e.anchor,e)}function RHe(){return Array.from(T8.values())}E8({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 zHe(){let{t:e}=U(),{data:t,isLoading:n,isError:r,refetch:i}=K({queryKey:[`encryptionStatus`],queryFn:()=>Z.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,G.jsxs)(jd,{id:`card-mfa-encryption`,"data-testid":`encryption-status-card`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ru,{className:`text-bambu-gray`,size:20}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`settings.encryption.title`)})]})}),(0,G.jsx)(Nd,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,"data-testid":`encryption-loading`,children:[(0,G.jsx)(Y,{className:`animate-spin`,size:16}),(0,G.jsx)(`span`,{children:e(`common.loading`)})]})})]});if(r||!t)return(0,G.jsxs)(jd,{id:`card-mfa-encryption`,"data-testid":`encryption-status-card`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ru,{className:`text-bambu-gray`,size:20}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`settings.encryption.title`)})]})}),(0,G.jsxs)(Nd,{children:[(0,G.jsx)(`div`,{className:`text-red-700 dark:text-red-400`,"data-testid":`encryption-error`,children:e(`common.errorLoading`)}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(),className:`mt-2 text-sm text-blue-700 dark:text-blue-400 underline hover:text-blue-800 dark: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-100 dark:bg-red-500/20 border-red-400 dark:border-red-500/50 text-red-700 dark:text-red-400`,c=(0,G.jsx)(Ts,{className:`text-red-600 dark:text-red-400`,size:20}),l=e(`settings.encryption.decryptionBrokenTitle`),u=e(`settings.encryption.decryptionBrokenError`,{count:o})):t.key_source===`generated`?(s=`bg-amber-50 dark:bg-amber-500/10 border-amber-300 dark:border-amber-500/30 text-amber-700 dark:text-amber-400`,c=(0,G.jsx)(tu,{className:`text-amber-600 dark:text-amber-400`,size:20}),l=e(`settings.encryption.enabledGenerated`),u=e(`settings.encryption.backupHint`)):a>0?(s=`bg-amber-50 dark:bg-amber-500/10 border-amber-300 dark:border-amber-500/30 text-amber-700 dark:text-amber-400`,c=(0,G.jsx)(Nu,{className:`text-amber-600 dark: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-100 dark:bg-green-500/20 border-green-300 dark:border-green-500/30 text-green-700 dark:text-green-400`,c=(0,G.jsx)(tu,{className:`text-green-600 dark: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,G.jsx)(nu,{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,G.jsxs)(jd,{id:`card-mfa-encryption`,"data-testid":`encryption-status-card`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c,(0,G.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`settings.encryption.title`)})]})}),(0,G.jsxs)(Nd,{children:[(0,G.jsxs)(`div`,{className:`p-3 border rounded-lg ${s}`,"data-testid":`encryption-status`,children:[(0,G.jsx)(`p`,{className:`font-medium mb-1`,children:l}),(0,G.jsx)(`p`,{className:`text-sm`,children:u})]}),d&&(0,G.jsx)(`div`,{className:`mt-2 p-3 border rounded-lg bg-amber-50 dark:bg-amber-500/10 border-amber-300 dark:border-amber-500/30 text-amber-700 dark:text-amber-400`,"data-testid":`encryption-legacy-warning`,children:(0,G.jsx)(`p`,{className:`text-sm`,children:e(`settings.encryption.legacyRowsWarning`,{count:a})})}),t.migration_error_count>0&&(0,G.jsx)(`div`,{className:`mt-2 p-3 border rounded-lg bg-amber-50 dark:bg-amber-500/10 border-amber-300 dark:border-amber-500/30 text-amber-700 dark:text-amber-400`,"data-testid":`encryption-migration-warning`,children:(0,G.jsx)(`p`,{className:`text-sm`,children:e(`settings.encryption.migrationErrorWarning`,{count:t.migration_error_count})})}),(0,G.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-4 text-sm`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`settings.encryption.encryptedRowsLabel`)}),(0,G.jsxs)(`p`,{className:`font-medium`,children:[`OIDC: `,t.encrypted_rows.oidc_providers,` · TOTP: `,t.encrypted_rows.user_totp]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`settings.encryption.legacyRowsLabel`)}),(0,G.jsxs)(`p`,{className:`font-medium`,children:[`OIDC: `,t.legacy_plaintext_rows.oidc_providers,` · TOTP: `,t.legacy_plaintext_rows.user_totp]})]})]})]})]})}var BHe={get:`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400 border-blue-300 dark:border-blue-500/30`,post:`bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-400 border-green-300 dark:border-green-500/30`,put:`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400 border-yellow-300 dark:border-yellow-500/30`,patch:`bg-orange-100 dark:bg-orange-500/20 text-orange-700 dark:text-orange-400 border-orange-300 dark:border-orange-500/30`,delete:`bg-red-100 dark:bg-red-500/20 text-red-700 dark:text-red-400 border-red-300 dark:border-red-500/30`};function VHe(e,t){let n=t.replace(`#/`,``).split(`/`),r=e;for(let e of n)r=r[e];return r}function D8(e,t,n=0){if(n>5)return`...`;if(t.$ref)return D8(e,VHe(e,t.$ref),n+1);if(t.allOf){let r={};for(let i of t.allOf){let t=D8(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?[D8(e,t.items,n+1)]:[];case`object`:if(t.properties){let r={};for(let[i,a]of Object.entries(t.properties))r[i]=D8(e,a,n+1);return r}return{};default:return null}}function HHe({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=D8(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,G.jsxs)(`div`,{className:`border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:[(0,G.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,G.jsx)(ds,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}):(0,G.jsx)(fs,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,G.jsx)(`span`,{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${BHe[t]||`bg-gray-500/20 text-gray-400`}`,children:t}),(0,G.jsx)(`code`,{className:`text-sm text-white font-mono flex-1 truncate`,children:e}),n.summary&&(0,G.jsx)(`span`,{className:`text-sm text-bambu-gray truncate max-w-[40%]`,children:n.summary})]}),a&&(0,G.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50`,children:[n.description&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n.description}),x.length>0&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:`Path Parameters`}),(0,G.jsx)(`div`,{className:`space-y-2`,children:x.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`label`,{className:`text-sm text-bambu-gray w-32 flex-shrink-0`,children:[e.name,e.required&&(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400 ml-1`,children:`*`})]}),(0,G.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,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:`Query Parameters`}),(0,G.jsx)(`div`,{className:`space-y-2`,children:S.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`label`,{className:`text-sm text-bambu-gray w-32 flex-shrink-0`,children:[e.name,e.required&&(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400 ml-1`,children:`*`})]}),e.schema?.enum?(0,G.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,G.jsx)(`option`,{value:``,children:`-- Select --`}),e.schema.enum.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]}):(0,G.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,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:`Request Body`}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(Q,{onClick:v,disabled:p,children:[p?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(kl,{className:`w-4 h-4`}),`Execute`]}),_.length>0&&(0,G.jsxs)(`span`,{className:`text-xs text-yellow-700 dark:text-yellow-400 flex items-center gap-1`,children:[(0,G.jsx)(_s,{className:`w-3 h-3`}),`Fill in: `,_.join(`, `)]})]}),d&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h4`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[`Response`,(0,G.jsxs)(`span`,{className:`px-2 py-0.5 text-xs rounded ${d.status>=200&&d.status<300?`bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-400`:d.status>=400?`bg-red-100 dark:bg-red-500/20 text-red-700 dark:text-red-400`:`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400`}`,children:[d.status,` `,d.statusText]}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[d.duration,`ms`]})]}),(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:b,children:h?(0,G.jsx)(ys,{className:`w-3 h-3 text-green-600 dark:text-green-400`}):(0,G.jsx)(zs,{className:`w-3 h-3`})})]}),(0,G.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 UHe({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,G.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})});if(a||!t)return(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-8`,children:(0,G.jsxs)(`div`,{className:`text-center text-red-700 dark:text-red-400`,children:[(0,G.jsx)(_s,{className:`w-12 h-12 mx-auto mb-3 opacity-50`}),(0,G.jsx)(`p`,{children:`Failed to load API schema`}),(0,G.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,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`div`,{className:`flex-1`,children:(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>{c(new Set(f.map(e=>e.tag)))},children:`Expand All`}),(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>{c(new Set)},children:`Collapse All`}),(0,G.jsxs)(`a`,{href:`/docs`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-sm text-bambu-green hover:underline`,children:[(0,G.jsx)(ec,{className:`w-4 h-4`}),`Swagger UI`]})]})]}),(0,G.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[f.reduce((e,t)=>e+t.endpoints.length,0),` endpoints in `,f.length,` categories`]}),(0,G.jsx)(`div`,{className:`space-y-3`,children:f.map(({tag:n,endpoints:r})=>(0,G.jsxs)(jd,{children:[(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s.has(n)?(0,G.jsx)(ds,{className:`w-5 h-5 text-bambu-gray`}):(0,G.jsx)(fs,{className:`w-5 h-5 text-bambu-gray`}),(0,G.jsx)(`h3`,{className:`text-base font-semibold text-white capitalize`,children:n.replace(/-/g,` `)}),(0,G.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,G.jsx)(Nd,{className:`pt-0 space-y-2`,children:r.map(({path:n,method:r,spec:i})=>(0,G.jsx)(HHe,{path:n,method:r,spec:i,schema:t,apiKey:e},`${r}-${n}`))})]},n))})]})}var WHe=[{id:`sidecar`,labelKey:`settings.sliceEngineSidecar`,descriptionKey:`settings.sliceEngineSidecarHint`,available:!0},{id:`browser`,labelKey:`settings.sliceEngineBrowser`,descriptionKey:`settings.sliceEngineBrowserHint`,available:!1}];function O8(){return WHe.filter(e=>e.available)}function GHe(){return O8().length>1}function k8(e){return O8().find(t=>t.id===e)?.id??`sidecar`}var KHe=[`general`,`plugs`,`notifications`,`queue`,`filament`,`network`,`apikeys`,`virtual-printer`,`spoolbuddy`,`failure-detection`,`users`,`backup`];E8({labelKey:`settings.general`,tab:`general`,keywords:`language date time format printer model printers cards`,anchor:`card-general`}),E8({labelKey:`settings.appearance`,tab:`general`,keywords:`theme dark light mode colors`,anchor:`card-appearance`}),E8({labelKey:`settings.archiveSettings`,tab:`general`,keywords:`archive auto save thumbnails captures`,anchor:`card-archive`}),E8({labelKey:`settings.camera`,tab:`general`,keywords:`camera external video stream`,anchor:`card-camera`}),E8({labelKey:`settings.costTracking`,tab:`general`,keywords:`currency filament cost energy kwh price`,anchor:`card-cost`}),E8({labelKey:`settings.fileManager`,tab:`general`,keywords:`file manager archive mode disk warning storage`,anchor:`card-filemanager`}),E8({labelKey:`settings.updates`,tab:`general`,keywords:`updates version firmware beta check`,anchor:`card-updates`}),E8({labelKey:`settings.dataManagement`,tab:`general`,keywords:`data reset clear logs notifications preferences`,anchor:`card-data`}),E8({labelKey:`settings.smartPlugs`,tab:`plugs`,keywords:`smart plug energy power automation tapo kasa tplink shelly`,anchor:`card-plugs`}),E8({labelKey:`settings.providers`,tab:`notifications`,keywords:`telegram discord email notification providers webhook`,anchor:`card-providers`}),E8({labelKey:`settings.messageTemplates`,tab:`notifications`,keywords:`message templates notification text edit`,anchor:`card-templates`}),E8({labelKey:`settings.defaultPrintOptions`,labelFallback:`Default Print Options`,tab:`queue`,keywords:`print bed leveling flow calibration vibration first layer timelapse`,anchor:`card-print-options`}),E8({labelKey:`settings.tempFanPresetsTitle`,labelFallback:`Temperature & Fan Presets`,tab:`queue`,keywords:`temperature fan presets nozzle bed chamber quick buttons popover`,anchor:`card-temp-fan-presets`}),E8({labelKey:`settings.staggeredStart`,labelFallback:`Staggered Start`,tab:`queue`,keywords:`staggered batch delay start queue group`,anchor:`card-staggered`}),E8({labelKey:`settings.plateClear`,labelFallback:`Plate-Clear Confirmation`,tab:`queue`,keywords:`plate clear confirm auto queue`,anchor:`card-plate`}),E8({labelKey:`settings.concurrentUploadsTitle`,labelFallback:`Concurrent Uploads`,tab:`queue`,keywords:`concurrent parallel upload transfer ftp queue slow farm simultaneous`,anchor:`card-concurrent-uploads`}),E8({labelKey:`settings.gcodeInjection`,labelFallback:`G-code Injection`,tab:`queue`,keywords:`gcode injection start end autoprint farmloop swapmod autoclear printflow`,anchor:`card-gcode`}),E8({labelKey:`settings.slicerCard`,labelFallback:`Slicer`,tab:`queue`,keywords:`slicer orcaslicer bambustudio orca bambu api sidecar url docker preferred`,anchor:`card-slicer`}),E8({labelKey:`settings.queueDrying`,tab:`queue`,keywords:`drying presets temperature time humidity ams`,anchor:`card-drying`}),E8({labelKey:`settings.filamentChecks`,tab:`filament`,keywords:`filament check warning runout remaining`,anchor:`card-filamentchecks`}),E8({labelKey:`settings.printModal`,tab:`filament`,keywords:`print modal custom mapping`,anchor:`card-printmodal`}),E8({labelKey:`settings.amsDisplayThresholds`,tab:`filament`,keywords:`ams humidity temperature threshold history retention`,anchor:`card-amsthresholds`}),E8({labelKey:`settings.externalUrl`,tab:`network`,keywords:`external url reverse proxy public notification link`,anchor:`card-externalurl`}),E8({labelKey:`settings.ftpRetry`,tab:`network`,keywords:`ftp retry upload retries backoff`,anchor:`card-ftpretry`}),E8({labelKey:`settings.homeAssistant`,tab:`network`,keywords:`home assistant ha hass mqtt integration`,anchor:`card-ha`}),E8({labelKey:`settings.mqttPublishing`,tab:`network`,keywords:`mqtt publish broker topic`,anchor:`card-mqtt`}),E8({labelKey:`settings.prometheusMetrics`,tab:`network`,keywords:`prometheus metrics grafana monitoring bearer token`,anchor:`card-prometheus`}),E8({labelKey:`settings.createNewApiKey`,tab:`apikeys`,keywords:`api key create permission scope`,anchor:`card-createapi`}),E8({labelKey:`settings.webhookEndpoints`,tab:`apikeys`,keywords:`webhook endpoint post http`,anchor:`card-webhooks`}),E8({labelKey:`settings.apiBrowser`,tab:`apikeys`,keywords:`api browser endpoint documentation test`,anchor:`card-apibrowser`}),E8({labelKey:`cameraTokens.title`,tab:`apikeys`,keywords:`camera token long-lived home assistant frigate kiosk stream`,anchor:`card-camera-tokens`}),E8({labelKey:`settings.tabs.virtualPrinter`,tab:`virtual-printer`,keywords:`virtual printer proxy archive slicer bambustudio orcaslicer ip bind`,anchor:`card-vp`}),E8({labelKey:`settings.tabs.spoolbuddy`,tab:`spoolbuddy`,keywords:`spoolbuddy device scale nfc rfid kiosk unregister`,anchor:`card-spoolbuddy`}),E8({labelKey:`settings.currentUser`,tab:`users`,subTab:`users`,keywords:`current user profile password change`,anchor:`card-currentuser`}),E8({labelKey:`settings.users`,tab:`users`,subTab:`users`,keywords:`users accounts list`,anchor:`card-users`}),E8({labelKey:`settings.groups`,tab:`users`,subTab:`users`,keywords:`groups roles permissions administrators operators viewers`,anchor:`card-groups`}),E8({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`}),E8({labelKey:`settings.email.smtpSettings`,labelFallback:`SMTP Configuration`,tab:`users`,subTab:`email`,keywords:`smtp email send server port password auth starttls ssl`,anchor:`card-smtp`}),E8({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`}),E8({labelKey:`settings.tabs.backup`,tab:`backup`,keywords:`backup github restore download cloud sync profiles archives`,anchor:`card-backup`}),E8({labelKey:`externalLinks.sidebarLayout`,labelFallback:`Sidebar`,tab:`general`,keywords:`sidebar layout links pages hide show external custom navigation url add`,anchor:`card-sidebar-links`}),E8({labelKey:`settings.filamentTracking`,tab:`filament`,keywords:`spoolman filament tracking inventory sync remote integration`,anchor:`card-spoolman`}),E8({labelKey:`settings.catalog.spoolCatalog`,labelFallback:`Spool Catalog`,tab:`filament`,keywords:`spool catalog entries brand material reset import export`,anchor:`card-spool-catalog`}),E8({labelKey:`settings.colorCatalog.title`,labelFallback:`Color Catalog`,tab:`filament`,keywords:`color catalog hex swatch palette sync reset`,anchor:`card-color-catalog`}),E8({labelKey:`settings.tabs.failureDetection`,labelFallback:`Failure Detection`,tab:`failure-detection`,keywords:`failure detection ai ml obico spaghetti detect monitoring`,anchor:`card-fd-ml`}),E8({labelKey:`failureDetection.perPrinterTitle`,labelFallback:`Per-Printer Settings`,tab:`failure-detection`,keywords:`failure detection per printer enable per-printer sensitivity`,anchor:`card-fd-perprinter`}),E8({labelKey:`failureDetection.statusTitle`,labelFallback:`Detection Status`,tab:`failure-detection`,keywords:`failure detection status running connection`,anchor:`card-fd-status`}),E8({labelKey:`failureDetection.historyTitle`,labelFallback:`Detection History`,tab:`failure-detection`,keywords:`failure detection history log events`,anchor:`card-fd-history`}),E8({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`}),E8({labelKey:`settings.email.testConnection`,labelFallback:`Test SMTP Connection`,tab:`users`,subTab:`email`,keywords:`email smtp test connection send check`,anchor:`card-email-test`}),E8({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`}),E8({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`}),E8({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`}),E8({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`}),E8({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`}),E8({labelKey:`backup.githubBackup`,labelFallback:`GitHub Backup`,tab:`backup`,keywords:`github backup cloud remote sync profiles token`,anchor:`card-backup-github`}),E8({labelKey:`backup.history`,labelFallback:`Backup History`,tab:`backup`,keywords:`backup history log runs github commits`,anchor:`card-backup-history`}),E8({labelKey:`backup.localBackup`,labelFallback:`Local Backup`,tab:`backup`,keywords:`local backup download zip manual export`,anchor:`card-backup-local`}),E8({labelKey:`backup.scheduledBackup`,labelFallback:`Scheduled Backups`,tab:`backup`,keywords:`scheduled backup automatic hourly daily weekly retention local path`,anchor:`card-backup-scheduled`});var A8=20,qHe={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`},j8=[`bg-blue-500`,`bg-green-500`,`bg-yellow-500`,`bg-red-500`,`bg-orange-500`,`bg-teal-500`,`bg-cyan-500`,`bg-purple-500`],M8=(e,t)=>qHe[e]||j8[t%j8.length];function JHe(){let e=so(),t=or(),[n,r]=Ri(),{t:i,i18n:a}=U(),{showToast:o}=zd(),{authEnabled:s,user:c,isAdmin:l,refreshAuth:u,hasPermission:d}=Td(),{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,progressInTitle:O,setProgressInTitle:k}=Od(),[A,j]=(0,y.useState)(null),[M,N]=(0,y.useState)({}),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(null),[R,z]=(0,y.useState)(!1),[B,V]=(0,y.useState)(null),[ee,te]=(0,y.useState)(!1),[ne,re]=(0,y.useState)(null),[ie,ae]=(0,y.useState)(null),[oe,se]=(0,y.useState)(``),[H,ce]=(0,y.useState)(``),[le,ue]=(0,y.useState)(!1),[de,fe]=(0,y.useState)(!1),[pe,me]=(0,y.useState)(!1),[he,ge]=(0,y.useState)(tm()),_e=n.get(`tab`),ve=_e===`email`,[ye,be]=(0,y.useState)(ve?`users`:_e&&KHe.includes(_e)?_e:`general`),[xe,Se]=(0,y.useState)(ve?`email`:`users`),[Ce,we]=(0,y.useState)(_e===`queue`&&n.get(`sub`)===`pipelines`?`pipelines`:`dispatch`),Te=e=>{be(e),e===`users`&&Se(`users`),e===`queue`&&(we(`dispatch`),n.delete(`sub`)),e===`general`?n.delete(`tab`):n.set(`tab`,e),r(n,{replace:!0})},Ee=e=>{we(e),e===`pipelines`?n.set(`sub`,`pipelines`):n.delete(`sub`),r(n,{replace:!0})},[De,Oe]=(0,y.useState)(!1),[ke,Ae]=(0,y.useState)(``),[je,Me]=(0,y.useState)({can_queue:!0,can_control_printer:!1,can_read_status:!0,can_manage_library:!0,can_manage_inventory:!0,can_manage_maintenance:!0,can_manage_archives:!0,can_manage_projects:!0,can_access_cloud:!1,can_update_energy_cost:!1}),[Ne,Pe]=(0,y.useState)(null),[Fe,Ie]=(0,y.useState)(!1),[Le,Re]=(0,y.useState)(null),[ze,Be]=(0,y.useState)(``),[Ve,He]=(0,y.useState)(!1),[Ue,We]=(0,y.useState)(!1),[Ge,Ke]=(0,y.useState)(null),[qe,Je]=(0,y.useState)(!1),[Ye,Xe]=(0,y.useState)(!1),[Ze,Qe]=(0,y.useState)(!1),[$e,et]=(0,y.useState)({currentPassword:``,newPassword:``,confirmPassword:``}),[tt,nt]=(0,y.useState)(!1),[rt,it]=(0,y.useState)(!1),[at,ot]=(0,y.useState)(!1),[st,ct]=(0,y.useState)(`local`),[lt,ut]=(0,y.useState)(!1),[dt,ft]=(0,y.useState)(null),[pt,mt]=(0,y.useState)(null),[ht,gt]=(0,y.useState)(null),[_t,vt]=(0,y.useState)(!1),[yt,bt]=(0,y.useState)({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),[xt,St]=(0,y.useState)(null),[Ct,wt]=(0,y.useState)(null),[Tt,Et]=(0,y.useState)(!1),[Dt,Ot]=(0,y.useState)({}),[At,jt]=(0,y.useState)({}),Mt=e=>{ge(e),bee(e),o(i(`settings.toast.settingsSaved`),`success`)},{data:Nt,isLoading:Pt}=K({queryKey:[`settings`],queryFn:Z.getSettings}),{data:Ft,isLoading:It,isFetching:Lt}=K({queryKey:[`storage-usage`],queryFn:()=>Z.getStorageUsage(),enabled:ye===`general`,staleTime:1/0,refetchInterval:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),Rt=async()=>{it(!0);try{let t=await Z.getStorageUsage({refresh:!0});e.setQueryData([`storage-usage`],t)}catch(e){o(e instanceof Error?e.message:`Failed to refresh storage usage`,`error`)}finally{it(!1)}},{data:zt,isLoading:Bt}=K({queryKey:[`smart-plugs`],queryFn:Z.getSmartPlugs}),{data:Vt,isLoading:Ht}=K({queryKey:[`smart-plugs-energy`,zt?.map(e=>e.id)],queryFn:async()=>{if(!zt||zt.length===0)return null;let e=await Promise.all(zt.filter(e=>e.enabled).map(async e=>{try{return{plug:e,status:await Z.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:zt.filter(e=>e.enabled).length}},enabled:ye===`plugs`&&!!zt&&zt.length>0,refetchInterval:ye===`plugs`?1e4:!1}),{data:Ut,isLoading:Wt}=K({queryKey:[`notification-providers`],queryFn:Z.getNotificationProviders}),{data:Gt,isLoading:Kt}=K({queryKey:[`api-keys`],queryFn:Z.getAPIKeys}),qt=q({mutationFn:e=>Z.createAPIKey(e),onSuccess:t=>{Pe(t.key||null),Oe(!1),Ae(``),e.invalidateQueries({queryKey:[`api-keys`]}),o(i(`settings.toast.apiKeyCreated`))},onError:e=>{o(`Failed to create API key: ${e.message}`,`error`)}}),Jt=q({mutationFn:e=>Z.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:Yt}=K({queryKey:[`printers`],queryFn:Z.getPrinters}),{data:Xt}=K({queryKey:[`haSensors`],queryFn:()=>Z.getHASensors(),enabled:ye===`plugs`}),Zt=Tf(Yt?.length??0),{data:Qt,isLoading:$t}=K({queryKey:[`notification-templates`],queryFn:Z.getNotificationTemplates}),{data:en}=K({queryKey:[`virtual-printer-settings`],queryFn:hd.getSettings,refetchInterval:1e4}),tn=en?.status?.running??!1,{data:W}=K({queryKey:[`spoolbuddy-devices`],queryFn:()=>bd.getDevices(),refetchInterval:15e3}),nn=W?.length??0,rn=W?.some(e=>e.online)??!1,{data:an}=K({queryKey:[`obico-status`],queryFn:Z.getObicoStatus,refetchInterval:15e3}),on=!!(an?.is_running&&an?.enabled),{data:sn}=K({queryKey:[`ffmpeg-status`],queryFn:Z.checkFfmpeg}),{data:cn}=K({queryKey:[`version`],queryFn:Z.getVersion}),ln=!s||d(`library:purge`),{data:un}=K({queryKey:[`library-trash-settings`],queryFn:()=>Z.getLibraryTrashSettings(),enabled:ln}),dn=q({mutationFn:e=>Z.updateLibraryTrashSettings(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`library-trash-settings`]}),o(i(`settings.toast.settingsSaved`),`success`)},onError:e=>o(e.message||i(`libraryAutoPurge.saveFailed`),`error`)}),fn=e=>{un&&dn.mutate({retention_days:un.retention_days,auto_purge_enabled:un.auto_purge_enabled,auto_purge_days:un.auto_purge_days,auto_purge_include_never_printed:un.auto_purge_include_never_printed,...e})},pn=!s||d(`archives:purge`),{data:mn}=K({queryKey:[`archive-purge-settings`],queryFn:()=>Z.getArchivePurgeSettings(),enabled:pn}),hn=q({mutationFn:e=>Z.updateArchivePurgeSettings(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`archive-purge-settings`]}),o(i(`settings.toast.settingsSaved`),`success`)},onError:e=>o(e.message||i(`archiveAutoPurge.saveFailed`),`error`)}),gn=e=>{mn&&hn.mutate({enabled:mn.enabled,days:mn.days,purge_stats:mn.purge_stats,...e})},{data:_n,refetch:vn,isRefetching:yn}=K({queryKey:[`updateCheck`],queryFn:Z.checkForUpdates,enabled:Nt?.check_updates!==!1,staleTime:300*1e3}),{data:bn,refetch:xn}=K({queryKey:[`updateStatus`],queryFn:Z.getUpdateStatus,refetchInterval:e=>{let t=e.state.data;return t?.status===`downloading`||t?.status===`installing`?1e3:!1}}),{data:Sn}=K({queryKey:[`mqtt-status`],queryFn:Z.getMQTTStatus,refetchInterval:ye===`network`?5e3:!1}),{data:Cn}=K({queryKey:[`github-backup-status`],queryFn:Z.getGitHubBackupStatus}),{data:wn}=K({queryKey:[`cloud-status`],queryFn:Z.getCloudStatus}),{data:Tn={advanced_auth_enabled:!1,smtp_configured:!1,local_login_enabled:!0,autologin_provider_id:null}}=K({queryKey:[`advancedAuthStatus`],queryFn:()=>Z.getAdvancedAuthStatus()}),{data:En}=K({queryKey:[`ldapStatus`],queryFn:()=>Z.getLDAPStatus()}),{data:Dn}=K({queryKey:[`twoFAStatus`],queryFn:()=>Z.get2FAStatus()}),{data:On=[]}=K({queryKey:[`oidcProvidersAll`],queryFn:()=>Z.getOIDCProvidersAll(),enabled:l}),{data:kn=[],isLoading:An}=K({queryKey:[`users`],queryFn:()=>Z.getUsers(),enabled:s&&d(`users:read`)}),{data:jn=[],isLoading:Mn}=K({queryKey:[`groups`],queryFn:()=>Z.getGroups(),enabled:s&&d(`groups:read`)}),Nn=q({mutationFn:e=>Z.createUser(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`users`]}),e.invalidateQueries({queryKey:[`groups`]}),ot(!1),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`settings.toast.userCreated`))},onError:e=>{o(e.message,`error`)}}),Pn=q({mutationFn:({id:e,data:t})=>Z.updateUser(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`users`]}),e.invalidateQueries({queryKey:[`groups`]}),ut(!1),ft(null),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`settings.toast.userUpdated`))},onError:e=>{o(e.message,`error`)}}),Fn=q({mutationFn:({id:e,deleteItems:t})=>Z.deleteUser(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`users`]}),o(i(`settings.toast.userDeleted`)),mt(null),gt(null)},onError:e=>{o(e.message,`error`)}}),In=q({mutationFn:e=>Z.resetUserPassword({user_id:e}),onSuccess:e=>{o(e.message,`success`)},onError:e=>{o(e.message,`error`)}}),Ln=async e=>{mt(e),vt(!0);try{gt(await Z.getUserItemsCount(e))}catch{gt({archives:0,queue_items:0,library_files:0})}finally{vt(!1)}},Rn=q({mutationFn:e=>Z.deleteGroup(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`groups`]}),o(i(`settings.toast.groupDeleted`))},onError:e=>{o(e.message,`error`)}}),zn=()=>{let e=Tn?.advanced_auth_enabled||!1;if(!yt.username){o(i(`settings.toast.fillRequiredFields`),`error`);return}if(e&&!yt.email){o(`Email is required when advanced authentication is enabled`,`error`);return}if(!e){if(!yt.password){o(i(`settings.toast.fillRequiredFields`),`error`);return}if(yt.password!==yt.confirmPassword){o(i(`settings.toast.passwordsDoNotMatch`),`error`);return}let e=T6(yt.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}}Nn.mutate({username:yt.username,password:e?void 0:yt.password,email:yt.email||void 0,role:yt.role,group_ids:yt.group_ids.length>0?yt.group_ids:void 0})},Bn=e=>{if(yt.password){if(yt.password!==yt.confirmPassword){o(i(`settings.toast.passwordsDoNotMatch`),`error`);return}let e=T6(yt.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:yt.username||void 0,password:yt.password||void 0,email:yt.email||void 0,role:yt.role,group_ids:yt.group_ids};t.password||delete t.password,Pn.mutate({id:e,data:t})},Vn=e=>{ft(e.id),bt({username:e.username,password:``,email:e.email||``,confirmPassword:``,role:e.role,group_ids:e.groups?.map(e=>e.id)||[]}),ut(!0)},Hn=e=>{bt(t=>({...t,group_ids:t.group_ids.includes(e)?t.group_ids.filter(t=>t!==e):[...t.group_ids,e]}))},Un=q({mutationFn:Z.applyUpdate,onSuccess:e=>{e.is_ha_addon||e.is_docker||e.is_windows_installer?o(e.message,`error`):xn()}}),[Wn,Gn]=(0,y.useState)(null),Kn=q({mutationFn:Z.testAllNotificationProviders,onSuccess:t=>{Gn(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`)}}),qn=q({mutationFn:async e=>{if(!zt)return{success:0,failed:0};let t=zt.filter(e=>e.enabled),n=await Promise.all(t.map(async t=>{try{return await Z.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`)}}),Jn=(0,y.useRef)(null),Yn=(0,y.useRef)(null),Xn=(0,y.useRef)(!1),Zn=(0,y.useRef)(!0),Qn=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(Nt&&!A){let e={...Nt,external_url:Nt.external_url||window.location.origin};Qn.current=Nt,j(e),setTimeout(()=>{Zn.current=!1},100)}},[Nt,A]),(0,y.useEffect)(()=>{let e=Qn.current;if(!Nt||!A||!e||Nt===e)return;let t={};for(let n of Object.keys(Nt))Nt[n]!==e[n]&&A[n]===e[n]&&(t[n]=Nt[n]);Qn.current=Nt,Object.keys(t).length>0&&j(e=>e&&{...e,...t})},[Nt,A]);let $n=q({mutationFn:Z.updateSettings,onSuccess:t=>{Qn.current=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:()=>{Xn.current=!1}}),er=q({mutationFn:({id:e,data:t})=>Z.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)(()=>{let e=Qn.current;if(!(Zn.current||!A||!Nt||!e)&&!(s&&!d(`settings:update`))&&(e.auto_archive!==A.auto_archive||e.save_thumbnails!==A.save_thumbnails||e.capture_finish_photo!==A.capture_finish_photo||(e.finish_photo_restore_plate??!0)!==(A.finish_photo_restore_plate??!0)||e.default_filament_cost!==A.default_filament_cost||e.currency!==A.currency||e.energy_cost_per_kwh!==A.energy_cost_per_kwh||e.energy_tracking_mode!==A.energy_tracking_mode||e.check_updates!==A.check_updates||(e.check_printer_firmware??!0)!==(A.check_printer_firmware??!0)||(e.include_beta_updates??!1)!==(A.include_beta_updates??!1)||(e.local_login_enabled??!0)!==(A.local_login_enabled??!0)||e.notification_language!==A.notification_language||(e.bed_cooled_threshold??35)!==(A.bed_cooled_threshold??35)||e.ams_humidity_good!==A.ams_humidity_good||e.ams_humidity_fair!==A.ams_humidity_fair||e.ams_temp_good!==A.ams_temp_good||e.ams_temp_fair!==A.ams_temp_fair||e.ams_history_retention_days!==A.ams_history_retention_days||e.disable_filament_warnings!==A.disable_filament_warnings||e.prefer_lowest_filament!==A.prefer_lowest_filament||(e.queue_drying_enabled??!1)!==(A.queue_drying_enabled??!1)||(e.queue_drying_block??!1)!==(A.queue_drying_block??!1)||(e.ambient_drying_enabled??!1)!==(A.ambient_drying_enabled??!1)||(e.print_drying_enabled??!1)!==(A.print_drying_enabled??!1)||(e.drying_presets??``)!==(A.drying_presets??``)||(e.ams_humidity_thresholds??``)!==(A.ams_humidity_thresholds??``)||e.per_printer_mapping_expanded!==A.per_printer_mapping_expanded||e.date_format!==A.date_format||e.time_format!==A.time_format||e.default_printer_id!==A.default_printer_id||e.ftp_retry_enabled!==A.ftp_retry_enabled||e.ftp_retry_count!==A.ftp_retry_count||e.ftp_retry_delay!==A.ftp_retry_delay||e.ftp_timeout!==A.ftp_timeout||e.mqtt_enabled!==A.mqtt_enabled||e.mqtt_broker!==A.mqtt_broker||e.mqtt_port!==A.mqtt_port||e.mqtt_username!==A.mqtt_username||e.mqtt_password!==A.mqtt_password||e.mqtt_topic_prefix!==A.mqtt_topic_prefix||e.mqtt_use_tls!==A.mqtt_use_tls||e.external_url!==A.external_url||e.ha_enabled!==A.ha_enabled||e.ha_url!==A.ha_url||e.ha_token!==A.ha_token||(e.library_archive_mode??`ask`)!==(A.library_archive_mode??`ask`)||Number(e.library_disk_warning_gb??5)!==Number(A.library_disk_warning_gb??5)||(e.preferred_slicer??`bambu_studio`)!==(A.preferred_slicer??`bambu_studio`)||k8(e.slice_engine)!==k8(A.slice_engine)||(e.open_in_slicer??null)!==(A.open_in_slicer??null)||(e.use_slicer_api??!1)!==(A.use_slicer_api??!1)||(e.orcaslicer_api_url??``)!==(A.orcaslicer_api_url??``)||(e.slicer_stall_timeout_minutes??15)!==(A.slicer_stall_timeout_minutes??15)||(e.bambu_studio_api_url??``)!==(A.bambu_studio_api_url??``)||e.prometheus_enabled!==A.prometheus_enabled||e.prometheus_token!==A.prometheus_token||(e.user_notifications_enabled??!0)!==(A.user_notifications_enabled??!0)||(e.default_bed_levelling??`auto`)!==(A.default_bed_levelling??`auto`)||(e.default_flow_cali??`auto`)!==(A.default_flow_cali??`auto`)||(e.default_vibration_cali??!0)!==(A.default_vibration_cali??!0)||(e.default_layer_inspect??!1)!==(A.default_layer_inspect??!1)||(e.default_timelapse??!1)!==(A.default_timelapse??!1)||(e.default_nozzle_offset_cali??`auto`)!==(A.default_nozzle_offset_cali??`auto`)||(e.stagger_group_size??2)!==(A.stagger_group_size??2)||(e.stagger_interval_minutes??5)!==(A.stagger_interval_minutes??5)||(e.require_plate_clear??!1)!==(A.require_plate_clear??!1)||(e.queue_max_concurrent_uploads??4)!==(A.queue_max_concurrent_uploads??4)||(e.preheat_enabled??!1)!==(A.preheat_enabled??!1)||(e.preheat_filament_targets??``)!==(A.preheat_filament_targets??``)||(e.preheat_max_wait_seconds??900)!==(A.preheat_max_wait_seconds??900)||(e.preheat_soak_seconds??300)!==(A.preheat_soak_seconds??300)||(e.queue_keep_bed_warm??!1)!==(A.queue_keep_bed_warm??!1)||(e.queue_keep_warm_bed_temp??90)!==(A.queue_keep_warm_bed_temp??90)||(e.queue_keep_warm_max_minutes??120)!==(A.queue_keep_warm_max_minutes??120)||(e.nozzle_temp_presets??``)!==(A.nozzle_temp_presets??``)||(e.bed_temp_presets??``)!==(A.bed_temp_presets??``)||(e.chamber_temp_presets??``)!==(A.chamber_temp_presets??``)||(e.fan_speed_presets??``)!==(A.fan_speed_presets??``)||(e.session_max_hours??24)!==(A.session_max_hours??24)||(e.billing_enabled??!1)!==(A.billing_enabled??!1)||(e.printer_kill_switch_enabled??!1)!==(A.printer_kill_switch_enabled??!1)||(e.finance_budget_reset_day??1)!==(A.finance_budget_reset_day??1)||(e.finance_budget_reset_timezone??`UTC`)!==(A.finance_budget_reset_timezone??`UTC`))&&!Xn.current)return Jn.current&&clearTimeout(Jn.current),Jn.current=setTimeout(()=>{if(Xn.current)return;Xn.current=!0;let e={auto_archive:A.auto_archive,save_thumbnails:A.save_thumbnails,capture_finish_photo:A.capture_finish_photo,finish_photo_restore_plate:A.finish_photo_restore_plate??!0,default_filament_cost:A.default_filament_cost,currency:A.currency,energy_cost_per_kwh:A.energy_cost_per_kwh,energy_tracking_mode:A.energy_tracking_mode,check_updates:A.check_updates,check_printer_firmware:A.check_printer_firmware,include_beta_updates:A.include_beta_updates,local_login_enabled:A.local_login_enabled,notification_language:A.notification_language,bed_cooled_threshold:A.bed_cooled_threshold,ams_humidity_good:A.ams_humidity_good,ams_humidity_fair:A.ams_humidity_fair,ams_temp_good:A.ams_temp_good,ams_temp_fair:A.ams_temp_fair,ams_history_retention_days:A.ams_history_retention_days,disable_filament_warnings:A.disable_filament_warnings,prefer_lowest_filament:A.prefer_lowest_filament,queue_drying_enabled:A.queue_drying_enabled,queue_drying_block:A.queue_drying_block,ambient_drying_enabled:A.ambient_drying_enabled,print_drying_enabled:A.print_drying_enabled,drying_presets:A.drying_presets,ams_humidity_thresholds:A.ams_humidity_thresholds,per_printer_mapping_expanded:A.per_printer_mapping_expanded,date_format:A.date_format,time_format:A.time_format,default_printer_id:A.default_printer_id,ftp_retry_enabled:A.ftp_retry_enabled,ftp_retry_count:A.ftp_retry_count,ftp_retry_delay:A.ftp_retry_delay,ftp_timeout:A.ftp_timeout,mqtt_enabled:A.mqtt_enabled,mqtt_broker:A.mqtt_broker,mqtt_port:A.mqtt_port,mqtt_username:A.mqtt_username,mqtt_password:A.mqtt_password,mqtt_topic_prefix:A.mqtt_topic_prefix,mqtt_use_tls:A.mqtt_use_tls,external_url:A.external_url,ha_enabled:A.ha_enabled,ha_url:A.ha_url,ha_token:A.ha_token,library_archive_mode:A.library_archive_mode,library_disk_warning_gb:A.library_disk_warning_gb,preferred_slicer:A.preferred_slicer,slice_engine:A.slice_engine,open_in_slicer:A.open_in_slicer,use_slicer_api:A.use_slicer_api,orcaslicer_api_url:A.orcaslicer_api_url,slicer_stall_timeout_minutes:A.slicer_stall_timeout_minutes,bambu_studio_api_url:A.bambu_studio_api_url,prometheus_enabled:A.prometheus_enabled,prometheus_token:A.prometheus_token,user_notifications_enabled:A.user_notifications_enabled,default_bed_levelling:A.default_bed_levelling,default_flow_cali:A.default_flow_cali,default_vibration_cali:A.default_vibration_cali,default_layer_inspect:A.default_layer_inspect,default_timelapse:A.default_timelapse,default_nozzle_offset_cali:A.default_nozzle_offset_cali,stagger_group_size:A.stagger_group_size,stagger_interval_minutes:A.stagger_interval_minutes,require_plate_clear:A.require_plate_clear,queue_max_concurrent_uploads:A.queue_max_concurrent_uploads,preheat_enabled:A.preheat_enabled,preheat_filament_targets:A.preheat_filament_targets,preheat_max_wait_seconds:A.preheat_max_wait_seconds,preheat_soak_seconds:A.preheat_soak_seconds,queue_keep_bed_warm:A.queue_keep_bed_warm,queue_keep_warm_bed_temp:A.queue_keep_warm_bed_temp,queue_keep_warm_max_minutes:A.queue_keep_warm_max_minutes,nozzle_temp_presets:A.nozzle_temp_presets,bed_temp_presets:A.bed_temp_presets,chamber_temp_presets:A.chamber_temp_presets,fan_speed_presets:A.fan_speed_presets,session_max_hours:A.session_max_hours,billing_enabled:A.billing_enabled,printer_kill_switch_enabled:A.printer_kill_switch_enabled,finance_budget_reset_day:A.finance_budget_reset_day,finance_budget_reset_timezone:A.finance_budget_reset_timezone};$n.mutate(e)},500),()=>{Jn.current&&clearTimeout(Jn.current)}},[A,Nt,$n,s,d,o,i]);let tr=(0,y.useCallback)((e,t)=>{if(s&&!d(`settings:update`)){o(i(`settings.toast.noPermissionUpdate`),`error`);return}j(n=>n?{...n,[e]:t}:null)},[s,d,o,i]),nr=async(e,t,n)=>{if(!t){o(i(`settings.toast.enterCameraUrl`),`error`);return}jt(t=>({...t,[e]:!0})),Ot(t=>({...t,[e]:null}));try{let r=await Z.testExternalCamera(e,t,n);Ot(t=>({...t,[e]:r})),r.success?o(r.coalesced?i(`settings.toast.cameraConnectedCoalesced`,{resolution:r.resolution||``}):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`);Ot(t=>({...t,[e]:{success:!1,error:n}})),o(n,`error`)}finally{jt(t=>({...t,[e]:!1}))}},[rr,ir]=(0,y.useState)({}),ar=(0,y.useRef)({}),sr=(0,y.useRef)(new Set),[cr,lr]=(0,y.useState)({}),ur=(0,y.useRef)({}),dr=(0,y.useRef)(new Set);(0,y.useEffect)(()=>{if(Yt){let e={},t={};Yt.forEach(n=>{n.external_camera_url&&!sr.current.has(n.id)&&(e[n.id]=n.external_camera_url,sr.current.add(n.id)),n.external_camera_snapshot_url&&!dr.current.has(n.id)&&(t[n.id]=n.external_camera_snapshot_url,dr.current.add(n.id))}),Object.keys(e).length>0&&ir(t=>({...t,...e})),Object.keys(t).length>0&&lr(e=>({...e,...t}))}},[Yt]);let fr=(e,t)=>{ir(n=>({...n,[e]:t})),ar.current[e]&&clearTimeout(ar.current[e]),ar.current[e]=setTimeout(()=>{er.mutate({id:e,data:{external_camera_url:t||null}})},800)},pr=(e,t)=>{lr(n=>({...n,[e]:t})),ur.current[e]&&clearTimeout(ur.current[e]),ur.current[e]=setTimeout(()=>{er.mutate({id:e,data:{external_camera_snapshot_url:t||null}})},800)},mr=(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),er.mutate({id:e,data:n})};if(Pt||!A)return(0,G.jsx)(`div`,{className:`p-4 md:p-8 flex justify-center`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})});let hr=RHe().map(e=>({...e,label:i(e.labelKey,e.labelFallback??e.labelKey)})),gr=H.trim().toLowerCase(),_r=gr?hr.filter(e=>e.label.toLowerCase().includes(gr)||e.keywords.toLowerCase().includes(gr)).slice(0,8):[],vr=e=>{Te(e.tab),e.subTab&&Se(e.subTab),ce(``),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)},yr=(A?.docker_compose_dir??``).trim()||(_n?.compose_dir_detected??``),br=yr?`cd ${/\s/.test(yr)?`"${yr}"`:yr} && docker compose pull && docker compose up -d`:`docker compose pull && docker compose up -d`;return(0,G.jsx)(Ad,{density:`dense`,children:(0,G.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,G.jsxs)(`div`,{className:`mb-4 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,G.jsx)($l,{className:`w-7 h-7 text-bambu-green`}),i(`settings.title`)]}),(0,G.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:i(`settings.configureBambuddy`)})]}),(0,G.jsxs)(`div`,{className:`relative sm:w-72`,children:[(0,G.jsx)(Jl,{className:`w-4 h-4 text-bambu-gray absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none`}),(0,G.jsx)(`input`,{type:`text`,value:H,onChange:e=>ce(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`}),H&&(0,G.jsx)(`button`,{onClick:()=>ce(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-bambu-gray hover:text-white`,"aria-label":`Clear`,children:(0,G.jsx)(Qu,{className:`w-3.5 h-3.5`})}),_r.length>0&&(0,G.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:_r.map(e=>(0,G.jsxs)(`button`,{onClick:()=>vr(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,G.jsx)(`p`,{className:`text-sm text-white`,children:e.label}),(0,G.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))}),gr&&_r.length===0&&(0,G.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,G.jsx)(`p`,{className:`text-xs text-bambu-gray italic`,children:i(`settings.noSearchResults`,`No matching settings.`)})})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,G.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,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`general`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)($l,{className:`w-4 h-4`}),i(`settings.tabs.general`)]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`plugs`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Al,{className:`w-4 h-4`}),i(`settings.tabs.smartPlugs`),zt&&zt.length>0&&(0,G.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:zt.length})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`notifications`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Go,{className:`w-4 h-4`}),i(`settings.tabs.notifications`),Ut&&Ut.length>0&&(0,G.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:Ut.length})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`queue`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Jc,{className:`w-4 h-4`}),i(`settings.tabs.queue`,`Workflow`)]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`filament`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Hs,{className:`w-4 h-4`}),i(`settings.tabs.filament`)]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`network`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Ju,{className:`w-4 h-4`}),i(`settings.tabs.network`),(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${Sn?.enabled?`bg-green-400`:`bg-gray-500`}`})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`apikeys`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Vc,{className:`w-4 h-4`}),i(`settings.tabs.apiKeys`),Gt&&Gt.length>0&&(0,G.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:Gt.length})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`virtual-printer`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Pl,{className:`w-4 h-4`}),i(`settings.tabs.virtualPrinter`),(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${tn?`bg-green-400`:`bg-gray-500`}`})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`spoolbuddy`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Wl,{className:`w-4 h-4`}),i(`settings.tabs.spoolbuddy`),nn>0&&(0,G.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:nn}),(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${rn?`bg-green-400`:`bg-gray-500`}`})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`failure-detection`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Gl,{className:`w-4 h-4`}),i(`settings.tabs.failureDetection`),(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${on?`bg-green-400`:`bg-gray-500`}`})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`users`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(zu,{className:`w-4 h-4`}),i(`settings.tabs.users`),s&&(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green-400`})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`backup`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Us,{className:`w-4 h-4`}),i(`settings.tabs.backup`),(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${wn?.is_authenticated&&Cn?.configured&&Cn?.enabled||Nt?.local_backup_enabled?`bg-green-400`:`bg-gray-500`}`})]})]}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[ye===`general`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`a`,{href:Ef(Zt,`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,G.jsxs)(`div`,{className:`flex flex-col md:flex-row items-start md:items-center gap-4 p-4 md:p-5`,children:[(0,G.jsx)(`div`,{className:`p-3 rounded-lg bg-bambu-green/20 text-bambu-green flex-shrink-0`,children:Zt===`business`?(0,G.jsx)(Xo,{className:`w-6 h-6`}):(0,G.jsx)(Nc,{className:`w-6 h-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-base font-semibold text-white`,children:Zt===`business`?i(`sponsors.businessTitle`,`Bambuddy for business`):i(`sponsors.sectionTitle`,`Independent & community-funded`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-0.5`,children:Zt===`business`?i(`sponsors.businessTagline`,`You're running {{count}} printers. Priority support, commercial licensing and invoicing are available for teams and print farms.`,{count:Yt?.length??0}):i(`sponsors.tagline`,`Bambuddy is free and stays that way because people choose to support it. No VC, no cloud lock-in.`)})]}),(0,G.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:[Zt===`business`?i(`sponsors.businessCta`,`Bambuddy for business`):i(`sponsors.viewSupporters`,`View supporters`),(0,G.jsx)(ec,{className:`w-4 h-4`})]})]})}),(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,G.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-xl`,children:[(0,G.jsxs)(jd,{id:`card-general`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.general`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,G.jsx)(Ec,{className:`w-4 h-4 inline mr-1`}),i(`settings.language`)]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.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),$n.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:kt.map(e=>(0,G.jsxs)(`option`,{value:e.code,children:[e.nativeName,` (`,e.name,`)`]},e.code))}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.languageDescription`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.defaultView`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`select`,{value:he,onChange:e=>Mt(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:em.map(e=>(0,G.jsx)(`option`,{value:e.to,children:i(e.labelKey)},e.id))}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.defaultViewDescription`)})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.dateFormat`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`select`,{value:A.date_format||`system`,onChange:e=>tr(`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,G.jsx)(`option`,{value:`system`,children:i(`settings.systemDefault`)}),(0,G.jsx)(`option`,{value:`us`,children:i(`settings.dateFormatUs`)}),(0,G.jsx)(`option`,{value:`eu`,children:i(`settings.dateFormatEu`)}),(0,G.jsx)(`option`,{value:`iso`,children:i(`settings.dateFormatIso`)})]}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.timeFormat`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`select`,{value:A.time_format||`system`,onChange:e=>tr(`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,G.jsx)(`option`,{value:`system`,children:i(`settings.systemDefault`)}),(0,G.jsx)(`option`,{value:`12h`,children:i(`settings.timeFormat12`)}),(0,G.jsx)(`option`,{value:`24h`,children:i(`settings.timeFormat24`)})]}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.defaultPrinter`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`select`,{value:A.default_printer_id??``,onChange:e=>tr(`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,G.jsx)(`option`,{value:``,children:i(`settings.noDefaultPrinter`)}),Yt?.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.defaultPrinterDescription`)})]})]})]}),(0,G.jsxs)(jd,{id:`card-appearance`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(bl,{className:`w-5 h-5`}),i(`settings.appearance`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,G.jsxs)(`label`,{className:`text-sm text-bambu-gray`,children:[i(`settings.theme`),`:`]}),(0,G.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,G.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,G.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,G.jsxs)(`h3`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[i(`settings.darkMode`),p===`dark`&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-green`,children:i(`settings.active`)})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.background`)}),(0,G.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,G.jsx)(`option`,{value:`neutral`,children:i(`settings.bgNeutral`)}),(0,G.jsx)(`option`,{value:`warm`,children:i(`settings.bgWarm`)}),(0,G.jsx)(`option`,{value:`cool`,children:i(`settings.bgCool`)}),(0,G.jsx)(`option`,{value:`oled`,children:i(`settings.bgOled`)}),(0,G.jsx)(`option`,{value:`slate`,children:i(`settings.bgSlate`)}),(0,G.jsx)(`option`,{value:`forest`,children:i(`settings.bgForest`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.accent`)}),(0,G.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,G.jsx)(`option`,{value:`green`,children:i(`settings.accentGreen`)}),(0,G.jsx)(`option`,{value:`teal`,children:i(`settings.accentTeal`)}),(0,G.jsx)(`option`,{value:`blue`,children:i(`settings.accentBlue`)}),(0,G.jsx)(`option`,{value:`orange`,children:i(`settings.accentOrange`)}),(0,G.jsx)(`option`,{value:`purple`,children:i(`settings.accentPurple`)}),(0,G.jsx)(`option`,{value:`red`,children:i(`settings.accentRed`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.style`)}),(0,G.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,G.jsx)(`option`,{value:`classic`,children:i(`settings.styleClassic`)}),(0,G.jsx)(`option`,{value:`glow`,children:i(`settings.styleGlow`)}),(0,G.jsx)(`option`,{value:`vibrant`,children:i(`settings.styleVibrant`)})]})]})]})]}),(0,G.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,G.jsxs)(`h3`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[i(`settings.lightMode`),p===`light`&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-green`,children:i(`settings.active`)})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.background`)}),(0,G.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,G.jsx)(`option`,{value:`neutral`,children:i(`settings.bgNeutral`)}),(0,G.jsx)(`option`,{value:`warm`,children:i(`settings.bgWarm`)}),(0,G.jsx)(`option`,{value:`cool`,children:i(`settings.bgCool`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.accent`)}),(0,G.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,G.jsx)(`option`,{value:`green`,children:i(`settings.accentGreen`)}),(0,G.jsx)(`option`,{value:`teal`,children:i(`settings.accentTeal`)}),(0,G.jsx)(`option`,{value:`blue`,children:i(`settings.accentBlue`)}),(0,G.jsx)(`option`,{value:`orange`,children:i(`settings.accentOrange`)}),(0,G.jsx)(`option`,{value:`purple`,children:i(`settings.accentPurple`)}),(0,G.jsx)(`option`,{value:`red`,children:i(`settings.accentRed`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.style`)}),(0,G.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,G.jsx)(`option`,{value:`classic`,children:i(`settings.styleClassic`)}),(0,G.jsx)(`option`,{value:`glow`,children:i(`settings.styleGlow`)}),(0,G.jsx)(`option`,{value:`vibrant`,children:i(`settings.styleVibrant`)})]})]})]})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.themeToggleHint`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-2 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.progressInTitle`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.progressInTitleDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:O,onChange:e=>{k(e.target.checked),o(i(`settings.toast.settingsSaved`),`success`)},className:`sr-only peer`}),(0,G.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,G.jsxs)(jd,{id:`card-archive`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.archiveSettings`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.autoArchivePrints`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.autoArchiveDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.auto_archive,onChange:e=>tr(`auto_archive`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.saveThumbnails`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.saveThumbnailsDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.save_thumbnails,onChange:e=>tr(`save_thumbnails`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.captureFinishPhoto`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.captureFinishPhotoDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.capture_finish_photo,onChange:e=>tr(`capture_finish_photo`,e.target.checked),className:`sr-only peer`}),(0,G.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.capture_finish_photo&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between pl-4 border-l-2 border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.finishPhotoRestorePlate`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.finishPhotoRestorePlateDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.finish_photo_restore_plate??!0,onChange:e=>tr(`finish_photo_restore_plate`,e.target.checked),className:`sr-only peer`}),(0,G.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.capture_finish_photo&&sn&&!sn.installed&&(0,G.jsxs)(`div`,{className:`flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg`,children:[(0,G.jsx)(Nu,{className:`w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5`}),(0,G.jsxs)(`div`,{className:`text-sm`,children:[(0,G.jsx)(`p`,{className:`text-yellow-500 font-medium`,children:i(`settings.ffmpegNotInstalled`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:i(`settings.ffmpegRequired`)})]})]}),pn&&mn&&(0,G.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-3 mt-3 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`archiveAutoPurge.enableLabel`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`archiveAutoPurge.enableDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:mn.enabled,onChange:e=>gn({enabled:e.target.checked}),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`archiveAutoPurge.ageLabel`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:7,max:3650,disabled:!mn.enabled,value:mn.days,onChange:e=>gn({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,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`archiveAutoPurge.days`)})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`archiveAutoPurge.ageDescription`)})]}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,disabled:!mn.enabled,checked:mn.purge_stats,onChange:e=>gn({purge_stats:e.target.checked}),className:`mt-0.5 shrink-0 disabled:opacity-50`}),(0,G.jsxs)(`span`,{className:`text-sm`,children:[(0,G.jsx)(`span`,{className:`text-white block`,children:i(`archiveAutoPurge.purgeStatsLabel`)}),(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray block mt-0.5`,children:i(`archiveAutoPurge.purgeStatsDescription`)})]})]})]})]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-md`,children:[(0,G.jsxs)(jd,{id:`card-camera`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Vu,{className:`w-5 h-5 text-bambu-green`}),i(`settings.camera`)]})}),(0,G.jsx)(Nd,{className:`space-y-3`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-white mb-2`,children:i(`settings.externalCameras`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-3`,children:i(`settings.externalCamerasDescription`)}),Yt&&Yt.length>0?(0,G.jsx)(`div`,{className:`space-y-3`,children:Yt.map(e=>(0,G.jsxs)(`div`,{className:`p-3 bg-bambu-dark rounded-lg`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsx)(`span`,{className:`text-white font-medium text-sm`,children:e.name}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e.external_camera_enabled,onChange:t=>mr(e.id,{enabled:t.target.checked}),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`space-y-2 mt-2`,children:[(0,G.jsx)(`input`,{type:`text`,placeholder:e.external_camera_type===`usb`?i(`settings.cameraPlaceholderUsb`):i(`settings.cameraPlaceholderUrl`),value:rr[e.id]??e.external_camera_url??``,onChange:t=>fr(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,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`select`,{value:e.external_camera_type||`mjpeg`,onChange:t=>mr(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,G.jsx)(`option`,{value:`mjpeg`,children:i(`settings.cameraTypeMjpeg`)}),(0,G.jsx)(`option`,{value:`rtsp`,children:i(`settings.cameraTypeRtsp`)}),(0,G.jsx)(`option`,{value:`snapshot`,children:i(`settings.cameraTypeSnapshot`)}),(0,G.jsx)(`option`,{value:`usb`,children:i(`settings.cameraTypeUsb`)})]}),(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>nr(e.id,rr[e.id]??e.external_camera_url??``,e.external_camera_type||`mjpeg`),disabled:At[e.id]||!(rr[e.id]??e.external_camera_url),children:At[e.id]?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):i(`settings.test`)})]}),Dt[e.id]&&(0,G.jsx)(`div`,{className:`text-xs flex items-center gap-1 ${Dt[e.id]?.success?`text-green-500`:`text-red-500`}`,children:Dt[e.id]?.success?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ys,{className:`w-3 h-3`}),i(`settings.connected`),Dt[e.id]?.resolution&&` (${Dt[e.id]?.resolution})`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ts,{className:`w-3 h-3`}),Dt[e.id]?.error||i(`settings.toast.connectionFailed`)]})}),(e.external_camera_type===`mjpeg`||e.external_camera_type===`rtsp`||e.external_camera_type===`usb`)&&(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:i(`settings.cameraSnapshotUrl`,`Snapshot URL (optional)`)}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`input`,{type:`text`,placeholder:i(`settings.cameraSnapshotUrlPlaceholder`,`http://192.168.1.61:1984/api/frame.jpeg?src=printer`),value:cr[e.id]??e.external_camera_snapshot_url??``,onChange:t=>pr(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,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>nr(e.id,cr[e.id]??e.external_camera_snapshot_url??``,`snapshot`),disabled:At[e.id]||!(cr[e.id]??e.external_camera_snapshot_url),children:At[e.id]?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):i(`settings.test`)})]}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:i(`settings.cameraRotation`)}),(0,G.jsxs)(`select`,{value:e.camera_rotation||0,onChange:t=>mr(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,G.jsx)(`option`,{value:0,children:`0°`}),(0,G.jsx)(`option`,{value:90,children:`90°`}),(0,G.jsx)(`option`,{value:180,children:`180°`}),(0,G.jsx)(`option`,{value:270,children:`270°`})]})]})]})]},e.id))}):(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray italic`,children:i(`settings.noPrintersConfigured`)})]})})]}),(0,G.jsxs)(jd,{id:`card-cost`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.costTracking`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.currency`)}),(0,G.jsx)(`select`,{value:A.currency,onChange:e=>tr(`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:aee.map(e=>(0,G.jsx)(`option`,{value:e.code,children:e.label},e.code))})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.defaultFilamentCost`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none`,children:wf(A.currency)}),(0,G.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,value:A.default_filament_cost,onChange:e=>tr(`default_filament_cost`,parseFloat(e.target.value)||0),style:{paddingLeft:`${Math.max(2,wf(A.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.electricityCost`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none`,children:wf(A.currency)}),(0,G.jsx)(`input`,{type:`number`,step:`0.001`,min:`0`,value:A.energy_cost_per_kwh,onChange:e=>tr(`energy_cost_per_kwh`,parseFloat(e.target.value)||0),style:{paddingLeft:`${Math.max(2,wf(A.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.energyDisplayMode`)}),(0,G.jsxs)(`select`,{value:A.energy_tracking_mode||`total`,onChange:e=>tr(`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,G.jsx)(`option`,{value:`print`,children:i(`settings.printsOnly`)}),(0,G.jsx)(`option`,{value:`total`,children:i(`settings.totalConsumption`)})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:A.energy_tracking_mode===`print`?i(`settings.energyModePrintDescription`):i(`settings.energyModeTotalDescription`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.billingEnabled`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.billingEnabledDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.billing_enabled??!1,onChange:e=>tr(`billing_enabled`,e.target.checked),className:`peer sr-only`}),(0,G.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary rounded-full peer-checked:bg-bambu-green peer-checked:after:translate-x-5 after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border after:rounded-full after:h-5 after:w-5 after:transition-all`})]})]}),A.billing_enabled&&(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.printerKillSwitch`,`Unauthorized print kill switch`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.printerKillSwitchDescription`,`Immediately stop prints that start without authorization.`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.printer_kill_switch_enabled??!1,onChange:e=>tr(`printer_kill_switch_enabled`,e.target.checked),className:`peer sr-only`}),(0,G.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary rounded-full peer-checked:bg-bambu-green peer-checked:after:translate-x-5 after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border after:rounded-full after:h-5 after:w-5 after:transition-all`})]})]}),A.billing_enabled&&(0,G.jsxs)(`div`,{className:`mt-4 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-4`,children:[(0,G.jsx)(`div`,{className:`mb-3`,children:(0,G.jsxs)(`h4`,{className:`text-base font-medium text-white flex items-center gap-2`,children:[(0,G.jsx)(rs,{className:`w-4 h-4 text-bambu-green`}),i(`settings.financeBudgetReset`,`Finance Monthly Budget Reset`)]})}),(0,G.jsxs)(`div`,{className:`flex gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.financeBudgetResetDay`,`Reset Day`)}),(0,G.jsx)(`input`,{type:`number`,min:1,max:31,value:A.finance_budget_reset_day??1,onChange:e=>tr(`finance_budget_reset_day`,Math.max(1,Math.min(31,parseInt(e.target.value,10)||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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.financeBudgetResetDayHelp`,`For short months, reset uses the last day of the month.`)})]}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.financeBudgetResetTimezone`,`Reset timezone`)}),(0,G.jsxs)(`select`,{value:A.finance_budget_reset_timezone??`UTC`,onChange:e=>tr(`finance_budget_reset_timezone`,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:outline-none focus:border-bambu-green`,children:[(0,G.jsx)(`option`,{value:`UTC`,children:`UTC`}),(0,G.jsx)(`option`,{value:`Europe/Berlin`,children:`Europe/Berlin`}),(0,G.jsx)(`option`,{value:`Europe/Vienna`,children:`Europe/Vienna`}),(0,G.jsx)(`option`,{value:`Europe/Zurich`,children:`Europe/Zurich`}),(0,G.jsx)(`option`,{value:`America/New_York`,children:`America/New_York`}),(0,G.jsx)(`option`,{value:`America/Chicago`,children:`America/Chicago`}),(0,G.jsx)(`option`,{value:`America/Denver`,children:`America/Denver`}),(0,G.jsx)(`option`,{value:`America/Los_Angeles`,children:`America/Los_Angeles`}),(0,G.jsx)(`option`,{value:`Asia/Tokyo`,children:`Asia/Tokyo`}),(0,G.jsx)(`option`,{value:`Asia/Singapore`,children:`Asia/Singapore`}),(0,G.jsx)(`option`,{value:`Australia/Sydney`,children:`Australia/Sydney`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.financeBudgetResetTimezoneHelp`,`Budget window start is calculated in this timezone.`)})]})]})]}),A.billing_enabled&&l&&(0,G.jsxs)(`div`,{className:`mt-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>fe(!0),disabled:pe,children:pe?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 mr-2 animate-spin`}),i(`settings.rebuildLedgerInProgress`,`Starting...`)]}):i(`settings.rebuildLedger`,`Rebuild wallet ledger`)}),de&&(0,G.jsx)(Xd,{title:i(`settings.rebuildLedgerConfirmTitle`,`Rebuild wallet ledger?`),message:i(`settings.rebuildLedgerConfirmMessage`,`This will rebuild the wallet ledger to repair historical balance values. Run this only if you know what you are doing.`),confirmText:i(`common.run`,`Run`),cancelText:i(`common.cancel`,`Cancel`),isLoading:pe,loadingText:i(`common.running`,`Running`),variant:`warning`,onCancel:()=>fe(!1),onConfirm:async()=>{me(!0);try{await Z.rebuildBalanceLedger(),o(i(`settings.rebuildLedgerStarted`,`Ledger rebuild started`),`success`),fe(!1)}catch(e){o(e.message||`Failed to start ledger rebuild`,`error`)}finally{me(!1)}}})]})]})]})]}),(0,G.jsxs)(jd,{id:`card-filemanager`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(cc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.fileManager`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.createArchiveEntry`)}),(0,G.jsxs)(`select`,{value:A.library_archive_mode??`ask`,onChange:e=>tr(`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,G.jsx)(`option`,{value:`always`,children:i(`settings.archiveMode.always`)}),(0,G.jsx)(`option`,{value:`never`,children:i(`settings.archiveMode.never`)}),(0,G.jsx)(`option`,{value:`ask`,children:i(`settings.archiveMode.ask`)})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.createArchiveEntryDescription`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.lowDiskSpaceWarning`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:`0.5`,max:`100`,step:`0.5`,value:A.library_disk_warning_gb??5,onChange:e=>tr(`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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`GB`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.lowDiskSpaceDescription`)})]}),ln&&un&&(0,G.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-3 mt-3 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`libraryAutoPurge.enableLabel`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`libraryAutoPurge.enableDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:un.auto_purge_enabled,onChange:e=>fn({auto_purge_enabled:e.target.checked}),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`libraryAutoPurge.ageLabel`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:7,max:3650,disabled:!un.auto_purge_enabled,value:un.auto_purge_days,onChange:e=>fn({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,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`libraryAutoPurge.days`)})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`libraryAutoPurge.ageDescription`)})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-white cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,disabled:!un.auto_purge_enabled,checked:un.auto_purge_include_never_printed,onChange:e=>fn({auto_purge_include_never_printed:e.target.checked}),className:`rounded border-gray-300 disabled:opacity-50`}),i(`libraryAutoPurge.includeNeverPrinted`)]})]})]})]}),(0,G.jsxs)(jd,{id:`card-data`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.dataManagement`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.clearNotificationLogs`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.clearNotificationLogsDescription`)})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>He(!0),children:[(0,G.jsx)(Au,{className:`w-4 h-4`}),i(`common.clear`)]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.resetUiPreferences`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.resetUiPreferencesDescription`)})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>We(!0),children:[(0,G.jsx)(Au,{className:`w-4 h-4`}),i(`settings.reset`)]})]}),(0,G.jsxs)(`div`,{className:`pt-4 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.storageUsage`,`Storage Usage`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.storageUsageDescription`,`Breakdown of data usage by category`)})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:Rt,disabled:Lt||rt,children:[(0,G.jsx)(Rl,{className:`w-4 h-4 ${Lt||rt?`animate-spin`:``}`}),i(`common.refresh`,`Refresh`)]})]}),(0,G.jsx)(`div`,{className:`mt-3`,children:It?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),i(`common.loading`,`Loading`)]}):Ft?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`w-full h-3 bg-bambu-dark rounded-full overflow-hidden flex`,children:Ft.categories.filter(e=>e.bytes>0).map((e,t)=>(0,G.jsx)(`div`,{className:`${M8(e.key,t)} h-full`,style:{width:`${e.percent_of_total}%`},title:`${e.label}: ${e.formatted}`},e.key))}),(0,G.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-3`,children:Ft.categories.filter(e=>e.bytes>0).map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsx)(`span`,{className:`w-3 h-3 rounded-full ${M8(e.key,t)}`}),(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:e.label}),(0,G.jsx)(`span`,{className:`text-white`,children:e.formatted}),(0,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,e.percent_of_total.toFixed(1),`%)`]})]},e.key))}),(0,G.jsxs)(`div`,{className:`mt-2 text-xs text-bambu-gray`,children:[i(`settings.storageUsageTotal`,`Total`),`: `,(0,G.jsx)(`span`,{className:`text-white`,children:Ft.total_formatted}),Ft.scan_errors>0&&(0,G.jsxs)(`span`,{className:`ml-2 text-amber-700 dark:text-amber-400`,children:[i(`settings.storageUsageErrors`,`Scan errors`),`: `,Ft.scan_errors]})]}),Ft.other_breakdown?.length>0&&(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:i(`settings.storageUsageOtherBreakdown`,`Other breakdown`)}),(0,G.jsx)(`div`,{className:`space-y-2`,children:Ft.other_breakdown.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-white`,children:e.label}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,G.jsx)(`span`,{className:`text-white`,children:e.formatted}),(0,G.jsxs)(`span`,{children:[`(`,e.percent_of_total.toFixed(1),`%)`]})]})]},`${e.bucket}-${e.kind}`))})]})]}):(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.storageUsageUnavailable`,`Storage usage data is unavailable`)})})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-4 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.backupRestore`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.backupRestoreDescription`)})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>Te(`backup`),children:[(0,G.jsx)(Us,{className:`w-4 h-4`}),i(`settings.goToBackup`)]})]})]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-sm`,children:[(0,G.jsxs)(jd,{id:`card-updates`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.updates`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-bambu-gray uppercase tracking-wider`,children:i(`settings.printerFirmware`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.checkPrinterFirmware`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.checkFirmwareDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.check_printer_firmware??!0,onChange:e=>tr(`check_printer_firmware`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:(0,G.jsx)(`p`,{className:`text-xs font-medium text-bambu-gray uppercase tracking-wider mb-4`,children:i(`settings.bambuddySoftware`)})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.checkForUpdatesLabel`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.autoCheckDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.check_updates,onChange:e=>tr(`check_updates`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between ${A.check_updates?``:`opacity-50`}`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.includeBetaUpdates`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.includeBetaUpdatesDesc`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.include_beta_updates??!1,onChange:e=>tr(`include_beta_updates`,e.target.checked),disabled:!A.check_updates,className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.currentVersion`)}),(0,G.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[`v`,cn?.version||`...`]})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>vn(),disabled:yn,children:[yn?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Rl,{className:`w-4 h-4`}),i(`settings.checkNow`)]})]}),_n?.update_available?(0,G.jsxs)(`div`,{className:`mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`p`,{className:`text-bambu-green font-medium`,children:[`Update available: v`,_n.latest_version]}),_n.release_name&&_n.release_name!==_n.latest_version&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:_n.release_name})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_n.release_notes&&(0,G.jsx)(`button`,{onClick:()=>Je(!0),className:`text-bambu-gray hover:text-white transition-colors text-sm underline`,children:i(`settings.releaseNotes`)}),_n.release_url&&(0,G.jsx)(`a`,{href:_n.release_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-bambu-gray hover:text-white transition-colors`,title:i(`settings.viewReleaseOnGitHub`),children:(0,G.jsx)(ec,{className:`w-4 h-4`})})]})]}),bn?.status===`downloading`||bn?.status===`installing`?(0,G.jsxs)(`div`,{className:`mt-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),(0,G.jsx)(`span`,{children:bn.message})]}),(0,G.jsx)(`div`,{className:`mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2`,children:(0,G.jsx)(`div`,{className:`bg-bambu-green h-2 rounded-full transition-all duration-300`,style:{width:`${bn.progress}%`}})})]}):bn?.status===`complete`?(0,G.jsx)(`div`,{className:`mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green`,children:bn.message}):bn?.status===`error`?(0,G.jsx)(`div`,{className:`mt-3 p-2 bg-red-100 dark:bg-red-500/20 rounded text-sm text-red-700 dark:text-red-400`,children:bn.error||bn.message}):_n?.is_ha_addon?(0,G.jsx)(`div`,{className:`mt-3 p-3 bg-bambu-dark-tertiary rounded-lg`,children:(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.updateViaHomeAssistant`)})}):_n?.is_docker?(0,G.jsxs)(`div`,{className:`mt-3 p-3 bg-bambu-dark-tertiary rounded-lg`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-2`,children:i(`settings.updateViaDocker`)}),(0,G.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,G.jsx)(`code`,{className:`flex-1 block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono break-all select-all`,children:br}),(0,G.jsx)(UW,{value:br,titleKey:`settings.copyUpdateCommand`,copiedTitleKey:`printers.copied`,className:`ml-0 p-2 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors flex-shrink-0`,iconClassName:`w-4 h-4`})]}),(0,G.jsxs)(`label`,{className:`block mt-3`,children:[(0,G.jsx)(`span`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.composeDirectory`)}),(0,G.jsx)(`input`,{type:`text`,value:A?.docker_compose_dir??``,onChange:e=>tr(`docker_compose_dir`,e.target.value),placeholder:_n?.compose_dir_detected||`/opt/bambuddy`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white font-mono placeholder:text-bambu-gray/60 focus:outline-none focus:border-bambu-green`}),(0,G.jsx)(`span`,{className:`block text-xs text-bambu-gray mt-1`,children:i(`settings.composeDirectoryHint`)})]})]}):_n?.update_method===`windows_installer`?(0,G.jsxs)(`div`,{className:`mt-3 p-3 bg-bambu-dark-tertiary rounded-lg`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-3`,children:i(`settings.updateViaWindowsInstaller`)}),(0,G.jsxs)(`a`,{href:_n.installer_download_url||_n.release_url||`https://github.com/maziggy/bambuddy/releases/tag/v${_n.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,G.jsx)(qs,{className:`w-4 h-4`}),i(`settings.downloadWindowsInstaller`,{version:_n.latest_version})]})]}):(0,G.jsxs)(Q,{className:`mt-3`,onClick:()=>Un.mutate(),disabled:Un.isPending,children:[Un.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(qs,{className:`w-4 h-4`}),i(`settings.installUpdate`)]})]}):_n?.error?(0,G.jsx)(`div`,{className:`mt-2 p-2 bg-red-50 dark:bg-red-500/10 border border-red-300 dark:border-red-500/30 rounded text-sm text-red-700 dark:text-red-400`,children:i(`settings.failedToCheckUpdates`,{error:_n.error})}):_n&&!_n.update_available?(0,G.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray`,children:i(`settings.latestVersionRunning`)}):null]})]})]}),(0,G.jsx)(fHe,{})]})]})]}),ye===`network`&&A&&(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-6`,children:[(0,G.jsxs)(`div`,{className:`flex-1 lg:max-w-xl space-y-3`,children:[(0,G.jsxs)(jd,{id:`card-externalurl`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Ec,{className:`w-5 h-5 text-blue-600 dark:text-blue-400`}),i(`settings.externalUrl`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.externalUrlDescription`)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.bambuddyUrl`)}),(0,G.jsx)(`input`,{type:`text`,value:A.external_url??``,onChange:e=>tr(`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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.externalUrlHint`)})]})]})]}),(0,G.jsxs)(jd,{id:`card-ftpretry`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Rl,{className:`w-5 h-5 text-blue-600 dark:text-blue-400`}),i(`settings.ftpRetry`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.ftpRetryDescription`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.enableRetry`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.autoRetryDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.ftp_retry_enabled??!0,onChange:e=>tr(`ftp_retry_enabled`,e.target.checked),className:`sr-only peer`}),(0,G.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.ftp_retry_enabled&&(0,G.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.retryAttempts`)}),(0,G.jsxs)(`div`,{className:`relative w-44`,children:[(0,G.jsx)(`select`,{value:A.ftp_retry_count??3,onChange:e=>tr(`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,G.jsx)(`option`,{value:e,children:i(`settings.time`,{count:e})},e))}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.retryDelay`)}),(0,G.jsxs)(`div`,{className:`relative w-44`,children:[(0,G.jsx)(`select`,{value:A.ftp_retry_delay??2,onChange:e=>tr(`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,G.jsx)(`option`,{value:e,children:i(`settings.second`,{count:e})},e))}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.connectionTimeout`)}),(0,G.jsxs)(`div`,{className:`relative w-44`,children:[(0,G.jsx)(`select`,{value:A.ftp_timeout??30,onChange:e=>tr(`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,G.jsx)(`option`,{value:e,children:i(`settings.nSeconds`,{count:e})},e))}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.increaseForWeakWifi`)})]})]})]})]})]}),(0,G.jsxs)(`div`,{className:`flex-1 lg:max-w-xl space-y-3`,children:[(0,G.jsxs)(jd,{id:`card-ha`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Fc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.homeAssistant`)]}),A.ha_enabled&&Ct&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${Ct.success?`bg-green-400`:`bg-red-400`}`}),(0,G.jsx)(`span`,{className:`text-sm ${Ct.success?`text-green-700 dark:text-green-400`:`text-red-700 dark:text-red-400`}`,children:Ct.success?i(`settings.connected`):i(`settings.disconnected`)})]})]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.homeAssistantFullDescription`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.enableHomeAssistant`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.homeAssistantDescription`)}),A.ha_env_managed&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1 mt-1`,children:[(0,G.jsx)(Qc,{className:`w-3 h-3 text-bambu-green`}),(0,G.jsx)(`span`,{className:`text-xs text-bambu-green`,children:i(`settings.autoEnabledViaEnv`)})]})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.ha_enabled??!1,onChange:e=>tr(`ha_enabled`,e.target.checked),disabled:A.ha_env_managed,className:`sr-only peer`}),(0,G.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.ha_env_managed?`opacity-60 cursor-not-allowed`:``}`})]})]}),A.ha_enabled&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.homeAssistantUrl`),A.ha_url_from_env&&(0,G.jsx)(`span`,{className:`ml-2 text-xs text-bambu-green`,children:i(`settings.environmentManagedLabel`)})]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:`text`,value:A.ha_url??``,onChange:e=>tr(`ha_url`,e.target.value),placeholder:`http://192.168.1.100:8123`,disabled:A.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 ${A.ha_url_from_env?`opacity-60 cursor-not-allowed`:``}`}),A.ha_url_from_env&&(0,G.jsx)(Qc,{className:`absolute right-3 top-2.5 w-4 h-4 text-bambu-gray`})]}),A.ha_url_from_env&&(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.urlFromEnvReadOnly`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.longLivedAccessToken`),A.ha_token_from_env&&(0,G.jsx)(`span`,{className:`ml-2 text-xs text-bambu-green`,children:i(`settings.environmentManagedLabel`)})]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:`password`,value:A.ha_token??``,onChange:e=>tr(`ha_token`,e.target.value),placeholder:`eyJ0eXAiOiJKV1QiLC...`,disabled:A.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 ${A.ha_token_from_env?`opacity-60 cursor-not-allowed`:``}`}),A.ha_token_from_env&&(0,G.jsx)(Qc,{className:`absolute right-3 top-2.5 w-4 h-4 text-bambu-gray`})]}),A.ha_token_from_env?(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.tokenFromEnvReadOnly`)}):(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.haTokenHint`)})]}),A.ha_url&&A.ha_token&&(0,G.jsx)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,disabled:Tt,onClick:async()=>{Et(!0),wt(null);try{wt(await Z.testHAConnection(A.ha_url,A.ha_token))}catch(e){wt({success:!1,message:null,error:e instanceof Error?e.message:i(`common.unknownError`)})}finally{Et(!1)}},children:[Tt?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Ju,{className:`w-4 h-4`}),i(`settings.testConnection`)]})})]})]})]}),(0,G.jsxs)(jd,{id:`card-mqtt`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Ju,{className:`w-5 h-5 text-blue-600 dark:text-blue-400`}),i(`settings.mqttPublishing`)]}),Sn?.enabled&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${Sn.connected?`bg-green-400`:`bg-red-400`}`}),(0,G.jsx)(`span`,{className:`text-sm ${Sn.connected?`text-green-700 dark:text-green-400`:`text-red-700 dark:text-red-400`}`,children:Sn.connected?i(`settings.connected`):i(`settings.disconnected`)})]})]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.mqttDescription`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.enableMqtt`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.mqttEnableDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.mqtt_enabled??!1,onChange:e=>tr(`mqtt_enabled`,e.target.checked),className:`sr-only peer`}),(0,G.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.mqtt_enabled&&(0,G.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.brokerHostname`)}),(0,G.jsx)(`input`,{type:`text`,value:A.mqtt_broker??``,onChange:e=>tr(`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,G.jsxs)(`div`,{className:`flex items-end gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.port`)}),(0,G.jsx)(`input`,{type:`number`,min:`1`,max:`65535`,value:A.mqtt_port??1883,onChange:e=>tr(`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,G.jsxs)(`div`,{className:`flex items-center gap-3 pb-2`,children:[(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.mqtt_use_tls??!1,onChange:e=>{let t=e.target.checked;tr(`mqtt_use_tls`,t);let n=A.mqtt_port??1883;t&&n===1883?tr(`mqtt_port`,8883):!t&&n===8883&&tr(`mqtt_port`,1883)},className:`sr-only peer`}),(0,G.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,G.jsx)(`span`,{className:`text-white text-sm`,children:i(`settings.useTls`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.usernameOptional`)}),(0,G.jsx)(`input`,{type:`text`,value:A.mqtt_username??``,onChange:e=>tr(`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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.passwordOptional`)}),(0,G.jsx)(`input`,{type:`password`,value:A.mqtt_password??``,onChange:e=>tr(`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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.topicPrefix`)}),(0,G.jsx)(`input`,{type:`text`,value:A.mqtt_topic_prefix??`bambuddy`,onChange:e=>tr(`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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.topicPrefixHint`,{prefix:A.mqtt_topic_prefix||`bambuddy`})})]}),Sn&&(0,G.jsx)(`div`,{className:`pt-3 mt-3 border-t border-bambu-dark-tertiary`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${Sn.connected?`bg-green-400`:`bg-red-400`}`}),(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:Sn.connected?(0,G.jsxs)(G.Fragment,{children:[i(`settings.mqttConnectedTo`),` `,(0,G.jsxs)(`span`,{className:`text-white`,children:[Sn.broker,`:`,Sn.port]})]}):i(`settings.spoolmanDisconnected`)})]})})]})]})]})]}),(0,G.jsx)(`div`,{className:`flex-1 lg:max-w-md space-y-3`,children:(0,G.jsxs)(jd,{id:`card-prometheus`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Mu,{className:`w-5 h-5 text-orange-600 dark:text-orange-400`}),i(`settings.prometheusMetrics`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.prometheusEndpointDescription`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.enableMetricsEndpoint`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.prometheusDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.prometheus_enabled??!1,onChange:e=>tr(`prometheus_enabled`,e.target.checked),className:`sr-only peer`}),(0,G.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.prometheus_enabled&&(0,G.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.bearerTokenOptional`)}),(0,G.jsx)(`input`,{type:`password`,value:A.prometheus_token??``,onChange:e=>tr(`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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.bearerTokenHint`)})]}),(0,G.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white mb-2`,children:i(`settings.availableMetrics`)}),(0,G.jsxs)(`div`,{className:`text-xs text-bambu-gray space-y-1`,children:[(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`code`,{className:`text-orange-700 dark:text-orange-400`,children:`bambuddy_printer_connected`}),` - `,i(`settings.metricsConnectionStatus`)]}),(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`code`,{className:`text-orange-700 dark:text-orange-400`,children:`bambuddy_printer_state`}),` - `,i(`settings.metricsPrinterState`)]}),(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`code`,{className:`text-orange-700 dark:text-orange-400`,children:`bambuddy_print_progress`}),` - `,i(`settings.metricsPrintProgress`)]}),(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`code`,{className:`text-orange-700 dark:text-orange-400`,children:`bambuddy_bed_temp_celsius`}),` - `,i(`settings.metricsBedTemp`)]}),(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`code`,{className:`text-orange-700 dark:text-orange-400`,children:`bambuddy_nozzle_temp_celsius`}),` - `,i(`settings.metricsNozzleTemp`)]}),(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`code`,{className:`text-orange-700 dark:text-orange-400`,children:`bambuddy_prints_total`}),` - `,i(`settings.metricsPrintsTotal`)]}),(0,G.jsx)(`p`,{className:`text-bambu-gray/70 italic`,children:i(`settings.metricsMore`)})]})]})]})]})]})})]}),Ct&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,G.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[Ct.success?(0,G.jsx)(ys,{className:`w-8 h-8 text-green-600 dark:text-green-400`}):(0,G.jsx)(Ts,{className:`w-8 h-8 text-red-600 dark:text-red-400`}),(0,G.jsx)(`h3`,{className:`text-lg font-medium text-white`,children:Ct.success?i(`settings.connectionSuccessful`):i(`settings.connectionFailed`)})]}),(0,G.jsx)(`p`,{className:`text-bambu-gray mb-6`,children:Ct.success?Ct.message||i(`settings.haConnectionSuccess`):Ct.error||i(`settings.haConnectionFailed`)}),(0,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(Q,{variant:`primary`,onClick:()=>wt(null),children:i(`settings.ok`)})})]})}),ye===`plugs`&&(0,G.jsxs)(`div`,{id:`card-plugs`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Al,{className:`w-5 h-5 text-bambu-green`}),i(`settings.smartPlugs`)]}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.smartPlugsDescription`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 pt-1 shrink-0`,children:[zt&&zt.filter(e=>e.enabled).length>1&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>Ke(`on`),disabled:qn.isPending,title:i(`settings.turnAllPlugsOn`),children:[qn.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Nl,{className:`w-4 h-4 text-bambu-green`}),i(`settings.allOn`)]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>Ke(`off`),disabled:qn.isPending,title:i(`settings.turnAllPlugsOff`),children:[qn.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Ml,{className:`w-4 h-4 text-red-600 dark:text-red-400`}),i(`settings.allOff`)]})]}),(0,G.jsxs)(Q,{className:`whitespace-nowrap`,onClick:()=>{L(null),F(!0)},children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.addSmartPlug`)]})]})]}),zt&&zt.length>0&&(0,G.jsxs)(jd,{className:`mb-6`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(ed,{className:`w-4 h-4 text-yellow-600 dark:text-yellow-400`}),i(`settings.energySummary`),Ht&&(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin text-bambu-gray ml-2`})]})}),(0,G.jsx)(Nd,{children:Vt?(0,G.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,G.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,G.jsx)(ed,{className:`w-3 h-3`}),i(`settings.currentPower`)]}),(0,G.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Vt.totalPower.toFixed(1),(0,G.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`W`})]}),(0,G.jsx)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.plugsOnline`,{reachable:Vt.reachableCount,total:Vt.totalPlugs})})]}),(0,G.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,G.jsx)(rs,{className:`w-3 h-3`}),i(`settings.today`)]}),(0,G.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Vt.totalToday.toFixed(3),(0,G.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`kWh`})]}),(A?.energy_cost_per_kwh??0)>0&&(0,G.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:[`~`,(Vt.totalToday*(A?.energy_cost_per_kwh??0)).toFixed(2),` `,wf(A?.currency||`USD`)]})]}),(0,G.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,G.jsx)(Mu,{className:`w-3 h-3`}),i(`settings.yesterday`)]}),(0,G.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Vt.totalYesterday.toFixed(3),(0,G.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`kWh`})]}),(A?.energy_cost_per_kwh??0)>0&&(0,G.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:[`~`,(Vt.totalYesterday*(A?.energy_cost_per_kwh??0)).toFixed(2),` `,wf(A?.currency||`USD`)]})]}),(0,G.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,G.jsx)(Ws,{className:`w-3 h-3`}),i(`settings.total`)]}),(0,G.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Vt.totalLifetime.toFixed(1),(0,G.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`kWh`})]}),(A?.energy_cost_per_kwh??0)>0&&(0,G.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:[`~`,(Vt.totalLifetime*(A?.energy_cost_per_kwh??0)).toFixed(2),` `,wf(A?.currency||`USD`)]})]})]}):Ht?null:(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.enablePlugsForSummary`)})})]}),Bt?(0,G.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):zt&&zt.length>0?(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4`,children:zt.map(e=>(0,G.jsx)(OVe,{plug:e,onEdit:e=>{L(e),F(!0)}},e.id))}):(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-12`,children:(0,G.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,G.jsx)(Al,{className:`w-16 h-16 mx-auto mb-4 opacity-30`}),(0,G.jsx)(`p`,{className:`text-lg font-medium text-white mb-2`,children:i(`settings.noSmartPlugsTitle`)}),(0,G.jsx)(`p`,{className:`text-sm mb-4`,children:i(`settings.noSmartPlugsDescription`)}),(0,G.jsxs)(Q,{onClick:()=>{L(null),F(!0)},children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.addFirstSmartPlug`)]})]})})}),(0,G.jsxs)(`div`,{className:`mt-8`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(xc,{className:`w-5 h-5 text-bambu-green`}),i(`haSensors.sectionTitle`)]}),(0,G.jsxs)(Q,{className:`whitespace-nowrap`,disabled:!Yt?.length,onClick:()=>{V(null),z(!0)},children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`haSensors.add`)]})]}),Xt&&Xt.length>0?(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Xt.map(e=>{let t=Yt?.find(t=>t.id===e.printer_id);return(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`py-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-white font-medium truncate`,children:e.name}),(0,G.jsx)(`div`,{className:`text-xs text-bambu-gray truncate`,children:e.entity_id}),(0,G.jsx)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:t?.name??i(`haSensors.unknownPrinter`)})]}),(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>{V(e),z(!0)},children:i(`common.edit`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-3`,children:[e.block_print&&(0,G.jsx)(`span`,{className:`px-2 py-0.5 text-xs rounded bg-amber-100 dark:bg-amber-500/20 text-amber-700 dark:text-amber-400`,children:i(`haSensors.badgeBlocks`)}),e.notify_on_alert&&(0,G.jsx)(`span`,{className:`px-2 py-0.5 text-xs rounded bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400`,children:i(`haSensors.badgeNotifies`)}),!e.show_on_printer_card&&(0,G.jsx)(`span`,{className:`px-2 py-0.5 text-xs rounded bg-bambu-dark-tertiary text-bambu-gray`,children:i(`haSensors.badgeHidden`)})]})]})},e.id)})}):(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-8`,children:(0,G.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,G.jsx)(xc,{className:`w-12 h-12 mx-auto mb-3 opacity-30`}),(0,G.jsx)(`p`,{className:`text-sm`,children:i(`haSensors.empty`)})]})})})]})]}),ye===`notifications`&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-providers`,children:[(0,G.jsx)(Go,{className:`w-5 h-5 text-bambu-green`}),i(`settings.providers`)]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(Q,{size:`sm`,variant:`secondary`,onClick:()=>ue(!0),children:[(0,G.jsx)(Pc,{className:`w-4 h-4`}),i(`settings.log`)]}),Ut&&Ut.length>0&&(0,G.jsxs)(Q,{size:`sm`,variant:`secondary`,onClick:()=>{Gn(null),Kn.mutate()},disabled:Kn.isPending,children:[Kn.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Yl,{className:`w-4 h-4`}),i(`settings.testAll`)]}),(0,G.jsxs)(Q,{size:`sm`,onClick:()=>{re(null),te(!0)},children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.addNotificationProvider`)]})]})]}),(0,G.jsx)(jd,{className:`mb-4`,children:(0,G.jsx)(Nd,{className:`py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm font-medium`,children:i(`settings.notificationLanguage`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.notificationLanguageDescription`)})]}),(0,G.jsx)(`select`,{value:A.notification_language||`en`,onChange:e=>tr(`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:kt.map(e=>(0,G.jsx)(`option`,{value:e.code,children:e.nativeName},e.code))})]})})}),(0,G.jsx)(jd,{className:`mb-4`,children:(0,G.jsx)(Nd,{className:`py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm font-medium`,children:i(`settings.bedCooledThreshold`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.bedCooledThresholdDescription`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`input`,{type:`number`,min:20,max:80,step:1,value:A.bed_cooled_threshold??35,onChange:e=>tr(`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,G.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`°C`})]})]})})}),(0,G.jsx)(jd,{className:`mb-4`,children:(0,G.jsx)(Nd,{className:`py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between ${Tn?.advanced_auth_enabled?``:`opacity-50`}`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm font-medium`,children:i(`settings.userNotificationsEnabled`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:Tn?.advanced_auth_enabled?i(`settings.userNotificationsEnabledDescription`):i(`settings.userNotificationsDisabledHint`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:A.user_notifications_enabled??!0,disabled:!Tn?.advanced_auth_enabled,onChange:e=>tr(`user_notifications_enabled`,e.target.checked)}),(0,G.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`})]})]})})}),Wn&&(0,G.jsx)(jd,{className:`mb-4`,children:(0,G.jsxs)(Nd,{className:`py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-white`,children:i(`settings.testResults`)}),(0,G.jsx)(`button`,{onClick:()=>Gn(null),className:`text-bambu-gray hover:text-white text-xs`,children:i(`common.dismiss`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-4 text-sm mb-2`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-green`,children:[(0,G.jsx)(ys,{className:`w-4 h-4`}),i(`settings.testPassedCount`,{count:Wn.success})]}),Wn.failed>0&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-red-700 dark:text-red-400`,children:[(0,G.jsx)(Ts,{className:`w-4 h-4`}),i(`settings.testFailedCount`,{count:Wn.failed})]})]}),Wn.results.filter(e=>!e.success).length>0&&(0,G.jsx)(`div`,{className:`space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary`,children:Wn.results.filter(e=>!e.success).map(e=>(0,G.jsxs)(`div`,{className:`text-xs text-red-700 dark:text-red-400`,children:[(0,G.jsxs)(`span`,{className:`font-medium`,children:[e.provider_name,`:`]}),` `,e.message]},e.provider_id))})]})}),Wt?(0,G.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,G.jsx)(Y,{className:`w-6 h-6 text-bambu-green animate-spin`})}):Ut&&Ut.length>0?(0,G.jsx)(`div`,{className:`space-y-3`,children:Ut.map(e=>(0,G.jsx)(MVe,{provider:e,onEdit:e=>{re(e),te(!0)}},e.id))}):(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-8`,children:(0,G.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,G.jsx)(Go,{className:`w-12 h-12 mx-auto mb-3 opacity-30`}),(0,G.jsx)(`p`,{className:`text-sm font-medium text-white mb-2`,children:i(`settings.noProvidersTitle`)}),(0,G.jsx)(`p`,{className:`text-xs mb-3`,children:i(`settings.noProvidersDescription`)}),(0,G.jsxs)(Q,{size:`sm`,onClick:()=>{re(null),te(!0)},children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.addProvider`)]})]})})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2 mb-2`,id:`card-templates`,children:[(0,G.jsx)(cc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.messageTemplates`)]}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-3`,children:i(`settings.messageTemplatesDescription`)}),(0,G.jsxs)(`div`,{className:`relative mb-3`,children:[(0,G.jsx)(Jl,{className:`w-4 h-4 text-bambu-gray absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none`}),(0,G.jsx)(`input`,{type:`text`,value:oe,onChange:e=>se(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`}),oe&&(0,G.jsx)(`button`,{onClick:()=>se(``),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,G.jsx)(Qu,{className:`w-3.5 h-3.5`})})]}),$t?(0,G.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,G.jsx)(Y,{className:`w-6 h-6 text-bambu-green animate-spin`})}):Qt&&Qt.length>0?(()=>{let e=oe.trim().toLowerCase(),t=[...Qt].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,G.jsx)(`p`,{className:`text-sm text-bambu-gray italic text-center py-6`,children:i(`settings.noTemplatesMatch`,`No templates match your filter.`)}):(0,G.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,G.jsx)(jd,{className:`cursor-pointer hover:border-bambu-green/50 transition-colors`,onClick:()=>ae(e),children:(0,G.jsx)(Nd,{className:`py-2.5 px-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`text-white font-medium text-sm truncate`,children:e.name}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs truncate mt-0.5`,children:e.title_template})]}),(0,G.jsx)(`button`,{className:`p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2`,onClick:t=>{t.stopPropagation(),ae(e)},children:(0,G.jsx)(Tl,{className:`w-4 h-4 text-bambu-gray`})})]})})},e.id))})})():(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-8`,children:(0,G.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,G.jsx)(cc,{className:`w-12 h-12 mx-auto mb-3 opacity-30`}),(0,G.jsx)(`p`,{className:`text-sm`,children:i(`settings.noTemplatesAvailable`)})]})})})]})]}),ye===`apikeys`&&(0,G.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,G.jsxs)(`div`,{children:[d(`api_keys:read`)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4 mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-createapi`,children:[(0,G.jsx)(Vc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.apiKeys`)]}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.apiKeysDescription`)})]}),(0,G.jsxs)(Q,{size:`sm`,onClick:()=>Oe(!0),className:`flex-shrink-0`,children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.createKey`)]})]}),Ne&&(0,G.jsx)(jd,{className:`mb-6 border-bambu-green`,children:(0,G.jsx)(Nd,{className:`py-4`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(ys,{className:`w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`p`,{className:`text-white font-medium mb-1`,children:i(`settings.apiKeyCreated`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-2`,children:i(`settings.apiKeyCopyWarning`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 bg-bambu-dark rounded-lg p-2`,children:[(0,G.jsx)(`code`,{className:`flex-1 text-sm text-bambu-green font-mono break-all`,children:Ne}),(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(Ne);else{let e=document.createElement(`textarea`);e.value=Ne,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,G.jsx)(zs,{className:`w-4 h-4`})})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 mt-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>{Be(Ne),o(i(`settings.toast.keyAddedToBrowser`))},children:i(`settings.useInApiBrowser`)}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>Ie(!0),children:[(0,G.jsx)(Fl,{className:`w-4 h-4`}),i(`settings.apiKeyQrButton`)]}),(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>{Ie(!1),Pe(null)},children:i(`common.dismiss`)})]})]})]})})}),Fe&&Ne&&(0,G.jsx)(YVe,{apiKey:Ne,baseUrl:A?.external_url||void 0,onClose:()=>Ie(!1)}),De&&(0,G.jsxs)(jd,{className:`mb-6`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h3`,{className:`text-base font-semibold text-white`,children:i(`settings.createNewApiKey`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.keyName`)}),(0,G.jsx)(`input`,{type:`text`,value:ke,onChange:e=>Ae(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:i(`common.permissions`)}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_read_status,onChange:e=>Me(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.readStatus`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.readStatusDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_queue,onChange:e=>Me(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.manageQueue`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageQueueDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_control_printer,onChange:e=>Me(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.controlPrinter`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.controlPrinterDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_manage_library,onChange:e=>Me(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.manageLibrary`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageLibraryDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_manage_inventory,onChange:e=>Me(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.manageInventory`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageInventoryDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_manage_maintenance,onChange:e=>Me(t=>({...t,can_manage_maintenance:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.manageMaintenance`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageMaintenanceDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_manage_archives,onChange:e=>Me(t=>({...t,can_manage_archives:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.manageArchives`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageArchivesDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_manage_projects,onChange:e=>Me(t=>({...t,can_manage_projects:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.manageProjects`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageProjectsDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_access_cloud,onChange:e=>Me(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.cloudAccess`,`Allow cloud access`)}),(0,G.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,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_update_energy_cost,onChange:e=>Me(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.updateEnergyCost`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.updateEnergyCostDescription`)})]})]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,G.jsxs)(Q,{onClick:()=>qt.mutate({name:ke||i(`settings.unnamedKey`),...je}),disabled:qt.isPending,children:[qt.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.createKey`)]}),(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>Oe(!1),children:i(`common.cancel`)})]})]})]}),Kt?(0,G.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):Gt&&Gt.length>0?(0,G.jsx)(`div`,{className:`space-y-3`,children:Gt.map(e=>(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(Vc,{className:`w-5 h-5 ${e.enabled?`text-bambu-green`:`text-bambu-gray`}`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white font-medium`,children:e.name}),(0,G.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[e.key_prefix,`••••••••`,e.last_used&&` · ${i(`settings.lastUsed`)}: ${Gf(e.last_used)}`]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex gap-1 text-xs flex-wrap justify-end`,children:[e.can_read_status&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400 rounded`,children:i(`settings.read`)}),e.can_queue&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-400 rounded`,children:i(`queue.title`)}),e.can_control_printer&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-orange-100 dark:bg-orange-500/20 text-orange-700 dark:text-orange-400 rounded`,children:i(`settings.control`)}),e.can_manage_library&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-cyan-100 dark:bg-cyan-500/20 text-cyan-700 dark:text-cyan-400 rounded`,children:i(`settings.libraryBadge`)}),e.can_manage_inventory&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-pink-100 dark:bg-pink-500/20 text-pink-700 dark:text-pink-400 rounded`,children:i(`settings.inventoryBadge`)}),e.can_manage_maintenance&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-teal-100 dark:bg-teal-500/20 text-teal-700 dark:text-teal-400 rounded`,children:i(`settings.maintenanceBadge`)}),e.can_manage_archives&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-indigo-100 dark:bg-indigo-500/20 text-indigo-700 dark:text-indigo-400 rounded`,children:i(`settings.archivesBadge`)}),e.can_manage_projects&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-lime-100 dark:bg-lime-500/20 text-lime-700 dark:text-lime-400 rounded`,children:i(`settings.projectsBadge`)}),e.can_access_cloud&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-400 rounded`,children:i(`settings.cloudBadge`,`Cloud`)}),e.can_update_energy_cost&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-amber-100 dark:bg-amber-500/20 text-amber-700 dark:text-amber-400 rounded`,children:i(`settings.energyCostBadge`)}),e.user_id===null&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400 rounded`,title:i(`settings.legacyKeyTooltip`,`Created before per-user ownership; recreate to use cloud access`),children:i(`settings.legacyKey`,`Legacy`)})]}),(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>Re(e.id),children:(0,G.jsx)(Au,{className:`w-4 h-4 text-red-600 dark:text-red-400`})})]})]})})},e.id))}):(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-12`,children:(0,G.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,G.jsx)(Vc,{className:`w-16 h-16 mx-auto mb-4 opacity-30`}),(0,G.jsx)(`p`,{className:`text-lg font-medium text-white mb-2`,children:i(`settings.apiKeysEmptyTitle`)}),(0,G.jsx)(`p`,{className:`text-sm mb-4`,children:i(`settings.apiKeysEmptyDescription`)}),(0,G.jsxs)(Q,{onClick:()=>Oe(!0),children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.createFirstKey`)]})]})})}),(0,G.jsxs)(jd,{className:`mt-6`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h3`,{className:`text-base font-semibold text-white`,id:`card-webhooks`,children:i(`settings.webhookEndpoints`)})}),(0,G.jsxs)(Nd,{className:`space-y-3 text-sm`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:i(`settings.webhookApiKeyHint`)}),(0,G.jsxs)(`div`,{className:`space-y-2 font-mono text-xs`,children:[(0,G.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,G.jsx)(`span`,{className:`text-blue-700 dark:text-blue-400`,children:`GET`}),` `,(0,G.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/status`}),(0,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.getAllStatus`)]})]}),(0,G.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,G.jsx)(`span`,{className:`text-blue-700 dark:text-blue-400`,children:`GET`}),` `,(0,G.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/status/:id`}),(0,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.getSpecificStatus`)]})]}),(0,G.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,G.jsx)(`span`,{className:`text-green-700 dark:text-green-400`,children:`POST`}),` `,(0,G.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/queue`}),(0,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.addToQueue`)]})]}),(0,G.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,G.jsx)(`span`,{className:`text-orange-700 dark:text-orange-400`,children:`POST`}),` `,(0,G.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/printer/:id/pause`}),(0,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.pausePrint`)]})]}),(0,G.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,G.jsx)(`span`,{className:`text-orange-700 dark:text-orange-400`,children:`POST`}),` `,(0,G.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/printer/:id/resume`}),(0,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.resumePrint`)]})]}),(0,G.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:`POST`}),` `,(0,G.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/printer/:id/stop`}),(0,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.stopPrint`)]})]})]})]})]})]}),(0,G.jsxs)(jd,{className:`mt-6`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,id:`card-camera-tokens`,children:[(0,G.jsx)(Vu,{className:`w-4 h-4 text-bambu-green`}),i(`cameraTokens.title`,`Camera API Tokens`)]})}),(0,G.jsx)(Nd,{children:(0,G.jsx)(TVe,{})})]}),(0,G.jsxs)(jd,{className:`mt-6`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,id:`card-stream-overlay`,children:[(0,G.jsx)(dl,{className:`w-4 h-4 text-bambu-green`}),i(`streamOverlay.builder.title`,`Streaming Overlay`)]})}),(0,G.jsx)(Nd,{children:(0,G.jsx)(DVe,{})})]})]}),d(`api_keys:read`)&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-6`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-apibrowser`,children:[(0,G.jsx)(Ec,{className:`w-5 h-5 text-bambu-green`}),i(`settings.apiBrowser`)]}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.apiBrowserDescription`)})]}),(0,G.jsx)(jd,{className:`mb-4`,children:(0,G.jsxs)(Nd,{className:`py-3`,children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:i(`settings.apiKeyForTesting`)}),(0,G.jsx)(`input`,{type:`text`,value:ze,onChange:e=>Be(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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-2`,children:i(`settings.apiKeyHint`)})]})}),(0,G.jsx)(UHe,{apiKey:ze})]})]}),ye===`virtual-printer`&&(0,G.jsx)(`div`,{id:`card-vp`,children:(0,G.jsx)(vHe,{})}),ye===`spoolbuddy`&&(0,G.jsx)(`div`,{id:`card-spoolbuddy`,children:(0,G.jsx)(bHe,{})}),ye===`queue`&&(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex gap-1 border-b border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`button`,{onClick:()=>Ee(`dispatch`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${Ce===`dispatch`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Jc,{className:`w-4 h-4`}),i(`settings.tabs.queueDispatch`,`Queue & Dispatch`)]}),(0,G.jsxs)(`button`,{onClick:()=>Ee(`pipelines`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${Ce===`pipelines`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Xu,{className:`w-4 h-4`}),i(`settings.tabs.queuePipelines`,`Pipelines`)]})]}),Ce===`pipelines`&&(0,G.jsx)(_Ve,{}),Ce===`dispatch`&&A&&(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,G.jsxs)(`div`,{className:`lg:w-1/2 space-y-3`,children:[(0,G.jsxs)(jd,{id:`card-print-options`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Jc,{className:`w-4 h-4 text-bambu-green`}),i(`settings.defaultPrintOptions`,`Default Print Options`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.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,tristate:!0},{key:`default_flow_cali`,label:i(`settings.defaultFlowCali`,`Flow Calibration`),desc:i(`settings.defaultFlowCaliDesc`,`Calibrate extrusion flow`),fallback:!1,dualNozzleOnly:!1,tristate:!0},{key:`default_vibration_cali`,label:i(`settings.defaultVibrationCali`,`Vibration Calibration`),desc:i(`settings.defaultVibrationCaliDesc`,`Reduce ringing artifacts`),fallback:!0,dualNozzleOnly:!1,tristate:!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,tristate:!1},{key:`default_timelapse`,label:i(`settings.defaultTimelapse`,`Timelapse`),desc:i(`settings.defaultTimelapseDesc`,`Record timelapse video`),fallback:!1,dualNozzleOnly:!1,tristate:!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,tristate:!0}].filter(({dualNozzleOnly:e})=>!e||(Yt||[]).some(e=>e.nozzle_count===2)).map(({key:e,label:t,desc:n,fallback:r,tristate:a})=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex-1 mr-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white`,children:t}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:n})]}),a?(0,G.jsx)(`div`,{className:`flex gap-1 shrink-0`,children:LW.map(t=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>tr(e,t),className:`px-2.5 py-1 text-xs rounded transition-colors ${(A[e]??`auto`)===t?RW[t]:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,children:i(`settings.calibrationMode_${t}`)},t))}):(0,G.jsx)(`div`,{className:`flex gap-1 shrink-0`,children:[`off`,`on`].map(t=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>tr(e,t===`on`),className:`px-2.5 py-1 text-xs rounded transition-colors ${(A[e]??r?`on`:`off`)===t?RW[t]:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,children:i(`settings.calibrationMode_${t}`)},t))})]},e))]})]}),(0,G.jsxs)(jd,{id:`card-plate`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(ru,{className:`w-4 h-4 text-bambu-green`}),i(`settings.plateClear`,`Plate-Clear Confirmation`)]})}),(0,G.jsx)(Nd,{className:`space-y-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex-1 mr-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white`,children:i(`settings.requirePlateClear`,`Require plate-clear confirmation`)}),(0,G.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,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.require_plate_clear??!1,onChange:e=>tr(`require_plate_clear`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(jd,{id:`card-temp-fan-presets`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Ou,{className:`w-4 h-4 text-bambu-green`}),i(`settings.tempFanPresetsTitle`,`Temperature & Fan Presets`)]})}),(0,G.jsxs)(Nd,{className:`space-y-4`,children:[(0,G.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.`)}),Pee.map(e=>{let t=gm(A?.[e.key]??``,e.defaults,e.lo,e.hi),n=e.unit===`C`?`°C`:`%`;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.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,G.jsxs)(`span`,{className:`text-bambu-gray text-xs`,children:[`(`,n,` · `,e.lo,`–`,e.hi,`)`]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>tr(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,G.jsx)(Bl,{className:`w-3.5 h-3.5`})})]}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:[0,1,2].map(n=>(0,G.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)),tr(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,G.jsxs)(jd,{id:`card-staggered`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Uc,{className:`w-4 h-4 text-bambu-green`}),i(`settings.staggeredStart`,`Staggered Start`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.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,G.jsxs)(`div`,{className:`flex gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.staggerGroupSize`,`Group size`)}),(0,G.jsx)(`input`,{type:`number`,min:1,max:50,value:A.stagger_group_size??2,onChange:e=>tr(`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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.staggerGroupSizeHelp`,`Printers to start simultaneously per group`)})]}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.staggerInterval`,`Interval (minutes)`)}),(0,G.jsx)(`input`,{type:`number`,min:1,max:60,value:A.stagger_interval_minutes??5,onChange:e=>tr(`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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.staggerIntervalHelp`,`Delay between each group starting`)})]})]})]})]}),(0,G.jsxs)(jd,{id:`card-concurrent-uploads`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(js,{className:`w-4 h-4 text-bambu-green`}),i(`settings.concurrentUploadsTitle`,`Concurrent Uploads`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.concurrentUploadsDescription`,`How many printers the queue may send files to at the same time. Printers receive files slowly (a large print can take several minutes), and each one waits its turn — so on a bigger fleet, raising this is what stops the last printer in a batch from waiting out every transfer before it. Lower it if your network or Bambuddy host struggles with parallel transfers.`)}),(0,G.jsxs)(`div`,{className:`w-full sm:w-1/2`,children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.concurrentUploadsLabel`,`Printers uploaded to at once`)}),(0,G.jsx)(`input`,{type:`number`,min:1,max:16,value:A.queue_max_concurrent_uploads??4,onChange:e=>tr(`queue_max_concurrent_uploads`,Math.max(1,Math.min(16,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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.concurrentUploadsHelp`,`1 sends to one printer at a time (the old behaviour). Default is 4.`)})]})]})]}),(0,G.jsxs)(jd,{id:`card-preheat`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(dc,{className:`w-4 h-4 text-amber-600 dark:text-amber-400`}),i(`settings.preheatTitle`,`Preheat & Heat Soak`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.preheatDescription`,`Heat the bed (and chamber, if supported) and hold at temperature before each queued print starts. Helpful for engineering filaments (PA, ABS) on printers without an active chamber heater — the bed warms the chamber by radiation while the soak timer runs. The bed target is read from the print file; chamber behaviour depends on printer model.`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex-1 mr-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white`,children:i(`settings.preheatEnabled`,`Enable preheat & soak`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.preheatEnabledDesc`,`When off, queued prints dispatch immediately.`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.preheat_enabled??!1,onChange:e=>tr(`preheat_enabled`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 pt-1`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.preheatMaxWait`,`Max wait (seconds)`)}),(0,G.jsx)(`input`,{type:`number`,min:60,max:3600,value:A.preheat_max_wait_seconds??900,onChange:e=>tr(`preheat_max_wait_seconds`,Math.max(60,Math.min(3600,parseInt(e.target.value)||900))),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 disabled:opacity-50`,disabled:!(A.preheat_enabled??!1)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.preheatMaxWaitHelp`,`Cap on the chamber warm-up phase before falling through.`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.preheatSoak`,`Soak (seconds)`)}),(0,G.jsx)(`input`,{type:`number`,min:0,max:1800,value:A.preheat_soak_seconds??300,onChange:e=>tr(`preheat_soak_seconds`,Math.max(0,Math.min(1800,parseInt(e.target.value)||0))),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 disabled:opacity-50`,disabled:!(A.preheat_enabled??!1)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.preheatSoakHelp`,`Hold time after target reached or max-wait elapsed.`)})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-2 border-t border-bambu-dark-tertiary/50`,children:[(0,G.jsxs)(`div`,{className:`flex-1 mr-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white`,children:i(`settings.keepBedWarm`,`Keep bed warm between prints`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.keepBedWarmDesc`,`While awaiting plate-clear, hold the bed at the keep-warm temperature below so the chamber stays hot — or at the next print's own bed temperature when that is higher. Only applies when the next print needs chamber heating (ASA, ABS, PA, PC etc.). Requires plate-clear confirmation to be enabled.`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.queue_keep_bed_warm??!1,onChange:e=>tr(`queue_keep_bed_warm`,e.target.checked),className:`sr-only peer`,disabled:!(A.preheat_enabled??!1)||!(A.require_plate_clear??!1)}),(0,G.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:opacity-50 peer-disabled:cursor-not-allowed`})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 mt-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.keepWarmBedTemp`,`Keep-warm bed temperature (°C)`)}),(0,G.jsx)(`input`,{type:`number`,min:40,max:110,value:A.queue_keep_warm_bed_temp??90,onChange:e=>tr(`queue_keep_warm_bed_temp`,Math.max(40,Math.min(110,parseInt(e.target.value)||90))),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 disabled:opacity-50`,disabled:!(A.preheat_enabled??!1)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.keepWarmBedTempHelp`,`Used whenever the bed's job is to heat the chamber — the keep-warm hold, and preheat when the print file carries no bed temperature. A higher bed temperature from the print file always wins.`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.keepWarmMaxMinutes`,`Stop keeping warm after (minutes)`)}),(0,G.jsx)(`input`,{type:`number`,min:5,max:480,value:A.queue_keep_warm_max_minutes??120,onChange:e=>tr(`queue_keep_warm_max_minutes`,Math.max(5,Math.min(480,parseInt(e.target.value)||120))),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 disabled:opacity-50`,disabled:!(A.queue_keep_bed_warm??!1)||!(A.preheat_enabled??!1)||!(A.require_plate_clear??!1)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.keepWarmMaxMinutesHelp`,`If the plate is not cleared within this time, the heaters are switched off rather than held indefinitely.`)})]})]}),(0,G.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary/50`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.jsx)(`label`,{className:`text-sm text-white`,children:i(`settings.preheatFilamentTargetsLabel`,`Per-filament chamber target (°C)`)}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>tr(`preheat_filament_targets`,``),title:i(`settings.preheatFilamentTargetsReset`,`Reset to defaults`),className:`text-bambu-gray hover:text-white transition-colors p-1 rounded hover:bg-bambu-dark-tertiary`,children:(0,G.jsx)(Bl,{className:`w-3.5 h-3.5`})})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:i(`settings.preheatFilamentTargetsHint`,`Bambuddy picks the highest target across the loaded AMS slots; PLA-only prints derive 0 and skip the chamber phase automatically.`)}),(0,G.jsx)(hVe,{value:A.preheat_filament_targets??``,onChange:e=>tr(`preheat_filament_targets`,e),disabled:!(A.preheat_enabled??!1)})]}),(0,G.jsxs)(`p`,{className:`text-xs text-bambu-gray pt-1 border-t border-bambu-dark-tertiary/50`,children:[(0,G.jsx)(`span`,{className:`font-medium text-bambu-gray/90`,children:i(`settings.preheatHardwareTitle`,`Per-printer behaviour:`)}),` `,i(`settings.preheatHardwareDetail`,`H2C/H2D/H2D Pro/H2S/X2D/X1E actively heat the chamber via M141. X1C/P2S read chamber temp but rely on bed-radiation heating. P1S/P1P/A1/A1 Mini have no chamber sensor — only the soak timer applies.`)]})]})]})]}),(0,G.jsxs)(`div`,{className:`lg:w-1/2 space-y-3`,children:[(0,G.jsxs)(jd,{id:`card-pipelines`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Xu,{className:`w-4 h-4 text-bambu-green`}),i(`settings.pipelineLimits.title`,`Slicer Pipeline limits`)]})}),(0,G.jsx)(Nd,{className:`space-y-2`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white`,children:i(`settings.pipelineLimits.maxCopiesLabel`,`Max copies per run`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.pipelineLimits.maxCopiesDesc`,`Upper bound on the copies operators can request when running a pipeline. Server-side hard cap is 1000.`)})]}),(0,G.jsx)(`input`,{type:`number`,min:1,max:1e3,value:A.pipeline_max_copies??50,onChange:e=>{let t=parseInt(e.target.value,10);Number.isNaN(t)||tr(`pipeline_max_copies`,Math.max(1,Math.min(1e3,t)))},"aria-label":i(`settings.pipelineLimits.maxCopiesLabel`,`Max copies per run`),className:`w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm`})]})})]}),(0,G.jsxs)(jd,{id:`card-slicer`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Is,{className:`w-4 h-4 text-bambu-green`}),i(`settings.slicerCard`,`Slicer`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[GHe()&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.sliceEngine`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`select`,{value:k8(A.slice_engine),onChange:e=>tr(`slice_engine`,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:O8().map(e=>(0,G.jsx)(`option`,{value:e.id,children:i(e.labelKey)},e.id))}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(O8().find(e=>e.id===k8(A.slice_engine))?.descriptionKey??`settings.sliceEngineSidecarHint`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.preferredSlicer`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`select`,{value:A.preferred_slicer??`bambu_studio`,onChange:e=>tr(`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,G.jsx)(`option`,{value:`bambu_studio`,children:i(`settings.slicerBambuStudio`)}),(0,G.jsx)(`option`,{value:`orcaslicer`,children:i(`settings.slicerOrcaSlicer`)})]}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.preferredSlicerDescription`)}),(A.preferred_slicer??`bambu_studio`)===`orcaslicer`&&(0,G.jsx)(`div`,{role:`alert`,className:`text-xs text-amber-800 dark:text-amber-200 bg-amber-50 dark:bg-amber-900/20 border border-amber-300 dark: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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.openInSlicerLabel`,`Open in Slicer`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`select`,{value:A.open_in_slicer??``,onChange:e=>tr(`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,G.jsx)(`option`,{value:``,children:i(`settings.openInSlicerInherit`,`Same as API slicer`)}),(0,G.jsx)(`option`,{value:`bambu_studio`,children:i(`settings.slicerBambuStudio`)}),(0,G.jsx)(`option`,{value:`orcaslicer`,children:i(`settings.slicerOrcaSlicer`)})]}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.useSlicerApi`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.useSlicerApiDescription`)})]}),(0,G.jsxs)(`label`,{className:`flex items-center cursor-pointer shrink-0`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.use_slicer_api??!1,onChange:e=>tr(`use_slicer_api`,e.target.checked),className:`sr-only peer`}),(0,G.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`})]})]}),(A.use_slicer_api??!1)&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:(A.preferred_slicer??`bambu_studio`)===`orcaslicer`?i(`settings.orcaslicerApiUrl`,`OrcaSlicer sidecar URL`):i(`settings.bambuStudioApiUrl`,`Bambu Studio sidecar URL`)}),(0,G.jsx)(`input`,{type:`text`,value:((A.preferred_slicer??`bambu_studio`)===`orcaslicer`?A.orcaslicer_api_url:A.bambu_studio_api_url)??``,onChange:e=>tr((A.preferred_slicer??`bambu_studio`)===`orcaslicer`?`orcaslicer_api_url`:`bambu_studio_api_url`,e.target.value),placeholder:(A.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,G.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.`)})]}),(A.use_slicer_api??!1)&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.slicerStallTimeout`)}),(0,G.jsx)(`input`,{type:`number`,min:1,max:240,value:A.slicer_stall_timeout_minutes??15,onChange:e=>tr(`slicer_stall_timeout_minutes`,Number(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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.slicerStallTimeoutDescription`)})]})]})]}),(0,G.jsxs)(jd,{children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,id:`card-drying`,children:[(0,G.jsx)(dc,{className:`w-4 h-4 text-amber-600 dark:text-amber-400`}),i(`settings.queueDrying`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.queueDryingDescription`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-white`,children:i(`settings.queueDryingEnabled`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.queueDryingEnabledDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.queue_drying_enabled??!1,onChange:e=>tr(`queue_drying_enabled`,e.target.checked),className:`sr-only peer`}),(0,G.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.queue_drying_enabled&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-white`,children:i(`settings.queueDryingBlock`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.queueDryingBlockDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.queue_drying_block??!1,onChange:e=>tr(`queue_drying_block`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-white`,children:i(`settings.ambientDryingEnabled`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.ambientDryingEnabledDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.ambient_drying_enabled??!1,onChange:e=>tr(`ambient_drying_enabled`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-white`,children:i(`settings.printDryingEnabled`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.printDryingEnabledDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.print_drying_enabled??!1,onChange:e=>tr(`print_drying_enabled`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white font-medium`,children:i(`settings.dryingPresets`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.dryingPresetsDescription`)}),(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,G.jsx)(`th`,{className:`text-left py-1.5`,children:i(`settings.dryingFilament`)}),(0,G.jsx)(`th`,{className:`text-center py-1.5`,colSpan:2,children:`AMS 2 Pro`}),(0,G.jsx)(`th`,{className:`text-center py-1.5`,colSpan:2,children:`AMS-HT`})]})}),(0,G.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(A.drying_presets){let n=JSON.parse(A.drying_presets);typeof n==`object`&&n&&(t={...e,...n})}}catch{}let n=(e,n,r)=>{let i={...t,[e]:{...t[e],[n]:r}};tr(`drying_presets`,JSON.stringify(i))};return Object.entries(t).map(([e,t])=>(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50`,children:[(0,G.jsx)(`td`,{className:`py-1.5 pr-2 text-white font-medium`,children:e}),(0,G.jsx)(`td`,{className:`py-1 px-1`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,G.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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})}),(0,G.jsx)(`td`,{className:`py-1 px-1`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`h`})]})}),(0,G.jsx)(`td`,{className:`py-1 px-1`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,G.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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})}),(0,G.jsx)(`td`,{className:`py-1 px-1`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`h`})]})})]},e))})()})]})})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white font-medium`,children:i(`settings.humidityThresholds`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.humidityThresholdsDescription`)}),(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,G.jsx)(`th`,{className:`text-left py-1.5`,children:i(`settings.dryingFilament`)}),(0,G.jsx)(`th`,{className:`text-right py-1.5 pr-2`,children:i(`settings.humidityThresholdCol`)})]})}),(0,G.jsx)(`tbody`,{children:(()=>{let e=A.ams_humidity_fair??60,t=[`PLA`,`PETG`,`TPU`,`ABS`,`ASA`,`PA`,`PC`,`PVA`],n={};try{if(A.ams_humidity_thresholds){let e=JSON.parse(A.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],tr(`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};tr(`ams_humidity_thresholds`,JSON.stringify(a))};return r.map(e=>{let t=M[e.key],n=t===void 0?String(e.value):t;return(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50`,children:[(0,G.jsx)(`td`,{className:`py-1.5 pr-2 font-medium ${e.isDefault?`text-bambu-gray italic`:`text-white`}`,children:e.label}),(0,G.jsx)(`td`,{className:`py-1 pr-2`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,G.jsx)(`input`,{type:`number`,min:5,max:95,value:n,onChange:t=>N(n=>({...n,[e.key]:t.target.value})),onBlur:t=>{a(e.key,t.target.value),N(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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`%`})]})})]},e.key)})})()})]})})]})]})]}),(0,G.jsxs)(jd,{id:`card-gcode`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Ns,{className:`w-4 h-4 text-bambu-green`}),i(`settings.gcodeInjection`,`G-code Injection`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.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 A.gcode_snippets?JSON.parse(A.gcode_snippets):{}}catch{return{}}})(),t=[...new Set((Yt||[]).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):``;j(e=>e?{...e,gcode_snippets:a}:null),Yn.current=a},r=()=>{Yn.current!==null&&($n.mutate({gcode_snippets:Yn.current}),Yn.current=null)};return t.length===0?(0,G.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,G.jsx)(Vp,{defaultOpen:o,className:`border border-bambu-dark-tertiary rounded-lg px-3 py-2`,summary:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:t}),o&&(0,G.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,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.gcodeStartLabel`,`Start G-code`)}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.gcodeEndLabel`,`End G-code`)}),(0,G.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)})})()]})]})]})]})]}),ye===`filament`&&A&&(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,G.jsxs)(`div`,{className:`lg:w-1/3 space-y-3`,children:[(0,G.jsx)($Ve,{}),(0,G.jsxs)(jd,{id:`card-filamentchecks`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.filamentChecks`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.disableFilamentWarnings`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.disableFilamentWarningsDesc`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.disable_filament_warnings,onChange:e=>tr(`disable_filament_warnings`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.preferLowestFilament`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.preferLowestFilamentDesc`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1`,children:i(`settings.preferLowestFilamentBackupNote`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.prefer_lowest_filament,onChange:e=>tr(`prefer_lowest_filament`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(jd,{id:`card-printmodal`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.printModal`)})}),(0,G.jsx)(Nd,{className:`space-y-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.expandCustomMapping`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.expandCustomMappingDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.per_printer_mapping_expanded??!1,onChange:e=>tr(`per_printer_mapping_expanded`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(jd,{id:`card-amsthresholds`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.amsDisplayThresholds`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.amsThresholdsDescription`)}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-white`,children:[(0,G.jsx)(Ys,{className:`w-4 h-4 text-blue-600 dark:text-blue-400`}),(0,G.jsx)(`span`,{className:`font-medium`,children:i(`settings.humidity`)})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.goodGreen`),` ≤`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:A.ams_humidity_good??40,onChange:e=>tr(`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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`%`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.fairOrange`),` ≤`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:A.ams_humidity_fair??60,onChange:e=>tr(`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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`%`})]})]})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.aboveFairBad`)}),(0,G.jsx)(`p`,{className:`text-xs text-amber-700/80 dark:text-amber-400/70`,children:i(`settings.fairAlsoDryingThreshold`)}),(A.ams_humidity_fair??60)tr(`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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.fairOrange`),` ≤`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,step:`0.5`,min:`0`,max:`60`,value:A.ams_temp_fair??35,onChange:e=>tr(`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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})]})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.aboveFairHot`)})]}),(0,G.jsxs)(`div`,{className:`space-y-3 pt-4 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-white`,children:[(0,G.jsx)(Us,{className:`w-4 h-4 text-purple-600 dark:text-purple-400`}),(0,G.jsx)(`span`,{className:`font-medium`,children:i(`settings.historyRetention`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.keepSensorHistory`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:`1`,max:`365`,value:A.ams_history_retention_days??30,onChange:e=>tr(`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,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`common.days`)})]})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.historyRetentionDescription`)})]})]})]})]}),(0,G.jsxs)(`div`,{className:`lg:w-2/3 space-y-3`,children:[(0,G.jsx)(eHe,{}),(0,G.jsx)(uHe,{})]})]})}),Le!==null&&(0,G.jsx)(Xd,{title:i(`settings.deleteApiKeyTitle`),message:i(`settings.deleteApiKeyMessage`),confirmText:i(`settings.deleteKey`),variant:`danger`,onConfirm:()=>{Jt.mutate(Le),Re(null)},onCancel:()=>Re(null)}),P&&(0,G.jsx)(kVe,{plug:I,onClose:()=>{F(!1),L(null)}}),R&&(0,G.jsx)(jVe,{sensor:B,printers:Yt??[],onClose:()=>{z(!1),V(null)}}),ee&&(0,G.jsx)(PVe,{provider:ne,onClose:()=>{te(!1),re(null)}}),ie&&(0,G.jsx)(FVe,{template:ie,onClose:()=>ae(null)}),le&&(0,G.jsx)(LVe,{onClose:()=>ue(!1)}),Ve&&(0,G.jsx)(Xd,{title:i(`settings.clearNotificationLogs`),message:i(`settings.clearLogsMessage`),confirmText:i(`settings.clearLogs`),variant:`warning`,onConfirm:async()=>{He(!1);try{o((await Z.clearNotificationLogs(30)).message,`success`)}catch{o(i(`settings.toast.clearLogsFailed`),`error`)}},onCancel:()=>He(!1)}),Ue&&(0,G.jsx)(Xd,{title:i(`settings.resetUiPreferences`),message:i(`settings.resetUiPreferencesMessage`),confirmText:i(`settings.resetPreferences`),variant:`default`,onConfirm:()=>{We(!1),localStorage.clear(),o(i(`settings.toast.uiPreferencesReset`),`success`),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>We(!1)}),Ge&&(0,G.jsx)(Xd,{title:`Turn All Plugs ${Ge===`on`?`On`:`Off`}`,message:`This will turn ${Ge===`on`?`ON`:`OFF`} all ${zt?.filter(e=>e.enabled).length||0} enabled smart plugs. ${Ge===`off`?`Any running printers may be affected!`:``}`,confirmText:`Turn All ${Ge===`on`?`On`:`Off`}`,variant:Ge===`off`?`danger`:`warning`,onConfirm:()=>{let e=Ge;Ke(null),qn.mutate(e)},onCancel:()=>Ke(null)}),qe&&_n?.release_notes&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:()=>Je(!1),children:(0,G.jsxs)(jd,{className:`w-full max-w-2xl max-h-[80vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(Md,{className:`flex flex-row items-center justify-between shrink-0`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white`,children:[`Release Notes - v`,_n.latest_version]}),_n.release_name&&_n.release_name!==_n.latest_version&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:_n.release_name})]}),(0,G.jsx)(`button`,{onClick:()=>Je(!1),className:`p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white`,children:(0,G.jsx)(Qu,{className:`w-5 h-5`})})]}),(0,G.jsx)(Nd,{className:`overflow-y-auto flex-1`,children:(0,G.jsx)(`pre`,{className:`text-sm text-bambu-gray whitespace-pre-wrap font-sans`,children:_n.release_notes})}),(0,G.jsxs)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2`,children:[_n.release_url&&(0,G.jsx)(`a`,{href:_n.release_url,target:`_blank`,rel:`noopener noreferrer`,className:`flex-1`,children:(0,G.jsxs)(Q,{variant:`secondary`,className:`w-full`,children:[(0,G.jsx)(ec,{className:`w-4 h-4`}),`View on GitHub`]})}),(0,G.jsx)(Q,{onClick:()=>Je(!1),className:`flex-1`,children:`Close`})]})]})}),ye===`users`&&(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex gap-1 border-b border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`button`,{onClick:()=>Se(`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 ${xe===`users`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(zu,{className:`w-4 h-4`}),i(`settings.tabs.users`)]}),(0,G.jsxs)(`button`,{onClick:()=>Se(`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 ${xe===`email`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(tl,{className:`w-4 h-4`}),i(`settings.tabs.emailAuth`)||`Email Authentication`,Tn?.advanced_auth_enabled&&(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green-400`})]}),(0,G.jsxs)(`button`,{onClick:()=>Se(`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 ${xe===`ldap`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(ru,{className:`w-4 h-4`}),i(`settings.tabs.ldap`)||`LDAP`,En?.ldap_enabled&&(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green-400`})]}),(0,G.jsxs)(`button`,{onClick:()=>Se(`twofa`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${xe===`twofa`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(ru,{className:`w-4 h-4`}),i(`settings.tabs.twoFa`),(0,G.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,G.jsxs)(`button`,{onClick:()=>Se(`oidc`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${xe===`oidc`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Ec,{className:`w-4 h-4`}),i(`settings.tabs.oidc`),(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${On.some(e=>e.is_enabled)?`bg-green-400`:`bg-bambu-gray/40`}`})]}),l&&(0,G.jsxs)(`button`,{onClick:()=>Se(`security`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${xe===`security`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(ru,{className:`w-4 h-4`}),i(`settings.tabs.security`)]})]}),xe===`users`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-4`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.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,G.jsx)(Qc,{className:`w-5 h-5 text-green-600 dark:text-green-400`}):(0,G.jsx)(Zc,{className:`w-5 h-5 text-gray-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-white font-medium`,children:i(`settings.authentication`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(s?`settings.authEnabledDescription`:`settings.authDisabledDescription`)})]})]}),s?c?.is_admin&&(0,G.jsxs)(Q,{variant:`secondary`,onClick:()=>Xe(!0),children:[(0,G.jsx)(Zc,{className:`w-4 h-4`}),i(`common.disable`)]}):(0,G.jsxs)(Q,{onClick:()=>t(`/setup`),children:[(0,G.jsx)(Qc,{className:`w-4 h-4`}),i(`common.enable`)]})]})})}),Tn?.advanced_auth_enabled&&(0,G.jsx)(jd,{className:`border-blue-500/30 bg-blue-500/5`,children:(0,G.jsx)(Nd,{className:`py-4`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center bg-blue-500/20 flex-shrink-0`,children:(0,G.jsx)(tl,{className:`w-5 h-5 text-blue-600 dark:text-blue-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-white font-medium`,children:i(`settings.email.advancedAuthEnabled`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.email.advancedAuthEnabledDesc`)})]})]})})}),s&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-2 gap-6`,children:[(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(jd,{id:`card-session-policy`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Qc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.sessionPolicy.title`)]})}),(0,G.jsxs)(Nd,{children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:i(`settings.sessionPolicy.description`)}),(0,G.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=(A?.session_max_hours??24)===e.hours;return(0,G.jsx)(`button`,{type:`button`,onClick:()=>tr(`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,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`input`,{type:`number`,min:1,max:720,value:A?.session_max_hours??24,onChange:e=>{let t=parseInt(e.target.value,10);Number.isNaN(t)||tr(`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,G.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:i(`settings.sessionPolicy.hoursSuffix`)})]})]}),(A?.session_max_hours??24)>24&&(0,G.jsxs)(`div`,{className:`flex items-start gap-2 p-3 rounded-lg bg-yellow-50 dark:bg-yellow-500/10 border border-yellow-300 dark:border-yellow-500/30`,children:[(0,G.jsx)(Nu,{className:`w-4 h-4 text-yellow-600 dark:text-yellow-400 flex-shrink-0 mt-0.5`}),(0,G.jsx)(`p`,{className:`text-xs text-yellow-800 dark:text-yellow-200`,children:i(`settings.sessionPolicy.warning`)})]})]})]}),c&&(0,G.jsxs)(jd,{children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-currentuser`,children:[(0,G.jsx)(zu,{className:`w-5 h-5 text-bambu-green`}),i(`settings.currentUser`)]}),c.auth_source!==`ldap`&&(0,G.jsxs)(Q,{size:`sm`,variant:`ghost`,onClick:()=>Qe(!0),children:[(0,G.jsx)(Vc,{className:`w-4 h-4`}),i(`settings.changePassword`)]})]})}),(0,G.jsx)(Nd,{children:(0,G.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white font-medium text-lg`,children:c.username}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:[c.is_admin&&(0,G.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-300`,children:i(`settings.admin`)}),c.groups?.map(e=>(0,G.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium ${e.name===`Administrators`?`bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-300`:e.name===`Operators`?`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-300`:e.name===`Viewers`?`bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-300`:`bg-gray-500/20 text-gray-300`}`,children:e.name},e.id))]})]})})})]}),(0,G.jsxs)(jd,{children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-users`,children:[(0,G.jsx)(zu,{className:`w-5 h-5 text-bambu-green`}),i(`settings.users`)]}),d(`users:create`)&&(0,G.jsxs)(Q,{size:`sm`,onClick:()=>{ot(!0),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.addUser`)]})]})}),(0,G.jsx)(Nd,{children:An?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(Y,{className:`w-6 h-6 text-bambu-green animate-spin`})}):kn.length===0?(0,G.jsx)(`p`,{className:`text-center text-bambu-gray py-8`,children:i(`settings.noUsersFound`)}):(0,G.jsx)(`div`,{className:`divide-y divide-bambu-dark-tertiary`,children:kn.map(e=>(0,G.jsxs)(`div`,{className:`py-3 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-white font-medium truncate`,children:e.username}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[e.auth_source===`ldap`&&(0,G.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium bg-cyan-100 dark:bg-cyan-500/20 text-cyan-700 dark:text-cyan-300`,children:`LDAP`}),e.is_admin&&(0,G.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-300`,children:i(`settings.admin`)}),e.groups?.map(e=>(0,G.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium ${e.name===`Administrators`?`bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-300`:e.name===`Operators`?`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-300`:e.name===`Viewers`?`bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-300`:`bg-gray-500/20 text-gray-300`}`,children:e.name},e.id))]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 ml-4`,children:[d(`users:update`)&&(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>Vn(e),children:(0,G.jsx)(Tl,{className:`w-4 h-4`})}),d(`users:delete`)&&e.id!==c?.id&&(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>Ln(e.id),children:(0,G.jsx)(Au,{className:`w-4 h-4`})})]})]},e.id))})})]})]}),(0,G.jsx)(`div`,{children:(0,G.jsxs)(jd,{children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-groups`,children:[(0,G.jsx)(ru,{className:`w-5 h-5 text-bambu-green`}),i(`settings.groups`)]}),d(`groups:create`)&&(0,G.jsxs)(Q,{size:`sm`,onClick:()=>t(`/groups/new`),children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.addGroup`)]})]})}),(0,G.jsx)(Nd,{children:Mn?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(Y,{className:`w-6 h-6 text-bambu-green animate-spin`})}):jn.length===0?(0,G.jsx)(`p`,{className:`text-center text-bambu-gray py-8`,children:i(`settings.noGroupsFound`)}):(0,G.jsx)(`div`,{className:`divide-y divide-bambu-dark-tertiary`,children:jn.map(e=>(0,G.jsxs)(`div`,{className:`py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ru,{className:`w-4 h-4 ${e.name===`Administrators`?`text-purple-600 dark:text-purple-400`:e.name===`Operators`?`text-blue-600 dark:text-blue-400`:e.name===`Viewers`?`text-green-600 dark:text-green-400`:`text-bambu-gray`}`}),(0,G.jsx)(`span`,{className:`text-white font-medium`,children:e.name}),e.is_system&&(0,G.jsx)(`span`,{className:`px-2 py-0.5 rounded text-xs bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400`,children:i(`settings.system`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[d(`groups:update`)&&(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>t(`/groups/${e.id}/edit`),children:(0,G.jsx)(Tl,{className:`w-4 h-4`})}),d(`groups:delete`)&&!e.is_system&&(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>St(e.id),children:(0,G.jsx)(Au,{className:`w-4 h-4`})})]})]}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1 ml-6`,children:e.description||i(`settings.noDescription`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-4 mt-2 ml-6 text-xs text-bambu-gray`,children:[(0,G.jsx)(`span`,{children:i(`settings.userCount`,{count:e.user_count})}),(0,G.jsx)(`span`,{children:i(`settings.permissionCount`,{count:e.permissions.length})})]})]},e.id))})})]})})]}),!s&&(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-6`,children:(0,G.jsxs)(`div`,{className:`text-center`,children:[(0,G.jsx)(Zc,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,G.jsx)(`h3`,{className:`text-lg font-medium text-white mb-2`,children:i(`settings.authDisabledTitle`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4 max-w-md mx-auto`,children:i(`settings.authDisabledMessage`)}),(0,G.jsxs)(`ul`,{className:`space-y-2 text-sm text-bambu-gray mb-6 text-left max-w-xs mx-auto`,children:[(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(ys,{className:`w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0`}),(0,G.jsx)(`span`,{children:i(`settings.authDisabledFeature1`)})]}),(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(ys,{className:`w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0`}),(0,G.jsx)(`span`,{children:i(`settings.authDisabledFeature2`)})]}),(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(ys,{className:`w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0`}),(0,G.jsx)(`span`,{children:i(`settings.authDisabledFeature3`)})]})]}),(0,G.jsxs)(Q,{onClick:()=>t(`/setup`),children:[(0,G.jsx)(Qc,{className:`w-4 h-4`}),i(`settings.enableAuthentication`)]})]})})})]}),xe===`email`&&(0,G.jsx)(`div`,{className:`max-w-5xl`,id:`card-smtp`,children:(0,G.jsx)(AHe,{})}),xe===`ldap`&&(0,G.jsx)(`div`,{className:`max-w-5xl`,id:`card-ldap`,children:(0,G.jsx)(MHe,{})}),xe===`twofa`&&(0,G.jsx)(`div`,{className:`max-w-2xl`,children:(0,G.jsx)(PHe,{})}),xe===`oidc`&&l&&(0,G.jsxs)(`div`,{className:`max-w-3xl space-y-4`,children:[(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`space-y-3 p-4`,children:(0,G.jsxs)(`label`,{className:`flex items-start gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.local_login_enabled===!1,onChange:e=>tr(`local_login_enabled`,!e.target.checked),className:`mt-1 h-4 w-4 rounded border-bambu-dark-tertiary bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green/50 cursor-pointer`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-white`,children:i(`settings.localLogin.disable`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.localLogin.disableHint`)})]})]})})}),(0,G.jsx)(LHe,{})]}),xe===`security`&&l&&(0,G.jsx)(`div`,{className:`max-w-3xl`,children:(0,G.jsx)(zHe,{})})]}),at&&!Tn?.advanced_auth_enabled&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black flex items-center justify-center z-50 p-4`,onClick:()=>{ot(!1),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,G.jsxs)(jd,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(zu,{className:`w-5 h-5 text-bambu-green`}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.createUser`)})]}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>{ot(!1),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,G.jsx)(Qu,{className:`w-5 h-5`})})]})}),(0,G.jsxs)(Nd,{children:[En?.ldap_enabled&&(0,G.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,G.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":st===`local`,onClick:()=>ct(`local`),className:`flex-1 px-3 py-2 text-sm rounded-md transition-colors ${st===`local`?`bg-bambu-green/15 text-bambu-green`:`text-bambu-gray hover:text-white`}`,children:i(`users.modal.localTab`)}),(0,G.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":st===`ldap`,onClick:()=>ct(`ldap`),className:`flex-1 px-3 py-2 text-sm rounded-md transition-colors ${st===`ldap`?`bg-bambu-green/15 text-bambu-green`:`text-bambu-gray hover:text-white`}`,children:i(`users.modal.ldapTab`)})]}),st===`ldap`&&En?.ldap_enabled?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(t8,{onSuccess:e=>{ot(!1),ct(`local`),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`users.toast.ldapProvisioned`,{username:e.username}))}}),(0,G.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{ot(!1),ct(`local`),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:i(`common.cancel`)})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.username`)}),(0,G.jsx)(`input`,{type:`text`,value:yt.username,onChange:e=>bt({...yt,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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.password`)}),(0,G.jsx)(`input`,{type:`password`,value:yt.password,onChange:e=>bt({...yt,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,G.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:i(`settings.passwordRequirements`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.confirmPassword`)}),(0,G.jsx)(`input`,{type:`password`,value:yt.confirmPassword,onChange:e=>bt({...yt,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 ${yt.confirmPassword&&yt.password!==yt.confirmPassword?`border-red-500`:`border-bambu-dark-tertiary`}`,placeholder:i(`settings.confirmPasswordPlaceholder`),autoComplete:`new-password`,minLength:6}),yt.confirmPassword&&yt.password!==yt.confirmPassword&&(0,G.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-xs mt-1`,children:i(`settings.passwordsDoNotMatch`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.groups`)}),(0,G.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:[jn.map(e=>(0,G.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:yt.group_ids.includes(e.id),onChange:()=>Hn(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,G.jsx)(`span`,{className:`text-sm text-white`,children:e.name}),e.is_system&&(0,G.jsx)(`span`,{className:`text-xs text-yellow-700 dark:text-yellow-400`,children:i(`settings.systemBadge`)})]},e.id)),jn.length===0&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.noGroupsAvailable`)})]})]})]}),(0,G.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{ot(!1),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:i(`common.cancel`)}),(0,G.jsx)(Q,{onClick:zn,disabled:Nn.isPending||!yt.username||!yt.password||yt.password!==yt.confirmPassword||T6(yt.password)!==null,children:Nn.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),i(`settings.creating`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.createUser`)]})})]})]})]})]})}),at&&Tn?.advanced_auth_enabled&&(0,G.jsx)(QVe,{formData:yt,setFormData:bt,groups:jn,onClose:()=>{ot(!1),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},onCreate:zn,isCreating:Nn.isPending,isCreateButtonDisabled:Nn.isPending||!yt.username||!yt.email,ldapEnabled:En?.ldap_enabled,onLdapProvisioned:e=>{ot(!1),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`users.toast.ldapProvisioned`,{username:e.username}))}}),lt&&dt!==null&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black flex items-center justify-center z-50 p-4`,onClick:()=>{ut(!1),ft(null),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,G.jsxs)(jd,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Tl,{className:`w-5 h-5 text-bambu-green`}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.editUser`)})]}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>{ut(!1),ft(null),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,G.jsx)(Qu,{className:`w-5 h-5`})})]})}),(0,G.jsxs)(Nd,{children:[(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[i(`settings.username`),` `,Tn?.advanced_auth_enabled&&(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:`*`})]}),(0,G.jsx)(`input`,{type:`text`,value:yt.username,onChange:e=>bt({...yt,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,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[i(`users.form.email`)||`Email`,` `,Tn?.advanced_auth_enabled?(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:`*`}):(0,G.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,i(`users.form.optional`)||`optional`,`)`]})]}),(0,G.jsx)(`input`,{type:`email`,value:yt.email,onChange:e=>bt({...yt,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:Tn?.advanced_auth_enabled})]}),!Tn?.advanced_auth_enabled&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[i(`users.form.password`)||`Password`,` `,(0,G.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,i(`users.form.leaveBlankToKeep`)||`leave blank to keep current`,`)`]})]}),(0,G.jsx)(`input`,{type:`password`,value:yt.password,onChange:e=>bt({...yt,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,G.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:i(`settings.passwordRequirements`)})]}),yt.password&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.confirmPassword`)}),(0,G.jsx)(`input`,{type:`password`,value:yt.confirmPassword,onChange:e=>bt({...yt,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 ${yt.confirmPassword&&yt.password!==yt.confirmPassword?`border-red-500`:`border-bambu-dark-tertiary`}`,placeholder:i(`settings.confirmNewPassword`),autoComplete:`new-password`,minLength:6}),yt.confirmPassword&&yt.password!==yt.confirmPassword&&(0,G.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-xs mt-1`,children:i(`settings.passwordsDoNotMatch`)})]})]}),Tn?.advanced_auth_enabled&&(0,G.jsxs)(`div`,{className:`bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3 space-y-3`,children:[(0,G.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,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>dt&&In.mutate(dt),disabled:In.isPending||!yt.email,className:`w-full`,children:In.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),i(`users.form.resettingPassword`)||`Resetting Password...`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Bl,{className:`w-4 h-4`}),i(`users.form.resetPassword`)||`Reset Password`]})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`users.form.groups`)||`Groups`}),(0,G.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:jn.map(e=>(0,G.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:yt.group_ids.includes(e.id),onChange:()=>Hn(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,G.jsx)(`span`,{className:`text-sm text-white`,children:e.name}),e.is_system&&(0,G.jsxs)(`span`,{className:`text-xs text-yellow-700 dark:text-yellow-400`,children:[`(`,i(`users.system`)||`System`,`)`]})]},e.id))})]})]}),(0,G.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{ut(!1),ft(null),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:i(`users.modal.cancel`)||`Cancel`}),(0,G.jsx)(Q,{onClick:()=>Bn(dt),disabled:Pn.isPending||!yt.username||Tn?.advanced_auth_enabled&&!yt.email||!!(!Tn?.advanced_auth_enabled&&yt.password&&(yt.password!==yt.confirmPassword||T6(yt.password)!==null)),children:Pn.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),i(`users.modal.saving`)||`Saving...`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ul,{className:`w-4 h-4`}),i(`users.modal.saveChanges`)||`Save Changes`]})})]})]})]})}),pt!==null&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4`,onClick:()=>{mt(null),gt(null)},children:(0,G.jsxs)(jd,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-red-700 dark:text-red-400`,children:[(0,G.jsx)(Au,{className:`w-5 h-5`}),(0,G.jsx)(`h3`,{className:`text-lg font-semibold`,children:i(`settings.deleteUserTitle`)})]})}),(0,G.jsx)(Nd,{className:`space-y-3`,children:_t?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,G.jsx)(`div`,{className:`animate-spin rounded-full h-6 w-6 border-2 border-bambu-green border-t-transparent`})}):ht&&ht.archives+ht.queue_items+ht.library_files>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.userHasCreated`)}),(0,G.jsxs)(`ul`,{className:`list-disc list-inside text-bambu-gray space-y-1`,children:[ht.archives>0&&(0,G.jsxs)(`li`,{children:[ht.archives,` archive`,ht.archives===1?``:`s`]}),ht.queue_items>0&&(0,G.jsxs)(`li`,{children:[ht.queue_items,` queue item`,ht.queue_items===1?``:`s`]}),ht.library_files>0&&(0,G.jsxs)(`li`,{children:[ht.library_files,` library file`,ht.library_files===1?``:`s`]})]}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:i(`settings.userItemsQuestion`)}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(Q,{variant:`danger`,onClick:()=>Fn.mutate({id:pt,deleteItems:!0}),disabled:Fn.isPending,className:`justify-center`,children:i(`settings.deleteUserAndItems`)}),(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>Fn.mutate({id:pt,deleteItems:!1}),disabled:Fn.isPending,className:`justify-center`,children:i(`settings.deleteUserKeepItems`)}),(0,G.jsx)(Q,{variant:`ghost`,onClick:()=>{mt(null),gt(null)},disabled:Fn.isPending,className:`justify-center`,children:i(`common.cancel`)})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.deleteUserConfirm`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:i(`settings.actionCannotBeUndone`)}),(0,G.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,G.jsx)(Q,{variant:`ghost`,onClick:()=>{mt(null),gt(null)},disabled:Fn.isPending,children:i(`common.cancel`)}),(0,G.jsx)(Q,{variant:`danger`,onClick:()=>Fn.mutate({id:pt,deleteItems:!1}),disabled:Fn.isPending,children:i(`settings.deleteUserTitle`)})]})]})})]})}),xt!==null&&(0,G.jsx)(Xd,{title:i(`settings.deleteGroupTitle`),message:i(`settings.deleteGroupMessage`),confirmText:i(`settings.deleteGroup`),variant:`danger`,onConfirm:()=>{Rn.mutate(xt),St(null)},onCancel:()=>St(null)}),ye===`failure-detection`&&(0,G.jsx)(`div`,{id:`card-failure-detection`,children:(0,G.jsx)(DHe,{})}),ye===`backup`&&(0,G.jsxs)(`div`,{id:`card-backup`,children:[(0,G.jsxs)(`div`,{className:`mb-4 p-3 bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/30 rounded-lg flex items-start gap-2`,children:[(0,G.jsx)(ru,{className:`text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5`,size:16}),(0,G.jsx)(`p`,{className:`text-sm text-amber-700 dark:text-amber-400`,children:i(`backup.includesEncryptionKey`)})]}),(0,G.jsx)(EHe,{})]}),Ye&&(0,G.jsx)(Xd,{title:i(`settings.disableAuthenticationTitle`),message:i(`settings.disableAuthenticationMessage`),confirmText:i(`settings.disableAuthentication`),variant:`danger`,onConfirm:async()=>{try{await Z.disableAuth(),o(i(`settings.toast.authDisabled`),`success`),await u(),Xe(!1),window.location.href=`/`}catch(e){o(e instanceof Error?e.message:i(`settings.toast.authDisableFailed`),`error`)}},onCancel:()=>Xe(!1)}),Ze&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:()=>{Qe(!1),et({currentPassword:``,newPassword:``,confirmPassword:``})},children:(0,G.jsxs)(jd,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Vc,{className:`w-5 h-5 text-bambu-green`}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.changePassword`)})]}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>{Qe(!1),et({currentPassword:``,newPassword:``,confirmPassword:``})},children:(0,G.jsx)(Qu,{className:`w-5 h-5`})})]})}),(0,G.jsxs)(Nd,{children:[(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:`Current Password`}),(0,G.jsx)(`input`,{type:`password`,value:$e.currentPassword,onChange:e=>et({...$e,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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:`New Password`}),(0,G.jsx)(`input`,{type:`password`,value:$e.newPassword,onChange:e=>et({...$e,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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:`Confirm New Password`}),(0,G.jsx)(`input`,{type:`password`,value:$e.confirmPassword,onChange:e=>et({...$e,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 ${$e.confirmPassword&&$e.newPassword!==$e.confirmPassword?`border-red-500`:`border-bambu-dark-tertiary`}`,placeholder:i(`settings.confirmNewPassword`),autoComplete:`new-password`,minLength:6}),$e.confirmPassword&&$e.newPassword!==$e.confirmPassword&&(0,G.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-xs mt-1`,children:i(`settings.passwordsDoNotMatch`)})]})]}),(0,G.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{Qe(!1),et({currentPassword:``,newPassword:``,confirmPassword:``})},children:i(`common.cancel`)}),(0,G.jsx)(Q,{onClick:async()=>{if($e.newPassword!==$e.confirmPassword){o(i(`settings.toast.passwordsDoNotMatch`),`error`);return}if($e.newPassword.length<6){o(i(`settings.toast.passwordTooShort`),`error`);return}nt(!0);try{await Z.changePassword($e.currentPassword,$e.newPassword),o(i(`settings.toast.passwordChanged`),`success`),Qe(!1),et({currentPassword:``,newPassword:``,confirmPassword:``})}catch(e){o(e instanceof Error?e.message:`Failed to change password`,`error`)}finally{nt(!1)}},disabled:tt||!$e.currentPassword||!$e.newPassword||$e.newPassword!==$e.confirmPassword||$e.newPassword.length<6,children:tt?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),i(`settings.changing`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Vc,{className:`w-4 h-4`}),i(`settings.changePassword`)]})})]})]})]})})]})]})]})})}var YHe=/\[(aborted|failed|cancelled):\s*([^\]]*)\]/i;function XHe(e){if(!e)return{isPartial:!1,partialType:null,cleanedDescription:null};let t=e.match(YHe);if(!t)return{isPartial:!1,partialType:null,cleanedDescription:e};let n=e.replace(t[0],``).trim();return{isPartial:!0,partialType:t[1].toLowerCase(),cleanedDescription:n||null}}function ZHe(e,t){if(!e)return`-`;let n=Uf(e);return n?n.toLocaleString(t):e}function N8(e){let t=e.trim();if(!t)return null;let n=Number.parseFloat(t);return Number.isFinite(n)?n:null}function P8(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`}var F8=`w-full px-3 py-2 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:outline-none focus:ring-1 focus:ring-bambu-green`,I8=`block text-sm font-medium text-white mb-1`,L8=`px-4 py-3 text-left text-bambu-gray font-medium`,R8=`px-4 py-3 align-top text-white`;function z8({title:e,onClose:t,children:n,size:r=`md`}){let{t:i}=U();return(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,G.jsxs)(`div`,{className:`w-full ${r===`sm`?`max-w-xl`:r===`lg`?`max-w-6xl`:`max-w-4xl`} overflow-hidden rounded-lg border border-bambu-dark-tertiary bg-bambu-dark-secondary`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-bambu-dark-tertiary px-4 py-3`,children:[(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:e}),(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:t,children:i(`common.close`,`Close`)})]}),(0,G.jsx)(`div`,{className:`max-h-[75vh] overflow-auto p-4`,children:n})]})})}function QHe(){let{t:e,i18n:t}=U(),{hasPermission:n,user:r}=Td(),{showToast:i}=zd(),a=so(),o=n(`cost_centers:read_own`),s=n(`cost_centers:read_all`),c=n(`cost_centers:create`),l=n(`cost_centers:modify`),u=n(`cost_centers:modify`),d=n(`cost_centers:modify`),f=n(`cost_centers:modify`),p=n(`users:read_slim`)||n(`users:read`),m=s||c||l||u||d||f,h=o||m,g=h,[_,v]=(0,y.useState)(``),[b,x]=(0,y.useState)(`monthly`),[S,C]=(0,y.useState)(``),[w,T]=(0,y.useState)(null),[E,D]=(0,y.useState)(`deposit`),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(null),[P,F]=(0,y.useState)(null),[I,L]=(0,y.useState)(null),[R,z]=(0,y.useState)(!0),[B,V]=(0,y.useState)(0),[ee,te]=(0,y.useState)(`all`),[ne,re]=(0,y.useState)(`all`),[ie,ae]=(0,y.useState)(!1),[oe,se]=(0,y.useState)(!1),[H,ce]=(0,y.useState)(!1),[le,ue]=(0,y.useState)(!1),[de,fe]=(0,y.useState)(`personal`),[pe,me]=(0,y.useState)(null),[he,ge]=(0,y.useState)(``),[_e,ve]=(0,y.useState)(`monthly`),[ye,be]=(0,y.useState)(``),[xe,Se]=(0,y.useState)(!1),[Ce,we]=(0,y.useState)(null),[Te,Ee]=(0,y.useState)(null),[De,Oe]=(0,y.useState)(null),[ke,Ae]=(0,y.useState)(``),[je,Me]=(0,y.useState)(``),[Ne,Pe]=(0,y.useState)(!1),[Fe,Ie]=(0,y.useState)(null),[Le,Re]=(0,y.useState)(null),[ze,Be]=(0,y.useState)(``),[Ve,He]=(0,y.useState)(``),[Ue,We]=(0,y.useState)(P8(new Date)),[Ge,Ke]=(0,y.useState)(null),[qe,Je]=(0,y.useState)(null),Ye=s||c||l||u||f&&p||d&&p;(0,y.useEffect)(()=>{Ye||fe(`personal`)},[Ye]);let{data:Xe,isLoading:Ze}=K({queryKey:[`finance`,`me`,`balance`],queryFn:Z.getMyBalance,enabled:o}),{data:Qe,isLoading:$e}=K({queryKey:[`finance`,`me`,`transactions`,50,B],queryFn:()=>Z.getMyTransactions(50,B),enabled:o}),{data:et,isLoading:tt}=K({queryKey:[`finance`,`transactions`,50,B],queryFn:()=>Z.getAllTransactions(50,B),enabled:de===`admin`&&s}),{data:nt,isLoading:rt}=K({queryKey:[`finance`,`cost-centers`,de],queryFn:()=>de===`admin`&&m?Z.listCostCenters(!0):Z.getMyCostCenters(),enabled:g}),{data:it}=K({queryKey:[`users`,`slim`],queryFn:Z.getUsersSlim,enabled:p&&(g||f||d)}),{data:at}=K({queryKey:[`finance`,`cost-center`,P],queryFn:()=>Z.getCostCenter(P),enabled:d&&P!=null});(0,y.useEffect)(()=>{!it||it.length===0||w!=null&&it.some(e=>e.id===w)||T(it[0].id)},[it,w]),(0,y.useEffect)(()=>{if(!d)return;let e=(nt||[]).filter(e=>!e.is_private);if(e.length===0){F(null);return}P!=null&&e.some(e=>e.id===P)||F(e[0].id)},[d,nt,P]),(0,y.useEffect)(()=>{if(!d||!it||it.length===0)return;let e=new Set((at?.members||[]).map(e=>e.user_id)),t=it.find(t=>!e.has(t.id));L(t?t.id:null)},[d,it,at]),(0,y.useEffect)(()=>{if(!le)return;let e=nt||[];if(e.length===0){me(null);return}pe!=null&&e.some(e=>e.id===pe)||me(e[0].id)},[le,pe,nt]),(0,y.useEffect)(()=>{if(!le||pe==null)return;let e=(nt||[]).find(e=>e.id===pe);if(e){if(ge(e.name),e.budget_mode===`total`){ve(`total`),be(e.total_budget==null?``:String(e.total_budget));return}ve(`monthly`),be(e.monthly_budget==null?``:String(e.monthly_budget))}},[le,pe,nt]);let ot=q({mutationFn:()=>Z.createCostCenter({name:_.trim(),total_budget:b===`total`?N8(S):null,monthly_budget:b===`monthly`?N8(S):null,is_active:!0}),onSuccess:()=>{a.invalidateQueries({queryKey:[`finance`]}),v(``),C(``),i(e(`finance.createdCostCenter`,`Cost center created`))},onError:t=>{i(t.message||e(`finance.createCostCenterFailed`,`Failed to create cost center`),`error`)}}),st=q({mutationFn:({costCenterId:e,value:t,mode:n})=>Z.updateCostCenterBudgets(e,{total_budget:n===`total`?N8(t):null,monthly_budget:n===`monthly`?N8(t):null})}),ct=q({mutationFn:({costCenterId:e,name:t})=>Z.updateCostCenter(e,{name:t})}),lt=q({mutationFn:e=>Z.deleteCostCenter(e)}),ut=q({mutationFn:e=>Z.deleteTransaction(e),onSuccess:()=>{a.invalidateQueries({queryKey:[`finance`]}),i(e(`finance.transactionDeleted`,`Transaction deleted`))},onError:t=>{i(t.message||e(`finance.deleteTransactionFailed`,`Failed to delete transaction`),`error`)}}),dt=q({mutationFn:e=>Z.editTransaction(e.transactionId,e.data),onSuccess:()=>{a.invalidateQueries({queryKey:[`finance`]}),i(e(`finance.transactionEdited`,`Transaction updated and ledger recalculated`)),Se(!1)},onError:t=>{i(t.message||e(`finance.editTransactionFailed`,`Failed to edit transaction`),`error`)}}),ft=q({mutationFn:e=>Z.createManualPrint(e),onSuccess:()=>{a.invalidateQueries({queryKey:[`finance`]}),i(e(`finance.manualPrintCreated`,`Manual print charge added and ledger recalculated`)),Pe(!1),Ie(null),Re(null),Be(``),He(``),We(P8(new Date))},onError:t=>{i(t.message||e(`finance.manualPrintFailed`,`Failed to create manual print`),`error`)}}),pt=q({mutationFn:e=>Z.depositUserBalance(e.userId,{amount:e.amount,description:e.description,cost_center_id:e.costCenterId??null})}),mt=q({mutationFn:e=>Z.withdrawUserBalance(e.userId,{amount:e.amount,description:e.description,cost_center_id:e.costCenterId??null})}),ht=q({mutationFn:e=>Z.upsertCostCenterMember(e.costCenterId,{user_id:e.userId,can_print:e.canPrint}),onSuccess:()=>{a.invalidateQueries({queryKey:[`finance`]}),i(e(`finance.memberSaved`,`Member saved`))},onError:t=>{i(t.message||e(`finance.memberSaveFailed`,`Failed to save member`),`error`)}}),gt=q({mutationFn:e=>Z.removeCostCenterMember(e.costCenterId,e.userId),onSuccess:()=>{a.invalidateQueries({queryKey:[`finance`]}),i(e(`finance.memberRemoved`,`Member removed`))},onError:t=>{i(t.message||e(`finance.memberRemoveFailed`,`Failed to remove member`),`error`)}}),_t=pt.isPending||mt.isPending,vt=()=>{if(!_.trim()){i(e(`finance.costCenterNameRequired`,`Cost center name is required`),`error`);return}ot.mutate()},yt=async()=>{if(pe==null){i(e(`finance.selectCostCenter`,`Please select a cost center`),`error`);return}let t=he.trim();if(!t){i(e(`finance.costCenterNameRequired`,`Cost center name is required`),`error`);return}try{l&&await ct.mutateAsync({costCenterId:pe,name:t}),u&&await st.mutateAsync({costCenterId:pe,mode:_e,value:ye}),a.invalidateQueries({queryKey:[`finance`]}),i(e(`finance.costCenterUpdated`,`Cost center updated`)),ue(!1)}catch(t){i(t.message||e(`finance.costCenterUpdateFailed`,`Failed to update cost center`),`error`)}},bt=e=>{let t=(nt||[]).find(t=>t.id===e);t&&(me(t.id),ge(t.name),t.budget_mode===`total`?(ve(`total`),be(t.total_budget==null?``:String(t.total_budget))):(ve(`monthly`),be(t.monthly_budget==null?``:String(t.monthly_budget))),ue(!0))},xt=async()=>{if(Ge)try{await lt.mutateAsync(Ge.id),a.invalidateQueries({queryKey:[`finance`]}),P===Ge.id&&F(null),i(e(`finance.costCenterDeleted`,`Cost center deleted`))}catch(t){i(t.message||e(`finance.costCenterDeleteFailed`,`Failed to delete cost center`),`error`)}finally{Ke(null)}},St=()=>{qe!=null&&ut.mutate(qe,{onSettled:()=>Je(null)})},Ct=e=>{we(e.id),Ee(e.user_id),Oe(e.cost_center_id),Ae(String(e.amount)),Me(e.description||``),Se(!0)},wt=async()=>{if(Ce==null)return;let t=ke?Number.parseFloat(ke):null;if(t!==null&&!Number.isFinite(t)){i(e(`finance.amountInvalid`,`Amount must be a valid number`),`error`);return}dt.mutate({transactionId:Ce,data:{user_id:Te||void 0,cost_center_id:De||void 0,amount:t??void 0,description:je||void 0}})},Tt=async()=>{if(Fe==null){i(e(`finance.userRequired`,`Please select a user`),`error`);return}if(Le==null){i(e(`finance.costCenterRequired`,`Please select a cost center`),`error`);return}let t=ze?Number.parseFloat(ze):null;if(t===null||!Number.isFinite(t)){i(e(`finance.amountInvalid`,`Amount must be a valid number`),`error`);return}t=Math.abs(t),ft.mutate({user_id:Fe,cost_center_id:Le,amount:t,description:Ve||void 0,created_at:Ue?new Date(Ue).toISOString():void 0})},Et=async()=>{if(w==null){i(e(`finance.userRequired`,`Please select a user`),`error`);return}let t=Number.parseFloat(O);if(!Number.isFinite(t)||t<=0){i(e(`finance.amountMustBePositive`,`Amount must be greater than zero`),`error`);return}let n={userId:w,amount:t,description:A.trim()||void 0,costCenterId:M};try{E===`deposit`?await pt.mutateAsync(n):await mt.mutateAsync(n),a.invalidateQueries({queryKey:[`finance`]}),k(``),j(``),i(E===`deposit`?e(`finance.depositSuccess`,`Deposit successful`):e(`finance.withdrawSuccess`,`Withdrawal successful`))}catch(t){i(t.message||e(`finance.adjustmentFailed`,`Wallet adjustment failed`),`error`)}},Dt=()=>{if(P==null){i(e(`finance.selectCostCenter`,`Please select a cost center`),`error`);return}if(I==null){i(e(`finance.noEligibleUsers`,`No eligible users available`),`error`);return}ht.mutate({costCenterId:P,userId:I,canPrint:R})},Ot=e=>{P!=null&>.mutate({costCenterId:P,userId:e})},kt=wf(Xe?.currency||`EUR`),At=(0,y.useMemo)(()=>[...it||[]].sort((e,t)=>e.username.localeCompare(t.username)),[it]),jt=(0,y.useMemo)(()=>{let e=new Map;for(let t of At)e.set(t.id,t.username);return e},[At]),Mt=(0,y.useMemo)(()=>{let e=new Set((at?.members||[]).map(e=>e.user_id));return At.filter(t=>!e.has(t.id))},[At,at]),Nt=de===`admin`&&s?et:Qe,Pt=de===`admin`&&s?tt:$e,Ft=(0,y.useMemo)(()=>Nt?.items??[],[Nt?.items]),It=Nt?.total??0,Lt=Math.max(1,Math.ceil(It/50)),Rt=(0,y.useMemo)(()=>Ft.filter(e=>!(ee!==`all`&&e.transaction_type!==ee||ne!==`all`&&e.cost_center_id!==ne)),[Ft,ee,ne]),zt=Math.floor(B/50)+1,Bt=de===`admin`,Vt=t=>t===`deposit`?e(`finance.deposit`):t===`withdraw`?e(`finance.withdraw`):t===`print_charge`?e(`finance.printCharge`):t,Ht=t=>t==null?e(`finance.personal`,`Personal`):jt.get(t)||(r?.id===t&&r.username?r.username:e(`finance.userWithId`,`User #{{id}}`,{id:t})),Ut=t=>t.budget_limit==null||t.budget_available==null?e(`finance.unlimited`,`Unlimited`):`${kt}${t.budget_available.toFixed(2)}/${kt}${t.budget_limit.toFixed(2)}`;return h?(0,G.jsxs)(`div`,{className:`p-4 md:p-8 space-y-8`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Wu,{className:`h-6 w-6 text-bambu-green`}),(0,G.jsx)(`h1`,{className:`text-2xl font-bold text-white`,children:e(`finance.title`,`Finance`)})]}),(0,G.jsx)(`p`,{className:`text-bambu-gray mt-2 max-w-2xl`,children:e(`finance.subtitle`,`Wallet, personal transactions, and cost centers`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1 max-w-2xl`,children:e(`finance.budgetPolicyHint`,`Account balances track costs. Printing is limited only by the selected cost center budget; without a budget, printing is unlimited.`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 lg:items-end`,children:[Ye&&(0,G.jsxs)(`div`,{className:`inline-flex overflow-hidden rounded border border-bambu-dark-tertiary`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>fe(`personal`),className:`px-3 py-1.5 text-sm ${de===`personal`?`bg-bambu-green text-black font-medium`:`bg-bambu-dark text-bambu-gray`}`,children:e(`finance.personalView`,`Personal view`)}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>fe(`admin`),className:`px-3 py-1.5 text-sm ${de===`admin`?`bg-bambu-green text-black font-medium`:`bg-bambu-dark text-bambu-gray`}`,children:e(`finance.adminView`,`Admin view`)})]}),de===`admin`&&Ye&&(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2 lg:justify-end`,children:[c&&(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>ae(!0),children:e(`finance.createCostCenter`,`Create cost center`)}),f&&p&&(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>se(!0),children:e(`finance.adjustWallet`,`Adjust wallet`)}),f&&p&&(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>Pe(!0),children:e(`finance.addManualPrint`,`Add manual print`)}),d&&p&&(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>ce(!0),children:e(`finance.manageMembers`,`Manage cost center members`)})]})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-5 md:grid-cols-2 xl:grid-cols-3`,children:[(0,G.jsxs)(jd,{children:[(0,G.jsxs)(Md,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e(`finance.currentBalance`,`Personal account balance`)}),(0,G.jsx)(Wu,{className:`w-4 h-4 text-bambu-green/90`})]}),(0,G.jsx)(Nd,{className:`pt-1`,children:(0,G.jsx)(`p`,{className:`text-3xl font-semibold text-white leading-tight`,children:Ze?e(`common.loading`,`Loading...`):`${kt}${(Xe?.balance??0).toFixed(2)}`})})]}),(0,G.jsxs)(jd,{children:[(0,G.jsxs)(Md,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:de===`admin`?e(`finance.transactions`,`Transactions`):e(`finance.personalTransactions`,`Personal transactions`)}),(0,G.jsx)(Os,{className:`w-4 h-4 text-blue-400`})]}),(0,G.jsx)(Nd,{className:`pt-1`,children:(0,G.jsx)(`p`,{className:`text-3xl font-semibold text-white leading-tight`,children:Pt?`-`:It})})]}),(0,G.jsxs)(jd,{children:[(0,G.jsxs)(Md,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e(`finance.costCenters`,`Cost centers`)}),(0,G.jsx)(Qo,{className:`w-4 h-4 text-orange-400`})]}),(0,G.jsx)(Nd,{className:`pt-1`,children:(0,G.jsx)(`p`,{className:`text-3xl font-semibold text-white leading-tight`,children:rt?`-`:nt?.length??0})})]})]}),ie&&c&&(0,G.jsx)(z8,{title:e(`finance.createCostCenter`,`Create cost center`),size:`md`,onClose:()=>ae(!1),children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.costCenterName`,`Name`)}),(0,G.jsx)(`input`,{type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:e(`finance.costCenterName`,`Name`),className:F8})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.budgetType`,`Budget type`)}),(0,G.jsxs)(`select`,{value:b,onChange:e=>x(e.target.value),className:F8,children:[(0,G.jsx)(`option`,{value:`monthly`,children:e(`finance.monthlyBudget`,`Monthly budget`)}),(0,G.jsx)(`option`,{value:`total`,children:e(`finance.totalBudget`,`Total budget`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:b===`monthly`?e(`finance.monthlyBudget`,`Monthly budget`):e(`finance.totalBudget`,`Total budget`)}),(0,G.jsx)(`input`,{type:`number`,step:`0.01`,value:S,onChange:e=>C(e.target.value),placeholder:`0.00`,className:F8})]})]}),(0,G.jsx)(Q,{className:`min-w-[180px]`,onClick:vt,disabled:ot.isPending,children:ot.isPending?e(`common.saving`,`Saving...`):e(`finance.create`,`Create`)})]})}),oe&&f&&p&&(0,G.jsx)(z8,{title:e(`finance.adjustWallet`,`Adjust wallet`),size:`md`,onClose:()=>se(!1),children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.selectUser`,`Select user`)}),(0,G.jsx)(`select`,{value:w??``,onChange:e=>T(e.target.value?Number(e.target.value):null),className:F8,children:(At||[]).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.username},e.id))})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.transactionType`,`Type`)}),(0,G.jsxs)(`select`,{value:E,onChange:e=>D(e.target.value),className:F8,children:[(0,G.jsx)(`option`,{value:`deposit`,children:e(`finance.deposit`,`Deposit`)}),(0,G.jsx)(`option`,{value:`withdraw`,children:e(`finance.withdraw`,`Withdraw`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.amount`,`Amount`)}),(0,G.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,value:O,onChange:e=>k(e.target.value),placeholder:`0.00`,className:F8})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.costCenters`,`Cost centers`)}),(0,G.jsxs)(`select`,{value:M??``,onChange:e=>N(e.target.value?Number(e.target.value):null),className:F8,children:[(0,G.jsx)(`option`,{value:``,children:e(`finance.noCostCenter`,`No cost center`)}),(nt||[]).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`common.description`,`Description`)}),(0,G.jsx)(`input`,{type:`text`,value:A,onChange:e=>j(e.target.value),placeholder:e(`finance.descriptionOptional`,`Description (optional)`),className:F8})]}),(0,G.jsx)(Q,{className:`min-w-[180px]`,onClick:Et,disabled:_t,children:_t?e(`common.saving`,`Saving...`):e(`finance.applyAdjustment`,`Apply adjustment`)})]})}),H&&d&&p&&(0,G.jsx)(z8,{title:e(`finance.manageMembers`,`Manage cost center members`),size:`lg`,onClose:()=>ce(!1),children:(0,G.jsxs)(`div`,{className:`space-y-5`,children:[(0,G.jsxs)(`div`,{className:`grid gap-5 md:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.costCenters`,`Cost centers`)}),(0,G.jsx)(`select`,{value:P??``,onChange:e=>F(e.target.value?Number(e.target.value):null),className:F8,children:(nt||[]).filter(e=>!e.is_private).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.selectUser`,`Select user`)}),(0,G.jsxs)(`select`,{value:I??``,onChange:e=>L(e.target.value?Number(e.target.value):null),className:F8,children:[(0,G.jsx)(`option`,{value:``,children:e(`finance.selectUser`,`Select user`)}),Mt.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.username},e.id))]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded border border-bambu-dark-tertiary bg-bambu-dark-secondary px-3 py-2`,children:[(0,G.jsx)(`input`,{id:`memberCanPrint`,type:`checkbox`,checked:R,onChange:e=>z(e.target.checked),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,G.jsx)(`label`,{htmlFor:`memberCanPrint`,className:`text-sm text-bambu-gray`,children:e(`finance.memberCanPrint`,`Member can print`)})]}),(0,G.jsx)(`div`,{className:`flex items-end`,children:(0,G.jsx)(Q,{className:`min-w-[180px]`,onClick:Dt,disabled:ht.isPending||I==null,children:ht.isPending?e(`common.saving`,`Saving...`):e(`finance.addMember`,`Add member`)})})]}),(0,G.jsx)(`div`,{className:`overflow-auto rounded-lg border border-bambu-dark-tertiary`,children:(0,G.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray`,children:[(0,G.jsx)(`th`,{className:L8,children:e(`common.name`,`Name`)}),(0,G.jsx)(`th`,{className:L8,children:e(`finance.canPrint`,`Can print`)}),(0,G.jsx)(`th`,{className:L8,children:e(`common.actions`,`Actions`)})]})}),(0,G.jsxs)(`tbody`,{children:[(at?.members||[]).map(t=>(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/60 text-white`,children:[(0,G.jsx)(`td`,{className:R8,children:At.find(e=>e.id===t.user_id)?.username||`User ${t.user_id}`}),(0,G.jsx)(`td`,{className:R8,children:t.can_print?e(`common.yes`,`Yes`):e(`common.no`,`No`)}),(0,G.jsx)(`td`,{className:R8,children:(0,G.jsx)(Q,{size:`sm`,variant:`danger`,onClick:()=>Ot(t.user_id),disabled:gt.isPending,children:e(`common.remove`,`Remove`)})})]},t.id)),(at?.members||[]).length===0&&(0,G.jsx)(`tr`,{children:(0,G.jsx)(`td`,{colSpan:3,className:`py-3 text-bambu-gray`,children:e(`finance.noMembers`,`No members assigned.`)})})]})]})})]})}),le&&(l||u)&&(0,G.jsx)(z8,{title:e(`finance.editCostCenter`,`Edit cost center`),size:`md`,onClose:()=>ue(!1),children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.costCenterName`,`Name`)}),(0,G.jsx)(`input`,{type:`text`,value:he,onChange:e=>ge(e.target.value),placeholder:e(`finance.costCenterName`,`Name`),className:F8,disabled:!l})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.budgetType`,`Budget type`)}),(0,G.jsxs)(`select`,{value:_e,onChange:e=>ve(e.target.value),className:F8,disabled:!u,children:[(0,G.jsx)(`option`,{value:`monthly`,children:e(`finance.monthlyBudget`,`Monthly budget`)}),(0,G.jsx)(`option`,{value:`total`,children:e(`finance.totalBudget`,`Total budget`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:_e===`monthly`?e(`finance.monthlyBudget`,`Monthly budget`):e(`finance.totalBudget`,`Total budget`)}),(0,G.jsx)(`input`,{type:`number`,step:`0.01`,value:ye,onChange:e=>be(e.target.value),placeholder:`0.00`,className:F8,disabled:!u})]})]}),(0,G.jsx)(Q,{className:`min-w-[180px]`,onClick:yt,disabled:ct.isPending||st.isPending||pe==null,children:ct.isPending||st.isPending?e(`common.saving`,`Saving...`):e(`common.save`,`Save`)})]})}),(0,G.jsxs)(`div`,{className:`grid gap-6 ${g&&o?`xl:grid-cols-2`:``}`,children:[g&&(0,G.jsxs)(jd,{children:[(0,G.jsxs)(Md,{children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`finance.myCostCenters`,`My cost centers`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:e(`finance.costCentersHint`,`Review budget limits and keep costs under control`)})]}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[rt&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`common.loading`,`Loading...`)}),!rt&&(!nt||nt.length===0)&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`finance.noCostCenters`,`No cost centers found.`)}),!rt&&nt&&nt.length>0&&(0,G.jsx)(`div`,{className:`overflow-auto rounded-lg border border-bambu-dark-tertiary`,children:(0,G.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray`,children:[(0,G.jsx)(`th`,{className:L8,children:e(`common.name`,`Name`)}),Bt&&(0,G.jsx)(`th`,{className:L8,children:e(`finance.owner`,`Owner`)}),(0,G.jsx)(`th`,{className:L8,children:e(`finance.balance`,`Account balance`)}),(0,G.jsx)(`th`,{className:L8,children:e(`finance.budget`,`Budget`)}),Bt&&(0,G.jsx)(`th`,{className:L8,children:e(`common.actions`,`Actions`)})]})}),(0,G.jsx)(`tbody`,{children:nt.map(t=>{let n=l||u,r=!t.is_private&&l;return(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/60 text-white`,children:[(0,G.jsx)(`td`,{className:R8,children:t.name}),Bt&&(0,G.jsx)(`td`,{className:R8,children:t.is_private?Ht(t.owner_user_id):e(`finance.shared`,`Shared`)}),(0,G.jsxs)(`td`,{className:R8,children:[kt,t.total_balance.toFixed(2)]}),(0,G.jsx)(`td`,{className:R8,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,G.jsx)(`span`,{children:Ut(t)}),(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:t.budget_mode===`monthly`?e(`finance.monthlyBudget`,`Monthly budget`):t.budget_mode===`total`?e(`finance.totalBudget`,`Total budget`):e(`finance.noBudget`,`No budget`)})]})}),Bt&&(0,G.jsx)(`td`,{className:R8,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>bt(t.id),disabled:!n,title:n?e(`common.edit`,`Edit`):e(`finance.cannotEditPrivateCostCenter`,`Private cost centers cannot be edited here`),className:`p-1.5 sm:p-2`,children:(0,G.jsx)(El,{className:`w-4 h-4`})}),r&&(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>Ke({id:t.id,name:t.name}),disabled:lt.isPending,title:e(`common.delete`,`Delete`),className:`text-red-400 hover:text-red-300 hover:bg-red-500/10 p-1.5 sm:p-2`,children:(0,G.jsx)(Au,{className:`w-4 h-4`})})]})})]},t.id)})})]})})]})]}),o&&(0,G.jsxs)(jd,{children:[(0,G.jsxs)(Md,{children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`finance.recentTransactions`,`Recent transactions`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:e(`finance.transactionsHint`,`Filter by type and cost center, then navigate pages`)})]}),(0,G.jsxs)(Nd,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_auto] items-end`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.transactionType`,`Type`)}),(0,G.jsxs)(`select`,{value:ee,onChange:e=>te(e.target.value),className:F8,children:[(0,G.jsx)(`option`,{value:`all`,children:e(`finance.allTypes`)}),(0,G.jsx)(`option`,{value:`deposit`,children:e(`finance.deposit`)}),(0,G.jsx)(`option`,{value:`withdraw`,children:e(`finance.withdraw`)}),(0,G.jsx)(`option`,{value:`print_charge`,children:e(`finance.printCharge`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.costCenters`,`Cost centers`)}),(0,G.jsxs)(`select`,{value:ne,onChange:e=>re(e.target.value===`all`?`all`:Number(e.target.value)),className:F8,children:[(0,G.jsx)(`option`,{value:`all`,children:e(`finance.allCostCenters`)}),(nt||[]).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})]}),Pt&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`common.loading`,`Loading...`)}),!Pt&&(!Ft||Ft.length===0)&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`finance.noTransactions`,`No transactions available.`)}),!Pt&&Ft.length>0&&Rt.length===0&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`finance.noTransactionsForFilter`,`No transactions match the selected filters.`)}),!Pt&&Rt.length>0&&(0,G.jsx)(`div`,{className:`overflow-auto rounded-lg border border-bambu-dark-tertiary`,children:(0,G.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray`,children:[(0,G.jsx)(`th`,{className:L8,children:e(`common.date`,`Date`)}),Bt&&(0,G.jsx)(`th`,{className:L8,children:e(`common.user`,`User`)}),(0,G.jsx)(`th`,{className:L8,children:e(`finance.costCenter`,`Cost center`)}),(0,G.jsx)(`th`,{className:L8,children:e(`finance.transactionType`,`Type`)}),(0,G.jsx)(`th`,{className:L8,children:e(`common.description`,`Description`)}),(0,G.jsx)(`th`,{className:L8,children:e(`finance.amount`,`Amount`)}),(0,G.jsx)(`th`,{className:L8,children:e(`finance.balanceAfter`,`Balance after`)}),Bt&&(0,G.jsx)(`th`,{className:L8,children:e(`common.actions`,`Actions`)})]})}),(0,G.jsx)(`tbody`,{children:Rt.map(n=>{let r=n.amount>=0,i=n.cost_center_id==null?null:(nt||[]).find(e=>e.id===n.cost_center_id),a=jt.get(n.user_id),o=n.transaction_type===`print_charge`?XHe(n.description??null):null,s=o?.isPartial??!1;return(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/60 text-white`,children:[(0,G.jsx)(`td`,{className:R8,children:ZHe(n.created_at,t.language)}),Bt&&(0,G.jsx)(`td`,{className:R8,children:a||e(`finance.userWithId`,`User #{{id}}`,{id:n.user_id})}),(0,G.jsx)(`td`,{className:R8,children:i?.name||`-`}),(0,G.jsx)(`td`,{className:R8,children:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,G.jsx)(`span`,{children:Vt(n.transaction_type)}),s&&(0,G.jsx)(`span`,{className:`rounded border border-yellow-500/40 bg-yellow-500/10 px-2 py-0.5 text-[11px] text-yellow-300`,children:o&&o.partialType?e(`finance.partialStatus.${o.partialType}`,o.partialType):e(`finance.partial`,`Partial`)})]})}),(0,G.jsx)(`td`,{className:R8,children:(o?.cleanedDescription??n.description)||`-`}),(0,G.jsxs)(`td`,{className:`${R8} ${r?`text-green-400`:`text-red-400`}`,children:[r?`+`:`-`,kt,Math.abs(n.amount).toFixed(2)]}),(0,G.jsx)(`td`,{className:R8,children:n.balance_after==null?`-`:`${n.balance_after<0?`-`:``}${kt}${Math.abs(n.balance_after).toFixed(2)}`}),Bt&&(0,G.jsx)(`td`,{className:R8,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>Ct(n),disabled:dt.isPending,children:(0,G.jsx)(El,{className:`w-4 h-4`})}),(0,G.jsx)(Q,{size:`sm`,variant:`danger`,onClick:()=>Je(n.id),disabled:ut.isPending,children:(0,G.jsx)(Au,{className:`w-4 h-4`})})]})})]},n.id)})})]})}),!Pt&&Rt.length>0&&(0,G.jsx)(`div`,{className:`flex justify-end pt-2 lg:pt-0`,children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>V(0),disabled:B===0||Pt,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,"aria-label":e(`finance.first`,`First`),children:(0,G.jsx)(hs,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>V(e=>Math.max(0,e-50)),disabled:B===0||Pt,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,"aria-label":e(`finance.prev`,`Previous`),children:(0,G.jsx)(ps,{className:`w-4 h-4`})}),(0,G.jsx)(`span`,{className:`text-bambu-gray px-1 whitespace-nowrap`,children:e(`finance.pageNumberOf`,`Page {{page}} of {{total}}`,{page:zt,total:Lt})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>V(e=>e+50),disabled:Pt||zt>=Lt,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,"aria-label":e(`finance.next`,`Next`),children:(0,G.jsx)(fs,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>V(Math.max(0,(Lt-1)*50)),disabled:Pt||zt>=Lt,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,"aria-label":e(`finance.last`,`Last`),children:(0,G.jsx)(gs,{className:`w-4 h-4`})})]})})]})]}),xe&&Ce!==null&&(0,G.jsx)(z8,{title:e(`finance.editTransaction`,`Edit Transaction`),onClose:()=>Se(!1),size:`md`,children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`common.user`,`User`)}),(0,G.jsxs)(`select`,{className:F8,value:Te||``,onChange:e=>Ee(e.target.value?Number(e.target.value):null),children:[(0,G.jsx)(`option`,{value:``,children:e(`finance.selectUser`,`Select user...`)}),At.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.username},e.id))]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.costCenter`,`Cost center (optional)`)}),(0,G.jsxs)(`select`,{className:F8,value:De||``,onChange:e=>Oe(e.target.value?Number(e.target.value):null),children:[(0,G.jsx)(`option`,{value:``,children:e(`finance.noCostCenter`,`Personal (no cost center)`)}),(nt||[]).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.amount`,`Amount`)}),(0,G.jsx)(`input`,{type:`number`,step:`0.01`,className:F8,value:ke,onChange:e=>Ae(e.target.value),placeholder:e(`finance.amountExample`,`e.g., 10.50`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`common.description`,`Description`)}),(0,G.jsx)(`textarea`,{className:`${F8} resize-none`,rows:3,value:je,onChange:e=>Me(e.target.value),placeholder:e(`finance.manualAdjustmentExample`,`e.g., Manual adjustment`)})]}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 pt-4`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>Se(!1),children:e(`common.cancel`,`Cancel`)}),(0,G.jsx)(Q,{onClick:wt,disabled:dt.isPending,children:e(`common.save`,`Save`)})]})]})}),Ne&&(0,G.jsx)(z8,{title:e(`finance.addManualPrint`,`Add manual print`),onClose:()=>Pe(!1),size:`md`,children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`common.user`,`User`)}),(0,G.jsxs)(`select`,{className:F8,value:Fe||``,onChange:e=>Ie(e.target.value?Number(e.target.value):null),children:[(0,G.jsx)(`option`,{value:``,children:e(`finance.selectUser`,`Select user...`)}),At.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.username},e.id))]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.costCenter`,`Cost center`)}),(0,G.jsxs)(`select`,{className:F8,value:Le||``,onChange:e=>Re(e.target.value?Number(e.target.value):null),children:[(0,G.jsx)(`option`,{value:``,children:e(`finance.selectCostCenter`,`Select cost center...`)}),(nt||[]).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.amount`,`Amount`)}),(0,G.jsx)(`input`,{type:`number`,step:`0.01`,className:F8,value:ze,onChange:e=>Be(e.target.value),placeholder:e(`finance.amountExample`,`e.g., 4.00`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`common.description`,`Description`)}),(0,G.jsx)(`input`,{type:`text`,value:Ve,onChange:e=>He(e.target.value),placeholder:e(`finance.descriptionOptional`,`Description (optional)`),className:F8})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`common.date`,`Date`)}),(0,G.jsx)(`input`,{type:`datetime-local`,value:Ue,onChange:e=>We(e.target.value),className:F8})]}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 pt-4`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>Pe(!1),children:e(`common.cancel`,`Cancel`)}),(0,G.jsx)(Q,{onClick:Tt,disabled:ft.isPending,children:ft.isPending?e(`common.saving`,`Saving...`):e(`finance.addManualPrint`,`Add manual print`)})]})]})}),Ge&&(0,G.jsx)(Xd,{title:e(`common.delete`,`Delete`),message:e(`finance.confirmDeleteCostCenter`,`Delete cost center "{{name}}"?`,{name:Ge.name}),confirmText:e(`common.delete`,`Delete`),variant:`danger`,isLoading:lt.isPending,onConfirm:xt,onCancel:()=>Ke(null)}),qe!=null&&(0,G.jsx)(Xd,{title:e(`finance.deleteTransaction`,`Delete transaction`),message:e(`finance.deleteTransactionConfirm`,`Delete this transaction? Balances will be recalculated automatically.`),confirmText:e(`common.delete`,`Delete`),variant:`danger`,isLoading:ut.isPending,onConfirm:St,onCancel:()=>Je(null)})]})]}):(0,G.jsxs)(`div`,{className:`p-4 md:p-8 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Wu,{className:`h-6 w-6 text-bambu-green`}),(0,G.jsx)(`h1`,{className:`text-2xl font-bold text-white`,children:e(`finance.title`,`Finance`)})]}),(0,G.jsx)(`div`,{children:(0,G.jsx)(`p`,{className:`text-bambu-gray mt-2 max-w-2xl`,children:e(`finance.subtitle`,`Wallet, personal transactions, and cost centers`)})}),(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-8 text-center text-bambu-gray`,children:e(`finance.noAccess`,`You do not have permission to view finance data.`)})})]})}var B8={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`};function V8(e){let t=(e||``).toUpperCase().trim();return t&&(B8[t]||B8[t.replace(/[-\s]?CF$/,``)]||B8[t.replace(/\+$/,``)]||B8[t.split(/[-\s]/)[0]])||``}function H8(e){let t=e.replace(/@.+$/,``).trim();return t.startsWith(`# `)?t.slice(2).trim():t}var U8={local:0,orca_cloud:1,cloud:2,builtin:3};function $He(e){let{localPresets:t,orcaProfiles:n,cloudSettings:r,builtinFilaments:i}=e,a=[],o=e=>e.trim().toLowerCase(),s=new Set,c=new Set,l=new Set,u=(e,t,...n)=>{let r=n.filter(e=>!!e);if(r.some(e=>s.has(e)))return!1;let i=`${e}|${o(t)}`;return c.has(i)?!1:(r.forEach(e=>s.add(e)),c.add(i),l.add(o(t)),!0)};for(let e of t??[]){let t=H8(e.name),n=e.filament_type||XU(t).material;u(`local`,t)&&a.push({id:`local_${e.id}`,name:t,source:`local`,filamentId:V8(n),filamentType:n||``})}for(let e of n??[]){let t=H8(e.name),n=XU(t).material;u(`orca_cloud`,t,e.setting_id)&&a.push({id:`orca_${e.setting_id}`,name:t,source:`orca_cloud`,filamentId:V8(n),filamentType:n})}for(let e of r??[]){let t=H8(e.name),n=e.setting_id.startsWith(`GFS`)?iW(e.setting_id):``;u(`cloud`,t,e.setting_id,n||void 0)&&a.push({id:e.setting_id,name:t,source:`cloud`,filamentId:n,filamentType:XU(t).material})}for(let e of i??[]){let t=e.filament_id.startsWith(`GF`)?`GFS${e.filament_id.slice(2)}`:e.filament_id;l.has(o(e.name))||u(`builtin`,e.name,e.filament_id,t)&&a.push({id:`builtin_${e.filament_id}`,name:e.name,source:`builtin`,filamentId:e.filament_id,filamentType:XU(e.name).material})}return a.sort((e,t)=>e.source===t.source?e.name.localeCompare(t.name):U8[e.source]-U8[t.source])}async function eUe(e,t){if(e.filamentId)return e.filamentId;if(e.source!==`cloud`||!t)return``;try{return(await t(e.id)).filament_id||``}catch{return``}}var W8=e=>(Math.trunc(parseFloat(e)*1e3)/1e3).toFixed(3),G8=`HS00`,K8=`HH00`,q8=e=>{let t=e.match(/^([A-Z]{2}\d{2})/);return t?t[1]:G8},tUe=e=>q8(e)===K8?`HF`:`S`,J8=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 Y8({profile:e,onEdit:t,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){let s=tUe(e.nozzle_id),c=e.nozzle_diameter;return(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r&&(0,G.jsx)(`button`,{onClick:a,className:`text-bambu-gray hover:text-white transition-colors p-1`,children:i?(0,G.jsx)(mu,{className:`w-4 h-4 text-bambu-green`}):(0,G.jsx)(gu,{className:`w-4 h-4`})}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-bambu-green font-mono text-sm font-bold whitespace-nowrap`,children:W8(e.k_value)}),(0,G.jsx)(`span`,{className:`text-white text-sm truncate flex-1`,title:e.name,children:e.name||`Unnamed`}),o&&(0,G.jsx)(`span`,{title:`Has note`,children:(0,G.jsx)(yu,{className:`w-3 h-3 text-yellow-500`})}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:[s,` `,c]})]}),o&&(0,G.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,G.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n()},className:`text-bambu-gray hover:text-white transition-colors p-1`,title:`Copy profile`,children:(0,G.jsx)(zs,{className:`w-4 h-4`})})]})}function X8({profile:e,printerId:t,nozzleDiameter:n,existingProfiles:r=[],builtinFilaments:i=[],filamentPresets:a=[],isDualNozzle:o=!1,supportsFlowType:s=!0,initialNote:c=``,initialNoteKey:l=null,onClose:u,onSave:d,onSaveNote:f,hasPermission:p}){let{t:m}=U(),{showToast:h}=zd(),[g,_]=(0,y.useState)(e?.name||``),[v,b]=(0,y.useState)(e?.k_value?W8(e.k_value):`0.020`),[x,S]=(0,y.useState)(e?.filament_id||``),[C,w]=(0,y.useState)(e?q8(e.nozzle_id):G8),[T,E]=(0,y.useState)(e?.nozzle_diameter||n),[D,O]=(0,y.useState)(e?[e.extruder_id]:o?[0,1]:[0]),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)({current:0,total:0}),[N,P]=(0,y.useState)(c),[F,I]=(0,y.useState)(``),{schedule:L}=sW(),R=y.useMemo(()=>e?.filament_id?i.find(t=>t.filament_id===e.filament_id)?.name||J8(r.find(t=>t.filament_id===e.filament_id)?.name||e.name||``)||e.filament_id:``,[e,r,i]),z=y.useMemo(()=>{let e=[[`local`,m(`kProfiles.modal.source.local`)],[`orca_cloud`,m(`kProfiles.modal.source.orcaCloud`)],[`cloud`,m(`kProfiles.modal.source.bambuCloud`)],[`builtin`,m(`kProfiles.modal.source.builtin`)]],t=F.trim().toLowerCase(),n=t?a.filter(e=>e.name.toLowerCase().includes(t)):a;return e.map(([e,t])=>({source:e,label:t,items:n.filter(t=>t.source===e)})).filter(e=>e.items.length>0)},[a,F,m]),B=q({mutationFn:e=>(console.log(`[KProfile] Calling API...`),Z.setKProfile(t,e)),onSuccess:(t,n)=>{if(console.log(`[KProfile] Save success:`,t),h(m(`kProfiles.toast.profileSaved`)),f&&N!==c){let t;t=N===``&&l?l:e&&e.slot_id>0?e.setting_id||`slot_${e.slot_id}_${e.filament_id}_${e.extruder_id}`:`name_${g}_${n.filament_id}`,f(t,N)}A(!0),L(()=>{A(!1),d()},2500)},onError:e=>{console.error(`[KProfile] Save error:`,e),h(e.message,`error`),A(!1)}}),V=q({mutationFn:e=>(console.log(`[KProfile] Deleting profile...`),Z.deleteKProfile(t,e)),onSuccess:e=>{console.log(`[KProfile] Delete success:`,e),h(m(`kProfiles.toast.profileDeleted`)),A(!0),L(()=>{A(!1),u()},4e3)},onError:e=>{console.error(`[KProfile] Delete error:`,e),h(e.message,`error`),A(!1)}}),[ee,te]=(0,y.useState)(!1),ne=()=>{e&&V.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,G.jsxs)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:[(0,G.jsxs)(jd,{className:`w-full max-w-md relative`,children:[k&&(0,G.jsxs)(`div`,{className:`absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg`,children:[(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin mb-3`}),(0,G.jsx)(`p`,{className:`text-white font-medium`,children:j.total>1?m(`kProfiles.modal.savingExtruder`,{current:j.current,total:j.total}):m(`kProfiles.modal.syncing`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm mt-1`,children:m(`kProfiles.modal.pleaseWait`)})]}),(0,G.jsxs)(Nd,{className:`p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,G.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:m(e?`kProfiles.modal.editTitle`:`kProfiles.modal.addTitle`)}),(0,G.jsx)(`button`,{onClick:u,className:`text-bambu-gray hover:text-white transition-colors`,disabled:k,children:(0,G.jsx)(Qu,{className:`w-5 h-5`})})]}),(0,G.jsxs)(`form`,{onSubmit:async n=>{if(n.preventDefault(),o&&!e&&D.length===0){h(m(`kProfiles.toast.selectAtLeastOneExtruder`),`error`);return}let r=parseFloat(v).toFixed(6),i=`${C}-${T}`,s=e&&e.nozzle_id||i,c=e?e.nozzle_diameter:T,l=e?.filament_id||``;if(!e){let e=a.find(e=>e.id===x);if(!e){h(m(`kProfiles.toast.selectFilament`),`error`);return}if(l=await eUe(e,Z.getCloudSettingDetail),!l){h(m(`kProfiles.toast.filamentNotResolvable`,{name:e.name}),`error`);return}}if(e||D.length===1){let t={name:g,k_value:r,filament_id:l,nozzle_id:s,nozzle_diameter:c,extruder_id:e?e.extruder_id:D[0],setting_id:e?.setting_id,slot_id:e?.slot_id??0};console.log(`[KProfile] Saving profile:`,t),B.mutate(t);return}A(!0),M({current:1,total:D.length});let u=D.map(e=>({name:g,k_value:r,filament_id:l,nozzle_id:i,nozzle_diameter:T,extruder_id:e,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${u.length} profiles in batch:`,u);try{await Z.setKProfilesBatch(t,u),h(m(`kProfiles.toast.profilesSaved`,{count:D.length})),f&&N&&f(`name_${g}_${l}`,N)}catch(e){console.error(`[KProfile] Failed to save batch:`,e),h(m(`kProfiles.toast.failedToSaveBatch`),`error`),A(!1),M({current:0,total:0});return}M({current:D.length,total:D.length}),L(()=>{A(!1),M({current:0,total:0}),d()},3e3)},className:`p-4 space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:m(`kProfiles.modal.profileName`)}),(0,G.jsx)(`input`,{type:`text`,value:g,onChange:e=>_(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:m(`kProfiles.modal.profileNamePlaceholder`),required:!e})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:m(`kProfiles.modal.kValue`)}),(0,G.jsx)(`input`,{type:`text`,inputMode:`decimal`,value:v,onChange:e=>{let t=e.target.value;(t===``||/^\d*\.?\d*$/.test(t))&&b(t)},onBlur:e=>{let t=parseFloat(e.target.value);isNaN(t)||b((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:m(`kProfiles.modal.kValuePlaceholder`),required:!0}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:m(`kProfiles.modal.kValueHelp`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:m(`kProfiles.modal.filament`)}),e?(0,G.jsx)(`div`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60`,children:R||e.filament_id}):(0,G.jsxs)(`div`,{className:`border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`relative border-b border-bambu-dark-tertiary`,children:[(0,G.jsx)(Jl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,G.jsx)(`input`,{type:`text`,value:F,onChange:e=>I(e.target.value),placeholder:m(`kProfiles.modal.searchFilaments`),className:`w-full pl-10 pr-3 py-2 bg-bambu-dark text-white placeholder-bambu-gray focus:outline-none`})]}),(0,G.jsx)(`div`,{className:`max-h-56 overflow-y-auto bg-bambu-dark`,children:z.length===0?(0,G.jsx)(`p`,{className:`px-3 py-3 text-xs text-bambu-gray`,children:a.length===0?m(`kProfiles.modal.noFilamentsHelp`):m(`kProfiles.modal.noFilamentMatches`)}):z.map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 px-3 py-1.5 bg-bambu-dark-secondary border-y border-bambu-dark-tertiary`,children:[(0,G.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider text-bambu-green`,children:e.label}),(0,G.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:e.items.length})]}),e.items.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>{S(e.id),g||_(`${C===K8?`HF`:`S`} ${e.name}`)},className:`w-full text-left px-3 py-1.5 text-sm transition-colors ${x===e.id?`bg-bambu-green/20 text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,children:e.name},e.id))]},e.source))})]})]}),(0,G.jsxs)(`div`,{className:s?`grid grid-cols-2 gap-4`:``,children:[(0,G.jsxs)(`div`,{className:s?``:`hidden`,children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:m(`kProfiles.modal.flowType`)}),(0,G.jsxs)(`select`,{value:C,onChange:t=>{let n=t.target.value;if(w(n),!e&&x&&!g){let e=a.find(e=>e.id===x);e&&_(`${n===K8?`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,G.jsx)(`option`,{value:K8,children:m(`kProfiles.modal.highFlow`)}),(0,G.jsx)(`option`,{value:G8,children:m(`kProfiles.modal.standard`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:m(`kProfiles.modal.nozzleSize`)}),(0,G.jsxs)(`select`,{value:T,onChange:e=>E(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,G.jsx)(`option`,{value:`0.2`,children:`0.2mm`}),(0,G.jsx)(`option`,{value:`0.4`,children:`0.4mm`}),(0,G.jsx)(`option`,{value:`0.6`,children:`0.6mm`}),(0,G.jsx)(`option`,{value:`0.8`,children:`0.8mm`})]})]})]}),o&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:m(e?`kProfiles.modal.extruder`:`kProfiles.modal.extruders`)}),e?(0,G.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?m(`kProfiles.modal.left`):m(`kProfiles.modal.right`)}):(0,G.jsxs)(`div`,{className:`flex gap-4`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:D.includes(1),onChange:e=>{e.target.checked?O([...D,1]):O(D.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,G.jsx)(`span`,{className:`text-white`,children:m(`kProfiles.modal.left`)})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:D.includes(0),onChange:e=>{e.target.checked?O([...D,0]):O(D.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,G.jsx)(`span`,{className:`text-white`,children:m(`kProfiles.modal.right`)})]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:m(`kProfiles.modal.notes`)}),(0,G.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),placeholder:m(`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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:m(`kProfiles.modal.notesHelp`)})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 pt-4`,children:[e&&(0,G.jsx)(Q,{type:`button`,variant:`secondary`,onClick:()=>te(!0),disabled:V.isPending||k||!p(`kprofiles:delete`),title:p(`kprofiles:delete`)?void 0:m(`kProfiles.permission.noDelete`),className:`text-red-500 hover:bg-red-500/10`,children:V.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Au,{className:`w-4 h-4`})}),(0,G.jsx)(Q,{type:`button`,variant:`secondary`,onClick:u,disabled:k,className:`flex-1`,children:m(`common.cancel`)}),(0,G.jsxs)(Q,{type:`submit`,disabled:B.isPending||k||!p(e?`kprofiles:update`:`kprofiles:create`),title:p(e?`kprofiles:update`:`kprofiles:create`)?void 0:m(e?`kProfiles.permission.noUpdate`:`kProfiles.permission.noCreate`),className:`flex-1`,children:[B.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(xc,{className:`w-4 h-4`}),m(`common.save`)]})]})]})]})]}),ee&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-[60]`,children:(0,G.jsx)(jd,{className:`w-full max-w-sm`,children:(0,G.jsxs)(Nd,{className:`p-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center`,children:(0,G.jsx)(Au,{className:`w-5 h-5 text-red-500`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:m(`kProfiles.deleteConfirm.title`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:m(`kProfiles.deleteConfirm.cannotUndo`)})]})]}),(0,G.jsx)(`p`,{className:`text-bambu-gray mb-6`,children:m(`kProfiles.deleteConfirm.message`,{name:e?.name})}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>te(!1),className:`flex-1`,children:m(`common.cancel`)}),(0,G.jsxs)(Q,{onClick:()=>{te(!1),ne()},disabled:V.isPending,className:`flex-1 bg-red-500 hover:bg-red-600 text-white`,children:[V.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Au,{className:`w-4 h-4`}),m(`common.delete`)]})]})]})})})]})}var Z8={NOZZLE_DIAMETER:`bambusy_kprofiles_nozzle`,SORT_OPTION:`bambusy_kprofiles_sort`};function nUe(){let{t:e}=U(),{showToast:t}=zd(),{hasPermission:n}=Td(),[r,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(()=>localStorage.getItem(Z8.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(Z8.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(Z8.NOZZLE_DIAMETER,a)},[a]),(0,y.useEffect)(()=>{localStorage.setItem(Z8.SORT_OPTION,b)},[b]);let{data:j,isLoading:M}=K({queryKey:[`printers`],queryFn:Z.getPrinters}),{data:N,isLoading:P,isFetching:F,error:I,refetch:L}=K({queryKey:[`kprofiles`,r,a],queryFn:async()=>{console.log(`[KProfiles] Fetching profiles for printer`,r,`nozzle`,a);let e=await Z.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}=K({queryKey:[`builtinFilaments`],queryFn:()=>Z.getBuiltinFilaments(),staleTime:3e5}),{data:z}=K({queryKey:[`filamentIdMap`],queryFn:()=>Z.getFilamentIdMap(),staleTime:3e5}),{data:B}=K({queryKey:[`localPresets`],queryFn:()=>Z.getLocalPresets(),retry:!1}),{data:V}=K({queryKey:[`orcaCloudProfilesForKProfiles`],queryFn:()=>Z.orcaCloudListProfiles(),retry:!1}),{data:ee}=K({queryKey:[`cloudSettings`],queryFn:()=>Z.getCloudSettings(),retry:!1}),{data:te,refetch:ne}=K({queryKey:[`kprofile-notes`,r],queryFn:()=>Z.getKProfileNotes(r),enabled:!!r,staleTime:3e4}),re=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 ie=j?.filter(e=>e.is_active)||[],ae=y.useMemo(()=>{let e=new Map;if(R)for(let t of R)e.set(t.filament_id,t.name);if(z)for(let[t,n]of Object.entries(z))e.has(t)||e.set(t,n);return e},[R,z]),oe=y.useMemo(()=>Array.from(ae.entries()).map(([e,t])=>({filament_id:e,name:t})),[ae]),se=y.useMemo(()=>$He({localPresets:B?.filament,orcaProfiles:V?.filament,cloudSettings:ee?.filament,builtinFilaments:R}),[B?.filament,V?.filament,ee?.filament,R]),H=y.useCallback(e=>ae.get(e.filament_id)||J8(e.name),[ae]),ce=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]),le=j?.find(e=>e.id===r),ue=le?.nozzle_count===2,de=le?.supports_nozzle_flow_type??!0;(0,y.useEffect)(()=>{de||v(`all`)},[de]),(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 fe=(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:le?.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_${le?.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,le,a,t,e]),pe=(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 Z.setKProfile(r,{name:e.name,k_value:parseFloat(e.k_value).toFixed(6),filament_id:e.filament_id,nozzle_id:e.nozzle_id||`${G8}-${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]),me=(0,y.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),he=(0,y.useCallback)(()=>{T(new Set(ce.map(e=>A(e))))},[ce,A]),ge=(0,y.useCallback)(()=>{w.size!==0&&D(!0)},[w.size]),_e=(0,y.useCallback)(async()=>{let n=ce.filter(e=>w.has(A(e)));k(!0);let i=0;for(let e of n)try{await Z.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,ce,t,L,A,e]),ve=(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},[]),ye=(0,y.useCallback)(async(n,i)=>{if(r)try{await Z.setKProfileNote(r,n,i),ne()}catch(n){console.error(`Failed to save note:`,n),t(e(`kProfiles.toast.failedToSaveNote`),`error`)}},[r,ne,t,e]),be=(0,y.useCallback)(e=>{if(!te?.notes)return{note:``,key:null};let t=ve(e);for(let e of t)if(te.notes[e])return{note:te.notes[e],key:e};return{note:``,key:null}},[te,ve]),xe=(0,y.useCallback)(e=>be(e).note,[be]);return M?(0,G.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):!j||j.length===0?(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`py-12 text-center`,children:[(0,G.jsx)(_s,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noPrintersConfigured`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`kProfiles.addPrinterInSettings`)})]})}):ie.length===0?(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`py-12 text-center`,children:[(0,G.jsx)(Pl,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noActivePrinters`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`kProfiles.enablePrinterConnection`)})]})}):(0,G.jsxs)(G.Fragment,{children:[F&&!P&&(0,G.jsxs)(`div`,{className:`fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40`,children:[(0,G.jsx)(Y,{className:`w-10 h-10 text-bambu-green animate-spin mb-3`}),(0,G.jsx)(`p`,{className:`text-white font-medium`,children:e(`kProfiles.loadingProfiles`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-4 mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-48`,children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`kProfiles.printer`)}),(0,G.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:ie.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,G.jsxs)(`div`,{className:`w-32`,children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`kProfiles.nozzle`)}),(0,G.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,G.jsx)(`option`,{value:`0.2`,children:`0.2mm`}),(0,G.jsx)(`option`,{value:`0.4`,children:`0.4mm`}),(0,G.jsx)(`option`,{value:`0.6`,children:`0.6mm`}),(0,G.jsx)(`option`,{value:`0.8`,children:`0.8mm`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,G.jsxs)(Q,{variant:`secondary`,onClick:()=>L(),disabled:F||!n(`kprofiles:read`),title:n(`kprofiles:read`)?void 0:e(`kProfiles.permission.noRead`),children:[(0,G.jsx)(Rl,{className:`w-4 h-4 ${F?`animate-spin`:``}`}),e(`kProfiles.refresh`)]}),(0,G.jsxs)(Q,{onClick:()=>u(!0),disabled:!n(`kprofiles:create`),title:n(`kprofiles:create`)?void 0:e(`kProfiles.permission.noCreate`),children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),e(`kProfiles.addProfile`)]})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-4 mb-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-48 relative`,children:[(0,G.jsx)(Jl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,G.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`})]}),ue&&(0,G.jsx)(`div`,{className:`w-36`,children:(0,G.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,G.jsx)(`option`,{value:`all`,children:e(`kProfiles.allExtruders`)}),(0,G.jsx)(`option`,{value:`left`,children:e(`kProfiles.leftOnly`)}),(0,G.jsx)(`option`,{value:`right`,children:e(`kProfiles.rightOnly`)})]})}),de&&(0,G.jsx)(`div`,{className:`w-32`,children:(0,G.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,G.jsx)(`option`,{value:`all`,children:e(`kProfiles.allFlow`)}),(0,G.jsx)(`option`,{value:`hf`,children:e(`kProfiles.hfOnly`)}),(0,G.jsx)(`option`,{value:`s`,children:e(`kProfiles.sOnly`)})]})}),(0,G.jsx)(`div`,{className:`w-32`,children:(0,G.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,G.jsx)(`option`,{value:`name`,children:e(`kProfiles.sortName`)}),(0,G.jsx)(`option`,{value:`k_value`,children:e(`kProfiles.sortKValue`)}),(0,G.jsx)(`option`,{value:`filament`,children:e(`kProfiles.sortFilament`)})]})})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2 mb-6`,children:[(0,G.jsxs)(Q,{variant:`secondary`,onClick:fe,disabled:!N?.profiles?.length||!n(`kprofiles:read`),title:n(`kprofiles:read`)?void 0:e(`kProfiles.permission.noExport`),children:[(0,G.jsx)(qs,{className:`w-4 h-4`}),e(`kProfiles.export`)]}),(0,G.jsxs)(Q,{variant:`secondary`,onClick:pe,disabled:!n(`kprofiles:create`),title:n(`kprofiles:create`)?void 0:e(`kProfiles.permission.noImport`),children:[(0,G.jsx)(Lu,{className:`w-4 h-4`}),e(`kProfiles.import`)]}),(0,G.jsx)(`div`,{className:`flex-1`}),S?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Q,{variant:`secondary`,onClick:he,children:[(0,G.jsx)(mu,{className:`w-4 h-4`}),e(`kProfiles.selectAll`)]}),(0,G.jsxs)(Q,{variant:`secondary`,onClick:ge,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,G.jsx)(Au,{className:`w-4 h-4`}),e(`kProfiles.delete`),` (`,w.size,`)`]}),(0,G.jsxs)(Q,{variant:`secondary`,onClick:()=>{C(!1),T(new Set)},children:[(0,G.jsx)(Qu,{className:`w-4 h-4`}),e(`common.cancel`)]})]}):(0,G.jsxs)(Q,{variant:`secondary`,onClick:()=>C(!0),disabled:!ce.length||!n(`kprofiles:delete`),title:n(`kprofiles:delete`)?void 0:e(`kProfiles.permission.noDelete`),children:[(0,G.jsx)(mu,{className:`w-4 h-4`}),e(`kProfiles.select`)]})]}),P?(0,G.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):re?(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`py-12 text-center`,children:[(0,G.jsx)(qu,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.printerOffline`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`kProfiles.printerOfflineDesc`)}),(0,G.jsxs)(Q,{variant:`secondary`,onClick:()=>L(),children:[(0,G.jsx)(Rl,{className:`w-4 h-4`}),e(`common.refresh`)]})]})}):ce.length>0?ue?(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray mb-2 px-1`,children:e(`kProfiles.leftExtruder`)}),(0,G.jsx)(`div`,{className:`space-y-1`,children:ce.filter(e=>e.extruder_id===1).map(e=>(0,G.jsx)(Y8,{profile:e,onEdit:()=>c(e),onCopy:()=>f(e),selectionMode:S,isSelected:w.has(A(e)),onToggleSelect:()=>me(A(e)),note:xe(e)},A(e)))})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray mb-2 px-1`,children:e(`kProfiles.rightExtruder`)}),(0,G.jsx)(`div`,{className:`space-y-1`,children:ce.filter(e=>e.extruder_id===0).map(e=>(0,G.jsx)(Y8,{profile:e,onEdit:()=>c(e),onCopy:()=>f(e),selectionMode:S,isSelected:w.has(A(e)),onToggleSelect:()=>me(A(e)),note:xe(e)},A(e)))})]})]}):(0,G.jsx)(`div`,{className:`space-y-1`,children:ce.map(e=>(0,G.jsx)(Y8,{profile:e,onEdit:()=>c(e),onCopy:()=>f(e),selectionMode:S,isSelected:w.has(A(e)),onToggleSelect:()=>me(A(e)),note:xe(e)},A(e)))}):p||h!==`all`||_!==`all`?(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`py-12 text-center`,children:[(0,G.jsx)(Jl,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noMatchingProfiles`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`kProfiles.noMatchingProfilesDesc`)})]})}):(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`py-12 text-center`,children:[(0,G.jsx)(xc,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noKProfiles`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`kProfiles.noKProfilesDesc`,{diameter:a})}),(0,G.jsxs)(Q,{onClick:()=>u(!0),children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),e(`kProfiles.createFirstProfile`)]})]})}),s&&r&&(()=>{let{note:e,key:t}=be(s);return(0,G.jsx)(X8,{profile:s,printerId:r,nozzleDiameter:a,existingProfiles:N?.profiles,builtinFilaments:oe,filamentPresets:se,isDualNozzle:ue,supportsFlowType:de,initialNote:e,initialNoteKey:t,onSaveNote:ye,hasPermission:n,onClose:()=>{console.log(`[KProfiles] Edit modal onClose - refetching profiles...`),c(null),L()},onSave:()=>{c(null),L()}})})(),l&&r&&(0,G.jsx)(X8,{printerId:r,nozzleDiameter:a,existingProfiles:N?.profiles,builtinFilaments:oe,filamentPresets:se,isDualNozzle:ue,supportsFlowType:de,onSaveNote:ye,hasPermission:n,onClose:()=>{u(!1),L()},onSave:()=>{u(!1),L()}}),d&&r&&(0,G.jsx)(X8,{printerId:r,nozzleDiameter:a,existingProfiles:N?.profiles,builtinFilaments:oe,filamentPresets:se,isDualNozzle:ue,supportsFlowType:de,onSaveNote:ye,hasPermission:n,profile:{...d,slot_id:0,name:`${d.name} (Copy)`},onClose:()=>{f(null),L()},onSave:()=>{f(null),L()}}),E&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,G.jsx)(jd,{className:`w-full max-w-sm`,children:(0,G.jsxs)(Nd,{className:`p-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center`,children:(0,G.jsx)(Au,{className:`w-5 h-5 text-red-500`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:e(`kProfiles.bulkDelete.title`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`kProfiles.bulkDelete.cannotUndo`)})]})]}),(0,G.jsx)(`p`,{className:`text-bambu-gray mb-6`,children:e(`kProfiles.bulkDelete.message`,{count:w.size})}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>D(!1),disabled:O,className:`flex-1`,children:e(`common.cancel`)}),(0,G.jsxs)(Q,{onClick:_e,disabled:O,className:`flex-1 bg-red-500 hover:bg-red-600 text-white`,children:[O?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Au,{className:`w-4 h-4`}),e(`common.delete`)]})]})]})})})]})}var Q8=[`PLA`,`PETG`,`PCTG`,`ABS`,`ASA`,`TPU`,`PC`,`PA`,`PVA`,`HIPS`,`PP`,`PET`,`NYLON`],rUe={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 iUe(e){let t=e.toUpperCase();for(let e of Q8)if(RegExp(`\\b${e}\\b`).test(t))return e;return null}function aUe(e){let t=e.replace(/@.+$/,``).trim(),n=t.toUpperCase();for(let e of Q8){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 $8({preset:e,onDelete:t,onExpand:n,isExpanded:r}){let{t:i}=U(),{hasPermission:a}=Td(),o=e.filament_type||iUe(e.name),s=e.filament_vendor||aUe(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=rUe[o.toUpperCase()]||null),(0,G.jsx)(jd,{className:`bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80 transition-colors`,children:(0,G.jsxs)(Nd,{className:`p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[e.preset_type===`filament`&&(0,G.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,G.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,children:e.name})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[o&&(0,G.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-bambu-green/20 text-bambu-green`,children:o}),s&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:s}),(0,G.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400`,children:i(`profiles.localProfiles.badge`)})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[a(`settings:update`)&&(0,G.jsx)(`button`,{onClick:()=>t(e.id),className:`p-1 text-bambu-gray hover:text-red-600 dark:hover:text-red-400 transition-colors`,title:i(`profiles.localProfiles.delete`),children:(0,G.jsx)(Au,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`button`,{onClick:()=>n(r?null:e.id),className:`p-1 text-bambu-gray hover:text-white transition-colors`,children:r?(0,G.jsx)(ms,{className:`w-3.5 h-3.5`}):(0,G.jsx)(ds,{className:`w-3.5 h-3.5`})})]})]}),r&&(0,G.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-bambu-dark-tertiary text-xs space-y-1.5`,children:[o&&(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.filamentType`)}),(0,G.jsx)(`span`,{className:`text-white`,children:o})]}),s&&(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.vendor`)}),(0,G.jsx)(`span`,{className:`text-white`,children:s})]}),e.nozzle_temp_min!=null&&e.nozzle_temp_max!=null&&(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.nozzleTemp`)}),(0,G.jsxs)(`span`,{className:`text-white`,children:[e.nozzle_temp_min,`–`,e.nozzle_temp_max,`°C`]})]}),e.filament_cost&&(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.cost`)}),(0,G.jsx)(`span`,{className:`text-white`,children:e.filament_cost})]}),e.filament_density&&(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.density`)}),(0,G.jsxs)(`span`,{className:`text-white`,children:[e.filament_density,` g/cm³`]})]}),e.pressure_advance&&(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.pressureAdvance`)}),(0,G.jsx)(`span`,{className:`text-white`,children:e.pressure_advance})]}),e.compatible_printers&&(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.compatiblePrinters`)}),(0,G.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,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.inheritsFrom`)}),(0,G.jsx)(`span`,{className:`text-white truncate ml-2`,children:e.inherits})]}),(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.source`)}),(0,G.jsx)(`span`,{className:`text-white capitalize`,children:e.source})]})]})]})})}function oUe(){let{t:e}=U(),{hasPermission:t}=Td(),n=so(),{showToast:r}=zd(),[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}=K({queryKey:[`localPresets`],queryFn:()=>Z.getLocalPresets()}),m=q({mutationFn:async e=>{let t=[];for(let n of Array.from(e)){let e=new FormData;e.append(`file`,n),t.push(await Z.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=q({mutationFn:e=>Z.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,G.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[t(`settings:update`)&&(0,G.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,G.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,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,G.jsx)(Y,{className:`w-5 h-5 text-bambu-green animate-spin`}),(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:e(`profiles.localProfiles.importing`)})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Lu,{className:`w-8 h-8 text-bambu-gray mx-auto mb-2`}),(0,G.jsx)(`p`,{className:`text-sm text-white font-medium`,children:e(`profiles.localProfiles.import`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`profiles.localProfiles.importDesc`)})]})]}),w&&(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(Jl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,G.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,G.jsxs)(`div`,{className:`text-center py-12`,children:[(0,G.jsx)(Ac,{className:`w-12 h-12 text-bambu-gray mx-auto mb-3 opacity-50`}),(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`profiles.localProfiles.noPresets`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray/60 mt-1`,children:e(`profiles.localProfiles.importDesc`)})]}),w&&C===0&&!p&&(0,G.jsxs)(`div`,{className:`text-center py-12`,children:[(0,G.jsx)(Jl,{className:`w-12 h-12 text-bambu-gray mx-auto mb-3 opacity-50`}),(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`profiles.localProfiles.noSearchResults`)})]}),C>0&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6`,children:[b.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(Js,{className:`w-4 h-4 text-bambu-green`}),(0,G.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:e(`profiles.localProfiles.filament`)}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`(`,b.length,`)`]})]}),(0,G.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,G.jsx)($8,{preset:e,onDelete:e=>d(e),onExpand:s,isExpanded:o===e.id},e.id))})]}),S.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(Uc,{className:`w-4 h-4 text-blue-600 dark:text-blue-400`}),(0,G.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:e(`profiles.localProfiles.process`)}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`(`,S.length,`)`]})]}),(0,G.jsx)(`div`,{className:`space-y-2`,children:S.map(e=>(0,G.jsx)($8,{preset:e,onDelete:e=>d(e),onExpand:s,isExpanded:o===e.id},e.id))})]}),x.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(Ql,{className:`w-4 h-4 text-orange-600 dark:text-orange-400`}),(0,G.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:e(`profiles.localProfiles.printer`)}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`(`,x.length,`)`]})]}),(0,G.jsx)(`div`,{className:`space-y-2`,children:x.map(e=>(0,G.jsx)($8,{preset:e,onDelete:e=>d(e),onExpand:s,isExpanded:o===e.id},e.id))})]})]}),u!==null&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,G.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg p-6 max-w-sm mx-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(_s,{className:`w-5 h-5 text-red-600 dark:text-red-400`}),(0,G.jsx)(`h3`,{className:`text-white font-medium`,children:e(`profiles.localProfiles.deleteConfirmTitle`)})]}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:e(`profiles.localProfiles.deleteConfirm`)}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>d(null),children:e(`profiles.localProfiles.cancel`)}),(0,G.jsxs)(Q,{variant:`danger`,size:`sm`,onClick:()=>h.mutate(u),disabled:h.isPending,children:[h.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Au,{className:`w-4 h-4`}),e(`profiles.localProfiles.delete`)]})]})]})})]})}function sUe(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 cUe({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:sUe(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,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`space-y-4 mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.jsx)(Jl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,G.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,G.jsx)(`div`,{className:`flex gap-2`,children:(0,G.jsxs)(Q,{variant:`secondary`,onClick:n,disabled:r,children:[(0,G.jsx)(Rl,{className:`w-4 h-4 ${r?`animate-spin`:``}`}),a(`profiles.cloudView.refresh`)]})})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(bc,{className:`w-4 h-4 text-bambu-gray`}),(0,G.jsx)(r5,{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,G.jsx)(r5,{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,G.jsx)(r5,{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,G.jsx)(r5,{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,G.jsx)(r5,{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,G.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,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray`,children:[t&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(ks,{className:`w-3 h-3`}),a(`profiles.cloudView.lastSynced`),` `,Xf(t.toISOString(),`system`,a)]}),(0,G.jsx)(`span`,{children:a(`profiles.cloudView.showingCount`,{showing:w.length,total:D})})]}),w.length===0?(0,G.jsxs)(`div`,{className:`text-center py-16`,children:[(0,G.jsx)(Uc,{className:`w-12 h-12 text-bambu-gray-dark mx-auto mb-4`}),(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:a(`profiles.cloudView.noPresetsFound`)}),E&&(0,G.jsx)(`button`,{onClick:T,className:`mt-2 text-sm text-bambu-green hover:text-bambu-green-light`,children:a(`profiles.cloudView.clearFilters`)})]}):(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-6`,children:[(0,G.jsx)(e5,{icon:(0,G.jsx)(Js,{className:`w-4 h-4 text-amber-600 dark:text-amber-400`}),title:a(`profiles.cloudView.columns.filament`),presets:O(`filament`),emptyText:a(`profiles.cloudView.noFilamentPresets`),onSelect:b}),(0,G.jsx)(e5,{icon:(0,G.jsx)(Ql,{className:`w-4 h-4 text-blue-600 dark:text-blue-400`}),title:a(`profiles.cloudView.columns.process`),presets:O(`process`),emptyText:a(`profiles.cloudView.noProcessPresets`),onSelect:b}),(0,G.jsx)(e5,{icon:(0,G.jsx)(Pl,{className:`w-4 h-4 text-purple-600 dark:text-purple-400`}),title:a(`profiles.cloudView.columns.printer`),presets:O(`printer`),emptyText:a(`profiles.cloudView.noPrinterPresets`),onSelect:b})]}),v&&(0,G.jsx)(uUe,{setting:v,onClose:()=>b(null),t:a})]})}function e5({icon:e,title:t,presets:n,emptyText:r,onSelect:i}){return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 px-1`,children:[e,(0,G.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray`,children:t}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray-dark`,children:[`(`,n.length,`)`]})]}),(0,G.jsx)(`div`,{className:`space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1`,children:n.length===0?(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray-dark px-3 py-2`,children:r}):n.map(e=>(0,G.jsx)(lUe,{preset:e,onClick:()=>i(e)},e.setting_id))})]})}function lUe({preset:e,onClick:t}){return(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-white text-sm truncate flex-1`,title:e.name,children:e.name}),e.meta.filamentType&&e.type===`filament`&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:e.meta.filamentType}),e.meta.layerHeight&&e.type===`process`&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:e.meta.layerHeight}),e.meta.printer&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:e.meta.printer})]})})}function uUe({setting:e,onClose:t,t:n}){let{data:r,isLoading:i,error:a}=K({queryKey:[`orcaCloudProfileDetail`,e.setting_id],queryFn:()=>Z.orcaCloudGetProfile(e.setting_id),retry:!1});return(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/60 z-50 flex items-center justify-center p-4`,onClick:t,children:(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:e.name}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:e.type})]}),(0,G.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white p-1`,children:(0,G.jsx)(Qu,{className:`w-5 h-5`})})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:i?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):a?(0,G.jsx)(`p`,{className:`text-center text-bambu-gray py-16`,children:a.message}):r?(0,G.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,G.jsx)(`p`,{className:`text-center text-bambu-gray py-16`,children:n(`profiles.cloudView.noPresetsFound`)})})]})})}function dUe(){let{t:e}=U(),t=so(),{showToast:n}=zd(),{hasPermission:r}=Td(),i=r(`orca_cloud:auth`),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(5e3),[l,u]=(0,y.useState)(null),{data:d,isLoading:f}=K({queryKey:[`orcaCloudStatus`],queryFn:Z.orcaCloudStatus}),p=!!d?.connected,{data:m,isLoading:h,refetch:g,isRefetching:_,error:v,dataUpdatedAt:b}=K({queryKey:[`orcaCloudProfiles`],queryFn:Z.orcaCloudListProfiles,enabled:p,retry:!1,staleTime:1e3*60*5}),{data:x=[]}=K({queryKey:[`printers`],queryFn:Z.getPrinters,enabled:p}),[S,C]=(0,y.useState)();(0,y.useEffect)(()=>{b&&C(new Date(b))},[b]);let w=()=>{o(null),c(5e3)},T=t=>{t===`access_denied`?u(e(`profiles.orcaCloud.errors.denied`)):t===`expired_token`&&u(e(`profiles.orcaCloud.errors.expired`)),w()},E=q({mutationFn:Z.orcaCloudDeviceStart,onSuccess:e=>{u(null),c(Math.max(1,e.interval)*1e3),o(e)},onError:t=>{u(t.message||e(`profiles.orcaCloud.errors.startFailed`))}}),D=q({mutationFn:Z.orcaCloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:[`orcaCloudStatus`]}),t.removeQueries({queryKey:[`orcaCloudProfiles`]}),n(e(`profiles.orcaCloud.toast.disconnected`))}}),{data:O,error:k}=K({queryKey:[`orcaCloudDevicePoll`,a?.user_code??`none`],queryFn:Z.orcaCloudDevicePoll,enabled:a!==null,gcTime:0,retry:!1,refetchOnWindowFocus:!1,refetchInterval:a===null?!1:s}),A=(0,y.useRef)(null);return(0,y.useEffect)(()=>{if(!a||!O)return;let r=O.status;if(r===`slow_down`){c(e=>e+5e3);return}r!==`authorization_pending`&&A.current!==r&&(A.current=r,r===`complete`?(w(),t.invalidateQueries({queryKey:[`orcaCloudStatus`]}),t.invalidateQueries({queryKey:[`orcaCloudProfiles`]}),n(e(`profiles.orcaCloud.connectedShort`))):T(r))},[O,a]),(0,y.useEffect)(()=>{a&&k&&(u(e(`profiles.orcaCloud.errors.pollFailed`)),w())},[k,a]),(0,y.useEffect)(()=>{a&&(A.current=null)},[a]),f?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):(0,G.jsxs)(`div`,{children:[p&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-bambu-green animate-pulse`}),(0,G.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:d?.email?(0,G.jsxs)(G.Fragment,{children:[e(`profiles.orcaCloud.connectedAs`),` `,(0,G.jsx)(`span`,{className:`text-white`,children:d.email})]}):(0,G.jsx)(`span`,{className:`text-white`,children:e(`profiles.orcaCloud.connectedShort`)})})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>D.mutate(),disabled:D.isPending||!i,title:i?void 0:e(`profiles.orcaCloud.noLogoutPermission`),children:[(0,G.jsx)(el,{className:`w-4 h-4`}),e(`profiles.orcaCloud.logout`)]})]}),p?h?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):v?(0,G.jsxs)(`div`,{className:`text-center py-16`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:v.message}),(0,G.jsx)(Q,{onClick:()=>g(),children:e(`profiles.orcaCloud.retry`)})]}):m?(0,G.jsx)(cUe,{settings:m,lastSyncTime:S,onRefresh:()=>g(),isRefreshing:_,printers:x,t:e}):null:(0,G.jsx)(fUe,{pairing:a,connectError:l,onConnect:()=>E.mutate(),onCancel:w,isStarting:E.isPending,canManage:i,t:e})]})}function fUe({pairing:e,connectError:t,onConnect:n,onCancel:r,isStarting:i,canManage:a,t:o}){return e?(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`p-8 text-center max-w-md mx-auto`,children:[(0,G.jsx)(Ms,{className:`w-12 h-12 text-bambu-green mx-auto mb-4`}),(0,G.jsx)(`h2`,{className:`text-xl font-bold text-white mb-2`,children:o(`profiles.orcaCloud.device.title`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray mb-6`,children:o(`profiles.orcaCloud.device.instruction`)}),(0,G.jsx)(`p`,{className:`text-xs uppercase tracking-wide text-bambu-gray mb-2`,children:o(`profiles.orcaCloud.device.codeLabel`)}),(0,G.jsx)(`div`,{className:`mb-6 py-3 px-4 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg`,children:(0,G.jsx)(`span`,{className:`text-2xl font-mono font-bold tracking-[0.3em] text-white select-all`,children:e.user_code})}),(0,G.jsx)(`a`,{href:e.verification_uri_complete,target:`_blank`,rel:`noopener noreferrer`,children:(0,G.jsxs)(Q,{className:`w-full mb-3`,children:[(0,G.jsx)(ec,{className:`w-4 h-4`}),o(`profiles.orcaCloud.device.openButton`)]})}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray break-all mb-6`,children:o(`profiles.orcaCloud.device.manualHint`,{url:e.verification_uri})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-sm text-bambu-gray mb-4`,children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin text-bambu-green`}),o(`profiles.orcaCloud.device.waiting`)]}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`text-bambu-gray hover:text-white text-sm`,children:o(`profiles.orcaCloud.device.cancel`)})]})}):(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`p-8 text-center`,children:[(0,G.jsx)(Ms,{className:`w-12 h-12 text-bambu-green mx-auto mb-4`}),(0,G.jsx)(`h2`,{className:`text-xl font-bold text-white mb-2`,children:o(`profiles.orcaCloud.connect.title`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray mb-6 max-w-xl mx-auto`,children:o(`profiles.orcaCloud.connect.description`)}),(0,G.jsxs)(`div`,{className:`max-w-sm mx-auto`,children:[(0,G.jsxs)(Q,{onClick:n,disabled:i||!a,title:a?void 0:o(`profiles.orcaCloud.noConnectPermission`),className:`w-full`,children:[i?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(us,{className:`w-4 h-4`}),o(`profiles.orcaCloud.connectButton`)]}),t&&(0,G.jsxs)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-400 flex items-center justify-center gap-2`,children:[(0,G.jsx)(_s,{className:`w-4 h-4 flex-shrink-0`}),t]})]})]})})}function t5(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 n5(e){return/^(P[FPM]US|PF\d|PP\d)/.test(e)}function pUe({onSuccess:e,t}){let{showToast:n}=zd(),[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,x]=(0,y.useState)(!1),S=q({mutationFn:()=>Z.cloudLogin(a,s,p),onSuccess:r=>{if(x(r.reason===`captcha`),r.success)n(t(`profiles.login.toast.loggedIn`)),e();else if(r.reason===`captcha`)return;else 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=>{x(!1),n(e.message,`error`)}}),C=q({mutationFn:()=>Z.cloudVerify(a,l,_||void 0,p),onSuccess:r=>{x(r.reason===`captcha`),r.success?(n(t(`profiles.login.toast.loggedIn`)),e()):r.reason!==`captcha`&&n(r.message,`error`)},onError:e=>{x(!1),n(e.message,`error`)}}),w=q({mutationFn:()=>Z.cloudSetToken(d,p),onSuccess:()=>{n(t(`profiles.login.toast.tokenSet`)),e()},onError:e=>n(e.message,`error`)}),T=e=>{e.preventDefault(),r===`email`?S.mutate():r===`code`?C.mutate():r===`token`&&w.mutate()},E=S.isPending||C.isPending||w.isPending;return(0,G.jsx)(jd,{className:`max-w-md mx-auto`,children:(0,G.jsxs)(Nd,{children:[(0,G.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,G.jsx)(`div`,{className:`inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3`,children:(0,G.jsx)(Ms,{className:`w-6 h-6 text-bambu-green`})}),(0,G.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:t(`profiles.login.title`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:t(`profiles.login.subtitle`)})]}),b&&r!==`token`&&(0,G.jsx)(`div`,{role:`alert`,className:`mb-4 p-3 rounded-lg border border-amber-500/40 bg-amber-500/10`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(eu,{className:`w-4 h-4 text-amber-400 shrink-0 mt-0.5`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-amber-300`,children:t(`profiles.login.captchaTitle`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:t(`profiles.login.captchaBody`)}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{x(!1),i(`token`)},className:`mt-2 text-xs text-bambu-green hover:underline flex items-center gap-1`,children:[(0,G.jsx)(Vc,{className:`w-3 h-3`}),t(`profiles.login.useToken`)]})]})]})}),(0,G.jsxs)(`form`,{onSubmit:T,className:`space-y-4`,children:[r===`email`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.email`)}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.password`)}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.region`)}),(0,G.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,G.jsx)(`option`,{value:`global`,children:t(`profiles.login.regionGlobal`)}),(0,G.jsx)(`option`,{value:`china`,children:t(`profiles.login.regionChina`)})]})]})]}),r===`code`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(h===`totp`?`profiles.login.totpCode`:`profiles.login.verificationCode`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:h===`totp`?t(`profiles.login.enterTotpHint`):t(`profiles.login.checkEmail`,{email:a})}),(0,G.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,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.accessToken`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:t(`profiles.login.accessTokenHint`)}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.region`)}),(0,G.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,G.jsx)(`option`,{value:`global`,children:t(`profiles.login.regionGlobal`)}),(0,G.jsx)(`option`,{value:`china`,children:t(`profiles.login.regionChina`)})]})]})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 max-[550px]:flex-wrap max-[550px]:items-center`,children:[r===`code`&&(0,G.jsx)(Q,{type:`button`,variant:`secondary`,onClick:()=>i(`email`),className:`flex-1`,children:t(`profiles.login.back`)}),(0,G.jsxs)(Q,{type:`submit`,disabled:E,className:`flex-1`,children:[E?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)($c,{className:`w-4 h-4`}),t(r===`email`?`profiles.login.loginButton`:r===`code`?`profiles.login.verifyButton`:`profiles.login.setTokenButton`)]})]}),r===`email`&&(0,G.jsx)(`div`,{className:`pt-4 border-t border-bambu-dark-tertiary`,children:(0,G.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,G.jsx)(Vc,{className:`w-4 h-4`}),t(`profiles.login.useToken`)]})}),r===`token`&&(0,G.jsx)(`div`,{className:`pt-4 border-t border-bambu-dark-tertiary`,children:(0,G.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,G.jsx)($c,{className:`w-4 h-4`}),t(`profiles.login.useEmail`)]})})]})]})})}function r5({label:e,value:t,options:n,onChange:r}){let[i,a]=(0,y.useState)(!1),o=n.find(e=>e.value===t);return(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.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,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[e,`:`]}),(0,G.jsx)(`span`,{children:o?.label||`All`}),(0,G.jsx)(ds,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?`rotate-180`:``}`})]}),i&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>a(!1)}),(0,G.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,G.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,G.jsx)(`span`,{children:e.label}),e.count!==void 0&&(0,G.jsx)(`span`,{className:`text-bambu-gray text-xs`,children:e.count})]},e.value))})]})]})}function mUe(){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,G.jsx)(`button`,{onClick:()=>{window.scrollTo({top:0,behavior:`smooth`})},className:`fixed bottom-24 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,G.jsx)(Vo,{className:`w-5 h-5`})}):null}function i5({setting:e,onClick:t,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o,t:s}){let c=t5(e.name),l=n5(e.setting_id);return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 group`,children:[(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&a!==void 0&&(0,G.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,G.jsx)(`span`,{className:`flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green`,title:s(`profiles.presets.myPreset`)}),(0,G.jsx)(`span`,{className:`text-white text-sm truncate flex-1`,title:e.name,children:e.name}),c.filamentType&&e.type===`filament`&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:c.filamentType}),c.layerHeight&&e.type===`process`&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:c.layerHeight}),c.printer&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:c.printer})]})}),(0,G.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,G.jsx)(zs,{className:`w-4 h-4`})})]})}function a5(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,G.jsx)(zs,{className:`w-4 h-4`}),n(r?`common.copied`:`common.copy`)]}),(0,G.jsx)(Q,{variant:`primary`,size:`sm`,onClick:t,className:`flex-1`,children:n(`settings.twoFa.savedCodes`)})]})]})}function NHe({onDone:e}){let{t}=U(),n=so(),{showToast:r}=zd(),[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}=K({queryKey:[`totp-setup`],queryFn:()=>Z.setupTOTP(),staleTime:1/0}),m=q({mutationFn:e=>Z.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,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(Rl,{className:`w-6 h-6 animate-spin text-bambu-green`})}):i===`qr`?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:t(`settings.twoFa.setupInstructions`)}),(0,G.jsx)(`div`,{className:`flex justify-center`,children:(0,G.jsx)(`img`,{src:`data:image/png;base64,${f.qr_code_b64}`,alt:`TOTP QR Code`,className:`w-48 h-48 rounded-lg`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:t(`settings.twoFa.manualEntry`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 bg-bambu-dark-secondary rounded-lg px-3 py-2`,children:[(0,G.jsx)(`code`,{className:`text-white text-xs font-mono flex-1 break-all`,children:u?f.secret:`••••••••••••••••`}),(0,G.jsx)(`button`,{onClick:()=>d(!u),className:`text-bambu-gray hover:text-white`,children:u?(0,G.jsx)(tc,{className:`w-4 h-4`}):(0,G.jsx)(nc,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(f.secret)},className:`text-bambu-gray hover:text-white`,children:(0,G.jsx)(zs,{className:`w-4 h-4`})})]})]}),(0,G.jsx)(Q,{variant:`primary`,className:`w-full`,onClick:()=>a(`confirm`),children:t(`settings.twoFa.scannedContinue`)})]}):i===`confirm`?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:t(`settings.twoFa.enterCodeToConfirm`)}),(0,G.jsx)(S8,{value:o,onChange:s,placeholder:`000000`}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>a(`qr`),className:`flex-1`,children:t(`common.back`)}),(0,G.jsx)(Q,{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,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`h3`,{className:`text-white font-medium`,children:t(`settings.twoFa.backupCodesTitle`)}),(0,G.jsx)(C8,{codes:c,onDone:e})]})}function PHe(){let{t:e}=U(),t=so(),{showToast:n}=zd(),{user:r}=Td(),[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}=K({queryKey:[`2fa-status`],queryFn:()=>Z.get2FAStatus()}),{data:k}=K({queryKey:[`oidc-links`],queryFn:()=>Z.getOIDCLinks()}),A=q({mutationFn:()=>Z.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=q({mutationFn:()=>Z.confirmEnableEmailOTP(g,v),onSuccess:()=>{t.invalidateQueries({queryKey:[`2fa-status`]}),_(null),b(``),n(e(`settings.twoFa.emailOtpEnabled`),`success`)},onError:e=>n(e.message,`error`)}),M=q({mutationFn:e=>Z.disableEmailOTP(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`2fa-status`]}),S(!1),w(``),n(e(`settings.twoFa.emailOtpDisabled`),`success`)},onError:e=>n(e.message,`error`)}),N=q({mutationFn:e=>Z.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=q({mutationFn:e=>Z.regenerateBackupCodes(e),onSuccess:e=>{t.invalidateQueries({queryKey:[`2fa-status`]}),l(!1),p(``),h(e.backup_codes)},onError:()=>n(e(`settings.twoFa.invalidCode`),`error`)}),F=q({mutationFn:e=>Z.deleteOIDCLink(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-links`]}),n(e(`settings.twoFa.oidcUnlinked`),`success`)},onError:e=>n(e.message,`error`)});if(O)return(0,G.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,G.jsx)(Rl,{className:`w-6 h-6 animate-spin text-bambu-green`})});let I=!!r?.email;return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(jd,{id:`card-2fa-totp`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center ${D?.totp_enabled?`bg-green-100 dark:bg-green-500/20`:`bg-gray-500/20`}`,children:(0,G.jsx)(uu,{className:`w-5 h-5 ${D?.totp_enabled?`text-green-600 dark:text-green-400`:`text-gray-400`}`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.twoFa.totpTitle`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:e(`settings.twoFa.totpDesc`)})]}),(0,G.jsx)(`div`,{className:`ml-auto`,children:D?.totp_enabled?(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-green-700 dark:text-green-400 text-sm font-medium`,children:[(0,G.jsx)(tu,{className:`w-4 h-4`}),` `,e(`common.enabled`)]}):(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-gray text-sm`,children:[(0,G.jsx)(nu,{className:`w-4 h-4`}),` `,e(`common.disabled`)]})})]})}),(0,G.jsx)(Nd,{children:i?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsx)(`h4`,{className:`text-white font-medium`,children:e(`settings.twoFa.setupAuthApp`)}),(0,G.jsx)(`button`,{onClick:()=>{a(!1),t.removeQueries({queryKey:[`totp-setup`]})},className:`text-bambu-gray hover:text-white`,children:(0,G.jsx)(Qu,{className:`w-5 h-5`})})]}),(0,G.jsx)(NHe,{onDone:()=>{a(!1),t.removeQueries({queryKey:[`totp-setup`]})}})]}):o?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.disableConfirmHint`)}),(0,G.jsx)(S8,{value:u,onChange:d,placeholder:`000000 or XXXXXXXX`,maxLength:8}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{s(!1),d(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,G.jsx)(Q,{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,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.regenBackupHint`)}),(0,G.jsx)(S8,{value:f,onChange:p,placeholder:`000000 or XXXXXXXX`,maxLength:8}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{l(!1),p(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,G.jsx)(Q,{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,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`h4`,{className:`text-white font-medium`,children:e(`settings.twoFa.newBackupCodes`)}),(0,G.jsx)(C8,{codes:m,onDone:()=>h(null)})]}):(0,G.jsx)(`div`,{className:`space-y-3`,children:D?.totp_enabled?(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray-light`,children:[(0,G.jsx)(Vc,{className:`w-4 h-4`}),e(`settings.twoFa.backupCodesRemaining`,{count:D.backup_codes_remaining})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>l(!0),className:`flex items-center gap-2`,children:[(0,G.jsx)(Rl,{className:`w-4 h-4`}),e(`settings.twoFa.regenBackup`)]}),(0,G.jsxs)(Q,{variant:`danger`,size:`sm`,onClick:()=>s(!0),className:`flex items-center gap-2`,children:[(0,G.jsx)(Au,{className:`w-4 h-4`}),e(`settings.twoFa.disableTotp`)]})]}):(0,G.jsxs)(Q,{variant:`primary`,onClick:()=>a(!0),className:`flex items-center gap-2`,children:[(0,G.jsx)(uu,{className:`w-4 h-4`}),e(`settings.twoFa.setupTotp`)]})})})]}),(0,G.jsxs)(jd,{id:`card-2fa-emailotp`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center ${D?.email_otp_enabled?`bg-green-100 dark:bg-green-500/20`:`bg-gray-500/20`}`,children:(0,G.jsx)(tl,{className:`w-5 h-5 ${D?.email_otp_enabled?`text-green-600 dark:text-green-400`:`text-gray-400`}`})}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.twoFa.emailOtpTitle`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:I?e(`settings.twoFa.emailOtpDesc`,{email:r?.email}):e(`settings.twoFa.emailOtpNoEmail`)})]}),(0,G.jsx)(`div`,{className:`ml-auto`,children:D?.email_otp_enabled?(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-green-700 dark:text-green-400 text-sm font-medium`,children:[(0,G.jsx)(tu,{className:`w-4 h-4`}),` `,e(`common.enabled`)]}):(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-gray text-sm`,children:[(0,G.jsx)(nu,{className:`w-4 h-4`}),` `,e(`common.disabled`)]})})]})}),(0,G.jsx)(Nd,{children:I?g?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.emailSetupEnterCode`)}),(0,G.jsx)(S8,{value:v,onChange:b,placeholder:`000000`}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{_(null),b(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,G.jsx)(Q,{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,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.emailDisablePasswordHint`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.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,G.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,G.jsx)(tc,{className:`w-5 h-5`}):(0,G.jsx)(nc,{className:`w-5 h-5`})})]}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{S(!1),w(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,G.jsx)(Q,{variant:`danger`,className:`flex-1`,disabled:!C||M.isPending,onClick:()=>M.mutate(C),children:M.isPending?e(`common.saving`):e(`settings.twoFa.disableEmailOtp`)})]})]}):(0,G.jsx)(`div`,{className:`flex gap-3`,children:D?.email_otp_enabled?(0,G.jsxs)(Q,{variant:`danger`,size:`sm`,onClick:()=>S(!0),className:`flex items-center gap-2`,children:[(0,G.jsx)(Au,{className:`w-4 h-4`}),e(`settings.twoFa.disableEmailOtp`)]}):(0,G.jsxs)(Q,{variant:`primary`,disabled:!I||A.isPending,onClick:()=>A.mutate(),className:`flex items-center gap-2`,children:[(0,G.jsx)(tl,{className:`w-4 h-4`}),A.isPending?e(`common.saving`):e(`settings.twoFa.enableEmailOtp`)]})}):(0,G.jsx)(`p`,{className:`text-amber-700 dark:text-amber-400 text-sm`,children:e(`settings.twoFa.addEmailFirst`)})})]}),k&&k.length>0&&(0,G.jsxs)(jd,{id:`card-2fa-linked`,children:[(0,G.jsxs)(Md,{children:[(0,G.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.twoFa.linkedAccounts`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:e(`settings.twoFa.linkedAccountsDesc`)})]}),(0,G.jsx)(Nd,{children:(0,G.jsx)(`div`,{className:`space-y-3`,children:k.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between py-2 border-b border-bambu-dark-tertiary last:border-0`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm font-medium`,children:e.provider_name}),e.provider_email&&(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:e.provider_email})]}),(0,G.jsx)(Q,{variant:`danger`,size:`sm`,onClick:()=>F.mutate(e.provider_id),disabled:F.isPending,children:(0,G.jsx)(Au,{className:`w-4 h-4`})})]},e.id))})})]})]})}var FHe={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,is_autologin:!1};function w8({initial:e,isEdit:t=!1,groups:n=[],onSave:r,onCancel:i,isPending:a}){let{t:o}=U(),[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,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:o(`settings.oidc.form.requireEmailVerifiedWarning`)}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.name`),` `,(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:`*`})]}),(0,G.jsx)(`input`,{className:f,value:s.name,onChange:e=>d(`name`,e.target.value),placeholder:`Google`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.issuerUrl`),` `,(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:`*`})]}),(0,G.jsx)(`input`,{className:f,value:s.issuer_url,onChange:e=>d(`issuer_url`,e.target.value),placeholder:`https://accounts.google.com`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.clientId`),` `,(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:`*`})]}),(0,G.jsx)(`input`,{className:f,value:s.client_id,onChange:e=>d(`client_id`,e.target.value),placeholder:`your-client-id`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.clientSecret`),!t&&(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:` *`}),t&&(0,G.jsxs)(`span`,{className:`text-bambu-gray text-xs ml-1`,children:[`(`,o(`settings.oidc.form.secretHint`),`)`]})]}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:p,children:o(`settings.oidc.form.scopes`)}),(0,G.jsx)(`input`,{className:f,value:s.scopes,onChange:e=>d(`scopes`,e.target.value),placeholder:`openid email profile`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:p,children:o(`settings.oidc.form.iconUrl`)}),(0,G.jsx)(`input`,{className:f,value:s.icon_url??``,onChange:e=>d(`icon_url`,e.target.value===``?null:e.target.value),placeholder:`https://...`})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-6 pt-2`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(EU,{checked:s.is_enabled??!0,onChange:e=>d(`is_enabled`,e)}),(0,G.jsx)(`span`,{className:`text-white text-sm`,children:o(`settings.oidc.form.enabled`)})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(EU,{checked:s.auto_create_users??!1,onChange:e=>d(`auto_create_users`,e)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm`,children:o(`settings.oidc.form.autoCreate`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:o(`settings.oidc.form.autoCreateDesc`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer w-full`,children:[(0,G.jsx)(EU,{checked:s.auto_link_existing_accounts??!1,onChange:e=>d(`auto_link_existing_accounts`,e)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm`,children:o(`settings.oidc.form.autoLink`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:o(`settings.oidc.form.autoLinkDesc`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer w-full`,children:[(0,G.jsx)(EU,{checked:g,onChange:e=>d(`require_email_verified`,e),disabled:h}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm`,children:o(`settings.oidc.form.requireEmailVerified`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:_})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer w-full`,children:[(0,G.jsx)(EU,{checked:s.is_autologin??!1,onChange:e=>d(`is_autologin`,e)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm`,children:o(`settings.oidc.form.autologin`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:o(`settings.oidc.form.autologinDesc`)})]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:p,children:o(`settings.oidc.form.emailClaim`)}),(0,G.jsx)(`input`,{className:f,value:s.email_claim,onChange:e=>d(`email_claim`,e.target.value||`email`),placeholder:o(`settings.oidc.form.emailClaimPlaceholder`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:o(`settings.oidc.form.emailClaimDesc`)}),h&&s.email_claim!==`email`&&(0,G.jsx)(`p`,{className:`text-yellow-700 dark:text-yellow-400 text-xs mt-1`,children:o(`settings.oidc.form.emailClaimCustomClaimAutoLinkWarning`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:p,children:o(`settings.oidc.form.defaultGroup`)}),(0,G.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,G.jsx)(`option`,{value:``,children:o(`settings.oidc.form.defaultGroupViewersFallback`)}),n.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:o(`settings.oidc.form.defaultGroupDesc`)})]}),(0,G.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:i,className:`flex-1`,children:o(`common.cancel`)}),(0,G.jsx)(Q,{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 IHe({provider:e}){let[t,n]=(0,y.useState)(!1);return e.has_icon&&!t?(0,G.jsx)(`img`,{src:Z.oidcProviderIconUrl(e.id),alt:e.name,className:`w-8 h-8 rounded object-contain`,onError:()=>n(!0)}):(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,G.jsx)(Ec,{className:`w-4 h-4 text-bambu-gray`})})}function LHe(){let{t:e}=U(),t=so(),{showToast:n}=zd(),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(null),{data:l,isLoading:u}=K({queryKey:[`oidc-providers-all`],queryFn:()=>Z.getOIDCProvidersAll()}),{data:d=[]}=K({queryKey:[`groups`],queryFn:()=>Z.getGroups()}),f=q({mutationFn:e=>Z.createOIDCProvider(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-providers-all`]}),i(!1),n(e(`settings.oidc.created`),`success`)},onError:e=>n(e.message,`error`)}),p=q({mutationFn:({id:e,data:t})=>Z.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=q({mutationFn:e=>Z.deleteOIDCProvider(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-providers-all`]}),c(null),n(e(`settings.oidc.deleted`),`success`)},onError:e=>n(e.message,`error`)}),h=q({mutationFn:e=>Z.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=q({mutationFn:e=>Z.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,G.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,G.jsx)(Rl,{className:`w-6 h-6 animate-spin text-bambu-green`})}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(jd,{id:`card-oidc`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.oidc.title`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:e(`settings.oidc.desc`)})]}),!r&&(0,G.jsxs)(Q,{variant:`primary`,size:`sm`,onClick:()=>i(!0),className:`flex items-center gap-2`,children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),e(`settings.oidc.addProvider`)]})]})}),r&&(0,G.jsx)(Nd,{children:(0,G.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:[(0,G.jsx)(`h4`,{className:`text-white font-medium mb-4`,children:e(`settings.oidc.newProvider`)}),(0,G.jsx)(w8,{initial:FHe,groups:d,onSave:e=>f.mutate(e),onCancel:()=>i(!1),isPending:f.isPending})]})})]}),l&&l.length===0&&!r&&(0,G.jsx)(jd,{id:`card-oidc-empty`,children:(0,G.jsx)(Nd,{children:(0,G.jsxs)(`div`,{className:`text-center py-8 space-y-3`,children:[(0,G.jsx)(Ec,{className:`w-12 h-12 text-bambu-gray mx-auto`}),(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`settings.oidc.empty`)}),(0,G.jsxs)(Q,{variant:`primary`,size:`sm`,onClick:()=>i(!0),className:`inline-flex items-center gap-2`,children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),e(`settings.oidc.addProvider`)]})]})})}),l?.map(t=>(0,G.jsxs)(jd,{children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(IHe,{provider:t}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h4`,{className:`text-white font-medium`,children:t.name}),t.is_enabled?(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-green-700 dark:text-green-400 bg-green-50 dark:bg-green-400/10 px-2 py-0.5 rounded-full`,children:[(0,G.jsx)(us,{className:`w-3 h-3`}),` `,e(`common.enabled`)]}):(0,G.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,G.jsx)(Qu,{className:`w-3 h-3`}),` `,e(`common.disabled`)]}),t.is_env_managed&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-bambu-green`,children:[(0,G.jsx)(Qc,{className:`w-3 h-3`}),` `,e(`settings.environmentManagedLabel`)]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 text-bambu-gray text-xs mt-0.5`,children:[(0,G.jsx)(ec,{className:`w-3 h-3`}),(0,G.jsx)(`span`,{children:t.issuer_url})]})]}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:!t.is_env_managed&&(0,G.jsxs)(G.Fragment,{children:[t.icon_url&&(0,G.jsx)(Q,{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,G.jsx)(Rl,{className:`w-4 h-4 ${h.isPending?`animate-spin`:``}`})}),t.has_icon&&(0,G.jsx)(Q,{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,G.jsx)(Ic,{className:`w-4 h-4`})}),(0,G.jsx)(EU,{checked:t.is_enabled,onChange:()=>_(t),disabled:p.isPending}),(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>o(a===t.id?null:t.id),"data-testid":`edit-provider-${t.id}`,children:(0,G.jsx)(Tl,{className:`w-4 h-4`})}),(0,G.jsx)(Q,{variant:`danger`,size:`sm`,onClick:()=>c(t),"data-testid":`delete-provider-${t.id}`,children:(0,G.jsx)(Au,{className:`w-4 h-4`})})]})})]})}),a===t.id&&(0,G.jsx)(Nd,{children:(0,G.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:(0,G.jsx)(w8,{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,is_autologin:t.is_autologin},onSave:e=>p.mutate({id:t.id,data:e}),onCancel:()=>o(null),isPending:p.isPending})})}),a!==t.id&&(0,G.jsx)(Nd,{children:(0,G.jsxs)(`dl`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-x-6 gap-y-2 text-sm`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.clientId`)}),(0,G.jsx)(`dd`,{className:`text-white font-mono truncate`,children:t.client_id})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.scopes`)}),(0,G.jsx)(`dd`,{className:`text-white`,children:t.scopes})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.autoCreate`)}),(0,G.jsx)(`dd`,{className:t.auto_create_users?`text-green-700 dark:text-green-400`:`text-bambu-gray`,children:t.auto_create_users?e(`common.yes`):e(`common.no`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.autoLink`)}),(0,G.jsx)(`dd`,{className:t.auto_link_existing_accounts?`text-green-700 dark:text-green-400`:`text-bambu-gray`,children:t.auto_link_existing_accounts?e(`common.yes`):e(`common.no`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.emailClaim`)}),(0,G.jsx)(`dd`,{className:`text-white font-mono`,children:t.email_claim})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.requireEmailVerified`)}),(0,G.jsx)(`dd`,{className:t.require_email_verified?`text-green-700 dark:text-green-400`:`text-red-700 dark:text-red-400`,children:t.require_email_verified?e(`common.yes`):e(`common.no`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.defaultGroup`)}),(0,G.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,G.jsx)(Xd,{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 T8=new Map;function E8(e){T8.set(e.anchor,e)}function RHe(){return Array.from(T8.values())}E8({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 zHe(){let{t:e}=U(),{data:t,isLoading:n,isError:r,refetch:i}=K({queryKey:[`encryptionStatus`],queryFn:()=>Z.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,G.jsxs)(jd,{id:`card-mfa-encryption`,"data-testid":`encryption-status-card`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ru,{className:`text-bambu-gray`,size:20}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`settings.encryption.title`)})]})}),(0,G.jsx)(Nd,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,"data-testid":`encryption-loading`,children:[(0,G.jsx)(Y,{className:`animate-spin`,size:16}),(0,G.jsx)(`span`,{children:e(`common.loading`)})]})})]});if(r||!t)return(0,G.jsxs)(jd,{id:`card-mfa-encryption`,"data-testid":`encryption-status-card`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ru,{className:`text-bambu-gray`,size:20}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`settings.encryption.title`)})]})}),(0,G.jsxs)(Nd,{children:[(0,G.jsx)(`div`,{className:`text-red-700 dark:text-red-400`,"data-testid":`encryption-error`,children:e(`common.errorLoading`)}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(),className:`mt-2 text-sm text-blue-700 dark:text-blue-400 underline hover:text-blue-800 dark: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-100 dark:bg-red-500/20 border-red-400 dark:border-red-500/50 text-red-700 dark:text-red-400`,c=(0,G.jsx)(Ts,{className:`text-red-600 dark:text-red-400`,size:20}),l=e(`settings.encryption.decryptionBrokenTitle`),u=e(`settings.encryption.decryptionBrokenError`,{count:o})):t.key_source===`generated`?(s=`bg-amber-50 dark:bg-amber-500/10 border-amber-300 dark:border-amber-500/30 text-amber-700 dark:text-amber-400`,c=(0,G.jsx)(tu,{className:`text-amber-600 dark:text-amber-400`,size:20}),l=e(`settings.encryption.enabledGenerated`),u=e(`settings.encryption.backupHint`)):a>0?(s=`bg-amber-50 dark:bg-amber-500/10 border-amber-300 dark:border-amber-500/30 text-amber-700 dark:text-amber-400`,c=(0,G.jsx)(Nu,{className:`text-amber-600 dark: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-100 dark:bg-green-500/20 border-green-300 dark:border-green-500/30 text-green-700 dark:text-green-400`,c=(0,G.jsx)(tu,{className:`text-green-600 dark: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,G.jsx)(nu,{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,G.jsxs)(jd,{id:`card-mfa-encryption`,"data-testid":`encryption-status-card`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c,(0,G.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`settings.encryption.title`)})]})}),(0,G.jsxs)(Nd,{children:[(0,G.jsxs)(`div`,{className:`p-3 border rounded-lg ${s}`,"data-testid":`encryption-status`,children:[(0,G.jsx)(`p`,{className:`font-medium mb-1`,children:l}),(0,G.jsx)(`p`,{className:`text-sm`,children:u})]}),d&&(0,G.jsx)(`div`,{className:`mt-2 p-3 border rounded-lg bg-amber-50 dark:bg-amber-500/10 border-amber-300 dark:border-amber-500/30 text-amber-700 dark:text-amber-400`,"data-testid":`encryption-legacy-warning`,children:(0,G.jsx)(`p`,{className:`text-sm`,children:e(`settings.encryption.legacyRowsWarning`,{count:a})})}),t.migration_error_count>0&&(0,G.jsx)(`div`,{className:`mt-2 p-3 border rounded-lg bg-amber-50 dark:bg-amber-500/10 border-amber-300 dark:border-amber-500/30 text-amber-700 dark:text-amber-400`,"data-testid":`encryption-migration-warning`,children:(0,G.jsx)(`p`,{className:`text-sm`,children:e(`settings.encryption.migrationErrorWarning`,{count:t.migration_error_count})})}),(0,G.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-4 text-sm`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`settings.encryption.encryptedRowsLabel`)}),(0,G.jsxs)(`p`,{className:`font-medium`,children:[`OIDC: `,t.encrypted_rows.oidc_providers,` · TOTP: `,t.encrypted_rows.user_totp]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`settings.encryption.legacyRowsLabel`)}),(0,G.jsxs)(`p`,{className:`font-medium`,children:[`OIDC: `,t.legacy_plaintext_rows.oidc_providers,` · TOTP: `,t.legacy_plaintext_rows.user_totp]})]})]})]})]})}var BHe={get:`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400 border-blue-300 dark:border-blue-500/30`,post:`bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-400 border-green-300 dark:border-green-500/30`,put:`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400 border-yellow-300 dark:border-yellow-500/30`,patch:`bg-orange-100 dark:bg-orange-500/20 text-orange-700 dark:text-orange-400 border-orange-300 dark:border-orange-500/30`,delete:`bg-red-100 dark:bg-red-500/20 text-red-700 dark:text-red-400 border-red-300 dark:border-red-500/30`};function VHe(e,t){let n=t.replace(`#/`,``).split(`/`),r=e;for(let e of n)r=r[e];return r}function D8(e,t,n=0){if(n>5)return`...`;if(t.$ref)return D8(e,VHe(e,t.$ref),n+1);if(t.allOf){let r={};for(let i of t.allOf){let t=D8(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?[D8(e,t.items,n+1)]:[];case`object`:if(t.properties){let r={};for(let[i,a]of Object.entries(t.properties))r[i]=D8(e,a,n+1);return r}return{};default:return null}}function HHe({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=D8(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,G.jsxs)(`div`,{className:`border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:[(0,G.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,G.jsx)(ds,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}):(0,G.jsx)(fs,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,G.jsx)(`span`,{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${BHe[t]||`bg-gray-500/20 text-gray-400`}`,children:t}),(0,G.jsx)(`code`,{className:`text-sm text-white font-mono flex-1 truncate`,children:e}),n.summary&&(0,G.jsx)(`span`,{className:`text-sm text-bambu-gray truncate max-w-[40%]`,children:n.summary})]}),a&&(0,G.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50`,children:[n.description&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n.description}),x.length>0&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:`Path Parameters`}),(0,G.jsx)(`div`,{className:`space-y-2`,children:x.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`label`,{className:`text-sm text-bambu-gray w-32 flex-shrink-0`,children:[e.name,e.required&&(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400 ml-1`,children:`*`})]}),(0,G.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,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:`Query Parameters`}),(0,G.jsx)(`div`,{className:`space-y-2`,children:S.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`label`,{className:`text-sm text-bambu-gray w-32 flex-shrink-0`,children:[e.name,e.required&&(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400 ml-1`,children:`*`})]}),e.schema?.enum?(0,G.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,G.jsx)(`option`,{value:``,children:`-- Select --`}),e.schema.enum.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]}):(0,G.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,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:`Request Body`}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(Q,{onClick:v,disabled:p,children:[p?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(kl,{className:`w-4 h-4`}),`Execute`]}),_.length>0&&(0,G.jsxs)(`span`,{className:`text-xs text-yellow-700 dark:text-yellow-400 flex items-center gap-1`,children:[(0,G.jsx)(_s,{className:`w-3 h-3`}),`Fill in: `,_.join(`, `)]})]}),d&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h4`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[`Response`,(0,G.jsxs)(`span`,{className:`px-2 py-0.5 text-xs rounded ${d.status>=200&&d.status<300?`bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-400`:d.status>=400?`bg-red-100 dark:bg-red-500/20 text-red-700 dark:text-red-400`:`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400`}`,children:[d.status,` `,d.statusText]}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[d.duration,`ms`]})]}),(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:b,children:h?(0,G.jsx)(ys,{className:`w-3 h-3 text-green-600 dark:text-green-400`}):(0,G.jsx)(zs,{className:`w-3 h-3`})})]}),(0,G.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 UHe({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,G.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})});if(a||!t)return(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-8`,children:(0,G.jsxs)(`div`,{className:`text-center text-red-700 dark:text-red-400`,children:[(0,G.jsx)(_s,{className:`w-12 h-12 mx-auto mb-3 opacity-50`}),(0,G.jsx)(`p`,{children:`Failed to load API schema`}),(0,G.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,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`div`,{className:`flex-1`,children:(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>{c(new Set(f.map(e=>e.tag)))},children:`Expand All`}),(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>{c(new Set)},children:`Collapse All`}),(0,G.jsxs)(`a`,{href:`/docs`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-sm text-bambu-green hover:underline`,children:[(0,G.jsx)(ec,{className:`w-4 h-4`}),`Swagger UI`]})]})]}),(0,G.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[f.reduce((e,t)=>e+t.endpoints.length,0),` endpoints in `,f.length,` categories`]}),(0,G.jsx)(`div`,{className:`space-y-3`,children:f.map(({tag:n,endpoints:r})=>(0,G.jsxs)(jd,{children:[(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s.has(n)?(0,G.jsx)(ds,{className:`w-5 h-5 text-bambu-gray`}):(0,G.jsx)(fs,{className:`w-5 h-5 text-bambu-gray`}),(0,G.jsx)(`h3`,{className:`text-base font-semibold text-white capitalize`,children:n.replace(/-/g,` `)}),(0,G.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,G.jsx)(Nd,{className:`pt-0 space-y-2`,children:r.map(({path:n,method:r,spec:i})=>(0,G.jsx)(HHe,{path:n,method:r,spec:i,schema:t,apiKey:e},`${r}-${n}`))})]},n))})]})}var WHe=[{id:`sidecar`,labelKey:`settings.sliceEngineSidecar`,descriptionKey:`settings.sliceEngineSidecarHint`,available:!0},{id:`browser`,labelKey:`settings.sliceEngineBrowser`,descriptionKey:`settings.sliceEngineBrowserHint`,available:!1}];function O8(){return WHe.filter(e=>e.available)}function GHe(){return O8().length>1}function k8(e){return O8().find(t=>t.id===e)?.id??`sidecar`}var KHe=[`general`,`plugs`,`notifications`,`queue`,`filament`,`network`,`apikeys`,`virtual-printer`,`spoolbuddy`,`failure-detection`,`users`,`backup`];E8({labelKey:`settings.general`,tab:`general`,keywords:`language date time format printer model printers cards`,anchor:`card-general`}),E8({labelKey:`settings.appearance`,tab:`general`,keywords:`theme dark light mode colors`,anchor:`card-appearance`}),E8({labelKey:`settings.archiveSettings`,tab:`general`,keywords:`archive auto save thumbnails captures`,anchor:`card-archive`}),E8({labelKey:`settings.camera`,tab:`general`,keywords:`camera external video stream`,anchor:`card-camera`}),E8({labelKey:`settings.costTracking`,tab:`general`,keywords:`currency filament cost energy kwh price`,anchor:`card-cost`}),E8({labelKey:`settings.fileManager`,tab:`general`,keywords:`file manager archive mode disk warning storage`,anchor:`card-filemanager`}),E8({labelKey:`settings.updates`,tab:`general`,keywords:`updates version firmware beta check`,anchor:`card-updates`}),E8({labelKey:`settings.dataManagement`,tab:`general`,keywords:`data reset clear logs notifications preferences`,anchor:`card-data`}),E8({labelKey:`settings.smartPlugs`,tab:`plugs`,keywords:`smart plug energy power automation tapo kasa tplink shelly`,anchor:`card-plugs`}),E8({labelKey:`settings.providers`,tab:`notifications`,keywords:`telegram discord email notification providers webhook`,anchor:`card-providers`}),E8({labelKey:`settings.messageTemplates`,tab:`notifications`,keywords:`message templates notification text edit`,anchor:`card-templates`}),E8({labelKey:`settings.defaultPrintOptions`,labelFallback:`Default Print Options`,tab:`queue`,keywords:`print bed leveling flow calibration vibration first layer timelapse`,anchor:`card-print-options`}),E8({labelKey:`settings.tempFanPresetsTitle`,labelFallback:`Temperature & Fan Presets`,tab:`queue`,keywords:`temperature fan presets nozzle bed chamber quick buttons popover`,anchor:`card-temp-fan-presets`}),E8({labelKey:`settings.staggeredStart`,labelFallback:`Staggered Start`,tab:`queue`,keywords:`staggered batch delay start queue group`,anchor:`card-staggered`}),E8({labelKey:`settings.plateClear`,labelFallback:`Plate-Clear Confirmation`,tab:`queue`,keywords:`plate clear confirm auto queue`,anchor:`card-plate`}),E8({labelKey:`settings.concurrentUploadsTitle`,labelFallback:`Concurrent Uploads`,tab:`queue`,keywords:`concurrent parallel upload transfer ftp queue slow farm simultaneous`,anchor:`card-concurrent-uploads`}),E8({labelKey:`settings.gcodeInjection`,labelFallback:`G-code Injection`,tab:`queue`,keywords:`gcode injection start end autoprint farmloop swapmod autoclear printflow`,anchor:`card-gcode`}),E8({labelKey:`settings.slicerCard`,labelFallback:`Slicer`,tab:`queue`,keywords:`slicer orcaslicer bambustudio orca bambu api sidecar url docker preferred`,anchor:`card-slicer`}),E8({labelKey:`settings.queueDrying`,tab:`queue`,keywords:`drying presets temperature time humidity ams`,anchor:`card-drying`}),E8({labelKey:`settings.filamentChecks`,tab:`filament`,keywords:`filament check warning runout remaining`,anchor:`card-filamentchecks`}),E8({labelKey:`settings.printModal`,tab:`filament`,keywords:`print modal custom mapping`,anchor:`card-printmodal`}),E8({labelKey:`settings.amsDisplayThresholds`,tab:`filament`,keywords:`ams humidity temperature threshold history retention`,anchor:`card-amsthresholds`}),E8({labelKey:`settings.externalUrl`,tab:`network`,keywords:`external url reverse proxy public notification link`,anchor:`card-externalurl`}),E8({labelKey:`settings.ftpRetry`,tab:`network`,keywords:`ftp retry upload retries backoff`,anchor:`card-ftpretry`}),E8({labelKey:`settings.homeAssistant`,tab:`network`,keywords:`home assistant ha hass mqtt integration`,anchor:`card-ha`}),E8({labelKey:`settings.mqttPublishing`,tab:`network`,keywords:`mqtt publish broker topic`,anchor:`card-mqtt`}),E8({labelKey:`settings.prometheusMetrics`,tab:`network`,keywords:`prometheus metrics grafana monitoring bearer token`,anchor:`card-prometheus`}),E8({labelKey:`settings.createNewApiKey`,tab:`apikeys`,keywords:`api key create permission scope`,anchor:`card-createapi`}),E8({labelKey:`settings.webhookEndpoints`,tab:`apikeys`,keywords:`webhook endpoint post http`,anchor:`card-webhooks`}),E8({labelKey:`settings.apiBrowser`,tab:`apikeys`,keywords:`api browser endpoint documentation test`,anchor:`card-apibrowser`}),E8({labelKey:`cameraTokens.title`,tab:`apikeys`,keywords:`camera token long-lived home assistant frigate kiosk stream`,anchor:`card-camera-tokens`}),E8({labelKey:`settings.tabs.virtualPrinter`,tab:`virtual-printer`,keywords:`virtual printer proxy archive slicer bambustudio orcaslicer ip bind`,anchor:`card-vp`}),E8({labelKey:`settings.tabs.spoolbuddy`,tab:`spoolbuddy`,keywords:`spoolbuddy device scale nfc rfid kiosk unregister`,anchor:`card-spoolbuddy`}),E8({labelKey:`settings.currentUser`,tab:`users`,subTab:`users`,keywords:`current user profile password change`,anchor:`card-currentuser`}),E8({labelKey:`settings.users`,tab:`users`,subTab:`users`,keywords:`users accounts list`,anchor:`card-users`}),E8({labelKey:`settings.groups`,tab:`users`,subTab:`users`,keywords:`groups roles permissions administrators operators viewers`,anchor:`card-groups`}),E8({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`}),E8({labelKey:`settings.email.smtpSettings`,labelFallback:`SMTP Configuration`,tab:`users`,subTab:`email`,keywords:`smtp email send server port password auth starttls ssl`,anchor:`card-smtp`}),E8({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`}),E8({labelKey:`settings.tabs.backup`,tab:`backup`,keywords:`backup github restore download cloud sync profiles archives`,anchor:`card-backup`}),E8({labelKey:`externalLinks.sidebarLayout`,labelFallback:`Sidebar`,tab:`general`,keywords:`sidebar layout links pages hide show external custom navigation url add`,anchor:`card-sidebar-links`}),E8({labelKey:`settings.filamentTracking`,tab:`filament`,keywords:`spoolman filament tracking inventory sync remote integration`,anchor:`card-spoolman`}),E8({labelKey:`settings.catalog.spoolCatalog`,labelFallback:`Spool Catalog`,tab:`filament`,keywords:`spool catalog entries brand material reset import export`,anchor:`card-spool-catalog`}),E8({labelKey:`settings.colorCatalog.title`,labelFallback:`Color Catalog`,tab:`filament`,keywords:`color catalog hex swatch palette sync reset`,anchor:`card-color-catalog`}),E8({labelKey:`settings.tabs.failureDetection`,labelFallback:`Failure Detection`,tab:`failure-detection`,keywords:`failure detection ai ml obico spaghetti detect monitoring`,anchor:`card-fd-ml`}),E8({labelKey:`failureDetection.perPrinterTitle`,labelFallback:`Per-Printer Settings`,tab:`failure-detection`,keywords:`failure detection per printer enable per-printer sensitivity`,anchor:`card-fd-perprinter`}),E8({labelKey:`failureDetection.statusTitle`,labelFallback:`Detection Status`,tab:`failure-detection`,keywords:`failure detection status running connection`,anchor:`card-fd-status`}),E8({labelKey:`failureDetection.historyTitle`,labelFallback:`Detection History`,tab:`failure-detection`,keywords:`failure detection history log events`,anchor:`card-fd-history`}),E8({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`}),E8({labelKey:`settings.email.testConnection`,labelFallback:`Test SMTP Connection`,tab:`users`,subTab:`email`,keywords:`email smtp test connection send check`,anchor:`card-email-test`}),E8({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`}),E8({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`}),E8({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`}),E8({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`}),E8({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`}),E8({labelKey:`backup.githubBackup`,labelFallback:`GitHub Backup`,tab:`backup`,keywords:`github backup cloud remote sync profiles token`,anchor:`card-backup-github`}),E8({labelKey:`backup.history`,labelFallback:`Backup History`,tab:`backup`,keywords:`backup history log runs github commits`,anchor:`card-backup-history`}),E8({labelKey:`backup.localBackup`,labelFallback:`Local Backup`,tab:`backup`,keywords:`local backup download zip manual export`,anchor:`card-backup-local`}),E8({labelKey:`backup.scheduledBackup`,labelFallback:`Scheduled Backups`,tab:`backup`,keywords:`scheduled backup automatic hourly daily weekly retention local path`,anchor:`card-backup-scheduled`});var A8=20,qHe={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`},j8=[`bg-blue-500`,`bg-green-500`,`bg-yellow-500`,`bg-red-500`,`bg-orange-500`,`bg-teal-500`,`bg-cyan-500`,`bg-purple-500`],M8=(e,t)=>qHe[e]||j8[t%j8.length];function JHe(){let e=so(),t=or(),[n,r]=Ri(),{t:i,i18n:a}=U(),{showToast:o}=zd(),{authEnabled:s,user:c,isAdmin:l,refreshAuth:u,hasPermission:d}=Td(),{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,progressInTitle:O,setProgressInTitle:k}=Od(),[A,j]=(0,y.useState)(null),[M,N]=(0,y.useState)({}),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(null),[R,z]=(0,y.useState)(!1),[B,V]=(0,y.useState)(null),[ee,te]=(0,y.useState)(!1),[ne,re]=(0,y.useState)(null),[ie,ae]=(0,y.useState)(null),[oe,se]=(0,y.useState)(``),[H,ce]=(0,y.useState)(``),[le,ue]=(0,y.useState)(!1),[de,fe]=(0,y.useState)(!1),[pe,me]=(0,y.useState)(!1),[he,ge]=(0,y.useState)(tm()),_e=n.get(`tab`),ve=_e===`email`,[ye,be]=(0,y.useState)(ve?`users`:_e&&KHe.includes(_e)?_e:`general`),[xe,Se]=(0,y.useState)(ve?`email`:`users`),[Ce,we]=(0,y.useState)(_e===`queue`&&n.get(`sub`)===`pipelines`?`pipelines`:`dispatch`),Te=e=>{be(e),e===`users`&&Se(`users`),e===`queue`&&(we(`dispatch`),n.delete(`sub`)),e===`general`?n.delete(`tab`):n.set(`tab`,e),r(n,{replace:!0})},Ee=e=>{we(e),e===`pipelines`?n.set(`sub`,`pipelines`):n.delete(`sub`),r(n,{replace:!0})},[De,Oe]=(0,y.useState)(!1),[ke,Ae]=(0,y.useState)(``),[je,Me]=(0,y.useState)({can_queue:!0,can_control_printer:!1,can_read_status:!0,can_manage_library:!0,can_manage_inventory:!0,can_manage_maintenance:!0,can_manage_archives:!0,can_manage_projects:!0,can_access_cloud:!1,can_update_energy_cost:!1}),[Ne,Pe]=(0,y.useState)(null),[Fe,Ie]=(0,y.useState)(!1),[Le,Re]=(0,y.useState)(null),[ze,Be]=(0,y.useState)(``),[Ve,He]=(0,y.useState)(!1),[Ue,We]=(0,y.useState)(!1),[Ge,Ke]=(0,y.useState)(null),[qe,Je]=(0,y.useState)(!1),[Ye,Xe]=(0,y.useState)(!1),[Ze,Qe]=(0,y.useState)(!1),[$e,et]=(0,y.useState)({currentPassword:``,newPassword:``,confirmPassword:``}),[tt,nt]=(0,y.useState)(!1),[rt,it]=(0,y.useState)(!1),[at,ot]=(0,y.useState)(!1),[st,ct]=(0,y.useState)(`local`),[lt,ut]=(0,y.useState)(!1),[dt,ft]=(0,y.useState)(null),[pt,mt]=(0,y.useState)(null),[ht,gt]=(0,y.useState)(null),[_t,vt]=(0,y.useState)(!1),[yt,bt]=(0,y.useState)({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),[xt,St]=(0,y.useState)(null),[Ct,wt]=(0,y.useState)(null),[Tt,Et]=(0,y.useState)(!1),[Dt,Ot]=(0,y.useState)({}),[At,jt]=(0,y.useState)({}),Mt=e=>{ge(e),bee(e),o(i(`settings.toast.settingsSaved`),`success`)},{data:Nt,isLoading:Pt}=K({queryKey:[`settings`],queryFn:Z.getSettings}),{data:Ft,isLoading:It,isFetching:Lt}=K({queryKey:[`storage-usage`],queryFn:()=>Z.getStorageUsage(),enabled:ye===`general`,staleTime:1/0,refetchInterval:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),Rt=async()=>{it(!0);try{let t=await Z.getStorageUsage({refresh:!0});e.setQueryData([`storage-usage`],t)}catch(e){o(e instanceof Error?e.message:`Failed to refresh storage usage`,`error`)}finally{it(!1)}},{data:zt,isLoading:Bt}=K({queryKey:[`smart-plugs`],queryFn:Z.getSmartPlugs}),{data:Vt,isLoading:Ht}=K({queryKey:[`smart-plugs-energy`,zt?.map(e=>e.id)],queryFn:async()=>{if(!zt||zt.length===0)return null;let e=await Promise.all(zt.filter(e=>e.enabled).map(async e=>{try{return{plug:e,status:await Z.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)&&(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:zt.filter(e=>e.enabled).length}},enabled:ye===`plugs`&&!!zt&&zt.length>0,refetchInterval:ye===`plugs`?1e4:!1}),{data:Ut,isLoading:Wt}=K({queryKey:[`notification-providers`],queryFn:Z.getNotificationProviders}),{data:Gt,isLoading:Kt}=K({queryKey:[`api-keys`],queryFn:Z.getAPIKeys}),qt=q({mutationFn:e=>Z.createAPIKey(e),onSuccess:t=>{Pe(t.key||null),Oe(!1),Ae(``),e.invalidateQueries({queryKey:[`api-keys`]}),o(i(`settings.toast.apiKeyCreated`))},onError:e=>{o(`Failed to create API key: ${e.message}`,`error`)}}),Jt=q({mutationFn:e=>Z.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:Yt}=K({queryKey:[`printers`],queryFn:Z.getPrinters}),{data:Xt}=K({queryKey:[`haSensors`],queryFn:()=>Z.getHASensors(),enabled:ye===`plugs`}),Zt=Tf(Yt?.length??0),{data:Qt,isLoading:$t}=K({queryKey:[`notification-templates`],queryFn:Z.getNotificationTemplates}),{data:en}=K({queryKey:[`virtual-printer-settings`],queryFn:hd.getSettings,refetchInterval:1e4}),tn=en?.status?.running??!1,{data:W}=K({queryKey:[`spoolbuddy-devices`],queryFn:()=>bd.getDevices(),refetchInterval:15e3}),nn=W?.length??0,rn=W?.some(e=>e.online)??!1,{data:an}=K({queryKey:[`obico-status`],queryFn:Z.getObicoStatus,refetchInterval:15e3}),on=!!(an?.is_running&&an?.enabled),{data:sn}=K({queryKey:[`ffmpeg-status`],queryFn:Z.checkFfmpeg}),{data:cn}=K({queryKey:[`version`],queryFn:Z.getVersion}),ln=!s||d(`library:purge`),{data:un}=K({queryKey:[`library-trash-settings`],queryFn:()=>Z.getLibraryTrashSettings(),enabled:ln}),dn=q({mutationFn:e=>Z.updateLibraryTrashSettings(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`library-trash-settings`]}),o(i(`settings.toast.settingsSaved`),`success`)},onError:e=>o(e.message||i(`libraryAutoPurge.saveFailed`),`error`)}),fn=e=>{un&&dn.mutate({retention_days:un.retention_days,auto_purge_enabled:un.auto_purge_enabled,auto_purge_days:un.auto_purge_days,auto_purge_include_never_printed:un.auto_purge_include_never_printed,...e})},pn=!s||d(`archives:purge`),{data:mn}=K({queryKey:[`archive-purge-settings`],queryFn:()=>Z.getArchivePurgeSettings(),enabled:pn}),hn=q({mutationFn:e=>Z.updateArchivePurgeSettings(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`archive-purge-settings`]}),o(i(`settings.toast.settingsSaved`),`success`)},onError:e=>o(e.message||i(`archiveAutoPurge.saveFailed`),`error`)}),gn=e=>{mn&&hn.mutate({enabled:mn.enabled,days:mn.days,purge_stats:mn.purge_stats,...e})},{data:_n,refetch:vn,isRefetching:yn}=K({queryKey:[`updateCheck`],queryFn:Z.checkForUpdates,enabled:Nt?.check_updates!==!1,staleTime:300*1e3}),{data:bn,refetch:xn}=K({queryKey:[`updateStatus`],queryFn:Z.getUpdateStatus,refetchInterval:e=>{let t=e.state.data;return t?.status===`downloading`||t?.status===`installing`?1e3:!1}}),{data:Sn}=K({queryKey:[`mqtt-status`],queryFn:Z.getMQTTStatus,refetchInterval:ye===`network`?5e3:!1}),{data:Cn}=K({queryKey:[`github-backup-status`],queryFn:Z.getGitHubBackupStatus}),{data:wn}=K({queryKey:[`cloud-status`],queryFn:Z.getCloudStatus}),{data:Tn={advanced_auth_enabled:!1,smtp_configured:!1,local_login_enabled:!0,autologin_provider_id:null}}=K({queryKey:[`advancedAuthStatus`],queryFn:()=>Z.getAdvancedAuthStatus()}),{data:En}=K({queryKey:[`ldapStatus`],queryFn:()=>Z.getLDAPStatus()}),{data:Dn}=K({queryKey:[`twoFAStatus`],queryFn:()=>Z.get2FAStatus()}),{data:On=[]}=K({queryKey:[`oidcProvidersAll`],queryFn:()=>Z.getOIDCProvidersAll(),enabled:l}),{data:kn=[],isLoading:An}=K({queryKey:[`users`],queryFn:()=>Z.getUsers(),enabled:s&&d(`users:read`)}),{data:jn=[],isLoading:Mn}=K({queryKey:[`groups`],queryFn:()=>Z.getGroups(),enabled:s&&d(`groups:read`)}),Nn=q({mutationFn:e=>Z.createUser(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`users`]}),e.invalidateQueries({queryKey:[`groups`]}),ot(!1),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`settings.toast.userCreated`))},onError:e=>{o(e.message,`error`)}}),Pn=q({mutationFn:({id:e,data:t})=>Z.updateUser(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`users`]}),e.invalidateQueries({queryKey:[`groups`]}),ut(!1),ft(null),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`settings.toast.userUpdated`))},onError:e=>{o(e.message,`error`)}}),Fn=q({mutationFn:({id:e,deleteItems:t})=>Z.deleteUser(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`users`]}),o(i(`settings.toast.userDeleted`)),mt(null),gt(null)},onError:e=>{o(e.message,`error`)}}),In=q({mutationFn:e=>Z.resetUserPassword({user_id:e}),onSuccess:e=>{o(e.message,`success`)},onError:e=>{o(e.message,`error`)}}),Ln=async e=>{mt(e),vt(!0);try{gt(await Z.getUserItemsCount(e))}catch{gt({archives:0,queue_items:0,library_files:0})}finally{vt(!1)}},Rn=q({mutationFn:e=>Z.deleteGroup(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`groups`]}),o(i(`settings.toast.groupDeleted`))},onError:e=>{o(e.message,`error`)}}),zn=()=>{let e=Tn?.advanced_auth_enabled||!1;if(!yt.username){o(i(`settings.toast.fillRequiredFields`),`error`);return}if(e&&!yt.email){o(`Email is required when advanced authentication is enabled`,`error`);return}if(!e){if(!yt.password){o(i(`settings.toast.fillRequiredFields`),`error`);return}if(yt.password!==yt.confirmPassword){o(i(`settings.toast.passwordsDoNotMatch`),`error`);return}let e=T6(yt.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}}Nn.mutate({username:yt.username,password:e?void 0:yt.password,email:yt.email||void 0,role:yt.role,group_ids:yt.group_ids.length>0?yt.group_ids:void 0})},Bn=e=>{if(yt.password){if(yt.password!==yt.confirmPassword){o(i(`settings.toast.passwordsDoNotMatch`),`error`);return}let e=T6(yt.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:yt.username||void 0,password:yt.password||void 0,email:yt.email||void 0,role:yt.role,group_ids:yt.group_ids};t.password||delete t.password,Pn.mutate({id:e,data:t})},Vn=e=>{ft(e.id),bt({username:e.username,password:``,email:e.email||``,confirmPassword:``,role:e.role,group_ids:e.groups?.map(e=>e.id)||[]}),ut(!0)},Hn=e=>{bt(t=>({...t,group_ids:t.group_ids.includes(e)?t.group_ids.filter(t=>t!==e):[...t.group_ids,e]}))},Un=q({mutationFn:Z.applyUpdate,onSuccess:e=>{e.is_ha_addon||e.is_docker||e.is_windows_installer?o(e.message,`error`):xn()}}),[Wn,Gn]=(0,y.useState)(null),Kn=q({mutationFn:Z.testAllNotificationProviders,onSuccess:t=>{Gn(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`)}}),qn=q({mutationFn:async e=>{if(!zt)return{success:0,failed:0};let t=zt.filter(e=>e.enabled),n=await Promise.all(t.map(async t=>{try{return await Z.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`)}}),Jn=(0,y.useRef)(null),Yn=(0,y.useRef)(null),Xn=(0,y.useRef)(!1),Zn=(0,y.useRef)(!0),Qn=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(Nt&&!A){let e={...Nt,external_url:Nt.external_url||window.location.origin};Qn.current=Nt,j(e),setTimeout(()=>{Zn.current=!1},100)}},[Nt,A]),(0,y.useEffect)(()=>{let e=Qn.current;if(!Nt||!A||!e||Nt===e)return;let t={};for(let n of Object.keys(Nt))Nt[n]!==e[n]&&A[n]===e[n]&&(t[n]=Nt[n]);Qn.current=Nt,Object.keys(t).length>0&&j(e=>e&&{...e,...t})},[Nt,A]);let $n=q({mutationFn:Z.updateSettings,onSuccess:t=>{Qn.current=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:()=>{Xn.current=!1}}),er=q({mutationFn:({id:e,data:t})=>Z.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)(()=>{let e=Qn.current;if(!(Zn.current||!A||!Nt||!e)&&!(s&&!d(`settings:update`))&&(e.auto_archive!==A.auto_archive||e.save_thumbnails!==A.save_thumbnails||e.capture_finish_photo!==A.capture_finish_photo||(e.finish_photo_restore_plate??!0)!==(A.finish_photo_restore_plate??!0)||e.default_filament_cost!==A.default_filament_cost||e.currency!==A.currency||e.energy_cost_per_kwh!==A.energy_cost_per_kwh||e.energy_tracking_mode!==A.energy_tracking_mode||e.check_updates!==A.check_updates||(e.check_printer_firmware??!0)!==(A.check_printer_firmware??!0)||(e.include_beta_updates??!1)!==(A.include_beta_updates??!1)||(e.local_login_enabled??!0)!==(A.local_login_enabled??!0)||e.notification_language!==A.notification_language||(e.bed_cooled_threshold??35)!==(A.bed_cooled_threshold??35)||e.ams_humidity_good!==A.ams_humidity_good||e.ams_humidity_fair!==A.ams_humidity_fair||e.ams_temp_good!==A.ams_temp_good||e.ams_temp_fair!==A.ams_temp_fair||e.ams_history_retention_days!==A.ams_history_retention_days||e.disable_filament_warnings!==A.disable_filament_warnings||e.prefer_lowest_filament!==A.prefer_lowest_filament||(e.queue_drying_enabled??!1)!==(A.queue_drying_enabled??!1)||(e.queue_drying_block??!1)!==(A.queue_drying_block??!1)||(e.ambient_drying_enabled??!1)!==(A.ambient_drying_enabled??!1)||(e.print_drying_enabled??!1)!==(A.print_drying_enabled??!1)||(e.drying_presets??``)!==(A.drying_presets??``)||(e.ams_humidity_thresholds??``)!==(A.ams_humidity_thresholds??``)||e.per_printer_mapping_expanded!==A.per_printer_mapping_expanded||e.date_format!==A.date_format||e.time_format!==A.time_format||e.default_printer_id!==A.default_printer_id||e.ftp_retry_enabled!==A.ftp_retry_enabled||e.ftp_retry_count!==A.ftp_retry_count||e.ftp_retry_delay!==A.ftp_retry_delay||e.ftp_timeout!==A.ftp_timeout||e.mqtt_enabled!==A.mqtt_enabled||e.mqtt_broker!==A.mqtt_broker||e.mqtt_port!==A.mqtt_port||e.mqtt_username!==A.mqtt_username||e.mqtt_password!==A.mqtt_password||e.mqtt_topic_prefix!==A.mqtt_topic_prefix||e.mqtt_use_tls!==A.mqtt_use_tls||e.external_url!==A.external_url||e.ha_enabled!==A.ha_enabled||e.ha_url!==A.ha_url||e.ha_token!==A.ha_token||(e.library_archive_mode??`ask`)!==(A.library_archive_mode??`ask`)||Number(e.library_disk_warning_gb??5)!==Number(A.library_disk_warning_gb??5)||(e.preferred_slicer??`bambu_studio`)!==(A.preferred_slicer??`bambu_studio`)||k8(e.slice_engine)!==k8(A.slice_engine)||(e.open_in_slicer??null)!==(A.open_in_slicer??null)||(e.use_slicer_api??!1)!==(A.use_slicer_api??!1)||(e.orcaslicer_api_url??``)!==(A.orcaslicer_api_url??``)||(e.slicer_stall_timeout_minutes??15)!==(A.slicer_stall_timeout_minutes??15)||(e.bambu_studio_api_url??``)!==(A.bambu_studio_api_url??``)||e.prometheus_enabled!==A.prometheus_enabled||e.prometheus_token!==A.prometheus_token||(e.user_notifications_enabled??!0)!==(A.user_notifications_enabled??!0)||(e.default_bed_levelling??`auto`)!==(A.default_bed_levelling??`auto`)||(e.default_flow_cali??`auto`)!==(A.default_flow_cali??`auto`)||(e.default_vibration_cali??!0)!==(A.default_vibration_cali??!0)||(e.default_layer_inspect??!1)!==(A.default_layer_inspect??!1)||(e.default_timelapse??!1)!==(A.default_timelapse??!1)||(e.default_nozzle_offset_cali??`auto`)!==(A.default_nozzle_offset_cali??`auto`)||(e.stagger_group_size??2)!==(A.stagger_group_size??2)||(e.stagger_interval_minutes??5)!==(A.stagger_interval_minutes??5)||(e.require_plate_clear??!1)!==(A.require_plate_clear??!1)||(e.queue_max_concurrent_uploads??4)!==(A.queue_max_concurrent_uploads??4)||(e.preheat_enabled??!1)!==(A.preheat_enabled??!1)||(e.preheat_filament_targets??``)!==(A.preheat_filament_targets??``)||(e.preheat_max_wait_seconds??900)!==(A.preheat_max_wait_seconds??900)||(e.preheat_soak_seconds??300)!==(A.preheat_soak_seconds??300)||(e.queue_keep_bed_warm??!1)!==(A.queue_keep_bed_warm??!1)||(e.queue_keep_warm_bed_temp??90)!==(A.queue_keep_warm_bed_temp??90)||(e.queue_keep_warm_max_minutes??120)!==(A.queue_keep_warm_max_minutes??120)||(e.nozzle_temp_presets??``)!==(A.nozzle_temp_presets??``)||(e.bed_temp_presets??``)!==(A.bed_temp_presets??``)||(e.chamber_temp_presets??``)!==(A.chamber_temp_presets??``)||(e.fan_speed_presets??``)!==(A.fan_speed_presets??``)||(e.session_max_hours??24)!==(A.session_max_hours??24)||(e.billing_enabled??!1)!==(A.billing_enabled??!1)||(e.printer_kill_switch_enabled??!1)!==(A.printer_kill_switch_enabled??!1)||(e.finance_budget_reset_day??1)!==(A.finance_budget_reset_day??1)||(e.finance_budget_reset_timezone??`UTC`)!==(A.finance_budget_reset_timezone??`UTC`))&&!Xn.current)return Jn.current&&clearTimeout(Jn.current),Jn.current=setTimeout(()=>{if(Xn.current)return;Xn.current=!0;let e={auto_archive:A.auto_archive,save_thumbnails:A.save_thumbnails,capture_finish_photo:A.capture_finish_photo,finish_photo_restore_plate:A.finish_photo_restore_plate??!0,default_filament_cost:A.default_filament_cost,currency:A.currency,energy_cost_per_kwh:A.energy_cost_per_kwh,energy_tracking_mode:A.energy_tracking_mode,check_updates:A.check_updates,check_printer_firmware:A.check_printer_firmware,include_beta_updates:A.include_beta_updates,local_login_enabled:A.local_login_enabled,notification_language:A.notification_language,bed_cooled_threshold:A.bed_cooled_threshold,ams_humidity_good:A.ams_humidity_good,ams_humidity_fair:A.ams_humidity_fair,ams_temp_good:A.ams_temp_good,ams_temp_fair:A.ams_temp_fair,ams_history_retention_days:A.ams_history_retention_days,disable_filament_warnings:A.disable_filament_warnings,prefer_lowest_filament:A.prefer_lowest_filament,queue_drying_enabled:A.queue_drying_enabled,queue_drying_block:A.queue_drying_block,ambient_drying_enabled:A.ambient_drying_enabled,print_drying_enabled:A.print_drying_enabled,drying_presets:A.drying_presets,ams_humidity_thresholds:A.ams_humidity_thresholds,per_printer_mapping_expanded:A.per_printer_mapping_expanded,date_format:A.date_format,time_format:A.time_format,default_printer_id:A.default_printer_id,ftp_retry_enabled:A.ftp_retry_enabled,ftp_retry_count:A.ftp_retry_count,ftp_retry_delay:A.ftp_retry_delay,ftp_timeout:A.ftp_timeout,mqtt_enabled:A.mqtt_enabled,mqtt_broker:A.mqtt_broker,mqtt_port:A.mqtt_port,mqtt_username:A.mqtt_username,mqtt_password:A.mqtt_password,mqtt_topic_prefix:A.mqtt_topic_prefix,mqtt_use_tls:A.mqtt_use_tls,external_url:A.external_url,ha_enabled:A.ha_enabled,ha_url:A.ha_url,ha_token:A.ha_token,library_archive_mode:A.library_archive_mode,library_disk_warning_gb:A.library_disk_warning_gb,preferred_slicer:A.preferred_slicer,slice_engine:A.slice_engine,open_in_slicer:A.open_in_slicer,use_slicer_api:A.use_slicer_api,orcaslicer_api_url:A.orcaslicer_api_url,slicer_stall_timeout_minutes:A.slicer_stall_timeout_minutes,bambu_studio_api_url:A.bambu_studio_api_url,prometheus_enabled:A.prometheus_enabled,prometheus_token:A.prometheus_token,user_notifications_enabled:A.user_notifications_enabled,default_bed_levelling:A.default_bed_levelling,default_flow_cali:A.default_flow_cali,default_vibration_cali:A.default_vibration_cali,default_layer_inspect:A.default_layer_inspect,default_timelapse:A.default_timelapse,default_nozzle_offset_cali:A.default_nozzle_offset_cali,stagger_group_size:A.stagger_group_size,stagger_interval_minutes:A.stagger_interval_minutes,require_plate_clear:A.require_plate_clear,queue_max_concurrent_uploads:A.queue_max_concurrent_uploads,preheat_enabled:A.preheat_enabled,preheat_filament_targets:A.preheat_filament_targets,preheat_max_wait_seconds:A.preheat_max_wait_seconds,preheat_soak_seconds:A.preheat_soak_seconds,queue_keep_bed_warm:A.queue_keep_bed_warm,queue_keep_warm_bed_temp:A.queue_keep_warm_bed_temp,queue_keep_warm_max_minutes:A.queue_keep_warm_max_minutes,nozzle_temp_presets:A.nozzle_temp_presets,bed_temp_presets:A.bed_temp_presets,chamber_temp_presets:A.chamber_temp_presets,fan_speed_presets:A.fan_speed_presets,session_max_hours:A.session_max_hours,billing_enabled:A.billing_enabled,printer_kill_switch_enabled:A.printer_kill_switch_enabled,finance_budget_reset_day:A.finance_budget_reset_day,finance_budget_reset_timezone:A.finance_budget_reset_timezone};$n.mutate(e)},500),()=>{Jn.current&&clearTimeout(Jn.current)}},[A,Nt,$n,s,d,o,i]);let tr=(0,y.useCallback)((e,t)=>{if(s&&!d(`settings:update`)){o(i(`settings.toast.noPermissionUpdate`),`error`);return}j(n=>n?{...n,[e]:t}:null)},[s,d,o,i]),nr=async(e,t,n)=>{if(!t){o(i(`settings.toast.enterCameraUrl`),`error`);return}jt(t=>({...t,[e]:!0})),Ot(t=>({...t,[e]:null}));try{let r=await Z.testExternalCamera(e,t,n);Ot(t=>({...t,[e]:r})),r.success?o(r.coalesced?i(`settings.toast.cameraConnectedCoalesced`,{resolution:r.resolution||``}):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`);Ot(t=>({...t,[e]:{success:!1,error:n}})),o(n,`error`)}finally{jt(t=>({...t,[e]:!1}))}},[rr,ir]=(0,y.useState)({}),ar=(0,y.useRef)({}),sr=(0,y.useRef)(new Set),[cr,lr]=(0,y.useState)({}),ur=(0,y.useRef)({}),dr=(0,y.useRef)(new Set);(0,y.useEffect)(()=>{if(Yt){let e={},t={};Yt.forEach(n=>{n.external_camera_url&&!sr.current.has(n.id)&&(e[n.id]=n.external_camera_url,sr.current.add(n.id)),n.external_camera_snapshot_url&&!dr.current.has(n.id)&&(t[n.id]=n.external_camera_snapshot_url,dr.current.add(n.id))}),Object.keys(e).length>0&&ir(t=>({...t,...e})),Object.keys(t).length>0&&lr(e=>({...e,...t}))}},[Yt]);let fr=(e,t)=>{ir(n=>({...n,[e]:t})),ar.current[e]&&clearTimeout(ar.current[e]),ar.current[e]=setTimeout(()=>{er.mutate({id:e,data:{external_camera_url:t||null}})},800)},pr=(e,t)=>{lr(n=>({...n,[e]:t})),ur.current[e]&&clearTimeout(ur.current[e]),ur.current[e]=setTimeout(()=>{er.mutate({id:e,data:{external_camera_snapshot_url:t||null}})},800)},mr=(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),er.mutate({id:e,data:n})};if(Pt||!A)return(0,G.jsx)(`div`,{className:`p-4 md:p-8 flex justify-center`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})});let hr=RHe().map(e=>({...e,label:i(e.labelKey,e.labelFallback??e.labelKey)})),gr=H.trim().toLowerCase(),_r=gr?hr.filter(e=>e.label.toLowerCase().includes(gr)||e.keywords.toLowerCase().includes(gr)).slice(0,8):[],vr=e=>{Te(e.tab),e.subTab&&Se(e.subTab),ce(``),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)},yr=(A?.docker_compose_dir??``).trim()||(_n?.compose_dir_detected??``),br=yr?`cd ${/\s/.test(yr)?`"${yr}"`:yr} && docker compose pull && docker compose up -d`:`docker compose pull && docker compose up -d`;return(0,G.jsx)(Ad,{density:`dense`,children:(0,G.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,G.jsxs)(`div`,{className:`mb-4 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,G.jsx)($l,{className:`w-7 h-7 text-bambu-green`}),i(`settings.title`)]}),(0,G.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:i(`settings.configureBambuddy`)})]}),(0,G.jsxs)(`div`,{className:`relative sm:w-72`,children:[(0,G.jsx)(Jl,{className:`w-4 h-4 text-bambu-gray absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none`}),(0,G.jsx)(`input`,{type:`text`,value:H,onChange:e=>ce(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`}),H&&(0,G.jsx)(`button`,{onClick:()=>ce(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-bambu-gray hover:text-white`,"aria-label":`Clear`,children:(0,G.jsx)(Qu,{className:`w-3.5 h-3.5`})}),_r.length>0&&(0,G.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:_r.map(e=>(0,G.jsxs)(`button`,{onClick:()=>vr(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,G.jsx)(`p`,{className:`text-sm text-white`,children:e.label}),(0,G.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))}),gr&&_r.length===0&&(0,G.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,G.jsx)(`p`,{className:`text-xs text-bambu-gray italic`,children:i(`settings.noSearchResults`,`No matching settings.`)})})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,G.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,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`general`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)($l,{className:`w-4 h-4`}),i(`settings.tabs.general`)]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`plugs`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Al,{className:`w-4 h-4`}),i(`settings.tabs.smartPlugs`),zt&&zt.length>0&&(0,G.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:zt.length})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`notifications`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Go,{className:`w-4 h-4`}),i(`settings.tabs.notifications`),Ut&&Ut.length>0&&(0,G.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:Ut.length})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`queue`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Jc,{className:`w-4 h-4`}),i(`settings.tabs.queue`,`Workflow`)]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`filament`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Hs,{className:`w-4 h-4`}),i(`settings.tabs.filament`)]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`network`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Ju,{className:`w-4 h-4`}),i(`settings.tabs.network`),(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${Sn?.enabled?`bg-green-400`:`bg-gray-500`}`})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`apikeys`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Vc,{className:`w-4 h-4`}),i(`settings.tabs.apiKeys`),Gt&&Gt.length>0&&(0,G.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:Gt.length})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`virtual-printer`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Pl,{className:`w-4 h-4`}),i(`settings.tabs.virtualPrinter`),(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${tn?`bg-green-400`:`bg-gray-500`}`})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`spoolbuddy`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Wl,{className:`w-4 h-4`}),i(`settings.tabs.spoolbuddy`),nn>0&&(0,G.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:nn}),(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${rn?`bg-green-400`:`bg-gray-500`}`})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`failure-detection`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Gl,{className:`w-4 h-4`}),i(`settings.tabs.failureDetection`),(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${on?`bg-green-400`:`bg-gray-500`}`})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`users`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(zu,{className:`w-4 h-4`}),i(`settings.tabs.users`),s&&(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green-400`})]}),(0,G.jsxs)(`button`,{onClick:()=>Te(`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 ${ye===`backup`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Us,{className:`w-4 h-4`}),i(`settings.tabs.backup`),(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${wn?.is_authenticated&&Cn?.configured&&Cn?.enabled||Nt?.local_backup_enabled?`bg-green-400`:`bg-gray-500`}`})]})]}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[ye===`general`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`a`,{href:Ef(Zt,`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,G.jsxs)(`div`,{className:`flex flex-col md:flex-row items-start md:items-center gap-4 p-4 md:p-5`,children:[(0,G.jsx)(`div`,{className:`p-3 rounded-lg bg-bambu-green/20 text-bambu-green flex-shrink-0`,children:Zt===`business`?(0,G.jsx)(Xo,{className:`w-6 h-6`}):(0,G.jsx)(Nc,{className:`w-6 h-6`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-base font-semibold text-white`,children:Zt===`business`?i(`sponsors.businessTitle`,`Bambuddy for business`):i(`sponsors.sectionTitle`,`Independent & community-funded`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-0.5`,children:Zt===`business`?i(`sponsors.businessTagline`,`You're running {{count}} printers. Priority support, commercial licensing and invoicing are available for teams and print farms.`,{count:Yt?.length??0}):i(`sponsors.tagline`,`Bambuddy is free and stays that way because people choose to support it. No VC, no cloud lock-in.`)})]}),(0,G.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:[Zt===`business`?i(`sponsors.businessCta`,`Bambuddy for business`):i(`sponsors.viewSupporters`,`View supporters`),(0,G.jsx)(ec,{className:`w-4 h-4`})]})]})}),(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,G.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-xl`,children:[(0,G.jsxs)(jd,{id:`card-general`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.general`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,G.jsx)(Ec,{className:`w-4 h-4 inline mr-1`}),i(`settings.language`)]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.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),$n.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:kt.map(e=>(0,G.jsxs)(`option`,{value:e.code,children:[e.nativeName,` (`,e.name,`)`]},e.code))}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.languageDescription`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.defaultView`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`select`,{value:he,onChange:e=>Mt(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:em.map(e=>(0,G.jsx)(`option`,{value:e.to,children:i(e.labelKey)},e.id))}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.defaultViewDescription`)})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.dateFormat`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`select`,{value:A.date_format||`system`,onChange:e=>tr(`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,G.jsx)(`option`,{value:`system`,children:i(`settings.systemDefault`)}),(0,G.jsx)(`option`,{value:`us`,children:i(`settings.dateFormatUs`)}),(0,G.jsx)(`option`,{value:`eu`,children:i(`settings.dateFormatEu`)}),(0,G.jsx)(`option`,{value:`iso`,children:i(`settings.dateFormatIso`)})]}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.timeFormat`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`select`,{value:A.time_format||`system`,onChange:e=>tr(`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,G.jsx)(`option`,{value:`system`,children:i(`settings.systemDefault`)}),(0,G.jsx)(`option`,{value:`12h`,children:i(`settings.timeFormat12`)}),(0,G.jsx)(`option`,{value:`24h`,children:i(`settings.timeFormat24`)})]}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.defaultPrinter`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`select`,{value:A.default_printer_id??``,onChange:e=>tr(`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,G.jsx)(`option`,{value:``,children:i(`settings.noDefaultPrinter`)}),Yt?.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.defaultPrinterDescription`)})]})]})]}),(0,G.jsxs)(jd,{id:`card-appearance`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(bl,{className:`w-5 h-5`}),i(`settings.appearance`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,G.jsxs)(`label`,{className:`text-sm text-bambu-gray`,children:[i(`settings.theme`),`:`]}),(0,G.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,G.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,G.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,G.jsxs)(`h3`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[i(`settings.darkMode`),p===`dark`&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-green`,children:i(`settings.active`)})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.background`)}),(0,G.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,G.jsx)(`option`,{value:`neutral`,children:i(`settings.bgNeutral`)}),(0,G.jsx)(`option`,{value:`warm`,children:i(`settings.bgWarm`)}),(0,G.jsx)(`option`,{value:`cool`,children:i(`settings.bgCool`)}),(0,G.jsx)(`option`,{value:`oled`,children:i(`settings.bgOled`)}),(0,G.jsx)(`option`,{value:`slate`,children:i(`settings.bgSlate`)}),(0,G.jsx)(`option`,{value:`forest`,children:i(`settings.bgForest`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.accent`)}),(0,G.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,G.jsx)(`option`,{value:`green`,children:i(`settings.accentGreen`)}),(0,G.jsx)(`option`,{value:`teal`,children:i(`settings.accentTeal`)}),(0,G.jsx)(`option`,{value:`blue`,children:i(`settings.accentBlue`)}),(0,G.jsx)(`option`,{value:`orange`,children:i(`settings.accentOrange`)}),(0,G.jsx)(`option`,{value:`purple`,children:i(`settings.accentPurple`)}),(0,G.jsx)(`option`,{value:`red`,children:i(`settings.accentRed`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.style`)}),(0,G.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,G.jsx)(`option`,{value:`classic`,children:i(`settings.styleClassic`)}),(0,G.jsx)(`option`,{value:`glow`,children:i(`settings.styleGlow`)}),(0,G.jsx)(`option`,{value:`vibrant`,children:i(`settings.styleVibrant`)})]})]})]})]}),(0,G.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,G.jsxs)(`h3`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[i(`settings.lightMode`),p===`light`&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-green`,children:i(`settings.active`)})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.background`)}),(0,G.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,G.jsx)(`option`,{value:`neutral`,children:i(`settings.bgNeutral`)}),(0,G.jsx)(`option`,{value:`warm`,children:i(`settings.bgWarm`)}),(0,G.jsx)(`option`,{value:`cool`,children:i(`settings.bgCool`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.accent`)}),(0,G.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,G.jsx)(`option`,{value:`green`,children:i(`settings.accentGreen`)}),(0,G.jsx)(`option`,{value:`teal`,children:i(`settings.accentTeal`)}),(0,G.jsx)(`option`,{value:`blue`,children:i(`settings.accentBlue`)}),(0,G.jsx)(`option`,{value:`orange`,children:i(`settings.accentOrange`)}),(0,G.jsx)(`option`,{value:`purple`,children:i(`settings.accentPurple`)}),(0,G.jsx)(`option`,{value:`red`,children:i(`settings.accentRed`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.style`)}),(0,G.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,G.jsx)(`option`,{value:`classic`,children:i(`settings.styleClassic`)}),(0,G.jsx)(`option`,{value:`glow`,children:i(`settings.styleGlow`)}),(0,G.jsx)(`option`,{value:`vibrant`,children:i(`settings.styleVibrant`)})]})]})]})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.themeToggleHint`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-2 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.progressInTitle`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.progressInTitleDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:O,onChange:e=>{k(e.target.checked),o(i(`settings.toast.settingsSaved`),`success`)},className:`sr-only peer`}),(0,G.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,G.jsxs)(jd,{id:`card-archive`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.archiveSettings`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.autoArchivePrints`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.autoArchiveDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.auto_archive,onChange:e=>tr(`auto_archive`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.saveThumbnails`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.saveThumbnailsDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.save_thumbnails,onChange:e=>tr(`save_thumbnails`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.captureFinishPhoto`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.captureFinishPhotoDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.capture_finish_photo,onChange:e=>tr(`capture_finish_photo`,e.target.checked),className:`sr-only peer`}),(0,G.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.capture_finish_photo&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between pl-4 border-l-2 border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.finishPhotoRestorePlate`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.finishPhotoRestorePlateDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.finish_photo_restore_plate??!0,onChange:e=>tr(`finish_photo_restore_plate`,e.target.checked),className:`sr-only peer`}),(0,G.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.capture_finish_photo&&sn&&!sn.installed&&(0,G.jsxs)(`div`,{className:`flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg`,children:[(0,G.jsx)(Nu,{className:`w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5`}),(0,G.jsxs)(`div`,{className:`text-sm`,children:[(0,G.jsx)(`p`,{className:`text-yellow-500 font-medium`,children:i(`settings.ffmpegNotInstalled`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:i(`settings.ffmpegRequired`)})]})]}),pn&&mn&&(0,G.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-3 mt-3 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`archiveAutoPurge.enableLabel`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`archiveAutoPurge.enableDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:mn.enabled,onChange:e=>gn({enabled:e.target.checked}),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`archiveAutoPurge.ageLabel`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:7,max:3650,disabled:!mn.enabled,value:mn.days,onChange:e=>gn({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,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`archiveAutoPurge.days`)})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`archiveAutoPurge.ageDescription`)})]}),(0,G.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,disabled:!mn.enabled,checked:mn.purge_stats,onChange:e=>gn({purge_stats:e.target.checked}),className:`mt-0.5 shrink-0 disabled:opacity-50`}),(0,G.jsxs)(`span`,{className:`text-sm`,children:[(0,G.jsx)(`span`,{className:`text-white block`,children:i(`archiveAutoPurge.purgeStatsLabel`)}),(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray block mt-0.5`,children:i(`archiveAutoPurge.purgeStatsDescription`)})]})]})]})]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-md`,children:[(0,G.jsxs)(jd,{id:`card-camera`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Vu,{className:`w-5 h-5 text-bambu-green`}),i(`settings.camera`)]})}),(0,G.jsx)(Nd,{className:`space-y-3`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-white mb-2`,children:i(`settings.externalCameras`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-3`,children:i(`settings.externalCamerasDescription`)}),Yt&&Yt.length>0?(0,G.jsx)(`div`,{className:`space-y-3`,children:Yt.map(e=>(0,G.jsxs)(`div`,{className:`p-3 bg-bambu-dark rounded-lg`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsx)(`span`,{className:`text-white font-medium text-sm`,children:e.name}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e.external_camera_enabled,onChange:t=>mr(e.id,{enabled:t.target.checked}),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`space-y-2 mt-2`,children:[(0,G.jsx)(`input`,{type:`text`,placeholder:e.external_camera_type===`usb`?i(`settings.cameraPlaceholderUsb`):i(`settings.cameraPlaceholderUrl`),value:rr[e.id]??e.external_camera_url??``,onChange:t=>fr(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,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`select`,{value:e.external_camera_type||`mjpeg`,onChange:t=>mr(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,G.jsx)(`option`,{value:`mjpeg`,children:i(`settings.cameraTypeMjpeg`)}),(0,G.jsx)(`option`,{value:`rtsp`,children:i(`settings.cameraTypeRtsp`)}),(0,G.jsx)(`option`,{value:`snapshot`,children:i(`settings.cameraTypeSnapshot`)}),(0,G.jsx)(`option`,{value:`usb`,children:i(`settings.cameraTypeUsb`)})]}),(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>nr(e.id,rr[e.id]??e.external_camera_url??``,e.external_camera_type||`mjpeg`),disabled:At[e.id]||!(rr[e.id]??e.external_camera_url),children:At[e.id]?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):i(`settings.test`)})]}),Dt[e.id]&&(0,G.jsx)(`div`,{className:`text-xs flex items-center gap-1 ${Dt[e.id]?.success?`text-green-500`:`text-red-500`}`,children:Dt[e.id]?.success?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ys,{className:`w-3 h-3`}),i(`settings.connected`),Dt[e.id]?.resolution&&` (${Dt[e.id]?.resolution})`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ts,{className:`w-3 h-3`}),Dt[e.id]?.error||i(`settings.toast.connectionFailed`)]})}),(e.external_camera_type===`mjpeg`||e.external_camera_type===`rtsp`||e.external_camera_type===`usb`)&&(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:i(`settings.cameraSnapshotUrl`,`Snapshot URL (optional)`)}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`input`,{type:`text`,placeholder:i(`settings.cameraSnapshotUrlPlaceholder`,`http://192.168.1.61:1984/api/frame.jpeg?src=printer`),value:cr[e.id]??e.external_camera_snapshot_url??``,onChange:t=>pr(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,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>nr(e.id,cr[e.id]??e.external_camera_snapshot_url??``,`snapshot`),disabled:At[e.id]||!(cr[e.id]??e.external_camera_snapshot_url),children:At[e.id]?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):i(`settings.test`)})]}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:i(`settings.cameraRotation`)}),(0,G.jsxs)(`select`,{value:e.camera_rotation||0,onChange:t=>mr(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,G.jsx)(`option`,{value:0,children:`0°`}),(0,G.jsx)(`option`,{value:90,children:`90°`}),(0,G.jsx)(`option`,{value:180,children:`180°`}),(0,G.jsx)(`option`,{value:270,children:`270°`})]})]})]})]},e.id))}):(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray italic`,children:i(`settings.noPrintersConfigured`)})]})})]}),(0,G.jsxs)(jd,{id:`card-cost`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.costTracking`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.currency`)}),(0,G.jsx)(`select`,{value:A.currency,onChange:e=>tr(`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:aee.map(e=>(0,G.jsx)(`option`,{value:e.code,children:e.label},e.code))})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.defaultFilamentCost`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none`,children:wf(A.currency)}),(0,G.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,value:A.default_filament_cost,onChange:e=>tr(`default_filament_cost`,parseFloat(e.target.value)||0),style:{paddingLeft:`${Math.max(2,wf(A.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.electricityCost`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none`,children:wf(A.currency)}),(0,G.jsx)(`input`,{type:`number`,step:`0.001`,min:`0`,value:A.energy_cost_per_kwh,onChange:e=>tr(`energy_cost_per_kwh`,parseFloat(e.target.value)||0),style:{paddingLeft:`${Math.max(2,wf(A.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.energyDisplayMode`)}),(0,G.jsxs)(`select`,{value:A.energy_tracking_mode||`total`,onChange:e=>tr(`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,G.jsx)(`option`,{value:`print`,children:i(`settings.printsOnly`)}),(0,G.jsx)(`option`,{value:`total`,children:i(`settings.totalConsumption`)})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:A.energy_tracking_mode===`print`?i(`settings.energyModePrintDescription`):i(`settings.energyModeTotalDescription`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.billingEnabled`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.billingEnabledDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.billing_enabled??!1,onChange:e=>tr(`billing_enabled`,e.target.checked),className:`peer sr-only`}),(0,G.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary rounded-full peer-checked:bg-bambu-green peer-checked:after:translate-x-5 after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border after:rounded-full after:h-5 after:w-5 after:transition-all`})]})]}),A.billing_enabled&&(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-4 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.printerKillSwitch`,`Unauthorized print kill switch`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.printerKillSwitchDescription`,`Immediately stop prints that start without authorization.`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.printer_kill_switch_enabled??!1,onChange:e=>tr(`printer_kill_switch_enabled`,e.target.checked),className:`peer sr-only`}),(0,G.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary rounded-full peer-checked:bg-bambu-green peer-checked:after:translate-x-5 after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border after:rounded-full after:h-5 after:w-5 after:transition-all`})]})]}),A.billing_enabled&&(0,G.jsxs)(`div`,{className:`mt-4 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-4`,children:[(0,G.jsx)(`div`,{className:`mb-3`,children:(0,G.jsxs)(`h4`,{className:`text-base font-medium text-white flex items-center gap-2`,children:[(0,G.jsx)(rs,{className:`w-4 h-4 text-bambu-green`}),i(`settings.financeBudgetReset`,`Finance Monthly Budget Reset`)]})}),(0,G.jsxs)(`div`,{className:`flex gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.financeBudgetResetDay`,`Reset Day`)}),(0,G.jsx)(`input`,{type:`number`,min:1,max:31,value:A.finance_budget_reset_day??1,onChange:e=>tr(`finance_budget_reset_day`,Math.max(1,Math.min(31,parseInt(e.target.value,10)||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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.financeBudgetResetDayHelp`,`For short months, reset uses the last day of the month.`)})]}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.financeBudgetResetTimezone`,`Reset timezone`)}),(0,G.jsxs)(`select`,{value:A.finance_budget_reset_timezone??`UTC`,onChange:e=>tr(`finance_budget_reset_timezone`,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:outline-none focus:border-bambu-green`,children:[(0,G.jsx)(`option`,{value:`UTC`,children:`UTC`}),(0,G.jsx)(`option`,{value:`Europe/Berlin`,children:`Europe/Berlin`}),(0,G.jsx)(`option`,{value:`Europe/Vienna`,children:`Europe/Vienna`}),(0,G.jsx)(`option`,{value:`Europe/Zurich`,children:`Europe/Zurich`}),(0,G.jsx)(`option`,{value:`America/New_York`,children:`America/New_York`}),(0,G.jsx)(`option`,{value:`America/Chicago`,children:`America/Chicago`}),(0,G.jsx)(`option`,{value:`America/Denver`,children:`America/Denver`}),(0,G.jsx)(`option`,{value:`America/Los_Angeles`,children:`America/Los_Angeles`}),(0,G.jsx)(`option`,{value:`Asia/Tokyo`,children:`Asia/Tokyo`}),(0,G.jsx)(`option`,{value:`Asia/Singapore`,children:`Asia/Singapore`}),(0,G.jsx)(`option`,{value:`Australia/Sydney`,children:`Australia/Sydney`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.financeBudgetResetTimezoneHelp`,`Budget window start is calculated in this timezone.`)})]})]})]}),A.billing_enabled&&l&&(0,G.jsxs)(`div`,{className:`mt-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>fe(!0),disabled:pe,children:pe?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 mr-2 animate-spin`}),i(`settings.rebuildLedgerInProgress`,`Starting...`)]}):i(`settings.rebuildLedger`,`Rebuild wallet ledger`)}),de&&(0,G.jsx)(Xd,{title:i(`settings.rebuildLedgerConfirmTitle`,`Rebuild wallet ledger?`),message:i(`settings.rebuildLedgerConfirmMessage`,`This will rebuild the wallet ledger to repair historical balance values. Run this only if you know what you are doing.`),confirmText:i(`common.run`,`Run`),cancelText:i(`common.cancel`,`Cancel`),isLoading:pe,loadingText:i(`common.running`,`Running`),variant:`warning`,onCancel:()=>fe(!1),onConfirm:async()=>{me(!0);try{await Z.rebuildBalanceLedger(),o(i(`settings.rebuildLedgerStarted`,`Ledger rebuild started`),`success`),fe(!1)}catch(e){o(e.message||`Failed to start ledger rebuild`,`error`)}finally{me(!1)}}})]})]})]})]}),(0,G.jsxs)(jd,{id:`card-filemanager`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(cc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.fileManager`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.createArchiveEntry`)}),(0,G.jsxs)(`select`,{value:A.library_archive_mode??`ask`,onChange:e=>tr(`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,G.jsx)(`option`,{value:`always`,children:i(`settings.archiveMode.always`)}),(0,G.jsx)(`option`,{value:`never`,children:i(`settings.archiveMode.never`)}),(0,G.jsx)(`option`,{value:`ask`,children:i(`settings.archiveMode.ask`)})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.createArchiveEntryDescription`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.lowDiskSpaceWarning`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:`0.5`,max:`100`,step:`0.5`,value:A.library_disk_warning_gb??5,onChange:e=>tr(`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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`GB`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.lowDiskSpaceDescription`)})]}),ln&&un&&(0,G.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-3 mt-3 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`libraryAutoPurge.enableLabel`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`libraryAutoPurge.enableDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:un.auto_purge_enabled,onChange:e=>fn({auto_purge_enabled:e.target.checked}),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`libraryAutoPurge.ageLabel`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:7,max:3650,disabled:!un.auto_purge_enabled,value:un.auto_purge_days,onChange:e=>fn({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,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`libraryAutoPurge.days`)})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`libraryAutoPurge.ageDescription`)})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-white cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,disabled:!un.auto_purge_enabled,checked:un.auto_purge_include_never_printed,onChange:e=>fn({auto_purge_include_never_printed:e.target.checked}),className:`rounded border-gray-300 disabled:opacity-50`}),i(`libraryAutoPurge.includeNeverPrinted`)]})]})]})]}),(0,G.jsxs)(jd,{id:`card-data`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.dataManagement`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.clearNotificationLogs`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.clearNotificationLogsDescription`)})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>He(!0),children:[(0,G.jsx)(Au,{className:`w-4 h-4`}),i(`common.clear`)]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.resetUiPreferences`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.resetUiPreferencesDescription`)})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>We(!0),children:[(0,G.jsx)(Au,{className:`w-4 h-4`}),i(`settings.reset`)]})]}),(0,G.jsxs)(`div`,{className:`pt-4 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.storageUsage`,`Storage Usage`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.storageUsageDescription`,`Breakdown of data usage by category`)})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:Rt,disabled:Lt||rt,children:[(0,G.jsx)(Rl,{className:`w-4 h-4 ${Lt||rt?`animate-spin`:``}`}),i(`common.refresh`,`Refresh`)]})]}),(0,G.jsx)(`div`,{className:`mt-3`,children:It?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),i(`common.loading`,`Loading`)]}):Ft?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`w-full h-3 bg-bambu-dark rounded-full overflow-hidden flex`,children:Ft.categories.filter(e=>e.bytes>0).map((e,t)=>(0,G.jsx)(`div`,{className:`${M8(e.key,t)} h-full`,style:{width:`${e.percent_of_total}%`},title:`${e.label}: ${e.formatted}`},e.key))}),(0,G.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-3`,children:Ft.categories.filter(e=>e.bytes>0).map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsx)(`span`,{className:`w-3 h-3 rounded-full ${M8(e.key,t)}`}),(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:e.label}),(0,G.jsx)(`span`,{className:`text-white`,children:e.formatted}),(0,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,e.percent_of_total.toFixed(1),`%)`]})]},e.key))}),(0,G.jsxs)(`div`,{className:`mt-2 text-xs text-bambu-gray`,children:[i(`settings.storageUsageTotal`,`Total`),`: `,(0,G.jsx)(`span`,{className:`text-white`,children:Ft.total_formatted}),Ft.scan_errors>0&&(0,G.jsxs)(`span`,{className:`ml-2 text-amber-700 dark:text-amber-400`,children:[i(`settings.storageUsageErrors`,`Scan errors`),`: `,Ft.scan_errors]})]}),Ft.other_breakdown?.length>0&&(0,G.jsxs)(`div`,{className:`mt-4`,children:[(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:i(`settings.storageUsageOtherBreakdown`,`Other breakdown`)}),(0,G.jsx)(`div`,{className:`space-y-2`,children:Ft.other_breakdown.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-white`,children:e.label}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,G.jsx)(`span`,{className:`text-white`,children:e.formatted}),(0,G.jsxs)(`span`,{children:[`(`,e.percent_of_total.toFixed(1),`%)`]})]})]},`${e.bucket}-${e.kind}`))})]})]}):(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.storageUsageUnavailable`,`Storage usage data is unavailable`)})})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-4 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.backupRestore`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.backupRestoreDescription`)})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>Te(`backup`),children:[(0,G.jsx)(Us,{className:`w-4 h-4`}),i(`settings.goToBackup`)]})]})]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-sm`,children:[(0,G.jsxs)(jd,{id:`card-updates`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.updates`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-xs font-medium text-bambu-gray uppercase tracking-wider`,children:i(`settings.printerFirmware`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.checkPrinterFirmware`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.checkFirmwareDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.check_printer_firmware??!0,onChange:e=>tr(`check_printer_firmware`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:(0,G.jsx)(`p`,{className:`text-xs font-medium text-bambu-gray uppercase tracking-wider mb-4`,children:i(`settings.bambuddySoftware`)})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.checkForUpdatesLabel`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.autoCheckDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.check_updates,onChange:e=>tr(`check_updates`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between ${A.check_updates?``:`opacity-50`}`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.includeBetaUpdates`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.includeBetaUpdatesDesc`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.include_beta_updates??!1,onChange:e=>tr(`include_beta_updates`,e.target.checked),disabled:!A.check_updates,className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.currentVersion`)}),(0,G.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[`v`,cn?.version||`...`]})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>vn(),disabled:yn,children:[yn?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Rl,{className:`w-4 h-4`}),i(`settings.checkNow`)]})]}),_n?.update_available?(0,G.jsxs)(`div`,{className:`mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`p`,{className:`text-bambu-green font-medium`,children:[`Update available: v`,_n.latest_version]}),_n.release_name&&_n.release_name!==_n.latest_version&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:_n.release_name})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_n.release_notes&&(0,G.jsx)(`button`,{onClick:()=>Je(!0),className:`text-bambu-gray hover:text-white transition-colors text-sm underline`,children:i(`settings.releaseNotes`)}),_n.release_url&&(0,G.jsx)(`a`,{href:_n.release_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-bambu-gray hover:text-white transition-colors`,title:i(`settings.viewReleaseOnGitHub`),children:(0,G.jsx)(ec,{className:`w-4 h-4`})})]})]}),bn?.status===`downloading`||bn?.status===`installing`?(0,G.jsxs)(`div`,{className:`mt-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),(0,G.jsx)(`span`,{children:bn.message})]}),(0,G.jsx)(`div`,{className:`mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2`,children:(0,G.jsx)(`div`,{className:`bg-bambu-green h-2 rounded-full transition-all duration-300`,style:{width:`${bn.progress}%`}})})]}):bn?.status===`complete`?(0,G.jsx)(`div`,{className:`mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green`,children:bn.message}):bn?.status===`error`?(0,G.jsx)(`div`,{className:`mt-3 p-2 bg-red-100 dark:bg-red-500/20 rounded text-sm text-red-700 dark:text-red-400`,children:bn.error||bn.message}):_n?.is_ha_addon?(0,G.jsx)(`div`,{className:`mt-3 p-3 bg-bambu-dark-tertiary rounded-lg`,children:(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.updateViaHomeAssistant`)})}):_n?.is_docker?(0,G.jsxs)(`div`,{className:`mt-3 p-3 bg-bambu-dark-tertiary rounded-lg`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-2`,children:i(`settings.updateViaDocker`)}),(0,G.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,G.jsx)(`code`,{className:`flex-1 block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono break-all select-all`,children:br}),(0,G.jsx)(UW,{value:br,titleKey:`settings.copyUpdateCommand`,copiedTitleKey:`printers.copied`,className:`ml-0 p-2 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors flex-shrink-0`,iconClassName:`w-4 h-4`})]}),(0,G.jsxs)(`label`,{className:`block mt-3`,children:[(0,G.jsx)(`span`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.composeDirectory`)}),(0,G.jsx)(`input`,{type:`text`,value:A?.docker_compose_dir??``,onChange:e=>tr(`docker_compose_dir`,e.target.value),placeholder:_n?.compose_dir_detected||`/opt/bambuddy`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white font-mono placeholder:text-bambu-gray/60 focus:outline-none focus:border-bambu-green`}),(0,G.jsx)(`span`,{className:`block text-xs text-bambu-gray mt-1`,children:i(`settings.composeDirectoryHint`)})]})]}):_n?.update_method===`windows_installer`?(0,G.jsxs)(`div`,{className:`mt-3 p-3 bg-bambu-dark-tertiary rounded-lg`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-3`,children:i(`settings.updateViaWindowsInstaller`)}),(0,G.jsxs)(`a`,{href:_n.installer_download_url||_n.release_url||`https://github.com/maziggy/bambuddy/releases/tag/v${_n.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,G.jsx)(qs,{className:`w-4 h-4`}),i(`settings.downloadWindowsInstaller`,{version:_n.latest_version})]})]}):(0,G.jsxs)(Q,{className:`mt-3`,onClick:()=>Un.mutate(),disabled:Un.isPending,children:[Un.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(qs,{className:`w-4 h-4`}),i(`settings.installUpdate`)]})]}):_n?.error?(0,G.jsx)(`div`,{className:`mt-2 p-2 bg-red-50 dark:bg-red-500/10 border border-red-300 dark:border-red-500/30 rounded text-sm text-red-700 dark:text-red-400`,children:i(`settings.failedToCheckUpdates`,{error:_n.error})}):_n&&!_n.update_available?(0,G.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray`,children:i(`settings.latestVersionRunning`)}):null]})]})]}),(0,G.jsx)(fHe,{})]})]})]}),ye===`network`&&A&&(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-6`,children:[(0,G.jsxs)(`div`,{className:`flex-1 lg:max-w-xl space-y-3`,children:[(0,G.jsxs)(jd,{id:`card-externalurl`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Ec,{className:`w-5 h-5 text-blue-600 dark:text-blue-400`}),i(`settings.externalUrl`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.externalUrlDescription`)}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.bambuddyUrl`)}),(0,G.jsx)(`input`,{type:`text`,value:A.external_url??``,onChange:e=>tr(`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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.externalUrlHint`)})]})]})]}),(0,G.jsxs)(jd,{id:`card-ftpretry`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Rl,{className:`w-5 h-5 text-blue-600 dark:text-blue-400`}),i(`settings.ftpRetry`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.ftpRetryDescription`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.enableRetry`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.autoRetryDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.ftp_retry_enabled??!0,onChange:e=>tr(`ftp_retry_enabled`,e.target.checked),className:`sr-only peer`}),(0,G.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.ftp_retry_enabled&&(0,G.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.retryAttempts`)}),(0,G.jsxs)(`div`,{className:`relative w-44`,children:[(0,G.jsx)(`select`,{value:A.ftp_retry_count??3,onChange:e=>tr(`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,G.jsx)(`option`,{value:e,children:i(`settings.time`,{count:e})},e))}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.retryDelay`)}),(0,G.jsxs)(`div`,{className:`relative w-44`,children:[(0,G.jsx)(`select`,{value:A.ftp_retry_delay??2,onChange:e=>tr(`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,G.jsx)(`option`,{value:e,children:i(`settings.second`,{count:e})},e))}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.connectionTimeout`)}),(0,G.jsxs)(`div`,{className:`relative w-44`,children:[(0,G.jsx)(`select`,{value:A.ftp_timeout??30,onChange:e=>tr(`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,G.jsx)(`option`,{value:e,children:i(`settings.nSeconds`,{count:e})},e))}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.increaseForWeakWifi`)})]})]})]})]})]}),(0,G.jsxs)(`div`,{className:`flex-1 lg:max-w-xl space-y-3`,children:[(0,G.jsxs)(jd,{id:`card-ha`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Fc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.homeAssistant`)]}),A.ha_enabled&&Ct&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${Ct.success?`bg-green-400`:`bg-red-400`}`}),(0,G.jsx)(`span`,{className:`text-sm ${Ct.success?`text-green-700 dark:text-green-400`:`text-red-700 dark:text-red-400`}`,children:Ct.success?i(`settings.connected`):i(`settings.disconnected`)})]})]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.homeAssistantFullDescription`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.enableHomeAssistant`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.homeAssistantDescription`)}),A.ha_env_managed&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1 mt-1`,children:[(0,G.jsx)(Qc,{className:`w-3 h-3 text-bambu-green`}),(0,G.jsx)(`span`,{className:`text-xs text-bambu-green`,children:i(`settings.autoEnabledViaEnv`)})]})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.ha_enabled??!1,onChange:e=>tr(`ha_enabled`,e.target.checked),disabled:A.ha_env_managed,className:`sr-only peer`}),(0,G.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.ha_env_managed?`opacity-60 cursor-not-allowed`:``}`})]})]}),A.ha_enabled&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.homeAssistantUrl`),A.ha_url_from_env&&(0,G.jsx)(`span`,{className:`ml-2 text-xs text-bambu-green`,children:i(`settings.environmentManagedLabel`)})]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:`text`,value:A.ha_url??``,onChange:e=>tr(`ha_url`,e.target.value),placeholder:`http://192.168.1.100:8123`,disabled:A.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 ${A.ha_url_from_env?`opacity-60 cursor-not-allowed`:``}`}),A.ha_url_from_env&&(0,G.jsx)(Qc,{className:`absolute right-3 top-2.5 w-4 h-4 text-bambu-gray`})]}),A.ha_url_from_env&&(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.urlFromEnvReadOnly`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.longLivedAccessToken`),A.ha_token_from_env&&(0,G.jsx)(`span`,{className:`ml-2 text-xs text-bambu-green`,children:i(`settings.environmentManagedLabel`)})]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:`password`,value:A.ha_token??``,onChange:e=>tr(`ha_token`,e.target.value),placeholder:`eyJ0eXAiOiJKV1QiLC...`,disabled:A.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 ${A.ha_token_from_env?`opacity-60 cursor-not-allowed`:``}`}),A.ha_token_from_env&&(0,G.jsx)(Qc,{className:`absolute right-3 top-2.5 w-4 h-4 text-bambu-gray`})]}),A.ha_token_from_env?(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.tokenFromEnvReadOnly`)}):(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.haTokenHint`)})]}),A.ha_url&&A.ha_token&&(0,G.jsx)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,disabled:Tt,onClick:async()=>{Et(!0),wt(null);try{wt(await Z.testHAConnection(A.ha_url,A.ha_token))}catch(e){wt({success:!1,message:null,error:e instanceof Error?e.message:i(`common.unknownError`)})}finally{Et(!1)}},children:[Tt?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Ju,{className:`w-4 h-4`}),i(`settings.testConnection`)]})})]})]})]}),(0,G.jsxs)(jd,{id:`card-mqtt`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Ju,{className:`w-5 h-5 text-blue-600 dark:text-blue-400`}),i(`settings.mqttPublishing`)]}),Sn?.enabled&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${Sn.connected?`bg-green-400`:`bg-red-400`}`}),(0,G.jsx)(`span`,{className:`text-sm ${Sn.connected?`text-green-700 dark:text-green-400`:`text-red-700 dark:text-red-400`}`,children:Sn.connected?i(`settings.connected`):i(`settings.disconnected`)})]})]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.mqttDescription`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.enableMqtt`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.mqttEnableDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.mqtt_enabled??!1,onChange:e=>tr(`mqtt_enabled`,e.target.checked),className:`sr-only peer`}),(0,G.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.mqtt_enabled&&(0,G.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.brokerHostname`)}),(0,G.jsx)(`input`,{type:`text`,value:A.mqtt_broker??``,onChange:e=>tr(`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,G.jsxs)(`div`,{className:`flex items-end gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.port`)}),(0,G.jsx)(`input`,{type:`number`,min:`1`,max:`65535`,value:A.mqtt_port??1883,onChange:e=>tr(`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,G.jsxs)(`div`,{className:`flex items-center gap-3 pb-2`,children:[(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.mqtt_use_tls??!1,onChange:e=>{let t=e.target.checked;tr(`mqtt_use_tls`,t);let n=A.mqtt_port??1883;t&&n===1883?tr(`mqtt_port`,8883):!t&&n===8883&&tr(`mqtt_port`,1883)},className:`sr-only peer`}),(0,G.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,G.jsx)(`span`,{className:`text-white text-sm`,children:i(`settings.useTls`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.usernameOptional`)}),(0,G.jsx)(`input`,{type:`text`,value:A.mqtt_username??``,onChange:e=>tr(`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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.passwordOptional`)}),(0,G.jsx)(`input`,{type:`password`,value:A.mqtt_password??``,onChange:e=>tr(`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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.topicPrefix`)}),(0,G.jsx)(`input`,{type:`text`,value:A.mqtt_topic_prefix??`bambuddy`,onChange:e=>tr(`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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.topicPrefixHint`,{prefix:A.mqtt_topic_prefix||`bambuddy`})})]}),Sn&&(0,G.jsx)(`div`,{className:`pt-3 mt-3 border-t border-bambu-dark-tertiary`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${Sn.connected?`bg-green-400`:`bg-red-400`}`}),(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:Sn.connected?(0,G.jsxs)(G.Fragment,{children:[i(`settings.mqttConnectedTo`),` `,(0,G.jsxs)(`span`,{className:`text-white`,children:[Sn.broker,`:`,Sn.port]})]}):i(`settings.spoolmanDisconnected`)})]})})]})]})]})]}),(0,G.jsx)(`div`,{className:`flex-1 lg:max-w-md space-y-3`,children:(0,G.jsxs)(jd,{id:`card-prometheus`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Mu,{className:`w-5 h-5 text-orange-600 dark:text-orange-400`}),i(`settings.prometheusMetrics`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.prometheusEndpointDescription`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.enableMetricsEndpoint`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.prometheusDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.prometheus_enabled??!1,onChange:e=>tr(`prometheus_enabled`,e.target.checked),className:`sr-only peer`}),(0,G.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.prometheus_enabled&&(0,G.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.bearerTokenOptional`)}),(0,G.jsx)(`input`,{type:`password`,value:A.prometheus_token??``,onChange:e=>tr(`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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.bearerTokenHint`)})]}),(0,G.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white mb-2`,children:i(`settings.availableMetrics`)}),(0,G.jsxs)(`div`,{className:`text-xs text-bambu-gray space-y-1`,children:[(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`code`,{className:`text-orange-700 dark:text-orange-400`,children:`bambuddy_printer_connected`}),` - `,i(`settings.metricsConnectionStatus`)]}),(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`code`,{className:`text-orange-700 dark:text-orange-400`,children:`bambuddy_printer_state`}),` - `,i(`settings.metricsPrinterState`)]}),(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`code`,{className:`text-orange-700 dark:text-orange-400`,children:`bambuddy_print_progress`}),` - `,i(`settings.metricsPrintProgress`)]}),(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`code`,{className:`text-orange-700 dark:text-orange-400`,children:`bambuddy_bed_temp_celsius`}),` - `,i(`settings.metricsBedTemp`)]}),(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`code`,{className:`text-orange-700 dark:text-orange-400`,children:`bambuddy_nozzle_temp_celsius`}),` - `,i(`settings.metricsNozzleTemp`)]}),(0,G.jsxs)(`p`,{children:[(0,G.jsx)(`code`,{className:`text-orange-700 dark:text-orange-400`,children:`bambuddy_prints_total`}),` - `,i(`settings.metricsPrintsTotal`)]}),(0,G.jsx)(`p`,{className:`text-bambu-gray/70 italic`,children:i(`settings.metricsMore`)})]})]})]})]})]})})]}),Ct&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,G.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[Ct.success?(0,G.jsx)(ys,{className:`w-8 h-8 text-green-600 dark:text-green-400`}):(0,G.jsx)(Ts,{className:`w-8 h-8 text-red-600 dark:text-red-400`}),(0,G.jsx)(`h3`,{className:`text-lg font-medium text-white`,children:Ct.success?i(`settings.connectionSuccessful`):i(`settings.connectionFailed`)})]}),(0,G.jsx)(`p`,{className:`text-bambu-gray mb-6`,children:Ct.success?Ct.message||i(`settings.haConnectionSuccess`):Ct.error||i(`settings.haConnectionFailed`)}),(0,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(Q,{variant:`primary`,onClick:()=>wt(null),children:i(`settings.ok`)})})]})}),ye===`plugs`&&(0,G.jsxs)(`div`,{id:`card-plugs`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Al,{className:`w-5 h-5 text-bambu-green`}),i(`settings.smartPlugs`)]}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.smartPlugsDescription`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 pt-1 shrink-0`,children:[zt&&zt.filter(e=>e.enabled).length>1&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>Ke(`on`),disabled:qn.isPending,title:i(`settings.turnAllPlugsOn`),children:[qn.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Nl,{className:`w-4 h-4 text-bambu-green`}),i(`settings.allOn`)]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>Ke(`off`),disabled:qn.isPending,title:i(`settings.turnAllPlugsOff`),children:[qn.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Ml,{className:`w-4 h-4 text-red-600 dark:text-red-400`}),i(`settings.allOff`)]})]}),(0,G.jsxs)(Q,{className:`whitespace-nowrap`,onClick:()=>{L(null),F(!0)},children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.addSmartPlug`)]})]})]}),zt&&zt.length>0&&(0,G.jsxs)(jd,{className:`mb-6`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(ed,{className:`w-4 h-4 text-yellow-600 dark:text-yellow-400`}),i(`settings.energySummary`),Ht&&(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin text-bambu-gray ml-2`})]})}),(0,G.jsx)(Nd,{children:Vt?(0,G.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,G.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,G.jsx)(ed,{className:`w-3 h-3`}),i(`settings.currentPower`)]}),(0,G.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Vt.totalPower.toFixed(1),(0,G.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`W`})]}),(0,G.jsx)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.plugsOnline`,{reachable:Vt.reachableCount,total:Vt.totalPlugs})})]}),(0,G.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,G.jsx)(rs,{className:`w-3 h-3`}),i(`settings.today`)]}),(0,G.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Vt.totalToday.toFixed(3),(0,G.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`kWh`})]}),(A?.energy_cost_per_kwh??0)>0&&(0,G.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:[`~`,(Vt.totalToday*(A?.energy_cost_per_kwh??0)).toFixed(2),` `,wf(A?.currency||`USD`)]})]}),(0,G.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,G.jsx)(Mu,{className:`w-3 h-3`}),i(`settings.yesterday`)]}),(0,G.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Vt.totalYesterday.toFixed(3),(0,G.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`kWh`})]}),(A?.energy_cost_per_kwh??0)>0&&(0,G.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:[`~`,(Vt.totalYesterday*(A?.energy_cost_per_kwh??0)).toFixed(2),` `,wf(A?.currency||`USD`)]})]}),(0,G.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,G.jsx)(Ws,{className:`w-3 h-3`}),i(`settings.total`)]}),(0,G.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Vt.totalLifetime.toFixed(1),(0,G.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`kWh`})]}),(A?.energy_cost_per_kwh??0)>0&&(0,G.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:[`~`,(Vt.totalLifetime*(A?.energy_cost_per_kwh??0)).toFixed(2),` `,wf(A?.currency||`USD`)]})]})]}):Ht?null:(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.enablePlugsForSummary`)})})]}),Bt?(0,G.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):zt&&zt.length>0?(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4`,children:zt.map(e=>(0,G.jsx)(OVe,{plug:e,onEdit:e=>{L(e),F(!0)}},e.id))}):(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-12`,children:(0,G.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,G.jsx)(Al,{className:`w-16 h-16 mx-auto mb-4 opacity-30`}),(0,G.jsx)(`p`,{className:`text-lg font-medium text-white mb-2`,children:i(`settings.noSmartPlugsTitle`)}),(0,G.jsx)(`p`,{className:`text-sm mb-4`,children:i(`settings.noSmartPlugsDescription`)}),(0,G.jsxs)(Q,{onClick:()=>{L(null),F(!0)},children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.addFirstSmartPlug`)]})]})})}),(0,G.jsxs)(`div`,{className:`mt-8`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(xc,{className:`w-5 h-5 text-bambu-green`}),i(`haSensors.sectionTitle`)]}),(0,G.jsxs)(Q,{className:`whitespace-nowrap`,disabled:!Yt?.length,onClick:()=>{V(null),z(!0)},children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`haSensors.add`)]})]}),Xt&&Xt.length>0?(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Xt.map(e=>{let t=Yt?.find(t=>t.id===e.printer_id);return(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`py-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-white font-medium truncate`,children:e.name}),(0,G.jsx)(`div`,{className:`text-xs text-bambu-gray truncate`,children:e.entity_id}),(0,G.jsx)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:t?.name??i(`haSensors.unknownPrinter`)})]}),(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>{V(e),z(!0)},children:i(`common.edit`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-3`,children:[e.block_print&&(0,G.jsx)(`span`,{className:`px-2 py-0.5 text-xs rounded bg-amber-100 dark:bg-amber-500/20 text-amber-700 dark:text-amber-400`,children:i(`haSensors.badgeBlocks`)}),e.notify_on_alert&&(0,G.jsx)(`span`,{className:`px-2 py-0.5 text-xs rounded bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400`,children:i(`haSensors.badgeNotifies`)}),!e.show_on_printer_card&&(0,G.jsx)(`span`,{className:`px-2 py-0.5 text-xs rounded bg-bambu-dark-tertiary text-bambu-gray`,children:i(`haSensors.badgeHidden`)})]})]})},e.id)})}):(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-8`,children:(0,G.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,G.jsx)(xc,{className:`w-12 h-12 mx-auto mb-3 opacity-30`}),(0,G.jsx)(`p`,{className:`text-sm`,children:i(`haSensors.empty`)})]})})})]})]}),ye===`notifications`&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-providers`,children:[(0,G.jsx)(Go,{className:`w-5 h-5 text-bambu-green`}),i(`settings.providers`)]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(Q,{size:`sm`,variant:`secondary`,onClick:()=>ue(!0),children:[(0,G.jsx)(Pc,{className:`w-4 h-4`}),i(`settings.log`)]}),Ut&&Ut.length>0&&(0,G.jsxs)(Q,{size:`sm`,variant:`secondary`,onClick:()=>{Gn(null),Kn.mutate()},disabled:Kn.isPending,children:[Kn.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Yl,{className:`w-4 h-4`}),i(`settings.testAll`)]}),(0,G.jsxs)(Q,{size:`sm`,onClick:()=>{re(null),te(!0)},children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.addNotificationProvider`)]})]})]}),(0,G.jsx)(jd,{className:`mb-4`,children:(0,G.jsx)(Nd,{className:`py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm font-medium`,children:i(`settings.notificationLanguage`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.notificationLanguageDescription`)})]}),(0,G.jsx)(`select`,{value:A.notification_language||`en`,onChange:e=>tr(`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:kt.map(e=>(0,G.jsx)(`option`,{value:e.code,children:e.nativeName},e.code))})]})})}),(0,G.jsx)(jd,{className:`mb-4`,children:(0,G.jsx)(Nd,{className:`py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm font-medium`,children:i(`settings.bedCooledThreshold`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.bedCooledThresholdDescription`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`input`,{type:`number`,min:20,max:80,step:1,value:A.bed_cooled_threshold??35,onChange:e=>tr(`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,G.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`°C`})]})]})})}),(0,G.jsx)(jd,{className:`mb-4`,children:(0,G.jsx)(Nd,{className:`py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between ${Tn?.advanced_auth_enabled?``:`opacity-50`}`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white text-sm font-medium`,children:i(`settings.userNotificationsEnabled`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:Tn?.advanced_auth_enabled?i(`settings.userNotificationsEnabledDescription`):i(`settings.userNotificationsDisabledHint`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:A.user_notifications_enabled??!0,disabled:!Tn?.advanced_auth_enabled,onChange:e=>tr(`user_notifications_enabled`,e.target.checked)}),(0,G.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`})]})]})})}),Wn&&(0,G.jsx)(jd,{className:`mb-4`,children:(0,G.jsxs)(Nd,{className:`py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-white`,children:i(`settings.testResults`)}),(0,G.jsx)(`button`,{onClick:()=>Gn(null),className:`text-bambu-gray hover:text-white text-xs`,children:i(`common.dismiss`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-4 text-sm mb-2`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-green`,children:[(0,G.jsx)(ys,{className:`w-4 h-4`}),i(`settings.testPassedCount`,{count:Wn.success})]}),Wn.failed>0&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1 text-red-700 dark:text-red-400`,children:[(0,G.jsx)(Ts,{className:`w-4 h-4`}),i(`settings.testFailedCount`,{count:Wn.failed})]})]}),Wn.results.filter(e=>!e.success).length>0&&(0,G.jsx)(`div`,{className:`space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary`,children:Wn.results.filter(e=>!e.success).map(e=>(0,G.jsxs)(`div`,{className:`text-xs text-red-700 dark:text-red-400`,children:[(0,G.jsxs)(`span`,{className:`font-medium`,children:[e.provider_name,`:`]}),` `,e.message]},e.provider_id))})]})}),Wt?(0,G.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,G.jsx)(Y,{className:`w-6 h-6 text-bambu-green animate-spin`})}):Ut&&Ut.length>0?(0,G.jsx)(`div`,{className:`space-y-3`,children:Ut.map(e=>(0,G.jsx)(MVe,{provider:e,onEdit:e=>{re(e),te(!0)}},e.id))}):(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-8`,children:(0,G.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,G.jsx)(Go,{className:`w-12 h-12 mx-auto mb-3 opacity-30`}),(0,G.jsx)(`p`,{className:`text-sm font-medium text-white mb-2`,children:i(`settings.noProvidersTitle`)}),(0,G.jsx)(`p`,{className:`text-xs mb-3`,children:i(`settings.noProvidersDescription`)}),(0,G.jsxs)(Q,{size:`sm`,onClick:()=>{re(null),te(!0)},children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.addProvider`)]})]})})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2 mb-2`,id:`card-templates`,children:[(0,G.jsx)(cc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.messageTemplates`)]}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-3`,children:i(`settings.messageTemplatesDescription`)}),(0,G.jsxs)(`div`,{className:`relative mb-3`,children:[(0,G.jsx)(Jl,{className:`w-4 h-4 text-bambu-gray absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none`}),(0,G.jsx)(`input`,{type:`text`,value:oe,onChange:e=>se(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`}),oe&&(0,G.jsx)(`button`,{onClick:()=>se(``),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,G.jsx)(Qu,{className:`w-3.5 h-3.5`})})]}),$t?(0,G.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,G.jsx)(Y,{className:`w-6 h-6 text-bambu-green animate-spin`})}):Qt&&Qt.length>0?(()=>{let e=oe.trim().toLowerCase(),t=[...Qt].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,G.jsx)(`p`,{className:`text-sm text-bambu-gray italic text-center py-6`,children:i(`settings.noTemplatesMatch`,`No templates match your filter.`)}):(0,G.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,G.jsx)(jd,{className:`cursor-pointer hover:border-bambu-green/50 transition-colors`,onClick:()=>ae(e),children:(0,G.jsx)(Nd,{className:`py-2.5 px-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`text-white font-medium text-sm truncate`,children:e.name}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-xs truncate mt-0.5`,children:e.title_template})]}),(0,G.jsx)(`button`,{className:`p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2`,onClick:t=>{t.stopPropagation(),ae(e)},children:(0,G.jsx)(Tl,{className:`w-4 h-4 text-bambu-gray`})})]})})},e.id))})})():(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-8`,children:(0,G.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,G.jsx)(cc,{className:`w-12 h-12 mx-auto mb-3 opacity-30`}),(0,G.jsx)(`p`,{className:`text-sm`,children:i(`settings.noTemplatesAvailable`)})]})})})]})]}),ye===`apikeys`&&(0,G.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,G.jsxs)(`div`,{children:[d(`api_keys:read`)&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4 mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-createapi`,children:[(0,G.jsx)(Vc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.apiKeys`)]}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.apiKeysDescription`)})]}),(0,G.jsxs)(Q,{size:`sm`,onClick:()=>Oe(!0),className:`flex-shrink-0`,children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.createKey`)]})]}),Ne&&(0,G.jsx)(jd,{className:`mb-6 border-bambu-green`,children:(0,G.jsx)(Nd,{className:`py-4`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(ys,{className:`w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`p`,{className:`text-white font-medium mb-1`,children:i(`settings.apiKeyCreated`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-2`,children:i(`settings.apiKeyCopyWarning`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 bg-bambu-dark rounded-lg p-2`,children:[(0,G.jsx)(`code`,{className:`flex-1 text-sm text-bambu-green font-mono break-all`,children:Ne}),(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(Ne);else{let e=document.createElement(`textarea`);e.value=Ne,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,G.jsx)(zs,{className:`w-4 h-4`})})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 mt-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>{Be(Ne),o(i(`settings.toast.keyAddedToBrowser`))},children:i(`settings.useInApiBrowser`)}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>Ie(!0),children:[(0,G.jsx)(Fl,{className:`w-4 h-4`}),i(`settings.apiKeyQrButton`)]}),(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>{Ie(!1),Pe(null)},children:i(`common.dismiss`)})]})]})]})})}),Fe&&Ne&&(0,G.jsx)(YVe,{apiKey:Ne,baseUrl:A?.external_url||void 0,onClose:()=>Ie(!1)}),De&&(0,G.jsxs)(jd,{className:`mb-6`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h3`,{className:`text-base font-semibold text-white`,children:i(`settings.createNewApiKey`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.keyName`)}),(0,G.jsx)(`input`,{type:`text`,value:ke,onChange:e=>Ae(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:i(`common.permissions`)}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_read_status,onChange:e=>Me(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.readStatus`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.readStatusDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_queue,onChange:e=>Me(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.manageQueue`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageQueueDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_control_printer,onChange:e=>Me(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.controlPrinter`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.controlPrinterDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_manage_library,onChange:e=>Me(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.manageLibrary`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageLibraryDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_manage_inventory,onChange:e=>Me(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.manageInventory`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageInventoryDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_manage_maintenance,onChange:e=>Me(t=>({...t,can_manage_maintenance:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.manageMaintenance`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageMaintenanceDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_manage_archives,onChange:e=>Me(t=>({...t,can_manage_archives:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.manageArchives`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageArchivesDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_manage_projects,onChange:e=>Me(t=>({...t,can_manage_projects:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.manageProjects`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageProjectsDescription`)})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_access_cloud,onChange:e=>Me(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.cloudAccess`,`Allow cloud access`)}),(0,G.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,G.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:je.can_update_energy_cost,onChange:e=>Me(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,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`text-white`,children:i(`settings.updateEnergyCost`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.updateEnergyCostDescription`)})]})]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,G.jsxs)(Q,{onClick:()=>qt.mutate({name:ke||i(`settings.unnamedKey`),...je}),disabled:qt.isPending,children:[qt.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.createKey`)]}),(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>Oe(!1),children:i(`common.cancel`)})]})]})]}),Kt?(0,G.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):Gt&&Gt.length>0?(0,G.jsx)(`div`,{className:`space-y-3`,children:Gt.map(e=>(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(Vc,{className:`w-5 h-5 ${e.enabled?`text-bambu-green`:`text-bambu-gray`}`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white font-medium`,children:e.name}),(0,G.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[e.key_prefix,`••••••••`,e.last_used&&` · ${i(`settings.lastUsed`)}: ${Gf(e.last_used)}`]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex gap-1 text-xs flex-wrap justify-end`,children:[e.can_read_status&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400 rounded`,children:i(`settings.read`)}),e.can_queue&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-400 rounded`,children:i(`queue.title`)}),e.can_control_printer&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-orange-100 dark:bg-orange-500/20 text-orange-700 dark:text-orange-400 rounded`,children:i(`settings.control`)}),e.can_manage_library&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-cyan-100 dark:bg-cyan-500/20 text-cyan-700 dark:text-cyan-400 rounded`,children:i(`settings.libraryBadge`)}),e.can_manage_inventory&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-pink-100 dark:bg-pink-500/20 text-pink-700 dark:text-pink-400 rounded`,children:i(`settings.inventoryBadge`)}),e.can_manage_maintenance&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-teal-100 dark:bg-teal-500/20 text-teal-700 dark:text-teal-400 rounded`,children:i(`settings.maintenanceBadge`)}),e.can_manage_archives&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-indigo-100 dark:bg-indigo-500/20 text-indigo-700 dark:text-indigo-400 rounded`,children:i(`settings.archivesBadge`)}),e.can_manage_projects&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-lime-100 dark:bg-lime-500/20 text-lime-700 dark:text-lime-400 rounded`,children:i(`settings.projectsBadge`)}),e.can_access_cloud&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-400 rounded`,children:i(`settings.cloudBadge`,`Cloud`)}),e.can_update_energy_cost&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-amber-100 dark:bg-amber-500/20 text-amber-700 dark:text-amber-400 rounded`,children:i(`settings.energyCostBadge`)}),e.user_id===null&&(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400 rounded`,title:i(`settings.legacyKeyTooltip`,`Created before per-user ownership; recreate to use cloud access`),children:i(`settings.legacyKey`,`Legacy`)})]}),(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>Re(e.id),children:(0,G.jsx)(Au,{className:`w-4 h-4 text-red-600 dark:text-red-400`})})]})]})})},e.id))}):(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-12`,children:(0,G.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,G.jsx)(Vc,{className:`w-16 h-16 mx-auto mb-4 opacity-30`}),(0,G.jsx)(`p`,{className:`text-lg font-medium text-white mb-2`,children:i(`settings.apiKeysEmptyTitle`)}),(0,G.jsx)(`p`,{className:`text-sm mb-4`,children:i(`settings.apiKeysEmptyDescription`)}),(0,G.jsxs)(Q,{onClick:()=>Oe(!0),children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.createFirstKey`)]})]})})}),(0,G.jsxs)(jd,{className:`mt-6`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h3`,{className:`text-base font-semibold text-white`,id:`card-webhooks`,children:i(`settings.webhookEndpoints`)})}),(0,G.jsxs)(Nd,{className:`space-y-3 text-sm`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:i(`settings.webhookApiKeyHint`)}),(0,G.jsxs)(`div`,{className:`space-y-2 font-mono text-xs`,children:[(0,G.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,G.jsx)(`span`,{className:`text-blue-700 dark:text-blue-400`,children:`GET`}),` `,(0,G.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/status`}),(0,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.getAllStatus`)]})]}),(0,G.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,G.jsx)(`span`,{className:`text-blue-700 dark:text-blue-400`,children:`GET`}),` `,(0,G.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/status/:id`}),(0,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.getSpecificStatus`)]})]}),(0,G.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,G.jsx)(`span`,{className:`text-green-700 dark:text-green-400`,children:`POST`}),` `,(0,G.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/queue`}),(0,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.addToQueue`)]})]}),(0,G.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,G.jsx)(`span`,{className:`text-orange-700 dark:text-orange-400`,children:`POST`}),` `,(0,G.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/printer/:id/pause`}),(0,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.pausePrint`)]})]}),(0,G.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,G.jsx)(`span`,{className:`text-orange-700 dark:text-orange-400`,children:`POST`}),` `,(0,G.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/printer/:id/resume`}),(0,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.resumePrint`)]})]}),(0,G.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:`POST`}),` `,(0,G.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/printer/:id/stop`}),(0,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.stopPrint`)]})]})]})]})]})]}),(0,G.jsxs)(jd,{className:`mt-6`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,id:`card-camera-tokens`,children:[(0,G.jsx)(Vu,{className:`w-4 h-4 text-bambu-green`}),i(`cameraTokens.title`,`Camera API Tokens`)]})}),(0,G.jsx)(Nd,{children:(0,G.jsx)(TVe,{})})]}),(0,G.jsxs)(jd,{className:`mt-6`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,id:`card-stream-overlay`,children:[(0,G.jsx)(dl,{className:`w-4 h-4 text-bambu-green`}),i(`streamOverlay.builder.title`,`Streaming Overlay`)]})}),(0,G.jsx)(Nd,{children:(0,G.jsx)(DVe,{})})]})]}),d(`api_keys:read`)&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-6`,children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-apibrowser`,children:[(0,G.jsx)(Ec,{className:`w-5 h-5 text-bambu-green`}),i(`settings.apiBrowser`)]}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.apiBrowserDescription`)})]}),(0,G.jsx)(jd,{className:`mb-4`,children:(0,G.jsxs)(Nd,{className:`py-3`,children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:i(`settings.apiKeyForTesting`)}),(0,G.jsx)(`input`,{type:`text`,value:ze,onChange:e=>Be(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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-2`,children:i(`settings.apiKeyHint`)})]})}),(0,G.jsx)(UHe,{apiKey:ze})]})]}),ye===`virtual-printer`&&(0,G.jsx)(`div`,{id:`card-vp`,children:(0,G.jsx)(vHe,{})}),ye===`spoolbuddy`&&(0,G.jsx)(`div`,{id:`card-spoolbuddy`,children:(0,G.jsx)(bHe,{})}),ye===`queue`&&(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex gap-1 border-b border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`button`,{onClick:()=>Ee(`dispatch`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${Ce===`dispatch`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Jc,{className:`w-4 h-4`}),i(`settings.tabs.queueDispatch`,`Queue & Dispatch`)]}),(0,G.jsxs)(`button`,{onClick:()=>Ee(`pipelines`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${Ce===`pipelines`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Xu,{className:`w-4 h-4`}),i(`settings.tabs.queuePipelines`,`Pipelines`)]})]}),Ce===`pipelines`&&(0,G.jsx)(_Ve,{}),Ce===`dispatch`&&A&&(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,G.jsxs)(`div`,{className:`lg:w-1/2 space-y-3`,children:[(0,G.jsxs)(jd,{id:`card-print-options`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Jc,{className:`w-4 h-4 text-bambu-green`}),i(`settings.defaultPrintOptions`,`Default Print Options`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.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,tristate:!0},{key:`default_flow_cali`,label:i(`settings.defaultFlowCali`,`Flow Calibration`),desc:i(`settings.defaultFlowCaliDesc`,`Calibrate extrusion flow`),fallback:!1,dualNozzleOnly:!1,tristate:!0},{key:`default_vibration_cali`,label:i(`settings.defaultVibrationCali`,`Vibration Calibration`),desc:i(`settings.defaultVibrationCaliDesc`,`Reduce ringing artifacts`),fallback:!0,dualNozzleOnly:!1,tristate:!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,tristate:!1},{key:`default_timelapse`,label:i(`settings.defaultTimelapse`,`Timelapse`),desc:i(`settings.defaultTimelapseDesc`,`Record timelapse video`),fallback:!1,dualNozzleOnly:!1,tristate:!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,tristate:!0}].filter(({dualNozzleOnly:e})=>!e||(Yt||[]).some(e=>e.nozzle_count===2)).map(({key:e,label:t,desc:n,fallback:r,tristate:a})=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex-1 mr-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white`,children:t}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:n})]}),a?(0,G.jsx)(`div`,{className:`flex gap-1 shrink-0`,children:LW.map(t=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>tr(e,t),className:`px-2.5 py-1 text-xs rounded transition-colors ${(A[e]??`auto`)===t?RW[t]:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,children:i(`settings.calibrationMode_${t}`)},t))}):(0,G.jsx)(`div`,{className:`flex gap-1 shrink-0`,children:[`off`,`on`].map(t=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>tr(e,t===`on`),className:`px-2.5 py-1 text-xs rounded transition-colors ${(A[e]??r?`on`:`off`)===t?RW[t]:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,children:i(`settings.calibrationMode_${t}`)},t))})]},e))]})]}),(0,G.jsxs)(jd,{id:`card-plate`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(ru,{className:`w-4 h-4 text-bambu-green`}),i(`settings.plateClear`,`Plate-Clear Confirmation`)]})}),(0,G.jsx)(Nd,{className:`space-y-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex-1 mr-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white`,children:i(`settings.requirePlateClear`,`Require plate-clear confirmation`)}),(0,G.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,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.require_plate_clear??!1,onChange:e=>tr(`require_plate_clear`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(jd,{id:`card-temp-fan-presets`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Ou,{className:`w-4 h-4 text-bambu-green`}),i(`settings.tempFanPresetsTitle`,`Temperature & Fan Presets`)]})}),(0,G.jsxs)(Nd,{className:`space-y-4`,children:[(0,G.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.`)}),Pee.map(e=>{let t=gm(A?.[e.key]??``,e.defaults,e.lo,e.hi),n=e.unit===`C`?`°C`:`%`;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.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,G.jsxs)(`span`,{className:`text-bambu-gray text-xs`,children:[`(`,n,` · `,e.lo,`–`,e.hi,`)`]})]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>tr(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,G.jsx)(Bl,{className:`w-3.5 h-3.5`})})]}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:[0,1,2].map(n=>(0,G.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)),tr(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,G.jsxs)(jd,{id:`card-staggered`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Uc,{className:`w-4 h-4 text-bambu-green`}),i(`settings.staggeredStart`,`Staggered Start`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.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,G.jsxs)(`div`,{className:`flex gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.staggerGroupSize`,`Group size`)}),(0,G.jsx)(`input`,{type:`number`,min:1,max:50,value:A.stagger_group_size??2,onChange:e=>tr(`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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.staggerGroupSizeHelp`,`Printers to start simultaneously per group`)})]}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.staggerInterval`,`Interval (minutes)`)}),(0,G.jsx)(`input`,{type:`number`,min:1,max:60,value:A.stagger_interval_minutes??5,onChange:e=>tr(`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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.staggerIntervalHelp`,`Delay between each group starting`)})]})]})]})]}),(0,G.jsxs)(jd,{id:`card-concurrent-uploads`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(js,{className:`w-4 h-4 text-bambu-green`}),i(`settings.concurrentUploadsTitle`,`Concurrent Uploads`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.concurrentUploadsDescription`,`How many printers the queue may send files to at the same time. Printers receive files slowly (a large print can take several minutes), and each one waits its turn — so on a bigger fleet, raising this is what stops the last printer in a batch from waiting out every transfer before it. Lower it if your network or Bambuddy host struggles with parallel transfers.`)}),(0,G.jsxs)(`div`,{className:`w-full sm:w-1/2`,children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.concurrentUploadsLabel`,`Printers uploaded to at once`)}),(0,G.jsx)(`input`,{type:`number`,min:1,max:16,value:A.queue_max_concurrent_uploads??4,onChange:e=>tr(`queue_max_concurrent_uploads`,Math.max(1,Math.min(16,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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.concurrentUploadsHelp`,`1 sends to one printer at a time (the old behaviour). Default is 4.`)})]})]})]}),(0,G.jsxs)(jd,{id:`card-preheat`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(dc,{className:`w-4 h-4 text-amber-600 dark:text-amber-400`}),i(`settings.preheatTitle`,`Preheat & Heat Soak`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.preheatDescription`,`Heat the bed (and chamber, if supported) and hold at temperature before each queued print starts. Helpful for engineering filaments (PA, ABS) on printers without an active chamber heater — the bed warms the chamber by radiation while the soak timer runs. The bed target is read from the print file; chamber behaviour depends on printer model.`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex-1 mr-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white`,children:i(`settings.preheatEnabled`,`Enable preheat & soak`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.preheatEnabledDesc`,`When off, queued prints dispatch immediately.`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.preheat_enabled??!1,onChange:e=>tr(`preheat_enabled`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 pt-1`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.preheatMaxWait`,`Max wait (seconds)`)}),(0,G.jsx)(`input`,{type:`number`,min:60,max:3600,value:A.preheat_max_wait_seconds??900,onChange:e=>tr(`preheat_max_wait_seconds`,Math.max(60,Math.min(3600,parseInt(e.target.value)||900))),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 disabled:opacity-50`,disabled:!(A.preheat_enabled??!1)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.preheatMaxWaitHelp`,`Cap on the chamber warm-up phase before falling through.`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.preheatSoak`,`Soak (seconds)`)}),(0,G.jsx)(`input`,{type:`number`,min:0,max:1800,value:A.preheat_soak_seconds??300,onChange:e=>tr(`preheat_soak_seconds`,Math.max(0,Math.min(1800,parseInt(e.target.value)||0))),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 disabled:opacity-50`,disabled:!(A.preheat_enabled??!1)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.preheatSoakHelp`,`Hold time after target reached or max-wait elapsed.`)})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-2 border-t border-bambu-dark-tertiary/50`,children:[(0,G.jsxs)(`div`,{className:`flex-1 mr-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white`,children:i(`settings.keepBedWarm`,`Keep bed warm between prints`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.keepBedWarmDesc`,`While awaiting plate-clear, hold the bed at the keep-warm temperature below so the chamber stays hot — or at the next print's own bed temperature when that is higher. Only applies when the next print needs chamber heating (ASA, ABS, PA, PC etc.). Requires plate-clear confirmation to be enabled.`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.queue_keep_bed_warm??!1,onChange:e=>tr(`queue_keep_bed_warm`,e.target.checked),className:`sr-only peer`,disabled:!(A.preheat_enabled??!1)||!(A.require_plate_clear??!1)}),(0,G.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:opacity-50 peer-disabled:cursor-not-allowed`})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 mt-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.keepWarmBedTemp`,`Keep-warm bed temperature (°C)`)}),(0,G.jsx)(`input`,{type:`number`,min:40,max:110,value:A.queue_keep_warm_bed_temp??90,onChange:e=>tr(`queue_keep_warm_bed_temp`,Math.max(40,Math.min(110,parseInt(e.target.value)||90))),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 disabled:opacity-50`,disabled:!(A.preheat_enabled??!1)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.keepWarmBedTempHelp`,`Used whenever the bed's job is to heat the chamber — the keep-warm hold, and preheat when the print file carries no bed temperature. A higher bed temperature from the print file always wins.`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.keepWarmMaxMinutes`,`Stop keeping warm after (minutes)`)}),(0,G.jsx)(`input`,{type:`number`,min:5,max:480,value:A.queue_keep_warm_max_minutes??120,onChange:e=>tr(`queue_keep_warm_max_minutes`,Math.max(5,Math.min(480,parseInt(e.target.value)||120))),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 disabled:opacity-50`,disabled:!(A.queue_keep_bed_warm??!1)||!(A.preheat_enabled??!1)||!(A.require_plate_clear??!1)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.keepWarmMaxMinutesHelp`,`If the plate is not cleared within this time, the heaters are switched off rather than held indefinitely.`)})]})]}),(0,G.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary/50`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,G.jsx)(`label`,{className:`text-sm text-white`,children:i(`settings.preheatFilamentTargetsLabel`,`Per-filament chamber target (°C)`)}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>tr(`preheat_filament_targets`,``),title:i(`settings.preheatFilamentTargetsReset`,`Reset to defaults`),className:`text-bambu-gray hover:text-white transition-colors p-1 rounded hover:bg-bambu-dark-tertiary`,children:(0,G.jsx)(Bl,{className:`w-3.5 h-3.5`})})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:i(`settings.preheatFilamentTargetsHint`,`Bambuddy picks the highest target across the loaded AMS slots; PLA-only prints derive 0 and skip the chamber phase automatically.`)}),(0,G.jsx)(hVe,{value:A.preheat_filament_targets??``,onChange:e=>tr(`preheat_filament_targets`,e),disabled:!(A.preheat_enabled??!1)})]}),(0,G.jsxs)(`p`,{className:`text-xs text-bambu-gray pt-1 border-t border-bambu-dark-tertiary/50`,children:[(0,G.jsx)(`span`,{className:`font-medium text-bambu-gray/90`,children:i(`settings.preheatHardwareTitle`,`Per-printer behaviour:`)}),` `,i(`settings.preheatHardwareDetail`,`H2C/H2D/H2D Pro/H2S/X2D/X1E actively heat the chamber via M141. X1C/P2S read chamber temp but rely on bed-radiation heating. P1S/P1P/A1/A1 Mini have no chamber sensor — only the soak timer applies.`)]})]})]})]}),(0,G.jsxs)(`div`,{className:`lg:w-1/2 space-y-3`,children:[(0,G.jsxs)(jd,{id:`card-pipelines`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Xu,{className:`w-4 h-4 text-bambu-green`}),i(`settings.pipelineLimits.title`,`Slicer Pipeline limits`)]})}),(0,G.jsx)(Nd,{className:`space-y-2`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white`,children:i(`settings.pipelineLimits.maxCopiesLabel`,`Max copies per run`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.pipelineLimits.maxCopiesDesc`,`Upper bound on the copies operators can request when running a pipeline. Server-side hard cap is 1000.`)})]}),(0,G.jsx)(`input`,{type:`number`,min:1,max:1e3,value:A.pipeline_max_copies??50,onChange:e=>{let t=parseInt(e.target.value,10);Number.isNaN(t)||tr(`pipeline_max_copies`,Math.max(1,Math.min(1e3,t)))},"aria-label":i(`settings.pipelineLimits.maxCopiesLabel`,`Max copies per run`),className:`w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm`})]})})]}),(0,G.jsxs)(jd,{id:`card-slicer`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Is,{className:`w-4 h-4 text-bambu-green`}),i(`settings.slicerCard`,`Slicer`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[GHe()&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.sliceEngine`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`select`,{value:k8(A.slice_engine),onChange:e=>tr(`slice_engine`,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:O8().map(e=>(0,G.jsx)(`option`,{value:e.id,children:i(e.labelKey)},e.id))}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(O8().find(e=>e.id===k8(A.slice_engine))?.descriptionKey??`settings.sliceEngineSidecarHint`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.preferredSlicer`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`select`,{value:A.preferred_slicer??`bambu_studio`,onChange:e=>tr(`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,G.jsx)(`option`,{value:`bambu_studio`,children:i(`settings.slicerBambuStudio`)}),(0,G.jsx)(`option`,{value:`orcaslicer`,children:i(`settings.slicerOrcaSlicer`)})]}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.preferredSlicerDescription`)}),(A.preferred_slicer??`bambu_studio`)===`orcaslicer`&&(0,G.jsx)(`div`,{role:`alert`,className:`text-xs text-amber-800 dark:text-amber-200 bg-amber-50 dark:bg-amber-900/20 border border-amber-300 dark: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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.openInSlicerLabel`,`Open in Slicer`)}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsxs)(`select`,{value:A.open_in_slicer??``,onChange:e=>tr(`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,G.jsx)(`option`,{value:``,children:i(`settings.openInSlicerInherit`,`Same as API slicer`)}),(0,G.jsx)(`option`,{value:`bambu_studio`,children:i(`settings.slicerBambuStudio`)}),(0,G.jsx)(`option`,{value:`orcaslicer`,children:i(`settings.slicerOrcaSlicer`)})]}),(0,G.jsx)(ds,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.useSlicerApi`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.useSlicerApiDescription`)})]}),(0,G.jsxs)(`label`,{className:`flex items-center cursor-pointer shrink-0`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.use_slicer_api??!1,onChange:e=>tr(`use_slicer_api`,e.target.checked),className:`sr-only peer`}),(0,G.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`})]})]}),(A.use_slicer_api??!1)&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:(A.preferred_slicer??`bambu_studio`)===`orcaslicer`?i(`settings.orcaslicerApiUrl`,`OrcaSlicer sidecar URL`):i(`settings.bambuStudioApiUrl`,`Bambu Studio sidecar URL`)}),(0,G.jsx)(`input`,{type:`text`,value:((A.preferred_slicer??`bambu_studio`)===`orcaslicer`?A.orcaslicer_api_url:A.bambu_studio_api_url)??``,onChange:e=>tr((A.preferred_slicer??`bambu_studio`)===`orcaslicer`?`orcaslicer_api_url`:`bambu_studio_api_url`,e.target.value),placeholder:(A.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,G.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.`)})]}),(A.use_slicer_api??!1)&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.slicerStallTimeout`)}),(0,G.jsx)(`input`,{type:`number`,min:1,max:240,value:A.slicer_stall_timeout_minutes??15,onChange:e=>tr(`slicer_stall_timeout_minutes`,Number(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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.slicerStallTimeoutDescription`)})]})]})]}),(0,G.jsxs)(jd,{children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,id:`card-drying`,children:[(0,G.jsx)(dc,{className:`w-4 h-4 text-amber-600 dark:text-amber-400`}),i(`settings.queueDrying`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.queueDryingDescription`)}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-white`,children:i(`settings.queueDryingEnabled`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.queueDryingEnabledDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.queue_drying_enabled??!1,onChange:e=>tr(`queue_drying_enabled`,e.target.checked),className:`sr-only peer`}),(0,G.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.queue_drying_enabled&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-white`,children:i(`settings.queueDryingBlock`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.queueDryingBlockDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.queue_drying_block??!1,onChange:e=>tr(`queue_drying_block`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-white`,children:i(`settings.ambientDryingEnabled`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.ambientDryingEnabledDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.ambient_drying_enabled??!1,onChange:e=>tr(`ambient_drying_enabled`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-white`,children:i(`settings.printDryingEnabled`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.printDryingEnabledDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.print_drying_enabled??!1,onChange:e=>tr(`print_drying_enabled`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white font-medium`,children:i(`settings.dryingPresets`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.dryingPresetsDescription`)}),(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,G.jsx)(`th`,{className:`text-left py-1.5`,children:i(`settings.dryingFilament`)}),(0,G.jsx)(`th`,{className:`text-center py-1.5`,colSpan:2,children:`AMS 2 Pro`}),(0,G.jsx)(`th`,{className:`text-center py-1.5`,colSpan:2,children:`AMS-HT`})]})}),(0,G.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(A.drying_presets){let n=JSON.parse(A.drying_presets);typeof n==`object`&&n&&(t={...e,...n})}}catch{}let n=(e,n,r)=>{let i={...t,[e]:{...t[e],[n]:r}};tr(`drying_presets`,JSON.stringify(i))};return Object.entries(t).map(([e,t])=>(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50`,children:[(0,G.jsx)(`td`,{className:`py-1.5 pr-2 text-white font-medium`,children:e}),(0,G.jsx)(`td`,{className:`py-1 px-1`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,G.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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})}),(0,G.jsx)(`td`,{className:`py-1 px-1`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`h`})]})}),(0,G.jsx)(`td`,{className:`py-1 px-1`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,G.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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})}),(0,G.jsx)(`td`,{className:`py-1 px-1`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`h`})]})})]},e))})()})]})})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-sm text-white font-medium`,children:i(`settings.humidityThresholds`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.humidityThresholdsDescription`)}),(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,G.jsx)(`th`,{className:`text-left py-1.5`,children:i(`settings.dryingFilament`)}),(0,G.jsx)(`th`,{className:`text-right py-1.5 pr-2`,children:i(`settings.humidityThresholdCol`)})]})}),(0,G.jsx)(`tbody`,{children:(()=>{let e=A.ams_humidity_fair??60,t=[`PLA`,`PETG`,`TPU`,`ABS`,`ASA`,`PA`,`PC`,`PVA`],n={};try{if(A.ams_humidity_thresholds){let e=JSON.parse(A.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],tr(`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};tr(`ams_humidity_thresholds`,JSON.stringify(a))};return r.map(e=>{let t=M[e.key],n=t===void 0?String(e.value):t;return(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50`,children:[(0,G.jsx)(`td`,{className:`py-1.5 pr-2 font-medium ${e.isDefault?`text-bambu-gray italic`:`text-white`}`,children:e.label}),(0,G.jsx)(`td`,{className:`py-1 pr-2`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,G.jsx)(`input`,{type:`number`,min:5,max:95,value:n,onChange:t=>N(n=>({...n,[e.key]:t.target.value})),onBlur:t=>{a(e.key,t.target.value),N(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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`%`})]})})]},e.key)})})()})]})})]})]})]}),(0,G.jsxs)(jd,{id:`card-gcode`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Ns,{className:`w-4 h-4 text-bambu-green`}),i(`settings.gcodeInjection`,`G-code Injection`)]})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.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 A.gcode_snippets?JSON.parse(A.gcode_snippets):{}}catch{return{}}})(),t=[...new Set((Yt||[]).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):``;j(e=>e?{...e,gcode_snippets:a}:null),Yn.current=a},r=()=>{Yn.current!==null&&($n.mutate({gcode_snippets:Yn.current}),Yn.current=null)};return t.length===0?(0,G.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,G.jsx)(Vp,{defaultOpen:o,className:`border border-bambu-dark-tertiary rounded-lg px-3 py-2`,summary:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:t}),o&&(0,G.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,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.gcodeStartLabel`,`Start G-code`)}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.gcodeEndLabel`,`End G-code`)}),(0,G.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)})})()]})]})]})]})]}),ye===`filament`&&A&&(0,G.jsx)(G.Fragment,{children:(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,G.jsxs)(`div`,{className:`lg:w-1/3 space-y-3`,children:[(0,G.jsx)($Ve,{}),(0,G.jsxs)(jd,{id:`card-filamentchecks`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.filamentChecks`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.disableFilamentWarnings`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.disableFilamentWarningsDesc`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.disable_filament_warnings,onChange:e=>tr(`disable_filament_warnings`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.preferLowestFilament`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.preferLowestFilamentDesc`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1`,children:i(`settings.preferLowestFilamentBackupNote`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.prefer_lowest_filament,onChange:e=>tr(`prefer_lowest_filament`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(jd,{id:`card-printmodal`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.printModal`)})}),(0,G.jsx)(Nd,{className:`space-y-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.expandCustomMapping`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.expandCustomMappingDescription`)})]}),(0,G.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.per_printer_mapping_expanded??!1,onChange:e=>tr(`per_printer_mapping_expanded`,e.target.checked),className:`sr-only peer`}),(0,G.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,G.jsxs)(jd,{id:`card-amsthresholds`,children:[(0,G.jsx)(Md,{children:(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.amsDisplayThresholds`)})}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.amsThresholdsDescription`)}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-white`,children:[(0,G.jsx)(Ys,{className:`w-4 h-4 text-blue-600 dark:text-blue-400`}),(0,G.jsx)(`span`,{className:`font-medium`,children:i(`settings.humidity`)})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.goodGreen`),` ≤`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:A.ams_humidity_good??40,onChange:e=>tr(`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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`%`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.fairOrange`),` ≤`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:A.ams_humidity_fair??60,onChange:e=>tr(`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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`%`})]})]})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.aboveFairBad`)}),(0,G.jsx)(`p`,{className:`text-xs text-amber-700/80 dark:text-amber-400/70`,children:i(`settings.fairAlsoDryingThreshold`)}),(A.ams_humidity_fair??60)tr(`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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.fairOrange`),` ≤`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,step:`0.5`,min:`0`,max:`60`,value:A.ams_temp_fair??35,onChange:e=>tr(`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,G.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})]})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.aboveFairHot`)})]}),(0,G.jsxs)(`div`,{className:`space-y-3 pt-4 border-t border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-white`,children:[(0,G.jsx)(Us,{className:`w-4 h-4 text-purple-600 dark:text-purple-400`}),(0,G.jsx)(`span`,{className:`font-medium`,children:i(`settings.historyRetention`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.keepSensorHistory`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:`1`,max:`365`,value:A.ams_history_retention_days??30,onChange:e=>tr(`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,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`common.days`)})]})]}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.historyRetentionDescription`)})]})]})]})]}),(0,G.jsxs)(`div`,{className:`lg:w-2/3 space-y-3`,children:[(0,G.jsx)(eHe,{}),(0,G.jsx)(uHe,{})]})]})}),Le!==null&&(0,G.jsx)(Xd,{title:i(`settings.deleteApiKeyTitle`),message:i(`settings.deleteApiKeyMessage`),confirmText:i(`settings.deleteKey`),variant:`danger`,onConfirm:()=>{Jt.mutate(Le),Re(null)},onCancel:()=>Re(null)}),P&&(0,G.jsx)(kVe,{plug:I,onClose:()=>{F(!1),L(null)}}),R&&(0,G.jsx)(jVe,{sensor:B,printers:Yt??[],onClose:()=>{z(!1),V(null)}}),ee&&(0,G.jsx)(PVe,{provider:ne,onClose:()=>{te(!1),re(null)}}),ie&&(0,G.jsx)(FVe,{template:ie,onClose:()=>ae(null)}),le&&(0,G.jsx)(LVe,{onClose:()=>ue(!1)}),Ve&&(0,G.jsx)(Xd,{title:i(`settings.clearNotificationLogs`),message:i(`settings.clearLogsMessage`),confirmText:i(`settings.clearLogs`),variant:`warning`,onConfirm:async()=>{He(!1);try{o((await Z.clearNotificationLogs(30)).message,`success`)}catch{o(i(`settings.toast.clearLogsFailed`),`error`)}},onCancel:()=>He(!1)}),Ue&&(0,G.jsx)(Xd,{title:i(`settings.resetUiPreferences`),message:i(`settings.resetUiPreferencesMessage`),confirmText:i(`settings.resetPreferences`),variant:`default`,onConfirm:()=>{We(!1),localStorage.clear(),o(i(`settings.toast.uiPreferencesReset`),`success`),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>We(!1)}),Ge&&(0,G.jsx)(Xd,{title:`Turn All Plugs ${Ge===`on`?`On`:`Off`}`,message:`This will turn ${Ge===`on`?`ON`:`OFF`} all ${zt?.filter(e=>e.enabled).length||0} enabled smart plugs. ${Ge===`off`?`Any running printers may be affected!`:``}`,confirmText:`Turn All ${Ge===`on`?`On`:`Off`}`,variant:Ge===`off`?`danger`:`warning`,onConfirm:()=>{let e=Ge;Ke(null),qn.mutate(e)},onCancel:()=>Ke(null)}),qe&&_n?.release_notes&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:()=>Je(!1),children:(0,G.jsxs)(jd,{className:`w-full max-w-2xl max-h-[80vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(Md,{className:`flex flex-row items-center justify-between shrink-0`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h2`,{className:`text-lg font-semibold text-white`,children:[`Release Notes - v`,_n.latest_version]}),_n.release_name&&_n.release_name!==_n.latest_version&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:_n.release_name})]}),(0,G.jsx)(`button`,{onClick:()=>Je(!1),className:`p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white`,children:(0,G.jsx)(Qu,{className:`w-5 h-5`})})]}),(0,G.jsx)(Nd,{className:`overflow-y-auto flex-1`,children:(0,G.jsx)(`pre`,{className:`text-sm text-bambu-gray whitespace-pre-wrap font-sans`,children:_n.release_notes})}),(0,G.jsxs)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2`,children:[_n.release_url&&(0,G.jsx)(`a`,{href:_n.release_url,target:`_blank`,rel:`noopener noreferrer`,className:`flex-1`,children:(0,G.jsxs)(Q,{variant:`secondary`,className:`w-full`,children:[(0,G.jsx)(ec,{className:`w-4 h-4`}),`View on GitHub`]})}),(0,G.jsx)(Q,{onClick:()=>Je(!1),className:`flex-1`,children:`Close`})]})]})}),ye===`users`&&(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex gap-1 border-b border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`button`,{onClick:()=>Se(`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 ${xe===`users`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(zu,{className:`w-4 h-4`}),i(`settings.tabs.users`)]}),(0,G.jsxs)(`button`,{onClick:()=>Se(`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 ${xe===`email`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(tl,{className:`w-4 h-4`}),i(`settings.tabs.emailAuth`)||`Email Authentication`,Tn?.advanced_auth_enabled&&(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green-400`})]}),(0,G.jsxs)(`button`,{onClick:()=>Se(`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 ${xe===`ldap`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(ru,{className:`w-4 h-4`}),i(`settings.tabs.ldap`)||`LDAP`,En?.ldap_enabled&&(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green-400`})]}),(0,G.jsxs)(`button`,{onClick:()=>Se(`twofa`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${xe===`twofa`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(ru,{className:`w-4 h-4`}),i(`settings.tabs.twoFa`),(0,G.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,G.jsxs)(`button`,{onClick:()=>Se(`oidc`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${xe===`oidc`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(Ec,{className:`w-4 h-4`}),i(`settings.tabs.oidc`),(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full ${On.some(e=>e.is_enabled)?`bg-green-400`:`bg-bambu-gray/40`}`})]}),l&&(0,G.jsxs)(`button`,{onClick:()=>Se(`security`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${xe===`security`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,G.jsx)(ru,{className:`w-4 h-4`}),i(`settings.tabs.security`)]})]}),xe===`users`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-4`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.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,G.jsx)(Qc,{className:`w-5 h-5 text-green-600 dark:text-green-400`}):(0,G.jsx)(Zc,{className:`w-5 h-5 text-gray-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-white font-medium`,children:i(`settings.authentication`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(s?`settings.authEnabledDescription`:`settings.authDisabledDescription`)})]})]}),s?c?.is_admin&&(0,G.jsxs)(Q,{variant:`secondary`,onClick:()=>Xe(!0),children:[(0,G.jsx)(Zc,{className:`w-4 h-4`}),i(`common.disable`)]}):(0,G.jsxs)(Q,{onClick:()=>t(`/setup`),children:[(0,G.jsx)(Qc,{className:`w-4 h-4`}),i(`common.enable`)]})]})})}),Tn?.advanced_auth_enabled&&(0,G.jsx)(jd,{className:`border-blue-500/30 bg-blue-500/5`,children:(0,G.jsx)(Nd,{className:`py-4`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center bg-blue-500/20 flex-shrink-0`,children:(0,G.jsx)(tl,{className:`w-5 h-5 text-blue-600 dark:text-blue-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-white font-medium`,children:i(`settings.email.advancedAuthEnabled`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.email.advancedAuthEnabledDesc`)})]})]})})}),s&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-2 gap-6`,children:[(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(jd,{id:`card-session-policy`,children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,G.jsx)(Qc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.sessionPolicy.title`)]})}),(0,G.jsxs)(Nd,{children:[(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:i(`settings.sessionPolicy.description`)}),(0,G.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=(A?.session_max_hours??24)===e.hours;return(0,G.jsx)(`button`,{type:`button`,onClick:()=>tr(`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,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`input`,{type:`number`,min:1,max:720,value:A?.session_max_hours??24,onChange:e=>{let t=parseInt(e.target.value,10);Number.isNaN(t)||tr(`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,G.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:i(`settings.sessionPolicy.hoursSuffix`)})]})]}),(A?.session_max_hours??24)>24&&(0,G.jsxs)(`div`,{className:`flex items-start gap-2 p-3 rounded-lg bg-yellow-50 dark:bg-yellow-500/10 border border-yellow-300 dark:border-yellow-500/30`,children:[(0,G.jsx)(Nu,{className:`w-4 h-4 text-yellow-600 dark:text-yellow-400 flex-shrink-0 mt-0.5`}),(0,G.jsx)(`p`,{className:`text-xs text-yellow-800 dark:text-yellow-200`,children:i(`settings.sessionPolicy.warning`)})]})]})]}),c&&(0,G.jsxs)(jd,{children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-currentuser`,children:[(0,G.jsx)(zu,{className:`w-5 h-5 text-bambu-green`}),i(`settings.currentUser`)]}),c.auth_source!==`ldap`&&(0,G.jsxs)(Q,{size:`sm`,variant:`ghost`,onClick:()=>Qe(!0),children:[(0,G.jsx)(Vc,{className:`w-4 h-4`}),i(`settings.changePassword`)]})]})}),(0,G.jsx)(Nd,{children:(0,G.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-white font-medium text-lg`,children:c.username}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:[c.is_admin&&(0,G.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-300`,children:i(`settings.admin`)}),c.groups?.map(e=>(0,G.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium ${e.name===`Administrators`?`bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-300`:e.name===`Operators`?`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-300`:e.name===`Viewers`?`bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-300`:`bg-gray-500/20 text-gray-300`}`,children:e.name},e.id))]})]})})})]}),(0,G.jsxs)(jd,{children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-users`,children:[(0,G.jsx)(zu,{className:`w-5 h-5 text-bambu-green`}),i(`settings.users`)]}),d(`users:create`)&&(0,G.jsxs)(Q,{size:`sm`,onClick:()=>{ot(!0),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.addUser`)]})]})}),(0,G.jsx)(Nd,{children:An?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(Y,{className:`w-6 h-6 text-bambu-green animate-spin`})}):kn.length===0?(0,G.jsx)(`p`,{className:`text-center text-bambu-gray py-8`,children:i(`settings.noUsersFound`)}):(0,G.jsx)(`div`,{className:`divide-y divide-bambu-dark-tertiary`,children:kn.map(e=>(0,G.jsxs)(`div`,{className:`py-3 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-white font-medium truncate`,children:e.username}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[e.auth_source===`ldap`&&(0,G.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium bg-cyan-100 dark:bg-cyan-500/20 text-cyan-700 dark:text-cyan-300`,children:`LDAP`}),e.is_admin&&(0,G.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-300`,children:i(`settings.admin`)}),e.groups?.map(e=>(0,G.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium ${e.name===`Administrators`?`bg-purple-100 dark:bg-purple-500/20 text-purple-700 dark:text-purple-300`:e.name===`Operators`?`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-300`:e.name===`Viewers`?`bg-green-100 dark:bg-green-500/20 text-green-700 dark:text-green-300`:`bg-gray-500/20 text-gray-300`}`,children:e.name},e.id))]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 ml-4`,children:[d(`users:update`)&&(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>Vn(e),children:(0,G.jsx)(Tl,{className:`w-4 h-4`})}),d(`users:delete`)&&e.id!==c?.id&&(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>Ln(e.id),children:(0,G.jsx)(Au,{className:`w-4 h-4`})})]})]},e.id))})})]})]}),(0,G.jsx)(`div`,{children:(0,G.jsxs)(jd,{children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-groups`,children:[(0,G.jsx)(ru,{className:`w-5 h-5 text-bambu-green`}),i(`settings.groups`)]}),d(`groups:create`)&&(0,G.jsxs)(Q,{size:`sm`,onClick:()=>t(`/groups/new`),children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.addGroup`)]})]})}),(0,G.jsx)(Nd,{children:Mn?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(Y,{className:`w-6 h-6 text-bambu-green animate-spin`})}):jn.length===0?(0,G.jsx)(`p`,{className:`text-center text-bambu-gray py-8`,children:i(`settings.noGroupsFound`)}):(0,G.jsx)(`div`,{className:`divide-y divide-bambu-dark-tertiary`,children:jn.map(e=>(0,G.jsxs)(`div`,{className:`py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ru,{className:`w-4 h-4 ${e.name===`Administrators`?`text-purple-600 dark:text-purple-400`:e.name===`Operators`?`text-blue-600 dark:text-blue-400`:e.name===`Viewers`?`text-green-600 dark:text-green-400`:`text-bambu-gray`}`}),(0,G.jsx)(`span`,{className:`text-white font-medium`,children:e.name}),e.is_system&&(0,G.jsx)(`span`,{className:`px-2 py-0.5 rounded text-xs bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400`,children:i(`settings.system`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[d(`groups:update`)&&(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>t(`/groups/${e.id}/edit`),children:(0,G.jsx)(Tl,{className:`w-4 h-4`})}),d(`groups:delete`)&&!e.is_system&&(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>St(e.id),children:(0,G.jsx)(Au,{className:`w-4 h-4`})})]})]}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1 ml-6`,children:e.description||i(`settings.noDescription`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-4 mt-2 ml-6 text-xs text-bambu-gray`,children:[(0,G.jsx)(`span`,{children:i(`settings.userCount`,{count:e.user_count})}),(0,G.jsx)(`span`,{children:i(`settings.permissionCount`,{count:e.permissions.length})})]})]},e.id))})})]})})]}),!s&&(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-6`,children:(0,G.jsxs)(`div`,{className:`text-center`,children:[(0,G.jsx)(Zc,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,G.jsx)(`h3`,{className:`text-lg font-medium text-white mb-2`,children:i(`settings.authDisabledTitle`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4 max-w-md mx-auto`,children:i(`settings.authDisabledMessage`)}),(0,G.jsxs)(`ul`,{className:`space-y-2 text-sm text-bambu-gray mb-6 text-left max-w-xs mx-auto`,children:[(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(ys,{className:`w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0`}),(0,G.jsx)(`span`,{children:i(`settings.authDisabledFeature1`)})]}),(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(ys,{className:`w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0`}),(0,G.jsx)(`span`,{children:i(`settings.authDisabledFeature2`)})]}),(0,G.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(ys,{className:`w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0`}),(0,G.jsx)(`span`,{children:i(`settings.authDisabledFeature3`)})]})]}),(0,G.jsxs)(Q,{onClick:()=>t(`/setup`),children:[(0,G.jsx)(Qc,{className:`w-4 h-4`}),i(`settings.enableAuthentication`)]})]})})})]}),xe===`email`&&(0,G.jsx)(`div`,{className:`max-w-5xl`,id:`card-smtp`,children:(0,G.jsx)(AHe,{})}),xe===`ldap`&&(0,G.jsx)(`div`,{className:`max-w-5xl`,id:`card-ldap`,children:(0,G.jsx)(MHe,{})}),xe===`twofa`&&(0,G.jsx)(`div`,{className:`max-w-2xl`,children:(0,G.jsx)(PHe,{})}),xe===`oidc`&&l&&(0,G.jsxs)(`div`,{className:`max-w-3xl space-y-4`,children:[(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`space-y-3 p-4`,children:(0,G.jsxs)(`label`,{className:`flex items-start gap-3 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:A.local_login_enabled===!1,onChange:e=>tr(`local_login_enabled`,!e.target.checked),className:`mt-1 h-4 w-4 rounded border-bambu-dark-tertiary bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green/50 cursor-pointer`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-white`,children:i(`settings.localLogin.disable`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.localLogin.disableHint`)})]})]})})}),(0,G.jsx)(LHe,{})]}),xe===`security`&&l&&(0,G.jsx)(`div`,{className:`max-w-3xl`,children:(0,G.jsx)(zHe,{})})]}),at&&!Tn?.advanced_auth_enabled&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black flex items-center justify-center z-50 p-4`,onClick:()=>{ot(!1),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,G.jsxs)(jd,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(zu,{className:`w-5 h-5 text-bambu-green`}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.createUser`)})]}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>{ot(!1),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,G.jsx)(Qu,{className:`w-5 h-5`})})]})}),(0,G.jsxs)(Nd,{children:[En?.ldap_enabled&&(0,G.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,G.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":st===`local`,onClick:()=>ct(`local`),className:`flex-1 px-3 py-2 text-sm rounded-md transition-colors ${st===`local`?`bg-bambu-green/15 text-bambu-green`:`text-bambu-gray hover:text-white`}`,children:i(`users.modal.localTab`)}),(0,G.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":st===`ldap`,onClick:()=>ct(`ldap`),className:`flex-1 px-3 py-2 text-sm rounded-md transition-colors ${st===`ldap`?`bg-bambu-green/15 text-bambu-green`:`text-bambu-gray hover:text-white`}`,children:i(`users.modal.ldapTab`)})]}),st===`ldap`&&En?.ldap_enabled?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(t8,{onSuccess:e=>{ot(!1),ct(`local`),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`users.toast.ldapProvisioned`,{username:e.username}))}}),(0,G.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{ot(!1),ct(`local`),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:i(`common.cancel`)})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.username`)}),(0,G.jsx)(`input`,{type:`text`,value:yt.username,onChange:e=>bt({...yt,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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.password`)}),(0,G.jsx)(`input`,{type:`password`,value:yt.password,onChange:e=>bt({...yt,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,G.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:i(`settings.passwordRequirements`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.confirmPassword`)}),(0,G.jsx)(`input`,{type:`password`,value:yt.confirmPassword,onChange:e=>bt({...yt,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 ${yt.confirmPassword&&yt.password!==yt.confirmPassword?`border-red-500`:`border-bambu-dark-tertiary`}`,placeholder:i(`settings.confirmPasswordPlaceholder`),autoComplete:`new-password`,minLength:6}),yt.confirmPassword&&yt.password!==yt.confirmPassword&&(0,G.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-xs mt-1`,children:i(`settings.passwordsDoNotMatch`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.groups`)}),(0,G.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:[jn.map(e=>(0,G.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:yt.group_ids.includes(e.id),onChange:()=>Hn(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,G.jsx)(`span`,{className:`text-sm text-white`,children:e.name}),e.is_system&&(0,G.jsx)(`span`,{className:`text-xs text-yellow-700 dark:text-yellow-400`,children:i(`settings.systemBadge`)})]},e.id)),jn.length===0&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.noGroupsAvailable`)})]})]})]}),(0,G.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{ot(!1),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:i(`common.cancel`)}),(0,G.jsx)(Q,{onClick:zn,disabled:Nn.isPending||!yt.username||!yt.password||yt.password!==yt.confirmPassword||T6(yt.password)!==null,children:Nn.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),i(`settings.creating`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),i(`settings.createUser`)]})})]})]})]})]})}),at&&Tn?.advanced_auth_enabled&&(0,G.jsx)(QVe,{formData:yt,setFormData:bt,groups:jn,onClose:()=>{ot(!1),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},onCreate:zn,isCreating:Nn.isPending,isCreateButtonDisabled:Nn.isPending||!yt.username||!yt.email,ldapEnabled:En?.ldap_enabled,onLdapProvisioned:e=>{ot(!1),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`users.toast.ldapProvisioned`,{username:e.username}))}}),lt&&dt!==null&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black flex items-center justify-center z-50 p-4`,onClick:()=>{ut(!1),ft(null),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,G.jsxs)(jd,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Tl,{className:`w-5 h-5 text-bambu-green`}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.editUser`)})]}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>{ut(!1),ft(null),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,G.jsx)(Qu,{className:`w-5 h-5`})})]})}),(0,G.jsxs)(Nd,{children:[(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[i(`settings.username`),` `,Tn?.advanced_auth_enabled&&(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:`*`})]}),(0,G.jsx)(`input`,{type:`text`,value:yt.username,onChange:e=>bt({...yt,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,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[i(`users.form.email`)||`Email`,` `,Tn?.advanced_auth_enabled?(0,G.jsx)(`span`,{className:`text-red-700 dark:text-red-400`,children:`*`}):(0,G.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,i(`users.form.optional`)||`optional`,`)`]})]}),(0,G.jsx)(`input`,{type:`email`,value:yt.email,onChange:e=>bt({...yt,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:Tn?.advanced_auth_enabled})]}),!Tn?.advanced_auth_enabled&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[i(`users.form.password`)||`Password`,` `,(0,G.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,i(`users.form.leaveBlankToKeep`)||`leave blank to keep current`,`)`]})]}),(0,G.jsx)(`input`,{type:`password`,value:yt.password,onChange:e=>bt({...yt,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,G.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:i(`settings.passwordRequirements`)})]}),yt.password&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.confirmPassword`)}),(0,G.jsx)(`input`,{type:`password`,value:yt.confirmPassword,onChange:e=>bt({...yt,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 ${yt.confirmPassword&&yt.password!==yt.confirmPassword?`border-red-500`:`border-bambu-dark-tertiary`}`,placeholder:i(`settings.confirmNewPassword`),autoComplete:`new-password`,minLength:6}),yt.confirmPassword&&yt.password!==yt.confirmPassword&&(0,G.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-xs mt-1`,children:i(`settings.passwordsDoNotMatch`)})]})]}),Tn?.advanced_auth_enabled&&(0,G.jsxs)(`div`,{className:`bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3 space-y-3`,children:[(0,G.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,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>dt&&In.mutate(dt),disabled:In.isPending||!yt.email,className:`w-full`,children:In.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),i(`users.form.resettingPassword`)||`Resetting Password...`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Bl,{className:`w-4 h-4`}),i(`users.form.resetPassword`)||`Reset Password`]})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`users.form.groups`)||`Groups`}),(0,G.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:jn.map(e=>(0,G.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:yt.group_ids.includes(e.id),onChange:()=>Hn(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,G.jsx)(`span`,{className:`text-sm text-white`,children:e.name}),e.is_system&&(0,G.jsxs)(`span`,{className:`text-xs text-yellow-700 dark:text-yellow-400`,children:[`(`,i(`users.system`)||`System`,`)`]})]},e.id))})]})]}),(0,G.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{ut(!1),ft(null),bt({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:i(`users.modal.cancel`)||`Cancel`}),(0,G.jsx)(Q,{onClick:()=>Bn(dt),disabled:Pn.isPending||!yt.username||Tn?.advanced_auth_enabled&&!yt.email||!!(!Tn?.advanced_auth_enabled&&yt.password&&(yt.password!==yt.confirmPassword||T6(yt.password)!==null)),children:Pn.isPending?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),i(`users.modal.saving`)||`Saving...`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ul,{className:`w-4 h-4`}),i(`users.modal.saveChanges`)||`Save Changes`]})})]})]})]})}),pt!==null&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4`,onClick:()=>{mt(null),gt(null)},children:(0,G.jsxs)(jd,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-red-700 dark:text-red-400`,children:[(0,G.jsx)(Au,{className:`w-5 h-5`}),(0,G.jsx)(`h3`,{className:`text-lg font-semibold`,children:i(`settings.deleteUserTitle`)})]})}),(0,G.jsx)(Nd,{className:`space-y-3`,children:_t?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,G.jsx)(`div`,{className:`animate-spin rounded-full h-6 w-6 border-2 border-bambu-green border-t-transparent`})}):ht&&ht.archives+ht.queue_items+ht.library_files>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.userHasCreated`)}),(0,G.jsxs)(`ul`,{className:`list-disc list-inside text-bambu-gray space-y-1`,children:[ht.archives>0&&(0,G.jsxs)(`li`,{children:[ht.archives,` archive`,ht.archives===1?``:`s`]}),ht.queue_items>0&&(0,G.jsxs)(`li`,{children:[ht.queue_items,` queue item`,ht.queue_items===1?``:`s`]}),ht.library_files>0&&(0,G.jsxs)(`li`,{children:[ht.library_files,` library file`,ht.library_files===1?``:`s`]})]}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:i(`settings.userItemsQuestion`)}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(Q,{variant:`danger`,onClick:()=>Fn.mutate({id:pt,deleteItems:!0}),disabled:Fn.isPending,className:`justify-center`,children:i(`settings.deleteUserAndItems`)}),(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>Fn.mutate({id:pt,deleteItems:!1}),disabled:Fn.isPending,className:`justify-center`,children:i(`settings.deleteUserKeepItems`)}),(0,G.jsx)(Q,{variant:`ghost`,onClick:()=>{mt(null),gt(null)},disabled:Fn.isPending,className:`justify-center`,children:i(`common.cancel`)})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`text-white`,children:i(`settings.deleteUserConfirm`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:i(`settings.actionCannotBeUndone`)}),(0,G.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,G.jsx)(Q,{variant:`ghost`,onClick:()=>{mt(null),gt(null)},disabled:Fn.isPending,children:i(`common.cancel`)}),(0,G.jsx)(Q,{variant:`danger`,onClick:()=>Fn.mutate({id:pt,deleteItems:!1}),disabled:Fn.isPending,children:i(`settings.deleteUserTitle`)})]})]})})]})}),xt!==null&&(0,G.jsx)(Xd,{title:i(`settings.deleteGroupTitle`),message:i(`settings.deleteGroupMessage`),confirmText:i(`settings.deleteGroup`),variant:`danger`,onConfirm:()=>{Rn.mutate(xt),St(null)},onCancel:()=>St(null)}),ye===`failure-detection`&&(0,G.jsx)(`div`,{id:`card-failure-detection`,children:(0,G.jsx)(DHe,{})}),ye===`backup`&&(0,G.jsxs)(`div`,{id:`card-backup`,children:[(0,G.jsxs)(`div`,{className:`mb-4 p-3 bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/30 rounded-lg flex items-start gap-2`,children:[(0,G.jsx)(ru,{className:`text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5`,size:16}),(0,G.jsx)(`p`,{className:`text-sm text-amber-700 dark:text-amber-400`,children:i(`backup.includesEncryptionKey`)})]}),(0,G.jsx)(EHe,{})]}),Ye&&(0,G.jsx)(Xd,{title:i(`settings.disableAuthenticationTitle`),message:i(`settings.disableAuthenticationMessage`),confirmText:i(`settings.disableAuthentication`),variant:`danger`,onConfirm:async()=>{try{await Z.disableAuth(),o(i(`settings.toast.authDisabled`),`success`),await u(),Xe(!1),window.location.href=`/`}catch(e){o(e instanceof Error?e.message:i(`settings.toast.authDisableFailed`),`error`)}},onCancel:()=>Xe(!1)}),Ze&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:()=>{Qe(!1),et({currentPassword:``,newPassword:``,confirmPassword:``})},children:(0,G.jsxs)(jd,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(Md,{children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Vc,{className:`w-5 h-5 text-bambu-green`}),(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.changePassword`)})]}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>{Qe(!1),et({currentPassword:``,newPassword:``,confirmPassword:``})},children:(0,G.jsx)(Qu,{className:`w-5 h-5`})})]})}),(0,G.jsxs)(Nd,{children:[(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:`Current Password`}),(0,G.jsx)(`input`,{type:`password`,value:$e.currentPassword,onChange:e=>et({...$e,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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:`New Password`}),(0,G.jsx)(`input`,{type:`password`,value:$e.newPassword,onChange:e=>et({...$e,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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:`Confirm New Password`}),(0,G.jsx)(`input`,{type:`password`,value:$e.confirmPassword,onChange:e=>et({...$e,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 ${$e.confirmPassword&&$e.newPassword!==$e.confirmPassword?`border-red-500`:`border-bambu-dark-tertiary`}`,placeholder:i(`settings.confirmNewPassword`),autoComplete:`new-password`,minLength:6}),$e.confirmPassword&&$e.newPassword!==$e.confirmPassword&&(0,G.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-xs mt-1`,children:i(`settings.passwordsDoNotMatch`)})]})]}),(0,G.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>{Qe(!1),et({currentPassword:``,newPassword:``,confirmPassword:``})},children:i(`common.cancel`)}),(0,G.jsx)(Q,{onClick:async()=>{if($e.newPassword!==$e.confirmPassword){o(i(`settings.toast.passwordsDoNotMatch`),`error`);return}if($e.newPassword.length<6){o(i(`settings.toast.passwordTooShort`),`error`);return}nt(!0);try{await Z.changePassword($e.currentPassword,$e.newPassword),o(i(`settings.toast.passwordChanged`),`success`),Qe(!1),et({currentPassword:``,newPassword:``,confirmPassword:``})}catch(e){o(e instanceof Error?e.message:`Failed to change password`,`error`)}finally{nt(!1)}},disabled:tt||!$e.currentPassword||!$e.newPassword||$e.newPassword!==$e.confirmPassword||$e.newPassword.length<6,children:tt?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}),i(`settings.changing`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Vc,{className:`w-4 h-4`}),i(`settings.changePassword`)]})})]})]})]})})]})]})]})})}var YHe=/\[(aborted|failed|cancelled):\s*([^\]]*)\]/i;function XHe(e){if(!e)return{isPartial:!1,partialType:null,cleanedDescription:null};let t=e.match(YHe);if(!t)return{isPartial:!1,partialType:null,cleanedDescription:e};let n=e.replace(t[0],``).trim();return{isPartial:!0,partialType:t[1].toLowerCase(),cleanedDescription:n||null}}function ZHe(e,t){if(!e)return`-`;let n=Uf(e);return n?n.toLocaleString(t):e}function N8(e){let t=e.trim();if(!t)return null;let n=Number.parseFloat(t);return Number.isFinite(n)?n:null}function P8(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`}var F8=`w-full px-3 py-2 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:outline-none focus:ring-1 focus:ring-bambu-green`,I8=`block text-sm font-medium text-white mb-1`,L8=`px-4 py-3 text-left text-bambu-gray font-medium`,R8=`px-4 py-3 align-top text-white`;function z8({title:e,onClose:t,children:n,size:r=`md`}){let{t:i}=U();return(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,G.jsxs)(`div`,{className:`w-full ${r===`sm`?`max-w-xl`:r===`lg`?`max-w-6xl`:`max-w-4xl`} overflow-hidden rounded-lg border border-bambu-dark-tertiary bg-bambu-dark-secondary`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-bambu-dark-tertiary px-4 py-3`,children:[(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:e}),(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:t,children:i(`common.close`,`Close`)})]}),(0,G.jsx)(`div`,{className:`max-h-[75vh] overflow-auto p-4`,children:n})]})})}function QHe(){let{t:e,i18n:t}=U(),{hasPermission:n,user:r}=Td(),{showToast:i}=zd(),a=so(),o=n(`cost_centers:read_own`),s=n(`cost_centers:read_all`),c=n(`cost_centers:create`),l=n(`cost_centers:modify`),u=n(`cost_centers:modify`),d=n(`cost_centers:modify`),f=n(`cost_centers:modify`),p=n(`users:read_slim`)||n(`users:read`),m=s||c||l||u||d||f,h=o||m,g=h,[_,v]=(0,y.useState)(``),[b,x]=(0,y.useState)(`monthly`),[S,C]=(0,y.useState)(``),[w,T]=(0,y.useState)(null),[E,D]=(0,y.useState)(`deposit`),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(null),[P,F]=(0,y.useState)(null),[I,L]=(0,y.useState)(null),[R,z]=(0,y.useState)(!0),[B,V]=(0,y.useState)(0),[ee,te]=(0,y.useState)(`all`),[ne,re]=(0,y.useState)(`all`),[ie,ae]=(0,y.useState)(!1),[oe,se]=(0,y.useState)(!1),[H,ce]=(0,y.useState)(!1),[le,ue]=(0,y.useState)(!1),[de,fe]=(0,y.useState)(`personal`),[pe,me]=(0,y.useState)(null),[he,ge]=(0,y.useState)(``),[_e,ve]=(0,y.useState)(`monthly`),[ye,be]=(0,y.useState)(``),[xe,Se]=(0,y.useState)(!1),[Ce,we]=(0,y.useState)(null),[Te,Ee]=(0,y.useState)(null),[De,Oe]=(0,y.useState)(null),[ke,Ae]=(0,y.useState)(``),[je,Me]=(0,y.useState)(``),[Ne,Pe]=(0,y.useState)(!1),[Fe,Ie]=(0,y.useState)(null),[Le,Re]=(0,y.useState)(null),[ze,Be]=(0,y.useState)(``),[Ve,He]=(0,y.useState)(``),[Ue,We]=(0,y.useState)(P8(new Date)),[Ge,Ke]=(0,y.useState)(null),[qe,Je]=(0,y.useState)(null),Ye=s||c||l||u||f&&p||d&&p;(0,y.useEffect)(()=>{Ye||fe(`personal`)},[Ye]);let{data:Xe,isLoading:Ze}=K({queryKey:[`finance`,`me`,`balance`],queryFn:Z.getMyBalance,enabled:o}),{data:Qe,isLoading:$e}=K({queryKey:[`finance`,`me`,`transactions`,50,B],queryFn:()=>Z.getMyTransactions(50,B),enabled:o}),{data:et,isLoading:tt}=K({queryKey:[`finance`,`transactions`,50,B],queryFn:()=>Z.getAllTransactions(50,B),enabled:de===`admin`&&s}),{data:nt,isLoading:rt}=K({queryKey:[`finance`,`cost-centers`,de],queryFn:()=>de===`admin`&&m?Z.listCostCenters(!0):Z.getMyCostCenters(),enabled:g}),{data:it}=K({queryKey:[`users`,`slim`],queryFn:Z.getUsersSlim,enabled:p&&(g||f||d)}),{data:at}=K({queryKey:[`finance`,`cost-center`,P],queryFn:()=>Z.getCostCenter(P),enabled:d&&P!=null});(0,y.useEffect)(()=>{!it||it.length===0||w!=null&&it.some(e=>e.id===w)||T(it[0].id)},[it,w]),(0,y.useEffect)(()=>{if(!d)return;let e=(nt||[]).filter(e=>!e.is_private);if(e.length===0){F(null);return}P!=null&&e.some(e=>e.id===P)||F(e[0].id)},[d,nt,P]),(0,y.useEffect)(()=>{if(!d||!it||it.length===0)return;let e=new Set((at?.members||[]).map(e=>e.user_id)),t=it.find(t=>!e.has(t.id));L(t?t.id:null)},[d,it,at]),(0,y.useEffect)(()=>{if(!le)return;let e=nt||[];if(e.length===0){me(null);return}pe!=null&&e.some(e=>e.id===pe)||me(e[0].id)},[le,pe,nt]),(0,y.useEffect)(()=>{if(!le||pe==null)return;let e=(nt||[]).find(e=>e.id===pe);if(e){if(ge(e.name),e.budget_mode===`total`){ve(`total`),be(e.total_budget==null?``:String(e.total_budget));return}ve(`monthly`),be(e.monthly_budget==null?``:String(e.monthly_budget))}},[le,pe,nt]);let ot=q({mutationFn:()=>Z.createCostCenter({name:_.trim(),total_budget:b===`total`?N8(S):null,monthly_budget:b===`monthly`?N8(S):null,is_active:!0}),onSuccess:()=>{a.invalidateQueries({queryKey:[`finance`]}),v(``),C(``),i(e(`finance.createdCostCenter`,`Cost center created`))},onError:t=>{i(t.message||e(`finance.createCostCenterFailed`,`Failed to create cost center`),`error`)}}),st=q({mutationFn:({costCenterId:e,value:t,mode:n})=>Z.updateCostCenterBudgets(e,{total_budget:n===`total`?N8(t):null,monthly_budget:n===`monthly`?N8(t):null})}),ct=q({mutationFn:({costCenterId:e,name:t})=>Z.updateCostCenter(e,{name:t})}),lt=q({mutationFn:e=>Z.deleteCostCenter(e)}),ut=q({mutationFn:e=>Z.deleteTransaction(e),onSuccess:()=>{a.invalidateQueries({queryKey:[`finance`]}),i(e(`finance.transactionDeleted`,`Transaction deleted`))},onError:t=>{i(t.message||e(`finance.deleteTransactionFailed`,`Failed to delete transaction`),`error`)}}),dt=q({mutationFn:e=>Z.editTransaction(e.transactionId,e.data),onSuccess:()=>{a.invalidateQueries({queryKey:[`finance`]}),i(e(`finance.transactionEdited`,`Transaction updated and ledger recalculated`)),Se(!1)},onError:t=>{i(t.message||e(`finance.editTransactionFailed`,`Failed to edit transaction`),`error`)}}),ft=q({mutationFn:e=>Z.createManualPrint(e),onSuccess:()=>{a.invalidateQueries({queryKey:[`finance`]}),i(e(`finance.manualPrintCreated`,`Manual print charge added and ledger recalculated`)),Pe(!1),Ie(null),Re(null),Be(``),He(``),We(P8(new Date))},onError:t=>{i(t.message||e(`finance.manualPrintFailed`,`Failed to create manual print`),`error`)}}),pt=q({mutationFn:e=>Z.depositUserBalance(e.userId,{amount:e.amount,description:e.description,cost_center_id:e.costCenterId??null})}),mt=q({mutationFn:e=>Z.withdrawUserBalance(e.userId,{amount:e.amount,description:e.description,cost_center_id:e.costCenterId??null})}),ht=q({mutationFn:e=>Z.upsertCostCenterMember(e.costCenterId,{user_id:e.userId,can_print:e.canPrint}),onSuccess:()=>{a.invalidateQueries({queryKey:[`finance`]}),i(e(`finance.memberSaved`,`Member saved`))},onError:t=>{i(t.message||e(`finance.memberSaveFailed`,`Failed to save member`),`error`)}}),gt=q({mutationFn:e=>Z.removeCostCenterMember(e.costCenterId,e.userId),onSuccess:()=>{a.invalidateQueries({queryKey:[`finance`]}),i(e(`finance.memberRemoved`,`Member removed`))},onError:t=>{i(t.message||e(`finance.memberRemoveFailed`,`Failed to remove member`),`error`)}}),_t=pt.isPending||mt.isPending,vt=()=>{if(!_.trim()){i(e(`finance.costCenterNameRequired`,`Cost center name is required`),`error`);return}ot.mutate()},yt=async()=>{if(pe==null){i(e(`finance.selectCostCenter`,`Please select a cost center`),`error`);return}let t=he.trim();if(!t){i(e(`finance.costCenterNameRequired`,`Cost center name is required`),`error`);return}try{l&&await ct.mutateAsync({costCenterId:pe,name:t}),u&&await st.mutateAsync({costCenterId:pe,mode:_e,value:ye}),a.invalidateQueries({queryKey:[`finance`]}),i(e(`finance.costCenterUpdated`,`Cost center updated`)),ue(!1)}catch(t){i(t.message||e(`finance.costCenterUpdateFailed`,`Failed to update cost center`),`error`)}},bt=e=>{let t=(nt||[]).find(t=>t.id===e);t&&(me(t.id),ge(t.name),t.budget_mode===`total`?(ve(`total`),be(t.total_budget==null?``:String(t.total_budget))):(ve(`monthly`),be(t.monthly_budget==null?``:String(t.monthly_budget))),ue(!0))},xt=async()=>{if(Ge)try{await lt.mutateAsync(Ge.id),a.invalidateQueries({queryKey:[`finance`]}),P===Ge.id&&F(null),i(e(`finance.costCenterDeleted`,`Cost center deleted`))}catch(t){i(t.message||e(`finance.costCenterDeleteFailed`,`Failed to delete cost center`),`error`)}finally{Ke(null)}},St=()=>{qe!=null&&ut.mutate(qe,{onSettled:()=>Je(null)})},Ct=e=>{we(e.id),Ee(e.user_id),Oe(e.cost_center_id),Ae(String(e.amount)),Me(e.description||``),Se(!0)},wt=async()=>{if(Ce==null)return;let t=ke?Number.parseFloat(ke):null;if(t!==null&&!Number.isFinite(t)){i(e(`finance.amountInvalid`,`Amount must be a valid number`),`error`);return}dt.mutate({transactionId:Ce,data:{user_id:Te||void 0,cost_center_id:De||void 0,amount:t??void 0,description:je||void 0}})},Tt=async()=>{if(Fe==null){i(e(`finance.userRequired`,`Please select a user`),`error`);return}if(Le==null){i(e(`finance.costCenterRequired`,`Please select a cost center`),`error`);return}let t=ze?Number.parseFloat(ze):null;if(t===null||!Number.isFinite(t)){i(e(`finance.amountInvalid`,`Amount must be a valid number`),`error`);return}t=Math.abs(t),ft.mutate({user_id:Fe,cost_center_id:Le,amount:t,description:Ve||void 0,created_at:Ue?new Date(Ue).toISOString():void 0})},Et=async()=>{if(w==null){i(e(`finance.userRequired`,`Please select a user`),`error`);return}let t=Number.parseFloat(O);if(!Number.isFinite(t)||t<=0){i(e(`finance.amountMustBePositive`,`Amount must be greater than zero`),`error`);return}let n={userId:w,amount:t,description:A.trim()||void 0,costCenterId:M};try{E===`deposit`?await pt.mutateAsync(n):await mt.mutateAsync(n),a.invalidateQueries({queryKey:[`finance`]}),k(``),j(``),i(E===`deposit`?e(`finance.depositSuccess`,`Deposit successful`):e(`finance.withdrawSuccess`,`Withdrawal successful`))}catch(t){i(t.message||e(`finance.adjustmentFailed`,`Wallet adjustment failed`),`error`)}},Dt=()=>{if(P==null){i(e(`finance.selectCostCenter`,`Please select a cost center`),`error`);return}if(I==null){i(e(`finance.noEligibleUsers`,`No eligible users available`),`error`);return}ht.mutate({costCenterId:P,userId:I,canPrint:R})},Ot=e=>{P!=null&>.mutate({costCenterId:P,userId:e})},kt=wf(Xe?.currency||`EUR`),At=(0,y.useMemo)(()=>[...it||[]].sort((e,t)=>e.username.localeCompare(t.username)),[it]),jt=(0,y.useMemo)(()=>{let e=new Map;for(let t of At)e.set(t.id,t.username);return e},[At]),Mt=(0,y.useMemo)(()=>{let e=new Set((at?.members||[]).map(e=>e.user_id));return At.filter(t=>!e.has(t.id))},[At,at]),Nt=de===`admin`&&s?et:Qe,Pt=de===`admin`&&s?tt:$e,Ft=(0,y.useMemo)(()=>Nt?.items??[],[Nt?.items]),It=Nt?.total??0,Lt=Math.max(1,Math.ceil(It/50)),Rt=(0,y.useMemo)(()=>Ft.filter(e=>!(ee!==`all`&&e.transaction_type!==ee||ne!==`all`&&e.cost_center_id!==ne)),[Ft,ee,ne]),zt=Math.floor(B/50)+1,Bt=de===`admin`,Vt=t=>t===`deposit`?e(`finance.deposit`):t===`withdraw`?e(`finance.withdraw`):t===`print_charge`?e(`finance.printCharge`):t,Ht=t=>t==null?e(`finance.personal`,`Personal`):jt.get(t)||(r?.id===t&&r.username?r.username:e(`finance.userWithId`,`User #{{id}}`,{id:t})),Ut=t=>t.budget_limit==null||t.budget_available==null?e(`finance.unlimited`,`Unlimited`):`${kt}${t.budget_available.toFixed(2)}/${kt}${t.budget_limit.toFixed(2)}`;return h?(0,G.jsxs)(`div`,{className:`p-4 md:p-8 space-y-8`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Wu,{className:`h-6 w-6 text-bambu-green`}),(0,G.jsx)(`h1`,{className:`text-2xl font-bold text-white`,children:e(`finance.title`,`Finance`)})]}),(0,G.jsx)(`p`,{className:`text-bambu-gray mt-2 max-w-2xl`,children:e(`finance.subtitle`,`Wallet, personal transactions, and cost centers`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1 max-w-2xl`,children:e(`finance.budgetPolicyHint`,`Account balances track costs. Printing is limited only by the selected cost center budget; without a budget, printing is unlimited.`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 lg:items-end`,children:[Ye&&(0,G.jsxs)(`div`,{className:`inline-flex overflow-hidden rounded border border-bambu-dark-tertiary`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>fe(`personal`),className:`px-3 py-1.5 text-sm ${de===`personal`?`bg-bambu-green text-black font-medium`:`bg-bambu-dark text-bambu-gray`}`,children:e(`finance.personalView`,`Personal view`)}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>fe(`admin`),className:`px-3 py-1.5 text-sm ${de===`admin`?`bg-bambu-green text-black font-medium`:`bg-bambu-dark text-bambu-gray`}`,children:e(`finance.adminView`,`Admin view`)})]}),de===`admin`&&Ye&&(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2 lg:justify-end`,children:[c&&(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>ae(!0),children:e(`finance.createCostCenter`,`Create cost center`)}),f&&p&&(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>se(!0),children:e(`finance.adjustWallet`,`Adjust wallet`)}),f&&p&&(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>Pe(!0),children:e(`finance.addManualPrint`,`Add manual print`)}),d&&p&&(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>ce(!0),children:e(`finance.manageMembers`,`Manage cost center members`)})]})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-5 md:grid-cols-2 xl:grid-cols-3`,children:[(0,G.jsxs)(jd,{children:[(0,G.jsxs)(Md,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e(`finance.currentBalance`,`Personal account balance`)}),(0,G.jsx)(Wu,{className:`w-4 h-4 text-bambu-green/90`})]}),(0,G.jsx)(Nd,{className:`pt-1`,children:(0,G.jsx)(`p`,{className:`text-3xl font-semibold text-white leading-tight`,children:Ze?e(`common.loading`,`Loading...`):`${kt}${(Xe?.balance??0).toFixed(2)}`})})]}),(0,G.jsxs)(jd,{children:[(0,G.jsxs)(Md,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:de===`admin`?e(`finance.transactions`,`Transactions`):e(`finance.personalTransactions`,`Personal transactions`)}),(0,G.jsx)(Os,{className:`w-4 h-4 text-blue-400`})]}),(0,G.jsx)(Nd,{className:`pt-1`,children:(0,G.jsx)(`p`,{className:`text-3xl font-semibold text-white leading-tight`,children:Pt?`-`:It})})]}),(0,G.jsxs)(jd,{children:[(0,G.jsxs)(Md,{className:`flex flex-row items-center justify-between pb-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e(`finance.costCenters`,`Cost centers`)}),(0,G.jsx)(Qo,{className:`w-4 h-4 text-orange-400`})]}),(0,G.jsx)(Nd,{className:`pt-1`,children:(0,G.jsx)(`p`,{className:`text-3xl font-semibold text-white leading-tight`,children:rt?`-`:nt?.length??0})})]})]}),ie&&c&&(0,G.jsx)(z8,{title:e(`finance.createCostCenter`,`Create cost center`),size:`md`,onClose:()=>ae(!1),children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.costCenterName`,`Name`)}),(0,G.jsx)(`input`,{type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:e(`finance.costCenterName`,`Name`),className:F8})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.budgetType`,`Budget type`)}),(0,G.jsxs)(`select`,{value:b,onChange:e=>x(e.target.value),className:F8,children:[(0,G.jsx)(`option`,{value:`monthly`,children:e(`finance.monthlyBudget`,`Monthly budget`)}),(0,G.jsx)(`option`,{value:`total`,children:e(`finance.totalBudget`,`Total budget`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:b===`monthly`?e(`finance.monthlyBudget`,`Monthly budget`):e(`finance.totalBudget`,`Total budget`)}),(0,G.jsx)(`input`,{type:`number`,step:`0.01`,value:S,onChange:e=>C(e.target.value),placeholder:`0.00`,className:F8})]})]}),(0,G.jsx)(Q,{className:`min-w-[180px]`,onClick:vt,disabled:ot.isPending,children:ot.isPending?e(`common.saving`,`Saving...`):e(`finance.create`,`Create`)})]})}),oe&&f&&p&&(0,G.jsx)(z8,{title:e(`finance.adjustWallet`,`Adjust wallet`),size:`md`,onClose:()=>se(!1),children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.selectUser`,`Select user`)}),(0,G.jsx)(`select`,{value:w??``,onChange:e=>T(e.target.value?Number(e.target.value):null),className:F8,children:(At||[]).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.username},e.id))})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.transactionType`,`Type`)}),(0,G.jsxs)(`select`,{value:E,onChange:e=>D(e.target.value),className:F8,children:[(0,G.jsx)(`option`,{value:`deposit`,children:e(`finance.deposit`,`Deposit`)}),(0,G.jsx)(`option`,{value:`withdraw`,children:e(`finance.withdraw`,`Withdraw`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.amount`,`Amount`)}),(0,G.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,value:O,onChange:e=>k(e.target.value),placeholder:`0.00`,className:F8})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.costCenters`,`Cost centers`)}),(0,G.jsxs)(`select`,{value:M??``,onChange:e=>N(e.target.value?Number(e.target.value):null),className:F8,children:[(0,G.jsx)(`option`,{value:``,children:e(`finance.noCostCenter`,`No cost center`)}),(nt||[]).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`common.description`,`Description`)}),(0,G.jsx)(`input`,{type:`text`,value:A,onChange:e=>j(e.target.value),placeholder:e(`finance.descriptionOptional`,`Description (optional)`),className:F8})]}),(0,G.jsx)(Q,{className:`min-w-[180px]`,onClick:Et,disabled:_t,children:_t?e(`common.saving`,`Saving...`):e(`finance.applyAdjustment`,`Apply adjustment`)})]})}),H&&d&&p&&(0,G.jsx)(z8,{title:e(`finance.manageMembers`,`Manage cost center members`),size:`lg`,onClose:()=>ce(!1),children:(0,G.jsxs)(`div`,{className:`space-y-5`,children:[(0,G.jsxs)(`div`,{className:`grid gap-5 md:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.costCenters`,`Cost centers`)}),(0,G.jsx)(`select`,{value:P??``,onChange:e=>F(e.target.value?Number(e.target.value):null),className:F8,children:(nt||[]).filter(e=>!e.is_private).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.selectUser`,`Select user`)}),(0,G.jsxs)(`select`,{value:I??``,onChange:e=>L(e.target.value?Number(e.target.value):null),className:F8,children:[(0,G.jsx)(`option`,{value:``,children:e(`finance.selectUser`,`Select user`)}),Mt.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.username},e.id))]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded border border-bambu-dark-tertiary bg-bambu-dark-secondary px-3 py-2`,children:[(0,G.jsx)(`input`,{id:`memberCanPrint`,type:`checkbox`,checked:R,onChange:e=>z(e.target.checked),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,G.jsx)(`label`,{htmlFor:`memberCanPrint`,className:`text-sm text-bambu-gray`,children:e(`finance.memberCanPrint`,`Member can print`)})]}),(0,G.jsx)(`div`,{className:`flex items-end`,children:(0,G.jsx)(Q,{className:`min-w-[180px]`,onClick:Dt,disabled:ht.isPending||I==null,children:ht.isPending?e(`common.saving`,`Saving...`):e(`finance.addMember`,`Add member`)})})]}),(0,G.jsx)(`div`,{className:`overflow-auto rounded-lg border border-bambu-dark-tertiary`,children:(0,G.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray`,children:[(0,G.jsx)(`th`,{className:L8,children:e(`common.name`,`Name`)}),(0,G.jsx)(`th`,{className:L8,children:e(`finance.canPrint`,`Can print`)}),(0,G.jsx)(`th`,{className:L8,children:e(`common.actions`,`Actions`)})]})}),(0,G.jsxs)(`tbody`,{children:[(at?.members||[]).map(t=>(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/60 text-white`,children:[(0,G.jsx)(`td`,{className:R8,children:At.find(e=>e.id===t.user_id)?.username||`User ${t.user_id}`}),(0,G.jsx)(`td`,{className:R8,children:t.can_print?e(`common.yes`,`Yes`):e(`common.no`,`No`)}),(0,G.jsx)(`td`,{className:R8,children:(0,G.jsx)(Q,{size:`sm`,variant:`danger`,onClick:()=>Ot(t.user_id),disabled:gt.isPending,children:e(`common.remove`,`Remove`)})})]},t.id)),(at?.members||[]).length===0&&(0,G.jsx)(`tr`,{children:(0,G.jsx)(`td`,{colSpan:3,className:`py-3 text-bambu-gray`,children:e(`finance.noMembers`,`No members assigned.`)})})]})]})})]})}),le&&(l||u)&&(0,G.jsx)(z8,{title:e(`finance.editCostCenter`,`Edit cost center`),size:`md`,onClose:()=>ue(!1),children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.costCenterName`,`Name`)}),(0,G.jsx)(`input`,{type:`text`,value:he,onChange:e=>ge(e.target.value),placeholder:e(`finance.costCenterName`,`Name`),className:F8,disabled:!l})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.budgetType`,`Budget type`)}),(0,G.jsxs)(`select`,{value:_e,onChange:e=>ve(e.target.value),className:F8,disabled:!u,children:[(0,G.jsx)(`option`,{value:`monthly`,children:e(`finance.monthlyBudget`,`Monthly budget`)}),(0,G.jsx)(`option`,{value:`total`,children:e(`finance.totalBudget`,`Total budget`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:_e===`monthly`?e(`finance.monthlyBudget`,`Monthly budget`):e(`finance.totalBudget`,`Total budget`)}),(0,G.jsx)(`input`,{type:`number`,step:`0.01`,value:ye,onChange:e=>be(e.target.value),placeholder:`0.00`,className:F8,disabled:!u})]})]}),(0,G.jsx)(Q,{className:`min-w-[180px]`,onClick:yt,disabled:ct.isPending||st.isPending||pe==null,children:ct.isPending||st.isPending?e(`common.saving`,`Saving...`):e(`common.save`,`Save`)})]})}),(0,G.jsxs)(`div`,{className:`grid gap-6 ${g&&o?`xl:grid-cols-2`:``}`,children:[g&&(0,G.jsxs)(jd,{children:[(0,G.jsxs)(Md,{children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`finance.myCostCenters`,`My cost centers`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:e(`finance.costCentersHint`,`Review budget limits and keep costs under control`)})]}),(0,G.jsxs)(Nd,{className:`space-y-3`,children:[rt&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`common.loading`,`Loading...`)}),!rt&&(!nt||nt.length===0)&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`finance.noCostCenters`,`No cost centers found.`)}),!rt&&nt&&nt.length>0&&(0,G.jsx)(`div`,{className:`overflow-auto rounded-lg border border-bambu-dark-tertiary`,children:(0,G.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray`,children:[(0,G.jsx)(`th`,{className:L8,children:e(`common.name`,`Name`)}),Bt&&(0,G.jsx)(`th`,{className:L8,children:e(`finance.owner`,`Owner`)}),(0,G.jsx)(`th`,{className:L8,children:e(`finance.balance`,`Account balance`)}),(0,G.jsx)(`th`,{className:L8,children:e(`finance.budget`,`Budget`)}),Bt&&(0,G.jsx)(`th`,{className:L8,children:e(`common.actions`,`Actions`)})]})}),(0,G.jsx)(`tbody`,{children:nt.map(t=>{let n=l||u,r=!t.is_private&&l;return(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/60 text-white`,children:[(0,G.jsx)(`td`,{className:R8,children:t.name}),Bt&&(0,G.jsx)(`td`,{className:R8,children:t.is_private?Ht(t.owner_user_id):e(`finance.shared`,`Shared`)}),(0,G.jsxs)(`td`,{className:R8,children:[kt,t.total_balance.toFixed(2)]}),(0,G.jsx)(`td`,{className:R8,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,G.jsx)(`span`,{children:Ut(t)}),(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:t.budget_mode===`monthly`?e(`finance.monthlyBudget`,`Monthly budget`):t.budget_mode===`total`?e(`finance.totalBudget`,`Total budget`):e(`finance.noBudget`,`No budget`)})]})}),Bt&&(0,G.jsx)(`td`,{className:R8,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>bt(t.id),disabled:!n,title:n?e(`common.edit`,`Edit`):e(`finance.cannotEditPrivateCostCenter`,`Private cost centers cannot be edited here`),className:`p-1.5 sm:p-2`,children:(0,G.jsx)(El,{className:`w-4 h-4`})}),r&&(0,G.jsx)(Q,{size:`sm`,variant:`ghost`,onClick:()=>Ke({id:t.id,name:t.name}),disabled:lt.isPending,title:e(`common.delete`,`Delete`),className:`text-red-400 hover:text-red-300 hover:bg-red-500/10 p-1.5 sm:p-2`,children:(0,G.jsx)(Au,{className:`w-4 h-4`})})]})})]},t.id)})})]})})]})]}),o&&(0,G.jsxs)(jd,{children:[(0,G.jsxs)(Md,{children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`finance.recentTransactions`,`Recent transactions`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:e(`finance.transactionsHint`,`Filter by type and cost center, then navigate pages`)})]}),(0,G.jsxs)(Nd,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_auto] items-end`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.transactionType`,`Type`)}),(0,G.jsxs)(`select`,{value:ee,onChange:e=>te(e.target.value),className:F8,children:[(0,G.jsx)(`option`,{value:`all`,children:e(`finance.allTypes`)}),(0,G.jsx)(`option`,{value:`deposit`,children:e(`finance.deposit`)}),(0,G.jsx)(`option`,{value:`withdraw`,children:e(`finance.withdraw`)}),(0,G.jsx)(`option`,{value:`print_charge`,children:e(`finance.printCharge`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.costCenters`,`Cost centers`)}),(0,G.jsxs)(`select`,{value:ne,onChange:e=>re(e.target.value===`all`?`all`:Number(e.target.value)),className:F8,children:[(0,G.jsx)(`option`,{value:`all`,children:e(`finance.allCostCenters`)}),(nt||[]).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})]}),Pt&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`common.loading`,`Loading...`)}),!Pt&&(!Ft||Ft.length===0)&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`finance.noTransactions`,`No transactions available.`)}),!Pt&&Ft.length>0&&Rt.length===0&&(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`finance.noTransactionsForFilter`,`No transactions match the selected filters.`)}),!Pt&&Rt.length>0&&(0,G.jsx)(`div`,{className:`overflow-auto rounded-lg border border-bambu-dark-tertiary`,children:(0,G.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray`,children:[(0,G.jsx)(`th`,{className:L8,children:e(`common.date`,`Date`)}),Bt&&(0,G.jsx)(`th`,{className:L8,children:e(`common.user`,`User`)}),(0,G.jsx)(`th`,{className:L8,children:e(`finance.costCenter`,`Cost center`)}),(0,G.jsx)(`th`,{className:L8,children:e(`finance.transactionType`,`Type`)}),(0,G.jsx)(`th`,{className:L8,children:e(`common.description`,`Description`)}),(0,G.jsx)(`th`,{className:L8,children:e(`finance.amount`,`Amount`)}),(0,G.jsx)(`th`,{className:L8,children:e(`finance.balanceAfter`,`Balance after`)}),Bt&&(0,G.jsx)(`th`,{className:L8,children:e(`common.actions`,`Actions`)})]})}),(0,G.jsx)(`tbody`,{children:Rt.map(n=>{let r=n.amount>=0,i=n.cost_center_id==null?null:(nt||[]).find(e=>e.id===n.cost_center_id),a=jt.get(n.user_id),o=n.transaction_type===`print_charge`?XHe(n.description??null):null,s=o?.isPartial??!1;return(0,G.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/60 text-white`,children:[(0,G.jsx)(`td`,{className:R8,children:ZHe(n.created_at,t.language)}),Bt&&(0,G.jsx)(`td`,{className:R8,children:a||e(`finance.userWithId`,`User #{{id}}`,{id:n.user_id})}),(0,G.jsx)(`td`,{className:R8,children:i?.name||`-`}),(0,G.jsx)(`td`,{className:R8,children:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,G.jsx)(`span`,{children:Vt(n.transaction_type)}),s&&(0,G.jsx)(`span`,{className:`rounded border border-yellow-500/40 bg-yellow-500/10 px-2 py-0.5 text-[11px] text-yellow-300`,children:o&&o.partialType?e(`finance.partialStatus.${o.partialType}`,o.partialType):e(`finance.partial`,`Partial`)})]})}),(0,G.jsx)(`td`,{className:R8,children:(o?.cleanedDescription??n.description)||`-`}),(0,G.jsxs)(`td`,{className:`${R8} ${r?`text-green-400`:`text-red-400`}`,children:[r?`+`:`-`,kt,Math.abs(n.amount).toFixed(2)]}),(0,G.jsx)(`td`,{className:R8,children:n.balance_after==null?`-`:`${n.balance_after<0?`-`:``}${kt}${Math.abs(n.balance_after).toFixed(2)}`}),Bt&&(0,G.jsx)(`td`,{className:R8,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Q,{size:`sm`,variant:`secondary`,onClick:()=>Ct(n),disabled:dt.isPending,children:(0,G.jsx)(El,{className:`w-4 h-4`})}),(0,G.jsx)(Q,{size:`sm`,variant:`danger`,onClick:()=>Je(n.id),disabled:ut.isPending,children:(0,G.jsx)(Au,{className:`w-4 h-4`})})]})})]},n.id)})})]})}),!Pt&&Rt.length>0&&(0,G.jsx)(`div`,{className:`flex justify-end pt-2 lg:pt-0`,children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>V(0),disabled:B===0||Pt,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,"aria-label":e(`finance.first`,`First`),children:(0,G.jsx)(hs,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>V(e=>Math.max(0,e-50)),disabled:B===0||Pt,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,"aria-label":e(`finance.prev`,`Previous`),children:(0,G.jsx)(ps,{className:`w-4 h-4`})}),(0,G.jsx)(`span`,{className:`text-bambu-gray px-1 whitespace-nowrap`,children:e(`finance.pageNumberOf`,`Page {{page}} of {{total}}`,{page:zt,total:Lt})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>V(e=>e+50),disabled:Pt||zt>=Lt,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,"aria-label":e(`finance.next`,`Next`),children:(0,G.jsx)(fs,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>V(Math.max(0,(Lt-1)*50)),disabled:Pt||zt>=Lt,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,"aria-label":e(`finance.last`,`Last`),children:(0,G.jsx)(gs,{className:`w-4 h-4`})})]})})]})]}),xe&&Ce!==null&&(0,G.jsx)(z8,{title:e(`finance.editTransaction`,`Edit Transaction`),onClose:()=>Se(!1),size:`md`,children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`common.user`,`User`)}),(0,G.jsxs)(`select`,{className:F8,value:Te||``,onChange:e=>Ee(e.target.value?Number(e.target.value):null),children:[(0,G.jsx)(`option`,{value:``,children:e(`finance.selectUser`,`Select user...`)}),At.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.username},e.id))]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.costCenter`,`Cost center (optional)`)}),(0,G.jsxs)(`select`,{className:F8,value:De||``,onChange:e=>Oe(e.target.value?Number(e.target.value):null),children:[(0,G.jsx)(`option`,{value:``,children:e(`finance.noCostCenter`,`Personal (no cost center)`)}),(nt||[]).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.amount`,`Amount`)}),(0,G.jsx)(`input`,{type:`number`,step:`0.01`,className:F8,value:ke,onChange:e=>Ae(e.target.value),placeholder:e(`finance.amountExample`,`e.g., 10.50`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`common.description`,`Description`)}),(0,G.jsx)(`textarea`,{className:`${F8} resize-none`,rows:3,value:je,onChange:e=>Me(e.target.value),placeholder:e(`finance.manualAdjustmentExample`,`e.g., Manual adjustment`)})]}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 pt-4`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>Se(!1),children:e(`common.cancel`,`Cancel`)}),(0,G.jsx)(Q,{onClick:wt,disabled:dt.isPending,children:e(`common.save`,`Save`)})]})]})}),Ne&&(0,G.jsx)(z8,{title:e(`finance.addManualPrint`,`Add manual print`),onClose:()=>Pe(!1),size:`md`,children:(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`common.user`,`User`)}),(0,G.jsxs)(`select`,{className:F8,value:Fe||``,onChange:e=>Ie(e.target.value?Number(e.target.value):null),children:[(0,G.jsx)(`option`,{value:``,children:e(`finance.selectUser`,`Select user...`)}),At.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.username},e.id))]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.costCenter`,`Cost center`)}),(0,G.jsxs)(`select`,{className:F8,value:Le||``,onChange:e=>Re(e.target.value?Number(e.target.value):null),children:[(0,G.jsx)(`option`,{value:``,children:e(`finance.selectCostCenter`,`Select cost center...`)}),(nt||[]).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`finance.amount`,`Amount`)}),(0,G.jsx)(`input`,{type:`number`,step:`0.01`,className:F8,value:ze,onChange:e=>Be(e.target.value),placeholder:e(`finance.amountExample`,`e.g., 4.00`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`common.description`,`Description`)}),(0,G.jsx)(`input`,{type:`text`,value:Ve,onChange:e=>He(e.target.value),placeholder:e(`finance.descriptionOptional`,`Description (optional)`),className:F8})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:I8,children:e(`common.date`,`Date`)}),(0,G.jsx)(`input`,{type:`datetime-local`,value:Ue,onChange:e=>We(e.target.value),className:F8})]}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2 pt-4`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>Pe(!1),children:e(`common.cancel`,`Cancel`)}),(0,G.jsx)(Q,{onClick:Tt,disabled:ft.isPending,children:ft.isPending?e(`common.saving`,`Saving...`):e(`finance.addManualPrint`,`Add manual print`)})]})]})}),Ge&&(0,G.jsx)(Xd,{title:e(`common.delete`,`Delete`),message:e(`finance.confirmDeleteCostCenter`,`Delete cost center "{{name}}"?`,{name:Ge.name}),confirmText:e(`common.delete`,`Delete`),variant:`danger`,isLoading:lt.isPending,onConfirm:xt,onCancel:()=>Ke(null)}),qe!=null&&(0,G.jsx)(Xd,{title:e(`finance.deleteTransaction`,`Delete transaction`),message:e(`finance.deleteTransactionConfirm`,`Delete this transaction? Balances will be recalculated automatically.`),confirmText:e(`common.delete`,`Delete`),variant:`danger`,isLoading:ut.isPending,onConfirm:St,onCancel:()=>Je(null)})]})]}):(0,G.jsxs)(`div`,{className:`p-4 md:p-8 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Wu,{className:`h-6 w-6 text-bambu-green`}),(0,G.jsx)(`h1`,{className:`text-2xl font-bold text-white`,children:e(`finance.title`,`Finance`)})]}),(0,G.jsx)(`div`,{children:(0,G.jsx)(`p`,{className:`text-bambu-gray mt-2 max-w-2xl`,children:e(`finance.subtitle`,`Wallet, personal transactions, and cost centers`)})}),(0,G.jsx)(jd,{children:(0,G.jsx)(Nd,{className:`py-8 text-center text-bambu-gray`,children:e(`finance.noAccess`,`You do not have permission to view finance data.`)})})]})}var B8={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`};function V8(e){let t=(e||``).toUpperCase().trim();return t&&(B8[t]||B8[t.replace(/[-\s]?CF$/,``)]||B8[t.replace(/\+$/,``)]||B8[t.split(/[-\s]/)[0]])||``}function H8(e){let t=e.replace(/@.+$/,``).trim();return t.startsWith(`# `)?t.slice(2).trim():t}var U8={local:0,orca_cloud:1,cloud:2,builtin:3};function $He(e){let{localPresets:t,orcaProfiles:n,cloudSettings:r,builtinFilaments:i}=e,a=[],o=e=>e.trim().toLowerCase(),s=new Set,c=new Set,l=new Set,u=(e,t,...n)=>{let r=n.filter(e=>!!e);if(r.some(e=>s.has(e)))return!1;let i=`${e}|${o(t)}`;return c.has(i)?!1:(r.forEach(e=>s.add(e)),c.add(i),l.add(o(t)),!0)};for(let e of t??[]){let t=H8(e.name),n=e.filament_type||XU(t).material;u(`local`,t)&&a.push({id:`local_${e.id}`,name:t,source:`local`,filamentId:V8(n),filamentType:n||``})}for(let e of n??[]){let t=H8(e.name),n=XU(t).material;u(`orca_cloud`,t,e.setting_id)&&a.push({id:`orca_${e.setting_id}`,name:t,source:`orca_cloud`,filamentId:V8(n),filamentType:n})}for(let e of r??[]){let t=H8(e.name),n=e.setting_id.startsWith(`GFS`)?iW(e.setting_id):``;u(`cloud`,t,e.setting_id,n||void 0)&&a.push({id:e.setting_id,name:t,source:`cloud`,filamentId:n,filamentType:XU(t).material})}for(let e of i??[]){let t=e.filament_id.startsWith(`GF`)?`GFS${e.filament_id.slice(2)}`:e.filament_id;l.has(o(e.name))||u(`builtin`,e.name,e.filament_id,t)&&a.push({id:`builtin_${e.filament_id}`,name:e.name,source:`builtin`,filamentId:e.filament_id,filamentType:XU(e.name).material})}return a.sort((e,t)=>e.source===t.source?e.name.localeCompare(t.name):U8[e.source]-U8[t.source])}async function eUe(e,t){if(e.filamentId)return e.filamentId;if(e.source!==`cloud`||!t)return``;try{return(await t(e.id)).filament_id||``}catch{return``}}var W8=e=>(Math.trunc(parseFloat(e)*1e3)/1e3).toFixed(3),G8=`HS00`,K8=`HH00`,q8=e=>{let t=e.match(/^([A-Z]{2}\d{2})/);return t?t[1]:G8},tUe=e=>q8(e)===K8?`HF`:`S`,J8=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 Y8({profile:e,onEdit:t,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){let s=tUe(e.nozzle_id),c=e.nozzle_diameter;return(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r&&(0,G.jsx)(`button`,{onClick:a,className:`text-bambu-gray hover:text-white transition-colors p-1`,children:i?(0,G.jsx)(mu,{className:`w-4 h-4 text-bambu-green`}):(0,G.jsx)(gu,{className:`w-4 h-4`})}),(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-bambu-green font-mono text-sm font-bold whitespace-nowrap`,children:W8(e.k_value)}),(0,G.jsx)(`span`,{className:`text-white text-sm truncate flex-1`,title:e.name,children:e.name||`Unnamed`}),o&&(0,G.jsx)(`span`,{title:`Has note`,children:(0,G.jsx)(yu,{className:`w-3 h-3 text-yellow-500`})}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:[s,` `,c]})]}),o&&(0,G.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,G.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n()},className:`text-bambu-gray hover:text-white transition-colors p-1`,title:`Copy profile`,children:(0,G.jsx)(zs,{className:`w-4 h-4`})})]})}function X8({profile:e,printerId:t,nozzleDiameter:n,existingProfiles:r=[],builtinFilaments:i=[],filamentPresets:a=[],isDualNozzle:o=!1,supportsFlowType:s=!0,initialNote:c=``,initialNoteKey:l=null,onClose:u,onSave:d,onSaveNote:f,hasPermission:p}){let{t:m}=U(),{showToast:h}=zd(),[g,_]=(0,y.useState)(e?.name||``),[v,b]=(0,y.useState)(e?.k_value?W8(e.k_value):`0.020`),[x,S]=(0,y.useState)(e?.filament_id||``),[C,w]=(0,y.useState)(e?q8(e.nozzle_id):G8),[T,E]=(0,y.useState)(e?.nozzle_diameter||n),[D,O]=(0,y.useState)(e?[e.extruder_id]:o?[0,1]:[0]),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)({current:0,total:0}),[N,P]=(0,y.useState)(c),[F,I]=(0,y.useState)(``),{schedule:L}=sW(),R=y.useMemo(()=>e?.filament_id?i.find(t=>t.filament_id===e.filament_id)?.name||J8(r.find(t=>t.filament_id===e.filament_id)?.name||e.name||``)||e.filament_id:``,[e,r,i]),z=y.useMemo(()=>{let e=[[`local`,m(`kProfiles.modal.source.local`)],[`orca_cloud`,m(`kProfiles.modal.source.orcaCloud`)],[`cloud`,m(`kProfiles.modal.source.bambuCloud`)],[`builtin`,m(`kProfiles.modal.source.builtin`)]],t=F.trim().toLowerCase(),n=t?a.filter(e=>e.name.toLowerCase().includes(t)):a;return e.map(([e,t])=>({source:e,label:t,items:n.filter(t=>t.source===e)})).filter(e=>e.items.length>0)},[a,F,m]),B=q({mutationFn:e=>(console.log(`[KProfile] Calling API...`),Z.setKProfile(t,e)),onSuccess:(t,n)=>{if(console.log(`[KProfile] Save success:`,t),h(m(`kProfiles.toast.profileSaved`)),f&&N!==c){let t;t=N===``&&l?l:e&&e.slot_id>0?e.setting_id||`slot_${e.slot_id}_${e.filament_id}_${e.extruder_id}`:`name_${g}_${n.filament_id}`,f(t,N)}A(!0),L(()=>{A(!1),d()},2500)},onError:e=>{console.error(`[KProfile] Save error:`,e),h(e.message,`error`),A(!1)}}),V=q({mutationFn:e=>(console.log(`[KProfile] Deleting profile...`),Z.deleteKProfile(t,e)),onSuccess:e=>{console.log(`[KProfile] Delete success:`,e),h(m(`kProfiles.toast.profileDeleted`)),A(!0),L(()=>{A(!1),u()},4e3)},onError:e=>{console.error(`[KProfile] Delete error:`,e),h(e.message,`error`),A(!1)}}),[ee,te]=(0,y.useState)(!1),ne=()=>{e&&V.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,G.jsxs)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:[(0,G.jsxs)(jd,{className:`w-full max-w-md relative`,children:[k&&(0,G.jsxs)(`div`,{className:`absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg`,children:[(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin mb-3`}),(0,G.jsx)(`p`,{className:`text-white font-medium`,children:j.total>1?m(`kProfiles.modal.savingExtruder`,{current:j.current,total:j.total}):m(`kProfiles.modal.syncing`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray text-sm mt-1`,children:m(`kProfiles.modal.pleaseWait`)})]}),(0,G.jsxs)(Nd,{className:`p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,G.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:m(e?`kProfiles.modal.editTitle`:`kProfiles.modal.addTitle`)}),(0,G.jsx)(`button`,{onClick:u,className:`text-bambu-gray hover:text-white transition-colors`,disabled:k,children:(0,G.jsx)(Qu,{className:`w-5 h-5`})})]}),(0,G.jsxs)(`form`,{onSubmit:async n=>{if(n.preventDefault(),o&&!e&&D.length===0){h(m(`kProfiles.toast.selectAtLeastOneExtruder`),`error`);return}let r=parseFloat(v).toFixed(6),i=`${C}-${T}`,s=e&&e.nozzle_id||i,c=e?e.nozzle_diameter:T,l=e?.filament_id||``;if(!e){let e=a.find(e=>e.id===x);if(!e){h(m(`kProfiles.toast.selectFilament`),`error`);return}if(l=await eUe(e,Z.getCloudSettingDetail),!l){h(m(`kProfiles.toast.filamentNotResolvable`,{name:e.name}),`error`);return}}if(e||D.length===1){let t={name:g,k_value:r,filament_id:l,nozzle_id:s,nozzle_diameter:c,extruder_id:e?e.extruder_id:D[0],setting_id:e?.setting_id,slot_id:e?.slot_id??0};console.log(`[KProfile] Saving profile:`,t),B.mutate(t);return}A(!0),M({current:1,total:D.length});let u=D.map(e=>({name:g,k_value:r,filament_id:l,nozzle_id:i,nozzle_diameter:T,extruder_id:e,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${u.length} profiles in batch:`,u);try{await Z.setKProfilesBatch(t,u),h(m(`kProfiles.toast.profilesSaved`,{count:D.length})),f&&N&&f(`name_${g}_${l}`,N)}catch(e){console.error(`[KProfile] Failed to save batch:`,e),h(m(`kProfiles.toast.failedToSaveBatch`),`error`),A(!1),M({current:0,total:0});return}M({current:D.length,total:D.length}),L(()=>{A(!1),M({current:0,total:0}),d()},3e3)},className:`p-4 space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:m(`kProfiles.modal.profileName`)}),(0,G.jsx)(`input`,{type:`text`,value:g,onChange:e=>_(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:m(`kProfiles.modal.profileNamePlaceholder`),required:!e})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:m(`kProfiles.modal.kValue`)}),(0,G.jsx)(`input`,{type:`text`,inputMode:`decimal`,value:v,onChange:e=>{let t=e.target.value;(t===``||/^\d*\.?\d*$/.test(t))&&b(t)},onBlur:e=>{let t=parseFloat(e.target.value);isNaN(t)||b((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:m(`kProfiles.modal.kValuePlaceholder`),required:!0}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:m(`kProfiles.modal.kValueHelp`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:m(`kProfiles.modal.filament`)}),e?(0,G.jsx)(`div`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60`,children:R||e.filament_id}):(0,G.jsxs)(`div`,{className:`border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`relative border-b border-bambu-dark-tertiary`,children:[(0,G.jsx)(Jl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,G.jsx)(`input`,{type:`text`,value:F,onChange:e=>I(e.target.value),placeholder:m(`kProfiles.modal.searchFilaments`),className:`w-full pl-10 pr-3 py-2 bg-bambu-dark text-white placeholder-bambu-gray focus:outline-none`})]}),(0,G.jsx)(`div`,{className:`max-h-56 overflow-y-auto bg-bambu-dark`,children:z.length===0?(0,G.jsx)(`p`,{className:`px-3 py-3 text-xs text-bambu-gray`,children:a.length===0?m(`kProfiles.modal.noFilamentsHelp`):m(`kProfiles.modal.noFilamentMatches`)}):z.map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 px-3 py-1.5 bg-bambu-dark-secondary border-y border-bambu-dark-tertiary`,children:[(0,G.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider text-bambu-green`,children:e.label}),(0,G.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:e.items.length})]}),e.items.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>{S(e.id),g||_(`${C===K8?`HF`:`S`} ${e.name}`)},className:`w-full text-left px-3 py-1.5 text-sm transition-colors ${x===e.id?`bg-bambu-green/20 text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,children:e.name},e.id))]},e.source))})]})]}),(0,G.jsxs)(`div`,{className:s?`grid grid-cols-2 gap-4`:``,children:[(0,G.jsxs)(`div`,{className:s?``:`hidden`,children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:m(`kProfiles.modal.flowType`)}),(0,G.jsxs)(`select`,{value:C,onChange:t=>{let n=t.target.value;if(w(n),!e&&x&&!g){let e=a.find(e=>e.id===x);e&&_(`${n===K8?`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,G.jsx)(`option`,{value:K8,children:m(`kProfiles.modal.highFlow`)}),(0,G.jsx)(`option`,{value:G8,children:m(`kProfiles.modal.standard`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:m(`kProfiles.modal.nozzleSize`)}),(0,G.jsxs)(`select`,{value:T,onChange:e=>E(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,G.jsx)(`option`,{value:`0.2`,children:`0.2mm`}),(0,G.jsx)(`option`,{value:`0.4`,children:`0.4mm`}),(0,G.jsx)(`option`,{value:`0.6`,children:`0.6mm`}),(0,G.jsx)(`option`,{value:`0.8`,children:`0.8mm`})]})]})]}),o&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:m(e?`kProfiles.modal.extruder`:`kProfiles.modal.extruders`)}),e?(0,G.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?m(`kProfiles.modal.left`):m(`kProfiles.modal.right`)}):(0,G.jsxs)(`div`,{className:`flex gap-4`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:D.includes(1),onChange:e=>{e.target.checked?O([...D,1]):O(D.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,G.jsx)(`span`,{className:`text-white`,children:m(`kProfiles.modal.left`)})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:D.includes(0),onChange:e=>{e.target.checked?O([...D,0]):O(D.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,G.jsx)(`span`,{className:`text-white`,children:m(`kProfiles.modal.right`)})]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:m(`kProfiles.modal.notes`)}),(0,G.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),placeholder:m(`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,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:m(`kProfiles.modal.notesHelp`)})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 pt-4`,children:[e&&(0,G.jsx)(Q,{type:`button`,variant:`secondary`,onClick:()=>te(!0),disabled:V.isPending||k||!p(`kprofiles:delete`),title:p(`kprofiles:delete`)?void 0:m(`kProfiles.permission.noDelete`),className:`text-red-500 hover:bg-red-500/10`,children:V.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Au,{className:`w-4 h-4`})}),(0,G.jsx)(Q,{type:`button`,variant:`secondary`,onClick:u,disabled:k,className:`flex-1`,children:m(`common.cancel`)}),(0,G.jsxs)(Q,{type:`submit`,disabled:B.isPending||k||!p(e?`kprofiles:update`:`kprofiles:create`),title:p(e?`kprofiles:update`:`kprofiles:create`)?void 0:m(e?`kProfiles.permission.noUpdate`:`kProfiles.permission.noCreate`),className:`flex-1`,children:[B.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(xc,{className:`w-4 h-4`}),m(`common.save`)]})]})]})]})]}),ee&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-[60]`,children:(0,G.jsx)(jd,{className:`w-full max-w-sm`,children:(0,G.jsxs)(Nd,{className:`p-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center`,children:(0,G.jsx)(Au,{className:`w-5 h-5 text-red-500`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:m(`kProfiles.deleteConfirm.title`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:m(`kProfiles.deleteConfirm.cannotUndo`)})]})]}),(0,G.jsx)(`p`,{className:`text-bambu-gray mb-6`,children:m(`kProfiles.deleteConfirm.message`,{name:e?.name})}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>te(!1),className:`flex-1`,children:m(`common.cancel`)}),(0,G.jsxs)(Q,{onClick:()=>{te(!1),ne()},disabled:V.isPending,className:`flex-1 bg-red-500 hover:bg-red-600 text-white`,children:[V.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Au,{className:`w-4 h-4`}),m(`common.delete`)]})]})]})})})]})}var Z8={NOZZLE_DIAMETER:`bambusy_kprofiles_nozzle`,SORT_OPTION:`bambusy_kprofiles_sort`};function nUe(){let{t:e}=U(),{showToast:t}=zd(),{hasPermission:n}=Td(),[r,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(()=>localStorage.getItem(Z8.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(Z8.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(Z8.NOZZLE_DIAMETER,a)},[a]),(0,y.useEffect)(()=>{localStorage.setItem(Z8.SORT_OPTION,b)},[b]);let{data:j,isLoading:M}=K({queryKey:[`printers`],queryFn:Z.getPrinters}),{data:N,isLoading:P,isFetching:F,error:I,refetch:L}=K({queryKey:[`kprofiles`,r,a],queryFn:async()=>{console.log(`[KProfiles] Fetching profiles for printer`,r,`nozzle`,a);let e=await Z.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}=K({queryKey:[`builtinFilaments`],queryFn:()=>Z.getBuiltinFilaments(),staleTime:3e5}),{data:z}=K({queryKey:[`filamentIdMap`],queryFn:()=>Z.getFilamentIdMap(),staleTime:3e5}),{data:B}=K({queryKey:[`localPresets`],queryFn:()=>Z.getLocalPresets(),retry:!1}),{data:V}=K({queryKey:[`orcaCloudProfilesForKProfiles`],queryFn:()=>Z.orcaCloudListProfiles(),retry:!1}),{data:ee}=K({queryKey:[`cloudSettings`],queryFn:()=>Z.getCloudSettings(),retry:!1}),{data:te,refetch:ne}=K({queryKey:[`kprofile-notes`,r],queryFn:()=>Z.getKProfileNotes(r),enabled:!!r,staleTime:3e4}),re=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 ie=j?.filter(e=>e.is_active)||[],ae=y.useMemo(()=>{let e=new Map;if(R)for(let t of R)e.set(t.filament_id,t.name);if(z)for(let[t,n]of Object.entries(z))e.has(t)||e.set(t,n);return e},[R,z]),oe=y.useMemo(()=>Array.from(ae.entries()).map(([e,t])=>({filament_id:e,name:t})),[ae]),se=y.useMemo(()=>$He({localPresets:B?.filament,orcaProfiles:V?.filament,cloudSettings:ee?.filament,builtinFilaments:R}),[B?.filament,V?.filament,ee?.filament,R]),H=y.useCallback(e=>ae.get(e.filament_id)||J8(e.name),[ae]),ce=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]),le=j?.find(e=>e.id===r),ue=le?.nozzle_count===2,de=le?.supports_nozzle_flow_type??!0;(0,y.useEffect)(()=>{de||v(`all`)},[de]),(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 fe=(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:le?.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_${le?.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,le,a,t,e]),pe=(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 Z.setKProfile(r,{name:e.name,k_value:parseFloat(e.k_value).toFixed(6),filament_id:e.filament_id,nozzle_id:e.nozzle_id||`${G8}-${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]),me=(0,y.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),he=(0,y.useCallback)(()=>{T(new Set(ce.map(e=>A(e))))},[ce,A]),ge=(0,y.useCallback)(()=>{w.size!==0&&D(!0)},[w.size]),_e=(0,y.useCallback)(async()=>{let n=ce.filter(e=>w.has(A(e)));k(!0);let i=0;for(let e of n)try{await Z.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,ce,t,L,A,e]),ve=(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},[]),ye=(0,y.useCallback)(async(n,i)=>{if(r)try{await Z.setKProfileNote(r,n,i),ne()}catch(n){console.error(`Failed to save note:`,n),t(e(`kProfiles.toast.failedToSaveNote`),`error`)}},[r,ne,t,e]),be=(0,y.useCallback)(e=>{if(!te?.notes)return{note:``,key:null};let t=ve(e);for(let e of t)if(te.notes[e])return{note:te.notes[e],key:e};return{note:``,key:null}},[te,ve]),xe=(0,y.useCallback)(e=>be(e).note,[be]);return M?(0,G.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):!j||j.length===0?(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`py-12 text-center`,children:[(0,G.jsx)(_s,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noPrintersConfigured`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`kProfiles.addPrinterInSettings`)})]})}):ie.length===0?(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`py-12 text-center`,children:[(0,G.jsx)(Pl,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noActivePrinters`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`kProfiles.enablePrinterConnection`)})]})}):(0,G.jsxs)(G.Fragment,{children:[F&&!P&&(0,G.jsxs)(`div`,{className:`fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40`,children:[(0,G.jsx)(Y,{className:`w-10 h-10 text-bambu-green animate-spin mb-3`}),(0,G.jsx)(`p`,{className:`text-white font-medium`,children:e(`kProfiles.loadingProfiles`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-4 mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-48`,children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`kProfiles.printer`)}),(0,G.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:ie.map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,G.jsxs)(`div`,{className:`w-32`,children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`kProfiles.nozzle`)}),(0,G.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,G.jsx)(`option`,{value:`0.2`,children:`0.2mm`}),(0,G.jsx)(`option`,{value:`0.4`,children:`0.4mm`}),(0,G.jsx)(`option`,{value:`0.6`,children:`0.6mm`}),(0,G.jsx)(`option`,{value:`0.8`,children:`0.8mm`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,G.jsxs)(Q,{variant:`secondary`,onClick:()=>L(),disabled:F||!n(`kprofiles:read`),title:n(`kprofiles:read`)?void 0:e(`kProfiles.permission.noRead`),children:[(0,G.jsx)(Rl,{className:`w-4 h-4 ${F?`animate-spin`:``}`}),e(`kProfiles.refresh`)]}),(0,G.jsxs)(Q,{onClick:()=>u(!0),disabled:!n(`kprofiles:create`),title:n(`kprofiles:create`)?void 0:e(`kProfiles.permission.noCreate`),children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),e(`kProfiles.addProfile`)]})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-4 mb-4`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-48 relative`,children:[(0,G.jsx)(Jl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,G.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`})]}),ue&&(0,G.jsx)(`div`,{className:`w-36`,children:(0,G.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,G.jsx)(`option`,{value:`all`,children:e(`kProfiles.allExtruders`)}),(0,G.jsx)(`option`,{value:`left`,children:e(`kProfiles.leftOnly`)}),(0,G.jsx)(`option`,{value:`right`,children:e(`kProfiles.rightOnly`)})]})}),de&&(0,G.jsx)(`div`,{className:`w-32`,children:(0,G.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,G.jsx)(`option`,{value:`all`,children:e(`kProfiles.allFlow`)}),(0,G.jsx)(`option`,{value:`hf`,children:e(`kProfiles.hfOnly`)}),(0,G.jsx)(`option`,{value:`s`,children:e(`kProfiles.sOnly`)})]})}),(0,G.jsx)(`div`,{className:`w-32`,children:(0,G.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,G.jsx)(`option`,{value:`name`,children:e(`kProfiles.sortName`)}),(0,G.jsx)(`option`,{value:`k_value`,children:e(`kProfiles.sortKValue`)}),(0,G.jsx)(`option`,{value:`filament`,children:e(`kProfiles.sortFilament`)})]})})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2 mb-6`,children:[(0,G.jsxs)(Q,{variant:`secondary`,onClick:fe,disabled:!N?.profiles?.length||!n(`kprofiles:read`),title:n(`kprofiles:read`)?void 0:e(`kProfiles.permission.noExport`),children:[(0,G.jsx)(qs,{className:`w-4 h-4`}),e(`kProfiles.export`)]}),(0,G.jsxs)(Q,{variant:`secondary`,onClick:pe,disabled:!n(`kprofiles:create`),title:n(`kprofiles:create`)?void 0:e(`kProfiles.permission.noImport`),children:[(0,G.jsx)(Lu,{className:`w-4 h-4`}),e(`kProfiles.import`)]}),(0,G.jsx)(`div`,{className:`flex-1`}),S?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Q,{variant:`secondary`,onClick:he,children:[(0,G.jsx)(mu,{className:`w-4 h-4`}),e(`kProfiles.selectAll`)]}),(0,G.jsxs)(Q,{variant:`secondary`,onClick:ge,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,G.jsx)(Au,{className:`w-4 h-4`}),e(`kProfiles.delete`),` (`,w.size,`)`]}),(0,G.jsxs)(Q,{variant:`secondary`,onClick:()=>{C(!1),T(new Set)},children:[(0,G.jsx)(Qu,{className:`w-4 h-4`}),e(`common.cancel`)]})]}):(0,G.jsxs)(Q,{variant:`secondary`,onClick:()=>C(!0),disabled:!ce.length||!n(`kprofiles:delete`),title:n(`kprofiles:delete`)?void 0:e(`kProfiles.permission.noDelete`),children:[(0,G.jsx)(mu,{className:`w-4 h-4`}),e(`kProfiles.select`)]})]}),P?(0,G.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):re?(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`py-12 text-center`,children:[(0,G.jsx)(qu,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.printerOffline`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`kProfiles.printerOfflineDesc`)}),(0,G.jsxs)(Q,{variant:`secondary`,onClick:()=>L(),children:[(0,G.jsx)(Rl,{className:`w-4 h-4`}),e(`common.refresh`)]})]})}):ce.length>0?ue?(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray mb-2 px-1`,children:e(`kProfiles.leftExtruder`)}),(0,G.jsx)(`div`,{className:`space-y-1`,children:ce.filter(e=>e.extruder_id===1).map(e=>(0,G.jsx)(Y8,{profile:e,onEdit:()=>c(e),onCopy:()=>f(e),selectionMode:S,isSelected:w.has(A(e)),onToggleSelect:()=>me(A(e)),note:xe(e)},A(e)))})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray mb-2 px-1`,children:e(`kProfiles.rightExtruder`)}),(0,G.jsx)(`div`,{className:`space-y-1`,children:ce.filter(e=>e.extruder_id===0).map(e=>(0,G.jsx)(Y8,{profile:e,onEdit:()=>c(e),onCopy:()=>f(e),selectionMode:S,isSelected:w.has(A(e)),onToggleSelect:()=>me(A(e)),note:xe(e)},A(e)))})]})]}):(0,G.jsx)(`div`,{className:`space-y-1`,children:ce.map(e=>(0,G.jsx)(Y8,{profile:e,onEdit:()=>c(e),onCopy:()=>f(e),selectionMode:S,isSelected:w.has(A(e)),onToggleSelect:()=>me(A(e)),note:xe(e)},A(e)))}):p||h!==`all`||_!==`all`?(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`py-12 text-center`,children:[(0,G.jsx)(Jl,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noMatchingProfiles`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`kProfiles.noMatchingProfilesDesc`)})]})}):(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`py-12 text-center`,children:[(0,G.jsx)(xc,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noKProfiles`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`kProfiles.noKProfilesDesc`,{diameter:a})}),(0,G.jsxs)(Q,{onClick:()=>u(!0),children:[(0,G.jsx)(jl,{className:`w-4 h-4`}),e(`kProfiles.createFirstProfile`)]})]})}),s&&r&&(()=>{let{note:e,key:t}=be(s);return(0,G.jsx)(X8,{profile:s,printerId:r,nozzleDiameter:a,existingProfiles:N?.profiles,builtinFilaments:oe,filamentPresets:se,isDualNozzle:ue,supportsFlowType:de,initialNote:e,initialNoteKey:t,onSaveNote:ye,hasPermission:n,onClose:()=>{console.log(`[KProfiles] Edit modal onClose - refetching profiles...`),c(null),L()},onSave:()=>{c(null),L()}})})(),l&&r&&(0,G.jsx)(X8,{printerId:r,nozzleDiameter:a,existingProfiles:N?.profiles,builtinFilaments:oe,filamentPresets:se,isDualNozzle:ue,supportsFlowType:de,onSaveNote:ye,hasPermission:n,onClose:()=>{u(!1),L()},onSave:()=>{u(!1),L()}}),d&&r&&(0,G.jsx)(X8,{printerId:r,nozzleDiameter:a,existingProfiles:N?.profiles,builtinFilaments:oe,filamentPresets:se,isDualNozzle:ue,supportsFlowType:de,onSaveNote:ye,hasPermission:n,profile:{...d,slot_id:0,name:`${d.name} (Copy)`},onClose:()=>{f(null),L()},onSave:()=>{f(null),L()}}),E&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,G.jsx)(jd,{className:`w-full max-w-sm`,children:(0,G.jsxs)(Nd,{className:`p-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center`,children:(0,G.jsx)(Au,{className:`w-5 h-5 text-red-500`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:e(`kProfiles.bulkDelete.title`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`kProfiles.bulkDelete.cannotUndo`)})]})]}),(0,G.jsx)(`p`,{className:`text-bambu-gray mb-6`,children:e(`kProfiles.bulkDelete.message`,{count:w.size})}),(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(Q,{variant:`secondary`,onClick:()=>D(!1),disabled:O,className:`flex-1`,children:e(`common.cancel`)}),(0,G.jsxs)(Q,{onClick:_e,disabled:O,className:`flex-1 bg-red-500 hover:bg-red-600 text-white`,children:[O?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Au,{className:`w-4 h-4`}),e(`common.delete`)]})]})]})})})]})}var Q8=[`PLA`,`PETG`,`PCTG`,`ABS`,`ASA`,`TPU`,`PC`,`PA`,`PVA`,`HIPS`,`PP`,`PET`,`NYLON`],rUe={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 iUe(e){let t=e.toUpperCase();for(let e of Q8)if(RegExp(`\\b${e}\\b`).test(t))return e;return null}function aUe(e){let t=e.replace(/@.+$/,``).trim(),n=t.toUpperCase();for(let e of Q8){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 $8({preset:e,onDelete:t,onExpand:n,isExpanded:r}){let{t:i}=U(),{hasPermission:a}=Td(),o=e.filament_type||iUe(e.name),s=e.filament_vendor||aUe(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=rUe[o.toUpperCase()]||null),(0,G.jsx)(jd,{className:`bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80 transition-colors`,children:(0,G.jsxs)(Nd,{className:`p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[e.preset_type===`filament`&&(0,G.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,G.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,children:e.name})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[o&&(0,G.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-bambu-green/20 text-bambu-green`,children:o}),s&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:s}),(0,G.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400`,children:i(`profiles.localProfiles.badge`)})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[a(`settings:update`)&&(0,G.jsx)(`button`,{onClick:()=>t(e.id),className:`p-1 text-bambu-gray hover:text-red-600 dark:hover:text-red-400 transition-colors`,title:i(`profiles.localProfiles.delete`),children:(0,G.jsx)(Au,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`button`,{onClick:()=>n(r?null:e.id),className:`p-1 text-bambu-gray hover:text-white transition-colors`,children:r?(0,G.jsx)(ms,{className:`w-3.5 h-3.5`}):(0,G.jsx)(ds,{className:`w-3.5 h-3.5`})})]})]}),r&&(0,G.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-bambu-dark-tertiary text-xs space-y-1.5`,children:[o&&(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.filamentType`)}),(0,G.jsx)(`span`,{className:`text-white`,children:o})]}),s&&(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.vendor`)}),(0,G.jsx)(`span`,{className:`text-white`,children:s})]}),e.nozzle_temp_min!=null&&e.nozzle_temp_max!=null&&(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.nozzleTemp`)}),(0,G.jsxs)(`span`,{className:`text-white`,children:[e.nozzle_temp_min,`–`,e.nozzle_temp_max,`°C`]})]}),e.filament_cost&&(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.cost`)}),(0,G.jsx)(`span`,{className:`text-white`,children:e.filament_cost})]}),e.filament_density&&(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.density`)}),(0,G.jsxs)(`span`,{className:`text-white`,children:[e.filament_density,` g/cm³`]})]}),e.pressure_advance&&(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.pressureAdvance`)}),(0,G.jsx)(`span`,{className:`text-white`,children:e.pressure_advance})]}),e.compatible_printers&&(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.compatiblePrinters`)}),(0,G.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,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.inheritsFrom`)}),(0,G.jsx)(`span`,{className:`text-white truncate ml-2`,children:e.inherits})]}),(0,G.jsxs)(`div`,{className:`flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.source`)}),(0,G.jsx)(`span`,{className:`text-white capitalize`,children:e.source})]})]})]})})}function oUe(){let{t:e}=U(),{hasPermission:t}=Td(),n=so(),{showToast:r}=zd(),[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}=K({queryKey:[`localPresets`],queryFn:()=>Z.getLocalPresets()}),m=q({mutationFn:async e=>{let t=[];for(let n of Array.from(e)){let e=new FormData;e.append(`file`,n),t.push(await Z.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=q({mutationFn:e=>Z.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,G.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):(0,G.jsxs)(`div`,{className:`space-y-6`,children:[t(`settings:update`)&&(0,G.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,G.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,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,G.jsx)(Y,{className:`w-5 h-5 text-bambu-green animate-spin`}),(0,G.jsx)(`span`,{className:`text-bambu-gray`,children:e(`profiles.localProfiles.importing`)})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Lu,{className:`w-8 h-8 text-bambu-gray mx-auto mb-2`}),(0,G.jsx)(`p`,{className:`text-sm text-white font-medium`,children:e(`profiles.localProfiles.import`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`profiles.localProfiles.importDesc`)})]})]}),w&&(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(Jl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,G.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,G.jsxs)(`div`,{className:`text-center py-12`,children:[(0,G.jsx)(Ac,{className:`w-12 h-12 text-bambu-gray mx-auto mb-3 opacity-50`}),(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`profiles.localProfiles.noPresets`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray/60 mt-1`,children:e(`profiles.localProfiles.importDesc`)})]}),w&&C===0&&!p&&(0,G.jsxs)(`div`,{className:`text-center py-12`,children:[(0,G.jsx)(Jl,{className:`w-12 h-12 text-bambu-gray mx-auto mb-3 opacity-50`}),(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:e(`profiles.localProfiles.noSearchResults`)})]}),C>0&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6`,children:[b.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(Js,{className:`w-4 h-4 text-bambu-green`}),(0,G.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:e(`profiles.localProfiles.filament`)}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`(`,b.length,`)`]})]}),(0,G.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,G.jsx)($8,{preset:e,onDelete:e=>d(e),onExpand:s,isExpanded:o===e.id},e.id))})]}),S.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(Uc,{className:`w-4 h-4 text-blue-600 dark:text-blue-400`}),(0,G.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:e(`profiles.localProfiles.process`)}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`(`,S.length,`)`]})]}),(0,G.jsx)(`div`,{className:`space-y-2`,children:S.map(e=>(0,G.jsx)($8,{preset:e,onDelete:e=>d(e),onExpand:s,isExpanded:o===e.id},e.id))})]}),x.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(Ql,{className:`w-4 h-4 text-orange-600 dark:text-orange-400`}),(0,G.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:e(`profiles.localProfiles.printer`)}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`(`,x.length,`)`]})]}),(0,G.jsx)(`div`,{className:`space-y-2`,children:x.map(e=>(0,G.jsx)($8,{preset:e,onDelete:e=>d(e),onExpand:s,isExpanded:o===e.id},e.id))})]})]}),u!==null&&(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,G.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg p-6 max-w-sm mx-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(_s,{className:`w-5 h-5 text-red-600 dark:text-red-400`}),(0,G.jsx)(`h3`,{className:`text-white font-medium`,children:e(`profiles.localProfiles.deleteConfirmTitle`)})]}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:e(`profiles.localProfiles.deleteConfirm`)}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`secondary`,size:`sm`,onClick:()=>d(null),children:e(`profiles.localProfiles.cancel`)}),(0,G.jsxs)(Q,{variant:`danger`,size:`sm`,onClick:()=>h.mutate(u),disabled:h.isPending,children:[h.isPending?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(Au,{className:`w-4 h-4`}),e(`profiles.localProfiles.delete`)]})]})]})})]})}function sUe(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 cUe({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:sUe(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,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`space-y-4 mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.jsx)(Jl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,G.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,G.jsx)(`div`,{className:`flex gap-2`,children:(0,G.jsxs)(Q,{variant:`secondary`,onClick:n,disabled:r,children:[(0,G.jsx)(Rl,{className:`w-4 h-4 ${r?`animate-spin`:``}`}),a(`profiles.cloudView.refresh`)]})})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(bc,{className:`w-4 h-4 text-bambu-gray`}),(0,G.jsx)(r5,{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,G.jsx)(r5,{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,G.jsx)(r5,{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,G.jsx)(r5,{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,G.jsx)(r5,{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,G.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,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray`,children:[t&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(ks,{className:`w-3 h-3`}),a(`profiles.cloudView.lastSynced`),` `,Xf(t.toISOString(),`system`,a)]}),(0,G.jsx)(`span`,{children:a(`profiles.cloudView.showingCount`,{showing:w.length,total:D})})]}),w.length===0?(0,G.jsxs)(`div`,{className:`text-center py-16`,children:[(0,G.jsx)(Uc,{className:`w-12 h-12 text-bambu-gray-dark mx-auto mb-4`}),(0,G.jsx)(`p`,{className:`text-bambu-gray`,children:a(`profiles.cloudView.noPresetsFound`)}),E&&(0,G.jsx)(`button`,{onClick:T,className:`mt-2 text-sm text-bambu-green hover:text-bambu-green-light`,children:a(`profiles.cloudView.clearFilters`)})]}):(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-6`,children:[(0,G.jsx)(e5,{icon:(0,G.jsx)(Js,{className:`w-4 h-4 text-amber-600 dark:text-amber-400`}),title:a(`profiles.cloudView.columns.filament`),presets:O(`filament`),emptyText:a(`profiles.cloudView.noFilamentPresets`),onSelect:b}),(0,G.jsx)(e5,{icon:(0,G.jsx)(Ql,{className:`w-4 h-4 text-blue-600 dark:text-blue-400`}),title:a(`profiles.cloudView.columns.process`),presets:O(`process`),emptyText:a(`profiles.cloudView.noProcessPresets`),onSelect:b}),(0,G.jsx)(e5,{icon:(0,G.jsx)(Pl,{className:`w-4 h-4 text-purple-600 dark:text-purple-400`}),title:a(`profiles.cloudView.columns.printer`),presets:O(`printer`),emptyText:a(`profiles.cloudView.noPrinterPresets`),onSelect:b})]}),v&&(0,G.jsx)(uUe,{setting:v,onClose:()=>b(null),t:a})]})}function e5({icon:e,title:t,presets:n,emptyText:r,onSelect:i}){return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 px-1`,children:[e,(0,G.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray`,children:t}),(0,G.jsxs)(`span`,{className:`text-xs text-bambu-gray-dark`,children:[`(`,n.length,`)`]})]}),(0,G.jsx)(`div`,{className:`space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1`,children:n.length===0?(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray-dark px-3 py-2`,children:r}):n.map(e=>(0,G.jsx)(lUe,{preset:e,onClick:()=>i(e)},e.setting_id))})]})}function lUe({preset:e,onClick:t}){return(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-white text-sm truncate flex-1`,title:e.name,children:e.name}),e.meta.filamentType&&e.type===`filament`&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:e.meta.filamentType}),e.meta.layerHeight&&e.type===`process`&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:e.meta.layerHeight}),e.meta.printer&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:e.meta.printer})]})})}function uUe({setting:e,onClose:t,t:n}){let{data:r,isLoading:i,error:a}=K({queryKey:[`orcaCloudProfileDetail`,e.setting_id],queryFn:()=>Z.orcaCloudGetProfile(e.setting_id),retry:!1});return(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/60 z-50 flex items-center justify-center p-4`,onClick:t,children:(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:e.name}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:e.type})]}),(0,G.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white p-1`,children:(0,G.jsx)(Qu,{className:`w-5 h-5`})})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:i?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):a?(0,G.jsx)(`p`,{className:`text-center text-bambu-gray py-16`,children:a.message}):r?(0,G.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,G.jsx)(`p`,{className:`text-center text-bambu-gray py-16`,children:n(`profiles.cloudView.noPresetsFound`)})})]})})}function dUe(){let{t:e}=U(),t=so(),{showToast:n}=zd(),{hasPermission:r}=Td(),i=r(`orca_cloud:auth`),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(5e3),[l,u]=(0,y.useState)(null),{data:d,isLoading:f}=K({queryKey:[`orcaCloudStatus`],queryFn:Z.orcaCloudStatus}),p=!!d?.connected,{data:m,isLoading:h,refetch:g,isRefetching:_,error:v,dataUpdatedAt:b}=K({queryKey:[`orcaCloudProfiles`],queryFn:Z.orcaCloudListProfiles,enabled:p,retry:!1,staleTime:1e3*60*5}),{data:x=[]}=K({queryKey:[`printers`],queryFn:Z.getPrinters,enabled:p}),[S,C]=(0,y.useState)();(0,y.useEffect)(()=>{b&&C(new Date(b))},[b]);let w=()=>{o(null),c(5e3)},T=t=>{t===`access_denied`?u(e(`profiles.orcaCloud.errors.denied`)):t===`expired_token`&&u(e(`profiles.orcaCloud.errors.expired`)),w()},E=q({mutationFn:Z.orcaCloudDeviceStart,onSuccess:e=>{u(null),c(Math.max(1,e.interval)*1e3),o(e)},onError:t=>{u(t.message||e(`profiles.orcaCloud.errors.startFailed`))}}),D=q({mutationFn:Z.orcaCloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:[`orcaCloudStatus`]}),t.removeQueries({queryKey:[`orcaCloudProfiles`]}),n(e(`profiles.orcaCloud.toast.disconnected`))}}),{data:O,error:k}=K({queryKey:[`orcaCloudDevicePoll`,a?.user_code??`none`],queryFn:Z.orcaCloudDevicePoll,enabled:a!==null,gcTime:0,retry:!1,refetchOnWindowFocus:!1,refetchInterval:a===null?!1:s}),A=(0,y.useRef)(null);return(0,y.useEffect)(()=>{if(!a||!O)return;let r=O.status;if(r===`slow_down`){c(e=>e+5e3);return}r!==`authorization_pending`&&A.current!==r&&(A.current=r,r===`complete`?(w(),t.invalidateQueries({queryKey:[`orcaCloudStatus`]}),t.invalidateQueries({queryKey:[`orcaCloudProfiles`]}),n(e(`profiles.orcaCloud.connectedShort`))):T(r))},[O,a]),(0,y.useEffect)(()=>{a&&k&&(u(e(`profiles.orcaCloud.errors.pollFailed`)),w())},[k,a]),(0,y.useEffect)(()=>{a&&(A.current=null)},[a]),f?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):(0,G.jsxs)(`div`,{children:[p&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-bambu-green animate-pulse`}),(0,G.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:d?.email?(0,G.jsxs)(G.Fragment,{children:[e(`profiles.orcaCloud.connectedAs`),` `,(0,G.jsx)(`span`,{className:`text-white`,children:d.email})]}):(0,G.jsx)(`span`,{className:`text-white`,children:e(`profiles.orcaCloud.connectedShort`)})})]}),(0,G.jsxs)(Q,{variant:`secondary`,size:`sm`,onClick:()=>D.mutate(),disabled:D.isPending||!i,title:i?void 0:e(`profiles.orcaCloud.noLogoutPermission`),children:[(0,G.jsx)(el,{className:`w-4 h-4`}),e(`profiles.orcaCloud.logout`)]})]}),p?h?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,G.jsx)(Y,{className:`w-8 h-8 text-bambu-green animate-spin`})}):v?(0,G.jsxs)(`div`,{className:`text-center py-16`,children:[(0,G.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:v.message}),(0,G.jsx)(Q,{onClick:()=>g(),children:e(`profiles.orcaCloud.retry`)})]}):m?(0,G.jsx)(cUe,{settings:m,lastSyncTime:S,onRefresh:()=>g(),isRefreshing:_,printers:x,t:e}):null:(0,G.jsx)(fUe,{pairing:a,connectError:l,onConnect:()=>E.mutate(),onCancel:w,isStarting:E.isPending,canManage:i,t:e})]})}function fUe({pairing:e,connectError:t,onConnect:n,onCancel:r,isStarting:i,canManage:a,t:o}){return e?(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`p-8 text-center max-w-md mx-auto`,children:[(0,G.jsx)(Ms,{className:`w-12 h-12 text-bambu-green mx-auto mb-4`}),(0,G.jsx)(`h2`,{className:`text-xl font-bold text-white mb-2`,children:o(`profiles.orcaCloud.device.title`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray mb-6`,children:o(`profiles.orcaCloud.device.instruction`)}),(0,G.jsx)(`p`,{className:`text-xs uppercase tracking-wide text-bambu-gray mb-2`,children:o(`profiles.orcaCloud.device.codeLabel`)}),(0,G.jsx)(`div`,{className:`mb-6 py-3 px-4 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg`,children:(0,G.jsx)(`span`,{className:`text-2xl font-mono font-bold tracking-[0.3em] text-white select-all`,children:e.user_code})}),(0,G.jsx)(`a`,{href:e.verification_uri_complete,target:`_blank`,rel:`noopener noreferrer`,children:(0,G.jsxs)(Q,{className:`w-full mb-3`,children:[(0,G.jsx)(ec,{className:`w-4 h-4`}),o(`profiles.orcaCloud.device.openButton`)]})}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray break-all mb-6`,children:o(`profiles.orcaCloud.device.manualHint`,{url:e.verification_uri})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-sm text-bambu-gray mb-4`,children:[(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin text-bambu-green`}),o(`profiles.orcaCloud.device.waiting`)]}),(0,G.jsx)(`button`,{type:`button`,onClick:r,className:`text-bambu-gray hover:text-white text-sm`,children:o(`profiles.orcaCloud.device.cancel`)})]})}):(0,G.jsx)(jd,{children:(0,G.jsxs)(Nd,{className:`p-8 text-center`,children:[(0,G.jsx)(Ms,{className:`w-12 h-12 text-bambu-green mx-auto mb-4`}),(0,G.jsx)(`h2`,{className:`text-xl font-bold text-white mb-2`,children:o(`profiles.orcaCloud.connect.title`)}),(0,G.jsx)(`p`,{className:`text-bambu-gray mb-6 max-w-xl mx-auto`,children:o(`profiles.orcaCloud.connect.description`)}),(0,G.jsxs)(`div`,{className:`max-w-sm mx-auto`,children:[(0,G.jsxs)(Q,{onClick:n,disabled:i||!a,title:a?void 0:o(`profiles.orcaCloud.noConnectPermission`),className:`w-full`,children:[i?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(us,{className:`w-4 h-4`}),o(`profiles.orcaCloud.connectButton`)]}),t&&(0,G.jsxs)(`p`,{className:`mt-3 text-sm text-red-700 dark:text-red-400 flex items-center justify-center gap-2`,children:[(0,G.jsx)(_s,{className:`w-4 h-4 flex-shrink-0`}),t]})]})]})})}function t5(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 n5(e){return/^(P[FPM]US|PF\d|PP\d)/.test(e)}function pUe({onSuccess:e,t}){let{showToast:n}=zd(),[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,x]=(0,y.useState)(!1),S=q({mutationFn:()=>Z.cloudLogin(a,s,p),onSuccess:r=>{if(x(r.reason===`captcha`),r.success)n(t(`profiles.login.toast.loggedIn`)),e();else if(r.reason===`captcha`)return;else 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=>{x(!1),n(e.message,`error`)}}),C=q({mutationFn:()=>Z.cloudVerify(a,l,_||void 0,p),onSuccess:r=>{x(r.reason===`captcha`),r.success?(n(t(`profiles.login.toast.loggedIn`)),e()):r.reason!==`captcha`&&n(r.message,`error`)},onError:e=>{x(!1),n(e.message,`error`)}}),w=q({mutationFn:()=>Z.cloudSetToken(d,p),onSuccess:()=>{n(t(`profiles.login.toast.tokenSet`)),e()},onError:e=>n(e.message,`error`)}),T=e=>{e.preventDefault(),r===`email`?S.mutate():r===`code`?C.mutate():r===`token`&&w.mutate()},E=S.isPending||C.isPending||w.isPending;return(0,G.jsx)(jd,{className:`max-w-md mx-auto`,children:(0,G.jsxs)(Nd,{children:[(0,G.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,G.jsx)(`div`,{className:`inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3`,children:(0,G.jsx)(Ms,{className:`w-6 h-6 text-bambu-green`})}),(0,G.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:t(`profiles.login.title`)}),(0,G.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:t(`profiles.login.subtitle`)})]}),b&&r!==`token`&&(0,G.jsx)(`div`,{role:`alert`,className:`mb-4 p-3 rounded-lg border border-amber-500/40 bg-amber-500/10`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,G.jsx)(eu,{className:`w-4 h-4 text-amber-400 shrink-0 mt-0.5`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm font-medium text-amber-300`,children:t(`profiles.login.captchaTitle`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:t(`profiles.login.captchaBody`)}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{x(!1),i(`token`)},className:`mt-2 text-xs text-bambu-green hover:underline flex items-center gap-1`,children:[(0,G.jsx)(Vc,{className:`w-3 h-3`}),t(`profiles.login.useToken`)]})]})]})}),(0,G.jsxs)(`form`,{onSubmit:T,className:`space-y-4`,children:[r===`email`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.email`)}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.password`)}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.region`)}),(0,G.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,G.jsx)(`option`,{value:`global`,children:t(`profiles.login.regionGlobal`)}),(0,G.jsx)(`option`,{value:`china`,children:t(`profiles.login.regionChina`)})]})]})]}),r===`code`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(h===`totp`?`profiles.login.totpCode`:`profiles.login.verificationCode`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:h===`totp`?t(`profiles.login.enterTotpHint`):t(`profiles.login.checkEmail`,{email:a})}),(0,G.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,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.accessToken`)}),(0,G.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:t(`profiles.login.accessTokenHint`)}),(0,G.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,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.region`)}),(0,G.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,G.jsx)(`option`,{value:`global`,children:t(`profiles.login.regionGlobal`)}),(0,G.jsx)(`option`,{value:`china`,children:t(`profiles.login.regionChina`)})]})]})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 max-[550px]:flex-wrap max-[550px]:items-center`,children:[r===`code`&&(0,G.jsx)(Q,{type:`button`,variant:`secondary`,onClick:()=>i(`email`),className:`flex-1`,children:t(`profiles.login.back`)}),(0,G.jsxs)(Q,{type:`submit`,disabled:E,className:`flex-1`,children:[E?(0,G.jsx)(Y,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)($c,{className:`w-4 h-4`}),t(r===`email`?`profiles.login.loginButton`:r===`code`?`profiles.login.verifyButton`:`profiles.login.setTokenButton`)]})]}),r===`email`&&(0,G.jsx)(`div`,{className:`pt-4 border-t border-bambu-dark-tertiary`,children:(0,G.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,G.jsx)(Vc,{className:`w-4 h-4`}),t(`profiles.login.useToken`)]})}),r===`token`&&(0,G.jsx)(`div`,{className:`pt-4 border-t border-bambu-dark-tertiary`,children:(0,G.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,G.jsx)($c,{className:`w-4 h-4`}),t(`profiles.login.useEmail`)]})})]})]})})}function r5({label:e,value:t,options:n,onChange:r}){let[i,a]=(0,y.useState)(!1),o=n.find(e=>e.value===t);return(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.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,G.jsxs)(`span`,{className:`text-bambu-gray`,children:[e,`:`]}),(0,G.jsx)(`span`,{children:o?.label||`All`}),(0,G.jsx)(ds,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?`rotate-180`:``}`})]}),i&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>a(!1)}),(0,G.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,G.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,G.jsx)(`span`,{children:e.label}),e.count!==void 0&&(0,G.jsx)(`span`,{className:`text-bambu-gray text-xs`,children:e.count})]},e.value))})]})]})}function mUe(){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,G.jsx)(`button`,{onClick:()=>{window.scrollTo({top:0,behavior:`smooth`})},className:`fixed bottom-24 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,G.jsx)(Vo,{className:`w-5 h-5`})}):null}function i5({setting:e,onClick:t,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o,t:s}){let c=t5(e.name),l=n5(e.setting_id);return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 group`,children:[(0,G.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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&a!==void 0&&(0,G.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,G.jsx)(`span`,{className:`flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green`,title:s(`profiles.presets.myPreset`)}),(0,G.jsx)(`span`,{className:`text-white text-sm truncate flex-1`,title:e.name,children:e.name}),c.filamentType&&e.type===`filament`&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:c.filamentType}),c.layerHeight&&e.type===`process`&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:c.layerHeight}),c.printer&&(0,G.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:c.printer})]})}),(0,G.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,G.jsx)(zs,{className:`w-4 h-4`})})]})}function a5(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`""" diff --git a/static/index.html b/static/index.html index c9c5ba9b5..57e884b2f 100644 --- a/static/index.html +++ b/static/index.html @@ -26,7 +26,7 @@ - +