diff --git a/docs/advanced/advanced-guide.en.md b/docs/advanced/advanced-guide.en.md index 91580db..b5e67b9 100644 --- a/docs/advanced/advanced-guide.en.md +++ b/docs/advanced/advanced-guide.en.md @@ -224,13 +224,13 @@ if __name__ == "__main__": Alternative front-ends can reuse the `/api/config` endpoints that power the built-in YAML editor (one line each; see `src/profiles/server/routes/config.py` for the full contracts): -- `GET /api/config/content` — the active file's text as `{filename, content, config_path, session_trial}`; a session trial answers an empty body with `session_trial=True`, a missing file answers 404. +- `GET /api/config/content` — the active file's text as `{filename, content, config_path, session_trial, content_hash}`; `content_hash` is the SHA-256 of the served text, the staleness baseline to echo back on save (issue #116). A session trial answers an empty body with `session_trial=True`, a missing file answers 404. - `POST /api/config/validate` — validate content in memory, never applied to the session; always answers 200 with `{valid, issues[]}` (invalid drafts come back as data, not as an HTTP error). - `POST /api/config/template` — render the starter template in memory (nothing written, no state change); the same content `--init` puts on disk. -- `POST /api/config/save` — write the content to the active config file and re-apply it; refuses a session trial (400) since there is no file to overwrite. -- `POST /api/config/save-as` — write to a new file (extension whitelist `.profiles` / `.profiles.yaml`, overwrite guard answering 409 without `overwrite=true`) and anchor the session onto it. +- `POST /api/config/save` — write the content to the active config file (atomically, via temp file + replace) and re-apply it; refuses a session trial (400) since there is no file to overwrite. With an optional `baseline_hash`, answers **409** when the on-disk file no longer matches the hash the client loaded — an external edit is refused instead of silently clobbered; `overwrite_changes=true` lifts the guard. The response carries `content_hash`, the next save's baseline. +- `POST /api/config/save-as` — write to a new file (extension whitelist `.profiles` / `.profiles.yaml`, overwrite guard answering 409 without `overwrite=true`) and anchor the session onto it; no baseline check (the editor's baseline describes the file it loaded, not the save-as target). -Note the error duality on `save`/`save-as`: validation failures answer **400 with a JSON issues list** (`[{severity, message}, ...]`), while every other refusal (session-trial save, bad filename, missing directory, 409 existing target) answers with a **plain string** `detail` — clients must handle both shapes. The save endpoints also apply the freshly written file to the session, so a response's `config` object is the new live configuration. +Note the error duality on `save`/`save-as`: validation failures answer **400 with a JSON issues list** (`[{severity, message}, ...]`), while every other refusal (session-trial save, bad filename, missing directory, 409 existing target, 409 stale baseline) answers with a **plain string** `detail` — clients must handle both shapes. The save endpoints also apply the freshly written file to the session, so a response's `config` object is the new live configuration. --- diff --git a/docs/advanced/guide-avance.fr.md b/docs/advanced/guide-avance.fr.md index 3ece2fe..9192f23 100644 --- a/docs/advanced/guide-avance.fr.md +++ b/docs/advanced/guide-avance.fr.md @@ -212,13 +212,13 @@ if __name__ == "__main__": Les interfaces alternatives peuvent réutiliser les endpoints `/api/config` qui alimentent l'éditeur YAML intégré (une ligne chacun ; voir `src/profiles/server/routes/config.py` pour les contrats complets) : -- `GET /api/config/content` — le texte du fichier actif sous `{filename, content, config_path, session_trial}` ; une config d'essai répond un corps vide avec `session_trial=True`, un fichier manquant répond 404. +- `GET /api/config/content` — le texte du fichier actif sous `{filename, content, config_path, session_trial, content_hash}` ; `content_hash` est le SHA-256 du texte servi, la baseline d'obsolescence à renvoyer à la sauvegarde (issue #116). Une config d'essai répond un corps vide avec `session_trial=True`, un fichier manquant répond 404. - `POST /api/config/validate` — valide le contenu en mémoire, jamais appliqué à la session ; répond toujours 200 avec `{valid, issues[]}` (les brouillons invalides reviennent sous forme de données, pas d'erreur HTTP). - `POST /api/config/template` — rend le modèle starter en mémoire (rien n'est écrit, aucun changement d'état) ; le même contenu que `--init` pose sur disque. -- `POST /api/config/save` — écrit le contenu dans le fichier de config actif puis le ré-applique ; refuse une config d'essai (400) puisqu'il n'y a aucun fichier à écraser. -- `POST /api/config/save-as` — écrit dans un nouveau fichier (liste blanche d'extensions `.profiles` / `.profiles.yaml`, garde d'existence répondant 409 sans `overwrite=true`) et ancre la session dessus. +- `POST /api/config/save` — écrit le contenu dans le fichier de config actif (de manière atomique, via fichier temporaire + replace) puis le ré-applique ; refuse une config d'essai (400) puisqu'il n'y a aucun fichier à écraser. Avec un `baseline_hash` optionnel, répond **409** quand le fichier sur disque ne correspond plus au hash chargé par le client — une édition externe est refusée au lieu d'être écrasée silencieusement ; `overwrite_changes=true` lève la garde. La réponse porte `content_hash`, la baseline de la prochaine sauvegarde. +- `POST /api/config/save-as` — écrit dans un nouveau fichier (liste blanche d'extensions `.profiles` / `.profiles.yaml`, garde d'existence répondant 409 sans `overwrite=true`) et ancre la session dessus ; pas de vérification de baseline (la baseline de l'éditeur décrit le fichier chargé, pas la cible du save-as). -Notez la dualité des erreurs sur `save`/`save-as` : un échec de validation répond **400 avec une liste JSON de problèmes** (`[{severity, message}, ...]`), tandis que tout autre refus (save d'une config d'essai, nom de fichier invalide, répertoire inexistant, cible existante en 409) répond avec un `detail` **chaîne simple** — les clients doivent gérer les deux formes. Les endpoints de sauvegarde appliquent aussi le fichier fraîchement écrit à la session : le `config` de la réponse est donc la nouvelle configuration active. +Notez la dualité des erreurs sur `save`/`save-as` : un échec de validation répond **400 avec une liste JSON de problèmes** (`[{severity, message}, ...]`), tandis que tout autre refus (save d'une config d'essai, nom de fichier invalide, répertoire inexistant, cible existante en 409, baseline obsolète en 409) répond avec un `detail` **chaîne simple** — les clients doivent gérer les deux formes. Les endpoints de sauvegarde appliquent aussi le fichier fraîchement écrit à la session : le `config` de la réponse est donc la nouvelle configuration active. --- diff --git a/src/profiles/core/config/io/__init__.py b/src/profiles/core/config/io/__init__.py index 02761b3..1619cad 100644 --- a/src/profiles/core/config/io/__init__.py +++ b/src/profiles/core/config/io/__init__.py @@ -4,8 +4,10 @@ CONFIG_FILE_NAMES, FALLBACK_CONFIG_NAMES, PRIMARY_CONFIG_NAME, + content_hash, find_config_file, read_yaml, + write_text_atomic, write_value, ) @@ -13,7 +15,9 @@ "CONFIG_FILE_NAMES", "FALLBACK_CONFIG_NAMES", "PRIMARY_CONFIG_NAME", + "content_hash", "find_config_file", "read_yaml", + "write_text_atomic", "write_value", ] diff --git a/src/profiles/core/config/io/yaml_io.py b/src/profiles/core/config/io/yaml_io.py index 1dac2c3..589785a 100644 --- a/src/profiles/core/config/io/yaml_io.py +++ b/src/profiles/core/config/io/yaml_io.py @@ -7,7 +7,9 @@ from __future__ import annotations +import hashlib import os +import tempfile from collections import deque from pathlib import Path @@ -83,6 +85,54 @@ def write_value(path: Path | str, dotted_key: str, value: object) -> None: _yaml.dump(data, fh) +def write_text_atomic(path: Path | str, content: str) -> None: + """Write *content* to *path* atomically (temp file + ``os.replace``). + + A plain ``write_text`` can leave a truncated file behind when the + process dies or power is lost mid-write — and the configuration file + is the user's only one. The text is written to a temp file created in + the *same directory* (so ``os.replace`` stays on one filesystem and + remains atomic), flushed to disk, then renamed over the target. + + Args: + path: Destination file path. + content: Full text to write (UTF-8 encoded). + """ + p = Path(path) + fd, tmp_name = tempfile.mkstemp( + dir=p.parent, + prefix=f"{p.name}.", + suffix=".tmp", + ) + tmp_path = Path(tmp_name) + try: + with os.fdopen(fd, "w", encoding="utf-8") as fh: + fh.write(content) + fh.flush() + os.fsync(fh.fileno()) + os.replace(tmp_path, p) + except BaseException: + tmp_path.unlink(missing_ok=True) + raise + + +def content_hash(content: str) -> str: + """Return the SHA-256 hex digest of *content* (UTF-8 encoded). + + Version marker returned by ``GET /api/config/content`` and compared + by ``POST /api/config/save`` against the on-disk file, so an external + edit landing between the editor's load and its Save is detected + instead of silently clobbered (issue #116). + + Args: + content: Text to fingerprint. + + Returns: + Lowercase hex digest string. + """ + return hashlib.sha256(content.encode("utf-8")).hexdigest() + + def _find_named_file(start: Path, name: str, max_depth: int) -> Path | None: """Return the first *name* file within *max_depth* of *start*. @@ -170,7 +220,9 @@ def find_config_file( "CONFIG_FILE_NAMES", "FALLBACK_CONFIG_NAMES", "PRIMARY_CONFIG_NAME", + "content_hash", "find_config_file", "read_yaml", + "write_text_atomic", "write_value", ] diff --git a/src/profiles/server/routes/config.py b/src/profiles/server/routes/config.py index df781bd..6c275f1 100644 --- a/src/profiles/server/routes/config.py +++ b/src/profiles/server/routes/config.py @@ -8,7 +8,7 @@ from pydantic import BaseModel from profiles.core.config.diagnostics import collect_config_issues -from profiles.core.config.io.yaml_io import CONFIG_FILE_NAMES +from profiles.core.config.io.yaml_io import CONFIG_FILE_NAMES, content_hash, write_text_atomic from profiles.core.config.models import AppConfig from profiles.core.config.reader import ConfigReader from profiles.core.config.template import STARTER_CONFIG_TEMPLATE @@ -44,6 +44,13 @@ class ValidateRequest(BaseModel): class SaveRequest(BaseModel): content: str force: bool = False + # Staleness guard (issue #116): the content hash the editor loaded + # (from GET /content or a previous save response). Optional — a save + # without it keeps the legacy no-check behaviour. + baseline_hash: str | None = None + # When True a baseline mismatch no longer refuses the write: the user + # answered the 409 conflict with "overwrite anyway". + overwrite_changes: bool = False class SaveAsRequest(BaseModel): @@ -365,9 +372,13 @@ async def validate_config_endpoint(payload: ValidateRequest) -> dict: async def get_config_content(request: Request) -> dict: """Return the active configuration file's text for the YAML editor. - Responds ``{"filename", "content", "config_path", "session_trial"}``. - A session trial (config applied from dropped content) answers the - text that was applied (``ServerState.trial_content``, issue #97) with + Responds ``{"filename", "content", "config_path", "session_trial", + "content_hash"}``. ``content_hash`` is the SHA-256 of the served + text (issue #116): the editor echoes it back on ``POST /save`` as + its baseline so a concurrent external edit is refused with 409 + instead of silently clobbered. A session trial (config applied from + dropped content) answers the text that was applied + (``ServerState.trial_content``, issue #97) with ``session_trial=True`` and ``config_path=None`` — ``config_path`` stays ``None`` so the stale CWD-resolved path never leaks, and ``filename`` carries the config's display name. A @@ -375,11 +386,13 @@ async def get_config_content(request: Request) -> dict: """ state: ServerState = request.app.state.server_state if not has_disk_path(state): + content = state.trial_content or "" return { "filename": state.config.title or "session-trial", - "content": state.trial_content or "", + "content": content, "config_path": None, "session_trial": True, + "content_hash": content_hash(content), } config_path = state.active_config_path() @@ -389,11 +402,13 @@ async def get_config_content(request: Request) -> dict: detail=f"Configuration file not found: {config_path}", ) + content = config_path.read_text(encoding="utf-8") return { "filename": config_path.name, - "content": config_path.read_text(encoding="utf-8"), + "content": content, "config_path": str(config_path), "session_trial": False, + "content_hash": content_hash(content), } @@ -402,16 +417,26 @@ async def save_config_endpoint(payload: SaveRequest, request: Request) -> dict: """Write editor content to the active config file and apply it. Gate order: session-trial refusal (:func:`has_disk_path`) → - :func:`validate_issues` → 400 with the issues list when invalid and - not ``force`` → write the file → :func:`_apply_config_from_disk`, so - the live configuration is always re-read from what is on disk. + staleness guard → :func:`validate_issues` → 400 with the issues list + when invalid and not ``force`` → atomic write (temp file + + :func:`os.replace`, issue #116) → :func:`_apply_config_from_disk`, + so the live configuration is always re-read from what is on disk. ``force=True`` is the escape hatch that lets a broken draft reach the disk (it will load as defaults until fixed); without it, bad YAML never touches the file. - Returns ``{"status": "SAVED", "path": str, "config": }``; - the apply step clears ``session_trial``, anchoring the saved config - to its file. + The staleness guard (issue #116) fires only when the client sends + ``baseline_hash``: when the on-disk file's hash no longer matches — + an external edit landed between the editor's load and this Save — + the write is refused with **409** instead of silently clobbered; + ``overwrite_changes=True`` answers the user's "overwrite anyway" + decision and lets the write through. Older callers that send no + baseline keep the legacy no-check behaviour. + + Returns ``{"status": "SAVED", "path": str, "config": , + "content_hash": str}`` — the hash of what was written, the next + save's baseline; the apply step clears ``session_trial``, anchoring + the saved config to its file. """ state: ServerState = request.app.state.server_state if not has_disk_path(state): @@ -422,13 +447,35 @@ async def save_config_endpoint(payload: SaveRequest, request: Request) -> dict: ) config_path = state.active_config_path() + + if payload.baseline_hash is not None and not payload.overwrite_changes: + if not config_path.exists(): + raise HTTPException( + status_code=409, + detail=f"Configuration file not found on disk: {config_path}. " + "It was deleted or moved since it was loaded.", + ) + on_disk_hash = content_hash(config_path.read_text(encoding="utf-8")) + if on_disk_hash != payload.baseline_hash: + raise HTTPException( + status_code=409, + detail="The configuration file changed on disk since it was " + "loaded (edited externally?). Saving would overwrite those " + "changes.", + ) + issues = validate_issues(payload.content) if issues and not payload.force: raise HTTPException(status_code=400, detail=issues) - config_path.write_text(payload.content, encoding="utf-8") + write_text_atomic(config_path, payload.content) config = _apply_config_from_disk(state, config_path) - return {"status": "SAVED", "path": str(config_path), "config": config} + return { + "status": "SAVED", + "path": str(config_path), + "config": config, + "content_hash": content_hash(payload.content), + } SAVE_AS_EXTENSIONS = (".profiles", ".profiles.yaml") @@ -446,13 +493,18 @@ async def save_as_config_endpoint(payload: SaveAsRequest, request: Request) -> d (:data:`SAVE_AS_EXTENSIONS`) → :func:`normalize_user_path` + directory existence → existence/overwrite guard (409 when the target exists without ``overwrite=True``) → :func:`validate_issues` → 400 - with the issues list when invalid and not ``force`` → write the file - → :func:`_apply_config_from_disk`, so the live configuration is + with the issues list when invalid and not ``force`` → atomic write + (temp file + :func:`os.replace`, issue #116) → + :func:`_apply_config_from_disk`, so the live configuration is always re-read from what is on disk (which also clears ``session_trial``). - Returns ``{"status": "SAVED", "path": str, "config": }``, - the same shape as ``POST /save``. + No baseline staleness check here (unlike ``POST /save``): the + editor's baseline describes the file it loaded, not the save-as + target — the existing-target 409 above is the guard for that path. + + Returns ``{"status": "SAVED", "path": str, "config": , + "content_hash": str}``, the same shape as ``POST /save``. """ state: ServerState = request.app.state.server_state @@ -485,9 +537,14 @@ async def save_as_config_endpoint(payload: SaveAsRequest, request: Request) -> d if issues and not payload.force: raise HTTPException(status_code=400, detail=issues) - target.write_text(payload.content, encoding="utf-8") + write_text_atomic(target, payload.content) config = _apply_config_from_disk(state, target) - return {"status": "SAVED", "path": str(target), "config": config} + return { + "status": "SAVED", + "path": str(target), + "config": config, + "content_hash": content_hash(payload.content), + } @router.post("/select-directory") diff --git a/src/profiles/web/dist/assets/index-CY2LGDSY.js b/src/profiles/web/dist/assets/index-CY2LGDSY.js new file mode 100644 index 0000000..e6f84b9 --- /dev/null +++ b/src/profiles/web/dist/assets/index-CY2LGDSY.js @@ -0,0 +1,448 @@ +var sM=Object.defineProperty;var oM=(n,e,t)=>e in n?sM(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var dh=(n,e,t)=>oM(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const o of l)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(l){const o={};return l.integrity&&(o.integrity=l.integrity),l.referrerPolicy&&(o.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?o.credentials="include":l.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(l){if(l.ep)return;l.ep=!0;const o=t(l);fetch(l.href,o)}})();function my(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Vg={exports:{}},_c={};/** + * @license React + * react-jsx-runtime.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Ok;function aM(){if(Ok)return _c;Ok=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(i,l,o){var a=null;if(o!==void 0&&(a=""+o),l.key!==void 0&&(a=""+l.key),"key"in l){o={};for(var u in l)u!=="key"&&(o[u]=l[u])}else o=l;return l=o.ref,{$$typeof:n,type:i,key:a,ref:l!==void 0?l:null,props:o}}return _c.Fragment=e,_c.jsx=t,_c.jsxs=t,_c}var Nk;function cM(){return Nk||(Nk=1,Vg.exports=aM()),Vg.exports}var y=cM(),Qg={exports:{}},qe={};/** + * @license React + * react.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Tk;function uM(){if(Tk)return qe;Tk=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),b=Symbol.for("react.view_transition"),v=Symbol.iterator;function w(R){return R===null||typeof R!="object"?null:(R=v&&R[v]||R["@@iterator"],typeof R=="function"?R:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,N={};function j(R,$,ue){this.props=R,this.context=$,this.refs=N,this.updater=ue||S}j.prototype.isReactComponent={},j.prototype.setState=function(R,$){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,$,"setState")},j.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function D(){}D.prototype=j.prototype;function I(R,$,ue){this.props=R,this.context=$,this.refs=N,this.updater=ue||S}var U=I.prototype=new D;U.constructor=I,C(U,j.prototype),U.isPureReactComponent=!0;var E=Array.isArray;function T(){}var z={H:null,A:null,T:null,S:null},te=Object.prototype.hasOwnProperty;function q(R,$,ue){var ge=ue.ref;return{$$typeof:n,type:R,key:$,ref:ge!==void 0?ge:null,props:ue}}function G(R,$){return q(R.type,$,R.props)}function F(R){return typeof R=="object"&&R!==null&&R.$$typeof===n}function se(R){var $={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(ue){return $[ue]})}var me=/\/+/g;function ne(R,$){return typeof R=="object"&&R!==null&&R.key!=null?se(""+R.key):$.toString(36)}function _(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(T,T):(R.status="pending",R.then(function($){R.status==="pending"&&(R.status="fulfilled",R.value=$)},function($){R.status==="pending"&&(R.status="rejected",R.reason=$)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function Z(R,$,ue,ge,je){var Ne=typeof R;(Ne==="undefined"||Ne==="boolean")&&(R=null);var Pe=!1;if(R===null)Pe=!0;else switch(Ne){case"bigint":case"string":case"number":Pe=!0;break;case"object":switch(R.$$typeof){case n:case e:Pe=!0;break;case m:return Pe=R._init,Z(Pe(R._payload),$,ue,ge,je)}}if(Pe)return je=je(R),Pe=ge===""?"."+ne(R,0):ge,E(je)?(ue="",Pe!=null&&(ue=Pe.replace(me,"$&/")+"/"),Z(je,$,ue,"",function(Pt){return Pt})):je!=null&&(F(je)&&(je=G(je,ue+(je.key==null||R&&R.key===je.key?"":(""+je.key).replace(me,"$&/")+"/")+Pe)),$.push(je)),1;Pe=0;var be=ge===""?".":ge+":";if(E(R))for(var _e=0;_e>>1,A=_[re];if(0>>1;rel(B,ie))Rl($,B)?(_[re]=$,_[R]=ie,re=R):(_[re]=B,_[ze]=ie,re=ze);else if(Rl($,ie))_[re]=$,_[R]=ie,re=R;else break e}}return Z}function l(_,Z){var ie=_.sortIndex-Z.sortIndex;return ie!==0?ie:_.id-Z.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;n.unstable_now=function(){return o.now()}}else{var a=Date,u=a.now();n.unstable_now=function(){return a.now()-u}}var f=[],d=[],m=1,g=null,b=3,v=!1,w=!1,S=!1,C=!1,N=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;function I(_){for(var Z=t(d);Z!==null;){if(Z.callback===null)i(d);else if(Z.startTime<=_)i(d),Z.sortIndex=Z.expirationTime,e(f,Z);else break;Z=t(d)}}function U(_){if(S=!1,I(_),!w)if(t(f)!==null)w=!0,E||(E=!0,F());else{var Z=t(d);Z!==null&&ne(U,Z.startTime-_)}}var E=!1,T=-1,z=5,te=-1;function q(){return C?!0:!(n.unstable_now()-te_&&q());){var re=g.callback;if(typeof re=="function"){g.callback=null,b=g.priorityLevel;var A=re(g.expirationTime<=_);if(_=n.unstable_now(),typeof A=="function"){g.callback=A,I(_),Z=!0;break t}g===t(f)&&i(f),I(_)}else i(f);g=t(f)}if(g!==null)Z=!0;else{var Be=t(d);Be!==null&&ne(U,Be.startTime-_),Z=!1}}break e}finally{g=null,b=ie,v=!1}Z=void 0}}finally{Z?F():E=!1}}}var F;if(typeof D=="function")F=function(){D(G)};else if(typeof MessageChannel<"u"){var se=new MessageChannel,me=se.port2;se.port1.onmessage=G,F=function(){me.postMessage(null)}}else F=function(){N(G,0)};function ne(_,Z){T=N(function(){_(n.unstable_now())},Z)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(_){_.callback=null},n.unstable_forceFrameRate=function(_){0>_||125<_?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<_?Math.floor(1e3/_):5},n.unstable_getCurrentPriorityLevel=function(){return b},n.unstable_next=function(_){switch(b){case 1:case 2:case 3:var Z=3;break;default:Z=b}var ie=b;b=Z;try{return _()}finally{b=ie}},n.unstable_requestPaint=function(){C=!0},n.unstable_runWithPriority=function(_,Z){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var ie=b;b=_;try{return Z()}finally{b=ie}},n.unstable_scheduleCallback=function(_,Z,ie){var re=n.unstable_now();switch(typeof ie=="object"&&ie!==null?(ie=ie.delay,ie=typeof ie=="number"&&0re?(_.sortIndex=ie,e(d,_),t(f)===null&&_===t(d)&&(S?(j(T),T=-1):S=!0,ne(U,ie-re))):(_.sortIndex=A,e(f,_),w||v||(w=!0,E||(E=!0,F()))),_},n.unstable_shouldYield=q,n.unstable_wrapCallback=function(_){var Z=b;return function(){var ie=b;b=Z;try{return _.apply(this,arguments)}finally{b=ie}}}})(Yg)),Yg}var Mk;function dM(){return Mk||(Mk=1,$g.exports=hM()),$g.exports}var Gg={exports:{}},Rn={};/** + * @license React + * react-dom.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Dk;function mM(){if(Dk)return Rn;Dk=1;var n=py();function e(m){var g="https://react.dev/errors/"+m;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),Gg.exports=mM(),Gg.exports}/** + * @license React + * react-dom-client.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var jk;function pM(){if(jk)return Lc;jk=1;var n=dM(),e=py(),t=YC();function i(r){var s="https://react.dev/errors/"+r;if(1gn||(r.current=tn[gn],tn[gn]=null,gn--)}function ot(r,s){gn++,tn[gn]=r.current,r.current=s}var nn=zt(null),Pn=zt(null),Ht=zt(null),rn=zt(null);function Se(r,s){switch(ot(Ht,s),ot(Pn,r),ot(nn,null),s.nodeType){case 9:case 11:r=(r=s.documentElement)&&(r=r.namespaceURI)?_w(r):0;break;default:if(r=s.tagName,s=s.namespaceURI)s=_w(s),r=Lw(s,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}Ct(nn),ot(nn,r)}function Ve(){Ct(nn),Ct(Pn),Ct(Ht)}function We(r){var s=r.memoizedState;s!==null&&(Zo._currentValue=s.memoizedState,ot(rn,r)),s=nn.current;var c=Lw(s,r.type);s!==c&&(ot(Pn,r),ot(nn,c))}function ft(r){Pn.current===r&&(Ct(nn),Ct(Pn)),rn.current===r&&(Ct(rn),Zo._currentValue=Pt)}var ee,fe;function Te(r){if(ee===void 0)try{throw Error()}catch(c){var s=c.stack.trim().match(/\n( *(at )?)/);ee=s&&s[1]||"",fe=-1)":-1p||L[h]!==Y[p]){var J=` +`+L[h].replace(" at new "," at ");return r.displayName&&J.includes("")&&(J=J.replace("",r.displayName)),J}while(1<=h&&0<=p);break}}}finally{He=!1,Error.prepareStackTrace=c}return(c=r?r.displayName||r.name:"")?Te(c):""}function pe(r,s){switch(r.tag){case 26:case 27:case 5:return Te(r.type);case 16:return Te("Lazy");case 13:return r.child!==s&&s!==null?Te("Suspense Fallback"):Te("Suspense");case 19:return Te("SuspenseList");case 0:case 15:return de(r.type,!1);case 11:return de(r.type.render,!1);case 1:return de(r.type,!0);case 31:return Te("Activity");case 30:return Te("ViewTransition");default:return""}}function Ee(r){try{var s="",c=null;do s+=pe(r,c),c=r,r=r.return;while(r);return s}catch(h){return` +Error generating stack: `+h.message+` +`+h.stack}}var nt=Object.prototype.hasOwnProperty,at=n.unstable_scheduleCallback,hn=n.unstable_cancelCallback,Kt=n.unstable_shouldYield,bi=n.unstable_requestPaint,Vt=n.unstable_now,xn=n.unstable_getCurrentPriorityLevel,ti=n.unstable_ImmediatePriority,yn=n.unstable_UserBlockingPriority,dl=n.unstable_NormalPriority,ps=n.unstable_LowPriority,zu=n.unstable_IdlePriority,uo=n.log,gs=n.unstable_setDisableYieldValue,ye=null,Qn=null;function cr(r){if(typeof uo=="function"&&gs(r),Qn&&typeof Qn.setStrictMode=="function")try{Qn.setStrictMode(ye,r)}catch{}}var Bt=Math.clz32?Math.clz32:ii,Qt=Math.log,ni=Math.LN2;function ii(r){return r>>>=0,r===0?32:31-(Qt(r)/ni|0)|0}var At=256,fo=262144,xs=4194304;function bn(r){var s=r&42;if(s!==0)return s;switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return r&-r;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function ho(r,s,c){var h=r.pendingLanes;if(h===0)return 0;var p=0,x=r.suspendedLanes,k=r.pingedLanes;r=r.warmLanes;var O=h&134217727;return O!==0?(h=O&~x,h!==0?p=bn(h):(k&=O,k!==0?p=bn(k):c||(c=O&~r,c!==0&&(p=bn(c))))):(O=h&~x,O!==0?p=bn(O):k!==0?p=bn(k):c||(c=h&~r,c!==0&&(p=bn(c)))),p===0?0:s!==0&&s!==p&&(s&x)===0&&(x=p&-p,c=s&-s,x>=c||x===32&&(c&4194048)!==0)?s:p}function ml(r,s){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&s)===0}function ys(r,s){(s&8)!==0&&(s|=s&32);var c=r.entangledLanes;if(c!==0)for(r=r.entanglements,c&=s;0c;c++)s.push(r);return s}function ur(r,s){r.pendingLanes|=s,s!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function Pa(r,s,c,h,p,x){var k=r.pendingLanes;r.pendingLanes=c,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=c,r.entangledLanes&=c,r.errorRecoveryDisabledLanes&=c,r.shellSuspendCounter=0;var O=r.entanglements,L=r.expirationTimes,Y=r.hiddenUpdates;for(c=k&~c;0"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Tm=!1;if(qr)try{var $a={};Object.defineProperty($a,"passive",{get:function(){Tm=!0}}),window.addEventListener("test",$a,$a),window.removeEventListener("test",$a,$a)}catch{Tm=!1}var vl=null,Am=null,Gu=null;function Mb(){if(Gu)return Gu;var r,s=Am,c=s.length,h,p="value"in vl?vl.value:vl.textContent,x=p.length;for(r=0;r=Ka),zb=" ",Bb=!1;function Pb(r,s){switch(r){case"keyup":return i5.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Hb(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var vo=!1;function l5(r,s){switch(r){case"compositionend":return Hb(s);case"keypress":return s.which!==32?null:(Bb=!0,zb);case"textInput":return r=s.data,r===zb&&Bb?null:r;default:return null}}function s5(r,s){if(vo)return r==="compositionend"||!jm&&Pb(r,s)?(r=Mb(),Gu=Am=vl=null,vo=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function $b(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Yb(r,s){var c=$b(r);r=0;for(var h;c;){if(c.nodeType===3){if(h=r+c.textContent.length,r<=s&&h>=s)return{node:c,offset:s-r};r=h}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=$b(c)}}function Gb(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?Gb(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function Kb(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var s=zm(r.document);s instanceof r.HTMLIFrameElement;){try{var c=typeof s.contentWindow.location.href=="string"}catch{c=!1}if(c)r=s.contentWindow;else break;s=zm(r.document)}return s}function Bm(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}var m5=qr&&"documentMode"in document&&11>=document.documentMode,wo=null,Pm=null,ec=null,Hm=!1;function Wb(r,s,c){var h=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;Hm||wo==null||wo!==zm(h)||(h=wo,"selectionStart"in h&&Bm(h)?h={start:h.selectionStart,end:h.selectionEnd}:(h=(h.ownerDocument&&h.ownerDocument.defaultView||window).getSelection(),h={anchorNode:h.anchorNode,anchorOffset:h.anchorOffset,focusNode:h.focusNode,focusOffset:h.focusOffset}),ec&&Ja(ec,h)||(ec=h,h=th(Pm,"onSelect"),0>=k,p-=k,dr=1<<32-Bt(s)+p|c<Ue?(cn=Le,Le=null):cn=Le.sibling;var dt=Q(X,Le,K[Ue],ae);if(dt===null){Le===null&&(Le=cn);break}r&&Le&&dt.alternate===null&&s(X,Le),V=x(dt,V,Ue),ut===null?Ae=dt:ut.sibling=dt,ut=dt,Le=cn}if(Ue===K.length)return c(X,Le),Ze&&$r(X,Ue),Ae;if(Le===null){for(;UeUe?(cn=Le,Le=null):cn=Le.sibling;var Ql=Q(X,Le,dt.value,ae);if(Ql===null){Le===null&&(Le=cn);break}r&&Le&&Ql.alternate===null&&s(X,Le),V=x(Ql,V,Ue),ut===null?Ae=Ql:ut.sibling=Ql,ut=Ql,Le=cn}if(dt.done)return c(X,Le),Ze&&$r(X,Ue),Ae;if(Le===null){for(;!dt.done;Ue++,dt=K.next())dt=ce(X,dt.value,ae),dt!==null&&(V=x(dt,V,Ue),ut===null?Ae=dt:ut.sibling=dt,ut=dt);return Ze&&$r(X,Ue),Ae}for(Le=h(Le);!dt.done;Ue++,dt=K.next())dt=W(Le,X,Ue,dt.value,ae),dt!==null&&(r&&(cn=dt.alternate,cn!==null&&Le.delete(cn.key===null?Ue:cn.key)),V=x(dt,V,Ue),ut===null?Ae=dt:ut.sibling=dt,ut=dt);return r&&Le.forEach(function(lM){return s(X,lM)}),Ze&&$r(X,Ue),Ae}function Ge(X,V,K,ae){if(typeof K=="object"&&K!==null&&K.type===G&&K.key===null&&K.props.ref===void 0&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case te:e:{for(var Ae=K.key;V!==null;){if(V.key===Ae){if(Ae=K.type,Ae===G){if(V.tag===7){c(X,V.sibling),ae=p(V,K.props.children),Nl(ae,K),ae.return=X,X=ae;break e}}else if(V.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===A&&Rs(Ae)===V.type){c(X,V.sibling),ae=p(V,K.props),Nl(ae,K),ae.return=X,X=ae;break e}c(X,V);break}else s(X,V);V=V.sibling}K.type===G?(ae=Os(K.props.children,X.mode,ae,K.key),Nl(ae,K),ae.return=X,X=ae):(ae=sf(K.type,K.key,K.props,null,X.mode,ae),Nl(ae,K),ae.return=X,X=ae)}return k(X);case q:e:{for(Ae=K.key;V!==null;){if(V.key===Ae)if(V.tag===4&&V.stateNode.containerInfo===K.containerInfo&&V.stateNode.implementation===K.implementation){c(X,V.sibling),ae=p(V,K.children||[]),ae.return=X,X=ae;break e}else{c(X,V);break}else s(X,V);V=V.sibling}ae=Xm(K,X.mode,ae),ae.return=X,X=ae}return k(X);case A:return K=Rs(K),Ge(X,V,K,ae)}if(Pe(K))return ve(X,V,K,ae);if(ge(K)){if(Ae=ge(K),typeof Ae!="function")throw Error(i(150));return K=Ae.call(K),Me(X,V,K,ae)}if(typeof K.then=="function")return Ge(X,V,gf(K),ae);if(K.$$typeof===ne)return Ge(X,V,hf(X,K),ae);xf(X,K)}return typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint"?(K=""+K,V!==null&&V.tag===6?(c(X,V.sibling),ae=p(V,K),ae.return=X,X=ae):(c(X,V),ae=Qm(K,X.mode,ae),ae.return=X,X=ae),k(X)):c(X,V)}return function(X,V,K,ae){try{sc=0;var Ae=Ge(X,V,K,ae);return Mo=null,Ae}catch(Le){if(Le===Eo||Le===mf)throw Le;var ut=li(29,Le,null,X.mode);return ut.lanes=ae,ut.return=X,ut}finally{}}}var _s=w1(!0),k1=w1(!1),Tl=!1;function np(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ip(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function Al(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function El(r,s,c){var h=r.updateQueue;if(h===null)return null;if(h=h.shared,(yt&2)!==0){var p=h.pending;return p===null?s.next=s:(s.next=p.next,p.next=s),h.pending=s,s=lf(r),l1(r,null,c),s}return rf(r,h,s,c),lf(r)}function oc(r,s,c){if(s=s.updateQueue,s!==null&&(s=s.shared,(c&4194048)!==0)){var h=s.lanes;h&=r.pendingLanes,c|=h,s.lanes=c,mo(r,c)}}function rp(r,s){var c=r.updateQueue,h=r.alternate;if(h!==null&&(h=h.updateQueue,c===h)){var p=null,x=null;if(c=c.firstBaseUpdate,c!==null){do{var k={lane:c.lane,tag:c.tag,payload:c.payload,callback:null,next:null};x===null?p=x=k:x=x.next=k,c=c.next}while(c!==null);x===null?p=x=s:x=x.next=s}else p=x=s;c={baseState:h.baseState,firstBaseUpdate:p,lastBaseUpdate:x,shared:h.shared,callbacks:h.callbacks},r.updateQueue=c;return}r=c.lastBaseUpdate,r===null?c.firstBaseUpdate=s:r.next=s,c.lastBaseUpdate=s}var lp=!1;function ac(){if(lp){var r=Ao;if(r!==null)throw r}}function cc(r,s,c,h){lp=!1;var p=r.updateQueue;Tl=!1;var x=p.firstBaseUpdate,k=p.lastBaseUpdate,O=p.shared.pending;if(O!==null){p.shared.pending=null;var L=O,Y=L.next;L.next=null,k===null?x=Y:k.next=Y,k=L;var J=r.alternate;J!==null&&(J=J.updateQueue,O=J.lastBaseUpdate,O!==k&&(O===null?J.firstBaseUpdate=Y:O.next=Y,J.lastBaseUpdate=L))}if(x!==null){var ce=p.baseState;k=0,J=Y=L=null,O=x;do{var Q=O.lane&-536870913,W=Q!==O.lane;if(W?(ct&Q)===Q:(h&Q)===Q){Q!==0&&Q===Ms&&(lp=!0),J!==null&&(J=J.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var ve=r,Me=O;Q=s;var Ge=c;switch(Me.tag){case 1:if(ve=Me.payload,typeof ve=="function"){ce=ve.call(Ge,ce,Q);break e}ce=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=Me.payload,Q=typeof ve=="function"?ve.call(Ge,ce,Q):ve,Q==null)break e;ce=T({},ce,Q);break e;case 2:Tl=!0}}Q=O.callback,Q!==null&&(r.flags|=64,W&&(r.flags|=8192),W=p.callbacks,W===null?p.callbacks=[Q]:W.push(Q))}else W={lane:Q,tag:O.tag,payload:O.payload,callback:O.callback,next:null},J===null?(Y=J=W,L=ce):J=J.next=W,k|=Q;if(O=O.next,O===null){if(O=p.shared.pending,O===null)break;W=O,O=W.next,W.next=null,p.lastBaseUpdate=W,p.shared.pending=null}}while(!0);J===null&&(L=ce),p.baseState=L,p.firstBaseUpdate=Y,p.lastBaseUpdate=J,x===null&&(p.shared.lanes=0),zl|=k,r.lanes=k,r.memoizedState=ce}}function S1(r,s){if(typeof r!="function")throw Error(i(191,r));r.call(s)}function C1(r,s){var c=r.callbacks;if(c!==null)for(r.callbacks=null,r=0;rx?x:8;var k=be.T,O={};O.types=k!==null?k.types:null,be.T=O,Op(r,!1,s,c);try{var L=p(),Y=be.S;if(Y!==null&&Y(O,L),L!==null&&typeof L=="object"&&typeof L.then=="function"){var J=O5(L,h);dc(r,s,J,Oi(r))}else dc(r,s,h,Oi(r))}catch(ce){dc(r,s,{then:function(){},status:"rejected",reason:ce},Oi())}finally{_e.p=x,k!==null&&O.types!==null&&(k.types=O.types),be.T=k}}function D5(){}function Sp(r,s,c,h){if(r.tag!==5)throw Error(i(476));var p=nv(r).queue;tv(r,p,s,Pt,c===null?D5:function(){return iv(r),c(h)})}function nv(r){var s=r.memoizedState;if(s!==null)return s;s={memoizedState:Pt,baseState:Pt,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wr,lastRenderedState:Pt},next:null};var c={};return s.next={memoizedState:c,baseState:c,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wr,lastRenderedState:c},next:null},r.memoizedState=s,r=r.alternate,r!==null&&(r.memoizedState=s),s}function iv(r){var s=nv(r);s.next===null&&(s=r.alternate.memoizedState),dc(r,s.next.queue,{},Oi())}function Cp(){return Tn(Zo)}function rv(){return Zt().memoizedState}function lv(){return Zt().memoizedState}function R5(r){for(var s=r.return;s!==null;){switch(s.tag){case 24:case 3:var c=Oi();r=Al(c);var h=El(s,r,c);h!==null&&(ci(h,s,c),oc(h,s,c)),s={cache:Zm()},r.payload=s;return}s=s.return}}function j5(r,s,c){var h=Oi();c={lane:h,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Tf(r)?ov(s,c):(c=qm(r,s,c,h),c!==null&&(ci(c,r,h),av(c,s,h)))}function sv(r,s,c){var h=Oi();dc(r,s,c,h)}function dc(r,s,c,h){var p={lane:h,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null};if(Tf(r))ov(s,p);else{var x=r.alternate;if(r.lanes===0&&(x===null||x.lanes===0)&&(x=s.lastRenderedReducer,x!==null))try{var k=s.lastRenderedState,O=x(k,c);if(p.hasEagerState=!0,p.eagerState=O,vi(O,k))return rf(r,s,p,0),Et===null&&nf(),!1}catch{}finally{}if(c=qm(r,s,p,h),c!==null)return ci(c,r,h),av(c,s,h),!0}return!1}function Op(r,s,c,h){if(h={lane:2,revertLane:pg(),gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},Tf(r)){if(s)throw Error(i(479))}else s=qm(r,c,h,2),s!==null&&ci(s,r,2)}function Tf(r){var s=r.alternate;return r===Ye||s!==null&&s===Ye}function ov(r,s){Do=vf=!0;var c=r.pending;c===null?s.next=s:(s.next=c.next,c.next=s),r.pending=s}function av(r,s,c){if((c&4194048)!==0){var h=s.lanes;h&=r.pendingLanes,c|=h,s.lanes=c,mo(r,c)}}var Af={readContext:Tn,use:Sf,useCallback:Xt,useContext:Xt,useEffect:Xt,useImperativeHandle:Xt,useLayoutEffect:Xt,useInsertionEffect:Xt,useMemo:Xt,useReducer:Xt,useRef:Xt,useState:Xt,useDebugValue:Xt,useDeferredValue:Xt,useTransition:Xt,useSyncExternalStore:Xt,useId:Xt,useHostTransitionStatus:Xt,useFormState:Xt,useActionState:Xt,useOptimistic:Xt,useMemoCache:Xt,useCacheRefresh:Xt,useEffectEvent:Xt},cv={readContext:Tn,use:Sf,useCallback:function(r,s){return Yn().memoizedState=[r,s===void 0?null:s],r},useContext:Tn,useEffect:X1,useImperativeHandle:function(r,s,c){c=c!=null?c.concat([r]):null,Of(4194308,4,K1.bind(null,s,r),c)},useLayoutEffect:function(r,s){return Of(4194308,4,r,s)},useInsertionEffect:function(r,s){Of(4,2,r,s)},useMemo:function(r,s){var c=Yn();s=s===void 0?null:s;var h=r();if(Ls){cr(!0);try{r()}finally{cr(!1)}}return c.memoizedState=[h,s],h},useReducer:function(r,s,c){var h=Yn();if(c!==void 0){var p=c(s);if(Ls){cr(!0);try{c(s)}finally{cr(!1)}}}else p=s;return h.memoizedState=h.baseState=p,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:p},h.queue=r,r=r.dispatch=j5.bind(null,Ye,r),[h.memoizedState,r]},useRef:function(r){var s=Yn();return r={current:r},s.memoizedState=r},useState:function(r){r=yp(r);var s=r.queue,c=sv.bind(null,Ye,s);return s.dispatch=c,[r.memoizedState,c]},useDebugValue:wp,useDeferredValue:function(r,s){var c=Yn();return kp(c,r,s)},useTransition:function(){var r=yp(!1);return r=tv.bind(null,Ye,r.queue,!0,!1),Yn().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,s,c){var h=Ye,p=Yn();if(Ze){if(c===void 0)throw Error(i(407));c=c()}else{if(c=s(),Et===null)throw Error(i(349));(ct&127)!==0||M1(h,s,c)}p.memoizedState=c;var x={value:c,getSnapshot:s};return p.queue=x,X1(R1.bind(null,h,x,r),[r]),h.flags|=2048,jo(9,{destroy:void 0},D1.bind(null,h,x,c,s),null),c},useId:function(){var r=Yn(),s=Et.identifierPrefix;if(Ze){var c=mr,h=dr;c=(h&~(1<<32-Bt(h)-1)).toString(32)+c,s="_"+s+"R_"+c,c=wf++,0<\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof h.is=="string"?k.createElement("select",{is:h.is}):k.createElement("select"),h.multiple?x.multiple=!0:h.size&&(x.size=h.size);break;default:x=typeof h.is=="string"?k.createElement(p,{is:h.is}):k.createElement(p)}}x[It]=s,x[Wt]=h;e:for(k=s.child;k!==null;){if(k.tag===5||k.tag===6)x.appendChild(k.stateNode);else if(k.tag!==4&&k.tag!==27&&k.child!==null){k.child.return=k,k=k.child;continue}if(k===s)break e;for(;k.sibling===null;){if(k.return===null||k.return===s)break e;k=k.return}k.sibling.return=k.return,k=k.sibling}s.stateNode=x;e:switch(Dn(x,p,h),p){case"button":case"input":case"select":case"textarea":h=!!h.autoFocus;break e;case"img":h=!0;break e;default:h=!1}h&&Jr(s)}}return _t(s),s.subtreeFlags&=-33554433,Pp(s,s.type,r===null?null:r.memoizedProps,s.pendingProps,c),null;case 6:if(r&&s.stateNode!=null)r.memoizedProps!==h&&Jr(s);else{if(typeof h!="string"&&s.stateNode===null)throw Error(i(166));if(r=Ht.current,To(s)){if(r=s.stateNode,c=s.memoizedProps,h=null,p=wn,p!==null)switch(p.tag){case 27:case 5:h=p.memoizedProps}r[It]=s,r=!!(r.nodeValue===c||h!==null&&h.suppressHydrationWarning===!0||Rw(r.nodeValue,c)),r||Cl(s,!0)}else r=Nc(r).createTextNode(h),r[It]=s,s.stateNode=r}return _t(s),null;case 31:if(c=s.memoizedState,r===null||r.memoizedState!==null){if(h=To(s),c!==null){if(r===null){if(!h)throw Error(i(318));if(r=s.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(557));r[It]=s}else Ns(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;_t(s),r=!1}else c=Gm(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=c),r=!0;if(!r)return s.flags&256?(wi(s),s):(wi(s),null);if((s.flags&128)!==0)throw Error(i(558))}return _t(s),null;case 13:if(h=s.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(p=To(s),h!==null&&h.dehydrated!==null){if(r===null){if(!p)throw Error(i(318));if(p=s.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(i(317));p[It]=s}else Ns(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;_t(s),p=!1}else p=Gm(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=p),p=!0;if(!p)return s.flags&256?(wi(s),s):(wi(s),null)}return wi(s),(s.flags&128)!==0?(s.lanes=c,s):(c=h!==null,r=r!==null&&r.memoizedState!==null,c&&(h=s.child,p=null,h.alternate!==null&&h.alternate.memoizedState!==null&&h.alternate.memoizedState.cachePool!==null&&(p=h.alternate.memoizedState.cachePool.pool),x=null,h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(x=h.memoizedState.cachePool.pool),x!==p&&(h.flags|=2048)),c!==r&&c&&(s.child.flags|=8192),_f(s,s.updateQueue),_t(s),null);case 4:return Ve(),r===null&&bg(s.stateNode.containerInfo),s.flags|=67108864,_t(s),null;case 10:return Gr(s.type),_t(s),null;case 19:if(cp(s),h=s.memoizedState,h===null)return _t(s),null;if(p=(s.flags&128)!==0,x=h.rendering,x===null)if(p)pc(h,!1);else{if($t!==0||r!==null&&(r.flags&128)!==0)for(r=s.child;r!==null;){if(x=bf(r),x!==null){for(s.flags|=128,pc(h,!1),r=x.updateQueue,s.updateQueue=r,_f(s,r),s.subtreeFlags=0,r=c,c=s.child;c!==null;)s1(c,r),c=c.sibling;return uc(s,En.current&1|2),Ze&&$r(s,h.treeForkCount),s.child}r=r.sibling}h.tail!==null&&Vt()>Xf&&(s.flags|=128,p=!0,pc(h,!1),s.lanes=4194304)}else{if(!p)if(r=bf(x),r!==null){if(s.flags|=128,p=!0,r=r.updateQueue,s.updateQueue=r,_f(s,r),pc(h,!0),h.tail===null&&h.tailMode!=="collapsed"&&h.tailMode!=="visible"&&!x.alternate&&!Ze)return _t(s),null}else 2*Vt()-h.renderingStartTime>Xf&&c!==536870912&&(s.flags|=128,p=!0,pc(h,!1),s.lanes=4194304);h.isBackwards?(x.sibling=s.child,s.child=x):(r=h.last,r!==null?r.sibling=x:s.child=x,h.last=x)}if(h.tail!==null){r=h.tail;e:{for(c=r;c!==null;){if(c.alternate!==null){c=!1;break e}c=c.sibling}c=!0}return h.rendering=r,h.tail=r.sibling,h.renderingStartTime=Vt(),r.sibling=null,x=En.current,x=p?x&1|2:x&1,h.tailMode==="visible"||h.tailMode==="collapsed"||!c||Ze?uc(s,x):(c=x,ot(An,s),ot(En,c),Hn===null&&(Hn=s)),Ze&&$r(s,h.treeForkCount),r}return _t(s),null;case 22:case 23:return wi(s),op(),h=s.memoizedState!==null,r!==null?r.memoizedState!==null!==h&&(s.flags|=8192):h&&(s.flags|=8192),h?(c&536870912)!==0&&(s.flags&128)===0&&(_t(s),s.subtreeFlags&6&&(s.flags|=8192)):_t(s),c=s.updateQueue,c!==null&&_f(s,c.retryQueue),c=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(c=r.memoizedState.cachePool.pool),h=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(h=s.memoizedState.cachePool.pool),h!==c&&(s.flags|=2048),r!==null&&Ct(Ds),null;case 24:return c=null,r!==null&&(c=r.memoizedState.cache),s.memoizedState.cache!==c&&(s.flags|=2048),Gr(sn),_t(s),null;case 25:return null;case 30:return s.flags|=33554432,_t(s),null}throw Error(i(156,s.tag))}function I5(r,s){switch($m(s),s.tag){case 1:return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return Gr(sn),Ve(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 26:case 27:case 5:return ft(s),null;case 31:if(s.memoizedState!==null){if(wi(s),s.alternate===null)throw Error(i(340));Ns()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 13:if(wi(s),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(i(340));Ns()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return cp(s),r=s.flags,r&65536?(s.flags=r&-65537|128,r=s.memoizedState,r!==null&&(r.rendering=null,r.tail=null),s.flags|=4,s):null;case 4:return Ve(),null;case 10:return Gr(s.type),null;case 22:case 23:return wi(s),op(),r!==null&&Ct(Ds),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 24:return Gr(sn),null;case 25:return null;default:return null}}function _v(r,s){switch($m(s),s.tag){case 3:Gr(sn),Ve();break;case 26:case 27:case 5:ft(s);break;case 4:Ve();break;case 31:s.memoizedState!==null&&wi(s);break;case 13:wi(s);break;case 19:cp(s);break;case 10:Gr(s.type);break;case 22:case 23:wi(s),op(),r!==null&&Ct(Ds);break;case 24:Gr(sn)}}function gc(r,s){try{var c=s.updateQueue,h=c!==null?c.lastEffect:null;if(h!==null){var p=h.next;c=p;do{if((c.tag&r)===r){h=void 0;var x=c.create,k=c.inst;h=x(),k.destroy=h}c=c.next}while(c!==p)}}catch(O){kt(s,s.return,O)}}function jl(r,s,c){try{var h=s.updateQueue,p=h!==null?h.lastEffect:null;if(p!==null){var x=p.next;h=x;do{if((h.tag&r)===r){var k=h.inst,O=k.destroy;if(O!==void 0){k.destroy=void 0,p=s;var L=c,Y=O;try{Y()}catch(J){kt(p,L,J)}}}h=h.next}while(h!==x)}}catch(J){kt(s,s.return,J)}}function Lv(r){var s=r.updateQueue;if(s!==null){var c=r.stateNode;try{C1(s,c)}catch(h){kt(r,r.return,h)}}}function zv(r,s,c){c.props=zs(r.type,r.memoizedProps),c.state=r.memoizedState;try{c.componentWillUnmount()}catch(h){kt(r,s,h)}}function pr(r,s){try{var c=r.ref;if(c!==null){switch(r.tag){case 26:case 27:case 5:var h=r.stateNode;break;case 30:var p=r.stateNode,x=Vr(r.memoizedProps,p);(p.ref===null||p.ref.name!==x)&&(p.ref=qw(x)),h=p.ref;break;case 7:if(r.stateNode===null){var k=new Ni(r);g(r.child,!1,M3,k,void 0,void 0),r.stateNode=k}h=r.stateNode;break;default:h=r.stateNode}typeof c=="function"?r.refCleanup=c(h):c.current=h}}catch(O){kt(r,s,O)}}function Mn(r,s){var c=r.ref,h=r.refCleanup;if(c!==null)if(typeof h=="function")try{h()}catch(p){kt(r,s,p)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof c=="function")try{c(null)}catch(p){kt(r,s,p)}else c.current=null}function Lf(r,s){if((r.tag===5||r.tag===27||r.tag===6)&&r.alternate===null&&s!==null)for(var c=0;c title"))),Dn(h,s,c),h[It]=r,ln(h),s=h;break e;case"link":if(x=sk("link","href",p).get(s+(c.href||""))){for(k=0;kGe&&(k=Ge,Ge=Me,Me=k);var X=Yb(O,Me),V=Yb(O,Ge);if(X&&V&&(W.rangeCount!==1||W.anchorNode!==X.node||W.anchorOffset!==X.offset||W.focusNode!==V.node||W.focusOffset!==V.offset)){var K=ce.createRange();K.setStart(X.node,X.offset),W.removeAllRanges(),Me>Ge?(W.addRange(K),W.extend(V.node,V.offset)):(K.setEnd(V.node,V.offset),W.addRange(K))}}}}for(ce=[],W=O;W=W.parentNode;)W.nodeType===1&&ce.push({element:W,left:W.scrollLeft,top:W.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;Oc?32:c,be.T=null,c=lg,lg=null;var x=Zi,k=wr;if(qt=0,Is=Zi=null,wr=0,(yt&6)!==0)throw Error(i(331));var O=yt;if(yt|=4,lw(x.current),nw(x,x.current,k,c),yt=O,Sc(0,!1),Qn&&typeof Qn.onPostCommitFiberRoot=="function")try{Qn.onPostCommitFiberRoot(ye,x)}catch{}return!0}finally{_e.p=p,be.T=h,vw(r,s)}}function ww(r,s,c){s=_i(c,s),s=Ap(r.stateNode,s,2),r=El(r,s,2),r!==null&&(ur(r,2),kr(r))}function kt(r,s,c){if(r.tag===3)ww(r,r,c);else for(;s!==null;){if(s.tag===3){ww(s,r,c);break}else if(s.tag===1){var h=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(Bl===null||!Bl.has(h))){r=_i(c,r),c=xv(2),h=El(s,c,2),h!==null&&(yv(c,h,s,r),ur(h,2),kr(h));break}}s=s.return}}function hg(r,s,c){var h=r.pingCache;if(h===null){h=r.pingCache=new V5;var p=new Set;h.set(s,p)}else p=h.get(s),p===void 0&&(p=new Set,h.set(s,p));p.has(c)||(ng=!0,p.add(c),r=Z5.bind(null,r,s,c),s.then(r,r))}function Z5(r,s,c){var h=r.pingCache;h!==null&&h.delete(s),r.pingedLanes|=r.suspendedLanes&c,r.warmLanes&=~c,Et===r&&(ct&c)===c&&(($t===4||$t===3&&(ct&62914560)===ct&&300>Vt()-Qf)&&(yt&2)===0?Vo(r,0):Vf|=c,Ho===ct&&(Ho=0)),kr(r)}function kw(r,s){s===0&&(s=Bu()),r=Cs(r,s),r!==null&&(ur(r,s),kr(r))}function J5(r){var s=r.memoizedState,c=0;s!==null&&(c=s.retryLane),kw(r,c)}function e3(r,s){var c=0;switch(r.tag){case 31:case 13:var h=r.stateNode,p=r.memoizedState;p!==null&&(c=p.retryLane);break;case 19:h=r.stateNode;break;case 22:h=r.stateNode._retryCache;break;default:throw Error(i(314))}h!==null&&h.delete(s),kw(r,c)}function t3(r,s){return at(r,s)}var Xo=null,$o=null,dg=!1,Jf=!1,mg=!1,Hl=0;function kr(r){r!==$o&&r.next===null&&($o===null?Xo=$o=r:$o=$o.next=r),Jf=!0,dg||(dg=!0,i3())}function Sc(r,s){if(!mg&&Jf){mg=!0;do for(var c=!1,h=Xo;h!==null;){if(r!==0){var p=h.pendingLanes;if(p===0)var x=0;else{var k=h.suspendedLanes,O=h.pingedLanes;x=(1<<31-Bt(42|r)+1)-1,x&=p&~(k&~O),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(c=!0,Nw(h,x))}else x=ct,x=ho(h,h===Et?x:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),(x&3)===0||ml(h,x)||(c=!0,Nw(h,x));h=h.next}while(c);mg=!1}}function n3(){Sw()}function Sw(){Jf=dg=!1;var r=0;Hl!==0&&m3()&&(r=Hl);for(var s=Vt(),c=null,h=Xo;h!==null;){var p=h.next,x=Cw(h,s);x===0?(h.next=null,c===null?Xo=p:c.next=p,p===null&&($o=c)):(c=h,(r!==0||(x&3)!==0)&&(Jf=!0)),h=p}qt!==0&&qt!==5||Sc(r),Hl!==0&&(Hl=0)}function Cw(r,s){for(var c=r.suspendedLanes,h=r.pingedLanes,p=r.expirationTimes,x=r.pendingLanes&-62914561;0O)break;var J=L.transferSize,ce=L.initiatorType;J&&jw(ce)&&(L=L.responseEnd,k+=J*(Lrh){Me.length=ve;break}K=new Promise(v3.bind(K)),Me.push(K)}}}if(0"u"?null:document;function nk(r,s,c){var h=Go;if(h&&typeof s=="string"&&s){var p=H(s);p='link[rel="'+r+'"][href="'+p+'"]',typeof c=="string"&&(p+='[crossorigin="'+c+'"]'),tk.has(p)||(tk.add(p),r={rel:r,crossOrigin:c,href:s},h.querySelector(p)===null&&(s=h.createElement("link"),Dn(s,"link",r),ln(s),h.head.appendChild(s)))}}function H3(r){tl.D(r),nk("dns-prefetch",r,null)}function I3(r,s){tl.C(r,s),nk("preconnect",r,s)}function U3(r,s,c){tl.L(r,s,c);var h=Go;if(h&&r&&s){var p='link[rel="preload"][as="'+H(s)+'"]';s==="image"&&c&&c.imageSrcSet?(p+='[imagesrcset="'+H(c.imageSrcSet)+'"]',typeof c.imageSizes=="string"&&(p+='[imagesizes="'+H(c.imageSizes)+'"]')):p+='[href="'+H(r)+'"]';var x=p;switch(s){case"style":x=Ko(r);break;case"script":x=Wo(r)}if(!(Ii.has(x)||(r=T({rel:"preload",href:s==="image"&&c&&c.imageSrcSet?void 0:r,as:s},c),Ii.set(x,r),h.querySelector(p)!==null||s==="style"&&h.querySelector(Ac(x))||s==="script"&&h.querySelector(Ec(x))))){var k=h.createElement("link");Dn(k,"link",r),s==="style"&&(k[po]=!0,k.onload=k.onerror=function(){Uu(k)}),ln(k),h.head.appendChild(k)}}}function F3(r,s){tl.m(r,s);var c=Go;if(c&&r){var h=s&&typeof s.as=="string"?s.as:"script",p='link[rel="modulepreload"][as="'+H(h)+'"][href="'+H(r)+'"]',x=p;switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Wo(r)}if(!Ii.has(x)&&(r=T({rel:"modulepreload",href:r},s),Ii.set(x,r),c.querySelector(p)===null)){switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(c.querySelector(Ec(x)))return}h=c.createElement("link"),Dn(h,"link",r),ln(h),c.head.appendChild(h)}}}function q3(r,s,c){tl.S(r,s,c);var h=Go;if(h&&r){var p=yl(h).hoistableStyles,x=Ko(r);s=s||"default";var k=p.get(x);if(!k){var O={loading:0,preload:null};if(k=h.querySelector(Ac(x)))O.loading=5;else{r=T({rel:"stylesheet",href:r,"data-precedence":s},c),(c=Ii.get(x))&&Lg(r,c);var L=k=h.createElement("link");ln(L),Dn(L,"link",r),L._p=new Promise(function(Y,J){L.onload=Y,L.onerror=J}),L.addEventListener("load",function(){O.loading|=1}),L.addEventListener("error",function(){O.loading|=2}),O.loading|=4,nh(k,s,h)}k={type:"stylesheet",instance:k,count:1,state:O},p.set(x,k)}}}function V3(r,s){tl.X(r,s);var c=Go;if(c&&r){var h=yl(c).hoistableScripts,p=Wo(r),x=h.get(p);x||(x=c.querySelector(Ec(p)),x||(r=T({src:r,async:!0},s),(s=Ii.get(p))&&zg(r,s),x=c.createElement("script"),ln(x),Dn(x,"link",r),c.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},h.set(p,x))}}function Q3(r,s){tl.M(r,s);var c=Go;if(c&&r){var h=yl(c).hoistableScripts,p=Wo(r),x=h.get(p);x||(x=c.querySelector(Ec(p)),x||(r=T({src:r,async:!0,type:"module"},s),(s=Ii.get(p))&&zg(r,s),x=c.createElement("script"),ln(x),Dn(x,"link",r),c.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},h.set(p,x))}}function ik(r,s,c,h){var p=(p=Ht.current)?Tc(p):null;if(!p)throw Error(i(446));switch(r){case"meta":case"title":return null;case"style":return typeof c.precedence=="string"&&typeof c.href=="string"?(c=Ko(c.href),s=yl(p).hoistableStyles,h=s.get(c),h||(h={type:"style",instance:null,count:0,state:null},s.set(c,h)),h):{type:"void",instance:null,count:0,state:null};case"link":if(c.rel==="stylesheet"&&typeof c.href=="string"&&typeof c.precedence=="string"){r=Ko(c.href);var x=yl(p).hoistableStyles,k=x.get(r);if(k||(p=p.ownerDocument||p,k={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(r,k),(x=p.querySelector(Ac(r)))?x._p||(k.instance=x,k.state.loading=5):(x=Ii.get(r),x||(x={rel:"preload",as:"style",href:c.href,crossOrigin:c.crossOrigin,integrity:c.integrity,media:c.media,hrefLang:c.hrefLang,referrerPolicy:c.referrerPolicy},Ii.set(r,x)),X3(p,r,x,k.state))),s&&h===null)throw Error(i(528,""));return k}if(s&&h!==null)throw Error(i(529,""));return null;case"script":return s=c.async,c=c.src,typeof c=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(c=Wo(c),s=yl(p).hoistableScripts,h=s.get(c),h||(h={type:"script",instance:null,count:0,state:null},s.set(c,h)),h):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,r))}}function Ko(r){return'href="'+H(r)+'"'}function Ac(r){return'link[rel="stylesheet"]['+r+"]"}function rk(r){return T({},r,{"data-precedence":r.precedence,precedence:null})}function X3(r,s,c,h){if(s=r.querySelector('link[rel="preload"][as="style"]['+s+"]")){if(s[po]!==!0){h.loading=1;return}}else s=r.createElement("link"),s[po]=!0,s.onload=s.onerror=Uu.bind(null,s),Dn(s,"link",c),ln(s),r.head.appendChild(s);h.preload=s,s.addEventListener("load",function(){return h.loading|=1}),s.addEventListener("error",function(){return h.loading|=2})}function Wo(r){return'[src="'+H(r)+'"]'}function Ec(r){return"script[async]"+r}function lk(r,s,c){if(s.count++,s.instance===null)switch(s.type){case"style":var h=r.querySelector('style[data-href~="'+H(c.href)+'"]');if(h)return s.instance=h,ln(h),h;var p=T({},c,{"data-href":c.href,"data-precedence":c.precedence,href:null,precedence:null});return h=(r.ownerDocument||r).createElement("style"),ln(h),Dn(h,"style",p),nh(h,c.precedence,r),s.instance=h;case"stylesheet":p=Ko(c.href);var x=r.querySelector(Ac(p));if(x)return s.state.loading|=4,s.instance=x,ln(x),x;h=rk(c),(p=Ii.get(p))&&Lg(h,p),x=(r.ownerDocument||r).createElement("link"),ln(x);var k=x;return k._p=new Promise(function(O,L){k.onload=O,k.onerror=L}),Dn(x,"link",h),s.state.loading|=4,nh(x,c.precedence,r),s.instance=x;case"script":return x=Wo(c.src),(p=r.querySelector(Ec(x)))?(s.instance=p,ln(p),p):(h=c,(p=Ii.get(x))&&(h=T({},c),zg(h,p)),r=r.ownerDocument||r,p=r.createElement("script"),ln(p),Dn(p,"link",h),r.head.appendChild(p),s.instance=p);case"void":return null;default:throw Error(i(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(h=s.instance,s.state.loading|=4,nh(h,c.precedence,r));return s.instance}function nh(r,s,c){for(var h=c.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=h.length?h[h.length-1]:null,x=p,k=0;k title"):null)}function $3(r,s,c){if(c===1||s.itemProp!=null)return!1;switch(r){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;switch(s.rel){case"stylesheet":return r=s.disabled,typeof s.precedence=="string"&&r==null;default:return!0}case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function ok(r,s){return r==="img"&&s.src!=null&&s.src!==""&&s.onLoad==null&&s.loading!=="lazy"}function ak(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function ck(r){return(r.width||100)*(r.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function uk(r,s){typeof s.decode=="function"&&(r.imgCount++,s.complete||(r.imgBytes+=ck(s),r.suspenseyImages.push(s)),r=K3.bind(r),s.decode().then(r,r))}function Y3(r,s,c,h){if(c.type==="stylesheet"&&(typeof h.media!="string"||matchMedia(h.media).matches!==!1)&&(c.state.loading&4)===0){if(c.instance===null){var p=Ko(h.href),x=s.querySelector(Ac(p));if(x){s=x._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(r.count++,r=Mc.bind(r),s.then(r,r)),c.state.loading|=4,c.instance=x,ln(x);return}x=s.ownerDocument||s,h=rk(h),(p=Ii.get(p))&&Lg(h,p),x=x.createElement("link"),ln(x);var k=x;k._p=new Promise(function(O,L){k.onload=O,k.onerror=L}),Dn(x,"link",h),c.instance=x}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(c,s),(s=c.state.preload)&&(c.state.loading&3)===0&&(r.count++,c=Mc.bind(r),s.addEventListener("load",c),s.addEventListener("error",c))}}var rh=0;function G3(r,s){return r.stylesheets&&r.count===0&&sh(r,r.stylesheets),0rh?50:800)+s);return r.unsuspend=c,function(){r.unsuspend=null,clearTimeout(h),clearTimeout(p)}}:null}function fk(r){if(r.count===0&&(r.imgCount===0||!r.waitingForImages)){if(r.stylesheets)sh(r,r.stylesheets);else if(r.unsuspend){var s=r.unsuspend;r.unsuspend=null,s()}}}function Mc(){this.count--,fk(this)}function K3(){this.imgCount--,fk(this)}var lh=null;function sh(r,s){r.stylesheets=null,r.unsuspend!==null&&(r.count++,lh=new Map,s.forEach(W3,r),lh=null,Mc.call(r))}function W3(r,s){if(!(s.state.loading&4)){var c=lh.get(r);if(c)var h=c.get(null);else{c=new Map,lh.set(r,c);for(var p=r.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),Xg.exports=pM(),Xg.exports}var xM=gM();const yM=my(xM);class gy extends Error{constructor(t,i,l){super(t);dh(this,"status");dh(this,"detail");this.name="ApiError",this.status=i,this.detail=l}}async function fs(n,e){let t=e,i;try{const l=await n.json();typeof(l==null?void 0:l.detail)=="string"&&l.detail?(t=l.detail,i=l.detail):Array.isArray(l==null?void 0:l.detail)&&(i=l.detail)}catch{}return new gy(t,n.status,i)}async function bM(n){const e=await fetch(`/api/notifications?after=${n}`);if(!e.ok)throw new Error("Failed to fetch notifications");return e.json()}async function vM(){const n=await fetch("/api/actions/open-log",{method:"POST"});if(!n.ok)throw new Error("Failed to open log file");return n.json()}async function wM(n){const e=new URLSearchParams;e.set("limit",String(n.limit)),n!=null&&n.level&&e.set("level",n.level),n!=null&&n.search&&e.set("search",n.search);const t=await fetch(`/api/logs?${e.toString()}`);if(!t.ok)throw new Error("Failed to fetch log entries");return t.json()}async function Gh(){const n=await fetch("/api/system");if(!n.ok)throw new Error("Failed to fetch system info");return n.json()}async function kM(n){const e=await fetch("/api/system/bind",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:n})});if(!e.ok){let t="Failed to update LAN binding";try{const i=await e.json();i!=null&&i.detail&&(t=i.detail)}catch{}throw new Error(t)}return e.json()}async function SM(n,e=1e4){const t=Date.now()+e;let i=null;for(;Date.now()setTimeout(l,500))}return i}async function Lk(){const n=await fetch("/api/config");if(!n.ok)throw new Error("Failed to fetch app configuration");return n.json()}async function zk(n){const e=await fetch("/api/config/select-directory",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:n})});if(!e.ok)throw new Error("Failed to select directory");return e.json()}async function CM(n){const e=await fetch("/api/config/load",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config_path:n})});if(!e.ok)throw new Error("Failed to load config file");return e.json()}async function GC(n,e){const t=await fetch("/api/config/load-content",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,content:e})});if(!t.ok){let i=`Failed to apply dropped config (${n})`;try{const l=await t.json();l!=null&&l.detail&&(i=l.detail)}catch{}throw new Error(i)}return t.json()}async function OM(){const n=await fetch("/api/config/reload",{method:"POST"});if(!n.ok){let e="Failed to reload configuration";try{const t=await n.json();t!=null&&t.detail&&(e=t.detail)}catch{}throw new Error(e)}return n.json()}async function NM(n){const e=await fetch("/api/config/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:n})});if(!e.ok)throw new Error("Failed to create config file");return e.json()}async function Bk(){const n=await fetch("/api/config/content");if(!n.ok)throw await fs(n,"Failed to fetch config content");return n.json()}async function Pk(n,e){const t=await fetch("/api/config/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,content:e})});if(!t.ok)throw await fs(t,"Failed to validate config content");return t.json()}async function TM(){const n=await fetch("/api/config/template",{method:"POST"});if(!n.ok)throw await fs(n,"Failed to fetch config template");return n.json()}async function Hk(n,e,t={}){const i=await fetch("/api/config/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,force:e,baseline_hash:t.baselineHash??null,overwrite_changes:t.overwriteChanges??!1})});if(!i.ok)throw await fs(i,"Failed to save configuration");const l=await i.json();return{config:l.config,contentHash:l.content_hash??null}}async function AM(n){const e=await fetch("/api/config/save-as",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw await fs(e,"Failed to save configuration as");const t=await e.json();return{config:t.config,contentHash:t.content_hash??null}}async function EM(n){const e=`/api/fs/browse?path=${encodeURIComponent(n)}&include_hidden=true`,t=await fetch(e);if(!t.ok)throw new Error("Failed to browse config files");return t.json()}async function KC(n){const e=`/api/fs/browse?path=${encodeURIComponent(n)}`,t=await fetch(e);if(!t.ok)throw new Error("Failed to browse directory");return t.json()}async function Ik(n,e){const t=await fetch("/api/scan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),signal:e});if(!t.ok)throw new Error("Failed to execute scan");return t.json()}async function Kg(n){const e=new URLSearchParams;(n==null?void 0:n.offset)!=null&&e.set("offset",String(n.offset)),(n==null?void 0:n.limit)!=null&&e.set("limit",String(n.limit)),n!=null&&n.sort_by&&e.set("sort_by",n.sort_by),n!=null&&n.sort_dir&&e.set("sort_dir",n.sort_dir);const t=e.toString(),i=`/api/scan/results${t?`?${t}`:""}`,l=await fetch(i,{signal:n==null?void 0:n.signal});if(!l.ok)throw new Error("Failed to fetch scan results");return l.json()}async function MM(n){const e=await fetch("/api/actions/launch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw new Error("Failed to launch file");return e.json()}async function WC(n){const e=await fetch("/api/actions/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n})});if(!e.ok)throw new Error("Failed to reveal file");return e.json()}async function Y0(n){const e=await fetch("/api/actions/open-folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n})});if(!e.ok)throw new Error("Failed to open folder");return e.json()}async function Uk(n){const e=await fetch("/api/actions/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n})});if(!e.ok)throw new Error("Failed to open terminal");return e.json()}async function Fk(n,e){const t=await fetch("/api/actions/hash",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n,algorithm:e})});if(!t.ok)throw new Error("Failed to compute hash");return t.json()}async function DM(){const n=await fetch("/api/actions/open-config",{method:"POST"});if(!n.ok)throw new Error("Failed to open config file");return n.json()}async function qk(n){const e={file_path:n.file_path||n.filePath,content:n.content},t=await fetch("/api/actions/barcode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error("Failed to generate barcode");return t.json()}async function RM(n){const e=await fetch("/api/actions/barcode/decode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image_base64:n.imageBase64,formats:n.formats})});if(!e.ok)throw e.status===503?new Error("Server-side barcode decoding is unavailable"):new Error(`Failed to decode frame (HTTP ${e.status})`);return e.json()}async function jM(n,e){const t=await fetch("/api/actions/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n}),signal:e});if(!t.ok)throw new Error("Failed to fetch metadata");return t.json()}async function _M(n,e){const t=await fetch("/api/actions/export-csv",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,filename:e})});if(!t.ok)throw new Error("Failed to export CSV");return t.json()}async function LM(n,e){const t=await fetch("/api/actions/save-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image_base64:n,filename:e})});if(!t.ok)throw new Error("Failed to save image");return t.json()}async function zM(n){const e=await fetch("/api/workflow/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw await fs(e,"Failed to start workflow session");return e.json()}async function BM(n,e){const t=await fetch(`/api/workflow/${n}/respond`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e})});if(!t.ok)throw await fs(t,"Failed to respond to workflow prompt");return t.json()}async function PM(n){const e=await fetch(`/api/workflow/${n}/abort`,{method:"POST"});if(!e.ok)throw await fs(e,"Failed to abort workflow session");return e.json()}const HM=[".profiles",".profiles.yaml",".profiles.yml",".yaml",".yml"];function IM(n){const e=n.toLowerCase();return HM.some(t=>e.endsWith(t))}function UM(n){for(const e of n)if(IM(e.name))return e;return null}function Kh(){return{depth:0,overlayVisible:!1}}function Vk(n,e,t){switch(e){case"enter":return t?{depth:n.depth+1,overlayVisible:!0}:n;case"leave":{const i=Math.max(0,n.depth-1);return{depth:i,overlayVisible:n.depth>0&&i>0}}case"drop":return Kh()}}function Qk(n){return n==="light"?"light":"dark"}/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const FM=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ZC=(...n)=>n.filter((e,t,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===t).join(" ").trim();/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var qM={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const VM=M.forwardRef(({color:n="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:i,className:l="",children:o,iconNode:a,...u},f)=>M.createElement("svg",{ref:f,...qM,width:e,height:e,stroke:n,strokeWidth:i?Number(t)*24/Number(e):t,className:ZC("lucide",l),...u},[...a.map(([d,m])=>M.createElement(d,m)),...Array.isArray(o)?o:[o]]));/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const De=(n,e)=>{const t=M.forwardRef(({className:i,...l},o)=>M.createElement(VM,{ref:o,iconNode:e,className:ZC(`lucide-${FM(n)}`,i),...l}));return t.displayName=`${n}`,t};/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const QM=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],XM=De("Activity",QM);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $M=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],JC=De("ArrowDown",$M);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const YM=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],GM=De("ArrowLeftRight",YM);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const KM=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],WM=De("ArrowRight",KM);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ZM=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Xk=De("ArrowUpDown",ZM);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const JM=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],e4=De("ArrowUp",JM);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const t4=[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]],n4=De("Bug",t4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const i4=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],r4=De("Calendar",i4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const l4=[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],eO=De("Camera",l4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const s4=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Lr=De("Check",s4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const o4=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],a4=De("ChevronDown",o4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const c4=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Xd=De("ChevronRight",c4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const u4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Gc=De("CircleAlert",u4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const f4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],$k=De("CircleCheck",f4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const h4=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],d4=De("CircleDashed",h4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const m4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],p4=De("CircleDot",m4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const g4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],x4=De("CirclePause",g4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const y4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]],b4=De("CirclePlay",y4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const v4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],ou=De("CircleX",v4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const w4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],k4=De("Clock",w4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const S4=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],fi=De("Copy",S4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const C4=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],tO=De("Download",C4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const O4=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],nO=De("ExternalLink",O4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const N4=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],T4=De("EyeOff",N4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const A4=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],G0=De("Eye",A4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const E4=[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]],M4=De("FastForward",E4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const D4=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],R4=De("FileCode2",D4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const j4=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],K0=De("FileCode",j4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _4=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3.2 12.9-.9-.4",key:"1i3dj5"}],["path",{d:"m3.2 15.1-.9.4",key:"1fvgj0"}],["path",{d:"M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5",key:"1yo3oz"}],["path",{d:"m4.9 11.2-.4-.9",key:"otmhb9"}],["path",{d:"m4.9 16.8-.4.9",key:"1b8z07"}],["path",{d:"m7.5 10.3-.4.9",key:"11k65u"}],["path",{d:"m7.5 17.7-.4-.9",key:"431x55"}],["path",{d:"m9.7 12.5-.9.4",key:"87sjan"}],["path",{d:"m9.7 15.5-.9-.4",key:"khqm91"}],["circle",{cx:"6",cy:"14",r:"3",key:"a1xfv6"}]],oa=De("FileCog",_4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const L4=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]],z4=De("FilePlus2",L4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const B4=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ka=De("FileText",B4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const P4=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]],Wg=De("File",P4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const H4=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],I4=De("FlaskConical",H4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const U4=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],es=De("FolderOpen",U4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const F4=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Ou=De("Folder",F4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const q4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],V4=De("Globe",q4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Q4=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],aa=De("Hash",Q4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const X4=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]],$d=De("House",X4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],xy=De("Info",$4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Y4=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],iO=De("Keyboard",Y4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const G4=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],K4=De("Link2",G4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const W4=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],sl=De("LoaderCircle",W4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Z4=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],J4=De("Lock",Z4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const eD=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],tD=De("Moon",eD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const nD=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],iD=De("Network",nD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const rD=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],ns=De("Play",rD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const lD=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],sD=De("Plus",lD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const oD=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],yy=De("QrCode",oD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const aD=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Yd=De("RefreshCw",aD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const cD=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],uD=De("Rocket",cD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const fD=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],hD=De("RotateCcw",fD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const dD=[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]],mD=De("SaveAll",dD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const pD=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],rO=De("Save",pD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gD=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],lO=De("Search",gD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const xD=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],yD=De("Settings",xD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bD=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],vD=De("Sun",bD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wD=[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]],W0=De("Terminal",wD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kD=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],sO=De("Timer",kD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const SD=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],oO=De("Trash2",SD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const CD=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],by=De("TriangleAlert",CD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const OD=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],ND=De("User",OD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const TD=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],aO=De("Webhook",TD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const AD=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],ED=De("Workflow",AD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const MD=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ri=De("X",MD);function DD(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m${t.toString().padStart(2,"0")}s`}function RD(n){if(!n)return{label:"",cut:!1};const e=n.replace(/\\/g,"/").split("/").filter(Boolean);return e.length===0?{label:n,cut:!1}:{label:e[e.length-1],cut:e.length>1}}function jD({directory:n}){const[e,t]=M.useState(0);M.useEffect(()=>{t(0);const o=window.setInterval(()=>{t(a=>a+1)},1e3);return()=>window.clearInterval(o)},[]);const{label:i,cut:l}=RD(n);return y.jsxs("div",{"data-testid":"scan-status-strip",className:"flex min-w-0 items-center gap-1.5 text-[11px] text-ink-muted",children:[y.jsx(sl,{className:"h-3 w-3 shrink-0 animate-spin text-chip-indigo-text motion-reduce:animate-none","aria-hidden":"true"}),y.jsxs("span",{className:"min-w-0 truncate",children:["Scanning",n&&y.jsxs(y.Fragment,{children:[" ",y.jsxs("span",{className:"font-mono text-ink-secondary",title:n,children:[l?"…/":"",i]})]})," — ",y.jsx("span",{className:"font-mono tabular-nums text-ink-secondary",children:DD(e)})]})]})}function _D({onExecute:n,scanning:e,hasSelection:t,fileCount:i,totalCount:l,scanningDirectory:o="",toastMessage:a,onToastDismiss:u}){const f=(a==null?void 0:a.kind)==="error";return y.jsxs("div",{className:"relative flex items-center justify-between border-t border-line bg-surface-glass px-4 py-2.5 text-xs transition-colors duration-200",children:[a&&y.jsx("div",{role:"status","aria-live":f?"assertive":"polite","aria-atomic":"true",className:`animate-toast-in absolute left-1/2 top-1/2 z-[var(--z-toast)] max-w-[min(80vw,640px)] -translate-x-1/2 -translate-y-1/2 rounded-xl border px-4 py-2 text-xs font-medium glass-panel-strong ${f?"pointer-events-auto flex max-w-[min(70vw,560px)] items-center gap-2.5 border-status-danger-border text-left text-ink":"pointer-events-none max-w-[min(70vw,560px)] text-center text-ink"}`,children:f?y.jsxs(y.Fragment,{children:[y.jsx(ou,{className:"h-3.5 w-3.5 shrink-0 text-status-danger-text/80","aria-hidden":"true"}),y.jsx("span",{className:"min-w-0 flex-1",children:a.message}),u&&y.jsx("button",{type:"button",onClick:u,"aria-label":"Dismiss error",className:"shrink-0 rounded-md p-0.5 text-status-danger-text/60 hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-status-danger-border transition-colors",children:y.jsx(Ri,{className:"h-3.5 w-3.5"})})]}):a.message}),y.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e&&y.jsx(jD,{directory:o}),l!==void 0&&l!==i&&y.jsxs("span",{"data-testid":"action-bar-count",className:"text-ink-muted",children:["Showing ",i," of ",l]})]}),y.jsxs("button",{onClick:n,disabled:!t||e,className:"flex shrink-0 items-center gap-2 rounded-xl border border-emerald-300/50 bg-gradient-to-b from-emerald-400/90 to-emerald-600/90 px-5 py-2 font-semibold text-white shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_8px_24px_-6px_rgb(16_185_129/0.55)] transition-[filter,box-shadow,transform] hover:-translate-y-px hover:brightness-110 hover:shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_12px_30px_-6px_rgb(16_185_129/0.7)] disabled:opacity-40 disabled:hover:translate-y-0 disabled:hover:brightness-100 disabled:hover:shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_8px_24px_-6px_rgb(16_185_129/0.55)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400",children:[y.jsx(ns,{className:"h-3.5 w-3.5 fill-current"}),y.jsx("span",{children:"Execute"}),y.jsx("kbd",{className:"rounded bg-emerald-800/60 px-1.5 py-0.5 text-[10px] text-emerald-200 shadow-[inset_0_1px_0_rgb(255_255_255/0.12)]",children:"↵"})]})]})}let Z0=[],cO=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e>1;if(n=cO[i])e=i+1;else return!0;if(e==t)return!1}}function Yk(n){return n>=127462&&n<=127487}const Gk=8205;function zD(n,e,t=!0,i=!0){return(t?uO:BD)(n,e,i)}function uO(n,e,t){if(e==n.length)return e;e&&fO(n.charCodeAt(e))&&hO(n.charCodeAt(e-1))&&e--;let i=Zg(n,e);for(e+=Kk(i);e=0&&Yk(Zg(n,a));)o++,a-=2;if(o%2==0)break;e+=2}else break}return e}function BD(n,e,t){for(;e>1;){let i=uO(n,e-2,t);if(i=56320&&n<57344}function hO(n){return n>=55296&&n<56320}function Kk(n){return n<65536?1:2}class mt{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Sa(this,e,t);let l=[];return this.decompose(0,e,l,2),i.length&&i.decompose(0,i.length,l,3),this.decompose(t,this.length,l,1),Er.from(l,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Sa(this,e,t);let i=[];return this.decompose(e,t,i,0),Er.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),l=new Kc(this),o=new Kc(e);for(let a=t,u=t;;){if(l.next(a),o.next(a),a=0,l.lineBreak!=o.lineBreak||l.done!=o.done||l.value!=o.value)return!1;if(u+=l.value.length,l.done||u>=i)return!0}}iter(e=1){return new Kc(this,e)}iterRange(e,t=this.length){return new dO(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let l=this.line(e).from;i=this.iterRange(l,Math.max(l,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new mO(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Jt(e):Er.from(Jt.split(e,[]))}}class Jt extends mt{constructor(e,t=PD(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,l){for(let o=0;;o++){let a=this.text[o],u=l+a.length;if((t?i:u)>=e)return new HD(l,u,i,a);l=u+1,i++}}decompose(e,t,i,l){let o=e<=0&&t>=this.length?this:new Jt(Wk(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(l&1){let a=i.pop(),u=Wh(o.text,a.text.slice(),0,o.length);if(u.length<=32)i.push(new Jt(u,a.length+o.length));else{let f=u.length>>1;i.push(new Jt(u.slice(0,f)),new Jt(u.slice(f)))}}else i.push(o)}replace(e,t,i){if(!(i instanceof Jt))return super.replace(e,t,i);[e,t]=Sa(this,e,t);let l=Wh(this.text,Wh(i.text,Wk(this.text,0,e)),t),o=this.length+i.length-(t-e);return l.length<=32?new Jt(l,o):Er.from(Jt.split(l,[]),o)}sliceString(e,t=this.length,i=` +`){[e,t]=Sa(this,e,t);let l="";for(let o=0,a=0;o<=t&&ae&&a&&(l+=i),eo&&(l+=u.slice(Math.max(0,e-o),t-o)),o=f+1}return l}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],l=-1;for(let o of e)i.push(o),l+=o.length+1,i.length==32&&(t.push(new Jt(i,l)),i=[],l=-1);return l>-1&&t.push(new Jt(i,l)),t}}class Er extends mt{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,l){for(let o=0;;o++){let a=this.children[o],u=l+a.length,f=i+a.lines-1;if((t?f:u)>=e)return a.lineInner(e,t,i,l);l=u+1,i=f+1}}decompose(e,t,i,l){for(let o=0,a=0;a<=t&&o=a){let d=l&((a<=e?1:0)|(f>=t?2:0));a>=e&&f<=t&&!d?i.push(u):u.decompose(e-a,t-a,i,d)}a=f+1}}replace(e,t,i){if([e,t]=Sa(this,e,t),i.lines=o&&t<=u){let f=a.replace(e-o,t-o,i),d=this.lines-a.lines+f.lines;if(f.lines>4&&f.lines>d>>6){let m=this.children.slice();return m[l]=f,new Er(m,this.length-(t-e)+i.length)}return super.replace(o,u,f)}o=u+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` +`){[e,t]=Sa(this,e,t);let l="";for(let o=0,a=0;oe&&o&&(l+=i),ea&&(l+=u.sliceString(e-a,t-a,i)),a=f+1}return l}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Er))return 0;let i=0,[l,o,a,u]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;l+=t,o+=t){if(l==a||o==u)return i;let f=this.children[l],d=e.children[o];if(f!=d)return i+f.scanIdentical(d,t);i+=f.length+1}}static from(e,t=e.reduce((i,l)=>i+l.length+1,-1)){let i=0;for(let v of e)i+=v.lines;if(i<32){let v=[];for(let w of e)w.flatten(v);return new Jt(v,t)}let l=Math.max(32,i>>5),o=l<<1,a=l>>1,u=[],f=0,d=-1,m=[];function g(v){let w;if(v.lines>o&&v instanceof Er)for(let S of v.children)g(S);else v.lines>a&&(f>a||!f)?(b(),u.push(v)):v instanceof Jt&&f&&(w=m[m.length-1])instanceof Jt&&v.lines+w.lines<=32?(f+=v.lines,d+=v.length+1,m[m.length-1]=new Jt(w.text.concat(v.text),w.length+1+v.length)):(f+v.lines>l&&b(),f+=v.lines,d+=v.length+1,m.push(v))}function b(){f!=0&&(u.push(m.length==1?m[0]:Er.from(m,d)),d=-1,f=m.length=0)}for(let v of e)g(v);return b(),u.length==1?u[0]:new Er(u,t)}}mt.empty=new Jt([""],0);function PD(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Wh(n,e,t=0,i=1e9){for(let l=0,o=0,a=!0;o=t&&(f>i&&(u=u.slice(0,i-l)),l0?1:(e instanceof Jt?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,l=this.nodes[i],o=this.offsets[i],a=o>>1,u=l instanceof Jt?l.text.length:l.children.length;if(a==(t>0?u:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(l instanceof Jt){let f=l.text[a+(t<0?-1:0)];if(this.offsets[i]+=t,f.length>Math.max(0,e))return this.value=e==0?f:t>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=l.children[a+(t<0?-1:0)];e>f.length?(e-=f.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(f),this.offsets.push(t>0?1:(f instanceof Jt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class dO{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Kc(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:l}=this.cursor.next(e);return this.pos+=(l.length+e)*t,this.value=l.length<=i?l:t<0?l.slice(l.length-i):l.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class mO{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:l}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=l,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},Kc.prototype[Symbol.iterator]=dO.prototype[Symbol.iterator]=mO.prototype[Symbol.iterator]=function(){return this});class HD{constructor(e,t,i,l){this.from=e,this.to=t,this.number=i,this.text=l}get length(){return this.to-this.from}}function Sa(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function On(n,e,t=!0,i=!0){return zD(n,e,t,i)}function ID(n){return n>=56320&&n<57344}function UD(n){return n>=55296&&n<56320}function hi(n,e){let t=n.charCodeAt(e);if(!UD(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return ID(i)?(t-55296<<10)+(i-56320)+65536:t}function vy(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Mr(n){return n<65536?1:2}const J0=/\r\n?|\n/;var Zn=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(Zn||(Zn={}));class zr{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return o+(e-l);o+=u}else{if(i!=Zn.Simple&&d>=e&&(i==Zn.TrackDel&&le||i==Zn.TrackBefore&&le))return null;if(d>e||d==e&&t<0&&!u)return e==l||t<0?o:o+f;o+=f}l=d}if(e>l)throw new RangeError(`Position ${e} is out of range for changeset of length ${l}`);return o}touchesRange(e,t=e){for(let i=0,l=0;i=0&&l<=t&&u>=e)return lt?"cover":!0;l=u}return!1}toString(){let e="";for(let t=0;t=0?":"+l:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zr(e)}static create(e){return new zr(e)}}class mn extends zr{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ex(this,(t,i,l,o,a)=>e=e.replace(l,l+(i-t),a),!1),e}mapDesc(e,t=!1){return tx(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let l=0,o=0;l=0){t[l]=u,t[l+1]=a;let f=l>>1;for(;i.length0&&Wl(i,t,o.text),o.forward(m),u+=m}let d=e[a++];for(;u>1].toJSON()))}return e}static of(e,t,i){let l=[],o=[],a=0,u=null;function f(m=!1){if(!m&&!l.length)return;ab||g<0||b>t)throw new RangeError(`Invalid change range ${g} to ${b} (in doc of length ${t})`);let w=v?typeof v=="string"?mt.of(v.split(i||J0)):v:mt.empty,S=w.length;if(g==b&&S==0)return;ga&&In(l,g-a,-1),In(l,b-g,S),Wl(o,l,w),a=b}}return d(e),f(!u),u}static empty(e){return new mn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let l=0;lu&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)t.push(o[0],0);else{for(;i.length=0&&t<=0&&t==n[l+1]?n[l]+=e:l>=0&&e==0&&n[l]==0?n[l+1]+=t:i?(n[l]+=e,n[l+1]+=t):n.push(e,t)}function Wl(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||a==n.sections.length||n.sections[a+1]<0);)u=n.sections[a++],f=n.sections[a++];e(l,d,o,m,g),l=d,o=m}}}function tx(n,e,t,i=!1){let l=[],o=i?[]:null,a=new au(n),u=new au(e);for(let f=-1;;){if(a.done&&u.len||u.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&u.ins==-1){let d=Math.min(a.len,u.len);In(l,d,-1),a.forward(d),u.forward(d)}else if(u.ins>=0&&(a.ins<0||f==a.i||a.off==0&&(u.len=0&&f=0){let d=0,m=a.len;for(;m;)if(u.ins==-1){let g=Math.min(m,u.len);d+=g,m-=g,u.forward(g)}else if(u.ins==0&&u.lenf||a.ins>=0&&a.len>f)&&(u||i.length>d),o.forward2(f),a.forward(f)}}}}class au{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?mt.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?mt.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Gl{constructor(e,t,i,l){this.from=e,this.to=t,this.flags=i,this.goalColumn=l}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,l;return this.empty?i=l=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),l=e.mapPos(this.to,-1)),i==this.from&&l==this.to?this:new Gl(i,l,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return oe.range(e,t,void 0,void 0,i);let l=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return oe.range(this.anchor,l,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return oe.range(e.anchor,e.head)}static create(e,t,i,l){return new Gl(e,t,i,l)}}class oe{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:oe.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new oe(e.ranges.map(t=>Gl.fromJSON(t)),e.main)}static single(e,t=e){return new oe([oe.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,l=0;ll.from-o.from),t=e.indexOf(i);for(let l=1;lo.head?oe.range(f,u):oe.range(u,f))}}return new oe(e,t)}}function gO(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let wy=0;class Ce{constructor(e,t,i,l,o){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=l,this.id=wy++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new Ce(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:ky),!!e.static,e.enables)}of(e){return new Zh([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Zh(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Zh(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function ky(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class Zh{constructor(e,t,i,l){this.dependencies=e,this.facet=t,this.type=i,this.value=l,this.id=wy++}dynamicSlot(e){var t;let i=this.value,l=this.facet.compareInput,o=this.id,a=e[o]>>1,u=this.type==2,f=!1,d=!1,m=[];for(let g of this.dependencies)g=="doc"?f=!0:g=="selection"?d=!0:(((t=e[g.id])!==null&&t!==void 0?t:1)&1)==0&&m.push(e[g.id]);return{create(g){return g.values[a]=i(g),1},update(g,b){if(f&&b.docChanged||d&&(b.docChanged||b.selection)||nx(g,m)){let v=i(g);if(u?!Zk(v,g.values[a],l):!l(v,g.values[a]))return g.values[a]=v,1}return 0},reconfigure:(g,b)=>{let v,w=b.config.address[o];if(w!=null){let S=fd(b,w);if(this.dependencies.every(C=>C instanceof Ce?b.facet(C)===g.facet(C):C instanceof Fn?b.field(C,!1)==g.field(C,!1):!0)||(u?Zk(v=i(g),S,l):l(v=i(g),S)))return g.values[a]=S,0}else v=i(g);return g.values[a]=v,1}}}get extension(){return this}}function Zk(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[f.id]),l=t.map(f=>f.type),o=i.filter(f=>!(f&1)),a=n[e.id]>>1;function u(f){let d=[];for(let m=0;mi===l),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(mh).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,l)=>{let o=i.values[t],a=this.updateF(o,l);return this.compareF(o,a)?0:(i.values[t]=a,1)},reconfigure:(i,l)=>{let o=i.facet(mh),a=l.facet(mh),u;return(u=o.find(f=>f.field==this))&&u!=a.find(f=>f.field==this)?(i.values[t]=u.create(i),1):l.config.address[this.id]!=null?(i.values[t]=l.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,mh.of({field:this,create:e})]}get extension(){return this}}const $s={lowest:4,low:3,default:2,high:1,highest:0};function zc(n){return e=>new xO(e,n)}const ao={highest:zc($s.highest),high:zc($s.high),default:zc($s.default),low:zc($s.low),lowest:zc($s.lowest)};class xO{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Gd{of(e){return new ix(this,e)}reconfigure(e){return Gd.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class ix{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class ud{constructor(e,t,i,l,o,a){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=l,this.staticValues=o,this.facets=a,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let l=[],o=Object.create(null),a=new Map;for(let b of qD(e,t,a))b instanceof Fn?l.push(b):(o[b.facet.id]||(o[b.facet.id]=[])).push(b);let u=Object.create(null),f=[],d=[];for(let b of l)u[b.id]=d.length<<1,d.push(v=>b.slot(v));let m=i==null?void 0:i.config.facets;for(let b in o){let v=o[b],w=v[0].facet,S=m&&m[b]||[];if(v.every(C=>C.type==0))if(u[w.id]=f.length<<1|1,ky(S,v))f.push(i.facet(w));else{let C=w.combine(v.map(N=>N.value));f.push(i&&w.compare(C,i.facet(w))?i.facet(w):C)}else{for(let C of v)C.type==0?(u[C.id]=f.length<<1|1,f.push(C.value)):(u[C.id]=d.length<<1,d.push(N=>C.dynamicSlot(N)));u[w.id]=d.length<<1,d.push(C=>FD(C,w,v))}}let g=d.map(b=>b(u));return new ud(e,a,g,u,f,o)}}function qD(n,e,t){let i=[[],[],[],[],[]],l=new Map;function o(a,u){let f=l.get(a);if(f!=null){if(f<=u)return;let d=i[f].indexOf(a);d>-1&&i[f].splice(d,1),a instanceof ix&&t.delete(a.compartment)}if(l.set(a,u),Array.isArray(a))for(let d of a)o(d,u);else if(a instanceof ix){if(t.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let d=e.get(a.compartment)||a.inner;t.set(a.compartment,d),o(d,u)}else if(a instanceof xO)o(a.inner,a.prec);else if(a instanceof Fn)i[u].push(a),a.provides&&o(a.provides,u);else if(a instanceof Zh)i[u].push(a),a.facet.extensions&&o(a.facet.extensions,$s.default);else{let d=a.extension;if(!d)throw new Error(`Unrecognized extension value in extension set (${a}).`);if(d==a)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(d,u)}}return o(n,$s.default),i.reduce((a,u)=>a.concat(u))}function Wc(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let l=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|l}function fd(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const yO=Ce.define(),rx=Ce.define({combine:n=>n.some(e=>e),static:!0}),bO=Ce.define({combine:n=>n.length?n[0]:void 0,static:!0}),vO=Ce.define(),wO=Ce.define(),kO=Ce.define(),SO=Ce.define({combine:n=>n.length?n[0]:!1});class ul{constructor(e,t){this.type=e,this.value=t}static define(){return new VD}}class VD{of(e){return new ul(this,e)}}class QD{constructor(e){this.map=e}of(e){return new Ke(this,e)}}class Ke{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new Ke(this.type,t)}is(e){return this.type==e}static define(e={}){return new QD(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let l of e){let o=l.map(t);o&&i.push(o)}return i}}Ke.reconfigure=Ke.define();Ke.appendConfig=Ke.define();class pn{constructor(e,t,i,l,o,a){this.startState=e,this.changes=t,this.selection=i,this.effects=l,this.annotations=o,this.scrollIntoView=a,this._doc=null,this._state=null,i&&gO(i,t.newLength),o.some(u=>u.type==pn.time)||(this.annotations=o.concat(pn.time.of(Date.now())))}static create(e,t,i,l,o,a){return new pn(e,t,i,l,o,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(pn.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}pn.time=ul.define();pn.userEvent=ul.define();pn.addToHistory=ul.define();pn.remote=ul.define();function XD(n,e){let t=[];for(let i=0,l=0;;){let o,a;if(i=n[i]))o=n[i++],a=n[i++];else if(l=0;l--){let o=i[l](n);o instanceof pn?n=o:Array.isArray(o)&&o.length==1&&o[0]instanceof pn?n=o[0]:n=OO(e,ma(o),!1)}return n}function YD(n){let e=n.startState,t=e.facet(kO),i=n;for(let l=t.length-1;l>=0;l--){let o=t[l](n);o&&Object.keys(o).length&&(i=CO(i,lx(e,o,n.changes.newLength),!0))}return i==n?n:pn.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const GD=[];function ma(n){return n==null?GD:Array.isArray(n)?n:[n]}var Ft=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(Ft||(Ft={}));const KD=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let sx;try{sx=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function WD(n){if(sx)return sx.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||KD.test(t)))return!0}return!1}function ZD(n){return e=>{if(!/\S/.test(e))return Ft.Space;if(WD(e))return Ft.Word;for(let t=0;t-1)return Ft.Word;return Ft.Other}}class gt{constructor(e,t,i,l,o,a){this.config=e,this.doc=t,this.selection=i,this.values=l,this.status=e.statusTemplate.slice(),this.computeSlot=o,a&&(a._state=this);for(let u=0;ul.set(d,f)),t=null),l.set(u.value.compartment,u.value.extension)):u.is(Ke.reconfigure)?(t=null,i=u.value):u.is(Ke.appendConfig)&&(t=null,i=ma(i).concat(u.value));let o;t?o=e.startState.values.slice():(t=ud.resolve(i,l,this),o=new gt(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(f,d)=>d.reconfigure(f,this),null).values);let a=e.startState.facet(rx)?e.newSelection:e.newSelection.asSingle();new gt(t,e.newDoc,a,o,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:oe.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),l=this.changes(i.changes),o=[i.range],a=ma(i.effects);for(let u=1;ua.spec.fromJSON(u,f)))}}return gt.create({doc:e.doc,selection:oe.fromJSON(e.selection),extensions:t.extensions?l.concat([t.extensions]):l})}static create(e={}){let t=ud.resolve(e.extensions||[],new Map),i=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(t.staticFacet(gt.lineSeparator)||J0)),l=e.selection?e.selection instanceof oe?e.selection:oe.single(e.selection.anchor,e.selection.head):oe.single(0);return gO(l,i.length),t.staticFacet(rx)||(l=l.asSingle()),new gt(t,i,l,t.dynamicSlots.map(()=>null),(o,a)=>a.create(o),null)}get tabSize(){return this.facet(gt.tabSize)}get lineBreak(){return this.facet(gt.lineSeparator)||` +`}get readOnly(){return this.facet(SO)}phrase(e,...t){for(let i of this.facet(gt.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,l)=>{if(l=="$")return"$";let o=+(l||1);return!o||o>t.length?i:t[o-1]})),e}languageDataAt(e,t,i=-1){let l=[];for(let o of this.facet(yO))for(let a of o(this,t,i))Object.prototype.hasOwnProperty.call(a,e)&&l.push(a[e]);return l}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return ZD(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:l}=this.doc.lineAt(e),o=this.charCategorizer(e),a=e-i,u=e-i;for(;a>0;){let f=On(t,a,!1);if(o(t.slice(f,a))!=Ft.Word)break;a=f}for(;un.length?n[0]:4});gt.lineSeparator=bO;gt.readOnly=SO;gt.phrases=Ce.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(l=>n[l]==e[l])}});gt.languageData=yO;gt.changeFilter=vO;gt.transactionFilter=wO;gt.transactionExtender=kO;Gd.reconfigure=Ke.define();function Pr(n,e,t={}){let i={};for(let l of n)for(let o of Object.keys(l)){let a=l[o],u=i[o];if(u===void 0)i[o]=a;else if(!(u===a||a===void 0))if(Object.hasOwnProperty.call(t,o))i[o]=t[o](u,a);else throw new Error("Config merge conflict for field "+o)}for(let l in e)i[l]===void 0&&(i[l]=e[l]);return i}class is{eq(e){return this==e}range(e,t=e){return ox.create(e,t,this)}}is.prototype.startSide=is.prototype.endSide=0;is.prototype.point=!1;is.prototype.mapMode=Zn.TrackDel;function Sy(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}let ox=class NO{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new NO(e,t,i)}};function ax(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class Cy{constructor(e,t,i,l){this.from=e,this.to=t,this.value=i,this.maxPoint=l}get length(){return ta(this.to)}findIndex(e,t,i,l=0){let o=i?this.to:this.from;for(let a=l,u=o.length;;){if(a==u)return a;let f=a+u>>1,d=o[f]-e||(i?this.value[f].endSide:this.value[f].startSide)-t;if(f==a)return d>=0?a:u;d>=0?u=f:a=f+1}}between(e,t,i,l){for(let o=this.findIndex(t,-1e9,!0),a=this.findIndex(i,1e9,!1,o);oC||S==C&&b.startSide>0&&b.endSide<=0)continue;if(!((C-S||b.endSide-b.startSide)<0))if(d<0&&(d=S),b.point&&(m=Math.max(m,C-S)),(S-i||b.startSide-l)>=0)a.push(b),u.push(S-d),f.push(C-d),i=C,l=b.endSide;else{if(S==C)for(let N=a.length;N>0;N--){if((S-(f[N-1]+d)||b.startSide-a[N-1].endSide)>=0){a.splice(N,0,b),u.splice(N,0,S-d),f.splice(N,0,C-d);continue e}if((S-(u[N-1]+d)||b.endSide-a[N-1].startSide)>0)break}o(S,C,b)}}return{mapped:a.length?new Cy(u,f,a,m):null,pos:d}}}class st{constructor(e,t,i,l){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=l}static create(e,t,i,l){return new st(e,t,i,l)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:l=0,filterTo:o=this.length}=e,a=e.filter;if(t.length==0&&!a)return this;if(i&&(t=t.slice().sort(ax)),this.isEmpty)return t.length?st.of(t):this;let u=new TO(this,null,-1).goto(0),f=0,d=[],m=new Br;for(;u.value||f=0){let g=t[f++];m.addInner(g.from,g.to,g.value,!1)||d.push(g)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||ou.to||o{o||(o=new Br),o.addRange(f,d,m,!1)};for(let f=0;f=o&&e<=o+a.length&&a.between(o,e-o,t-o,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return cu.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return cu.from(e).goto(t)}static compare(e,t,i,l,o=-1){let a=e.filter(g=>g.maxPoint>0||!g.isEmpty&&g.maxPoint>=o),u=t.filter(g=>g.maxPoint>0||!g.isEmpty&&g.maxPoint>=o),f=Jk(a,u,i),d=new Bc(a,f,o),m=new Bc(u,f,o);i.iterGaps((g,b,v)=>eS(d,g,m,b,v,l)),i.empty&&i.length==0&&eS(d,0,m,0,0,l)}static eq(e,t,i=0,l){l==null&&(l=999999999);let o=e.filter(m=>!m.isEmpty&&t.indexOf(m)<0),a=t.filter(m=>!m.isEmpty&&e.indexOf(m)<0);if(o.length!=a.length)return!1;if(!o.length)return!0;let u=Jk(o,a),f=new Bc(o,u,0).goto(i),d=new Bc(a,u,0).goto(i);for(;;){if(f.to!=d.to||!cx(f.active,d.active)||f.point&&(!d.point||!Sy(f.point,d.point)))return!1;if(f.to>l)return!0;f.next(),d.next()}}static spans(e,t,i,l,o=-1){let a=new Bc(e,null,o).goto(t),u=t,f=a.openStart;for(;;){let d=Math.min(a.to,i);if(a.point){let m=a.activeForPoint(a.to),g=a.pointFromu&&(l.span(u,d,a.active,f),f=a.openEnd(d));if(a.to>i)return f+(a.point&&a.to>i?1:0);u=a.to,a.next()}}static of(e,t=!1){let i=new Br;for(let l of e instanceof ox?[e]:t?JD(e):e)i.add(l.from,l.to,l.value);return i.finish()}static join(e){if(!e.length)return st.empty;let t=ta(e);for(let i=e.length-2;i>=0;i--)for(let l=e[i];l!=st.empty;l=l.nextLayer)t=new st(l.chunkPos,l.chunk,t,Math.max(l.maxPoint,t.maxPoint));return t}}st.empty=new st([],[],null,-1);function ta(n){return n[n.length-1]}function JD(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(ax);e=i}return n}st.empty.nextLayer=st.empty;class Br{finishChunk(e){this.chunks.push(new Cy(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addRange(e,t,i,!0)}addRange(e,t,i,l){this.addInner(e,t,i,l)||(this.nextLayer||(this.nextLayer=new Br)).addRange(e,t,i,l)}addInner(e,t,i,l){let o=e-this.lastTo||i.startSide-this.last.endSide;if(l&&o<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(st.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=st.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Jk(n,e,t){let i=new Map;for(let o of n)for(let a=0;a=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&l.push(new TO(a,t,i,o));return l.length==1?l[0]:new cu(l)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)Jg(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)Jg(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Jg(this.heap,0)}}}function Jg(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let l=n[i];if(i+1=0&&(l=n[i+1],i++),t.compare(l)<0)break;n[i]=t,n[e]=l,e=i}}class Bc{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=cu.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){ph(this.active,e),ph(this.activeTo,e),ph(this.activeRank,e),this.minActive=tS(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:l,rank:o}=this.cursor;for(;t0;)t++;gh(this.active,t,i),gh(this.activeTo,t,l),gh(this.activeRank,t,o),e&&gh(e,t,this.cursor.from),this.minActive=tS(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let l=this.minActive;if(l>-1&&(this.activeTo[l]-this.cursor.from||this.active[l].endSide-this.cursor.startSide)<0){if(this.activeTo[l]>e){this.to=this.activeTo[l],this.endSide=this.active[l].endSide;break}this.removeActive(l),i&&ph(i,l)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[l]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function eS(n,e,t,i,l,o){n.goto(e),t.goto(i);let a=i+l,u=i,f=i-e,d=!!o.boundChange;for(let m=!1;;){let g=n.to+f-t.to,b=g||n.endSide-t.endSide,v=b<0?n.to+f:t.to,w=Math.min(v,a);if(n.point||t.point?(n.point&&t.point&&Sy(n.point,t.point)&&cx(n.activeForPoint(n.to),t.activeForPoint(t.to))||o.comparePoint(u,w,n.point,t.point),m=!1):(m&&(o.boundChange(u),m=!1),w>u&&!cx(n.active,t.active)&&o.compareRange(u,w,n.active,t.active),d&&wa)break;u=v,b<=0&&n.next(),b>=0&&t.next()}}function cx(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function tS(n,e){let t=-1,i=1e9;for(let l=0;l=e)return l;if(l==n.length)break;o+=n.charCodeAt(l)==9?t-o%t:1,l=On(n,l)}return i===!0?-1:n.length}const fx="ͼ",nS=typeof Symbol>"u"?"__"+fx:Symbol.for(fx),hx=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),iS=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class rs{constructor(e,t){this.rules=[];let{finish:i}=t||{};function l(a){return/^@/.test(a)?[a]:a.split(/,\s*/)}function o(a,u,f,d){let m=[],g=/^@(\w+)\b/.exec(a[0]),b=g&&g[1]=="keyframes";if(g&&u==null)return f.push(a[0]+";");for(let v in u){let w=u[v];if(/&/.test(v))o(v.split(/,\s*/).map(S=>a.map(C=>S.replace(/&/,C))).reduce((S,C)=>S.concat(C)),w,f);else if(w&&typeof w=="object"){if(!g)throw new RangeError("The value of a property ("+v+") should be a primitive value.");o(l(v),w,m,b)}else w!=null&&m.push(v.replace(/_.*/,"").replace(/[A-Z]/g,S=>"-"+S.toLowerCase())+": "+w+";")}(m.length||b)&&f.push((i&&!g&&!d?a.map(i):a).join(", ")+" {"+m.join(" ")+"}")}for(let a in e)o(l(a),e[a],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=iS[nS]||1;return iS[nS]=e+1,fx+e.toString(36)}static mount(e,t,i){let l=e[hx],o=i&&i.nonce;l?o&&l.setNonce(o):l=new eR(e,o),l.mount(Array.isArray(t)?t:[t],e)}}let rS=new Map;class eR{constructor(e,t){let i=e.ownerDocument||e,l=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&l.CSSStyleSheet){let o=rS.get(i);if(o)return e[hx]=o;this.sheet=new l.CSSStyleSheet,rS.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[hx]=this}mount(e,t){let i=this.sheet,l=0,o=0,a=!1;for(let u=0;u-1&&(this.modules.splice(d,1),a=!0,o--,d=-1),d==-1){if(this.modules.splice(o++,0,f),a=!0,i)for(let m=0;m",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},tR=typeof navigator<"u"&&/Mac/.test(navigator.platform),nR=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var _n=0;_n<10;_n++)ls[48+_n]=ls[96+_n]=String(_n);for(var _n=1;_n<=24;_n++)ls[_n+111]="F"+_n;for(var _n=65;_n<=90;_n++)ls[_n]=String.fromCharCode(_n+32),uu[_n]=String.fromCharCode(_n);for(var e0 in ls)uu.hasOwnProperty(e0)||(uu[e0]=ls[e0]);function iR(n){var e=tR&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||nR&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?uu:ls)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function Nt(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var l=t[i];typeof l=="string"?n.setAttribute(i,l):l!=null&&(n[i]=l)}e++}for(;e2);var ke={mac:oS||/Mac/.test(Wn.platform),windows:/Win/.test(Wn.platform),linux:/Linux|X11/.test(Wn.platform),ie:Kd,ie_version:EO?dx.documentMode||6:px?+px[1]:mx?+mx[1]:0,gecko:lS,gecko_version:lS?+(/Firefox\/(\d+)/.exec(Wn.userAgent)||[0,0])[1]:0,chrome:!!t0,chrome_version:t0?+t0[1]:0,ios:oS,android:/Android\b/.test(Wn.userAgent),webkit:sS,webkit_version:sS?+(/\bAppleWebKit\/(\d+)/.exec(Wn.userAgent)||[0,0])[1]:0,safari:gx,safari_version:gx?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Wn.userAgent)||[0,0])[1]:0,tabSize:dx.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Oy(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}const hd=Object.create(null);function Ny(n,e,t){if(n==e)return!0;n||(n=hd),e||(e=hd);let i=Object.keys(n),l=Object.keys(e);if(i.length-0!=l.length-0)return!1;for(let o of i)if(o!=t&&(l.indexOf(o)==-1||n[o]!==e[o]))return!1;return!0}function rR(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function aS(n,e,t){let i=!1;if(e)for(let l in e)t&&l in t||(i=!0,l=="style"?n.style.cssText="":n.removeAttribute(l));if(t)for(let l in t)e&&e[l]==t[l]||(i=!0,l=="style"?n.style.cssText=t[l]:n.setAttribute(l,t[l]));return i}function lR(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new ro(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,l;if(e.isBlockGap)i=-5e8,l=4e8;else{let{start:o,end:a}=MO(e,t);i=(o?t?-3e8:-1:5e8)-1,l=(a?t?2e8:1:-6e8)+1}return new ro(e,i,l,t,e.widget||null,!0)}static line(e){return new Tu(e)}static set(e,t=!1){return st.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Fe.none=st.empty;class Nu extends Fe{constructor(e){let{start:t,end:i}=MO(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Oy(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||hd}eq(e){return this==e||e instanceof Nu&&this.tagName==e.tagName&&Ny(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Nu.prototype.point=!1;class Tu extends Fe{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Tu&&this.spec.class==e.spec.class&&Ny(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Tu.prototype.mapMode=Zn.TrackBefore;Tu.prototype.point=!0;class ro extends Fe{constructor(e,t,i,l,o,a){super(t,i,o,e),this.block=l,this.isReplace=a,this.mapMode=l?t<=0?Zn.TrackBefore:Zn.TrackAfter:Zn.TrackDel}get type(){return this.startSide!=this.endSide?Bn.WidgetRange:this.startSide<=0?Bn.WidgetBefore:Bn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof ro&&sR(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}ro.prototype.point=!0;function MO(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function sR(n,e){return n==e||!!(n&&e&&n.compare(e))}function pa(n,e,t,i=0){let l=t.length-1;l>=0&&t[l]+i>=n?t[l]=Math.max(t[l],e):t.push(n,e)}class fu extends is{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof fu&&this.tagName==e.tagName&&Ny(this.attributes,e.attributes)}static create(e){return new fu(e.tagName,e.attributes||hd,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return st.of(e,t)}}fu.prototype.startSide=fu.prototype.endSide=-1;const Nn=n=>n.nodeType==1,Ca=n=>n.nodeType==3;function hu(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function xx(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Zc(n,e){if(!e.anchorNode)return!1;try{return xx(n,e.anchorNode)}catch{return!1}}function Jh(n){return Ca(n)?du(n,0,n.nodeValue.length).getClientRects():Nn(n)?n.getClientRects():[]}function Jc(n,e,t,i){return t?cS(n,e,t,i,-1)||cS(n,e,t,i,1):!1}function ss(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function dd(n){return Nn(n)&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function cS(n,e,t,i,l){for(;;){if(n==t&&e==i)return!0;if(e==(l<0?0:ol(n))){if(n.nodeName=="DIV")return!1;let o=n.parentNode;if(!o||!Nn(o))return!1;e=ss(n)+(l<0?0:1),n=o}else if(Nn(n)){if(n=n.childNodes[e+(l<0?-1:0)],Nn(n)&&(n.nodeName=="IMG"||n.nodeName=="BR"||n.contentEditable=="false"))return!1;e=l<0?ol(n):0}else return!1}}function ol(n){return Ca(n)?n.nodeValue.length:n.childNodes.length}function md(n,e){let{left:t,right:i}=n;if(t==i)return n;let l=e?t:i;return{left:l,right:l,top:n.top,bottom:n.bottom}}function oR(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function DO(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function aR(n,e,t,i,l,o,a,u){let f=n.ownerDocument,d=f.defaultView||window;for(let m=n,g=!1;m&&!g;)if(Nn(m)){let b,v=m==f.body,w=1,S=1,C=!0,N=!0;if(v)b=oR(d);else{let I=getComputedStyle(m);if(/^(fixed|sticky)$/.test(I.position)&&(g=!0),(m.scrollHeight<=m.clientHeight||!/auto|scroll/.test(I.overflowY))&&(N=!1),(m.scrollWidth<=m.clientWidth||!/auto|scroll/.test(I.overflowX))&&(C=!1),!C&&!N){m=m.assignedSlot||m.parentNode;continue}let U=m.getBoundingClientRect();({scaleX:w,scaleY:S}=DO(m,U)),b={left:U.left,right:U.left+m.clientWidth*w,top:U.top,bottom:U.top+m.clientHeight*S}}let j=0,D=0;if(N)if(l=="nearest")e.top0&&e.bottom>b.bottom+D&&(D=e.bottom-b.bottom+a)):e.bottom>b.bottom-a&&(D=e.bottom-b.bottom+a,t<0&&e.top-D0&&e.right>b.right+j&&(j=e.right-b.right+o)):e.right>b.right-o&&(j=e.right-b.right+o,t<0&&e.leftb.bottom||e.leftb.right)&&(e={left:Math.max(e.left,b.left),right:Math.min(e.right,b.right),top:Math.max(e.top,b.top),bottom:Math.min(e.bottom,b.bottom)}),m=m.assignedSlot||m.parentNode}else if(m.nodeType==11)m=m.host;else break}function RO(n,e=!0){let t=n.ownerDocument,i=null,l=null;for(let o=n.parentNode;o&&!(o==t.body||(!e||i)&&l);)if(Nn(o))!l&&o.scrollHeight>o.clientHeight&&/scroll|auto/.test(getComputedStyle(o).overflowY)&&(l=o),e&&!i&&o.scrollWidth>o.clientWidth&&/scroll|auto/.test(getComputedStyle(o).overflowX)&&(i=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:i,y:l}}class cR{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?ol(t):0),i,Math.min(e.focusOffset,i?ol(i):0))}set(e,t,i,l){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=l}}function jO(n){let e=[];for(let t=n;t;t=t.nodeType==11?t.host:t.parentNode)Nn(t)&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function _O(n,e=!0){for(let{node:t,left:i,top:l}of n)e&&t.scrollTop!=l&&(t.scrollTop=l),t.scrollLeft!=i&&(t.scrollLeft=i)}let Qs=null;ke.safari&&ke.safari_version>=26&&(Qs=!1);function LO(n){if(n.setActive)return n.setActive();if(Qs)return n.focus(Qs);let e=jO(n);n.focus(Qs==null?{get preventScroll(){return Qs={preventScroll:!0},!0}}:void 0),Qs||(Qs=!1,_O(e))}let uS;function du(n,e,t=e){let i=uS||(uS=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function ga(n,e,t,i){let l={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:l.altKey,ctrlKey:l.ctrlKey,shiftKey:l.shiftKey,metaKey:l.metaKey}=i);let o=new KeyboardEvent("keydown",l);o.synthetic=!0,n.dispatchEvent(o);let a=new KeyboardEvent("keyup",l);return a.synthetic=!0,n.dispatchEvent(a),o.defaultPrevented||a.defaultPrevented}function uR(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function fR(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,ol(t));;)if(i){if(!Nn(t))return!1;let l=t.childNodes[i-1];l.contentEditable=="false"?i--:(t=l,i=ol(t))}else{if(t==n)return!0;i=ss(t),t=t.parentNode}}function zO(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function BO(n,e){for(let t=n,i=e;;){if(Ca(t)&&i>0)return{node:t,offset:i};if(Nn(t)&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=ol(t)}else if(t.parentNode&&!dd(t))i=ss(t),t=t.parentNode;else return null}}function PO(n,e){for(let t=n,i=e;;){if(Ca(t)&&i=t){if(u.level==i)return a;(o<0||(l!=0?l<0?u.fromt:e[o].level>u.level))&&(o=a)}}if(o<0)throw new RangeError("Index out of range");return o}}function UO(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;S-=3)if(Sr[S+1]==-v){let C=Sr[S+2],N=C&2?l:C&4?C&1?o:l:0;N&&(Dt[g]=Dt[Sr[S]]=N),u=S;break}}else{if(Sr.length==189)break;Sr[u++]=g,Sr[u++]=b,Sr[u++]=f}else if((w=Dt[g])==2||w==1){let S=w==l;f=S?0:1;for(let C=u-3;C>=0;C-=3){let N=Sr[C+2];if(N&2)break;if(S)Sr[C+2]|=2;else{if(N&4)break;Sr[C+2]|=4}}}}}function xR(n,e,t,i){for(let l=0,o=i;l<=t.length;l++){let a=l?t[l-1].to:n,u=lf;)w==C&&(w=t[--S].from,C=S?t[S-1].to:n),Dt[--w]=v;f=m}else o=d,f++}}}function bx(n,e,t,i,l,o,a){let u=i%2?2:1;if(i%2==l%2)for(let f=e,d=0;ff&&a.push(new Rr(f,S.from,v));let C=S.direction==Oa!=!(v%2);vx(n,C?i+1:i,l,S.inner,S.from,S.to,a),f=S.to}w=S.to}else{if(w==t||(m?Dt[w]!=u:Dt[w]==u))break;w++}b?bx(n,f,w,i+1,l,b,a):fe;){let m=!0,g=!1;if(!d||f>o[d-1].to){let S=Dt[f-1];S!=u&&(m=!1,g=S==16)}let b=!m&&u==1?[]:null,v=m?i:i+1,w=f;e:for(;;)if(d&&w==o[d-1].to){if(g)break e;let S=o[--d];if(!m)for(let C=S.from,N=d;;){if(C==e)break e;if(N&&o[N-1].to==C)C=o[--N].from;else{if(Dt[C-1]==u)break e;break}}if(b)b.push(S);else{S.toDt.length;)Dt[Dt.length]=256;let i=[],l=e==Oa?0:1;return vx(n,l,l,t,0,n.length,i),i}function FO(n){return[new Rr(0,n,0)]}let qO="";function bR(n,e,t,i,l){var o;if(!n.length)return null;let a=i.head-n.from,u;if(i.head==n.from&&i.assoc<0){if(!l)return null;a=e[u=0].side(!1,t)}else if(i.head==n.to&&i.assoc>0){if(l)return null;a=e[u=e.length-1].side(!0,t)}else u=Rr.find(e,a,(o=i.bidiLevel)!==null&&o!==void 0?o:-1,i.assoc);let f=e[u],d=f.side(l,t);if(a==d){let b=u+=l?1:-1;if(b<0||b>=e.length)return null;f=e[u=b],a=f.side(!l,t),d=f.side(l,t)}let m=On(n.text,a,f.forward(l,t));(mf.to)&&(m=d),qO=n.text.slice(Math.min(a,m),Math.max(a,m));let g=u==(l?e.length-1:0)?null:e[u+(l?1:-1)];if(m==d){if(!g)return l?oe.cursor(n.to,1):oe.cursor(n.from,-1);if(g.level+(l?0:1)n.some(e=>e)}),WO=Ce.define({combine:n=>n.some(e=>e)}),ZO=Ce.define();class xa{constructor(e,t,i,l,o,a=!1){this.range=e,this.y=t,this.x=i,this.yMargin=l,this.xMargin=o,this.isSnapshot=a}map(e){return e.empty?this:new xa(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new xa(oe.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const xh=Ke.define({map:(n,e)=>n.map(e)}),JO=Ke.define();function pi(n,e,t){let i=n.facet($O);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const rl=Ce.define({combine:n=>n.length?n[0]:!0});let wR=0;const ca=Ce.define({combine(n){return n.filter((e,t)=>{for(let i=0;i{let f=[];return a&&f.push(Wd.of(d=>{let m=d.plugin(u);return m?a(m):Fe.none})),o&&f.push(o(u)),f})}static fromClass(e,t){return en.define((i,l)=>new e(i,l),t)}}class n0{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(pi(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){pi(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){pi(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const eN=Ce.define(),My=Ce.define(),Wd=Ce.define(),tN=Ce.define(),Dy=Ce.define(),Au=Ce.define(),nN=Ce.define();function fS(n,e){let t=n.state.facet(nN);if(!t.length)return t;let i=t.map(o=>o instanceof Function?o(n):o),l=[];return st.spans(i,e.from,e.to,{point(){},span(o,a,u,f){let d=o-e.from,m=a-e.from,g=l;for(let b=u.length-1;b>=0;b--,f--){let v=u[b].spec.bidiIsolate,w;if(f>0&&g.length&&(w=g[g.length-1]).to==d&&w.direction==v)w.to=m,g=w.inner;else{let S={from:d,to:m,direction:v,inner:[]};g.push(S),g=S.inner}}}}),iN(e.text,l)}function iN(n,e){for(let t of e){if(t.direction==null){for(let i=t.from,l=0;i0;t--){let l=e[t-1];if(!(l.fromA>i.toA)){if(l.toAl.push(new Fi(o,a,u,f))),this.changedRanges=l}static create(e,t,i){return new pd(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const kR=[];class Gt{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return kR}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&rR(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let l of this.children){if(l==e)return i;i+=l.length+l.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=ss(this.dom),l=this.length?e>0:t>0;return new nr(this.parent.dom,i+(l?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Jd)return e;return null}static get(e){return e.cmTile}}class Zd extends Gt{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,l,o=(e==null?void 0:e.node)==t?e:null,a=0;for(let u of this.children){if(u.sync(e),a+=u.length+u.breakAfter,l=i?i.nextSibling:t.firstChild,o&&l!=u.dom&&(o.written=!0),u.dom.parentNode==t)for(;l&&l!=u.dom;)l=hS(l);else t.insertBefore(u.dom,l);i=u.dom}for(l=i?i.nextSibling:t.firstChild,o&&l&&(o.written=!0);l;)l=hS(l);this.length=a}}function hS(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Jd extends Zd{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Gt.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,l=0,o=0;;)if(l==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&o++,l=t.pop()}else{let a=i.children[l++];if(a instanceof ll)t.push(l),i=a,l=0;else{let u=o+a.length,f=e(a,o);if(f!==void 0)return f;o=u+a.breakAfter}}}resolveBlock(e,t){let i,l=-1,o,a=-1;if(this.blockTiles((u,f)=>{let d=f+u.length;if(e>=f&&e<=d){if(u.isWidget()&&t>=-1&&t<=1){if(u.flags&32)return!0;u.flags&16&&(i=void 0)}(fe||e==f&&(t>1?u.length:u.covers(-1)))&&(!o||!u.isWidget()&&o.isWidget())&&(o=u,a=e-f)}}),!i&&!o)throw new Error("No tile at position "+e);return i&&t<0||!o?{tile:i,offset:l}:{tile:o,offset:a}}}class ll extends Zd{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new ll(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Na extends Zd{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let l=new Na(t||document.createElement("div"),e);return(!t||!i)&&(l.flags|=4),l}get domAttrs(){return this.attrs}resolveInline(e,t,i=!1){let l=null,o=-1,a=null,u=-1;function f(m,g){for(let b=0,v=0;b=g&&(w.isComposite()?f(w,g-v):(!a||i&&a.isHidden&&(t>0&&!(a.flags&32)||i&&CR(a,w)))&&(S>g||w.flags&32&&t<=1)?(a=w,u=g-v):(v=-1)&&(l=w,o=g-v)),v=S}}f(this,e);let d=(t<0?l:a)||l||a;return d?{tile:d,offset:d==l?o:u}:null}coordsIn(e,t,i){let l=this.resolveInline(e,t,!0);return l?l.tile.coordsIn(Math.max(0,l.offset),t,i):SR(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:l,offset:o}=i;if(this.dom.contains(l.dom))return l.isText()?new nr(l.dom,Math.min(l.dom.nodeValue.length,o)):l.domPosFor(o,l.flags&16?1:l.flags&32?-1:t);let a=i.tile.parent,u=!1;for(let f of a.children){if(u)return new nr(f.dom,0);f==i.tile&&(u=!0)}}return new nr(this.dom,0)}}function SR(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=Jh(e);return t[t.length-1]||null}function CR(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.topl&&(e=l);let o=e,a=e,u=0;e==0&&t<0||e==l&&t>=0?ke.chrome||ke.gecko||(e?(o--,u=1):a=0)?0:f.length-1];return ke.safari&&!u&&d.width==0&&(d=Array.prototype.find.call(f,m=>m.width)||d),i==null?d:md(d,(u?u>0:t<0)==i)}static of(e,t){let i=new Ks(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class lo extends Gt{constructor(e,t,i,l){super(e,t,l),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let l=this.widget.coordsAt(this.dom,e,t);if(l)return l;if(i)return md(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let o=this.dom.getClientRects(),a=null;if(!o.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?o.length-1:0;a=o[f],!(e>0?f==0:f==o.length-1||a.top0==i)}}class OR{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:l,index:o,beforeBreak:a,parents:u}=this;for(;e||t>0;)if(l.isComposite())if(a){if(!e)break;i&&i.break(),e--,a=!1}else if(o==l.children.length){if(!e&&!u.length)break;i&&i.leave(l),a=!!l.breakAfter,{tile:l,index:o}=u.pop(),o++}else{let f=l.children[o],d=f.breakAfter;(t>0?f.length<=e:f.length=0;u--){let f=t.marks[u],d=l.lastChild;if(d instanceof mi&&d.mark.eq(f.mark))d.dom!=f.dom&&d.setDOM(i0(f.dom)),l=d;else{let{dom:m}=f;this.cache.reused.get(f)&&Gt.get(f.dom)&&(m=i0(f.dom));let g=mi.of(f.mark,m);l.append(g),l=g}this.cache.reused.set(f,2)}let o=Gt.get(e.text);o&&this.cache.reused.set(o,2);let a=new Ks(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,l.append(a)}addInlineWidget(e,t,i){let l=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);l||this.flushBuffer();let o=this.ensureMarks(t,i);!l&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=lN);let l=Na.start(e,t||((i=this.cache.find(Na))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=l)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let l=this.curLine;for(let o=e.length-1;o>=0;o--){let a=e[o],u;if(t>0&&(u=l.lastChild)&&u instanceof mi&&u.mark.eq(a))l=u,t--;else{let f=mi.of(a,(i=this.cache.find(mi,d=>d.mark.eq(a)))===null||i===void 0?void 0:i.dom);l.append(f),l=f,t=0}}return l}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!dS(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(ke.ios&&dS(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(r0,0,32)||new lo(r0.toDOM(),0,r0,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let t=e.rank*102+e.value.rank,i=new NR(e.from,e.to,e.value,t),l=this.wrappers.length;for(;l>0&&(this.wrappers[l-1].rank-i.rank||this.wrappers[l-1].to-i.to)<0;)l--;this.wrappers.splice(l,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let l=t.lastChild;if(i.froma.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(o),t=o}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(gd,void 0,1);return i&&(i.flags=t),i||new gd(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class AR{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:l,lineBreak:o,done:a}=this.cursor.next(this.skipCount);if(this.skipCount=0,a)throw new Error("Ran out of text content when drawing inline views");this.text=l;let u=this.textOff=Math.min(e,l.length);return o?null:l.slice(0,u)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const xd=[lo,Na,Ks,mi,gd,ll,Jd];for(let n=0;n[]),this.index=xd.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let l=e.bucket,o=this.buckets[l],a=this.index[l];for(let u=0;u{if(this.cache.add(a),a.isComposite())return!1},enter:a=>this.cache.add(a),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let l=0,o=0,a=0;;){let u=al){let d=f-l;this.preserve(d,!a,!u),l=f,o+=d}if(!u)break;t&&u.fromA<=t.range.fromA&&u.toA>=t.range.toA?(this.forward(u.fromA,t.range.fromA,t.range.fromA{if(a.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let d=f>0||u{a.isLine()?this.builder.addLineStart(a.attrs,this.cache.maybeReuse(a)):(this.cache.add(a),a instanceof mi&&l.unshift(a.mark)),this.openWidget=!1},leave:a=>{a.isLine()?l.length&&(l.length=o=0):a instanceof mi&&(l.shift(),o=Math.min(o,l.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,l=this.builder,o=-1,a=st.spans(this.decorations,e,t,{point:(u,f,d,m,g,b)=>{if(d instanceof ro){if(this.disallowBlockEffectsFor[b]){if(d.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=m.length,g>m.length)l.continueWidget(f-u);else{let v=d.widget||(d.block?Ta.block:Ta.inline),w=DR(d),S=this.cache.findWidget(v,f-u,w)||lo.of(v,this.view,f-u,w);d.block?(d.startSide>0&&l.addLineStartIfNotCovered(i),l.addBlockWidget(S)):(l.ensureLine(i),l.addInlineWidget(S,m,g))}i=null}else i=RR(i,d);f>u&&this.text.skip(f-u)},span:(u,f,d,m)=>{for(let g=u;g-1&&(this.openWidget=a>o),this.openWidget||l.addLineStartIfNotCovered(i),this.openMarks=a}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let l=e.parentNode;;l=l.parentNode){let o=Gt.get(l);if(l==this.view.contentDOM)break;o instanceof mi?t.push(o):o!=null&&o.isLine()?i=o:o instanceof ll||(l.nodeName=="DIV"&&!i?i=new Na(l,lN):i||t.push(mi.of(new Nu({tagName:l.nodeName.toLowerCase(),attributes:lR(l)}),l)))}return i?{line:i,marks:t}:null}}function dS(n,e){let t=i=>{for(let l of i.children)if((e?l.isText():l.length)||t(l))return!0;return!1};return t(n)}function DR(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}const lN={class:"cm-line"};function RR(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&Oy(t,n),i&&(n.class+=" "+i)),n}function jR(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof mi&&e.push(i.mark)}return e}function i0(n){let e=Gt.get(n);return e&&e.setDOM(n.cloneNode()),n}class Ta extends fl{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Ta.inline=new Ta("span");Ta.block=new Ta("div");const r0=new class extends fl{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class mS{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Fe.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Jd(e,e.contentDOM),this.updateInner([new Fi(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:m,toA:g})=>gthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let l=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?l=this.domChanged.newSel.head:!FR(e.changes,this.hasComposition)&&!e.selectionSet&&(l=e.state.selection.main.head));let o=l>-1?LR(this.view,e.changes,l):null;if(this.domChanged=null,this.hasComposition){let{from:m,to:g}=this.hasComposition;i=new Fi(m,g,e.changes.mapPos(m,-1),e.changes.mapPos(g,1)).addToSet(i.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(ke.ie||ke.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,u=this.blockWrappers;this.updateDeco();let f=PR(a,this.decorations,e.changes);f.length&&(i=Fi.extendWithRanges(i,f));let d=IR(u,this.blockWrappers,e.changes);return d.length&&(i=Fi.extendWithRanges(i,d)),o&&!i.some(m=>m.fromA<=o.range.fromA&&m.toA>=o.range.toA)&&(i=o.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let a=this.tile,u=new MR(this.view,a,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Gt.get(t.text)&&u.cache.reused.set(Gt.get(t.text),2),this.tile=u.run(e,t),kx(a,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=ke.chrome||ke.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||i.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let l=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Zc(i,this.view.observer.selectionRange)&&!(l&&i.contains(l));if(!(o||t||a))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,d,m;if(f.empty?m=d=this.inlineDOMNearPos(f.anchor,f.assoc||1):(m=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),d=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),ke.gecko&&f.empty&&!this.hasComposition&&_R(d)){let b=document.createTextNode("");this.view.observer.ignore(()=>d.node.insertBefore(b,d.node.childNodes[d.offset]||null)),d=m=new nr(b,0),u=!0}let g=this.view.observer.selectionRange;(u||!g.focusNode||(!Jc(d.node,d.offset,g.anchorNode,g.anchorOffset)||!Jc(m.node,m.offset,g.focusNode,g.focusOffset))&&!this.suppressWidgetCursorChange(g,f))&&(this.view.observer.ignore(()=>{ke.android&&ke.chrome&&i.contains(g.focusNode)&&UR(g.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let b=hu(this.view.root);if(b)if(f.empty){if(ke.gecko){let v=zR(d.node,d.offset);if(v&&v!=3){let w=(v==1?BO:PO)(d.node,d.offset);w&&(d=new nr(w.node,w.offset))}}b.collapse(d.node,d.offset),f.bidiLevel!=null&&b.caretBidiLevel!==void 0&&(b.caretBidiLevel=f.bidiLevel)}else if(b.extend){b.collapse(d.node,d.offset);try{b.extend(m.node,m.offset)}catch{}}else{let v=document.createRange();f.anchor>f.head&&([d,m]=[m,d]),v.setEnd(m.node,m.offset),v.setStart(d.node,d.offset),b.removeAllRanges(),b.addRange(v)}a&&this.view.root.activeElement==i&&(i.blur(),l&&l.focus())}),this.view.observer.setSelectionRange(d,m)),this.impreciseAnchor=d.precise?null:new nr(g.anchorNode,g.anchorOffset),this.impreciseHead=m.precise?null:new nr(g.focusNode,g.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Jc(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=hu(e.root),{anchorNode:l,anchorOffset:o}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let u=a.posAtStart;if(t.head==u||t.head==u+a.length)return;let f=this.coordsAt(t.head,-1),d=this.coordsAt(t.head,1);if(!f||!d||f.bottom>d.top)return;let m=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(m.node,m.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let g=e.observer.selectionRange;e.docView.posFromDOM(g.anchorNode,g.anchorOffset)!=t.from&&i.collapse(l,o)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let l=i.posAtStart;if(i.isComposite()){let o;if(e==i.dom)o=i.dom.childNodes[t];else{let a=ol(e)==0?0:t==0?-1:1;for(;;){let u=e.parentNode;if(u==i.dom)break;a==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?a=-1:a=1),e=u}a<0?o=e:o=e.nextSibling}if(o==i.dom.firstChild)return l;for(;o&&!Gt.get(o);)o=o.nextSibling;if(!o)return l+i.length;for(let a=0,u=l;;a++){let f=i.children[a];if(f.dom==o)return u;u+=f.length+f.breakAfter}}else return i.isText()?e==i.dom?l+t:l+(t?i.length:0):l}domAtPos(e,t){let{tile:i,offset:l}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(l,t):i.domIn(l,t)}inlineDOMNearPos(e,t){let i,l=-1,o=!1,a,u=-1,f=!1;return this.tile.blockTiles((d,m)=>{if(d.isWidget()){if(d.flags&32&&m>=e)return!0;d.flags&16&&(o=!0)}else{let g=m+d.length;if(m<=e&&(i=d,l=e-m,o=g=e&&!a&&(a=d,u=e-m,f=m>e),m>e&&a)return!0}}),!i&&!a?this.domAtPos(e,t):(o&&a?i=null:f&&i&&(a=null),i&&t<0||!a?i.domIn(l,t):a.domIn(u,t))}coordsAt(e,t,i){let{tile:l,offset:o}=this.tile.resolveBlock(e,t);return l.isWidget()?l.widget instanceof l0?null:l.coordsInWidget(o,t,!0):l.coordsIn(o,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function l(o,a){if(o.isComposite())for(let u of o.children){if(u.length>=a){let f=l(u,a);if(f)return f}if(a-=u.length,a<0)break}else if(o.isText()&&aMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Tt.LTR,d=0,m=(g,b,v)=>{for(let w=0;wl);w++){let S=g.children[w],C=b+S.length,N=S.dom.getBoundingClientRect(),{height:j}=N;if(v&&!w&&(d+=N.top-v.top),S instanceof ll)C>i&&m(S,b,N);else if(b>=i&&(d>0&&t.push(-d),t.push(j+d),d=0,a)){let D=S.dom.lastChild,I=D?Jh(D):[];if(I.length){let U=I[I.length-1],E=f?U.right-N.left:N.right-U.left;E>u&&(u=E,this.minWidth=o,this.minWidthFrom=b,this.minWidthTo=C)}}v&&w==g.children.length-1&&(d+=v.bottom-N.bottom),b=C+S.breakAfter}};return m(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?Tt.RTL:Tt.LTR}measureTextSize(){let e=this.tile.blockTiles(a=>{if(a.isLine()&&a.children.length&&a.length<=20){let u=0,f;for(let d of a.children){if(!d.isText()||/[^ -~]/.test(d.text))return;let m=Jh(d.dom);if(m.length!=1)return;u+=m[0].width,f=m[0].height}if(u)return{lineHeight:a.dom.getBoundingClientRect().height,charWidth:u/a.length,textHeight:f}}});if(e)return e;let t=document.createElement("div"),i,l,o;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let a=Jh(t.firstChild)[0];i=t.getBoundingClientRect().height,l=a&&a.width?a.width/27:7,o=a&&a.height?a.height:i,t.remove()}),{lineHeight:i,charWidth:l,textHeight:o}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,l=0;;l++){let o=l==t.viewports.length?null:t.viewports[l],a=o?o.from-1:this.view.state.doc.length;if(a>i){let u=(t.lineBlockAt(a).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(Fe.replace({widget:new l0(u),block:!0,inclusive:!0,isBlockGap:!0}).range(i,a))}if(!o)break;i=o.to+1}return Fe.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Wd).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),i=!1,l=this.view.state.facet(Dy).map((o,a)=>{let u=typeof o=="function";return u&&(i=!0),u?o(this.view):o});for(l.length&&(this.dynamicDecorationMap[e++]=i,t.push(st.join(l))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof o=="function"?o(this.view):o)}scrollIntoView(e){if(e.isSnapshot){let d=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=d.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let d of this.view.state.facet(ZO))try{if(d(this.view,e.range,e))return!0}catch(m){pi(this.view.state,m,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),l;if(!i)return;!t.empty&&(l=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,l.left),top:Math.min(i.top,l.top),right:Math.max(i.right,l.right),bottom:Math.max(i.bottom,l.bottom)});let o=Ry(this.view),a={left:i.left-o.left,top:i.top-o.top,right:i.right+o.right,bottom:i.bottom+o.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(aR(this.view.scrollDOM,a,t.head1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottomi.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){kx(this.tile)}}function kx(n,e){let t=e==null?void 0:e.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)kx(i,e)}}function _R(n){return Nn(n.node)&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function sN(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=BO(t.focusNode,t.focusOffset),l=PO(t.focusNode,t.focusOffset),o=i||l;if(l&&i&&l.node!=i.node){let u=Gt.get(l.node);if(!u||u.isText()&&u.text!=l.node.nodeValue)o=l;else if(n.docView.lastCompositionAfterCursor){let f=Gt.get(i.node);!f||f.isText()&&f.text!=i.node.nodeValue||(o=l)}}if(n.docView.lastCompositionAfterCursor=o!=i,!o)return null;let a=e-o.offset;return{from:a,to:a+o.node.nodeValue.length,node:o.node}}function LR(n,e,t){let i=sN(n,t);if(!i)return null;let{node:l,from:o,to:a}=i,u=l.nodeValue;if(/[\n\r]/.test(u)||n.state.doc.sliceString(i.from,i.to)!=u)return null;let f=e.invertedDesc;return{range:new Fi(f.mapPos(o),f.mapPos(a),o,a),text:l}}function zR(n,e){return Nn(n)?(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}class l0 extends fl{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function qR(n,e,t=1){let i=n.charCategorizer(e),l=n.doc.lineAt(e),o=e-l.from;if(l.length==0)return oe.cursor(e);o==0?t=1:o==l.length&&(t=-1);let a=o,u=o;t<0?a=On(l.text,o,!1):u=On(l.text,o);let f=i(l.text.slice(a,u));for(;a>0;){let d=On(l.text,a,!1);if(i(l.text.slice(d,a))!=f)break;a=d}for(;un.defaultLineHeight*1.5){let u=n.viewState.heightOracle.textHeight,f=Math.floor((l-t.top-(n.defaultLineHeight-u)*.5)/u);o+=f*n.viewState.heightOracle.lineLength}let a=n.state.sliceDoc(t.from,t.to);return t.from+ux(a,o,n.state.tabSize)}function Sx(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let l;for(let o of i.type){if(o.from>e)break;if(!(o.toe)return o;(!l||o.type==Bn.Text&&(l.type!=o.type||(t<0?o.frome)))&&(l=o)}}return l||i}return i}function QR(n,e,t,i){let l=Sx(n,e.head,e.assoc||-1),o=!i||l.type!=Bn.Text||!(n.lineWrapping||l.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>l.from?e.head-1:e.head);if(o){let a=n.dom.getBoundingClientRect(),u=n.textDirectionAt(l.from),f=n.posAndSideAtCoords({x:t==(u==Tt.LTR)?a.right-1:a.left+1,y:(o.top+o.bottom)/2});if(f)return oe.cursor(f.pos,f.assoc)}return oe.cursor(t?l.to:l.from,t?1:-1)}function pS(n,e,t,i){let l=n.state.doc.lineAt(e.head),o=n.bidiSpans(l),a=n.textDirectionAt(l.from);for(let u=e,f=null;;){let d=bR(l,o,a,u,t),m=qO;if(!d){if(l.number==(t?n.state.doc.lines:1))return u;m=` +`,l=n.state.doc.line(l.number+(t?1:-1)),o=n.bidiSpans(l),d=t?oe.cursor(l.from,-1):oe.cursor(l.to,1)}if(f){if(!f(m))return u}else{if(!i)return d;f=i(m)}u=d}}function XR(n,e,t){let i=n.state.charCategorizer(e),l=i(t);return o=>{let a=i(o);return l==Ft.Space&&(l=a),l==a}}function $R(n,e,t,i){let l=e.head,o=t?1:-1;if(l==(t?n.state.doc.length:0))return oe.cursor(l,e.assoc);let a=e.goalColumn,u,f=n.contentDOM.getBoundingClientRect(),d=n.coordsAtPos(l,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),m=n.documentTop;if(d)a==null&&(a=d.left-f.left),u=o<0?d.top:d.bottom;else{let w=n.viewState.lineBlockAt(l);a==null&&(a=Math.min(f.right-f.left,n.defaultCharacterWidth*(l-w.from))),u=(o<0?w.top:w.bottom)+m}let g=f.left+a,b=n.viewState.heightOracle.textHeight>>1,v=i??b;for(let w=0;;w+=b){let S=u+(v+w)*o,C=Cx(n,{x:g,y:S},!1,o);if(t?S>f.bottom:Su:j{if(e>o&&el(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:oe.cursor(i,in.viewState.docHeight)return new Dr(n.state.doc.length,-1);if(d=n.elementAtHeight(f),i==null)break;if(d.type==Bn.Text){if(i<0?d.ton.viewport.to)break;let b=n.docView.coordsAt(i<0?d.from:d.to,i>0?-1:1);if(b&&(i<0?b.top<=f+o:b.bottom>=f+o))break}let g=n.viewState.heightOracle.textHeight/2;f=i>0?d.bottom+g:d.top-g}if(n.viewport.from>=d.to||n.viewport.to<=d.from){if(t)return null;if(d.type==Bn.Text){let g=VR(n,l,d,a,u);return new Dr(g,g==d.from?1:-1)}}if(d.type!=Bn.Text)return f<(d.top+d.bottom)/2?new Dr(d.from,1):new Dr(d.to,-1);let m=n.docView.lineAt(d.from,2);return(!m||m.length!=d.length)&&(m=n.docView.lineAt(d.from,-2)),new YR(n,a,u,n.textDirectionAt(d.from)).scanTile(m,d.from)}class YR{constructor(e,t,i,l){this.view=e,this.x=t,this.y=i,this.baseDir=l,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+l.from>1;t:if(a.has(S)){for(let j=1;j=o&&(D-=w),!a.has(D)){S=D;break t}}break e}a.add(S);let C=t(S),N=0;if(C)for(let j=0;j1))if(D.bottomthis.y)(!d||d.top>D.top)&&(d=D),N=-1;else{let I=D.left>this.x?this.x-D.left:D.right(w+w+S)/3)return this.y=f.bottom-1,this.scan(e,t,!0);if(d&&d.top<(w+S+S)/3)return this.y=d.top+1,this.scan(e,t,!0)}let v=(u?this.dirAt(e[m],1):this.baseDir)==Tt.LTR;return{i:m,after:this.x>(b.left+b.right)/2==v}}scanText(e,t){let i=[];for(let o=0;o{let a=i[o]-t,u=i[o+1]-t;return du(e.dom,a,u).getClientRects()});return l.after?new Dr(i[l.i+1],-1):new Dr(i[l.i],1)}scanTile(e,t){if(!e.length)return new Dr(t,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,t);if(u.isComposite())return this.scanTile(u,t)}let i=[t];for(let u=0,f=t;u{let f=e.children[u];return f.flags&48?null:(Nn(f.dom)?f.dom:du(f.dom,0,f.length)).getClientRects()}),o=e.children[l.i],a=i[l.i];return o.isText()?this.scanText(o,a):o.isComposite()?this.scanTile(o,a):l.after?new Dr(i[l.i+1],-1):new Dr(a,1)}}const na="￿";class GR{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(gt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=na}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let l=e;;){this.findPointBefore(i,l);let o=this.text.length;this.readNode(l);let a=Gt.get(l),u=l.nextSibling;if(u==t){a!=null&&a.breakAfter&&!u&&i!=this.view.contentDOM&&this.lineBreak();break}let f=Gt.get(u);(a&&f?a.breakAfter:(a?a.breakAfter:dd(l))||dd(u)&&(l.nodeName!="BR"||a!=null&&a.isWidget())&&this.text.length>o)&&!WR(u,t)&&this.lineBreak(),l=u}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,l=this.lineSeparator?null:/\r\n?|\n/g;;){let o=-1,a=1,u;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,i),a=this.lineSeparator.length):(u=l.exec(t))&&(o=u.index,a=u[0].length),this.append(t.slice(i,o<0?t.length:o)),o<0)break;if(this.lineBreak(),a>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=a-1);i=o+a}}readNode(e){let t=Gt.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let l=i.iter();!l.next().done;)l.lineBreak?this.lineBreak():this.append(l.value)}else Ca(e)?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():Nn(e)&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(Ca(e)?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(KR(e,i.node,i.offset)?t:0))}}function KR(n,e,t){for(;;){if(!e||t-1;let{impreciseHead:o,impreciseAnchor:a}=e.docView,u=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=aN(e.docView.tile,t,i,0))){let f=o||a?[]:ej(e),d=new GR(f,e);d.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=d.text,this.newSel=tj(f,this.bounds.from)}else{let f=e.observer.selectionRange,d=o&&o.node==f.focusNode&&o.offset==f.focusOffset||!xx(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),m=a&&a.node==f.anchorNode&&a.offset==f.anchorOffset||!xx(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),g=e.viewport;if((ke.ios||ke.chrome)&&d!=m&&Math.min(d,m)<=u.main.from&&Math.max(d,m)>=u.main.to&&(g.from>0||g.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(oe.range(m,d));else if(e.lineWrapping&&m==d&&!(u.main.empty&&u.main.head==d)&&e.inputState.lastTouchTime>Date.now()-100){let b=e.coordsAtPos(d,-1),v=0;b&&(v=e.inputState.lastTouchY<=b.bottom?-1:1),this.newSel=oe.create([oe.cursor(d,v)])}else this.newSel=oe.single(m,d)}}}function aN(n,e,t,i){if(n.isComposite()){let l=-1,o=-1,a=-1,u=-1;for(let f=0,d=i,m=i;ft)return aN(g,e,t,d);if(b>=e&&l==-1&&(l=f,o=d),d>t&&g.dom.parentNode==n.dom){a=f,u=m;break}m=b,d=b+g.breakAfter}return{from:o,to:u<0?i+n.length:u,startDOM:(l?n.children[l-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:a=0?n.children[a].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function cN(n,e){let t,{newSel:i}=e,{state:l}=n,o=l.selection.main,a=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,d=o.from,m=null;(a===8||ke.android&&e.text.length=u&&o.to<=f&&(e.typeOver||g!=e.text)&&g.slice(0,o.from-u)==e.text.slice(0,o.from-u)&&g.slice(o.to-u)==e.text.slice(b=e.text.length-(g.length-(o.to-u)))?t={from:o.from,to:o.to,insert:mt.of(e.text.slice(o.from-u,b).split(na))}:(v=uN(g,e.text,d-u,m))&&(ke.chrome&&a==13&&v.toB==v.from+2&&e.text.slice(v.from,v.toB)==na+na&&v.toB--,t={from:u+v.from,to:u+v.toA,insert:mt.of(e.text.slice(v.from,v.toB).split(na))})}else i&&(!n.hasFocus&&l.facet(rl)||Ox(i,o))&&(i=null);if(!t&&!i)return!1;if((ke.mac||ke.android)&&t&&t.from==t.to&&t.from==o.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=oe.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:mt.of([t.insert.toString().replace("."," ")])}):l.doc.lineAt(o.from).toDate.now()-50?t={from:o.from,to:o.to,insert:l.toText(n.inputState.insertingText)}:ke.chrome&&t&&t.from==t.to&&t.from==o.head&&t.insert.toString()==` + `&&n.lineWrapping&&(i&&(i=oe.single(i.main.anchor-1,i.main.head-1)),t={from:o.from,to:o.to,insert:mt.of([" "])}),t)return jy(n,t,i,a);if(i&&!Ox(i,o)){let u=!1,f="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(u=!0),f=n.inputState.lastSelectionOrigin,f=="select.pointer"&&(i=oN(l.facet(Au).map(d=>d(n)),i))),n.dispatch({selection:i,scrollIntoView:u,userEvent:f}),!0}else return!1}function jy(n,e,t,i=-1){if(ke.ios&&n.inputState.flushIOSKey(e))return!0;let l=n.state.selection.main;if(ke.android&&(e.to==l.to&&(e.from==l.from||e.from==l.from-1&&n.state.sliceDoc(e.from,l.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ga(n.contentDOM,"Enter",13)||(e.from==l.from-1&&e.to==l.to&&e.insert.length==0||i==8&&e.insert.lengthl.head)&&ga(n.contentDOM,"Backspace",8)||e.from==l.from&&e.to==l.to+1&&e.insert.length==0&&ga(n.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let a,u=()=>a||(a=JR(n,e,t));return n.state.facet(YO).some(f=>f(n,e.from,e.to,o,u))||n.dispatch(u()),!0}function JR(n,e,t){let i,l=n.state,o=l.selection.main,a=-1;if(e.from==e.to&&e.fromo.to){let f=e.fromg(n)),d,f);e.from==m&&(a=m)}if(a>-1)i={changes:e,selection:oe.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let f=o.frome.to?l.sliceDoc(e.to,o.to):"";i=l.replaceSelection(n.state.toText(f+e.insert.sliceString(0,void 0,n.state.lineBreak)+d))}else{let f=l.changes(e),d=t&&t.main.to<=f.newLength?t.main:void 0;if(l.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let m=n.state.sliceDoc(e.from,e.to),g,b=t&&sN(n,t.main.head);if(b){let w=e.insert.length-(e.to-e.from);g={from:b.from,to:b.to-w}}else g=n.state.doc.lineAt(o.head);let v=o.to-e.to;i=l.changeByRange(w=>{if(w.from==o.from&&w.to==o.to)return{changes:f,range:d||w.map(f)};let S=w.to-v,C=S-m.length;if(n.state.sliceDoc(C,S)!=m||S>=g.from&&C<=g.to)return{range:w};let N=l.changes({from:C,to:S,insert:e.insert}),j=w.to-o.to;return{changes:N,range:d?oe.range(Math.max(0,d.anchor+j),Math.max(0,d.head+j)):w.map(N)}})}else i={changes:f,selection:d&&l.selection.replaceRange(d)}}let u="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,u+=".compose",n.inputState.compositionFirstChange&&(u+=".start",n.inputState.compositionFirstChange=!1)),l.update(i,{userEvent:u,scrollIntoView:!0})}function uN(n,e,t,i){let l=Math.min(n.length,e.length),o=0;for(;o0&&u>0&&n.charCodeAt(a-1)==e.charCodeAt(u-1);)a--,u--;if(i=="end"){let f=Math.max(0,o-Math.min(a,u));t-=a+f-o}if(a=a?o-t:0;o-=f,u=o+(u-a),a=o}else if(u=u?o-t:0;o-=f,a=o+(a-u),u=o}return{from:o,toA:a,toB:u}}function ej(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:l,focusOffset:o}=n.observer.selectionRange;return t&&(e.push(new gS(t,i)),(l!=t||o!=i)&&e.push(new gS(l,o))),e}function tj(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t<0||i<0?null:t==i?oe.create([oe.cursor(i+e,-1)]):oe.single(t+e,i+e)}function Ox(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}class nj{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,ke.safari&&e.contentDOM.addEventListener("input",()=>null),ke.gecko&&yj(e.contentDOM.ownerDocument)}handleEvent(e){!fj(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let l of i.observers)l(this.view,t);for(let l of i.handlers){if(t.defaultPrevented)break;if(l(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=rj(e),i=this.handlers,l=this.view.contentDOM;for(let o in t)if(o!="scroll"){let a=!t[o].handlers.length,u=i[o];u&&a!=!u.handlers.length&&(l.removeEventListener(o,this.handleEvent),u=null),u||l.addEventListener(o,this.handleEvent,{passive:a})}for(let o in i)o!="scroll"&&!t[o]&&l.removeEventListener(o,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&hN.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),ke.android&&ke.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(ke.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(fN.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||lj.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&ke.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&ij(this.view.win)&&(t.shiftKey=!1);let i=this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t};return setTimeout(()=>{this.pendingIOSKey==i&&this.flushIOSKey()},50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key=="Enter"&&e&&e.from0?!0:ke.safari&&!ke.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function ij(n){return n.visualViewport?n.visualViewport.height*n.visualViewport.scale/n.document.documentElement.clientHeight<.85:!1}function xS(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(l){pi(t.state,l)}}}function rj(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let l=i.spec,o=l&&l.plugin.domEventHandlers,a=l&&l.plugin.domEventObservers;if(o)for(let u in o){let f=o[u];f&&t(u).handlers.push(xS(i.value,f))}if(a)for(let u in a){let f=a[u];f&&t(u).observers.push(xS(i.value,f))}}for(let i in sr)t(i).handlers.push(sr[i]);for(let i in ei)t(i).observers.push(ei[i]);return e}const fN=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],lj="dthko",hN=[16,17,18,20,91,92,224,225],yh=6;function bh(n){return Math.max(0,n)*.7+8}function sj(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class oj{constructor(e,t,i,l){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=l,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=RO(e.contentDOM),this.atoms=e.state.facet(Au).map(a=>a(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(gt.allowMultipleSelections)&&aj(e,t),this.dragging=uj(e,t)&&pN(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&sj(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,l=0,o=0,a=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:l,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Ry(this.view);e.clientX-f.left<=l+yh?t=-bh(l-e.clientX):e.clientX+f.right>=a-yh&&(t=bh(e.clientX-a)),e.clientY-f.top<=o+yh?i=-bh(o-e.clientY):e.clientY+f.bottom>=u-yh&&(i=bh(e.clientY-u)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=oN(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function aj(n,e){let t=n.state.facet(VO);return t.length?t[0](e):ke.mac?e.metaKey:e.ctrlKey}function cj(n,e){let t=n.state.facet(QO);return t.length?t[0](e):ke.mac?!e.altKey:!e.ctrlKey}function uj(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=hu(n.root);if(!i||i.rangeCount==0)return!0;let l=i.getRangeAt(0).getClientRects();for(let o=0;o=e.clientX&&a.top<=e.clientY&&a.bottom>=e.clientY)return!0}return!1}function fj(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=Gt.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const sr=Object.create(null),ei=Object.create(null),dN=ke.ie&&ke.ie_version<15||ke.ios&&ke.webkit_version<604;function hj(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),mN(n,t.value)},50)}function em(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function mN(n,e){e=em(n.state,Ay,e);let{state:t}=n,i,l=1,o=t.toText(e),a=o.lines==t.selection.ranges.length;if(Nx!=null&&t.selection.ranges.every(f=>f.empty)&&Nx==o.toString()){let f=-1;i=t.changeByRange(d=>{let m=t.doc.lineAt(d.from);if(m.from==f)return{range:d};f=m.from;let g=t.toText((a?o.line(l++).text:e)+t.lineBreak);return{changes:{from:m.from,insert:g},range:oe.cursor(d.from+g.length,-1)}})}else a?i=t.changeByRange(f=>{let d=o.line(l++);return{changes:{from:f.from,to:f.to,insert:d.text},range:oe.cursor(f.from+d.length,-1)}}):i=t.replaceSelection(o);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}ei.scroll=n=>{let e=n.inputState;e.lastScrollTop=n.scrollDOM.scrollTop,e.lastScrollLeft=n.scrollDOM.scrollLeft,ke.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};ei.wheel=ei.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};sr.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);ei.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};ei.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};ei.touchend=(n,e)=>{n.inputState.touchActive=!1};sr.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(XO))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=mj(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new oj(n,e,t,i)),i&&n.observer.ignore(()=>{LO(n.contentDOM);let o=n.root.activeElement;o&&!o.contains(n.contentDOM)&&o.blur()});let l=n.inputState.mouseSelection;if(l)return l.start(e),l.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function yS(n,e,t,i){if(i==1)return oe.cursor(e,t);if(i==2)return qR(n.state,e,t);{let l=n.docView.lineAt(e,t),o=n.state.doc.lineAt(l?l.posAtEnd:e),a=l?l.posAtStart:o.from,u=l?l.posAtEnd:o.to;return uDate.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(vS+1)%3:1}function mj(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=pN(e),l=n.state.selection;return{update(o){o.docChanged&&(t.pos=o.changes.mapPos(t.pos),l=l.map(o.changes))},get(o,a,u){let f=n.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),d,m=yS(n,f.pos,f.assoc,i);if(t.pos!=f.pos&&!a){let g=yS(n,t.pos,t.assoc,i),b=Math.min(g.from,m.from),v=Math.max(g.to,m.to);m=b1&&(d=pj(l,f.pos))?d:u?l.addRange(m):oe.create([m])}}}function pj(n,e){for(let t=0;t=e)return oe.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}sr.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let l=n.docView.tile.nearest(e.target);if(l&&l.isWidget()){let o=l.posAtStart,a=o+l.length;(o>=t.to||a<=t.from)&&(t=oe.undirectionalRange(o,a))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",em(n.state,Ey,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};sr.dragend=n=>(n.inputState.draggedContent=null,!1);function kS(n,e,t,i){if(t=em(n.state,Ay,t),!t)return;let l=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=n.inputState,a=i&&o&&cj(n,e)?{from:o.from,to:o.to}:null,u={from:l,insert:t},f=n.state.changes(a?[a,u]:u);n.focus(),n.dispatch({changes:f,selection:{anchor:f.mapPos(l,-1),head:f.mapPos(l,1)},userEvent:a?"move.drop":"input.drop"}),n.inputState.draggedContent=null}sr.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),l=0,o=()=>{++l==t.length&&kS(n,e,i.filter(a=>a!=null).join(n.state.lineBreak),!1)};for(let a=0;a{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(i[a]=u.result),o()},u.readAsText(t[a])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return kS(n,e,i,!0),!0}return!1};sr.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=dN?null:e.clipboardData;return t?(mN(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(hj(n),!1)};function gj(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function xj(n){let e=[],t=[],i=!1;for(let l of n.selection.ranges)l.empty||(e.push(n.sliceDoc(l.from,l.to)),t.push(l));if(!e.length){let l=-1;for(let{from:o}of n.selection.ranges){let a=n.doc.lineAt(o);a.number>l&&(e.push(a.text),t.push({from:a.from,to:Math.min(n.doc.length,a.to+1)})),l=a.number}i=!0}return{text:em(n,Ey,e.join(n.lineBreak)),ranges:t,linewise:i}}let Nx=null;sr.copy=sr.cut=(n,e)=>{if(!Zc(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:l}=xj(n.state);if(!t&&!l)return!1;Nx=l?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let o=dN?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",t),!0):(gj(n,t),!1)};const gN=ul.define();function xN(n,e){let t=[];for(let i of n.facet(GO)){let l=i(n,e);l&&t.push(l)}return t.length?n.update({effects:t,annotations:gN.of(!0)}):null}function yN(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=xN(n.state,e);t?n.dispatch(t):n.update([])}},10)}ei.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),yN(n)};ei.blur=n=>{n.observer.clearSelectionRange(),yN(n)};ei.compositionstart=ei.compositionupdate=(n,e)=>{if(!n.observer.editContext&&(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0)){let{main:t}=n.state.selection;!t.empty&&n.lineBlockAt(t.from).from!=n.lineBlockAt(t.to).from&&!n.state.readOnly&&n.dispatch({changes:n.state.selection.ranges.filter(i=>!i.empty).map(i=>({from:i.from,to:i.to})),userEvent:"input"}),n.inputState.composing=0}};ei.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,ke.chrome&&ke.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};ei.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};sr.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let o=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),a=e.getTargetRanges();if(o&&a.length){let u=a[0],f=n.posAtDOM(u.startContainer,u.startOffset),d=n.posAtDOM(u.endContainer,u.endOffset);return jy(n,{from:f,to:d,insert:n.state.toText(o)},null),!0}}let l;if(ke.chrome&&ke.android&&(l=fN.find(o=>o.inputType==e.inputType))&&(n.observer.delayAndroidKey(l.key,l.keyCode),l.key=="Backspace"||l.key=="Delete")){let o=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var a;(((a=window.visualViewport)===null||a===void 0?void 0:a.height)||0)>o+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return ke.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),ke.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>ei.compositionend(n,e),20),!1};const SS=new Set;function yj(n){SS.has(n)||(SS.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const CS=["pre-wrap","normal","pre-line","break-spaces"];let Aa=!1;function OS(){Aa=!1}class bj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return CS.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,f=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=t,this.charWidth=i,this.textHeight=l,this.lineLength=o,f){this.heightSamples={};for(let d=0;d0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>ed&&(Aa=!0),this.height=e)}replace(e,t,i){return Jn.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,l){let o=this,a=i.doc;for(let u=l.length-1;u>=0;u--){let{fromA:f,toA:d,fromB:m,toB:g}=l[u],b=o.lineAt(f,Lt.ByPosNoHeight,i.setDoc(t),0,0),v=b.to>=d?b:o.lineAt(d,Lt.ByPosNoHeight,i,0,0);for(g+=v.to-d,d=v.to;u>0&&b.from<=l[u-1].toA;)f=l[u-1].fromA,m=l[u-1].fromB,u--,fo*2){let u=e[t-1];u.break?e.splice(--t,1,u.left,null,u.right):e.splice(--t,1,u.left,u.right),i+=1+u.break,l-=u.size}else if(o>l*2){let u=e[i];u.break?e.splice(i,1,u.left,null,u.right):e.splice(i,1,u.left,u.right),i+=2+u.break,o-=u.size}else break;else if(l=o&&a(this.lineAt(0,Lt.ByPos,i,l,o))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,l){return l&&l.from<=t&&l.more&&this.setMeasuredHeight(l),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Mi extends bN{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new tr(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let l=i[0];return i.length==1&&(l instanceof Mi||l instanceof jn&&l.flags&4)&&Math.abs(this.length-l.length)<10?(l instanceof jn?l=new Mi(l.length,this.height,this.spaceAbove):l.height=this.height,this.outdated||(l.outdated=!1),l):Jn.of(i)}updateHeight(e,t=0,i=!1,l){return l&&l.from<=t&&l.more?this.setMeasuredHeight(l):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class jn extends Jn{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,l=e.doc.lineAt(t+this.length).number,o=l-i+1,a,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*o);a=f/o,this.length>o+1&&(u=(this.height-f)/(this.length-o-1))}else a=this.height/o;return{firstLine:i,lastLine:l,perLine:a,perChar:u}}blockAt(e,t,i,l){let{firstLine:o,lastLine:a,perLine:u,perChar:f}=this.heightMetrics(t,l);if(t.lineWrapping){let d=l+(e0){let o=i[i.length-1];o instanceof jn?i[i.length-1]=new jn(o.length+l):i.push(null,new jn(l-1))}if(e>0){let o=i[0];o instanceof jn?i[0]=new jn(e+o.length):i.unshift(new jn(e-1),null)}return Jn.of(i)}decomposeLeft(e,t){t.push(new jn(e-1),null)}decomposeRight(e,t){t.push(null,new jn(this.length-e-1))}updateHeight(e,t=0,i=!1,l){let o=t+this.length;if(l&&l.from<=t+this.length&&l.more){let a=[],u=Math.max(t,l.from),f=-1;for(l.from>t&&a.push(new jn(l.from-t-1).updateHeight(e,t));u<=o&&l.more;){let m=e.doc.lineAt(u).length;a.length&&a.push(null);let g=l.heights[l.index++],b=0;g<0&&(b=-g,g=l.heights[l.index++]),f==-1?f=g:Math.abs(g-f)>=ed&&(f=-2);let v=new Mi(m,g,b);v.outdated=!1,a.push(v),u+=m+1}u<=o&&a.push(null,new jn(o-u).updateHeight(e,u));let d=Jn.of(a);return(f<0||Math.abs(d.height-this.height)>=ed||Math.abs(f-this.heightMetrics(e,t).perLine)>=ed)&&(Aa=!0),yd(this,d)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class kj extends Jn{constructor(e,t,i){super(e.length+(t?1:0)+i.length,e.height+i.height,(t?1:0)|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,l){let o=i+this.left.height;return eu))return d;let m=t==Lt.ByPosNoHeight?Lt.ByPosNoHeight:Lt.ByPos;return f?d.join(this.right.lineAt(u,m,i,a,u)):this.left.lineAt(u,m,i,l,o).join(d)}forEachLine(e,t,i,l,o,a){let u=l+this.left.height,f=o+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,t,i,u,f,a);else{let d=this.lineAt(f,Lt.ByPos,i,l,o);e=e&&d.from<=t&&a(d),t>d.to&&this.right.forEachLine(Math.max(e,d.to+1),t,i,u,f,a)}}replace(e,t,i){let l=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-l,t-l,i));let o=[];e>0&&this.decomposeLeft(e,o);let a=o.length;for(let u of i)o.push(u);if(e>0&&NS(o,a-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,l=i+this.break;if(e>=l)return this.right.decomposeRight(e-l,t);e2*t.size||t.size>2*e.size?Jn.of(this.break?[e,null,t]:[e,t]):(this.left=yd(this.left,e),this.right=yd(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,l){let{left:o,right:a}=this,u=t+o.length+this.break,f=null;return l&&l.from<=t+o.length&&l.more?f=o=o.updateHeight(e,t,i,l):o.updateHeight(e,t,i),l&&l.from<=u+a.length&&l.more?f=a=a.updateHeight(e,u,i,l):a.updateHeight(e,u,i),f?this.balanced(o,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function NS(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof jn&&(i=n[e+1])instanceof jn&&n.splice(e-1,3,new jn(t.length+1+i.length))}const Sj=5;class _y{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),l=this.nodes[this.nodes.length-1];l instanceof Mi?l.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Mi(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=Sj)&&this.addLineDeco(l,o,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new Mi(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new jn(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Mi)return e;let t=new Mi(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let l=this.ensureLine();l.length+=i,l.collapsed+=i,l.widgetHeight=Math.max(l.widgetHeight,e),l.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Mi)&&!this.isCovered?this.nodes.push(new Mi(0,-1,0)):(this.writtenTod.clientHeight||d.scrollWidth>d.clientWidth)&&m.overflow!="visible"){let g=d.getBoundingClientRect();o=Math.max(o,g.left),a=Math.min(a,g.right),u=Math.max(u,g.top),f=Math.min(d==n.parentNode?l.innerHeight:f,g.bottom)}d=m.position=="absolute"||m.position=="fixed"?d.offsetParent:d.parentNode}else if(d.nodeType==11)d=d.host;else break;return{left:o-t.left,right:Math.max(o,a)-t.left,top:u-(t.top+e),bottom:Math.max(u,f)-(t.top+e)}}function Tj(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function Aj(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class o0{constructor(e,t,i,l){this.from=e,this.to=t,this.size=i,this.displaySize=l}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof l!="function"&&l.class=="cm-lineWrapping");this.heightOracle=new bj(i),this.stateDeco=AS(t),this.heightMap=Jn.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(t.doc),[new Fi(0,0,0,t.doc.length)]);for(let l=0;l<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());l++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Fe.set(this.lineGaps.map(l=>l.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let l=i?t.head:t.anchor;if(!e.some(({from:o,to:a})=>l>=o&&l<=a)){let{from:o,to:a}=this.lineBlockAt(l);e.push(new vh(o,a))}}return this.viewports=e.sort((i,l)=>i.from-l.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Tx:bd.get(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push($c(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=AS(this.state);let l=e.changedRanges,o=Fi.extendWithRanges(l,Cj(i,this.stateDeco,e?e.changes:mn.empty(this.state.doc.length))),a=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);OS(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=a||Aa)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let f=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,t));let d=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(d||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(WO)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),l=this.heightOracle,o=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?Tt.RTL:Tt.LTR;let a=this.heightOracle.mustRefreshForWrapping(o)||this.mustMeasureContent==="refresh",u=t.getBoundingClientRect(),f=a||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let d=0,m=0;if(u.width&&u.height){let{scaleX:U,scaleY:E}=DO(t,u);(U>.005&&Math.abs(this.scaleX-U)>.005||E>.005&&Math.abs(this.scaleY-E)>.005)&&(this.scaleX=U,this.scaleY=E,d|=16,a=f=!0)}let g=(parseInt(i.paddingTop)||0)*this.scaleY,b=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=g||this.paddingBottom!=b)&&(this.paddingTop=g,this.paddingBottom=b,d|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(l.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,d|=16);let v=RO(this.view.contentDOM,!1).y;v!=this.scrollParent&&(this.scrollParent=v,this.scrollAnchorHeight=-1,this.scrollOffset=0);let w=this.getScrollOffset();this.scrollOffset!=w&&(this.scrollAnchorHeight=-1,this.scrollOffset=w),this.scrolledToBottom=zO(this.scrollParent||e.win);let S=(this.printing?Aj:Nj)(t,this.paddingTop),C=S.top-this.pixelViewport.top,N=S.bottom-this.pixelViewport.bottom;this.pixelViewport=S;let j=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(j!=this.inView&&(this.inView=j,j&&(f=!0)),!this.inView&&!this.scrollTarget&&!Tj(e.dom))return 0;let D=u.width;if((this.contentDOMWidth!=D||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,d|=16),f){let U=e.docView.measureVisibleLineHeights(this.viewport);if(l.mustRefreshForHeights(U)&&(a=!0),a||l.lineWrapping&&Math.abs(D-this.contentDOMWidth)>l.charWidth){let{lineHeight:E,charWidth:T,textHeight:z}=e.docView.measureTextSize();a=E>0&&l.refresh(o,E,T,z,Math.max(5,D/T),U),a&&(e.docView.minWidth=0,d|=16)}C>0&&N>0?m=Math.max(C,N):C<0&&N<0&&(m=Math.min(C,N)),OS();for(let E of this.viewports){let T=E.from==this.viewport.from?U:e.docView.measureVisibleLineHeights(E);this.heightMap=(a?Jn.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new Fi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(l,0,a,new vj(E.from,T))}Aa&&(d|=2)}let I=!this.viewportIsAppropriate(this.viewport,m)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return I&&(d&2&&(d|=this.updateScaler()),this.viewport=this.getViewport(m,this.scrollTarget),d|=this.updateForViewport()),(d&2||I)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),d|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),d}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),l=this.heightMap,o=this.heightOracle,{visibleTop:a,visibleBottom:u}=this,f=new vh(l.lineAt(a-i*1e3,Lt.ByHeight,o,0,0).from,l.lineAt(u+(1-i)*1e3,Lt.ByHeight,o,0,0).to);if(t){let{head:d}=t.range;if(df.to){let m=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),g=l.lineAt(d,Lt.ByPos,o,0,0),b;t.y=="center"?b=(g.top+g.bottom)/2-m/2:t.y=="start"||t.y=="nearest"&&d=u+Math.max(10,Math.min(i,250)))&&l>a-2*1e3&&o>1,a=l<<1;if(this.defaultTextDirection!=Tt.LTR&&!i)return[];let u=[],f=(m,g,b,v)=>{if(g-mm&&NN.from>=b.from&&N.to<=b.to&&Math.abs(N.from-m)N.fromj));if(!C){if(gD.from<=g&&D.to>=g)){let D=t.moveToLineBoundary(oe.cursor(g),!1,!0).head;D>m&&(g=D)}let N=this.gapSize(b,m,g,v),j=i||N<2e6?N:2e6;C=new o0(m,g,N,j)}u.push(C)},d=m=>{if(m.length2e6)for(let E of e)E.from>=m.from&&E.fromm.from&&f(m.from,v,m,g),wt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];st.spans(t,this.viewport.from,this.viewport.to,{span(o,a){i.push({from:o,to:a})},point(){}},20);let l=0;if(i.length!=this.visibleRanges.length)l=12;else for(let o=0;o=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||$c(this.heightMap.lineAt(e,Lt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||$c(this.heightMap.lineAt(this.scaler.fromDOM(e),Lt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+12-this.paddingTop);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return $c(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class vh{constructor(e,t){this.from=e,this.to=t}}function Mj(n,e,t){let i=[],l=n,o=0;return st.spans(t,n,e,{span(){},point(a,u){a>l&&(i.push({from:l,to:a}),o+=a-l),l=u}},20),l=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let l=0;;l++){let{from:o,to:a}=e[l],u=a-o;if(i<=u)return o+i;i-=u}}function kh(n,e){let t=0;for(let{from:i,to:l}of n.ranges){if(e<=l){t+=e-i;break}t+=l-i}return t/n.total}function Dj(n,e){for(let t of n)if(e(t))return t}const Tx={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function AS(n){let e=n.facet(Wd).filter(i=>typeof i!="function"),t=n.facet(Dy).filter(i=>typeof i!="function");return t.length&&e.push(st.join(t)),e}class bd{constructor(e,t){this.scale=e,this.viewports=t}static get(e,t,i){let l=0,o=0,a=0,u=i.map(({from:d,to:m})=>{let g=t.lineAt(d,Lt.ByPos,e,0,0).top,b=t.lineAt(m,Lt.ByPos,e,0,0).bottom;return l+=b-g,{from:d,to:m,top:g,bottom:b,domTop:0,domBottom:0}});if(t.height-l<10)return Tx;let f=(7e6-l)/(t.height-l);for(let d of u)d.domTop=a+(d.top-o)*f,a=d.domBottom=d.domTop+(d.bottom-d.top),o=d.bottom;return new bd(f,u)}toDOM(e){for(let t=0,i=0,l=0;;t++){let o=tt.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function $c(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new tr(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(l=>$c(l,e)):n._content)}const Sh=Ce.define({combine:n=>n.join(" ")}),Ax=Ce.define({combine:n=>n.indexOf(!0)>-1}),Ex=rs.newName(),vN=rs.newName(),wN=rs.newName(),kN={"&light":"."+vN,"&dark":"."+wN};function Mx(n,e,t){return new rs(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,l=>{if(l=="&")return n;if(!t||!t[l])throw new RangeError(`Unsupported selector: ${l}`);return t[l]}):n+" "+i}})}const Rj=Mx("."+Ex,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"baseline",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},kN),jj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},a0=ke.ie&&ke.ie_version<=11;class _j{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new cR,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(ke.ie&&ke.ie_version<=11||ke.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&ke.android&&e.constructor.EDIT_CONTEXT!==!1&&!(ke.chrome&&ke.chrome_version<126)&&(this.editContext=new zj(e),e.state.facet(rl)&&(e.contentDOM.editContext=this.editContext.editContext)),a0&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(this.pendingRecords().length>0),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,l=this.selectionRange;if(i.state.facet(rl)?i.root.activeElement!=this.dom:!Zc(this.dom,l))return;let o=l.anchorNode&&i.docView.tile.nearest(l.anchorNode);if(o&&o.isWidget()&&o.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(ke.ie&&ke.ie_version<=11||ke.android&&ke.chrome)&&!i.state.selection.main.empty&&l.focusNode&&Jc(l.focusNode,l.focusOffset,l.anchorNode,l.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=hu(e.root);if(!t)return!1;let i=ke.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Lj(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let l=Zc(this.dom,i);return l&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&ga(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(l)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,l=!1;for(let o of e){let a=this.readMutation(o);a&&(a.typeOver&&(l=!0),t==-1?{from:t,to:i}=a:(t=Math.min(a.from,t),i=Math.max(a.to,i)))}return{from:t,to:i,typeOver:l}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),l=this.selectionChanged&&Zc(this.dom,this.selectionRange);if(e<0&&!l)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new ZR(this.view,e,t,i);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.selectionChanged,i=this.readChange();if(!i)return this.view.requestMeasure(),!1;let l=this.view.state,o=cN(this.view,i);return this.view.state==l&&(i.domChanged||t)&&this.view.update([]),o}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=ES(t,e.previousSibling||e.target.previousSibling,-1),l=ES(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:l?t.posBefore(l):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(rl)!=e.state.facet(rl)&&(e.view.contentDOM.editContext=e.state.facet(rl)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let l of this.scrollTargets)l.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function ES(n,e,t){for(;e;){let i=Gt.get(e);if(i&&i.parent==n)return i;let l=e.parentNode;e=l!=n.dom?l:t>0?e.nextSibling:e.previousSibling}return null}function MS(n,e){let t=e.startContainer,i=e.startOffset,l=e.endContainer,o=e.endOffset,a=n.docView.domAtPos(n.state.selection.main.anchor,1);return Jc(a.node,a.offset,l,o)&&([t,i,l,o]=[l,o,t,i]),{anchorNode:t,anchorOffset:i,focusNode:l,focusOffset:o}}function Lj(n,e){if(e.getComposedRanges){let l=e.getComposedRanges(n.root)[0];if(l)return MS(n,l)}let t=null;function i(l){l.preventDefault(),l.stopImmediatePropagation(),t=l.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?MS(n,t):null}class zj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let l=e.state.selection.main,{anchor:o,head:a}=l,u=this.toEditorPos(i.updateRangeStart),f=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:u,drifted:!1});let d=f-u>i.text.length;u==this.from&&othis.to&&(f=o);let m=uN(e.state.sliceDoc(u,f),i.text,(d?l.from:l.to)-u,d?"end":null);if(!m){let b=oe.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Ox(b,l)||e.dispatch({selection:b,userEvent:"select"});return}let g={from:m.from+u,to:m.toA+u,insert:mt.of(i.text.slice(m.from,m.toB).split(` +`))};if((ke.mac||ke.android)&&g.from==a-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(g={from:u,to:f,insert:mt.of([i.text.replace("."," ")])}),this.pendingContextChange=g,!e.state.readOnly){let b=this.to-this.from+(g.to-g.from+g.insert.length);jy(e,g,oe.single(this.toEditorPos(i.selectionStart,b),this.toEditorPos(i.selectionEnd,b)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),g.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let l=[],o=null;for(let a=this.toEditorPos(i.rangeStart),u=this.toEditorPos(i.rangeEnd);a{let l=[];for(let o of i.getTextFormats()){let a=o.underlineStyle,u=o.underlineThickness;if(!/none/i.test(a)&&!/none/i.test(u)){let f=this.toEditorPos(o.rangeStart),d=this.toEditorPos(o.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let l=hu(i.root);l&&l.rangeCount&&this.editContext.updateSelectionBounds(l.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,l=this.pendingContextChange;return e.changes.iterChanges((o,a,u,f,d)=>{if(i)return;let m=d.length-(a-o);if(l&&a>=l.to)if(l.from==o&&l.to==a&&l.insert.eq(d)){l=this.pendingContextChange=null,t+=m,this.to+=m;return}else l=null,this.revertPending(e.state);if(o+=t,a+=t,a<=this.from)this.from+=m,this.to+=m;else if(othis.to||this.to-this.from+d.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(a),d.toString()),this.to+=m}t+=m}),l&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(l=>!l.isUserEvent("input.type")&&l.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),l=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=l)&&this.editContext.updateSelection(i,l)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Oe{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(l=>l.forEach(o=>i(o,this)))||(l=>this.update(l)),this.dispatch=this.dispatch.bind(this),this._root=e.root||uR(e.parent)||document,this.viewState=new TS(this,e.state||gt.create(e)),e.scrollTo&&e.scrollTo.is(xh)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ca).map(l=>new n0(l));for(let l of this.plugins)l.update(this);this.observer=new _j(this),this.inputState=new nj(this),this.inputState.ensureHandlers(this.plugins),this.docView=new mS(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof pn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,l,o=this.state;for(let b of e){if(b.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=b.state}if(this.destroyed){this.viewState.state=o;return}let a=this.hasFocus,u=0,f=null;e.some(b=>b.annotation(gN))?(this.inputState.notifiedFocused=a,u=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,f=xN(o,a),f||(u=1));let d=this.observer.delayedAndroidKey,m=null;if(d?(this.observer.clearDelayedAndroidKey(),m=this.observer.readChange(),(m&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(m=null)):this.observer.clear(),o.facet(gt.phrases)!=this.state.facet(gt.phrases))return this.setState(o);l=pd.create(this,o,e),l.flags|=u;let g=this.viewState.scrollTarget;try{this.updateState=2;for(let b of e){if(g&&(g=g.map(b.changes)),b.scrollIntoView){let{main:v}=b.state.selection,{x:w,y:S}=this.state.facet(Oe.cursorScrollMargin);g=new xa(v.empty?v:oe.cursor(v.head,v.head>v.anchor?-1:1),"nearest","nearest",S,w)}for(let v of b.effects)v.is(xh)&&(g=v.value.clip(this.state))}this.viewState.update(l,g),this.bidiCache=vd.update(this.bidiCache,l.changes),l.empty||(this.updatePlugins(l),this.inputState.update(l)),t=this.docView.update(l),this.state.facet(Xc)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(b=>b.isUserEvent("select.pointer")))}finally{this.updateState=0}if(l.startState.facet(Sh)!=l.state.facet(Sh)&&(this.viewState.mustMeasureContent=!0),(t||i||g||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!l.empty)for(let b of this.state.facet(wx))try{b(l)}catch(v){pi(this.state,v,"update listener")}(f||m)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),m&&!cN(this,m)&&d.force&&ga(this.contentDOM,d.key,d.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new TS(this,e),this.plugins=e.facet(ca).map(i=>new n0(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new mS(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(ca),i=e.state.facet(ca);if(t!=i){let l=[];for(let o of i){let a=t.indexOf(o);if(a<0)l.push(new n0(o));else{let u=this.plugins[a];u.mustUpdate=e,l.push(u)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=l,this.pluginMap.clear()}else for(let l of this.plugins)l.mustUpdate=e;for(let l=0;l-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,l=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:a,scaleY:u}=this.viewState;Math.abs(l-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(a<0){if(zO(i||this.win))o=-1,a=this.viewState.heightMap.height/this.viewState.scaleY;else{let w=this.viewState.scrollAnchorAt(l);o=w.from,a=w.top}u=this.viewState.scaleY}this.updateState=1;let d=this.viewState.measure();if(!d&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let m=[];d&4||([this.measureRequests,m]=[m,this.measureRequests]);let g=m.map(w=>{try{return w.read(this)}catch(S){return pi(this.state,S),DS}}),b=pd.create(this,this.state,[]),v=!1;b.flags|=d,t?t.flags|=d:t=b,this.updateState=2,b.empty||(this.updatePlugins(b),this.inputState.update(b),this.updateAttrs(),v=this.docView.update(b),v&&this.docViewUpdate());for(let w=0;w1||S<-1)&&!(ke.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){l=l+S,i?o<0?i.scrollTop=i.scrollHeight:i.scrollTop+=S:this.win.scrollBy(0,S),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let f of this.state.facet(wx))f(t)}get themeClasses(){return Ex+" "+(this.state.facet(Ax)?wN:vN)+" "+this.state.facet(Sh)}updateAttrs(){let e=RS(this,eN,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(rl)?"true":"false",class:"cm-content",style:`${ke.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),RS(this,My,t);let i=this.observer.ignore(()=>{let l=aS(this.contentDOM,this.contentAttrs,t),o=aS(this.dom,this.editorAttrs,e);return l||o});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let l of i.effects)if(l.is(Oe.announce)){t&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=" "},200),t=!1);let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=l.value}}mountStyles(){this.styleModules=this.state.facet(Xc);let e=this.state.facet(Oe.cspNonce);rs.mount(this.root,this.styleModules.concat(Rj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ti.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return s0(this,e,pS(this,e,t,i))}moveByGroup(e,t){return s0(this,e,pS(this,e,t,i=>XR(this,e.head,i)))}visualLineSide(e,t){return t?oe.cursor(e.to,1):oe.cursor(e.from,-1)}moveToLineBoundary(e,t,i=!0){return QR(this,e,t,i)}moveVertically(e,t,i){return s0(this,e,$R(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=Cx(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Cx(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),l=this.bidiSpans(i),o=l[Rr.find(l,e-i.from,-1,t)];return i.length&&(e==i.from&&t<0||e==i.to&&t>0)&&o.dir!=this.textDirectionAt(i.from)&&(e==i.to?(e=i.from+o.from,t=1):(e=i.from+o.to,t=-1)),this.docView.coordsAt(e,t,o.dir==Tt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(KO)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Bj)return FO(e.length);let t=this.textDirectionAt(e.from),i;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==t&&(o.fresh||UO(o.isolates,i=fS(this,e))))return o.order;i||(i=fS(this,e));let l=yR(e.text,t,i);return this.bidiCache.push(new vd(e.from,e.to,t,i,!0,l)),l}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||ke.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{LO(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,l,o,a;return xh.of(new xa(typeof e=="number"?oe.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(l=t.x)!==null&&l!==void 0?l:"nearest",(o=t.yMargin)!==null&&o!==void 0?o:5,(a=t.xMargin)!==null&&a!==void 0?a:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return xh.of(new xa(oe.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return en.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return en.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=rs.newName(),l=[Sh.of(i),Xc.of(Mx(`.${i}`,e))];return t&&t.dark&&l.push(Ax.of(!0)),l}static baseTheme(e){return ao.lowest(Xc.of(Mx("."+Ex,e,kN)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),l=i&&Gt.get(i)||Gt.get(e);return((t=l==null?void 0:l.root)===null||t===void 0?void 0:t.view)||null}}Oe.styleModule=Xc;Oe.inputHandler=YO;Oe.clipboardInputFilter=Ay;Oe.clipboardOutputFilter=Ey;Oe.scrollHandler=ZO;Oe.focusChangeEffect=GO;Oe.perLineTextDirection=KO;Oe.exceptionSink=$O;Oe.updateListener=wx;Oe.editable=rl;Oe.mouseSelectionStyle=XO;Oe.dragMovesSelection=QO;Oe.clickAddsSelectionRange=VO;Oe.decorations=Wd;Oe.blockWrappers=tN;Oe.outerDecorations=Dy;Oe.atomicRanges=Au;Oe.bidiIsolatedRanges=nN;Oe.cursorScrollMargin=Ce.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});Oe.scrollMargins=rN;Oe.darkTheme=Ax;Oe.cspNonce=Ce.define({combine:n=>n.length?n[0]:""});Oe.contentAttributes=My;Oe.editorAttributes=eN;Oe.lineWrapping=Oe.contentAttributes.of({class:"cm-lineWrapping"});Oe.announce=Ke.define();const Bj=4096,DS={};class vd{constructor(e,t,i,l,o,a){this.from=e,this.to=t,this.dir=i,this.isolates=l,this.fresh=o,this.order=a}static update(e,t){if(t.empty&&!e.some(o=>o.fresh))return e;let i=[],l=e.length?e[e.length-1].dir:Tt.LTR;for(let o=Math.max(0,e.length-10);o=0;l--){let o=i[l],a=typeof o=="function"?o(n):o;a&&Oy(a,t)}return t}const Pj=ke.mac?"mac":ke.windows?"win":ke.linux?"linux":"key";function Hj(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let l,o,a,u;for(let f=0;fi.concat(l),[]))),t}function Uj(n,e,t){return CN(SN(n.state),e,n,t)}let Kl=null;const Fj=4e3;function qj(n,e=Pj){let t=Object.create(null),i=Object.create(null),l=(a,u)=>{let f=i[a];if(f==null)i[a]=u;else if(f!=u)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},o=(a,u,f,d,m)=>{var g,b;let v=t[a]||(t[a]=Object.create(null)),w=u.split(/ (?!$)/).map(N=>Hj(N,e));for(let N=1;N{let I=Kl={view:D,prefix:j,scope:a};return setTimeout(()=>{Kl==I&&(Kl=null)},Fj),!0}]})}let S=w.join(" ");l(S,!1);let C=v[S]||(v[S]={preventDefault:!1,stopPropagation:!1,run:((b=(g=v._any)===null||g===void 0?void 0:g.run)===null||b===void 0?void 0:b.slice())||[]});f&&C.run.push(f),d&&(C.preventDefault=!0),m&&(C.stopPropagation=!0)};for(let a of n){let u=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let d of u){let m=t[d]||(t[d]=Object.create(null));m._any||(m._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:g}=a;for(let b in m)m[b].run.push(v=>g(v,Dx))}let f=a[e]||a.key;if(f)for(let d of u)o(d,f,a.run,a.preventDefault,a.stopPropagation),a.shift&&o(d,"Shift-"+f,a.shift,a.preventDefault,a.stopPropagation)}return t}let Dx=null;function CN(n,e,t,i){Dx=e;let l=iR(e),o=hi(l,0),a=Mr(o)==l.length&&l!=" ",u="",f=!1,d=!1,m=!1;Kl&&Kl.view==t&&Kl.scope==i&&(u=Kl.prefix+" ",hN.indexOf(e.keyCode)<0&&(d=!0,Kl=null));let g=new Set,b=C=>{if(C){for(let N of C.run)if(!g.has(N)&&(g.add(N),N(t)))return C.stopPropagation&&(m=!0),!0;C.preventDefault&&(C.stopPropagation&&(m=!0),d=!0)}return!1},v=n[i],w,S;return v&&(b(v[u+Ch(l,e,!a)])?f=!0:a&&(e.altKey||e.metaKey||e.ctrlKey)&&!(ke.windows&&e.ctrlKey&&e.altKey)&&!(ke.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(w=ls[e.keyCode])&&w!=l?(b(v[u+Ch(w,e,!0)])||e.shiftKey&&(S=uu[e.keyCode])!=l&&S!=w&&b(v[u+Ch(S,e,!1)]))&&(f=!0):a&&e.shiftKey&&b(v[u+Ch(l,e,!0)])&&(f=!0),!f&&b(v._any)&&(f=!0)),d&&(f=!0),f&&m&&e.stopPropagation(),Dx=null,f}class eo{constructor(e,t,i,l,o){this.className=e,this.left=t,this.top=i,this.width=l,this.height=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let l=e.coordsAtPos(i.head,i.assoc||1);if(!l)return[];let o=ON(e);return[new eo(t,l.left-o.left,l.top-o.top,null,l.bottom-l.top)]}else return Vj(e,t,i)}}function ON(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==Tt.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function _S(n,e,t,i){let l=n.coordsAtPos(e,t*2);if(!l)return i;let o=n.dom.getBoundingClientRect(),a=(l.top+l.bottom)/2,u=n.posAtCoords({x:o.left+1,y:a}),f=n.posAtCoords({x:o.right-1,y:a});return u==null||f==null?i:{from:Math.max(i.from,Math.min(u,f)),to:Math.min(i.to,Math.max(u,f))}}function Vj(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),l=Math.min(t.to,n.viewport.to),o=n.textDirection==Tt.LTR,a=n.contentDOM,u=a.getBoundingClientRect(),f=ON(n),d=a.querySelector(".cm-line"),m=d&&window.getComputedStyle(d),g=u.left+(m?parseInt(m.paddingLeft)+Math.min(0,parseInt(m.textIndent)):0),b=u.right-(m?parseInt(m.paddingRight):0),v=Sx(n,i,1),w=Sx(n,l,-1),S=v.type==Bn.Text?v:null,C=w.type==Bn.Text?w:null;if(S&&(n.lineWrapping||v.widgetLineBreaks)&&(S=_S(n,i,1,S)),C&&(n.lineWrapping||w.widgetLineBreaks)&&(C=_S(n,l,-1,C)),S&&C&&S.from==C.from&&S.to==C.to)return j(D(t.from,t.to,S));{let U=S?D(t.from,null,S):I(v,!1),E=C?D(null,t.to,C):I(w,!0),T=[];return(S||v).to<(C||w).from-(S&&C?1:0)||v.widgetLineBreaks>1&&U.bottom+n.defaultLineHeight/2F&&me.from=_)break;A>ne&&G(Math.max(re,ne),U==null&&re<=F,Math.min(A,_),E==null&&A>=se,ie.dir)}if(ne=Z.to+1,ne>=_)break}return q.length==0&&G(F,U==null,se,E==null,n.textDirection),{top:z,bottom:te,horizontal:q}}function I(U,E){let T=u.top+(E?U.top:U.bottom);return{top:T,bottom:T,horizontal:[]}}}function Qj(n,e){return n.constructor==e.constructor&&n.eq(e)}class Xj{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(td)!=e.state.facet(td)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(td);for(;t!Qj(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let l of e)l.update&&t&&l.constructor&&this.drawn[i].constructor&&l.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(l.draw(),t);for(;t;){let l=t.nextSibling;t.remove(),t=l}this.drawn=e,ke.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const td=Ce.define();function NN(n){return[en.define(e=>new Xj(e,n)),td.of(n)]}const Rx=!ke.ios,Ea=Ce.define({combine(n){return Pr(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function $j(n={}){return[Ea.of(n),Yj,Gj,Wj,WO.of(!0)]}function TN(n){return n.startState.facet(Ea)!=n.state.facet(Ea)}const Yj=NN({above:!0,markers(n){let{state:e}=n,t=e.facet(Ea),i=[];for(let l of e.selection.ranges){let o=l==e.selection.main;if(l.empty||t.drawRangeCursor&&!(o&&ke.ios&&t.iosSelectionHandles)){let a=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=l.empty?l:oe.cursor(l.head,l.assoc);for(let f of eo.forRange(n,a,u))i.push(f)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=TN(n);return t&&LS(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){LS(e.state,n)},class:"cm-cursorLayer"});function LS(n,e){e.style.animationDuration=n.facet(Ea).cursorBlinkRate+"ms"}const Gj=NN({above:!1,markers(n){let e=[],{main:t,ranges:i}=n.state.selection;for(let l of i)if(!l.empty&&(Rx||l!=t))for(let o of eo.forRange(n,"cm-selectionBackground",l))e.push(o);if(ke.ios&&!t.empty&&n.state.facet(Ea).iosSelectionHandles){for(let l of eo.forRange(n,"cm-selectionHandle cm-selectionHandle-start",oe.cursor(t.from,1)))e.push(l);for(let l of eo.forRange(n,"cm-selectionHandle cm-selectionHandle-end",oe.cursor(t.to,1)))e.push(l)}return e},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||TN(n)},class:"cm-selectionLayer"}),Kj=ke.gecko&&ke.gecko_version==153?"#ffffff01":"transparent",Wj=ao.highest(Oe.theme({".cm-line":{...Rx?{"& ::selection, &::selection":{backgroundColor:`${Kj} !important`}}:{},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important",...Rx?{"&::selection, & ::selection":{backgroundColor:"Highlight !important"}}:{}}}})),AN=Ke.define({map(n,e){return n==null?null:e.mapPos(n)}}),Yc=Fn.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(AN)?i.value:t,n)}}),Zj=en.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(Yc);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(Yc)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(Yc),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(Yc)!=n&&this.view.dispatch({effects:AN.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Jj(){return[Yc,Zj]}function zS(n,e,t,i,l){e.lastIndex=0;for(let o=n.iterRange(t,i),a=t,u;!o.next().done;a+=o.value.length)if(!o.lineBreak)for(;u=e.exec(o.value);)l(a+u.index,u)}function e_(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:l,to:o}of t)l=Math.max(n.state.doc.lineAt(l).from,l-e),o=Math.min(n.state.doc.lineAt(o).to,o+e),i.length&&i[i.length-1].to>=l?i[i.length-1].to=o:i.push({from:l,to:o});return i}class t_{constructor(e){const{regexp:t,decoration:i,decorate:l,boundary:o,maxLength:a=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,l)this.addMatch=(u,f,d,m)=>l(m,d,d+u[0].length,u,f);else if(typeof i=="function")this.addMatch=(u,f,d,m)=>{let g=i(u,f,d);g&&m(d,d+u[0].length,g)};else if(i)this.addMatch=(u,f,d,m)=>m(d,d+u[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=o,this.maxLength=a}createDeco(e){let t=new Br,i=t.add.bind(t);for(let{from:l,to:o}of e_(e,this.maxLength))zS(e.state.doc,this.regexp,l,o,(a,u)=>this.addMatch(u,e,a,i));return t.finish()}updateDeco(e,t){let i=1e9,l=-1;return e.docChanged&&e.changes.iterChanges((o,a,u,f)=>{f>=e.view.viewport.from&&u<=e.view.viewport.to&&(i=Math.min(u,i),l=Math.max(f,l))}),e.viewportMoved||l-i>1e3?this.createDeco(e.view):l>-1?this.updateRange(e.view,t.map(e.changes),i,l):t}updateRange(e,t,i,l){for(let o of e.visibleRanges){let a=Math.max(o.from,i),u=Math.min(o.to,l);if(u>=a){let f=e.state.doc.lineAt(a),d=f.tof.from;a--)if(this.boundary.test(f.text[a-1-f.from])){m=a;break}for(;ub.push(N.range(S,C));if(f==d)for(this.regexp.lastIndex=m-f.from;(v=this.regexp.exec(f.text))&&v.indexthis.addMatch(C,e,S,w));t=t.update({filterFrom:m,filterTo:g,filter:(S,C)=>Sg,add:b})}}return t}}const jx=/x/.unicode!=null?"gu":"g",n_=new RegExp(`[\0-\b +--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,jx),i_={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let c0=null;function r_(){var n;if(c0==null&&typeof document<"u"&&document.body){let e=document.body.style;c0=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return c0||!1}const nd=Ce.define({combine(n){let e=Pr(n,{render:null,specialChars:n_,addSpecialChars:null});return(e.replaceTabs=!r_())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,jx)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,jx)),e}});function l_(n={}){return[nd.of(n),s_()]}let BS=null;function s_(){return BS||(BS=en.fromClass(class{constructor(n){this.view=n,this.decorations=Fe.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(nd)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new t_({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:l}=t.state,o=hi(e[0],0);if(o==9){let a=l.lineAt(i),u=t.state.tabSize,f=ja(a.text,u,i-a.from);return Fe.replace({widget:new u_((u-f%u)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=Fe.replace({widget:new c_(n,o)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(nd);n.startState.facet(nd)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const o_="•";function a_(n){return n>=32?o_:n==10?"␤":String.fromCharCode(9216+n)}class c_ extends fl{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=a_(this.code),i=e.state.phrase("Control character")+" "+(i_[this.code]||"0x"+this.code.toString(16)),l=this.options.render&&this.options.render(this.code,i,t);if(l)return l;let o=document.createElement("span");return o.textContent=t,o.title=i,o.setAttribute("aria-label",i),o.className="cm-specialChar",o}ignoreEvent(){return!1}}class u_ extends fl{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function f_(){return d_}const h_=Fe.line({class:"cm-activeLine"}),d_=en.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let l=n.lineBlockAt(i.head);l.from>e&&(t.push(h_.range(l.from)),e=l.from)}return Fe.set(t)}},{decorations:n=>n.decorations}),_x=2e3;function m_(n,e,t){let i=Math.min(e.line,t.line),l=Math.max(e.line,t.line),o=[];if(e.off>_x||t.off>_x||e.col<0||t.col<0){let a=Math.min(e.off,t.off),u=Math.max(e.off,t.off);for(let f=i;f<=l;f++){let d=n.doc.line(f);d.length<=u&&o.push(oe.range(d.from+a,d.to+u))}}else{let a=Math.min(e.col,t.col),u=Math.max(e.col,t.col);for(let f=i;f<=l;f++){let d=n.doc.line(f),m=ux(d.text,a,n.tabSize,!0);if(m<0)o.push(oe.cursor(d.to));else{let g=ux(d.text,u,n.tabSize);o.push(oe.range(d.from+m,d.from+g))}}}return o}function p_(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function PS(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),l=t-i.from,o=l>_x?-1:l==i.length?p_(n,e.clientX):ja(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:o,off:l}}function g_(n,e){let t=PS(n,e),i=n.state.selection;return t?{update(l){if(l.docChanged){let o=l.changes.mapPos(l.startState.doc.line(t.line).from),a=l.state.doc.lineAt(o);t={line:a.number,col:t.col,off:Math.min(t.off,a.length)},i=i.map(l.changes)}},get(l,o,a){let u=PS(n,l);if(!u)return i;let f=m_(n.state,t,u);return f.length?a?oe.create(f.concat(i.ranges)):oe.create(f):i}}:null}function x_(n){let e=(t=>t.altKey&&t.button==0);return Oe.mouseSelectionStyle.of((t,i)=>e(i)?g_(t,i):null)}const y_={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},b_={style:"cursor: crosshair"};function v_(n={}){let[e,t]=y_[n.key||"Alt"],i=en.fromClass(class{constructor(l){this.view=l,this.isDown=!1}set(l){this.isDown!=l&&(this.isDown=l,this.view.update([]))}},{eventObservers:{keydown(l){this.set(l.keyCode==e||t(l))},keyup(l){(l.keyCode==e||!t(l))&&this.set(!1)},mousemove(l){this.set(t(l))}}});return[i,Oe.contentAttributes.of(l=>{var o;return!((o=l.plugin(i))===null||o===void 0)&&o.isDown?b_:null})]}const Oh="-10000px";class EN{constructor(e,t,i,l){this.facet=t,this.createTooltipView=i,this.removeTooltipView=l,this.input=e.state.facet(t),this.tooltips=this.input.filter(a=>a);let o=null;this.tooltipViews=this.tooltips.map(a=>o=i(a,o))}update(e,t){var i;let l=e.state.facet(this.facet),o=l.filter(f=>f);if(l===this.input){for(let f of this.tooltipViews)f.update&&f.update(e);return!1}let a=[],u=t?[]:null;for(let f=0;ft[d]=f),t.length=u.length),this.input=l,this.tooltips=o,this.tooltipViews=a,!0}}function MN(n){let e=n.dom.ownerDocument.documentElement,t=e.clientWidth,i=getComputedStyle(e);if(!/stable/.test(i.scrollbarGutter||""))return{left:0,right:t};let l=e.getBoundingClientRect(),o=n.win.scrollX;return{left:Math.max(0,l.left+o-parseFloat(i.marginLeft)),right:Math.min(t,l.right+o+parseFloat(i.marginRight))}}function w_(n){let{left:e,right:t}=MN(n);return{top:0,left:e,right:t,bottom:n.dom.ownerDocument.documentElement.clientHeight}}const u0=Ce.define({combine:n=>{var e,t,i;return{position:ke.ios?"absolute":((e=n.find(l=>l.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(l=>l.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(l=>l.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||w_}}}),HS=new WeakMap,zy=en.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(u0);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new EN(n,By,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(u0);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let l of this.manager.tooltipViews)l.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let l of this.manager.tooltipViews)this.container.appendChild(l.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let l=document.createElement("div");l.className="cm-tooltip-arrow",t.dom.appendChild(l)}return t.dom.style.position=this.position,t.dom.style.top=Oh,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1,i=0;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:a}=this.manager.tooltipViews[0];if(ke.safari){let u=a.getBoundingClientRect();t=Math.abs(u.top+1e4)>1||Math.abs(u.left)>1}else t=!!a.offsetParent&&a.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let a=this.parent.getBoundingClientRect();a.width&&a.height&&(n=a.width/this.parent.offsetWidth,e=a.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);else i=MN(this.view).left;let l=this.view.scrollDOM.getBoundingClientRect(),o=Ry(this.view);return{visible:{left:l.left+o.left,top:l.top+o.top,right:l.right-o.right,bottom:l.bottom-o.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((a,u)=>{let f=this.manager.tooltipViews[u];return f.getCoords?f.getCoords(a.pos):this.view.coordsAtPos(a.pos)}),size:this.manager.tooltipViews.map(({dom:a})=>a.getBoundingClientRect()),space:this.view.state.facet(u0).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t,fixedLeft:i}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let u of this.manager.tooltipViews)u.dom.style.position="absolute"}let{visible:t,space:i,scaleX:l,scaleY:o}=n,a=[];for(let u=0;u=Math.min(t.bottom,i.bottom)||g.rightMath.min(t.right,i.right)+.1)){m.style.top=Oh;continue}let v=f.arrow?d.dom.querySelector(".cm-tooltip-arrow"):null,w=v?7:0,S=b.right-b.left,C=(e=HS.get(d))!==null&&e!==void 0?e:b.bottom-b.top,N=d.offset||S_,j=this.view.textDirection==Tt.LTR,D=b.width>i.right-i.left?j?i.left:i.right-b.width:j?Math.max(i.left,Math.min(g.left-(v?14:0)+N.x,i.right-S)):Math.min(Math.max(i.left,g.left-S+(v?14:0)-N.x),i.right-S),I=this.above[u];!f.strictSide&&(I?g.top-C-w-N.yi.bottom)&&I==i.bottom-g.bottom>g.top-i.top&&(I=this.above[u]=!I);let U=(I?g.top-i.top:i.bottom-g.bottom)-w;if(UD&&z.topE&&(E=I?z.top-C-2-w:z.bottom+w+2);if(this.position=="absolute"?(m.style.top=(E-n.parent.top)/o+"px",IS(m,(D-n.parent.left)/l)):(m.style.top=E/o+"px",IS(m,(D-n.fixedLeft)/l)),v){let z=g.left+(j?N.x:-N.x)-(D+14-7);v.style.left=z/l+"px"}d.overlap!==!0&&a.push({left:D,top:E,right:T,bottom:E+C}),m.classList.toggle("cm-tooltip-above",I),m.classList.toggle("cm-tooltip-below",!I),d.positioned&&d.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=Oh}},{eventObservers:{scroll(){this.maybeMeasure()}}});function IS(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}const k_=Oe.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),S_={x:0,y:0},By=Ce.define({enables:[zy,k_]}),wd=Ce.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class tm{static create(e){return new tm(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new EN(e,wd,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let l=i[e];if(l!==void 0){if(t===void 0)t=l;else if(t!==l)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const C_=By.compute([wd],n=>{let e=n.facet(wd);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:tm.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),DN=Ce.define();class O_{constructor(e,t,i,l,o,a){this.view=e,this.source=t,this.field=i,this.locked=l,this.setHover=o,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;ea.bottom||t.xa.right+e.defaultCharacterWidth)return;let u=e.bidiSpans(e.state.doc.lineAt(l)).find(d=>d.from<=l&&d.to>=l),f=u&&u.dir==Tt.RTL?-1:1;o=t.x{if(u&&!(Array.isArray(u)&&!u.length)){let f=Array.isArray(u)?u:[u];l&&this.locked.set(f,l),e.dispatch({effects:this.setHover.of(f)})}};if(o&&"then"in o){let u=this.pending={pos:t};o.then(f=>{this.pending==u&&(this.pending=null,a(f))},f=>pi(e.state,f,"hover tooltip"))}else a(o)}get tooltip(){let e=this.view.plugin(zy),t=e?e.manager.tooltips.findIndex(i=>i.create==tm.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:l,tooltip:o}=this;if(l.length&&!this.locked.has(l)&&o&&!N_(o.dom,e)||this.pending){let{pos:a}=l[0]||this.pending,u=(i=(t=l[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:a;(a==u?this.view.posAtCoords(this.lastMove)!=a:!T_(this.view,a,u,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:l}=this;l.length&&!this.locked.has(l)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Nh=4;function N_(n,e){let{left:t,right:i,top:l,bottom:o}=n.getBoundingClientRect(),a;if(a=n.querySelector(".cm-tooltip-arrow")){let u=a.getBoundingClientRect();l=Math.min(u.top,l),o=Math.max(u.bottom,o)}return e.clientX>=t-Nh&&e.clientX<=i+Nh&&e.clientY>=l-Nh&&e.clientY<=o+Nh}function T_(n,e,t,i,l,o){let a=n.scrollDOM.getBoundingClientRect(),u=n.documentTop+n.documentPadding.top+n.contentHeight;if(a.left>i||a.rightl||Math.min(a.bottom,u)=e&&f<=t}function A_(n,e={}){let t=Ke.define(),i=new WeakMap,l=Fn.define({create(){return[]},update(a,u){let f=i.get(a);if(a.length&&(e.hideOnChange&&(u.docChanged||u.selection)?a=[]:f&&f(u)?a=[]:e.hideOn&&(a=a.filter(d=>!e.hideOn(u,d)))),u.docChanged&&a.length){let d=[];for(let m of a){let g=u.changes.mapPos(m.pos,-1,Zn.TrackDel);if(g!=null){let b=Object.assign(Object.create(null),m);b.pos=g,b.end!=null&&(b.end=u.changes.mapPos(b.end)),d.push(b)}}a=d}for(let d of u.effects)d.is(t)&&(a=d.value,f=void 0),(d.is(M_)&&!d.value||d.value==l)&&(a=[]);return a.length&&f&&i.set(a,f),a},provide:a=>wd.from(a)});const o=en.define(a=>new O_(a,n,l,i,t,e.hoverTime||300));return{active:l,extension:[l,o,DN.of(o),C_]}}function E_(n,e,t,i={}){var l;let o=n.state.facet(DN).map(a=>n.plugin(a)).filter(a=>!!a);if(i.tooltip&&i.tooltip.active){let a=o.find(u=>u.field==i.tooltip.active);a&&(o=[a])}for(let a of o)a.activateHover(n,e,t,(l=i.until)!==null&&l!==void 0?l:(()=>!1))}function RN(n,e){let t=n.plugin(zy);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const M_=Ke.define(),US=Ce.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function nm(n,e){let t=n.plugin(jN),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const jN=en.fromClass(class{constructor(n){this.input=n.state.facet(mu),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(US);this.top=new Th(n,!0,e.topContainer),this.bottom=new Th(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(US);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Th(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Th(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(mu);if(t!=this.input){let i=t.filter(f=>f),l=[],o=[],a=[],u=[];for(let f of i){let d=this.specs.indexOf(f),m;d<0?(m=f(n.view),u.push(m)):(m=this.panels[d],m.update&&m.update(n)),l.push(m),(m.top?o:a).push(m)}this.specs=i,this.panels=l,this.top.sync(o),this.bottom.sync(a);for(let f of u)f.dom.classList.add("cm-panel"),f.mount&&f.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>Oe.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Th{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=FS(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=FS(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function FS(n){let e=n.nextSibling;return n.remove(),e}const mu=Ce.define({enables:jN});function D_(n,e){let t,i=new Promise(a=>t=a),l=a=>j_(a,e,t);n.state.field(id,!1)?n.dispatch({effects:_N.of(l)}):n.dispatch({effects:Ke.appendConfig.of(id.init(()=>[l]))});let o=LN.of(l);return{close:o,result:i.then(a=>((n.win.queueMicrotask||(f=>n.win.setTimeout(f,10)))(()=>{n.state.field(id).indexOf(l)>-1&&n.dispatch({effects:o})}),a))}}function R_(n,e){let t=n.state.field(id,!1)||[];for(let i of t){let l=nm(n,i);if(l&&l.dom.classList.contains(e))return l}return null}const id=Fn.define({create(){return[]},update(n,e){for(let t of e.effects)t.is(_N)?n=[t.value].concat(n):t.is(LN)&&(n=n.filter(i=>i!=t.value));return n},provide:n=>mu.computeN([n],e=>e.field(n))}),_N=Ke.define(),LN=Ke.define();function j_(n,e,t){let i=e.content?e.content(n,()=>u(null)):null;if(!i){if(i=Nt("form"),e.input){let f=Nt("input",e.input);/^(text|password|number|email|tel|url)$/.test(f.type)&&f.classList.add("cm-textfield"),f.name||(f.name="input"),i.appendChild(Nt("label",(e.label||"")+": ",f))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(Nt("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let l=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let f=0;f{m.keyCode==27?(m.preventDefault(),u(null)):m.keyCode==13&&(m.preventDefault(),u(d))}),d.addEventListener("submit",m=>{m.preventDefault(),u(d)})}let o=Nt("div",i,Nt("button",{onclick:()=>u(null),"aria-label":n.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(o.className=e.class),o.classList.add("cm-dialog");let a=typeof e.focus=="string"?i.querySelector(e.focus):e.focus?i.querySelector("input")||i.querySelector("button"):null;function u(f){o.contains(o.ownerDocument.activeElement)&&n.focus(),t(f)}return{dom:o,top:e.top,mount:()=>{a&&("select"in a?a.select():"focus"in a&&a.focus())},destroy:()=>t(null)}}class al extends is{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}al.prototype.elementClass="";al.prototype.toDOM=void 0;al.prototype.mapMode=Zn.TrackBefore;al.prototype.startSide=al.prototype.endSide=-1;al.prototype.point=!0;const rd=Ce.define(),__=Ce.define(),L_={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>st.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},tu=Ce.define();function z_(n){return[zN(),tu.of({...L_,...n})]}const qS=Ce.define({combine:n=>n.some(e=>e)});function zN(n){return[B_]}const B_=en.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(tu).map(e=>new QS(n,e)),this.fixed=!n.state.facet(qS);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(qS)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=st.iter(this.view.state.facet(rd),this.view.viewport.from),i=[],l=this.gutters.map(o=>new P_(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(o.type)){let a=!0;for(let u of o.type)if(u.type==Bn.Text&&a){Lx(t,i,u.from);for(let f of l)f.line(this.view,u,i);a=!1}else if(u.widget)for(let f of l)f.widget(this.view,u)}else if(o.type==Bn.Text){Lx(t,i,o.from);for(let a of l)a.line(this.view,o,i)}else if(o.widget)for(let a of l)a.widget(this.view,o);for(let o of l)o.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(tu),t=n.state.facet(tu),i=n.docChanged||n.heightChanged||n.viewportChanged||!st.eq(n.startState.facet(rd),n.state.facet(rd),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let l of this.gutters)l.update(n)&&(i=!0);else{i=!0;let l=[];for(let o of t){let a=e.indexOf(o);a<0?l.push(new QS(this.view,o)):(this.gutters[a].update(n),l.push(this.gutters[a]))}for(let o of this.gutters)o.dom.remove(),l.indexOf(o)<0&&o.destroy();for(let o of l)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=l}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>Oe.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,l=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Tt.LTR?{left:i,right:l}:{right:i,left:l}})});function VS(n){return Array.isArray(n)?n:[n]}function Lx(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class P_{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=st.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:l}=this,o=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==l.elements.length){let u=new BN(e,a,o,i);l.elements.push(u),l.dom.appendChild(u.dom)}else l.elements[this.i].update(e,a,o,i);this.height=t.bottom,this.i++}line(e,t,i){let l=[];Lx(this.cursor,l,t.from),i.length&&(l=l.concat(i));let o=this.gutter.config.lineMarker(e,t,l);o&&l.unshift(o);let a=this.gutter;l.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,l)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),l=i?[i]:null;for(let o of e.state.facet(__)){let a=o(e,t.widget,t);a&&(l||(l=[])).push(a)}l&&this.addElement(e,t,l)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class QS{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,l=>{let o=l.target,a;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let f=o.getBoundingClientRect();a=(f.top+f.bottom)/2}else a=l.clientY;let u=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[i](e,u,l)&&l.preventDefault()});this.markers=VS(t.markers(e)),t.initialSpacer&&(this.spacer=new BN(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=VS(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let l=this.config.updateSpacer(this.spacer.markers[0],e);l!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[l])}let i=e.view.viewport;return!st.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class BN{constructor(e,t,i,l){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,l)}update(e,t,i,l){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),H_(this.markers,l)||this.setMarkers(e,l)}setMarkers(e,t){let i="cm-gutterElement",l=this.dom.firstChild;for(let o=0,a=0;;){let u=a,f=oo(u,f,d)||a(u,f,d):a}return i}})}});class f0 extends al{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function h0(n,e){return n.state.facet(ua).formatNumber(e,n.state)}const F_=tu.compute([ua],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(I_)},lineMarker(e,t,i){return i.some(l=>l.toDOM)?null:new f0(h0(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let l of e.state.facet(U_)){let o=l(e,t,i);if(o)return o}return null},lineMarkerChange:e=>e.startState.facet(ua)!=e.state.facet(ua),initialSpacer(e){return new f0(h0(e,XS(e.state.doc.lines)))},updateSpacer(e,t){let i=h0(t.view,XS(t.view.state.doc.lines));return i==e.number?e:new f0(i)},domEventHandlers:n.facet(ua).domEventHandlers,side:"before"}));function q_(n={}){return[ua.of(n),zN(),F_]}function XS(n){let e=9;for(;e{let e=[],t=-1;for(let i of n.selection.ranges){let l=n.doc.lineAt(i.head).from;l>t&&(t=l,e.push(V_.range(l)))}return st.of(e)});function X_(){return Q_}const PN=1024;let $_=0;class d0{constructor(e,t){this.from=e,this.to=t}}class tt{constructor(e={}){this.id=$_++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=xi.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}tt.closedBy=new tt({deserialize:n=>n.split(" ")});tt.openedBy=new tt({deserialize:n=>n.split(" ")});tt.group=new tt({deserialize:n=>n.split(" ")});tt.isolate=new tt({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});tt.contextHash=new tt({perNode:!0});tt.lookAhead=new tt({perNode:!0});tt.mounted=new tt({perNode:!0});class nu{constructor(e,t,i,l=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=l}static get(e){return e&&e.props&&e.props[tt.mounted.id]}}const Y_=Object.create(null);class xi{constructor(e,t,i,l=0){this.name=e,this.props=t,this.id=i,this.flags=l}static define(e){let t=e.props&&e.props.length?Object.create(null):Y_,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),l=new xi(e.name||"",t,e.id,i);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(l)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[o[0].id]=o[1]}}return l}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(tt.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let l of i.split(" "))t[l]=e[i];return i=>{for(let l=i.prop(tt.group),o=-1;o<(l?l.length:0);o++){let a=t[o<0?i.name:l[o]];if(a)return a}}}}xi.none=new xi("",Object.create(null),0,8);class Py{constructor(e){this.types=e;for(let t=0;t0;for(let f=this.cursor(a|Yt.IncludeAnonymous);;){let d=!1;if(f.from<=o&&f.to>=l&&(!u&&f.type.isAnonymous||t(f)!==!1)){if(f.firstChild())continue;d=!0}for(;d&&i&&(u||!f.type.isAnonymous)&&i(f),!f.nextSibling();){if(!f.parent())return;d=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Uy(xi.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,l)=>new fn(this.type,t,i,l,this.propValues),e.makeTree||((t,i,l)=>new fn(xi.none,t,i,l)))}static build(e){return Z_(e)}}fn.empty=new fn(xi.none,[],[],0);class Hy{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Hy(this.buffer,this.index)}}class os{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return xi.none}toString(){let e=[];for(let t=0;t0));f=a[f+3]);return u}slice(e,t,i){let l=this.buffer,o=new Uint16Array(t-e),a=0;for(let u=e,f=0;u=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function pu(n,e,t,i){for(var l;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?u.length:-1;e!=d;e+=t){let m=u[e],g=f[e]+a.from,b;if(!(!(o&Yt.EnterBracketed&&m instanceof fn&&(b=nu.get(m))&&!b.overlay&&b.bracketed&&i>=g&&i<=g+m.length)&&!HN(l,i,g,g+m.length))){if(m instanceof os){if(o&Yt.ExcludeBuffers)continue;let v=m.findChild(0,m.buffer.length,t,i-g,l);if(v>-1)return new Zl(new G_(a,m,e,g),null,v)}else if(o&Yt.IncludeAnonymous||!m.type.isAnonymous||Iy(m)){let v;if(!(o&Yt.IgnoreMounts)&&(v=nu.get(m))&&!v.overlay)return new Qi(v.tree,g,e,a);let w=new Qi(m,g,e,a);return o&Yt.IncludeAnonymous||!w.type.isAnonymous?w:w.nextChild(t<0?m.children.length-1:0,t,i,l,o)}}}if(o&Yt.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+t:e=t<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let l;if(!(i&Yt.IgnoreOverlays)&&(l=nu.get(this._tree))&&l.overlay){let o=e-this.from,a=i&Yt.EnterBracketed&&l.bracketed;for(let{from:u,to:f}of l.overlay)if((t>0||a?u<=o:u=o:f>o))return new Qi(l.tree,l.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function YS(n,e,t,i){let l=n.cursor(),o=[];if(!l.firstChild())return o;if(t!=null){for(let a=!1;!a;)if(a=l.type.is(t),!l.nextSibling())return o}for(;;){if(i!=null&&l.type.is(i))return o;if(l.type.is(e)&&o.push(l.node),!l.nextSibling())return i==null?o:[]}}function zx(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class G_{constructor(e,t,i,l){this.parent=e,this.buffer=t,this.index=i,this.start=l}}class Zl extends IN{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:l}=this.context,o=l.findChild(this.index+4,l.buffer[this.index+3],e,t-this.context.start,i);return o<0?null:new Zl(this.context,this,o)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&Yt.ExcludeBuffers)return null;let{buffer:l}=this.context,o=l.findChild(this.index+4,l.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return o<0?null:new Zl(this.context,this,o)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Zl(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Zl(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,l=this.index+4,o=i.buffer[this.index+3];if(o>l){let a=i.buffer[this.index+1];e.push(i.slice(l,o,a)),t.push(0)}return new fn(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function UN(n){if(!n.length)return null;let e=0,t=n[0];for(let o=1;ot.from||a.to=e){let u=new Qi(a.tree,a.overlay[0].from+o.from,-1,o);(l||(l=[i])).push(pu(u,e,t,!1))}}return l?UN(l):i}class Bx{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~Yt.EnterBracketed,e instanceof Qi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:l}=this.buffer;return this.type=t||l.set.types[l.buffer[e]],this.from=i+l.buffer[e+1],this.to=i+l.buffer[e+2],!0}yield(e){return e?e instanceof Qi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:l}=this.buffer,o=l.findChild(this.index+4,l.buffer[this.index+3],e,t-this.buffer.start,i);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&Yt.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Yt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Yt.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let l=i<0?0:this.stack[i]+4;if(this.index!=l)return this.yieldBuf(t.findChild(l,this.index,-1,0,4))}else{let l=t.buffer[this.index+3];if(l<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(l)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:l}=this;if(l){if(e>0){if(this.index-1)for(let o=t+e,a=e<0?-1:i._tree.children.length;o!=a;o+=e){let u=i._tree.children[o];if(this.mode&Yt.IncludeAnonymous||u instanceof os||!u.type.isAnonymous||Iy(u))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let a=e;a;a=a._parent)if(a.index==l){if(l==this.index)return a;t=a,i=o+1;break e}l=this.stack[--o]}for(let l=i;l=0;o--){if(o<0)return zx(this._tree,e,l);let a=i[t.buffer[this.stack[o]]];if(!a.isAnonymous){if(e[l]&&e[l]!=a.name)return!1;l--}}return!0}}function Iy(n){return n.children.some(e=>e instanceof os||!e.type.isAnonymous||Iy(e))}function Z_(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:l=PN,reused:o=[],minRepeatType:a=i.types.length}=n,u=Array.isArray(t)?new Hy(t,t.length):t,f=i.types,d=0,m=0;function g(U,E,T,z,te,q){let{id:G,start:F,end:se,size:me}=u,ne=m,_=d;if(me<0)if(u.next(),me==-1){let Be=o[G];T.push(Be),z.push(F-U);return}else if(me==-3){d=G;return}else if(me==-4){m=G;return}else throw new RangeError(`Unrecognized record size: ${me}`);let Z=f[G],ie,re,A=F-U;if(se-F<=l&&(re=C(u.pos-E,te))){let Be=new Uint16Array(re.size-re.skip),ze=u.pos-re.size,B=Be.length;for(;u.pos>ze;)B=N(re.start,Be,B);ie=new os(Be,se-re.start,i),A=re.start-U}else{let Be=u.pos-me;u.next();let ze=[],B=[],R=G>=a?G:-1,$=0,ue=se,ge=ne;for(;u.pos>Be;)R>=0&&u.id==R&&u.size>=0?(u.end<=ue-l&&(w(ze,B,F,$,u.end,ue,R,ge,_),$=ze.length,ue=u.end,ge=m),u.next()):q>2500?b(F,Be,ze,B):(R>=0&&u.size==-1&&o[u.id].type==i.types[R]&&($=0&&$>0&&$-1&&$>0){let je=v(Z,_);ie=Uy(Z,ze,B,0,ze.length,0,se-F,je,je)}else ie=S(Z,ze,B,se-F,ne-se,_)}T.push(ie),z.push(A)}function b(U,E,T,z){let te=[],q=0,G=-1;for(;u.pos>E;){let{id:F,start:se,end:me,size:ne}=u;if(ne>4)u.next();else{if(G>-1&&se=0;me-=3)F[ne++]=te[me],F[ne++]=te[me+1]-se,F[ne++]=te[me+2]-se,F[ne++]=ne;T.push(new os(F,te[2]-se,i)),z.push(se-U)}}function v(U,E){return(T,z,te)=>{let q=0,G=T.length-1,F,se;if(G>=0&&(F=T[G])instanceof fn){if(!G&&F.type==U&&F.length==te)return F;(se=F.prop(tt.lookAhead))&&(q=z[G]+F.length+se-te)}return S(U,T,z,te,q,E)}}function w(U,E,T,z,te,q,G,F,se){let me=[],ne=[];for(;U.length>z;)me.push(U.pop()),ne.push(E.pop()+T-te);U.push(S(i.types[G],me,ne,q-te,F-q,se)),E.push(te-T)}function S(U,E,T,z,te,q,G){if(q){let F=[tt.contextHash,q];G=G?[F].concat(G):[F]}if(te>25){let F=[tt.lookAhead,te];G=G?[F].concat(G):[F]}return new fn(U,E,T,z,G)}function C(U,E){let T=u.fork(),z=0,te=0,q=0,G=T.end-l,F={size:0,start:0,skip:0};e:for(let se=T.pos-U;T.pos>se;){let me=T.size;if(T.id==E&&me>=0){F.size=z,F.start=te,F.skip=q,q+=4,z+=4,T.next();continue}let ne=T.pos-me;if(me<0||ne=a?4:0,Z=T.start;for(T.next();T.pos>ne;){if(T.size<0)if(T.size==-3||T.size==-4)_+=4;else break e;else T.id>=a&&(_+=4);T.next()}te=Z,z+=me,q+=_}return(E<0||z==U)&&(F.size=z,F.start=te,F.skip=q),F.size>4?F:void 0}function N(U,E,T){let{id:z,start:te,end:q,size:G}=u;if(u.next(),G>=0&&z4){let se=u.pos-(G-4);for(;u.pos>se;)T=N(U,E,T)}E[--T]=F,E[--T]=q-U,E[--T]=te-U,E[--T]=z}else G==-3?d=z:G==-4&&(m=z);return T}let j=[],D=[];for(;u.pos>0;)g(n.start||0,n.bufferStart||0,j,D,-1,0);let I=(e=n.length)!==null&&e!==void 0?e:j.length?D[0]+j[0].length:0;return new fn(f[n.topID],j.reverse(),D.reverse(),I)}const GS=new WeakMap;function ld(n,e){if(!n.isAnonymous||e instanceof os||e.type!=n)return 1;let t=GS.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof fn)){t=1;break}t+=ld(n,i)}GS.set(e,t)}return t}function Uy(n,e,t,i,l,o,a,u,f){let d=0;for(let w=i;w=m)break;E+=T}if(D==I+1){if(E>m){let T=w[I];v(T.children,T.positions,0,T.children.length,S[I]+j);continue}g.push(w[I])}else{let T=S[D-1]+w[D-1].length-U;g.push(Uy(n,w,S,I,D,U,T,null,f))}b.push(U+j-o)}}return v(e,t,i,l,0),(u||f)(g,b,a)}class to{constructor(e,t,i,l,o=!1,a=!1){this.from=e,this.to=t,this.tree=i,this.offset=l,this.open=(o?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let l=[new to(0,e.length,e,0,!1,i)];for(let o of t)o.to>e.length&&l.push(o);return l}static applyChanges(e,t,i=128){if(!t.length)return e;let l=[],o=1,a=e.length?e[0]:null;for(let u=0,f=0,d=0;;u++){let m=u=i)for(;a&&a.from=b.from||g<=b.to||d){let v=Math.max(b.from,f)-d,w=Math.min(b.to,g)-d;b=v>=w?null:new to(v,w,b.tree,b.offset+d,u>0,!!m)}if(b&&l.push(b),a.to>g)break;a=onew d0(l.from,l.to)):[new d0(0,0)]:[new d0(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let l=this.startParse(e,t,i);for(;;){let o=l.advance();if(o)return o}}}class J_{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new tt({perNode:!0});let eL=0,nl=class Px{constructor(e,t,i,l){this.name=e,this.set=t,this.base=i,this.modified=l,this.id=eL++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof Px&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let l=new Px(i,[],null,[]);if(l.set.push(l),t)for(let o of t.set)l.set.push(o);return l}static defineModifier(e){let t=new kd(e);return i=>i.modified.indexOf(t)>-1?i:kd.get(i.base||i,i.modified.concat(t).sort((l,o)=>l.id-o.id))}},tL=0;class kd{constructor(e){this.name=e,this.instances=[],this.id=tL++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(u=>u.base==e&&nL(t,u.modified));if(i)return i;let l=[],o=new nl(e.name,l,e,t);for(let u of t)u.instances.push(o);let a=iL(t);for(let u of e.set)if(!u.modified.length)for(let f of a)l.push(kd.get(u,f));return o}}function nL(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function iL(n){let e=[[]];for(let t=0;ti.length-t.length)}function qN(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let l of t.split(" "))if(l){let o=[],a=2,u=l;for(let g=0;;){if(u=="..."&&g>0&&g+3==l.length){a=1;break}let b=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!b)throw new RangeError("Invalid path: "+l);if(o.push(b[0]=="*"?"":b[0][0]=='"'?JSON.parse(b[0]):b[0]),g+=b[0].length,g==l.length)break;let v=l[g++];if(g==l.length&&v=="!"){a=0;break}if(v!="/")throw new RangeError("Invalid path: "+l);u=l.slice(g)}let f=o.length-1,d=o[f];if(!d)throw new RangeError("Invalid path: "+l);let m=new gu(i,a,f>0?o.slice(0,f):null);e[d]=m.sort(e[d])}}return VN.add(e)}const VN=new tt({combine(n,e){let t,i,l;for(;n||e;){if(!n||e&&n.depth<=e.depth?(l=e,e=e.next):(l=n,n=n.next),t&&t.mode==l.mode&&!l.context&&!t.context)continue;let o=new gu(l.tags,l.mode,l.context);t?t.next=o:i=o,t=o}return i}});class gu{constructor(e,t,i,l){this.tags=e,this.mode=t,this.context=i,this.next=l}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let a=l;for(let u of o)for(let f of u.set){let d=t[f.id];if(d){a=a?a+" "+d:d;break}}return a},scope:i}}function rL(n,e){let t=null;for(let i of n){let l=i.style(e);l&&(t=t?t+" "+l:l)}return t}function lL(n,e,t,i=0,l=n.length){let o=new sL(i,Array.isArray(e)?e:[e],t);o.highlightRange(n.cursor(),i,l,"",o.highlighters),o.flush(l)}class sL{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,l,o){let{type:a,from:u,to:f}=e;if(u>=i||f<=t)return;a.isTop&&(o=this.highlighters.filter(v=>!v.scope||v.scope(a)));let d=l,m=oL(e)||gu.empty,g=rL(o,m.tags);if(g&&(d&&(d+=" "),d+=g,m.mode==1&&(l+=(l?" ":"")+g)),this.startSpan(Math.max(t,u),d),m.opaque)return;let b=e.tree&&e.tree.prop(tt.mounted);if(b&&b.overlay){let v=e.node.enter(b.overlay[0].from+u,1),w=this.highlighters.filter(C=>!C.scope||C.scope(b.tree.type)),S=e.firstChild();for(let C=0,N=u;;C++){let j=C=D||!e.nextSibling())););if(!j||D>i)break;N=j.to+u,N>t&&(this.highlightRange(v.cursor(),Math.max(t,j.from+u),Math.min(i,N),"",w),this.startSpan(Math.min(i,N),d))}S&&e.parent()}else if(e.firstChild()){b&&(l="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,l,o),this.startSpan(Math.min(i,e.to),d)}while(e.nextSibling());e.parent()}}}function oL(n){let e=n.type.prop(VN);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const we=nl.define,Eh=we(),$l=we(),KS=we($l),WS=we($l),Yl=we(),Mh=we(Yl),m0=we(Yl),Nr=we(),Fs=we(Nr),Cr=we(),Or=we(),Hx=we(),Pc=we(Hx),Dh=we(),he={comment:Eh,lineComment:we(Eh),blockComment:we(Eh),docComment:we(Eh),name:$l,variableName:we($l),typeName:KS,tagName:we(KS),propertyName:WS,attributeName:we(WS),className:we($l),labelName:we($l),namespace:we($l),macroName:we($l),literal:Yl,string:Mh,docString:we(Mh),character:we(Mh),attributeValue:we(Mh),number:m0,integer:we(m0),float:we(m0),bool:we(Yl),regexp:we(Yl),escape:we(Yl),color:we(Yl),url:we(Yl),keyword:Cr,self:we(Cr),null:we(Cr),atom:we(Cr),unit:we(Cr),modifier:we(Cr),operatorKeyword:we(Cr),controlKeyword:we(Cr),definitionKeyword:we(Cr),moduleKeyword:we(Cr),operator:Or,derefOperator:we(Or),arithmeticOperator:we(Or),logicOperator:we(Or),bitwiseOperator:we(Or),compareOperator:we(Or),updateOperator:we(Or),definitionOperator:we(Or),typeOperator:we(Or),controlOperator:we(Or),punctuation:Hx,separator:we(Hx),bracket:Pc,angleBracket:we(Pc),squareBracket:we(Pc),paren:we(Pc),brace:we(Pc),content:Nr,heading:Fs,heading1:we(Fs),heading2:we(Fs),heading3:we(Fs),heading4:we(Fs),heading5:we(Fs),heading6:we(Fs),contentSeparator:we(Nr),list:we(Nr),quote:we(Nr),emphasis:we(Nr),strong:we(Nr),link:we(Nr),monospace:we(Nr),strikethrough:we(Nr),inserted:we(),deleted:we(),changed:we(),invalid:we(),meta:Dh,documentMeta:we(Dh),annotation:we(Dh),processingInstruction:we(Dh),definition:nl.defineModifier("definition"),constant:nl.defineModifier("constant"),function:nl.defineModifier("function"),standard:nl.defineModifier("standard"),local:nl.defineModifier("local"),special:nl.defineModifier("special")};for(let n in he){let e=he[n];e instanceof nl&&(e.name=n)}QN([{tag:he.link,class:"tok-link"},{tag:he.heading,class:"tok-heading"},{tag:he.emphasis,class:"tok-emphasis"},{tag:he.strong,class:"tok-strong"},{tag:he.keyword,class:"tok-keyword"},{tag:he.atom,class:"tok-atom"},{tag:he.bool,class:"tok-bool"},{tag:he.url,class:"tok-url"},{tag:he.labelName,class:"tok-labelName"},{tag:he.inserted,class:"tok-inserted"},{tag:he.deleted,class:"tok-deleted"},{tag:he.literal,class:"tok-literal"},{tag:he.string,class:"tok-string"},{tag:he.number,class:"tok-number"},{tag:[he.regexp,he.escape,he.special(he.string)],class:"tok-string2"},{tag:he.variableName,class:"tok-variableName"},{tag:he.local(he.variableName),class:"tok-variableName tok-local"},{tag:he.definition(he.variableName),class:"tok-variableName tok-definition"},{tag:he.special(he.variableName),class:"tok-variableName2"},{tag:he.definition(he.propertyName),class:"tok-propertyName tok-definition"},{tag:he.typeName,class:"tok-typeName"},{tag:he.namespace,class:"tok-namespace"},{tag:he.className,class:"tok-className"},{tag:he.macroName,class:"tok-macroName"},{tag:he.propertyName,class:"tok-propertyName"},{tag:he.operator,class:"tok-operator"},{tag:he.comment,class:"tok-comment"},{tag:he.meta,class:"tok-meta"},{tag:he.invalid,class:"tok-invalid"},{tag:he.punctuation,class:"tok-punctuation"}]);var p0;const fa=new tt;function aL(n){return Ce.define({combine:n?e=>e.concat(n):void 0})}const cL=new tt;class ir{constructor(e,t,i=[],l=""){this.data=e,this.name=l,gt.prototype.hasOwnProperty("tree")||Object.defineProperty(gt.prototype,"tree",{get(){return Un(this)}}),this.parser=t,this.extension=[as.of(this),gt.languageData.of((o,a,u)=>{let f=ZS(o,a,u),d=f.type.prop(fa);if(!d)return[];let m=o.facet(d),g=f.type.prop(cL);if(g){let b=f.resolve(a-f.from,u);for(let v of g)if(v.test(b,o)){let w=o.facet(v.facet);return v.type=="replace"?w:w.concat(m)}}return m})].concat(i)}isActiveAt(e,t,i=-1){return ZS(e,t,i).type.prop(fa)==this.data}findRegions(e){let t=e.facet(as);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],l=(o,a)=>{if(o.prop(fa)==this.data){i.push({from:a,to:a+o.length});return}let u=o.prop(tt.mounted);if(u){if(u.tree.prop(fa)==this.data){if(u.overlay)for(let f of u.overlay)i.push({from:f.from+a,to:f.to+a});else i.push({from:a,to:a+o.length});return}else if(u.overlay){let f=i.length;if(l(u.tree,u.overlay[0].from+a),i.length>f)return}}for(let f=0;fi.isTop?t:void 0)]}),e.name)}configure(e,t){return new Sd(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Un(n){let e=n.field(ir.state,!1);return e?e.tree:fn.empty}class uL{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let Hc=null;class Cd{constructor(e,t,i=[],l,o,a,u,f){this.parser=e,this.state=t,this.fragments=i,this.tree=l,this.treeLen=o,this.viewport=a,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Cd(e,t,[],fn.empty,0,i,[],null)}startParse(){return this.parser.startParse(new uL(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=fn.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let l=Date.now()+e;e=()=>Date.now()>l}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(to.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Hc;Hc=this;try{return e()}finally{Hc=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=JS(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:l,treeLen:o,viewport:a,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((d,m,g,b)=>f.push({fromA:d,toA:m,fromB:g,toB:b})),i=to.applyChanges(i,f),l=fn.empty,o=0,a={from:e.mapPos(a.from,-1),to:e.mapPos(a.to,1)},this.skipped.length){u=[];for(let d of this.skipped){let m=e.mapPos(d.from,1),g=e.mapPos(d.to,-1);me.from&&(this.fragments=JS(this.fragments,l,o),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends FN{createParse(t,i,l){let o=l[0].from,a=l[l.length-1].to;return{parsedPos:o,advance(){let f=Hc;if(f){for(let d of l)f.tempSkipped.push(d);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=a,new fn(xi.none,[],[],a-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Hc}}function JS(n,e,t){return to.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class Ma{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new Ma(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Cd.create(e.facet(as).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new Ma(i)}}ir.state=Fn.define({create:Ma.init,update(n,e){for(let t of e.effects)if(t.is(ir.setState))return t.value;return e.startState.facet(as)!=e.state.facet(as)?Ma.init(e.state):n.apply(e)}});let XN=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(XN=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const g0=typeof navigator<"u"&&(!((p0=navigator.scheduling)===null||p0===void 0)&&p0.isInputPending)?()=>navigator.scheduling.isInputPending():null,fL=en.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(ir.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(ir.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=XN(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndl+1e3,f=o.context.work(()=>g0&&g0()||Date.now()>a,l+(u?0:1e5));this.chunkBudget-=Date.now()-t,(f||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:ir.setState.of(new Ma(o.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>pi(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),as=Ce.define({combine(n){return n.length?n[0]:null},enables:n=>[ir.state,fL,Oe.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class hL{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const dL=Ce.define(),Fy=Ce.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Od(n){let e=n.facet(Fy);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function xu(n,e){let t="",i=n.tabSize,l=n.facet(Fy)[0];if(l==" "){for(;e>=i;)t+=" ",e-=i;l=" "}for(let o=0;o=e?mL(n,t,e):null}class im{constructor(e,t={}){this.state=e,this.options=t,this.unit=Od(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:l,simulateDoubleBreak:o}=this.options;return l!=null&&l>=i.from&&l<=i.to?o&&l==e?{text:"",from:e}:(t<0?l-1&&(o+=a-this.countColumn(i,i.search(/\S|$/))),o}countColumn(e,t=e.length){return ja(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:l}=this.lineAt(e,t),o=this.options.overrideIndentation;if(o){let a=o(l);if(a>-1)return a}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const $N=new tt;function mL(n,e,t){let i=e.resolveStack(t),l=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(l!=i.node){let o=[];for(let a=l;a&&!(a.fromi.node.to||a.from==i.node.from&&a.type==i.node.type);a=a.parent)o.push(a);for(let a=o.length-1;a>=0;a--)i={node:o[a],next:i}}return YN(i,n,t)}function YN(n,e,t){for(let i=n;i;i=i.next){let l=gL(i.node);if(l)return l(Vy.create(e,t,i))}return 0}function pL(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function gL(n){let e=n.type.prop($N);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(tt.closedBy))){let l=n.lastChild,o=l&&i.indexOf(l.name)>-1;return a=>GN(a,!0,1,void 0,o&&!pL(a)?l.from:void 0)}return n.parent==null?xL:null}function xL(){return 0}class Vy extends im{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new Vy(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(yL(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return YN(this.context.next,this.base,this.pos)}}function yL(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function bL(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let l=n.options.simulateBreak,o=n.state.doc.lineAt(t.from),a=l==null||l<=o.from?o.to:Math.min(o.to,l);for(let u=t.to;;){let f=e.childAfter(u);if(!f||f==i)return null;if(!f.type.isSkipped){if(f.from>=a)return null;let d=/^ */.exec(o.text.slice(t.to-o.from))[0].length;return{from:t.from,to:t.to+d}}u=f.to}}function e2({closing:n,align:e=!0,units:t=1}){return i=>GN(i,e,t,n)}function GN(n,e,t,i,l){let o=n.textAfter,a=o.match(/^\s*/)[0].length,u=i&&o.slice(a,a+i.length)==i||l==n.pos+a,f=e?bL(n):null;return f?u?n.column(f.from):n.column(f.to):n.baseIndent+(u?0:n.unit*t)}const vL=200;function wL(){return gt.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,l=t.lineAt(i);if(i>l.from+vL)return n;let o=t.sliceString(l.from,i);if(!e.some(d=>d.test(o)))return n;let{state:a}=n,u=-1,f=[];for(let{head:d}of a.selection.ranges){let m=a.doc.lineAt(d);if(m.from==u)continue;u=m.from;let g=qy(a,m.from);if(g==null)continue;let b=/^\s*/.exec(m.text)[0],v=xu(a,g);b!=v&&f.push({from:m.from,to:m.from+b.length,insert:v})}return f.length?[n,{changes:f,sequential:!0}]:n})}const kL=Ce.define(),KN=new tt;function SL(n){let e=n.firstChild,t=n.lastChild;return e&&e.tot)continue;if(o&&u.from=e&&d.to>t&&(o=d)}}return o}function OL(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function Nd(n,e,t){for(let i of n.facet(kL)){let l=i(n,e,t);if(l)return l}return CL(n,e,t)}function WN(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const rm=Ke.define({map:WN}),Eu=Ke.define({map:WN});function ZN(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const so=Fn.define({create(){return Fe.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,l)=>n=t2(n,i,l)),n=n.map(e.changes);let t=[];for(let i of e.effects)i.is(rm)&&!NL(n,i.value.from,i.value.to)?t.push(i.value):i.is(Eu)&&(n=n.update({filter:(l,o)=>i.value.from!=l||i.value.to!=o,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(tT),l=t.map(o=>(i?Fe.replace({widget:new jL(i(e.state,o))}):n2).range(o.from,o.to));n=n.update({add:l})}return e.selection&&(n=t2(n,e.selection.main.head)),n},provide:n=>Oe.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,l)=>{t.push(i,l)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{le&&(i=!0)}),i?n.update({filterFrom:e,filterTo:t,filter:(l,o)=>l>=t||o<=e}):n}function Td(n,e,t){var i;let l=null;return(i=n.field(so,!1))===null||i===void 0||i.between(e,t,(o,a)=>{(!l||l.from>o)&&(l={from:o,to:a})}),l}function NL(n,e,t){let i=!1;return n.between(e,e,(l,o)=>{l==e&&o==t&&(i=!0)}),i}function JN(n,e){return n.field(so,!1)?e:e.concat(Ke.appendConfig.of(nT()))}const TL=n=>{for(let e of ZN(n)){let t=Nd(n.state,e.from,e.to);if(t)return n.dispatch({effects:JN(n.state,[rm.of(t),eT(n,t)])}),!0}return!1},AL=n=>{if(!n.state.field(so,!1))return!1;let e=[];for(let t of ZN(n)){let i=Td(n.state,t.from,t.to);i&&e.push(Eu.of(i),eT(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function eT(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,l=n.state.doc.lineAt(e.to).number;return Oe.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${l}.`)}const EL=n=>{let{state:e}=n,t=[];for(let i=0;i{let e=n.state.field(so,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,l)=>{t.push(Eu.of({from:i,to:l}))}),n.dispatch({effects:t}),!0},DL=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:TL},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:AL},{key:"Ctrl-Alt-[",run:EL},{key:"Ctrl-Alt-]",run:ML}],RL={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},tT=Ce.define({combine(n){return Pr(n,RL)}});function nT(n){return[so,zL]}function iT(n,e){let{state:t}=n,i=t.facet(tT),l=a=>{let u=n.lineBlockAt(n.posAtDOM(a.target)),f=Td(n.state,u.from,u.to);f&&n.dispatch({effects:Eu.of(f)}),a.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,l,e);let o=document.createElement("span");return o.textContent=i.placeholderText,o.setAttribute("aria-label",t.phrase("folded code")),o.title=t.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=l,o}const n2=Fe.replace({widget:new class extends fl{toDOM(n){return iT(n,null)}}});class jL extends fl{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return iT(e,this.value)}}const _L={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class x0 extends al{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function LL(n={}){let e={..._L,...n},t=new x0(e,!0),i=new x0(e,!1),l=en.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(as)!=a.state.facet(as)||a.startState.field(so,!1)!=a.state.field(so,!1)||Un(a.startState)!=Un(a.state)||e.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let u=new Br;for(let f of a.viewportLineBlocks){let d=Td(a.state,f.from,f.to)?i:Nd(a.state,f.from,f.to)?t:null;d&&u.add(f.from,f.from,d)}return u.finish()}}),{domEventHandlers:o}=e;return[l,z_({class:"cm-foldGutter",markers(a){var u;return((u=a.plugin(l))===null||u===void 0?void 0:u.markers)||st.empty},initialSpacer(){return new x0(e,!1)},domEventHandlers:{...o,click:(a,u,f)=>{if(o.click&&o.click(a,u,f))return!0;let d=Td(a.state,u.from,u.to);if(d)return a.dispatch({effects:Eu.of(d)}),!0;let m=Nd(a.state,u.from,u.to);return m?(a.dispatch({effects:rm.of(m)}),!0):!1}}}),nT()]}const zL=Oe.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Mu{constructor(e,t){this.specs=e;let i;function l(u){let f=rs.newName();return(i||(i=Object.create(null)))["."+f]=u,f}const o=typeof t.all=="string"?t.all:t.all?l(t.all):void 0,a=t.scope;this.scope=a instanceof ir?u=>u.prop(fa)==a.data:a?u=>u==a:void 0,this.style=QN(e.map(u=>({tag:u.tag,class:u.class||l(Object.assign({},u,{tag:null}))})),{all:o}).style,this.module=i?new rs(i):null,this.themeType=t.themeType}static define(e,t){return new Mu(e,t||{})}}const Ix=Ce.define(),rT=Ce.define({combine(n){return n.length?[n[0]]:null}});function y0(n){let e=n.facet(Ix);return e.length?e:n.facet(rT)}function lT(n,e){let t=[PL],i;return n instanceof Mu&&(n.module&&t.push(Oe.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(rT.of(n)):i?t.push(Ix.computeN([Oe.darkTheme],l=>l.facet(Oe.darkTheme)==(i=="dark")?[n]:[])):t.push(Ix.of(n)),t}class BL{constructor(e){this.markCache=Object.create(null),this.tree=Un(e.state),this.decorations=this.buildDeco(e,y0(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Un(e.state),i=y0(e.state),l=i!=y0(e.startState),{viewport:o}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length=o.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||l)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=o.to)}buildDeco(e,t){if(!t||!this.tree.length)return Fe.none;let i=new Br;for(let{from:l,to:o}of e.visibleRanges)lL(this.tree,t,(a,u,f)=>{i.add(a,u,this.markCache[f]||(this.markCache[f]=Fe.mark({class:f})))},l,o);return i.finish()}}const PL=ao.high(en.fromClass(BL,{decorations:n=>n.decorations})),HL=Mu.define([{tag:he.meta,color:"#404740"},{tag:he.link,textDecoration:"underline"},{tag:he.heading,textDecoration:"underline",fontWeight:"bold"},{tag:he.emphasis,fontStyle:"italic"},{tag:he.strong,fontWeight:"bold"},{tag:he.strikethrough,textDecoration:"line-through"},{tag:he.keyword,color:"#708"},{tag:[he.atom,he.bool,he.url,he.contentSeparator,he.labelName],color:"#219"},{tag:[he.literal,he.inserted],color:"#164"},{tag:[he.string,he.deleted],color:"#a11"},{tag:[he.regexp,he.escape,he.special(he.string)],color:"#e40"},{tag:he.definition(he.variableName),color:"#00f"},{tag:he.local(he.variableName),color:"#30a"},{tag:[he.typeName,he.namespace],color:"#085"},{tag:he.className,color:"#167"},{tag:[he.special(he.variableName),he.macroName],color:"#256"},{tag:he.definition(he.propertyName),color:"#00c"},{tag:he.comment,color:"#940"},{tag:he.invalid,color:"#f00"}]),IL=Oe.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),sT=1e4,oT="()[]{}",aT=Ce.define({combine(n){return Pr(n,{afterCursor:!0,brackets:oT,maxScanDistance:sT,renderMatch:qL})}}),UL=Fe.mark({class:"cm-matchingBracket"}),FL=Fe.mark({class:"cm-nonmatchingBracket"});function qL(n){let e=[],t=n.matched?UL:FL;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function i2(n){let e=[],t=n.facet(aT);for(let i of n.selection.ranges){if(!i.empty)continue;let l=jr(n,i.head,-1,t)||i.head>0&&jr(n,i.head-1,1,t)||t.afterCursor&&(jr(n,i.head,1,t)||i.headn.decorations}),QL=[VL,IL];function XL(n={}){return[aT.of(n),QL]}const $L=new tt;function Ux(n,e,t){let i=n.prop(e<0?tt.openedBy:tt.closedBy);if(i)return i;if(n.name.length==1){let l=t.indexOf(n.name);if(l>-1&&l%2==(e<0?1:0))return[t[l+e]]}return null}function Fx(n){let e=n.type.prop($L);return e?e(n.node):n}function jr(n,e,t,i={}){let l=i.maxScanDistance||sT,o=i.brackets||oT,a=Un(n),u=a.resolveInner(e,t);for(let f=u;f;f=f.parent){let d=Ux(f.type,t,o);if(d&&f.from0?e>=m.from&&em.from&&e<=m.to))return YL(n,e,t,f,m,d,o)}}return GL(n,e,t,a,u.type,l,o)}function YL(n,e,t,i,l,o,a){let u=i.parent,f={from:l.from,to:l.to},d=0,m=u==null?void 0:u.cursor();if(m&&(t<0?m.childBefore(i.from):m.childAfter(i.to)))do if(t<0?m.to<=i.from:m.from>=i.to){if(d==0&&o.indexOf(m.type.name)>-1&&m.from0)return null;let d={from:t<0?e-1:e,to:t>0?e+1:e},m=n.doc.iterRange(e,t>0?n.doc.length:0),g=0;for(let b=0;!m.next().done&&b<=o;){let v=m.value;t<0&&(b+=v.length);let w=e+b*t;for(let S=t>0?0:v.length-1,C=t>0?v.length:-1;S!=C;S+=t){let N=a.indexOf(v[S]);if(!(N<0||i.resolveInner(w+S,1).type!=l))if(N%2==0==t>0)g++;else{if(g==1)return{start:d,end:{from:w+S,to:w+S+1},matched:N>>1==f>>1};g--}}t>0&&(b+=v.length)}return m.done?{start:d,matched:!1}:null}const KL=Object.create(null),r2=[xi.none],l2=[],s2=Object.create(null),WL=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])WL[n]=ZL(KL,e);function b0(n,e){l2.indexOf(n)>-1||(l2.push(n),console.warn(e))}function ZL(n,e){let t=[];for(let u of e.split(" ")){let f=[];for(let d of u.split(".")){let m=n[d]||he[d];m?typeof m=="function"?f.length?f=f.map(m):b0(d,`Modifier ${d} used at start of tag`):f.length?b0(d,`Tag ${d} used as modifier`):f=Array.isArray(m)?m:[m]:b0(d,`Unknown highlighting tag ${d}`)}for(let d of f)t.push(d)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),l=i+" "+t.map(u=>u.id),o=s2[l];if(o)return o.id;let a=s2[l]=xi.define({id:r2.length,name:i,props:[qN({[i]:t})]});return r2.push(a),a.id}Tt.RTL,Tt.LTR;const JL=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Xy(n.state,t.from);return i.line?ez(n):i.block?nz(n):!1};function Qy(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let l=n(e,t);return l?(i(t.update(l)),!0):!1}}const ez=Qy(lz,0),tz=Qy(cT,0),nz=Qy((n,e)=>cT(n,e,rz(e)),0);function Xy(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const Ic=50;function iz(n,{open:e,close:t},i,l){let o=n.sliceDoc(i-Ic,i),a=n.sliceDoc(l,l+Ic),u=/\s*$/.exec(o)[0].length,f=/^\s*/.exec(a)[0].length,d=o.length-u;if(o.slice(d-e.length,d)==e&&a.slice(f,f+t.length)==t)return{open:{pos:i-u,margin:u&&1},close:{pos:l+f,margin:f&&1}};let m,g;l-i<=2*Ic?m=g=n.sliceDoc(i,l):(m=n.sliceDoc(i,i+Ic),g=n.sliceDoc(l-Ic,l));let b=/^\s*/.exec(m)[0].length,v=/\s*$/.exec(g)[0].length,w=g.length-v-t.length;return m.slice(b,b+e.length)==e&&g.slice(w,w+t.length)==t?{open:{pos:i+b+e.length,margin:/\s/.test(m.charAt(b+e.length))?1:0},close:{pos:l-v-t.length,margin:/\s/.test(g.charAt(w-1))?1:0}}:null}function rz(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),l=t.to<=i.to?i:n.doc.lineAt(t.to);l.from>i.from&&l.from==t.to&&(l=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let o=e.length-1;o>=0&&e[o].to>i.from?e[o].to=l.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:l.to})}return e}function cT(n,e,t=e.selection.ranges){let i=t.map(o=>Xy(e,o.from).block);if(!i.every(o=>o))return null;let l=t.map((o,a)=>iz(e,i[a],o.from,o.to));if(n!=2&&!l.every(o=>o))return{changes:e.changes(t.map((o,a)=>l[a]?[]:[{from:o.from,insert:i[a].open+" "},{from:o.to,insert:" "+i[a].close}]))};if(n!=1&&l.some(o=>o)){let o=[];for(let a=0,u;al&&(o==a||a>g.from)){l=g.from;let b=/^\s*/.exec(g.text)[0].length,v=b==g.length,w=g.text.slice(b,b+d.length)==d?b:-1;bo.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:u,token:f,indent:d,empty:m,single:g}of i)(g||!m)&&o.push({from:u.from+d,insert:f+" "});let a=e.changes(o);return{changes:a,selection:e.selection.map(a,1)}}else if(n!=1&&i.some(o=>o.comment>=0)){let o=[];for(let{line:a,comment:u,token:f}of i)if(u>=0){let d=a.from+u,m=d+f.length;a.text[m-a.from]==" "&&m++,o.push({from:d,to:m})}return{changes:o}}return null}const qx=ul.define(),sz=ul.define(),oz=Ce.define(),uT=Ce.define({combine(n){return Pr(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,l)=>e(i,l)||t(i,l)})}}),fT=Fn.define({create(){return _r.empty},update(n,e){let t=e.state.facet(uT),i=e.annotation(qx);if(i){let f=gi.fromTransaction(e,i.selection),d=i.side,m=d==0?n.undone:n.done;return f?m=Ad(m,m.length,t.minDepth,f):m=mT(m,e.startState.selection),new _r(d==0?i.rest:m,d==0?m:i.rest)}let l=e.annotation(sz);if((l=="full"||l=="before")&&(n=n.isolate()),e.annotation(pn.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let o=gi.fromTransaction(e),a=e.annotation(pn.time),u=e.annotation(pn.userEvent);return o?n=n.addChanges(o,a,u,t,e):e.selection&&(n=n.addSelection(e.startState.selection,a,u,t.newGroupDelay)),(l=="full"||l=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new _r(n.done.map(gi.fromJSON),n.undone.map(gi.fromJSON))}});function az(n={}){return[fT,uT.of(n),Oe.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?hT:e.inputType=="historyRedo"?Vx:null;return i?(e.preventDefault(),i(t)):!1}})]}function lm(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let l=t.field(fT,!1);if(!l)return!1;let o=l.pop(n,t,e);return o?(i(o),!0):!1}}const hT=lm(0,!1),Vx=lm(1,!1),cz=lm(0,!0),uz=lm(1,!0);class gi{constructor(e,t,i,l,o){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=l,this.selectionsAfter=o}setSelAfter(e){return new gi(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(e){return new gi(e.changes&&mn.fromJSON(e.changes),[],e.mapped&&zr.fromJSON(e.mapped),e.startSelection&&oe.fromJSON(e.startSelection),e.selectionsAfter.map(oe.fromJSON))}static fromTransaction(e,t){let i=qi;for(let l of e.startState.facet(oz)){let o=l(e);o.length&&(i=i.concat(o))}return!i.length&&e.changes.empty?null:new gi(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,qi)}static selection(e){return new gi(void 0,qi,void 0,void 0,e)}}function Ad(n,e,t,i){let l=e+1>t+20?e-t-1:0,o=n.slice(l,e);return o.push(i),o}function fz(n,e){let t=[],i=!1;return n.iterChangedRanges((l,o)=>t.push(l,o)),e.iterChangedRanges((l,o,a,u)=>{for(let f=0;f=d&&a<=m&&(i=!0)}}),i}function hz(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function dT(n,e){return n.length?e.length?n.concat(e):n:e}const qi=[],dz=200;function mT(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-dz));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Ad(n,n.length-1,1e9,t.setSelAfter(i)))}else return[gi.selection([e])]}function mz(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function v0(n,e){if(!n.length)return n;let t=n.length,i=qi;for(;t;){let l=pz(n[t-1],e,i);if(l.changes&&!l.changes.empty||l.effects.length){let o=n.slice(0,t);return o[t-1]=l,o}else e=l.mapped,t--,i=l.selectionsAfter}return i.length?[gi.selection(i)]:qi}function pz(n,e,t){let i=dT(n.selectionsAfter.length?n.selectionsAfter.map(u=>u.map(e)):qi,t);if(!n.changes)return gi.selection(i);let l=n.changes.map(e),o=e.mapDesc(n.changes,!0),a=n.mapped?n.mapped.composeDesc(o):o;return new gi(l,Ke.mapEffects(n.effects,e),a,n.startSelection.map(o),i)}const gz=/^(input\.type|delete)($|\.)/;class _r{constructor(e,t,i=0,l=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=l}isolate(){return this.prevTime?new _r(this.done,this.undone):this}addChanges(e,t,i,l,o){let a=this.done,u=a[a.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!i||gz.test(i))&&(!u.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):sm(t,e))}function qn(n){return n.textDirectionAt(n.state.selection.main.head)==Tt.LTR}const gT=n=>pT(n,!qn(n)),xT=n=>pT(n,qn(n));function yT(n,e){return ar(n,t=>t.empty?n.moveByGroup(t,e):sm(t,e))}const yz=n=>yT(n,!qn(n)),bz=n=>yT(n,qn(n));function vz(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function om(n,e,t){let i=Un(n).resolveInner(e.head),l=t?tt.closedBy:tt.openedBy;for(let f=e.head;;){let d=t?i.childAfter(f):i.childBefore(f);if(!d)break;vz(n,d,l)?i=d:f=t?d.to:d.from}let o=i.type.prop(l),a,u;return o&&(a=t?jr(n,i.from,1):jr(n,i.to,-1))&&a.matched?u=t?a.end.to:a.end.from:u=t?i.to:i.from,oe.cursor(u,t?-1:1)}const wz=n=>ar(n,e=>om(n.state,e,!qn(n))),kz=n=>ar(n,e=>om(n.state,e,qn(n)));function bT(n,e){return ar(n,t=>{if(!t.empty)return sm(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const vT=n=>bT(n,!1),wT=n=>bT(n,!0);function kT(n){let e=n.scrollDOM.clientHeighta.empty?n.moveVertically(a,e,t.height):sm(a,e));if(l.eq(i.selection))return!1;let o;if(t.selfScroll){let a=n.coordsAtPos(i.selection.main.head),u=n.scrollDOM.getBoundingClientRect(),f=u.top+t.marginTop,d=u.bottom-t.marginBottom;a&&a.top>f&&a.bottomST(n,!1),Qx=n=>ST(n,!0);function hs(n,e,t){let i=n.lineBlockAt(e.head),l=n.moveToLineBoundary(e,t);if(l.head==e.head&&l.head!=(t?i.to:i.from)&&(l=n.moveToLineBoundary(e,t,!1)),!t&&l.head==i.from&&i.length){let o=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;o&&e.head!=i.from+o&&(l=oe.cursor(i.from+o))}return l}const Sz=n=>ar(n,e=>hs(n,e,!0)),Cz=n=>ar(n,e=>hs(n,e,!1)),Oz=n=>ar(n,e=>hs(n,e,!qn(n))),Nz=n=>ar(n,e=>hs(n,e,qn(n))),Tz=n=>ar(n,e=>n.moveToLineBoundary(e,!1,!1)),Az=n=>ar(n,e=>n.moveToLineBoundary(e,!0,!1));function Ez(n,e,t){let i=!1,l=_a(n.selection,o=>{let a=jr(n,o.head,-1)||jr(n,o.head,1)||o.head>0&&jr(n,o.head-1,1)||o.headEz(n,e);function Xi(n,e,t){let i=_a(n.state.selection,l=>{l.undirectional&&l.head>=l.anchor!=e&&(l=oe.range(l.head,l.anchor));let o=t(l);return oe.range(l.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return i.eq(n.state.selection)?!1:(n.dispatch(or(n.state,i)),!0)}function CT(n,e){return Xi(n,e,t=>n.moveByChar(t,e))}const OT=n=>CT(n,!qn(n)),NT=n=>CT(n,qn(n));function TT(n,e){return Xi(n,e,t=>n.moveByGroup(t,e))}const Dz=n=>TT(n,!qn(n)),Rz=n=>TT(n,qn(n)),jz=n=>{let e=!qn(n);return Xi(n,e,t=>om(n.state,t,e))},_z=n=>{let e=qn(n);return Xi(n,e,t=>om(n.state,t,e))};function AT(n,e){return Xi(n,e,t=>n.moveVertically(t,e))}const ET=n=>AT(n,!1),MT=n=>AT(n,!0);function DT(n,e){return Xi(n,e,t=>n.moveVertically(t,e,kT(n).height))}const a2=n=>DT(n,!1),c2=n=>DT(n,!0),Lz=n=>Xi(n,!0,e=>hs(n,e,!0)),zz=n=>Xi(n,!1,e=>hs(n,e,!1)),Bz=n=>{let e=!qn(n);return Xi(n,e,t=>hs(n,t,e))},Pz=n=>{let e=qn(n);return Xi(n,e,t=>hs(n,t,e))},Hz=n=>Xi(n,!1,e=>oe.cursor(n.lineBlockAt(e.head).from)),Iz=n=>Xi(n,!0,e=>oe.cursor(n.lineBlockAt(e.head).to)),u2=({state:n,dispatch:e})=>(e(or(n,{anchor:0})),!0),f2=({state:n,dispatch:e})=>(e(or(n,{anchor:n.doc.length})),!0),h2=({state:n,dispatch:e})=>(e(or(n,{anchor:n.selection.main.anchor,head:0})),!0),d2=({state:n,dispatch:e})=>(e(or(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),Uz=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Fz=({state:n,dispatch:e})=>{let t=am(n).map(({from:i,to:l})=>oe.undirectionalRange(i,Math.min(l+1,n.doc.length)));return e(n.update({selection:oe.create(t),userEvent:"select"})),!0},qz=({state:n,dispatch:e})=>{let t=_a(n.selection,i=>{let l=Un(n),o=l.resolveStack(i.from,1);if(i.empty){let a=l.resolveStack(i.from,-1);a.node.from>=o.node.from&&a.node.to<=o.node.to&&(o=a)}for(let a=o;a;a=a.next){let{node:u}=a;if((u.from=i.to||u.to>i.to&&u.from<=i.from)&&a.next)return oe.undirectionalRange(u.from,u.to)}return i});return t.eq(n.selection)?!1:(e(or(n,t)),!0)};function RT(n,e){let{state:t}=n,i=t.selection,l=t.selection.ranges.slice();for(let o of t.selection.ranges){let a=t.doc.lineAt(o.head);if(e?a.to0)for(let u=o;;){let f=n.moveVertically(u,e);if(f.heada.to){l.some(d=>d.head==f.head)||l.push(f);break}else{if(f.head==u.head)break;u=f}}}return l.length==i.ranges.length?!1:(n.dispatch(or(t,oe.create(l,l.length-1))),!0)}const Vz=n=>RT(n,!1),Qz=n=>RT(n,!0),Xz=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=oe.create([t.main]):t.main.empty||(i=oe.create([oe.cursor(t.main.head)])),i?(e(or(n,i)),!0):!1};function Du(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,l=i.changeByRange(o=>{let{from:a,to:u}=o;if(a==u){let f=e(o);fa&&(t="delete.forward",f=Rh(n,f,!0)),a=Math.min(a,f),u=Math.max(u,f)}else a=Rh(n,a,!1),u=Rh(n,u,!0);return a==u?{range:o}:{changes:{from:a,to:u},range:oe.cursor(a,al(n)))i.between(e,e,(l,o)=>{le&&(e=t?o:l)});return e}const jT=(n,e,t)=>Du(n,i=>{let l=i.from,{state:o}=n,a=o.doc.lineAt(l),u,f;if(t&&!e&&l>a.from&&ljT(n,!1,!0),_T=n=>jT(n,!0,!1),LT=(n,e)=>Du(n,t=>{let i=t.head,{state:l}=n,o=l.doc.lineAt(i),a=l.charCategorizer(i);for(let u=null;;){if(i==(e?o.to:o.from)){i==t.head&&o.number!=(e?l.doc.lines:1)&&(i+=e?1:-1);break}let f=On(o.text,i-o.from,e)+o.from,d=o.text.slice(Math.min(i,f)-o.from,Math.max(i,f)-o.from),m=a(d);if(u!=null&&m!=u)break;(d!=" "||i!=t.head)&&(u=m),i=f}return i}),zT=n=>LT(n,!1),$z=n=>LT(n,!0),Yz=n=>Du(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headDu(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Kz=n=>Du(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:mt.of(["",""])},range:oe.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Zz=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let l=i.from,o=n.doc.lineAt(l),a=l==o.from?l-1:On(o.text,l-o.from,!1)+o.from,u=l==o.to?l+1:On(o.text,l-o.from,!0)+o.from;return{changes:{from:a,to:u,insert:n.doc.slice(l,u).append(n.doc.slice(a,l))},range:oe.cursor(u)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function am(n){let e=[],t=-1;for(let i of n.selection.ranges){let l=n.doc.lineAt(i.from),o=n.doc.lineAt(i.to);if(!i.empty&&i.to==o.from&&(o=n.doc.lineAt(i.to-1)),t>=l.number){let a=e[e.length-1];a.to=o.to,a.ranges.push(i)}else e.push({from:l.from,to:o.to,ranges:[i]});t=o.number+1}return e}function BT(n,e,t){if(n.readOnly)return!1;let i=[],l=[];for(let o of am(n)){if(t?o.to==n.doc.length:o.from==0)continue;let a=n.doc.lineAt(t?o.to+1:o.from-1),u=a.length+1;if(t){i.push({from:o.to,to:a.to},{from:o.from,insert:a.text+n.lineBreak});for(let f of o.ranges)l.push(oe.range(Math.min(n.doc.length,f.anchor+u),Math.min(n.doc.length,f.head+u)))}else{i.push({from:a.from,to:o.from},{from:o.to,insert:n.lineBreak+a.text});for(let f of o.ranges)l.push(oe.range(f.anchor-u,f.head-u))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:oe.create(l,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Jz=({state:n,dispatch:e})=>BT(n,e,!1),e6=({state:n,dispatch:e})=>BT(n,e,!0);function PT(n,e,t){if(n.readOnly)return!1;let i=[];for(let o of am(n))t?i.push({from:o.from,insert:n.doc.slice(o.from,o.to)+n.lineBreak}):i.push({from:o.to,insert:n.lineBreak+n.doc.slice(o.from,o.to)});let l=n.changes(i);return e(n.update({changes:l,selection:n.selection.map(l,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const t6=({state:n,dispatch:e})=>PT(n,e,!1),n6=({state:n,dispatch:e})=>PT(n,e,!0),i6=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(am(e).map(({from:l,to:o})=>(l>0?l--:o{let o;if(n.lineWrapping){let a=n.lineBlockAt(l.head),u=n.coordsAtPos(l.head,l.assoc||1);u&&(o=a.bottom+n.documentTop-u.bottom+n.defaultLineHeight/2)}return n.moveVertically(l,!0,o)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function r6(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Un(n).resolveInner(e),i=t.childBefore(e),l=t.childAfter(e),o;return i&&l&&i.to<=e&&l.from>=e&&(o=i.type.prop(tt.closedBy))&&o.indexOf(l.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(l.from).from&&!/\S/.test(n.sliceDoc(i.to,l.from))?{from:i.to,to:l.from}:null}const m2=HT(!1),l6=HT(!0);function HT(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(l=>{let{from:o,to:a}=l,u=e.doc.lineAt(o),f=!n&&o==a&&r6(e,o);n&&(o=a=(a<=u.to?u:e.doc.lineAt(a)).to);let d=new im(e,{simulateBreak:o,simulateDoubleBreak:!!f}),m=qy(d,o);for(m==null&&(m=ja(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));au.from&&o{let l=[];for(let a=i.from;a<=i.to;){let u=n.doc.lineAt(a);u.number>t&&(i.empty||i.to>u.from)&&(e(u,l,i),t=u.number),a=u.to+1}let o=n.changes(l);return{changes:l,range:oe.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}})}const s6=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new im(n,{overrideIndentation:o=>{let a=t[o];return a??-1}}),l=$y(n,(o,a,u)=>{let f=qy(i,o.from);if(f==null)return;/\S/.test(o.text)||(f=0);let d=/^\s*/.exec(o.text)[0],m=xu(n,f);(d!=m||u.fromn.readOnly?!1:(e(n.update($y(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Fy)})}),{userEvent:"input.indent"})),!0),a6=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update($y(n,(t,i)=>{let l=/^\s*/.exec(t.text)[0];if(!l)return;let o=ja(l,n.tabSize),a=0,u=xu(n,Math.max(0,o-Od(n)));for(;a(n.setTabFocusMode(),!0),u6=[{key:"Ctrl-b",run:gT,shift:OT,preventDefault:!0},{key:"Ctrl-f",run:xT,shift:NT},{key:"Ctrl-p",run:vT,shift:ET},{key:"Ctrl-n",run:wT,shift:MT},{key:"Ctrl-a",run:Tz,shift:Hz},{key:"Ctrl-e",run:Az,shift:Iz},{key:"Ctrl-d",run:_T},{key:"Ctrl-h",run:Xx},{key:"Ctrl-k",run:Yz},{key:"Ctrl-Alt-h",run:zT},{key:"Ctrl-o",run:Wz},{key:"Ctrl-t",run:Zz},{key:"Ctrl-v",run:Qx}],f6=[{key:"ArrowLeft",run:gT,shift:OT,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:yz,shift:Dz,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Oz,shift:Bz,preventDefault:!0},{key:"ArrowRight",run:xT,shift:NT,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:bz,shift:Rz,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Nz,shift:Pz,preventDefault:!0},{key:"ArrowUp",run:vT,shift:ET,preventDefault:!0},{mac:"Cmd-ArrowUp",run:u2,shift:h2},{mac:"Ctrl-ArrowUp",run:o2,shift:a2},{key:"ArrowDown",run:wT,shift:MT,preventDefault:!0},{mac:"Cmd-ArrowDown",run:f2,shift:d2},{mac:"Ctrl-ArrowDown",run:Qx,shift:c2},{key:"PageUp",run:o2,shift:a2},{key:"PageDown",run:Qx,shift:c2},{key:"Home",run:Cz,shift:zz,preventDefault:!0},{key:"Mod-Home",run:u2,shift:h2},{key:"End",run:Sz,shift:Lz,preventDefault:!0},{key:"Mod-End",run:f2,shift:d2},{key:"Enter",run:m2,shift:m2},{key:"Mod-a",run:Uz},{key:"Backspace",run:Xx,shift:Xx,preventDefault:!0},{key:"Delete",run:_T,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:zT,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:$z,preventDefault:!0},{mac:"Mod-Backspace",run:Gz,preventDefault:!0},{mac:"Mod-Delete",run:Kz,preventDefault:!0}].concat(u6.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),h6=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:wz,shift:jz},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:kz,shift:_z},{key:"Alt-ArrowUp",run:Jz},{key:"Shift-Alt-ArrowUp",run:t6},{key:"Alt-ArrowDown",run:e6},{key:"Shift-Alt-ArrowDown",run:n6},{key:"Mod-Alt-ArrowUp",run:Vz},{key:"Mod-Alt-ArrowDown",run:Qz},{key:"Escape",run:Xz},{key:"Mod-Enter",run:l6},{key:"Alt-l",mac:"Ctrl-l",run:Fz},{key:"Mod-i",run:qz,preventDefault:!0},{key:"Mod-[",run:a6},{key:"Mod-]",run:o6},{key:"Mod-Alt-\\",run:s6},{key:"Shift-Mod-k",run:i6},{key:"Shift-Mod-\\",run:Mz},{key:"Mod-/",run:JL},{key:"Alt-A",mac:"Ctrl-A",run:tz},{key:"Ctrl-m",mac:"Shift-Alt-m",run:c6}].concat(f6),p2=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class Da{constructor(e,t,i=0,l=e.length,o,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,l),this.bufferStart=i,this.normalize=o?u=>o(p2(u)):p2,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return hi(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=vy(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Mr(e);let l=this.normalize(t);if(l.length)for(let o=0,a=i,u=!0;;o++){let f=l.charCodeAt(o),d=this.match(f,a,u,this.bufferPos+this.bufferStart,o==l.length-1);if(d)return this.value=d,this;if(o==l.length-1)break;u&&othis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,l=i+t[0].length;if(this.matchPos=Ed(this.text,l+(i==l?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,l,t)))return this.value={from:i,to:l,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=i||l.to<=t){let u=new ya(t,e.sliceString(t,i));return w0.set(e,u),u}if(l.from==t&&l.to==i)return l;let{text:o,from:a}=l;return a>t&&(o=e.sliceString(t,a)+o,a=t),l.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,l=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,l,t)))return this.value={from:i,to:l,precise:!0,match:t},this.matchPos=Ed(this.text,l+(i==l?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ya.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(UT.prototype[Symbol.iterator]=FT.prototype[Symbol.iterator]=function(){return this});function d6(n){try{return new RegExp(n,Yy),!0}catch{return!1}}function Ed(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e=56320&&i<57344;)e++;return e}const m6=n=>{let e=R_(n,"cm-goto-line");if(e){let a=e.dom.querySelector("input[type=text]");return a&&a.select(),!0}let{state:t}=n,i=String(t.doc.lineAt(n.state.selection.main.head).number),{close:l,result:o}=D_(n,{class:"cm-goto-line",label:t.phrase("Go to line"),input:{type:"text",name:"line",value:i},focus:!0,submitLabel:t.phrase("go")});return o.then(a=>{let u=a&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(a.elements.line.value);if(!u){n.dispatch({effects:l});return}let f=t.doc.lineAt(t.selection.main.head),[,d,m,g,b]=u,v=g?+g.slice(1):0,w=m?+m:f.number;if(m&&b){let N=w/100;d&&(N=N*(d=="-"?-1:1)+f.number/t.doc.lines),w=Math.round(t.doc.lines*N)}else m&&d&&(w=w*(d=="-"?-1:1)+f.number);let S=t.doc.line(Math.max(1,Math.min(t.doc.lines,w))),C=oe.cursor(S.from+Math.max(0,Math.min(v,S.length)));n.dispatch({effects:[l,Oe.scrollIntoView(C.from,{y:"center"})],selection:C})}),!0},p6={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},g6=Ce.define({combine(n){return Pr(n,p6,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function x6(n){return[k6,w6]}const y6=Fe.mark({class:"cm-selectionMatch"}),b6=Fe.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function g2(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=Ft.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=Ft.Word)}function v6(n,e,t,i){return n(e.sliceDoc(t,t+1))==Ft.Word&&n(e.sliceDoc(i-1,i))==Ft.Word}const w6=en.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(g6),{state:t}=n,i=t.selection;if(i.ranges.length>1)return Fe.none;let l=i.main,o,a=null;if(l.empty){if(!e.highlightWordAroundCursor)return Fe.none;let f=t.wordAt(l.head);if(!f)return Fe.none;a=t.charCategorizer(l.head),o=t.sliceDoc(f.from,f.to)}else{let f=l.to-l.from;if(f200)return Fe.none;if(e.wholeWords){if(o=t.sliceDoc(l.from,l.to),a=t.charCategorizer(l.head),!(g2(a,t,l.from,l.to)&&v6(a,t,l.from,l.to)))return Fe.none}else if(o=t.sliceDoc(l.from,l.to),!o)return Fe.none}let u=[];for(let f of n.visibleRanges){let d=new Da(t.doc,o,f.from,f.to);for(;!d.next().done;){let{from:m,to:g}=d.value;if((!a||g2(a,t,m,g))&&(l.empty&&m<=l.from&&g>=l.to?u.push(b6.range(m,g)):(m>=l.to||g<=l.from)&&u.push(y6.range(m,g)),u.length>e.maxMatches))return Fe.none}}return Fe.set(u)}},{decorations:n=>n.decorations}),k6=Oe.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),S6=({state:n,dispatch:e})=>{let{selection:t}=n,i=oe.create(t.ranges.map(l=>n.wordAt(l.head)||oe.cursor(l.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function C6(n,e){let{main:t,ranges:i}=n.selection,l=n.wordAt(t.head),o=l&&l.from==t.from&&l.to==t.to;for(let a=!1,u=new Da(n.doc,e,i[i.length-1].to);;)if(u.next(),u.done){if(a)return null;u=new Da(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),a=!0}else{if(a&&i.some(f=>f.from==u.value.from))continue;if(o){let f=n.wordAt(u.value.from);if(!f||f.from!=u.value.from||f.to!=u.value.to)continue}return u.value}}const O6=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(o=>o.from===o.to))return S6({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(o=>n.sliceDoc(o.from,o.to)!=i))return!1;let l=C6(n,i);return l?(e(n.update({selection:n.selection.addRange(oe.range(l.from,l.to),!1),effects:Oe.scrollIntoView(l.to)})),!0):!1},La=Ce.define({combine(n){return Pr(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new H6(e),scrollToMatch:e=>Oe.scrollIntoView(e)})}});class qT{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||d6(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?` +`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new D6(this):new A6(this)}getCursor(e,t=0,i){let l=e.doc?e:gt.create({doc:e});return i==null&&(i=l.doc.length),this.regexp?ra(this,l,t,i):ia(this,l,t,i)}}class VT{constructor(e){this.spec=e}}function N6(n,e,t){return(i,l,o,a)=>{if(t&&!t(i,l,o,a))return!1;let u=i>=a&&l<=a+o.length?o.slice(i-a,l-a):e.doc.sliceString(i,l);return n(u,e,i,l)}}function ia(n,e,t,i){let l;return n.wholeWord&&(l=T6(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(l=N6(n.test,e,l)),new Da(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:o=>o.toLowerCase(),l)}function T6(n,e){return(t,i,l,o)=>((o>t||o+l.length=t)return null;l.push(i.value)}return l}highlight(e,t,i,l){let o=ia(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!o.next().done;)l(o.value.from,o.value.to)}}function E6(n,e,t){return(i,l,o)=>(!t||t(i,l,o))&&n(o[0],e,i,l)}function ra(n,e,t,i){let l;return n.wholeWord&&(l=M6(e.charCategorizer(e.selection.main.head))),n.test&&(l=E6(n.test,e,l)),new UT(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:l},t,i)}function Md(n,e){return n.slice(On(n,e,!1),e)}function Dd(n,e){return n.slice(e,On(n,e))}function M6(n){return(e,t,i)=>!i[0].length||(n(Md(i.input,i.index))!=Ft.Word||n(Dd(i.input,i.index))!=Ft.Word)&&(n(Dd(i.input,i.index+i[0].length))!=Ft.Word||n(Md(i.input,i.index+i[0].length))!=Ft.Word)}class D6 extends VT{nextMatch(e,t,i){let l=ra(this.spec,e,i,e.doc.length).next();return l.done&&(l=ra(this.spec,e,0,t).next()),l.done?null:l.value}prevMatchInRange(e,t,i){for(let l=1;;l++){let o=Math.max(t,i-l*1e4),a=ra(this.spec,e,o,i),u=null;for(;!a.next().done;)u=a.value;if(u&&(o==t||u.from>o+10))return u;if(o==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let l=i.length;l>0;l--){let o=+i.slice(0,l);if(o>0&&o=t)return null;l.push(i.value)}return l}highlight(e,t,i,l){let o=ra(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!o.next().done;)l(o.value.from,o.value.to)}}const yu=Ke.define(),Gy=Ke.define(),ts=Fn.define({create(n){return new k0($x(n).create(),null)},update(n,e){for(let t of e.effects)t.is(yu)?n=new k0(t.value.create(),n.panel):t.is(Gy)&&(n=new k0(n.query,t.value?Ky:null));return n},provide:n=>mu.from(n,e=>e.panel)});class k0{constructor(e,t){this.query=e,this.panel=t}}const R6=Fe.mark({class:"cm-searchMatch"}),j6=Fe.mark({class:"cm-searchMatch cm-searchMatch-selected"}),_6=en.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(ts))}update(n){let e=n.state.field(ts);(e!=n.startState.field(ts)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return Fe.none;let{view:t}=this,i=new Br;for(let l=0,o=t.visibleRanges,a=o.length;lo[l+1].from-500;)f=o[++l].to;n.highlight(t.state,u,f,(d,m)=>{let g=t.state.selection.ranges.some(b=>b.from==d&&b.to==m);i.add(d,m,g?j6:R6)})}return i.finish()}},{decorations:n=>n.decorations});function Ru(n){return e=>{let t=e.state.field(ts,!1);return t&&t.query.spec.valid?n(e,t):$T(e)}}const Rd=Ru((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let l=oe.single(i.from,i.to),o=n.state.facet(La);return n.dispatch({selection:l,effects:[Wy(n,i),o.scrollToMatch(l.main,n)],userEvent:"select.search"}),XT(n),!0}),jd=Ru((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,l=e.prevMatch(t,i,i);if(!l)return!1;let o=oe.single(l.from,l.to),a=n.state.facet(La);return n.dispatch({selection:o,effects:[Wy(n,l),a.scrollToMatch(o.main,n)],userEvent:"select.search"}),XT(n),!0}),L6=Ru((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:oe.create(t.map(i=>oe.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),z6=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:l}=t.main,o=[],a=0;for(let u=new Da(n.doc,n.sliceDoc(i,l));!u.next().done;){if(o.length>1e3)return!1;u.value.from==i&&(a=o.length),o.push(oe.range(u.value.from,u.value.to))}return e(n.update({selection:oe.create(o,a),userEvent:"select.search.matches"})),!0},x2=Ru((n,{query:e})=>{let{state:t}=n,{from:i,to:l}=t.selection.main;if(t.readOnly)return!1;let o=e.nextMatch(t,i,i);if(!o)return!1;let a=o,u=[],f,d,m=[];a.precise?a.from==i&&a.to==l&&(d=t.toText(e.getReplacement(a)),u.push({from:a.from,to:a.to,insert:d}),a=e.nextMatch(t,a.from,a.to),m.push(Oe.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):a=e.nextMatch(t,a.from,a.to);let g=n.state.changes(u);return a&&(f=oe.single(a.from,a.to).map(g),m.push(Wy(n,a)),m.push(t.facet(La).scrollToMatch(f.main,n))),n.dispatch({changes:g,selection:f,effects:m,userEvent:"input.replace"}),!0}),B6=Ru((n,{query:e})=>{if(n.state.readOnly)return!1;let t=[];for(let l of e.matchAll(n.state,1e9)){let{from:o,to:a,precise:u}=l;u&&t.push({from:o,to:a,insert:e.getReplacement(l)})}if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:Oe.announce.of(i),userEvent:"input.replace.all"}),!0});function Ky(n){return n.state.facet(La).createPanel(n)}function $x(n,e){var t,i,l,o,a;let u=n.selection.main,f=u.empty||u.to>u.from+100?"":n.sliceDoc(u.from,u.to);if(e&&!f)return e;let d=n.facet(La);return new qT({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:d.literal)?f:f.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:d.caseSensitive,literal:(l=e==null?void 0:e.literal)!==null&&l!==void 0?l:d.literal,regexp:(o=e==null?void 0:e.regexp)!==null&&o!==void 0?o:d.regexp,wholeWord:(a=e==null?void 0:e.wholeWord)!==null&&a!==void 0?a:d.wholeWord})}function QT(n){let e=nm(n,Ky);return e&&e.dom.querySelector("[main-field]")}function XT(n){let e=QT(n);e&&e==n.root.activeElement&&e.select()}const $T=n=>{let e=n.state.field(ts,!1);if(e&&e.panel){let t=QT(n);if(t&&t!=n.root.activeElement){let i=$x(n.state,e.query.spec);i.valid&&n.dispatch({effects:yu.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Gy.of(!0),e?yu.of($x(n.state,e.query.spec)):Ke.appendConfig.of(U6)]});return!0},YT=n=>{let e=n.state.field(ts,!1);if(!e||!e.panel)return!1;let t=nm(n,Ky);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Gy.of(!1)}),!0},P6=[{key:"Mod-f",run:$T,scope:"editor search-panel"},{key:"F3",run:Rd,shift:jd,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Rd,shift:jd,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:YT,scope:"editor search-panel"},{key:"Mod-Shift-l",run:z6},{key:"Mod-Alt-g",run:m6},{key:"Mod-d",run:O6,preventDefault:!0}];class H6{constructor(e){this.view=e;let t=this.query=e.state.field(ts).query.spec;this.commit=this.commit.bind(this),this.searchField=Nt("input",{value:t.search,placeholder:Ti(e,"Find"),"aria-label":Ti(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Nt("input",{value:t.replace,placeholder:Ti(e,"Replace"),"aria-label":Ti(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Nt("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Nt("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Nt("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(l,o,a){return Nt("button",{class:"cm-button",name:l,onclick:o,type:"button"},a)}this.dom=Nt("div",{onkeydown:l=>this.keydown(l),class:"cm-search"},[this.searchField,i("next",()=>Rd(e),[Ti(e,"next")]),i("prev",()=>jd(e),[Ti(e,"previous")]),i("select",()=>L6(e),[Ti(e,"all")]),Nt("label",null,[this.caseField,Ti(e,"match case")]),Nt("label",null,[this.reField,Ti(e,"regexp")]),Nt("label",null,[this.wordField,Ti(e,"by word")]),...e.state.readOnly?[]:[Nt("br"),this.replaceField,i("replace",()=>x2(e),[Ti(e,"replace")]),i("replaceAll",()=>B6(e),[Ti(e,"replace all")])],Nt("button",{name:"close",onclick:()=>YT(e),"aria-label":Ti(e,"close"),type:"button"},["×"])])}commit(){let e=new qT({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:yu.of(e)}))}keydown(e){Uj(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?jd:Rd)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),x2(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(yu)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(La).top}}function Ti(n,e){return n.state.phrase(e)}const jh=30,_h=/[\s\.,:;?!]/;function Wy(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),l=n.state.doc.lineAt(t).to,o=Math.max(i.from,e-jh),a=Math.min(l,t+jh),u=n.state.sliceDoc(o,a);if(o!=i.from){for(let f=0;fu.length-jh;f--)if(!_h.test(u[f-1])&&_h.test(u[f])){u=u.slice(0,f);break}}return Oe.announce.of(`${n.state.phrase("current match")}. ${u} ${n.state.phrase("on line")} ${i.number}.`)}const I6=Oe.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),U6=[ts,ao.low(_6),I6];class GT{constructor(e,t,i,l){this.state=e,this.pos=t,this.explicit=i,this.view=l,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Un(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),l=t.text.slice(i-t.from,this.pos-t.from),o=l.search(KT(e,!1));return o<0?null:{from:i+o,to:this.pos,text:l.slice(o)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function y2(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function F6(n){let e=Object.create(null),t=Object.create(null);for(let{label:l}of n){e[l[0]]=!0;for(let o=1;otypeof l=="string"?{label:l}:l),[t,i]=e.every(l=>/^\w+$/.test(l.label))?[/\w*$/,/\w+$/]:F6(e);return l=>{let o=l.matchBefore(i);return o||l.explicit?{from:o?o.from:l.pos,options:e,validFor:t}:null}}class b2{constructor(e,t,i,l){this.completion=e,this.source=t,this.match=i,this.score=l}}function no(n){return n.selection.main.from}function KT(n,e){var t;let{source:i}=n,l=e&&i[0]!="^",o=i[i.length-1]!="$";return!l&&!o?n:new RegExp(`${l?"^":""}(?:${i})${o?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const WT=ul.define();function V6(n,e,t,i){let{main:l}=n.selection,o=t-l.from,a=i-l.from;return{...n.changeByRange(u=>{if(u!=l&&t!=i&&n.sliceDoc(u.from+o,u.from+a)!=n.sliceDoc(t,i))return{range:u};let f=n.toText(e);return{changes:{from:u.from+o,to:i==l.from?u.to:u.from+a,insert:f},range:oe.cursor(u.from+o+f.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const v2=new WeakMap;function Q6(n){if(!Array.isArray(n))return n;let e=v2.get(n);return e||v2.set(n,e=q6(n)),e}const _d=Ke.define(),bu=Ke.define();class X6{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&U<=57||U>=97&&U<=122?2:U>=65&&U<=90?1:0:(E=vy(U))!=E.toLowerCase()?1:E!=E.toUpperCase()?2:0;(!j||T==1&&C||I==0&&T!=0)&&(t[g]==U||i[g]==U&&(b=!0)?a[g++]=j:a.length&&(N=!1)),I=T,j+=Mr(U)}return g==f&&a[0]==0&&N?this.result(-100+(b?-200:0),a,e):v==f&&w==0?this.ret(-200-e.length+(S==e.length?0:-100),[0,S]):u>-1?this.ret(-700-e.length,[u,u+this.pattern.length]):v==f?this.ret(-900-e.length,[w,S]):g==f?this.result(-100+(b?-200:0)+-700+(N?0:-1100),a,e):t.length==2?null:this.result((l[0]?-700:0)+-200+-1100,l,e)}result(e,t,i){let l=[],o=0;for(let a of t){let u=a+(this.astral?Mr(hi(i,a)):1);o&&l[o-1]==a?l[o-1]=u:(l[o++]=a,l[o++]=u)}return this.ret(e-i.length,l)}}class $6{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Y6,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>w2(e(i),t(i)),optionClass:(e,t)=>i=>w2(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function w2(n,e){return n?e?n+" "+e:n:e}function Y6(n,e,t,i,l,o){let a=n.textDirection==Tt.RTL,u=a,f=!1,d="top",m,g,b=e.left-l.left,v=l.right-e.right,w=i.right-i.left,S=i.bottom-i.top;if(u&&b=S||j>e.top?m=t.bottom-e.top:(d="bottom",m=e.bottom-t.top)}let C=(e.bottom-e.top)/o.offsetHeight,N=(e.right-e.left)/o.offsetWidth;return{style:`${d}: ${m/C}px; max-width: ${g/N}px`,class:"cm-completionInfo-"+(f?a?"left-narrow":"right-narrow":u?"left":"right")}}const Zy=Ke.define();function G6(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(l=>"cm-completionIcon-"+l)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,l,o){let a=document.createElement("span");a.className="cm-completionLabel";let u=t.displayLabel||t.label,f=0;for(let d=0;df&&a.appendChild(document.createTextNode(u.slice(f,m)));let b=a.appendChild(document.createElement("span"));b.appendChild(document.createTextNode(u.slice(m,g))),b.className="cm-completionMatchedText",f=g}return ft.position-i.position).map(t=>t.render)}function S0(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let l=Math.floor(e/t);return{from:l*t,to:(l+1)*t}}let i=Math.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}class K6{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:f=>this.placeInfo(f),key:this},this.space=null,this.currentClass="";let l=e.state.field(t),{options:o,selected:a}=l.open,u=e.state.facet(Cn);this.optionContent=G6(u),this.optionClass=u.optionClass,this.tooltipClass=u.tooltipClass,this.range=S0(o.length,a,u.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",f=>{let{options:d}=e.state.field(t).open;for(let m=f.target,g;m&&m!=this.dom;m=m.parentNode)if(m.nodeName=="LI"&&(g=/-(\d+)$/.exec(m.id))&&+g[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;m!=null&&(e.dispatch({effects:Zy.of(m)}),f.preventDefault())}}),this.dom.addEventListener("focusout",f=>{let d=e.state.field(this.stateField,!1);d&&d.tooltip&&e.state.facet(Cn).closeOnBlur&&f.relatedTarget!=e.contentDOM&&e.dispatch({effects:bu.of(null)})}),this.showOptions(o,l.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),l=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=l){let{options:o,selected:a,disabled:u}=i.open;(!l.open||l.open.options!=o)&&(this.range=S0(o.length,a,e.state.facet(Cn).maxRenderedOptions),this.showOptions(o,i.id)),this.updateSel(),u!=((t=l.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!u)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected=this.range.to)&&(this.range=S0(t.options.length,t.selected,this.view.state.facet(Cn).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:l}=t.options[t.selected],{info:o}=l;if(!o)return;let a=typeof o=="string"?document.createTextNode(o):o(l);if(!a)return;"then"in a?a.then(u=>{u&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(u,l)}).catch(u=>pi(this.view.state,u,"completion info")):(this.addInfoPane(a,l),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:l,destroy:o}=e;i.appendChild(l),this.infoDestroy=o||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,l=this.range.from;i;i=i.nextSibling,l++)i.nodeName!="LI"||!i.id?l--:l==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&Z6(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),l=e.getBoundingClientRect(),o=this.space;if(!o){let a=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:a.clientWidth,bottom:a.clientHeight}}return l.top>Math.min(o.bottom,t.bottom)-10||l.bottom{a.target==l&&a.preventDefault()});let o=null;for(let a=i.from;ai.from||i.from==0))if(o=b,typeof d!="string"&&d.header)l.appendChild(d.header(d));else{let v=l.appendChild(document.createElement("completion-section"));v.textContent=b}}const m=l.appendChild(document.createElement("li"));m.id=t+"-"+a,m.setAttribute("role","option");let g=this.optionClass(u);g&&(m.className=g);for(let b of this.optionContent){let v=b(u,this.view.state,this.view,f);v&&m.appendChild(v)}}return i.from&&l.classList.add("cm-completionListIncompleteTop"),i.tonew K6(t,n,e)}function Z6(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),l=t.height/n.offsetHeight;i.topt.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/l)}function k2(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function J6(n,e){let t=[],i=null,l=null,o=m=>{t.push(m);let{section:g}=m.completion;if(g){i||(i=[]);let b=typeof g=="string"?g:g.name;i.some(v=>v.name==b)||i.push(typeof g=="string"?{name:b}:g)}},a=e.facet(Cn);for(let m of n)if(m.hasResult()){let g=m.result.getMatch;if(m.result.filter===!1)for(let b of m.result.options)o(new b2(b,m.source,g?g(b):[],1e9-t.length));else{let b=e.sliceDoc(m.from,m.to),v,w=a.filterStrict?new $6(b):new X6(b);for(let S of m.result.options)if(v=w.match(S.label)){let C=S.displayLabel?g?g(S,v.matched):[]:v.matched,N=v.score+(S.boost||0);if(o(new b2(S,m.source,C,N)),typeof S.section=="object"&&S.section.rank==="dynamic"){let{name:j}=S.section;l||(l=Object.create(null)),l[j]=Math.max(N,l[j]||-1e9)}}}}if(i){let m=Object.create(null),g=0,b=(v,w)=>(v.rank==="dynamic"&&w.rank==="dynamic"?l[w.name]-l[v.name]:0)||(typeof v.rank=="number"?v.rank:1e9)-(typeof w.rank=="number"?w.rank:1e9)||(v.nameb.score-g.score||d(g.completion,b.completion))){let g=m.completion;!f||f.label!=g.label||f.detail!=g.detail||f.type!=null&&g.type!=null&&f.type!=g.type||f.apply!=g.apply||f.boost!=g.boost?u.push(m):k2(m.completion)>k2(f)&&(u[u.length-1]=m),f=m.completion}return u}class ha{constructor(e,t,i,l,o,a){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=l,this.selected=o,this.disabled=a}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new ha(this.options,S2(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,l,o,a){if(l&&!a&&e.some(d=>d.isPending))return l.setDisabled();let u=J6(e,t);if(!u.length)return l&&e.some(d=>d.isPending)?l.setDisabled():null;let f=t.facet(Cn).selectOnOpen?0:-1;if(l&&l.selected!=f&&l.selected!=-1){let d=l.options[l.selected].completion;for(let m=0;mm.hasResult()?Math.min(d,m.from):d,1e8),create:lB,above:o.aboveCursor},l?l.timestamp:Date.now(),f,!1)}map(e){return new ha(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new ha(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Ld{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Ld(iB,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(Cn),o=(i.override||t.languageDataAt("autocomplete",no(t)).map(Q6)).map(f=>(this.active.find(m=>m.source==f)||new Vi(f,this.active.some(m=>m.state!=0)?1:0)).update(e,i));o.length==this.active.length&&o.every((f,d)=>f==this.active[d])&&(o=this.active);let a=this.open,u=e.effects.some(f=>f.is(Jy));a&&e.docChanged&&(a=a.map(e.changes)),e.selection||o.some(f=>f.hasResult()&&e.changes.touchesRange(f.from,f.to))||!eB(o,this.active)||u?a=ha.build(o,t,this.id,a,i,u):a&&a.disabled&&!o.some(f=>f.isPending)&&(a=null),!a&&o.every(f=>!f.isPending)&&o.some(f=>f.hasResult())&&(o=o.map(f=>f.hasResult()?new Vi(f.source,0):f));for(let f of e.effects)f.is(Zy)&&(a=a&&a.setSelected(f.value,this.id));return o==this.active&&a==this.open?this:new Ld(o,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?tB:nB}}function eB(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}const iB=[];function ZT(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(WT);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class Vi{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=ZT(e,t),l=this;(i&8||i&16&&this.touches(e))&&(l=new Vi(l.source,0)),i&4&&l.state==0&&(l=new Vi(this.source,1)),l=l.updateFor(e,i);for(let o of e.effects)if(o.is(_d))l=new Vi(l.source,1,o.value);else if(o.is(bu))l=new Vi(l.source,0);else if(o.is(Jy))for(let a of o.value)a.source==l.source&&(l=a);return l}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(no(e.state))}}class ba extends Vi{constructor(e,t,i,l,o,a){super(e,3,t),this.limit=i,this.result=l,this.from=o,this.to=a}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let l=this.result;l.map&&!e.changes.empty&&(l=l.map(l,e.changes));let o=e.changes.mapPos(this.from),a=e.changes.mapPos(this.to,1),u=no(e.state);if(u>a||!l||t&2&&(no(e.startState)==this.from||ut.map(e))}}),di=Fn.define({create(){return Ld.start()},update(n,e){return n.update(e)},provide:n=>[By.from(n,e=>e.tooltip),Oe.contentAttributes.from(n,e=>e.attrs)]});function eb(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(di).active.find(l=>l.source==e.source);return i instanceof ba?(typeof t=="string"?n.dispatch({...V6(n.state,t,i.from,i.to),annotations:WT.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}const lB=W6(di,eb);function Lh(n,e="option"){return t=>{let i=t.state.field(di,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+l*(n?1:-1):n?0:a-1;return u<0?u=e=="page"?0:a-1:u>=a&&(u=e=="page"?a-1:0),t.dispatch({effects:Zy.of(u)}),!0}}const sB=n=>{let e=n.state.field(di,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampn.state.field(di,!1)?(n.dispatch({effects:_d.of(!0)}),!0):!1,oB=n=>{let e=n.state.field(di,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:bu.of(null)}),!0)};class aB{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const cB=50,uB=1e3,fB=en.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(di).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(di),t=n.state.facet(Cn);if(!n.selectionSet&&!n.docChanged&&n.startState.field(di)==e)return;let i=n.transactions.some(o=>{let a=ZT(o,t);return a&8||(o.selection||o.docChanged)&&!(a&3)});for(let o=0;ocB&&Date.now()-a.time>uB){for(let u of a.context.abortListeners)try{u()}catch(f){pi(this.view.state,f)}a.context.abortListeners=null,this.running.splice(o--,1)}else a.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(o=>o.effects.some(a=>a.is(_d)))&&(this.pendingStart=!0);let l=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(o=>o.isPending&&!this.running.some(a=>a.active.source==o.source))?setTimeout(()=>this.startUpdate(),l):-1,this.composing!=0)for(let o of n.transactions)o.isUserEvent("input.type")?this.composing=2:this.composing==2&&o.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(di);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Cn).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=no(e),i=new GT(e,t,n.explicit,this.view),l=new aB(n,i);this.running.push(l),Promise.resolve(n.source(i)).then(o=>{l.context.aborted||(l.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:bu.of(null)}),pi(this.view.state,o)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Cn).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Cn),i=this.view.state.field(di);for(let l=0;lu.source==o.active.source);if(a&&a.isPending)if(o.done==null){let u=new Vi(o.active.source,0);for(let f of o.updates)u=u.update(f,t);u.isPending||e.push(u)}else this.startQuery(a)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Jy.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(di,!1);if(e&&e.tooltip&&this.view.state.facet(Cn).closeOnBlur){let t=e.open&&RN(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:bu.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:_d.of(!1)}),20),this.composing=0}}}),hB=typeof navigator=="object"&&/Win/.test(navigator.platform),dB=ao.highest(Oe.domEventHandlers({keydown(n,e){let t=e.state.field(di,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||!n.key||n.key.length>1||n.ctrlKey&&!(hB&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],l=t.active.find(a=>a.source==i.source),o=i.completion.commitCharacters||l.result.commitCharacters;return o&&o.indexOf(n.key)>-1&&eb(e,i),!1}})),mB=Oe.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),vu={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Ws=Ke.define({map(n,e){let t=e.mapPos(n,-1,Zn.TrackAfter);return t??void 0}}),tb=new class extends is{};tb.startSide=1;tb.endSide=-1;const JT=Fn.define({create(){return st.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Ws)&&(n=n.update({add:[tb.range(t.value,t.value+1)]}));return n}});function pB(){return[xB,JT]}const O0="()[]{}<>«»»«[]{}";function eA(n){for(let e=0;e{if((gB?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let l=n.state.selection.main;if(i.length>2||i.length==2&&Mr(hi(i,0))==1||e!=l.from||t!=l.to)return!1;let o=vB(n.state,i);return o?(n.dispatch(o),!0):!1}),yB=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=tA(n,n.selection.main.head).brackets||vu.brackets,l=null,o=n.changeByRange(a=>{if(a.empty){let u=wB(n.doc,a.head);for(let f of i)if(f==u&&cm(n.doc,a.head)==eA(hi(f,0)))return{changes:{from:a.head-f.length,to:a.head+f.length},range:oe.cursor(a.head-f.length)}}return{range:l=a}});return l||e(n.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!l},bB=[{key:"Backspace",run:yB}];function vB(n,e){let t=tA(n,n.selection.main.head),i=t.brackets||vu.brackets;for(let l of i){let o=eA(hi(l,0));if(e==l)return o==l?CB(n,l,i.indexOf(l+l+l)>-1,t):kB(n,l,o,t.before||vu.before);if(e==o&&nA(n,n.selection.main.from))return SB(n,l,o)}return null}function nA(n,e){let t=!1;return n.field(JT).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function cm(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Mr(hi(t,0)))}function wB(n,e){let t=n.sliceString(e-2,e);return Mr(hi(t,0))==t.length?t:t.slice(1)}function kB(n,e,t,i){let l=null,o=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:t,from:a.to}],effects:Ws.of(a.to+e.length),range:oe.range(a.anchor+e.length,a.head+e.length)};let u=cm(n.doc,a.head);return!u||/\s/.test(u)||i.indexOf(u)>-1?{changes:{insert:e+t,from:a.head},effects:Ws.of(a.head+e.length),range:oe.cursor(a.head+e.length)}:{range:l=a}});return l?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function SB(n,e,t){let i=null,l=n.changeByRange(o=>o.empty&&cm(n.doc,o.head)==t?{changes:{from:o.head,to:o.head+t.length,insert:t},range:oe.cursor(o.head+t.length)}:i={range:o});return i?null:n.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function CB(n,e,t,i){let l=i.stringPrefixes||vu.stringPrefixes,o=null,a=n.changeByRange(u=>{if(!u.empty)return{changes:[{insert:e,from:u.from},{insert:e,from:u.to}],effects:Ws.of(u.to+e.length),range:oe.range(u.anchor+e.length,u.head+e.length)};let f=u.head,d=cm(n.doc,f),m;if(d==e){if(C2(n,f))return{changes:{insert:e+e,from:f},effects:Ws.of(f+e.length),range:oe.cursor(f+e.length)};if(nA(n,f)){let b=t&&n.sliceDoc(f,f+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:f,to:f+b.length,insert:b},range:oe.cursor(f+b.length)}}}else{if(t&&n.sliceDoc(f-2*e.length,f)==e+e&&(m=O2(n,f-2*e.length,l))>-1&&C2(n,m))return{changes:{insert:e+e+e+e,from:f},effects:Ws.of(f+e.length),range:oe.cursor(f+e.length)};if(n.charCategorizer(f)(d)!=Ft.Word&&O2(n,f,l)>-1&&!OB(n,f,e,l))return{changes:{insert:e+e,from:f},effects:Ws.of(f+e.length),range:oe.cursor(f+e.length)}}return{range:o=u}});return o?null:n.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function C2(n,e){let t=Un(n).resolveInner(e+1);return t.parent&&t.from==e}function OB(n,e,t,i){let l=Un(n).resolveInner(e,-1),o=i.reduce((a,u)=>Math.max(a,u.length),0);for(let a=0;a<5;a++){let u=n.sliceDoc(l.from,Math.min(l.to,l.from+t.length+o)),f=u.indexOf(t);if(!f||f>-1&&i.indexOf(u.slice(0,f))>-1){let m=l.firstChild;for(;m&&m.from==l.from&&m.to-m.from>t.length+f;){if(n.sliceDoc(m.to-t.length,m.to)==t)return!1;m=m.firstChild}return!0}let d=l.to==e&&l.parent;if(!d)break;l=d}return!1}function O2(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=Ft.Word)return e;for(let l of t){let o=e-l.length;if(n.sliceDoc(o,e)==l&&i(n.sliceDoc(o-1,o))!=Ft.Word)return o}return-1}function NB(n={}){return[dB,di,Cn.of(n),fB,TB,mB]}const iA=[{key:"Ctrl-Space",run:C0},{mac:"Alt-`",run:C0},{mac:"Alt-i",run:C0},{key:"Escape",run:oB},{key:"ArrowDown",run:Lh(!0)},{key:"ArrowUp",run:Lh(!1)},{key:"PageDown",run:Lh(!0,"page")},{key:"PageUp",run:Lh(!1,"page")},{key:"Enter",run:sB}],TB=ao.highest(Ly.computeN([Cn],n=>n.facet(Cn).defaultKeymap?[iA]:[]));class N2{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Ys{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let l=i.facet(wu).markerFilter;l&&(e=l(e,i));let o=e.slice().sort((v,w)=>v.from-w.from||v.to-w.to),a=new Br,u=[],f=0,d=i.doc.iter(),m=0,g=i.doc.length;for(let v=0;;){let w=v==o.length?null:o[v];if(!w&&!u.length)break;let S,C;if(u.length)S=f,C=u.reduce((D,I)=>Math.min(D,I.to),w&&w.from>S?w.from:1e8);else{if(S=w.from,S>g)break;C=w.to,u.push(w),v++}for(;vD.from||D.to==S))u.push(D),v++,C=Math.min(D.to,C);else{C=Math.min(D.from,C);break}}C=Math.min(C,g);let N=!1;if(u.some(D=>D.from==S&&(D.to==C||C==g))&&(N=S==C,!N&&C-S<10)){let D=S-(m+d.value.length);D>0&&(d.next(D),m=S);for(let I=S;;){if(I>=C){N=!0;break}if(!d.lineBreak&&m+d.value.length>I)break;I=m+d.value.length,m+=d.value.length,d.next()}}let j=IB(u);if(N)a.add(S,S,Fe.widget({widget:new zB(j),diagnostics:u.slice()}));else{let D=u.reduce((I,U)=>U.markClass?I+" "+U.markClass:I,"");a.add(S,C,Fe.mark({class:"cm-lintRange cm-lintRange-"+j+D,diagnostics:u.slice(),inclusiveEnd:u.some(I=>I.to>C)}))}if(f=C,f==g)break;for(let D=0;D{if(!(e&&a.diagnostics.indexOf(e)<0))if(!i)i=new N2(l,o,e||a.diagnostics[0]);else{if(a.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new N2(i.from,o,i.diagnostic)}}),i}function AB(n,e){let t=e.pos,i=e.end||t,l=n.state.facet(wu).hideOn(n,t,i);if(l!=null)return l;let o=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(a=>a.is(rA))||n.changes.touchesRange(o.from,Math.max(o.to,i)))}function EB(n,e){return n.field(Di,!1)?e:e.concat(Ke.appendConfig.of(UB))}const rA=Ke.define(),nb=Ke.define(),lA=Ke.define(),Di=Fn.define({create(){return new Ys(Fe.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,l=n.panel;if(n.selected){let o=e.changes.mapPos(n.selected.from,1);i=cs(t,n.selected.diagnostic,o)||cs(t,null,o)}!t.size&&l&&e.state.facet(wu).autoPanel&&(l=null),n=new Ys(t,l,i)}for(let t of e.effects)if(t.is(rA)){let i=e.state.facet(wu).autoPanel?t.value.length?ku.open:null:n.panel;n=Ys.init(t.value,i,e.state)}else t.is(nb)?n=new Ys(n.diagnostics,t.value?ku.open:null,n.selected):t.is(lA)&&(n=new Ys(n.diagnostics,n.panel,t.value));return n},provide:n=>[mu.from(n,e=>e.panel),Oe.decorations.from(n,e=>e.diagnostics)]}),MB=Fe.mark({class:"cm-lintRange cm-lintRange-active"});function DB(n,e,t){let{diagnostics:i}=n.state.field(Di),l,o=-1,a=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(f,d,{spec:m})=>{if(e>=f&&e<=d&&(f==d||(e>f||t>0)&&(eoA(n,t,!1)))}const jB=n=>{let e=n.state.field(Di,!1);(!e||!e.panel)&&n.dispatch({effects:EB(n.state,[nb.of(!0)])});let t=nm(n,ku.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},T2=n=>{let e=n.state.field(Di,!1);return!e||!e.panel?!1:(n.dispatch({effects:nb.of(!1)}),!0)},_B=n=>{let e=n.state.field(Di,!1);if(!e)return!1;let t=n.state.selection.main,i=cs(e.diagnostics,null,t.to+1);return!i&&(i=cs(e.diagnostics,null,0),!i||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),E_(n,i.from,1,{tooltip:aA,until:l=>l.docChanged||l.newSelection.main.headi.to}),!0)},LB=[{key:"Mod-Shift-m",run:jB,preventDefault:!0},{key:"F8",run:_B}],wu=Ce.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...Pr(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:A2,tooltipFilter:A2,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,l,o)=>e(i,l,o)||t(i,l,o):e:t,autoPanel:(e,t)=>e||t})}}});function A2(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function sA(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;io.toLowerCase()==l.toLowerCase())){e.push(l);continue e}}e.push("")}return e}function oA(n,e,t){var i;let l=t?sA(e.actions):[];return Nt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Nt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((o,a)=>{let u=!1,f=v=>{if(v.preventDefault(),u)return;u=!0;let w=cs(n.state.field(Di).diagnostics,e);w&&o.apply(n,w.from,w.to)},{name:d}=o,m=l[a]?d.indexOf(l[a]):-1,g=m<0?d:[d.slice(0,m),Nt("u",d.slice(m,m+1)),d.slice(m+1)],b=o.markClass?" "+o.markClass:"";return Nt("button",{type:"button",class:"cm-diagnosticAction"+b,onclick:f,onmousedown:f,"aria-label":` Action: ${d}${m<0?"":` (access key "${l[a]})"`}.`},g)}),e.source&&Nt("div",{class:"cm-diagnosticSource"},e.source))}class zB extends fl{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Nt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class E2{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=oA(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ku{constructor(e){this.view=e,this.items=[];let t=l=>{if(!(l.ctrlKey||l.altKey||l.metaKey)){if(l.keyCode==27)T2(this.view),this.view.focus();else if(l.keyCode==38||l.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(l.keyCode==40||l.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(l.keyCode==36)this.moveSelection(0);else if(l.keyCode==35)this.moveSelection(this.items.length-1);else if(l.keyCode==13)this.view.focus();else if(l.keyCode>=65&&l.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],a=sA(o.actions);for(let u=0;u{for(let o=0;oT2(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Di).selected;if(!e)return-1;for(let t=0;t{for(let m of d.diagnostics){if(a.has(m))continue;a.add(m);let g=-1,b;for(let v=i;vi&&(this.items.splice(i,g-i),l=!0)),t&&b.diagnostic==t.diagnostic?b.dom.hasAttribute("aria-selected")||(b.dom.setAttribute("aria-selected","true"),o=b):b.dom.hasAttribute("aria-selected")&&b.dom.removeAttribute("aria-selected"),i++}});i({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:u,panel:f})=>{let d=f.height/this.list.offsetHeight;u.topf.bottom&&(this.list.scrollTop+=(u.bottom-f.bottom)/d)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),l&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Di),i=cs(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:lA.of(i)})}static open(e){return new ku(e)}}function BB(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function zh(n){return BB(``,'width="6" height="3"')}const PB=Oe.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:zh("#f11")},".cm-lintRange-warning":{backgroundImage:zh("orange")},".cm-lintRange-info":{backgroundImage:zh("#999")},".cm-lintRange-hint":{backgroundImage:zh("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function HB(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function IB(n){let e="hint",t=1;for(let i of n){let l=HB(i.severity);l>t&&(t=l,e=i.severity)}return e}const aA=A_(DB,{hideOn:AB}),UB=[Di,Oe.decorations.compute([Di],n=>{let{selected:e,panel:t}=n.field(Di);return!e||!t||e.from==e.to?Fe.none:Fe.set([MB.range(e.from,e.to)])}),aA,PB],FB=[q_(),X_(),l_(),az(),LL(),$j(),Jj(),gt.allowMultipleSelections.of(!0),wL(),lT(HL,{fallback:!0}),XL(),pB(),NB(),x_(),v_(),f_(),x6(),Ly.of([...bB,...h6,...P6,...xz,...DL,...iA,...LB])];var M2={};class zd{constructor(e,t,i,l,o,a,u,f,d,m=0,g){this.p=e,this.stack=t,this.state=i,this.reducePos=l,this.pos=o,this.score=a,this.buffer=u,this.bufferBase=f,this.curContext=d,this.lookAhead=m,this.parent=g}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let l=e.parser.context;return new zd(e,[],t,i,i,0,[],0,l?new D2(l,l.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,l=e&65535,{parser:o}=this.p,a=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[l])===null||t===void 0)&&t.isAnonymous)&&(d==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=m):this.p.lastBigReductionSizef;)this.stack.pop();this.reduceContext(l,d)}storeNode(e,t,i,l=4,o=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[a-4]==0&&this.buffer[a-1]>-1){if(t==i)return;if(this.buffer[a-2]>=t){this.buffer[a-2]=i;return}}}if(!o||this.pos==i)this.buffer.push(e,t,i,l);else{let a=this.buffer.length;if(a>0&&(this.buffer[a-4]!=0||this.buffer[a-1]<0)){let u=!1;for(let f=a;f>0&&this.buffer[f-2]>i;f-=4)if(this.buffer[f-1]>=0){u=!0;break}if(u)for(;a>0&&this.buffer[a-2]>i;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,l>4&&(l-=4)}this.buffer[a]=e,this.buffer[a+1]=t,this.buffer[a+2]=i,this.buffer[a+3]=l}}shift(e,t,i,l){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let o=e,{parser:a}=this.p;this.pos=l;let u=a.stateFlag(o,1);!u&&(l>i||t<=a.maxNode)&&(this.reducePos=l),this.pushState(o,u?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=a.maxNode&&this.buffer.push(t,i,l,4)}else this.pos=l,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,l,4)}apply(e,t,i,l){e&65536?this.reduce(e):this.shift(e,t,i,l)}useNode(e,t,i){let l=this.p.reused.length-1;(l<0||this.p.reused[l]!=e)&&(this.p.reused.push(e),l++);let o=this.reducePos=this.pos=i+e.length;this.pushState(t,i),this.buffer.push(l,i,o,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),l=e.bufferBase+t;for(;e&&l==e.bufferBase;)e=e.parent;return new zd(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,l,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new qB(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let l=[];for(let o=0,a;of&1&&u==a)||l.push(t[o],a)}t=l}let i=[];for(let l=0;l>19,l=t&65535,o=this.stack.length-i*3;if(o<0||e.getGoto(this.stack[o],l,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;t=a}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(l,o)=>{if(!t.includes(l))return t.push(l),e.allActions(l,a=>{if(!(a&393216))if(a&65536){let u=(a>>19)-o;if(u>1){let f=a&65535,d=this.stack.length-u*3;if(d>=0&&e.getGoto(this.stack[d],f,!1)>=0)return u<<19|65536|f}}else{let u=i(a,o+1);if(u!=null)return u}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t0&&this.emitLookAhead()}}class D2{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class qB{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let l=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=l}}class Bd{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Bd(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Bd(this.stack,this.pos,this.index)}}function Bh(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,l=0;i=92&&a--,a>=34&&a--;let f=a-32;if(f>=46&&(f-=46,u=!0),o+=f,u)break;o*=46}t?t[l++]=o:t=new e(o)}return t}class sd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const R2=new sd;class VB{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=R2,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,l=this.rangeIndex,o=this.pos+e;for(;oi.to:o>=i.to;){if(l==this.ranges.length-1)return null;let a=this.ranges[++l];o+=a.from-i.to,i=a}return o}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,l;if(t>=0&&t=this.chunk2Pos&&iu.to&&(this.chunk2=this.chunk2.slice(0,u.to-i)),l=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),l}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=R2,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let l of this.ranges){if(l.from>=t)break;l.to>e&&(i+=this.input.read(Math.max(l.from,e),Math.min(l.to,t)))}return i}}class va{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;QB(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}va.prototype.contextual=va.prototype.fallback=va.prototype.extend=!1;va.prototype.fallback=va.prototype.extend=!1;class um{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function QB(n,e,t,i,l,o){let a=0,u=1<0){let w=n[v];if(f.allows(w)&&(e.token.value==-1||e.token.value==w||XB(w,e.token.value,l,o))){e.acceptToken(w);break}}let m=e.next,g=0,b=n[a+2];if(e.next<0&&b>g&&n[d+b*3-3]==65535){a=n[d+b*3-1];continue e}for(;g>1,w=d+v+(v<<1),S=n[w],C=n[w+1]||65536;if(m=C)g=v+1;else{a=n[w+2],e.advance();continue e}}break}}function j2(n,e,t){for(let i=e,l;(l=n[i])!=65535;i++)if(l==t)return i-e;return-1}function XB(n,e,t,i){let l=j2(t,i,e);return l<0||j2(t,i,n)e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class $B{constructor(e,t){this.fragments=e,this.minRepeat=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.lastRepeat=null,this.lastRepeatPos=-1,this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?_2(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?_2(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=a,null;if(o instanceof fn){let u=a>this.lastRepeatPos&&o.type.id>=this.minRepeat;if(a==e||u){let f=a+o.length,d;if(a>=this.safeFrom&&f<=this.safeTo&&(!(d=o.prop(tt.lookAhead))||f+d=Math.max(this.safeFrom,e)&&(this.trees.push(o),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+o.length}}}class YB{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new sd)}getActions(e){let t=0,i=null,{parser:l}=e.p,{tokenizers:o}=l,a=l.stateSlot(e.state,3),u=e.curContext?e.curContext.hash:0,f=0;for(let d=0;dg.end+25&&(f=Math.max(g.lookAhead,f)),g.value!=0)){let b=t;if(g.extended>-1&&(t=this.addActions(e,g.extended,g.end,t)),t=this.addActions(e,g.value,g.end,t),!m.extend&&(i=g,t>b))break}}for(;this.actions.length>t;)this.actions.pop();return f&&e.setLookAhead(f),!i&&e.pos==this.stream.end&&(i=new sd,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new sd,{pos:i,p:l}=e;return t.start=i,t.end=Math.min(i+1,l.stream.end),t.value=i==l.stream.end?l.parser.eofTerm:0,t}updateCachedToken(e,t,i){let l=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(l,e),i),e.value>-1){let{parser:o}=i.p;for(let a=0;a=0&&i.p.parser.dialect.allows(u>>1)){(u&1)==0?e.value=u>>1:e.extended=u>>1;break}}}else e.value=0,e.end=this.stream.clipPos(l+1)}putAction(e,t,i,l){for(let o=0;oe.bufferLength*4?new $B(i,e.minRepeatTerm):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],l,o;if(this.bigReductionCount>300&&e.length==1){let[a]=e;for(;a.forceReduce()&&a.stack.length&&a.stack[a.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;at)i.push(u);else{if(this.advanceStack(u,i,e))continue;{l||(l=[],o=[]),l.push(u);let f=this.tokens.getMainToken(u);o.push(f.value,f.end)}}break}}if(!i.length){let a=l&&ZB(l);if(a)return Ai&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw Ai&&l&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&l){let a=this.stoppedAt!=null&&l[0].pos>this.stoppedAt?l[0]:this.runRecovery(l,o,i);if(a)return Ai&&console.log("Force-finish "+this.stackID(a)),this.stackToTree(a.forceAll())}if(this.recovering){let a=this.recovering==1?1:this.recovering*3;if(i.length>a)for(i.sort((u,f)=>f.score-u.score);i.length>a;)i.pop();i.some(u=>u.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let a=0;a500&&d.buffer.length>500)if((u.score-d.score||u.buffer.length-d.buffer.length)>0)i.splice(f--,1);else{i.splice(a--,1);continue e}}}i.length>12&&(i.sort((a,u)=>u.score-a.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let a=1;a-1&&i.length&&(!o||(i.prop(tt.contextHash)||0)==a))return e.useNode(i,u,t),i;if(i.children.length==0||i.positions[0]>0)break;let f=i.children[0];if(f instanceof fn&&(!l||f.type.id>=this.parser.minRepeatTerm))i=f;else break}return null}advanceStack(e,t,i){let l=e.pos,{parser:o}=this,a=Ai?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&l>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let d=e.reducePos0)return e.reduce(u),Ai&&console.log(a+this.stackID(e)+` (via always-reduce ${o.getName(u&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let f=this.tokens.getActions(e);for(let d=0;dl?t.push(w):i.push(w)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return L2(e,t),!0}}runRecovery(e,t,i){let l=null,o=!1;for(let a=0;a ":"";if(u.deadEnd&&(o||(o=!0,u.restart(),Ai&&console.log(m+this.stackID(u)+" (restarted)"),this.advanceFully(u,i))))continue;let g=u.split(),b=m;for(let v=0;v<10&&g.forceReduce()&&(Ai&&console.log(b+this.stackID(g)+" (via force-reduce)"),!this.advanceFully(g,i));v++)Ai&&(b=this.stackID(g)+" -> ");for(let v of u.recoverByInsert(f))Ai&&console.log(m+this.stackID(v)+" (via recover-insert)"),this.advanceFully(v,i);this.stream.end>u.pos?(d==u.pos&&(d++,f=0),u.recoverByDelete(f,d),Ai&&console.log(m+this.stackID(u)+` (via recover-delete ${this.parser.getName(f)})`),L2(u,i)):(!l||l.scoren;class WB{constructor(e){this.start=e.start,this.shift=e.shift||T0,this.reduce=e.reduce||T0,this.reuse=e.reuse||T0,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class Pd extends FN{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let u=0;ue.topRules[u][1]),l=[];for(let u=0;u=0)o(m,f,u[d++]);else{let g=u[d+-m];for(let b=-m;b>0;b--)o(u[d++],f,g);d++}}}this.nodeSet=new Py(t.map((u,f)=>xi.define({name:f>=this.minRepeatTerm?void 0:u,id:f,props:l[f],top:i.indexOf(f)>-1,error:f==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(f)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=PN;let a=Bh(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let u=0;utypeof u=="number"?new va(a,u):u),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let l=new GB(this,e,t,i);for(let o of this.wrappers)l=o(l,e,t,i);return l}getGoto(e,t,i=!1){let l=this.goto;if(t>=l[0])return-1;for(let o=l[t+1];;){let a=l[o++],u=a&1,f=l[o++];if(u&&i)return f;for(let d=o+(a>>1);o0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),l=i?t(i):void 0;for(let o=this.stateSlot(e,1);l==null;o+=3){if(this.data[o]==65535)if(this.data[o+1]==1)o=il(this.data,o+2);else break;l=t(il(this.data,o+1))}return l}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=il(this.data,i+2);else break;if((this.data[i+2]&1)==0){let l=this.data[i+1];t.some((o,a)=>a&1&&o==l)||t.push(this.data[i],l)}}return t}configure(e){let t=Object.assign(Object.create(Pd.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let l=e.tokenizers.find(o=>o.from==i);return l?l.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,l)=>{let o=e.specializers.find(u=>u.from==i.external);if(!o)return i;let a=Object.assign(Object.assign({},i),{external:o.to});return t.specializers[l]=z2(a),a})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let o of e.split(" ")){let a=t.indexOf(o);a>=0&&(i[a]=!0)}let l=null;for(let o=0;oi)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}const la=63,B2=64,JB=1,e9=2,cA=3,t9=4,uA=5,n9=6,i9=7,fA=65,r9=66,l9=8,s9=9,o9=10,a9=11,c9=12,hA=13,u9=19,f9=20,h9=29,d9=33,m9=34,p9=47,g9=0,ib=1,Yx=2,Su=3,Gx=4;class Gs{constructor(e,t,i){this.parent=e,this.depth=t,this.type=i,this.hash=(e?e.hash+e.hash<<8:0)+t+(t<<4)+i}}Gs.top=new Gs(null,-1,g9);function iu(n,e){for(let t=0,i=e-n.pos-1;;i--,t++){let l=n.peek(i);if(cl(l)||l==-1)return t}}function Kx(n){return n==32||n==9}function cl(n){return n==10||n==13}function dA(n){return Kx(n)||cl(n)}function Zs(n){return n<0||dA(n)}const x9=new WB({start:Gs.top,reduce(n,e){return n.type==Su&&(e==f9||e==m9)?n.parent:n},shift(n,e,t,i){if(e==cA)return new Gs(n,iu(i,i.pos),ib);if(e==fA||e==uA)return new Gs(n,iu(i,i.pos),Yx);if(e==la)return n.parent;if(e==u9||e==d9)return new Gs(n,0,Su);if(e==hA&&n.type==Gx)return n.parent;if(e==p9){let l=/[1-9]/.exec(i.read(i.pos,t.pos));if(l)return new Gs(n,n.depth+ +l[0],Gx)}return n},hash(n){return n.hash}});function Ra(n,e,t=0){return n.peek(t)==e&&n.peek(t+1)==e&&n.peek(t+2)==e&&Zs(n.peek(t+3))}const y9=new um((n,e)=>{if(n.next==-1&&e.canShift(B2))return n.acceptToken(B2);let t=n.peek(-1);if((cl(t)||t<0)&&e.context.type!=Su){if(Ra(n,45))if(e.canShift(la))n.acceptToken(la);else return n.acceptToken(JB,3);if(Ra(n,46))if(e.canShift(la))n.acceptToken(la);else return n.acceptToken(e9,3);let i=0;for(;n.next==32;)i++,n.advance();(i{if(e.context.type==Su){n.next==63&&(n.advance(),Zs(n.next)&&n.acceptToken(i9));return}if(n.next==45)n.advance(),Zs(n.next)&&n.acceptToken(e.context.type==ib&&e.context.depth==iu(n,n.pos-1)?t9:cA);else if(n.next==63)n.advance(),Zs(n.next)&&n.acceptToken(e.context.type==Yx&&e.context.depth==iu(n,n.pos-1)?n9:uA);else{let t=n.pos;for(;;)if(Kx(n.next)){if(n.pos==t)return;n.advance()}else if(n.next==33)mA(n);else if(n.next==38)Wx(n);else if(n.next==42){Wx(n);break}else if(n.next==39||n.next==34){if(rb(n,!0))break;return}else if(n.next==91||n.next==123){if(!w9(n))return;break}else{pA(n,!0,!1,0);break}for(;Kx(n.next);)n.advance();if(n.next==58){if(n.pos==t&&e.canShift(h9))return;let i=n.peek(1);Zs(i)&&n.acceptTokenTo(e.context.type==Yx&&e.context.depth==iu(n,t)?r9:fA,t)}}},{contextual:!0});function v9(n){return n>32&&n<127&&n!=34&&n!=37&&n!=44&&n!=60&&n!=62&&n!=92&&n!=94&&n!=96&&n!=123&&n!=124&&n!=125}function P2(n){return n>=48&&n<=57||n>=97&&n<=102||n>=65&&n<=70}function H2(n,e){return n.next==37?(n.advance(),P2(n.next)&&n.advance(),P2(n.next)&&n.advance(),!0):v9(n.next)||e&&n.next==44?(n.advance(),!0):!1}function mA(n){if(n.advance(),n.next==60){for(n.advance();;)if(!H2(n,!0)){n.next==62&&n.advance();break}}else for(;H2(n,!1););}function Wx(n){for(n.advance();!Zs(n.next)&&Hd(n.next)!="f";)n.advance()}function rb(n,e){let t=n.next,i=!1,l=n.pos;for(n.advance();;){let o=n.next;if(o<0)break;if(n.advance(),o==t)if(o==39)if(n.next==39)n.advance();else break;else break;else if(o==92&&t==34)n.next>=0&&n.advance();else if(cl(o)){if(e)return!1;i=!0}else if(e&&n.pos>=l+1024)return!1}return!i}function w9(n){for(let e=[],t=n.pos+1024;;)if(n.next==91||n.next==123)e.push(n.next),n.advance();else if(n.next==39||n.next==34){if(!rb(n,!0))return!1}else if(n.next==93||n.next==125){if(e[e.length-1]!=n.next-2)return!1;if(e.pop(),n.advance(),!e.length)return!0}else{if(n.next<0||n.pos>t||cl(n.next))return!1;n.advance()}}const k9="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function Hd(n){return n<33?"u":n>125?"s":k9[n-33]}function A0(n,e){let t=Hd(n);return t!="u"&&!(e&&t=="f")}function pA(n,e,t,i){if(Hd(n.next)=="s"||(n.next==63||n.next==58||n.next==45)&&A0(n.peek(1),t))n.advance();else return!1;let l=n.pos;for(;;){let o=n.next,a=0,u=i+1;for(;dA(o);){if(cl(o)){if(e)return!1;u=0}else u++;o=n.peek(++a)}if(!(o>=0&&(o==58?A0(n.peek(a+1),t):o==35?n.peek(a-1)!=32:A0(o,t)))||!t&&u<=i||u==0&&!t&&(Ra(n,45,a)||Ra(n,46,a)))break;if(e&&Hd(o)=="f")return!1;for(let d=a;d>=0;d--)n.advance();if(e&&n.pos>l+1024)return!1}return!0}const S9=new um((n,e)=>{if(n.next==33)mA(n),n.acceptToken(c9);else if(n.next==38||n.next==42){let t=n.next==38?o9:a9;Wx(n),n.acceptToken(t)}else n.next==39||n.next==34?(rb(n,!1),n.acceptToken(s9)):pA(n,!1,e.context.type==Su,e.context.depth)&&n.acceptToken(l9)}),C9=new um((n,e)=>{let t=e.context.type==Gx?e.context.depth:-1,i=n.pos;e:for(;;){let l=0,o=n.next;for(;o==32;)o=n.peek(++l);if(!l&&(Ra(n,45,l)||Ra(n,46,l))||!cl(o)&&(t<0&&(t=Math.max(e.context.depth+1,l)),lYAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:x9,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[O9],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[y9,b9,S9,C9,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),T9=Sd.define({name:"yaml",parser:N9.configure({props:[$N.add({Stream:n=>{for(let e=n.node.resolve(n.pos,-1);e&&e.to>=n.pos;e=e.parent){if(e.name=="BlockLiteralContent"&&e.fromn.pos)return null}}return null},FlowMapping:e2({closing:"}"}),FlowSequence:e2({closing:"]"})}),KN.add({"FlowMapping FlowSequence":SL,"Item Pair BlockLiteral":(n,e)=>({from:e.doc.lineAt(n.from).to,to:n.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function A9(){return new hL(T9)}const I2='button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], video[tabindex], [tabindex]:not([tabindex="-1"])';function ds({isOpen:n,onClose:e,dialogRef:t,initialFocusRef:i}){return M.useEffect(()=>{if(!n)return;const l=document.activeElement instanceof HTMLElement?document.activeElement:null,o=requestAnimationFrame(()=>{var f;const u=(i==null?void 0:i.current)??((f=t.current)==null?void 0:f.querySelector(I2))??t.current;u==null||u.focus()}),a=u=>{if(u.key!=="Tab")return;const f=t.current;if(!f)return;const d=Array.from(f.querySelectorAll(I2));if(!d.length)return;const m=d[0],g=d[d.length-1],b=document.activeElement;if(!(b instanceof Node&&f.contains(b))){u.preventDefault(),(u.shiftKey?g:m).focus();return}u.shiftKey&&(b===m||b===f)?(u.preventDefault(),g.focus()):!u.shiftKey&&(b===g||b===f)&&(u.preventDefault(),m.focus())};return window.addEventListener("keydown",a,!0),()=>{cancelAnimationFrame(o),l==null||l.focus(),window.removeEventListener("keydown",a,!0)}},[n]),l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),e())}}function Js({isOpen:n,title:e,message:t,confirmLabel:i="Confirm",cancelLabel:l="Cancel",danger:o=!1,onConfirm:a,onCancel:u}){const f=M.useRef(null),d=M.useRef(null),m=ds({isOpen:n,onClose:u,dialogRef:f,initialFocusRef:d});return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",onClick:u,children:y.jsxs("div",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"confirm-dialog-title",onKeyDown:m,onClick:g=>g.stopPropagation(),className:"animate-modal-in w-[400px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("div",{className:"mb-3 flex items-center gap-2.5",children:[y.jsx("span",{className:`grid h-9 w-9 shrink-0 place-items-center rounded-lg ${o?"bg-status-danger-bg text-status-danger-text":"bg-chip-indigo-bg text-chip-indigo-text"}`,children:y.jsx(by,{className:"h-5 w-5"})}),y.jsx("h2",{id:"confirm-dialog-title",className:"text-sm font-semibold text-ink",children:e})]}),y.jsx("div",{className:"mb-5 whitespace-pre-line text-xs text-ink-secondary",children:t}),y.jsxs("div",{className:"flex justify-end gap-2",children:[y.jsx("button",{ref:d,type:"button",onClick:u,className:"min-h-9 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:l}),y.jsx("button",{type:"button",onClick:a,className:`min-h-9 rounded-lg border px-4 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 ${o?"border-status-danger-border bg-status-danger-bg/30 text-status-danger-text hover:bg-status-danger-bg/60":"btn-primary border-transparent bg-indigo-600 text-white hover:bg-indigo-500"}`,children:i})]})]})}):null}var E9=YC();const Ar=8,Jl=8,M9=400,U2={top:"bottom",bottom:"top",left:"right",right:"left"},D9={top:"-bottom-1 left-1/2 -translate-x-1/2",bottom:"-top-1 left-1/2 -translate-x-1/2",left:"-right-1 top-1/2 -translate-y-1/2",right:"-left-1 top-1/2 -translate-y-1/2"},R9={top:"border-b border-r",bottom:"border-t border-l",left:"border-t border-r",right:"border-b border-l"},F2=(n,e,t)=>{switch(n){case"top":return e.top-Jl-t.h>=Ar;case"bottom":return e.bottom+Jl+t.h<=window.innerHeight-Ar;case"left":return e.left-Jl-t.w>=Ar;default:return e.right+Jl+t.w<=window.innerWidth-Ar}},j9=(n,e,t)=>{if(n==="top"||n==="bottom"){const a=e.left+e.width/2-t.w/2,u=window.innerWidth-t.w-Ar;return{x:Math.min(Math.max(a,Ar),Math.max(Ar,u))-a,y:0}}const i=e.top+e.height/2-t.h/2,l=window.innerHeight-t.h-Ar;return{x:0,y:Math.min(Math.max(i,Ar),Math.max(Ar,l))-i}},$e=({text:n,children:e,block:t=!0,placement:i="top",suppress:l=!1})=>{const o=M.useRef(null),a=M.useRef(null),u=M.useId(),f=M.useRef(null),[d,m]=M.useState(!1),[g,b]=M.useState(i),[v,w]=M.useState({x:0,y:0}),[S,C]=M.useState({left:-9999,top:-9999}),N=()=>{f.current!==null&&(window.clearTimeout(f.current),f.current=null)};M.useEffect(()=>{l&&(N(),m(!1))},[l]),M.useEffect(()=>()=>N(),[]);const j=M.useCallback(()=>{const E=o.current,T=a.current;if(!E||!T)return;const z=E.getBoundingClientRect(),te={w:T.offsetWidth,h:T.offsetHeight},q=F2(i,z,te)?i:F2(U2[i],z,te)?U2[i]:i,G=j9(q,z,te);b(q),w(G);const F=z.left+z.width/2,se=z.top+z.height/2;C(q==="top"?{left:F,top:z.top-Jl-te.h}:q==="bottom"?{left:F,top:z.bottom+Jl}:q==="left"?{left:z.left-Jl-te.w,top:se}:{left:z.right+Jl,top:se})},[i]);M.useEffect(()=>{if(!d)return;const E=()=>m(!1);return window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[d]);const D=E=>{if(l)return;N();const T=()=>{j(),m(!0)};E?T():f.current=window.setTimeout(T,M9)},I=()=>{N(),m(!1)};M.useEffect(()=>{if(!d)return;const E=T=>{T.key==="Escape"&&m(!1)};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[d]),M.useEffect(()=>{if(!d)return;const E=()=>!!document.querySelector('[role="dialog"][aria-modal="true"], dialog[open]');if(E()){m(!1);return}const T=new MutationObserver(()=>{E()&&m(!1)});return T.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","open","class"]}),()=>T.disconnect()},[d]);const U={onMouseEnter:()=>D(!1),onMouseLeave:I,onFocus:()=>D(!0),onBlur:I,"aria-describedby":u};return y.jsxs("div",{ref:o,className:`group relative ${t?"flex min-w-0 flex-1 items-center":"inline-flex shrink-0 items-center"}`,onMouseEnter:()=>D(!1),onMouseLeave:I,onFocus:()=>D(!0),onBlur:I,children:[M.cloneElement(e,U),E9.createPortal(y.jsxs("span",{ref:a,id:u,role:"tooltip",className:`pointer-events-none invisible fixed z-[var(--z-tooltip)] w-max max-w-[calc(100vw-16px)] rounded-md border border-line bg-elevated px-2 py-1 text-left text-[11px] leading-relaxed text-ink shadow-lg ${d?"visible opacity-100":"opacity-0"}`,style:{left:S.left,top:S.top,transform:g==="top"||g==="bottom"?`translateX(calc(-50% + ${v.x}px))`:`translateY(calc(-50% + ${v.y}px))`},children:[n,y.jsx("span",{className:`absolute h-2 w-2 rotate-45 border-line bg-elevated ${D9[g]} ${R9[g]}`,style:g==="top"||g==="bottom"?{left:`calc(50% - ${v.x}px)`}:void 0})]}),document.body)]})},_9=[".profiles",".profiles.yaml"];function L9(n){const e=n.trim();if(!e)return null;const t=e.toLowerCase(),i=_9.find(l=>t.endsWith(l));if(i!==void 0){const l=e.slice(0,e.length-i.length);return!l.trim()||l!==l.trimEnd()?null:e}return t.includes(".")?null:`${e}.profiles`}function z9({open:n,onCancel:e,onConfirm:t}){const[i,l]=M.useState(null),[o,a]=M.useState(""),[u,f]=M.useState(""),[d,m]=M.useState(null),[g,b]=M.useState(!1),[v,w]=M.useState(null),[S,C]=M.useState(null),N=M.useRef(null),j=M.useRef(null),D=M.useRef(null),I=M.useCallback(async z=>{b(!0),w(null);try{const te=await KC(z);l(te),a(te.current_path)}catch(te){w(te instanceof Error?te.message:String(te))}finally{b(!1)}},[]);M.useEffect(()=>{if(!n)return;f(""),m(null),C(null),I(o);const z=requestAnimationFrame(()=>{var te;return(te=j.current)==null?void 0:te.focus()});return()=>cancelAnimationFrame(z)},[n]);const U=ds({isOpen:n,onClose:e,dialogRef:N,initialFocusRef:j});function E(){if(!i)return;const z=L9(u);if(z===null){m("Not a ProFiles configuration file. Allowed extensions: .profiles, .profiles.yaml");return}m(null);const te=o.trim()||i.current_path;if(o.trim()===i.current_path&&i.items.some(F=>!F.is_dir&&F.name===z)){C({filename:z,directory:te});return}t({filename:z,directory:te,overwrite:!1})}if(!n)return null;const T=(i==null?void 0:i.items.filter(z=>z.is_dir))??[];return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-4 backdrop-blur-sm",onClick:e,children:y.jsxs("div",{ref:N,role:"dialog","aria-modal":"true","aria-labelledby":"save-as-dialog-title",onKeyDown:U,onClick:z=>z.stopPropagation(),className:"animate-modal-in flex max-h-[calc(100dvh-2rem)] w-[min(94vw,560px)] flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",children:[y.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-line px-5 py-3",children:y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(rO,{className:"h-4 w-4 text-chip-indigo-text"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"save-as-dialog-title",className:"text-sm font-semibold text-ink",children:"Save configuration as"}),y.jsx("p",{className:"truncate font-mono text-xs text-ink-muted",children:(i==null?void 0:i.current_path)||"…"})]})]})}),y.jsxs("div",{className:"border-b border-line px-5 py-3",children:[y.jsx("label",{htmlFor:"save-as-path",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"Location"}),y.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[y.jsx("input",{ref:D,id:"save-as-path",type:"text",value:o,onChange:z=>a(z.target.value),onKeyDown:z=>{z.key==="Enter"&&I(o.trim())},placeholder:"/path/to/directory",className:"h-9 min-w-0 flex-1 rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),y.jsx("button",{type:"button",onClick:()=>void I(o.trim()),className:"inline-flex h-9 shrink-0 items-center rounded-lg border border-line bg-elevated px-3 text-sm font-medium text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Go"}),y.jsx($e,{text:"Home directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void I(""),"aria-label":"Home directory",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx($d,{className:"h-4 w-4"})})}),(i==null?void 0:i.parent_path)&&y.jsx($e,{text:"Parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void I(i.parent_path),"aria-label":"Parent directory",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Xd,{className:"h-4 w-4 rotate-180"})})})]})]}),y.jsx("div",{className:"min-h-24 flex-1 overflow-y-auto px-2 py-2 sm:px-3","aria-busy":g,children:g?y.jsxs("div",{className:"flex h-full items-center justify-center gap-2.5 text-sm text-ink-muted",children:[y.jsx(sl,{className:"h-5 w-5 animate-spin text-chip-indigo-text"}),y.jsx("span",{role:"status",children:"Loading directories…"})]}):v?y.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2.5 text-center",children:[y.jsx("p",{className:"text-sm text-status-danger-text",children:v}),y.jsx("button",{type:"button",onClick:()=>void I(o||(i==null?void 0:i.current_path)||""),className:"min-h-9 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Retry"})]}):y.jsxs("ul",{className:"space-y-0.5",children:[T.map(z=>y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>void I(z.path),className:"flex min-h-9 w-full items-center gap-2.5 rounded-lg px-3 py-1.5 text-left text-sm text-ink-secondary transition-colors hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400",children:[y.jsx(Ou,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"}),y.jsx("span",{className:"truncate",children:z.name})]})},z.path)),T.length===0&&y.jsxs("li",{className:"flex min-h-16 flex-col items-center justify-center gap-2 text-center text-sm text-ink-muted",children:[y.jsx(es,{className:"h-6 w-6 text-ink-faint"}),"No subdirectories found"]})]})}),y.jsxs("div",{className:"shrink-0 border-t border-line px-5 py-3",children:[y.jsx("label",{htmlFor:"save-as-filename",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"File name"}),y.jsx("input",{ref:j,id:"save-as-filename",type:"text",value:u,onChange:z=>{f(z.target.value),m(null)},onKeyDown:z=>{z.key==="Enter"&&u.trim()&&E()},placeholder:"machine.profiles",className:"h-9 w-full rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),d&&y.jsx("p",{role:"alert","data-testid":"save-as-error",className:"mt-1.5 text-xs text-status-danger-text",children:d}),y.jsxs("div",{className:"mt-3 flex justify-end gap-1.5",children:[y.jsx("button",{type:"button",onClick:e,className:"min-h-9 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Cancel"}),y.jsxs("button",{type:"button",onClick:E,disabled:!u.trim()||!i||g,title:"Save the configuration to the selected folder",className:"btn btn-primary min-h-9 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(Lr,{className:"h-4 w-4"}),"Save"]})]})]})]})}),y.jsx(Js,{isOpen:S!==null,title:"Replace configuration?",message:`A configuration named "${S==null?void 0:S.filename}" already exists in this folder. +Saving will replace it.`,confirmLabel:"Replace",cancelLabel:"Keep existing",danger:!0,onConfirm:()=>{const z=S;C(null),z&&t({...z,overwrite:!0})},onCancel:()=>C(null)})]})}const B9=800,P9=Oe.theme({"&":{height:"100%",fontSize:"12.5px",color:"var(--app-text-primary)",backgroundColor:"var(--app-editor-bg)"},".cm-scroller":{fontFamily:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",lineHeight:"1.6"},".cm-content":{caretColor:"var(--color-indigo-500, #6366f1)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--color-indigo-500, #6366f1)"},"&.cm-focused":{outline:"none"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:"var(--app-editor-selection)"},".cm-activeLine":{backgroundColor:"var(--app-editor-active-line)"},".cm-matchingBracket":{color:"inherit",backgroundColor:"var(--app-editor-selection)",outline:"1px solid var(--app-editor-border)"},".cm-nonmatchingBracket":{color:"inherit",outline:"1px solid var(--status-danger-border, #fb7185)"},".cm-gutters":{backgroundColor:"var(--app-editor-gutter-bg)",color:"var(--app-text-faint)",border:"none",borderRight:"1px solid var(--app-editor-border)"},".cm-activeLineGutter":{backgroundColor:"var(--app-editor-active-line)",color:"var(--app-text-secondary)"},".cm-panels":{backgroundColor:"var(--app-editor-bg)",color:"var(--app-text-primary)"},".cm-tooltip":{border:"1px solid var(--app-border)",backgroundColor:"var(--app-glass-panel-strong)",color:"var(--app-text-primary)"}}),H9=Mu.define([{tag:he.lineComment,color:"var(--app-editor-syntax-comment)"},{tag:[he.propertyName,he.definition(he.propertyName)],color:"var(--app-editor-syntax-key)"},{tag:[he.string,he.special(he.string)],color:"var(--app-editor-syntax-string)"},{tag:he.content,color:"var(--app-editor-syntax-string)"},{tag:[he.keyword,he.typeName],color:"var(--app-editor-syntax-keyword)"},{tag:he.labelName,color:"var(--app-editor-syntax-label)"}]);function E0(n){return n.replace(/\r\n?/g,` +`)}function Ph(n,e){return n!==null&&n.state.doc.toString()!==e}function I9(n){return n instanceof gy&&Array.isArray(n.detail)?{text:n.message,issues:n.detail}:{text:n instanceof Error?n.message:String(n),issues:[]}}function U9({open:n,onClose:e,onApplied:t,onLoadConfig:i,reloadKey:l=0}){const[o,a]=M.useState({status:"loading"}),[u,f]=M.useState(!1),[d,m]=M.useState(!1),[g,b]=M.useState(null),[v,w]=M.useState([]),[S,C]=M.useState({kind:"unknown"}),[N,j]=M.useState(!1),[D,I]=M.useState({line:1,col:1}),[U,E]=M.useState(null),[T,z]=M.useState(null),[te,q]=M.useState(null),[G,F]=M.useState(null),se=M.useRef(null),me=M.useRef(null),ne=M.useRef(null),_=M.useRef(""),Z=M.useRef(null),ie=M.useRef(0),re=M.useRef(new Map),A=M.useRef(null),Be=M.useRef(null),ze=M.useRef(!1),B=M.useRef(()=>{}),R=M.useRef(()=>{});ze.current=T!==null||te!==null||G!==null;const $=ds({isOpen:n,onClose:je,dialogRef:se});M.useEffect(()=>{if(!n){_.current="",Z.current=null,ne.current=null,a({status:"loading"}),f(!1),m(!1),b(null),w([]),C({kind:"unknown"}),j(!1),I({line:1,col:1}),E(null),z(null),q(null),F(null),A.current!==null&&(clearTimeout(A.current),A.current=null),Be.current=null,ie.current+=1,re.current.clear();return}let de=!1;return Bk().then(pe=>{if(de)return;const Ee=E0(pe.content);_.current=Ee,Z.current=pe.content_hash??null,Be.current=Ee,a({status:"ready",data:{...pe,content:Ee}})}).catch(pe=>{de||(_.current="",a({status:"error",message:pe instanceof Error?pe.message:String(pe)}))}),()=>{de=!0}},[n,l]);const ue=M.useCallback(()=>{A.current!==null&&(clearTimeout(A.current),A.current=null)},[]),ge=M.useCallback(de=>{ze.current||de!==Be.current&&(ue(),A.current=window.setTimeout(()=>{if(A.current=null,re.current.has("test")){R.current(de);return}B.current()},B9))},[ue]);M.useEffect(()=>{if(!n||o.status!=="ready")return;const de=me.current;if(!de)return;const pe=new Oe({doc:o.data.content,extensions:[FB,A9(),lT(H9),P9,Oe.updateListener.of(Ee=>{if(Ee.selectionSet||Ee.docChanged){const nt=Ee.state.selection.main.head,at=Ee.state.doc.lineAt(nt);I({line:at.number,col:nt-at.from+1})}Ee.docChanged&&(f(Ph(Ee.view,_.current)),b(null),w([]),C({kind:"unknown"}),j(!1),ge(Ee.state.doc.toString()))})],parent:de});return ne.current=pe,()=>{pe.destroy(),ne.current=null,ue()}},[n,o]);function je(){if(Ph(ne.current,_.current)){m(!0);return}e()}const Ne=M.useCallback(()=>{DM().catch(de=>{console.error("Failed to open config file in OS editor:",de)})},[]);function Pe(){var de;return((de=ne.current)==null?void 0:de.state.doc.toString())??_.current}const be=M.useCallback(async(de,pe)=>{if(re.current.has(de))return;const Ee=++ie.current;re.current.set(de,Ee);try{await pe(Ee)}finally{re.current.get(de)===Ee&&re.current.delete(de)}},[]),_e=M.useCallback(()=>be("new",async de=>{b(null),w([]);try{const pe=await TM();if(de!==ie.current)return;const Ee=E0(pe.content);_.current=Ee,Z.current=null,f(!1),a(nt=>nt.status==="ready"?{status:"ready",data:{...nt.data,filename:pe.filename,content:Ee,config_path:null}}:nt),b({kind:"ok",text:"New configuration template loaded."})}catch(pe){if(de!==ie.current)return;b({kind:"error",text:pe instanceof Error?pe.message:String(pe)})}}),[be]),Pt=M.useCallback(()=>be("revert",async de=>{b(null),w([]);try{const pe=await Bk();if(de!==ie.current)return;const Ee=E0(pe.content);_.current=Ee,Z.current=pe.content_hash??null,f(!1),a({status:"ready",data:{...pe,content:Ee}}),b({kind:"ok",text:"Configuration reloaded from disk."})}catch(pe){if(de!==ie.current)return;b({kind:"error",text:pe instanceof Error?pe.message:String(pe)})}}),[be]);function tn(){if(Ph(ne.current,_.current)){E("new");return}_e()}function gn(){if(Ph(ne.current,_.current)){E("revert");return}Pt()}const zt=M.useCallback(()=>be("test",async de=>{if(o.status!=="ready")return;ue();const pe=Pe();Be.current=pe,C({kind:"validating"});try{const Ee=await Pk(o.data.filename,pe);if(de!==ie.current)return;w(Ee.issues),Ee.valid?(C({kind:"valid"}),b({kind:"ok",text:"Configuration is valid."})):(C({kind:"invalid",count:Ee.issues.length}),j(!0),b({kind:"error",text:`Validation failed with ${Ee.issues.length} issue${Ee.issues.length===1?"":"s"}.`}))}catch(Ee){if(de!==ie.current)return;w([]),C({kind:"unknown"}),b({kind:"error",text:Ee instanceof Error?Ee.message:String(Ee)})}}),[o,be]);B.current=()=>void zt(),R.current=ge;const Ct=M.useCallback(()=>be("apply",async de=>{if(o.status==="ready")try{const pe=await GC(o.data.filename,Pe());if(de!==ie.current)return;b({kind:"ok",text:"Configuration applied (session trial)."}),t==null||t(pe)}catch(pe){if(de!==ie.current)return;b({kind:"error",text:pe instanceof Error?pe.message:String(pe)})}}),[o,t,be]),ot=M.useCallback(de=>new Promise(pe=>{z({issues:de,resolve:Ee=>{z(null),pe(Ee)}})}),[]),nn=M.useCallback(()=>new Promise(de=>{q({resolve:pe=>{q(null),de(pe)}})}),[]),Pn=M.useCallback(()=>new Promise(de=>{F({resolve:pe=>{F(null),de(pe)}})}),[]),Ht=M.useCallback((de,pe,Ee)=>{if(_.current=pe,Z.current=Ee,f(!1),w([]),C({kind:"unknown"}),z(null),q(null),de.config_path){const nt=de.config_path.split(/[\\/]/).pop()||de.title||"configuration";a(at=>at.status!=="ready"||!(at.data.filename!==nt||at.data.config_path!==de.config_path||at.data.session_trial)?at:{status:"ready",data:{...at.data,filename:nt,config_path:de.config_path,session_trial:!1,content:pe}})}t==null||t(de)},[t]),rn=M.useCallback(de=>{const pe=I9(de);z(null),q(null),w(pe.issues),pe.issues.length>0?(C({kind:"invalid",count:pe.issues.length}),j(!0)):C({kind:"unknown"}),b({kind:"error",text:pe.text})},[]),Se=M.useCallback((de,pe)=>be(de,async Ee=>{if(o.status!=="ready")return;const nt=Pe();b(null),w([]),C({kind:"validating"});try{const at=await Pk(pe,nt);if(Ee!==ie.current)return;let hn=!1;if(at.valid)C({kind:"valid"});else{if(C({kind:"invalid",count:at.issues.length}),w(at.issues),j(!0),hn=await ot(at.issues),Ee!==ie.current)return;if(!hn){b({kind:"error",text:"Save cancelled — fix the listed issues, or force-save anyway."});return}}if(de==="save-as"){const Kt=await nn();if(Ee!==ie.current||Kt===null)return;const bi=await AM({content:nt,filename:Kt.filename,directory:Kt.directory,force:hn,overwrite:Kt.overwrite});if(Ee!==ie.current)return;Ht(bi.config,nt,bi.contentHash),b({kind:"ok",text:`Configuration saved as ${Kt.filename}.`})}else{let Kt;try{Kt=await Hk(nt,hn,{baselineHash:Z.current})}catch(bi){if(!(bi instanceof gy)||bi.status!==409)throw bi;const Vt=await Pn();if(Ee!==ie.current)return;if(!Vt){Pt();return}Kt=await Hk(nt,hn,{baselineHash:Z.current,overwriteChanges:!0})}if(Ee!==ie.current)return;Ht(Kt.config,nt,Kt.contentHash),b({kind:"ok",text:`Configuration saved to ${pe}.`})}}catch(at){if(Ee!==ie.current)return;rn(at)}}),[ot,nn,Pn,o,Ht,rn,Pt,be]),Ve=M.useCallback(()=>Se("save",o.status==="ready"?o.data.filename:""),[o,Se]),We=M.useCallback(()=>Se("save-as",o.status==="ready"?o.data.filename:""),[o,Se]),ft=M.useRef(()=>{});if(ft.current=()=>{o.status==="ready"&&(T!==null||te!==null||G!==null||d||U!==null||(o.data.config_path!==null?Ve():Ct()))},M.useEffect(()=>{if(!n)return;const de=pe=>{(pe.metaKey||pe.ctrlKey)&&!pe.altKey&&!pe.shiftKey&&pe.key.toLowerCase()==="s"&&(pe.preventDefault(),pe.stopPropagation(),ft.current())};return window.addEventListener("keydown",de,!0),()=>window.removeEventListener("keydown",de,!0)},[n]),!n)return null;const ee=o.status==="ready"?o.data.filename:"",fe=o.status==="ready"?o.data.session_trial:!1,Te=o.status!=="ready",He=o.status==="ready"&&o.data.config_path!==null;return y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:se,role:"dialog","aria-modal":"true","aria-labelledby":"config-editor-title",onKeyDown:$,onClick:je,className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",children:y.jsxs("div",{className:"animate-modal-in flex h-[90vh] w-full max-w-6xl flex-col overflow-hidden rounded-xl border border-frame-line glass-panel",onClick:de=>de.stopPropagation(),children:[y.jsxs("div",{"data-testid":"editor-header",className:"flex shrink-0 items-center justify-between gap-3 border-b border-line px-5 py-3",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-chip-indigo-bg text-chip-indigo-text",children:y.jsx(R4,{className:"h-4 w-4"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"config-editor-title",className:"text-sm font-semibold text-ink",children:"Configuration Editor"}),y.jsxs("p",{className:"truncate text-xs text-ink-muted",children:[ee||"…",fe?" • session trial (not anchored to disk)":""]})]})]}),y.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[y.jsxs("button",{type:"button",onClick:tn,disabled:Te,title:"Load the starter configuration template",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(z4,{className:"h-3.5 w-3.5"}),"New"]}),y.jsxs("button",{type:"button",onClick:()=>void zt(),disabled:Te,title:"Validate the editor content in memory",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(I4,{className:"h-3.5 w-3.5"}),"Test"]}),y.jsxs("button",{type:"button",onClick:gn,disabled:Te,title:"Discard edits and reload the file from disk",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(hD,{className:"h-3.5 w-3.5"}),"Revert"]}),He&&y.jsxs("button",{type:"button",onClick:()=>void Ve(),disabled:Te,title:"Save to the configuration file on disk (Ctrl/Cmd+S)",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(rO,{className:"h-3.5 w-3.5"}),"Save"]}),y.jsxs("button",{type:"button",onClick:()=>void We(),disabled:Te,title:"Save the configuration to a new file — also anchors a session trial onto disk",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(mD,{className:"h-3.5 w-3.5"}),"Save As"]}),y.jsxs("button",{type:"button",onClick:()=>void Ct(),disabled:Te,title:"Trial the editor content as the session configuration",className:"btn btn-primary px-2.5 py-1.5 font-semibold",children:[y.jsx(ns,{className:"h-3.5 w-3.5"}),"Apply"]}),i&&y.jsxs("button",{type:"button",onClick:i,title:"Load a different .profiles file",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(oa,{className:"h-3.5 w-3.5"}),"Load config file…"]}),He&&y.jsxs("button",{type:"button",onClick:Ne,title:"Open the configuration file with the OS default editor",className:"btn inline-flex items-center gap-1.5 rounded-md border border-line bg-surface px-2.5 py-1.5 text-xs font-medium text-ink-secondary hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:[y.jsx(nO,{className:"h-3.5 w-3.5"}),"Open in OS"]}),y.jsx("button",{type:"button",onClick:je,"aria-label":"Close editor",className:"rounded-md p-1.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:y.jsx(Ri,{className:"h-4 w-4"})})]})]}),y.jsxs("div",{className:"flex min-h-0 flex-1 gap-2 p-3 sm:p-4",children:[y.jsx("div",{"data-testid":"editor-card",className:"min-w-0 flex-1 overflow-hidden rounded-lg border border-[var(--app-editor-border)] bg-[var(--app-editor-bg)]",children:o.status==="loading"?y.jsx("div",{className:"flex h-full items-center justify-center",children:y.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent"})}):o.status==="error"?y.jsx("div",{className:"flex h-full items-center justify-center p-6",children:y.jsx("div",{className:"max-w-md rounded-md border border-status-danger-border bg-status-danger-bg p-4 text-center text-xs text-status-danger-text",children:o.message})}):y.jsx("div",{ref:me,className:"h-full"})}),o.status==="ready"&&N&&y.jsxs("aside",{"data-testid":"problems-panel","aria-live":"polite",className:"flex w-[280px] shrink-0 flex-col overflow-hidden rounded-lg border border-line bg-surface",children:[y.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-line px-3 py-1.5",children:[y.jsx("span",{className:"text-xs font-semibold text-ink-secondary",children:"Problems"}),y.jsx("button",{type:"button",onClick:()=>j(!1),"aria-label":"Close problems",className:"rounded-md p-1 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:y.jsx(Ri,{className:"h-3.5 w-3.5"})})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:v.length===0?y.jsx("p",{className:"px-2 py-1 text-xs text-ink-faint",children:"No problems detected."}):y.jsx("ul",{"data-testid":"editor-issues",className:"space-y-1",children:v.map((de,pe)=>y.jsxs("li",{tabIndex:0,className:`flex items-start gap-2 rounded-md border px-2.5 py-1.5 text-xs ${de.severity==="error"?"border-status-danger-border bg-status-danger-bg text-status-danger-text":de.severity==="warning"?"border-chip-amber-border bg-chip-amber-bg text-chip-amber-text":"border-line bg-surface text-ink-secondary"}`,children:[de.severity==="error"?y.jsx(ou,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}):de.severity==="warning"?y.jsx(by,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}):y.jsx(xy,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),y.jsx("span",{className:"min-w-0",children:de.message})]},`${de.severity}-${pe}`))})})]})]}),o.status==="ready"&&y.jsxs("footer",{"data-testid":"editor-footer",className:"flex shrink-0 items-center justify-between gap-3 border-t border-line px-5 py-1.5 text-xs",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[y.jsxs("button",{type:"button","data-testid":"validity-chip",onClick:()=>j(de=>!de),title:"Toggle the problems panel","aria-pressed":N,className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-bold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 ${S.kind==="valid"?"border-status-success-border bg-status-success-bg text-status-success-text":S.kind==="invalid"?"border-status-danger-border bg-status-danger-bg text-status-danger-text":"border-line bg-surface text-ink-muted"}`,children:[S.kind==="valid"?y.jsx(Lr,{className:"h-3 w-3"}):S.kind==="invalid"?y.jsx(ou,{className:"h-3 w-3"}):S.kind==="validating"?y.jsx(sl,{className:"h-3 w-3 animate-spin"}):y.jsx(d4,{className:"h-3 w-3"}),S.kind==="valid"?"Valid":S.kind==="invalid"?`${S.count} issue${S.count===1?"":"s"}`:S.kind==="validating"?"Validating…":"Not validated"]}),u&&y.jsxs("span",{role:"status",className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-chip-amber-border bg-chip-amber-bg px-2 py-0.5 text-[10px] font-bold text-chip-amber-text",children:[y.jsx(p4,{className:"h-3 w-3"}),"Unsaved changes"]}),g!==null&&y.jsx("div",{"data-testid":"editor-status","aria-live":"polite",className:`min-w-0 truncate rounded-md border px-2 py-0.5 font-medium ${g.kind==="ok"?"border-status-success-border bg-status-success-bg text-status-success-text":"border-status-danger-border bg-status-danger-bg text-status-danger-text"}`,children:g.text})]}),y.jsxs("div",{className:"flex shrink-0 items-center gap-3 text-ink-muted",children:[y.jsxs("span",{className:"font-mono",children:["Ln ",D.line,", Col ",D.col]}),y.jsx("span",{className:"text-ink-faint",children:"YAML"}),y.jsx("span",{className:"max-w-[220px] truncate font-mono",children:ee})]})]})]})}),y.jsx(Js,{isOpen:d,title:"Discard changes?",message:`The editor contains unsaved changes. +Closing now will discard them.`,confirmLabel:"Discard",cancelLabel:"Keep editing",danger:!0,onConfirm:()=>{m(!1),e()},onCancel:()=>m(!1)}),y.jsx(Js,{isOpen:U!==null,title:"Replace current edits?",message:U==="revert"?`The editor contains unsaved changes. +Reverting will discard them and reload the file from disk.`:`The editor contains unsaved changes. +Loading the starter template will discard them.`,confirmLabel:"Replace",cancelLabel:"Keep editing",danger:!0,onConfirm:()=>{const de=U;E(null),de==="new"?_e():de==="revert"&&Pt()},onCancel:()=>E(null)}),y.jsx(Js,{isOpen:T!==null,title:"Save with validation issues?",danger:!0,message:y.jsxs(y.Fragment,{children:[y.jsx("p",{children:"Saving will write these issues to disk; the file may fail to load until they are fixed."}),y.jsx("ul",{className:"mt-2 space-y-1",children:T==null?void 0:T.issues.map((de,pe)=>y.jsx("li",{className:`rounded-md border px-3 py-1.5 text-xs ${de.severity==="error"?"border-status-danger-border bg-status-danger-bg text-status-danger-text":"border-chip-amber-border bg-chip-amber-bg text-chip-amber-text"}`,children:de.message},`${de.severity}-${pe}`))})]}),confirmLabel:"Force save anyway",cancelLabel:"Go back and fix",onConfirm:()=>T==null?void 0:T.resolve(!0),onCancel:()=>T==null?void 0:T.resolve(!1)}),y.jsx(Js,{isOpen:G!==null,title:"File changed on disk",danger:!0,message:`The configuration file was modified outside this editor since it was loaded. + +Reload disk version: discard your edits and load the file as it is on disk. +Overwrite anyway: save your edits and replace the file's current content.`,confirmLabel:"Overwrite anyway",cancelLabel:"Reload disk version",onConfirm:()=>G==null?void 0:G.resolve(!0),onCancel:()=>G==null?void 0:G.resolve(!1)}),y.jsx(z9,{open:te!==null,onCancel:()=>te==null?void 0:te.resolve(null),onConfirm:de=>te==null?void 0:te.resolve(de)})]})}function F9({position:n,onClose:e,onLaunch:t,onLaunchWithArgs:i,onReveal:l,onOpenFolder:o,onOpenTerminal:a,onScanDirectory:u,onFilterFolder:f,onFilterExtension:d,onCopyPath:m,onCopyFilename:g,onCopyUri:b,onComputeHash:v,onVerifyHash:w,onProperties:S,onClearFile:C,onGenerateBarcode:N,showToast:j}){const[D,I]=M.useState(!1),[U,E]=M.useState(""),T=M.useRef(null),z=M.useRef(null),te=M.useRef(null),[q,G]=M.useState(null);if(M.useEffect(()=>{var re;D&&((re=z.current)==null||re.showModal())},[D]),M.useLayoutEffect(()=>{if(!n){G(null);return}const re=()=>{const A=T.current;if(!A)return;const Be=A.getBoundingClientRect(),ze=8;G({left:Math.max(ze,Math.min(n.x,window.innerWidth-Be.width-ze)),top:Math.max(ze,Math.min(n.y,window.innerHeight-Be.height-ze))})};return re(),window.addEventListener("resize",re),()=>window.removeEventListener("resize",re)},[n]),M.useEffect(()=>{if(!n)return;te.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const re=window.requestAnimationFrame(()=>{var A,Be;(Be=(A=T.current)==null?void 0:A.querySelector("[role='menuitem']"))==null||Be.focus()});return()=>{var A;window.cancelAnimationFrame(re),(A=te.current)==null||A.focus()}},[n]),!n)return null;const{file:F,x:se,y:me}=n,ne=()=>{i(F,U),I(!1),e()},_=re=>{const A=re.lastIndexOf(".");return A!==-1?re.slice(A):""},Z=re=>{const A=Math.max(re.lastIndexOf("/"),re.lastIndexOf("\\"));return A!==-1?re.slice(0,A):re},ie=re=>{const A=Math.max(re.lastIndexOf("/"),re.lastIndexOf("\\"));return A!==-1?re.slice(0,A):""};return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"fixed inset-0 z-[calc(var(--z-context-menu)-1)]",onClick:e,onContextMenu:re=>{re.preventDefault(),e()},"aria-hidden":"true"}),y.jsxs("div",{ref:T,role:"menu","aria-label":`Actions for ${F.filename}`,tabIndex:0,onKeyDown:re=>{var ze,B,R,$;["Escape","ArrowDown","ArrowUp","Home","End"].includes(re.key)&&re.stopPropagation();const A=Array.from(((ze=T.current)==null?void 0:ze.querySelectorAll("[role='menuitem']"))??[]),Be=A.indexOf(document.activeElement);if(re.key==="Escape")re.preventDefault(),e();else if(re.key==="ArrowDown"||re.key==="ArrowUp"){re.preventDefault();const ue=re.key==="ArrowDown"?1:-1;(B=A[(Be+ue+A.length)%A.length])==null||B.focus()}else re.key==="Home"?(re.preventDefault(),(R=A[0])==null||R.focus()):re.key==="End"&&(re.preventDefault(),($=A.at(-1))==null||$.focus())},className:"animate-modal-in fixed z-[var(--z-context-menu)] max-h-[calc(100dvh-16px)] w-56 max-w-[calc(100vw-16px)] overflow-y-auto rounded-lg border border-line bg-surface-glass py-1 text-xs text-ink shadow-2xl backdrop-blur-md",style:q??{left:se,top:me,visibility:"hidden"},children:[y.jsx("div",{className:"border-b border-line px-3 py-2 font-medium text-ink-muted truncate",children:F.filename}),y.jsxs("button",{role:"menuitem",onClick:()=>{t(F),e()},className:"flex w-full items-center gap-2 px-3 py-3 min-h-[44px] hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Launch ${F.filename}`,children:[y.jsx(ns,{className:"h-3.5 w-3.5 fill-current text-status-success-text group-hover:text-white"}),y.jsx("span",{children:"Launch"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{I(!0)},className:"flex w-full items-center gap-2 px-3 py-3 min-h-[44px] hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Launch ${F.filename} with arguments`,children:[y.jsx(ns,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Launch with arguments..."})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{l(F),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Reveal ${F.filename} in file manager`,children:[y.jsx(G0,{className:"h-3.5 w-3.5 text-chip-sky-text group-hover:text-white"}),y.jsx("span",{children:"Reveal in File Manager"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{o(F),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Open folder containing ${F.filename}`,children:[y.jsx(es,{className:"h-3.5 w-3.5 text-chip-amber-text group-hover:text-white"}),y.jsx("span",{children:"Open Folder"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{a(F),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Open terminal in directory containing ${F.filename}`,children:[y.jsx(W0,{className:"h-3.5 w-3.5 text-status-success-text group-hover:text-white"}),y.jsx("span",{children:"Open Terminal in Directory"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{N(F),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":"Generate QR Code",children:[y.jsx(yy,{className:"h-3.5 w-3.5 text-chip-fuchsia-text group-hover:text-white"}),y.jsx("span",{children:"Generate QR Code"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{const re=Z(F.path);u(re),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":"Scan to Directory",children:[y.jsx(es,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Scan to Directory"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{const re=ie(F.rel_path);re&&f(re),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Filter view to folder ${F.filename} is in`,children:[y.jsx(K0,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Filter to Folder"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{const re=_(F.filename);re&&d(re),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Filter view by extension ${_(F.filename)}`,children:[y.jsx(K0,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Filter by Extension"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{m(F,!1),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy full path of ${F.filename}`,children:[y.jsx(fi,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Full Path"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{m(F,!0),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy path of ${F.filename} with forward slashes`,children:[y.jsx(fi,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Path (Forward Slashes)"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{g(F,!1),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy filename of ${F.filename}`,children:[y.jsx(fi,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Filename"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{g(F,!0),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy filename of ${F.filename} without extension`,children:[y.jsx(fi,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Filename (no ext)"})]}),y.jsxs("button",{role:"menuitem",onClick:async()=>{const re=Z(F.path);e();try{await navigator.clipboard.writeText(re),j==null||j(`Copied: ${re}`)}catch(A){j==null||j(`Copy failed: ${(A==null?void 0:A.message)??A}`,"error")}},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":"Copy Directory",children:[y.jsx(fi,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Directory"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{b(F),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy URI of ${F.filename}`,children:[y.jsx(fi,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy URI"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{v(F,"md5"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Compute MD5 hash of ${F.filename}`,children:[y.jsx(aa,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Compute MD5 Hash"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{v(F,"sha256"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Compute SHA256 hash of ${F.filename}`,children:[y.jsx(aa,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Compute SHA256 Hash"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{w(F,"md5"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Verify MD5 hash of ${F.filename}`,children:[y.jsx(aa,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Verify MD5 Hash"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{w(F,"sha256"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Verify SHA256 hash of ${F.filename}`,children:[y.jsx(aa,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Verify SHA256 Hash"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{S(F),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`View properties of ${F.filename}`,children:[y.jsx(G0,{className:"h-3.5 w-3.5 text-chip-sky-text group-hover:text-white"}),y.jsx("span",{children:"Properties"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{C(F),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Remove ${F.filename} from list`,children:[y.jsx(oO,{className:"h-3.5 w-3.5 text-status-danger-text group-hover:text-white"}),y.jsx("span",{children:"Delete"})]})]}),D&&y.jsx("dialog",{ref:z,className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 rounded-xl","aria-labelledby":"args-modal-title",onClick:re=>{re.target===z.current&&I(!1)},onCancel:re=>{re.preventDefault(),I(!1)},children:y.jsxs("div",{className:"animate-modal-in w-96 rounded-xl border border-frame-line glass-panel p-4",children:[y.jsx("h3",{id:"args-modal-title",className:"mb-2 text-sm font-semibold text-ink",children:"Launch with Arguments"}),y.jsx("p",{className:"mb-3 text-xs text-ink-muted truncate",children:F.filename}),y.jsx("input",{type:"text",autoFocus:!0,placeholder:"Arguments (e.g. --verbose --port 80)",value:U,onChange:re=>E(re.target.value),onKeyDown:re=>{re.key==="Enter"&&ne(),re.key==="Escape"&&I(!1)},className:"mb-4 w-full rounded-md border border-line bg-elevated px-3 py-2 text-xs text-ink outline-none focus:border-indigo-500 focus:ring-2 focus:ring-indigo-500","aria-label":"Command line arguments"}),y.jsxs("div",{className:"flex justify-end gap-2",children:[y.jsx("button",{onClick:()=>I(!1),className:"rounded-md px-3 py-1.5 text-xs text-ink-muted hover:bg-elevated hover:text-ink focus:outline-none focus:ring-2 focus:ring-indigo-500","aria-label":"Cancel launch",children:"Cancel"}),y.jsx("button",{onClick:ne,className:"btn btn-primary px-3 py-1.5","aria-label":`Launch ${F.filename} with arguments`,children:"Launch"})]})]})})]})}function q9({isOpen:n,initialPath:e,onClose:t,onSelect:i}){const[l,o]=M.useState(null),[a,u]=M.useState(null),[f,d]=M.useState(""),[m,g]=M.useState(!1),[b,v]=M.useState(null),w=M.useRef(null),S=M.useRef(null),C=M.useRef(null);M.useEffect(()=>{var U;if(!n){(U=C.current)==null||U.focus();return}C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,v(null),N(e||"");const I=requestAnimationFrame(()=>{var E;return(E=S.current)==null?void 0:E.focus()});return()=>{var E;cancelAnimationFrame(I),(E=C.current)==null||E.focus()}},[n]);const N=async I=>{g(!0),v(null);try{const U=await fetch(`/api/fs/browse?path=${encodeURIComponent(I)}`);if(!U.ok)throw new Error("Failed to browse directory");const E=await U.json();o(E),u(E.current_path),d(E.current_path)}catch(U){v(U.message||"Navigation failed")}finally{g(!1)}},j=()=>{const I=f.trim()||a;I&&(i(I),t())},D=I=>{var z;if(I.key==="Escape"){I.preventDefault(),t();return}if(I.key!=="Tab")return;const U=(z=w.current)==null?void 0:z.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(U!=null&&U.length))return;const E=U[0],T=U[U.length-1];I.shiftKey&&document.activeElement===E?(I.preventDefault(),T.focus()):!I.shiftKey&&document.activeElement===T&&(I.preventDefault(),E.focus())};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",onClick:t,children:y.jsxs("div",{ref:w,role:"dialog","aria-modal":"true","aria-labelledby":"directory-picker-title",onKeyDown:D,className:"animate-modal-in flex h-[min(84dvh,760px)] max-h-[calc(100dvh-1.5rem)] w-[min(94vw,960px)] min-h-0 flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",onClick:I=>I.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-line px-4 py-3 sm:px-5",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(es,{className:"h-5 w-5 text-chip-indigo-text"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"directory-picker-title",className:"text-sm font-semibold text-ink",children:"Select a directory"}),y.jsx("p",{className:"truncate font-mono text-xs text-ink-muted",children:(l==null?void 0:l.current_path)||""})]})]}),y.jsx($e,{text:"Close",block:!1,children:y.jsx("button",{type:"button",onClick:t,"aria-label":"Close directory picker",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg text-ink-muted transition-colors hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Ri,{className:"h-4 w-4"})})})]}),y.jsxs("div",{className:"border-b border-line px-4 py-3 sm:px-5",children:[y.jsx("label",{htmlFor:"directory-picker-path",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"Location"}),y.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[y.jsx("input",{ref:S,id:"directory-picker-path",type:"text",value:f,onChange:I=>d(I.target.value),onKeyDown:I=>{I.key==="Enter"&&N(f.trim())},placeholder:"/path/to/directory",className:"h-10 min-w-0 flex-1 rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),y.jsx("button",{type:"button",onClick:()=>N(f.trim()),className:"inline-flex h-10 shrink-0 items-center gap-1.5 rounded-lg border border-line bg-elevated px-3.5 text-sm font-medium text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Go"}),y.jsx($e,{text:"Home directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>N(""),"aria-label":"Home directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx($d,{className:"h-4 w-4"})})}),(l==null?void 0:l.parent_path)&&y.jsx($e,{text:"Parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>N(l.parent_path),"aria-label":"Parent directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Xd,{className:"h-4 w-4 rotate-180"})})})]})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2 sm:px-3 sm:py-3","aria-busy":m,children:m?y.jsxs("div",{className:"flex h-full items-center justify-center gap-2.5 text-sm text-ink-muted",children:[y.jsx(sl,{className:"h-5 w-5 animate-spin text-chip-indigo-text"}),y.jsx("span",{role:"status",children:"Loading directories…"})]}):b?y.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2.5 text-center",children:[y.jsx("p",{className:"text-sm text-status-danger-text",children:b}),y.jsx("button",{type:"button",onClick:()=>N(f||(l==null?void 0:l.current_path)||""),className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Retry"})]}):y.jsxs("ul",{className:"space-y-0.5",children:[l==null?void 0:l.items.filter(I=>I.is_dir).map(I=>y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>N(I.path),onDoubleClick:()=>{d(I.path),i(I.path),t()},className:`flex min-h-10 w-full items-center justify-between rounded-lg px-3 py-1.5 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400 ${a===I.path?"bg-chip-indigo-bg text-chip-indigo-text":"text-ink-secondary hover:bg-elevated hover:text-ink"}`,children:[y.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx(Ou,{className:"h-5 w-5 shrink-0 text-chip-indigo-text"}),y.jsx("span",{className:"truncate",children:I.name})]}),a===I.path&&y.jsx(Lr,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"})]})},I.path)),(l==null?void 0:l.items.filter(I=>I.is_dir).length)===0&&y.jsxs("li",{className:"flex h-full min-h-36 flex-col items-center justify-center gap-2.5 text-center text-sm text-ink-muted",children:[y.jsx(es,{className:"h-7 w-7 text-ink-faint"}),"No subdirectories found"]})]})}),y.jsxs("div",{className:"flex flex-col gap-2 border-t border-line px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:px-5",children:[y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("p",{className:"mb-0.5 text-xs font-medium text-ink-muted",children:"Selected folder"}),y.jsx("p",{className:"truncate font-mono text-sm text-ink",title:a||f,children:a||f||"—"})]}),y.jsxs("div",{className:"flex shrink-0 justify-end gap-1.5",children:[y.jsx("button",{type:"button",onClick:t,className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Cancel"}),y.jsxs("button",{type:"button",onClick:j,disabled:!f.trim(),className:"btn btn-primary min-h-10 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(es,{className:"h-4 w-4"}),"Select folder"]})]})]})]})}):null}function V9({visible:n,onFileSelected:e}){const t=M.useRef(null);return n?y.jsxs("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-drop-overlay)] flex items-center justify-center bg-black/65 backdrop-blur-sm",onClick:()=>{var i;return(i=t.current)==null?void 0:i.click()},"data-testid":"drop-config-overlay",children:[y.jsx("input",{ref:t,type:"file",accept:".profiles,.profiles.yaml,.profiles.yml,.yaml,.yml",className:"hidden",onChange:i=>{var o;const l=(o=i.target.files)==null?void 0:o[0];l&&e(l),i.target.value=""}}),y.jsxs("div",{className:"rounded-xl border-2 border-dashed border-chip-indigo-border bg-surface px-8 py-6 text-center shadow-2xl",children:[y.jsx("span",{className:"mx-auto mb-3 grid h-9 w-9 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(oa,{className:"h-5 w-5 text-chip-indigo-text"})}),y.jsx("p",{className:"text-sm font-semibold text-ink",children:"Drop configuration file"}),y.jsx("p",{className:"mt-1 text-xs text-ink-muted",children:".profiles, .profiles.yaml, .yml, .yaml — session-only preview"})]})]}):null}function Q9({items:n,columnTemplate:e,resizePointerRef:t,resizeMovedRef:i}){return y.jsx("div",{className:"grid select-none items-center border-b border-l-2 border-l-transparent border-line/40 bg-surface/60 font-medium text-ink-muted shadow-sm backdrop-blur-md",role:"row","aria-rowindex":1,"data-file-list-header":!0,style:{gridTemplateColumns:e},children:n.map((l,o)=>{const a=!!(l.onSort&&l.sortKey),u=l.active?l.direction==="asc"?"ascending":"descending":"none";return y.jsxs("div",{role:"columnheader","data-column-key":l.sortKey,className:`group relative flex items-center gap-1.5 truncate px-3 py-2 ${a?"cursor-pointer hover:text-ink transition-colors":""} ${l.active?"text-ink":""}`,...a?{"aria-sort":u,tabIndex:0,onClick:l.onSort,onKeyDown:f=>{var d;(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),(d=l.onSort)==null||d.call(l))}}:{},children:[l.icon,y.jsx("span",{className:"truncate",children:l.label}),a?l.active?l.direction==="asc"?y.jsx(e4,{className:"ml-auto h-3 w-3 shrink-0 text-chip-indigo-text"}):y.jsx(JC,{className:"ml-auto h-3 w-3 shrink-0 text-chip-indigo-text"}):y.jsx(Xk,{className:"ml-auto h-3 w-3 shrink-0 opacity-0 transition-opacity group-hover:opacity-40 hover:opacity-40"}):o>0&&y.jsx(Xk,{className:"ml-auto h-3 w-3 shrink-0 opacity-40"}),l.canResize&&l.onResizeBy&&y.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${l.label} column`,"aria-valuemin":da,"aria-valuemax":Id,"aria-valuenow":l.width??l.defaultWidth??od,"aria-valuetext":`${l.width??l.defaultWidth??od} pixels wide`,title:"Drag to resize; use arrow keys or click either side to adjust",tabIndex:0,onClick:f=>{var g;f.preventDefault(),f.stopPropagation();const d=i.current;if(i.current=!1,d)return;const m=f.currentTarget.getBoundingClientRect();(g=l.onResizeBy)==null||g.call(l,f.clientX{f.preventDefault(),f.stopPropagation();const d=f.currentTarget.parentElement;i.current=!1,t.current={pointerId:f.pointerId,startX:f.clientX,startWidth:l.width??(d==null?void 0:d.getBoundingClientRect().width)??l.defaultWidth??od,resizeTo:l.onResizeTo},f.currentTarget.setPointerCapture(f.pointerId)},onPointerMove:f=>{const d=t.current;if(!d||d.pointerId!==f.pointerId)return;const m=f.clientX-d.startX;Math.abs(m)>2&&(i.current=!0),d.resizeTo(d.startWidth+m)},onPointerUp:f=>{var d;((d=t.current)==null?void 0:d.pointerId)===f.pointerId&&(f.currentTarget.releasePointerCapture(f.pointerId),t.current=null,window.setTimeout(()=>{i.current=!1},0))},onPointerCancel:()=>{t.current=null,i.current=!1},onKeyDown:f=>{var d,m;f.stopPropagation(),f.key==="ArrowLeft"||f.key==="ArrowRight"?(f.preventDefault(),(d=l.onResizeBy)==null||d.call(l,f.key==="ArrowLeft"?-Ih:Ih)):(f.key==="Home"||f.key==="End")&&(f.preventDefault(),(m=l.onResizeTo)==null||m.call(l,f.key==="Home"?da:Id))},className:"absolute inset-y-0 right-0 z-10 w-3 cursor-col-resize touch-none border-r border-transparent transition-colors hover:border-indigo-400 focus-visible:border-indigo-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500"})]},o)})})}const er=28,Hh=12,M0=500,da=80,Id=960,od=160,Ih=24,q2=44,Uh={File:2,Path:3,FileName:1,Type:1,Version:1};function X9({files:n,totalCount:e,rawLoadedCount:t,onLoadMore:i,loadingMore:l=!1,scanning:o=!1,hasScanned:a=!1,activeDirectory:u="",recursive:f=!1,onDisableRecursive:d,onOpenDirectory:m,onLoadConfig:g,filterText:b,onClearFilter:v,prefilterNote:w,columnHeaders:S,columnNames:C,selectedIndex:N,onSelectIndex:j,onLaunch:D,onContextMenu:I,rowColors:U,sort:E,onSortChange:T}){const z=["File"],te=C.length>0?C:z,q=S.length>0?S:te,G=Array.from({length:Math.max(te.length,q.length)},(Se,Ve)=>({key:te[Ve]??z[0],header:q[Ve]??te[Ve]??z[0]})),F=M.useRef(null),[se,me]=M.useState(0),[ne,_]=M.useState(600),[Z,ie]=M.useState(0),[re,A]=M.useState({}),Be=M.useRef(null),ze=M.useRef(!1),B=te.reduce((Se,Ve)=>Se+(Uh[Ve]??1),1),R=(Se,Ve)=>{const We=Math.min(Id,Math.max(da,Math.round(Ve)));A(ft=>({...ft,[Se]:We}))},$=(Se,Ve)=>{var ee;const We=Array.from(((ee=F.current)==null?void 0:ee.querySelectorAll("[data-column-key]"))??[]).find(fe=>fe.dataset.columnKey===Se),ft=re[Se]??(We==null?void 0:We.getBoundingClientRect().width)??od;R(Se,ft+Ve)},ue=[`${q2}px`,...te.map(Se=>re[Se]?`${re[Se]}px`:`minmax(${da}px, ${Uh[Se]??1}fr)`)].join(" "),ge=M.useRef(!1),je=M.useRef(null),Ne=n.length,Pe=t??Ne,be=e??Pe,_e=Pe{const Se=F.current;if(!Se)return;const Ve=new ResizeObserver(We=>{for(const ft of We)_(ft.contentRect.height),ie(ft.contentRect.width)});return Ve.observe(Se),_(Se.clientHeight||600),ie(Se.clientWidth||0),()=>Ve.disconnect()},[]),M.useEffect(()=>{var fe;const Se=F.current;if(!Se||N<0||N>=Ne)return;const Ve=((fe=Se.querySelector("[data-file-list-header]"))==null?void 0:fe.offsetHeight)??0,We=Ve+N*er,ft=We+er;let ee=Se.scrollTop;WeSe.scrollTop+Se.clientHeight&&(ee=ft-Se.clientHeight),ee!==Se.scrollTop&&(Se.scrollTop=ee,me(ee))},[N,Ne]),M.useEffect(()=>{const Se=F.current;if(!Se)return;const Ve=()=>{if(ge.current||!tn||!i)return;const We=Se.scrollTop+Se.clientHeight,ft=Ne*er;ft-WeWe&&(ge.current=!0,window.setTimeout(()=>{ge.current=!1},200),i())};return Se.addEventListener("scroll",Ve,{passive:!0}),window.addEventListener("scroll",Ve,{passive:!0}),()=>{Se.removeEventListener("scroll",Ve),window.removeEventListener("scroll",Ve)}},[n,tn,i,Ne]),M.useEffect(()=>{if(ge.current||!tn||!i)return;const Se=Ne*er,Ve=se+ne;if(!(Se-VeVe))return;const ft=`${Ne}:${Pe}:${be}`;je.current=ft,i()});const gn=M.useCallback(Se=>{me(Se.currentTarget.scrollTop)},[]),zt=Math.max(0,Math.floor(se/er)-Hh),Ct=Math.ceil(ne/er)+Hh*2,ot=Math.min(Ne,zt+Ct),nn=zt*er,Pn=(Se,Ve)=>{if(Ve)return{className:"bg-chip-indigo-bg border-l-4 border-chip-indigo-border text-ink",style:{}};for(const[We,ft]of U)if(Se.toLowerCase().includes(We.toLowerCase()))return{className:"hover:bg-elevated border-l-4 text-ink",style:{borderLeftColor:ft,borderLeftWidth:"4px"}};return{className:"border-l-4 border-transparent text-ink-secondary hover:bg-elevated/60",style:{borderLeftColor:"transparent",borderLeftWidth:"4px"}}},Ht=(tn?Ne+Ct:Ne)*er,rn="btn btn-secondary px-3 py-1.5";return y.jsxs("div",{ref:F,onScroll:gn,className:"flex-1 overflow-auto bg-app text-xs transition-colors duration-200 focus-visible:outline focus-visible:outline-2 focus-visible:outline-indigo-500 focus-visible:outline-offset-[-2px]","data-testid":"file-list","data-loaded-count":Pe,"aria-busy":o,role:"grid","aria-label":"Discovered files","aria-rowcount":Math.max(be,Ne===0?1:0)+1,"aria-colcount":te.length+1,"aria-activedescendant":Ne>0?`file-row-${N}`:void 0,tabIndex:0,children:[y.jsx("div",{className:"sticky top-0 z-10",role:"presentation",children:y.jsx(Q9,{columnTemplate:ue,resizePointerRef:Be,resizeMovedRef:ze,items:[{label:"#",icon:y.jsx(K0,{className:"h-3.5 w-3.5"})},...G.map(({key:Se,header:Ve})=>({label:Ve,weight:Uh[Se]??1,width:re[Se],defaultWidth:Math.min(Id,Math.max(da,Math.round((Z-q2)*(Uh[Se]??1)/B))),canResize:!0,onResizeBy:We=>$(Se,We),onResizeTo:We=>R(Se,We),sortKey:Se,active:(E==null?void 0:E.column)===Se,direction:E==null?void 0:E.direction,onSort:()=>{(E==null?void 0:E.column)!==Se?T({column:Se,direction:"asc"}):E.direction==="asc"?T({column:Se,direction:"desc"}):T(null)}}))]})}),w&&Ne>0&&y.jsxs("div",{role:"note","data-testid":"prefilter-note",className:"flex items-center gap-1.5 border-b border-line/40 bg-surface px-3 py-1 text-[11px] text-ink-faint",children:[y.jsx(xy,{className:"h-3 w-3 shrink-0 text-ink-faint","aria-hidden":"true"}),y.jsx("span",{className:"min-w-0 truncate",children:w})]}),Ne===0?y.jsx("div",{role:"row","aria-rowindex":2,"data-testid":"file-list-empty",children:y.jsx("div",{role:"gridcell","aria-colspan":te.length+1,className:"p-8 text-center text-ink-faint",children:o?y.jsxs("div",{className:"flex flex-col items-center gap-2",children:[y.jsx(sl,{className:"h-5 w-5 animate-spin text-chip-indigo-text motion-reduce:animate-none"}),y.jsx("span",{children:"Scanning files..."})]}):!u.trim()&&g?y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsx("span",{children:"Select a directory first."}),y.jsx("button",{type:"button",onClick:g,className:rn,children:"Choose configuration"})]}):a?b.trim()?y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsxs("span",{children:["No files match “",b,"”."]}),y.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[y.jsx("button",{type:"button",onClick:v,className:rn,children:"Clear filter"}),f&&d&&y.jsx("button",{type:"button",onClick:d,className:rn,children:"Turn off recursive"}),m&&y.jsx("button",{type:"button",onClick:m,className:rn,children:"Open directory"})]})]}):y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsx("span",{children:"No files found for the current directory and extension."}),y.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[f&&d&&y.jsx("button",{type:"button",onClick:d,className:rn,children:"Turn off recursive"}),m&&y.jsx("button",{type:"button",onClick:m,className:rn,children:"Open directory"})]})]}):y.jsx("span",{children:"Select a directory and scan to find files."})})}):y.jsxs("div",{className:"relative",style:{height:Ht},role:"rowgroup",children:[l&&y.jsx("div",{className:"pointer-events-none absolute left-1/2 top-2 z-20 -translate-x-1/2","aria-hidden":"true",children:y.jsx(sl,{className:"h-4 w-4 animate-spin text-chip-indigo-text"})}),y.jsx("div",{style:{transform:`translateY(${nn}px)`},"data-testid":"file-list-window",role:"presentation",children:n.slice(zt,ot).map((Se,Ve)=>{const We=zt+Ve,ft=We===N,ee=Pn(Se.filename,ft);return y.jsxs("div",{id:`file-row-${We}`,"data-row-index":We,role:"row","aria-rowindex":We+2,"aria-selected":ft,onClick:()=>{var fe;j(We),(fe=F.current)==null||fe.focus()},onDoubleClick:()=>D(Se),onContextMenu:fe=>I(fe,Se,We),className:`grid cursor-pointer items-center transition-colors ${ee.className}`,style:{...ee.style,height:er,gridTemplateColumns:ue},children:[y.jsxs("div",{className:"flex items-center justify-end gap-1 px-3 font-mono text-ink-faint",children:[Se.has_hook&&y.jsx("span",{title:Se.hook_pattern?`Launch workflow: ${Se.hook_pattern}`:"Launch workflow configured","aria-label":"Workflow hook attached",className:"inline-flex items-center text-status-warning-text hover:brightness-95",children:y.jsx(aO,{className:"h-3 w-3 shrink-0"})}),y.jsx("span",{className:"hidden sm:inline",children:We+1})]}),te.map((fe,Te)=>{const He=Se.column_values[fe]||(fe==="File"?Se.filename:"-");return y.jsx("div",{role:"gridcell","data-column-key":fe,className:"truncate px-3 font-mono",style:{minWidth:da},title:fe==="Path"?Se.path:He,children:He},Te)})]},Se.path||We)})}),_e&&y.jsxs("div",{className:"pointer-events-none absolute bottom-2 left-1/2 -translate-x-1/2 rounded-full border border-line bg-surface-strong px-3 py-1 text-[11px] text-ink-muted shadow","data-testid":"file-list-paging",children:[l?y.jsx(GM,{className:"mr-1.5 h-4 w-4 animate-spin motion-reduce:animate-none text-ink-muted"}):null,"(",Pe," of ",be," loaded)"]})]})]})}function Zx({id:n,ariaLabel:e,value:t,options:i,onChange:l,placeholder:o,className:a="",inputClassName:u="",optionLabel:f=m=>m,onOpenChange:d}){const m=M.useId(),g=M.useRef(null),[b,v]=M.useState(!1),[w,S]=M.useState(""),[C,N]=M.useState(-1),j=i.filter(T=>f(T).toLocaleLowerCase().includes(w.toLocaleLowerCase())),D=C>=0&&j[C]?`${m}-option-${C}`:void 0;M.useEffect(()=>{const T=z=>{var te;(te=g.current)!=null&&te.contains(z.target)||v(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),M.useEffect(()=>{d==null||d(b)},[b,d]),M.useEffect(()=>{var T;C<0||(T=document.getElementById(`${m}-option-${C}`))==null||T.scrollIntoView({block:"nearest"})},[C,m]);const I=()=>{S(""),N(-1),v(!0)},U=T=>{l(T),S(""),N(-1),v(!1)},E=T=>{if(T.key==="ArrowDown"){if(T.preventDefault(),!b){I(),N(0);return}N(z=>Math.min(z+1,j.length-1))}else if(T.key==="ArrowUp"){if(T.preventDefault(),!b){I(),N(j.length-1);return}N(z=>z<=0?j.length-1:z-1)}else T.key==="Enter"&&b&&j[C]!==void 0?(T.preventDefault(),U(j[C])):T.key==="Escape"&&v(!1)};return y.jsxs("div",{ref:g,onBlur:T=>{var z;(z=g.current)!=null&&z.contains(T.relatedTarget)||v(!1)},className:`relative flex min-w-0 ${a}`,children:[y.jsx("input",{id:n,type:"text",role:"combobox","aria-label":e,"aria-autocomplete":"list","aria-expanded":b,"aria-controls":m,"aria-activedescendant":D,value:t,placeholder:o,onChange:T=>{l(T.target.value),S(T.target.value),N(-1),v(!0)},onKeyDown:E,className:`min-w-0 flex-1 rounded-l-md border border-line bg-elevated px-3 py-1.5 text-ink outline-none transition-colors hover:bg-surface-strong focus:border-indigo-500 ${u}`}),y.jsx("button",{type:"button","aria-label":`Show ${e.toLowerCase()} options`,"aria-expanded":b,title:`Show ${e.toLowerCase()} options`,onMouseDown:T=>T.preventDefault(),onClick:()=>b?v(!1):I(),className:"shrink-0 rounded-r-md border border-l-0 border-line bg-elevated px-2 text-ink-muted hover:bg-surface-strong hover:text-ink focus-visible:z-10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-indigo-500 transition-colors",children:y.jsx(a4,{className:`h-3.5 w-3.5 transition-transform ${b?"rotate-180":""}`})}),b&&y.jsx("ul",{id:m,role:"listbox","aria-label":`${e} options`,className:"absolute left-0 top-full z-[var(--z-combobox-list)] mt-1 max-h-60 w-full min-w-48 overflow-y-auto rounded-md border border-line bg-surface py-1 text-ink shadow-xl",children:j.length>0?j.map((T,z)=>{const te=f(T),q=z===C,G=T===t;return y.jsx("li",{id:`${m}-option-${z}`,role:"option","aria-selected":G,title:te||void 0,onMouseEnter:()=>N(z),onMouseDown:F=>F.preventDefault(),onClick:()=>U(T),className:`cursor-pointer truncate px-3 py-1.5 ${q?"bg-elevated text-ink":"text-ink-secondary"} ${G?"font-semibold":""}`,children:te||"(No filter)"},`${T}-${z}`)}):y.jsx("li",{className:"px-3 py-1.5 text-ink-muted",children:"No matching presets"})})]})}function $9({title:n,release:e,directories:t,activeDirectory:i,onDirectoryChange:l,onBrowseDirectory:o,onGoToParentDirectory:a,onGoToHomeDirectory:u,onOpenActiveDirectory:f,onOpenTerminal:d}){const[m,g]=M.useState(!1);return y.jsxs("header",{className:"relative z-30 flex flex-wrap items-center gap-3 border-b border-line bg-app/90 px-5 py-2 text-xs backdrop-blur-xl shadow-xs transition-all duration-200",children:[y.jsx("div",{className:"flex shrink-0 items-center gap-3",children:y.jsxs("div",{className:"flex items-center gap-3.5",children:[y.jsxs("div",{className:"relative flex h-9 w-9 items-center justify-center rounded-xl bg-gradient-to-br from-chip-indigo-bg to-chip-purple-bg text-chip-indigo-text border border-chip-indigo-border shadow-xs",children:[y.jsx(W0,{className:"h-4 w-4"}),y.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 flex h-2.5 w-2.5 items-center justify-center rounded-full bg-emerald-500 ring-2 ring-app"})]}),y.jsxs("div",{children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("h1",{className:"text-sm font-bold tracking-tight text-ink font-heading",children:"ProFiles"}),n&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-ink-faint",children:"/"}),y.jsx("span",{className:"text-xs font-medium text-chip-indigo-text bg-chip-indigo-bg px-2 py-0.5 rounded-md border border-chip-indigo-border/50",children:n})]})]}),y.jsxs("p",{className:"text-[11px] font-medium text-ink-muted tracking-wide mt-0.5",children:["Crafted by ",y.jsx("span",{className:"text-ink font-semibold",children:"Florent ALBANY"})," • ",y.jsxs("span",{className:"font-mono text-chip-indigo-text",children:["v",e||"0.11.0-rc.2"]})]})]})]})}),y.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[y.jsxs("label",{className:"flex shrink-0 items-center gap-1.5 font-medium text-ink-secondary text-xs",children:[y.jsx(Ou,{className:"h-3.5 w-3.5 text-chip-indigo-text"}),y.jsx("span",{children:"Directory:"})]}),y.jsx($e,{text:"Select or type a directory path to scan files from.",suppress:m,children:y.jsx(Zx,{id:"directory-combobox",ariaLabel:"Directory",value:i,options:t,onChange:l,onOpenChange:g,placeholder:"/path/to/directory",className:"w-full",inputClassName:"font-mono"})}),f&&y.jsx($e,{text:"Open the active directory in the OS file manager",block:!1,children:y.jsx("button",{type:"button",onClick:f,"aria-label":"Open active directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(WM,{className:"h-3.5 w-3.5"})})}),a&&y.jsx($e,{text:"Go to parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:a,"aria-label":"Go to parent directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(Xd,{className:"h-3.5 w-3.5 rotate-180"})})}),o&&y.jsx($e,{text:"Browse for a folder on this system",block:!1,children:y.jsx("button",{type:"button",onClick:o,"aria-label":"Browse directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(es,{className:"h-3.5 w-3.5"})})}),d&&y.jsx($e,{text:"Open the active directory in a terminal",block:!1,children:y.jsx("button",{type:"button",onClick:()=>d(i),"aria-label":"Open directory in terminal",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(W0,{className:"h-3.5 w-3.5"})})}),u&&y.jsx($e,{text:"Set directory to your home folder",block:!1,children:y.jsx("button",{type:"button",onClick:u,"aria-label":"Go to home directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx($d,{className:"h-3.5 w-3.5"})})})]})]})}function Y9({message:n,onRetry:e,retrying:t=!1}){return y.jsx("div",{className:"flex flex-1 items-center justify-center p-8",role:"alert","data-testid":"init-error-panel",children:y.jsxs("div",{className:"w-full max-w-sm rounded-xl border border-line bg-surface p-6 text-center shadow-xl",children:[y.jsx("div",{className:"mx-auto mb-3 flex h-10 w-10 items-center justify-center rounded-full border border-status-danger-border bg-status-danger-bg",children:y.jsx(Gc,{className:"h-5 w-5 text-status-danger-text/80"})}),y.jsx("h3",{className:"text-sm font-semibold text-ink",children:"Couldn't load the app"}),y.jsx("p",{className:"mt-1 break-words text-xs text-ink-secondary",children:n}),y.jsxs("button",{type:"button",onClick:e,disabled:t,className:"btn btn-primary mx-auto mt-4 px-3.5 py-1.5 font-semibold shadow-sm",children:[y.jsx(Yd,{className:`h-3.5 w-3.5 ${t?"animate-spin motion-reduce:animate-none":""}`}),y.jsx("span",{children:t?"Retrying...":"Retry"})]})]})})}const V2=/"([^"]*)"|(\S+)/g,Q2=/"([^"]*)"/g,G9="Unmatched quote";function K9(n){const e=[];let t;for(V2.lastIndex=0;(t=V2.exec(n))!==null;){const a=t[1]!==void 0?t[1]:t[2];a&&a.trim()&&e.push(a)}let i="",l=0;Q2.lastIndex=0;let o;for(;(o=Q2.exec(n))!==null;)i+=n.slice(l,o.index),l=o.index+o[0].length;return i+=n.slice(l),{terms:e,error:i.includes('"')?G9:null}}function gA(n){const e=n.trim();if(!e)return{error:null,groups:[]};const{terms:t,error:i}=K9(e);if(t.length===0)return{error:i,groups:[]};const l=[];let o={includes:[],excludes:[]};for(const a of t){if(a.toUpperCase()==="OR"){l.push(o),o={includes:[],excludes:[]};continue}a==="-"||a==="+"||(a.startsWith("-")&&a.length>1?o.excludes.push(a.slice(1)):a.startsWith("+")&&a.length>1?o.includes.push(a.slice(1)):o.includes.push(a))}return l.push(o),{error:i,groups:l}}const W9=256,qs=new Map;function X2(n){return n.toLowerCase()}function Z9(n){const e=qs.get(n);if(e)return qs.delete(n),qs.set(n,e),e;const{groups:t}=gA(n),i={groups:t.map(l=>({includes:l.includes.map(X2),excludes:l.excludes.map(X2)}))};if(qs.size>=W9){const l=qs.keys().next().value;l!==void 0&&qs.delete(l)}return qs.set(n,i),i}function J9(n,e){return e.includes.every(t=>n.includes(t))&&!e.excludes.some(t=>n.includes(t))}function e8(n,e){const{groups:t}=Z9(e);if(t.length===0)return!0;const i=n.toLowerCase();return t.some(l=>J9(i,l))}function t8({query:n,visible:e}){if(!e)return null;const t=gA(n);return t.error?y.jsx("div",{"data-testid":"filter-syntax-helper",className:"pointer-events-none absolute left-0 right-0 top-full z-[var(--z-syntax-helper)] mt-1 rounded-md border border-status-danger-border bg-surface-strong px-3 py-2 text-[11px] leading-5 text-status-danger-text/90 shadow-xl",children:t.error}):t.groups.length===0?null:y.jsxs("div",{"data-testid":"filter-syntax-helper",className:"pointer-events-none absolute left-0 right-0 top-full z-[var(--z-syntax-helper)] mt-1 rounded-md border border-line bg-surface-strong px-3 py-2 text-[11px] leading-5 text-ink-secondary shadow-xl",children:[y.jsx("span",{className:"mr-1.5 align-[1px] text-[10px] uppercase tracking-wide text-ink-muted",children:"reads as"}),t.groups.map((i,l)=>y.jsxs("span",{"data-testid":"filter-syntax-group",children:[l>0&&y.jsx("span",{className:"mx-1 font-mono text-chip-indigo-text",children:"OR"}),i.includes.map((o,a)=>y.jsxs("span",{children:[a>0&&y.jsx("span",{className:"text-ink-muted",children:" · "}),y.jsx("span",{className:"font-mono text-chip-indigo-text",children:o})]},`i-${a}`)),i.includes.length>0&&i.excludes.length>0&&y.jsx("span",{className:"text-ink-muted",children:" · "}),i.excludes.map((o,a)=>y.jsxs("span",{children:[a>0&&y.jsx("span",{className:"text-ink-muted",children:" · "}),y.jsx("span",{className:"text-ink-muted",children:"✕ "}),y.jsx("span",{className:"font-mono text-status-danger-text/70 line-through",children:o})]},`x-${a}`))]},l))]})}const $2=y.jsxs("span",{className:"flex flex-col gap-1 whitespace-nowrap text-left",children:[y.jsx("span",{className:"font-semibold",children:"Supported operators"}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"a b"})," — AND (both terms)"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"a OR b"})," — either term"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"-a"})," — NOT (exclude)"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"+a"})," — force include"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:'"a b"'})," — exact phrase"]})]});function n8({extensions:n,activeExtension:e,onExtensionChange:t,filterOptions:i,filterText:l,onFilterTextChange:o,recursive:a,onRecursiveChange:u,onScan:f,scanning:d,barcodeMode:m,onBarcodeToggle:g,onCameraBarcodeClick:b,autoRescanActive:v,onTimerClick:w}){const[S,C]=M.useState(!1),[N,j]=M.useState(!1),[D,I]=M.useState(!1);return y.jsxs("div",{className:"flex w-full flex-wrap items-center gap-3 border-b border-line bg-surface-glass p-3 text-xs",children:[y.jsx($e,{text:$2,suppress:N,children:y.jsxs("div",{className:"relative min-w-0 flex-1 basis-64",onFocusCapture:U=>{U.target.tagName==="INPUT"&&C(!0)},onBlurCapture:U=>{U.target.tagName==="INPUT"&&C(!1)},children:[y.jsx(lO,{className:"pointer-events-none absolute left-3 top-1/2 z-10 h-4 w-4 -translate-y-1/2 text-ink-secondary"}),y.jsx(Zx,{id:"filter-combobox",ariaLabel:"File filter",value:l,options:i||[],onChange:o,onOpenChange:j,placeholder:"Filter files: keyword, a OR b, -tag, exact phrase...",className:"w-full",inputClassName:"pl-9 pr-3",optionLabel:U=>U||"(No filter)"}),y.jsx(t8,{query:l,visible:S&&!N&&l.trim().length>0})]})}),y.jsx($e,{text:$2,block:!1,suppress:D,children:y.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[y.jsx("span",{className:"text-ink-muted",children:"Ext:"}),y.jsx(Zx,{id:"extension-combobox",ariaLabel:"Extension filter",value:e,options:n,onChange:t,onOpenChange:I,placeholder:".py OR .toml",className:"w-44",inputClassName:"font-mono px-2.5"})]})}),y.jsx($e,{text:"Include subdirectories when scanning",block:!1,children:y.jsxs("label",{className:"flex shrink-0 cursor-pointer select-none items-center gap-1.5 text-ink-secondary",children:[y.jsx("input",{type:"checkbox",checked:a,onChange:U=>u(U.target.checked),className:"rounded border-line text-chip-indigo-text focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-1 focus-visible:ring-offset-app"}),y.jsx("span",{children:"Recursive"})]})}),y.jsx($e,{text:"Run the scan with the current criteria (Enter)",block:!1,children:y.jsxs("button",{onClick:f,disabled:d,className:"btn btn-primary shrink-0 px-3.5 py-1.5 font-semibold shadow-sm",children:[d?y.jsx(Yd,{className:"h-3.5 w-3.5 animate-spin motion-reduce:animate-none"}):y.jsx(ns,{className:"h-3.5 w-3.5 fill-current"}),y.jsx("span",{children:d?"Scanning...":"Scan"})]})}),y.jsx($e,{text:v?"Auto-rescan is active. Click to configure.":"Configure periodic auto-rescan (hot-folder mode)",block:!1,children:y.jsx("button",{type:"button",onClick:w,"aria-label":"Configure timer / auto-rescan",className:`flex shrink-0 items-center justify-center rounded-md border p-1.5 text-ink-secondary hover:border-indigo-500 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 transition-colors ${v?"border-chip-indigo-border bg-chip-indigo-bg text-chip-indigo-text":"border-line bg-elevated"}`,children:y.jsx(sO,{className:`h-3.5 w-3.5 ${v?"animate-pulse":""}`})})}),y.jsx($e,{text:"Toggle barcode scanner mode (USB HID). When active, scan a barcode to auto-fill controls and trigger a scan.",block:!1,children:y.jsx("button",{type:"button",onClick:g,"aria-label":m?"Disable barcode mode":"Enable barcode mode",className:`flex shrink-0 items-center justify-center rounded-md border p-1.5 text-ink-secondary hover:border-indigo-500 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 transition-colors ${m?"border-chip-indigo-border bg-chip-indigo-bg text-chip-indigo-text":"border-line bg-elevated"}`,children:y.jsx(yy,{className:`h-3.5 w-3.5 ${m?"animate-pulse":""}`})})}),b&&y.jsx($e,{text:"Scan barcode or QR code using webcam / camera (Ctrl + Shift + B)",block:!1,children:y.jsx("button",{type:"button",onClick:b,"aria-label":"Scan barcode with camera",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(eO,{className:"h-3.5 w-3.5"})})})]})}const i8=2e3,r8=500,l8=[{value:null,label:"ALL"},{value:"DEBUG",label:"DEBUG"},{value:"INFO",label:"INFO"},{value:"WARNING",label:"WARNING"},{value:"ERROR",label:"ERROR"},{value:"CRITICAL",label:"CRITICAL"}],Y2={DEBUG:{icon:n4,className:"text-chip-sky-text"},INFO:{icon:xy,className:"text-status-success-text"},WARNING:{icon:by,className:"text-status-warning-text"},ERROR:{icon:ou,className:"text-status-danger-text"},CRITICAL:{icon:ou,className:"text-status-danger-text"},UNKNOWN:{icon:ka,className:"text-ink-faint"}};function s8({isOpen:n,onClose:e,onOpenExternally:t}){const[i,l]=M.useState([]),[o,a]=M.useState("profiles.log"),[u,f]=M.useState(0),[d,m]=M.useState(null),[g,b]=M.useState(""),[v,w]=M.useState(!1),[S,C]=M.useState(!0),[N,j]=M.useState(null),[D,I]=M.useState(!0),U=M.useRef(null),E=M.useRef(null),T=M.useRef(null),z=M.useRef(null),te=M.useRef(S),q=M.useRef({level:d,search:g});te.current=S,q.current={level:d,search:g};const G=M.useCallback(async()=>{const{level:_,search:Z}=q.current;w(!0);try{const ie=await wM({limit:r8,level:_,search:Z});l(ie.entries),a(ie.path),f(ie.size_bytes),j(null)}catch(ie){j((ie==null?void 0:ie.message)||"Failed to read the log file")}finally{w(!1)}},[]);M.useEffect(()=>{n&&G()},[n,G]),M.useEffect(()=>{if(!n||!S)return;const _=window.setInterval(()=>{G()},i8);return()=>window.clearInterval(_)},[n,S,G]),M.useEffect(()=>{if(!n)return;const _=window.setTimeout(()=>void G(),250);return()=>window.clearTimeout(_)},[n,d,g,G]),M.useEffect(()=>{if(!D)return;const _=T.current;_&&(_.scrollTop=_.scrollHeight)},[i,D]),M.useEffect(()=>{if(!n)return;const _=document.activeElement instanceof HTMLElement?document.activeElement:null,Z=requestAnimationFrame(()=>{var ie;return(ie=E.current)==null?void 0:ie.focus()});return()=>{cancelAnimationFrame(Z),_==null||_.focus()}},[n]);const F=_=>{var A;if(_.key==="Escape"){_.preventDefault(),e();return}if(_.key!=="Tab")return;const Z=(A=U.current)==null?void 0:A.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(Z!=null&&Z.length))return;const ie=Z[0],re=Z[Z.length-1];_.shiftKey&&document.activeElement===ie?(_.preventDefault(),re.focus()):!_.shiftKey&&document.activeElement===re&&(_.preventDefault(),ie.focus())},se=()=>{const _=T.current;if(!_)return;const Z=_.scrollHeight-_.scrollTop-_.clientHeight<24;I(Z)},me=async()=>{try{await navigator.clipboard.writeText(i.map(_=>_.raw).join(` +`))}catch{}},ne=M.useMemo(()=>{const _=new Map;for(const Z of i)_.set(Z.level,(_.get(Z.level)??0)+1);return _},[i]);return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",onClick:e,children:y.jsxs("div",{ref:U,role:"dialog","aria-modal":"true","aria-labelledby":"log-viewer-title",onKeyDown:F,className:"animate-modal-in flex h-[min(84dvh,760px)] w-[clamp(560px,85vw,1500px)] min-h-0 flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",onClick:_=>_.stopPropagation(),children:[y.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b border-line px-5 py-4 sm:px-6",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[y.jsx("span",{className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(ka,{className:"h-5 w-5 text-chip-indigo-text","aria-hidden":"true"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"log-viewer-title",className:"text-base font-semibold text-ink",children:"Application logs"}),y.jsxs("p",{className:"truncate font-mono text-xs text-ink-muted",children:[o,y.jsxs("span",{className:"text-ink-faint",children:[" · ",G2(u)]})]})]})]}),y.jsxs("div",{className:"relative min-w-[220px] flex-1",children:[y.jsx(lO,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-ink-faint","aria-hidden":"true"}),y.jsx("input",{ref:z,type:"search",value:g,onChange:_=>b(_.target.value),placeholder:"Filter log lines…","aria-label":"Filter log lines",className:"w-full rounded-lg border border-line bg-elevated py-1.5 pl-8 pr-2.5 font-mono text-xs text-ink placeholder:text-ink-faint focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400"})]}),y.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[y.jsx($e,{text:S?"Pause live tail":"Resume live tail",block:!1,children:y.jsxs("button",{type:"button",onClick:()=>C(_=>!_),"aria-pressed":S,className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 ${S?"border-status-success-border bg-status-success-bg text-status-success-text":"border-line bg-elevated text-ink-muted hover:text-ink"}`,children:[y.jsx("span",{className:`h-2 w-2 rounded-full ${S?"bg-emerald-400":"bg-ink-faint"}`,"aria-hidden":"true"}),S?"Live":"Paused"]})}),y.jsx($e,{text:"Refresh now",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void G(),disabled:v,className:"rounded-lg border border-line bg-elevated p-2 text-ink-muted hover:text-ink disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Yd,{className:`h-4 w-4 ${v?"animate-spin":""}`,"aria-hidden":"true"})})}),y.jsx($e,{text:"Copy visible lines",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void me(),disabled:i.length===0,className:"rounded-lg border border-line bg-elevated p-2 text-ink-muted hover:text-ink disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(fi,{className:"h-4 w-4","aria-hidden":"true"})})}),y.jsx($e,{text:"Open log file in the default application",block:!1,children:y.jsx("button",{type:"button",onClick:()=>{t==null||t(),e()},className:"rounded-lg border border-line bg-elevated p-2 text-ink-muted hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(nO,{className:"h-4 w-4","aria-hidden":"true"})})}),y.jsx($e,{text:"Close",block:!1,children:y.jsx("button",{ref:E,type:"button",onClick:e,className:"rounded-lg p-2 text-ink-muted hover:bg-hover-surface hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Ri,{className:"h-4 w-4","aria-hidden":"true"})})})]})]}),y.jsxs("div",{ref:T,onScroll:se,className:"min-h-0 flex-1 overflow-y-auto overscroll-contain bg-app px-2 py-2 font-mono text-xs leading-relaxed sm:px-3",children:[y.jsxs("div",{className:"sticky top-0 z-10 mb-1 flex items-center gap-2 rounded-md border border-line/40 bg-surface/60 px-2 py-1 text-[10px] font-bold uppercase tracking-wider text-ink-muted shadow-sm backdrop-blur-md",role:"row",children:[y.jsx("span",{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),y.jsx("span",{className:"w-[138px] shrink-0 text-ink/70",children:"Time"}),y.jsx("span",{className:"w-[52px] shrink-0 text-ink/70",children:"Level"}),y.jsx("span",{className:"w-[150px] shrink-0 text-ink/70",children:"Source"}),y.jsx("span",{className:"min-w-0 flex-1 text-ink/70",children:"Message"})]}),N&&y.jsx("p",{role:"alert",className:"px-3 py-6 text-center text-xs text-status-danger-text",children:N}),!N&&i.length===0&&!v&&y.jsx("p",{className:"px-3 py-6 text-center text-xs text-ink-faint",children:"No log entries match the current filters."}),y.jsx("ul",{className:"space-y-0.5",children:i.map((_,Z)=>{const ie=Y2[_.level]??Y2.UNKNOWN,re=ie.icon,A=_.level==="ERROR"||_.level==="CRITICAL";return y.jsxs("li",{className:`group flex items-start gap-2 rounded px-2 py-1 ${A?"bg-status-danger-bg/40":"hover:bg-elevated/50"}`,children:[y.jsx("span",{className:ie.className,children:y.jsx(re,{className:"mt-0.5 h-3.5 w-3.5","aria-hidden":"true"})}),y.jsx("span",{className:"w-[138px] shrink-0 text-ink-faint",children:_.timestamp}),y.jsx("span",{className:`w-[52px] shrink-0 text-[10px] font-semibold ${ie.className}`,children:_.level}),y.jsx("span",{className:"w-[150px] shrink-0 truncate text-ink-faint",title:_.source,children:_.source}),y.jsx("span",{className:"min-w-0 flex-1 break-words text-ink-secondary",children:_.message})]},`${Z}-${_.raw}`)})})]}),y.jsx("div",{className:"border-t border-line/60 bg-elevated/50 px-5 py-2.5 text-[11px] text-ink-faint shadow-sm backdrop-blur-md sm:px-6",children:y.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[y.jsx("span",{className:"mr-auto min-w-0 max-w-full basis-full truncate sm:basis-auto",role:"status","aria-atomic":"true",children:v&&i.length===0?"Loading log entries…":`${i.length} of ${G2(u)} shown`}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("div",{className:"flex overflow-hidden rounded-lg border border-line/60 text-[11px] backdrop-blur-sm",role:"group","aria-label":"Filter by log level",children:l8.map(_=>{const Z=d===_.value,ie=_.value?ne.get(_.value)??0:i.length;return y.jsxs("button",{type:"button",onClick:()=>m(_.value),"aria-pressed":Z,title:_.value?`Show ${_.value} and above`:"Show all levels",className:`flex items-center gap-1 px-2.5 py-1 font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400 ${Z?"bg-indigo-600 text-white":"text-ink-muted hover:bg-elevated hover:text-ink"}`,children:[_.label,y.jsx("span",{className:Z?"text-chip-indigo-text":"text-ink-faint",children:ie})]},_.label)})}),y.jsx($e,{text:"Scroll to the newest entry",block:!1,children:y.jsxs("button",{type:"button",onClick:()=>I(!0),"aria-pressed":D,className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 ${D?"border-chip-indigo-border bg-chip-indigo-bg text-chip-indigo-text":"border-line bg-elevated text-ink-muted hover:text-ink"}`,children:[y.jsx(JC,{className:"h-3.5 w-3.5","aria-hidden":"true"}),y.jsx("span",{className:"hidden sm:inline",children:"Follow tail"})]})})]}),y.jsxs("span",{className:"hidden items-center gap-1.5 lg:flex",children:[y.jsx("span",{className:"hidden sm:inline",children:"Ctrl + Shift + L"}),y.jsx("span",{children:"opens externally"})]})]})})]})}):null}function G2(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}function o8({isOpen:n,onClose:e}){const t=M.useRef(null),i=ds({isOpen:n,onClose:e,dialogRef:t});if(!n)return null;const l=[{key:"F5",desc:"Refresh / re-scan file list"},{key:"Ctrl + R",desc:"Reload configuration & scan"},{key:"Enter",desc:"Execute / launch selected file"},{key:"P",desc:"Open properties for selected file"},{key:"↑ / ↓",desc:"Navigate file list"},{key:"Home / End",desc:"Jump to first / last file"},{key:"PageUp / PageDown",desc:"Page through the file list"},{key:"Ctrl + D",desc:"Focus Directory field"},{key:"Ctrl + E",desc:"Focus Extension field"},{key:"Ctrl + F",desc:"Focus Filter / Search field"},{key:"Ctrl + L",desc:"Focus File List"},{key:"Ctrl + Shift + L",desc:"Open the log viewer"},{key:"Ctrl + ,",desc:"Open the config editor"},{key:"Ctrl + Shift + T",desc:"Toggle theme (Dark / Light)"},{key:"Ctrl + B",desc:"Toggle barcode scanner mode"},{key:"Ctrl + Shift + B",desc:"Open webcam / camera barcode scanner"},{key:"Ctrl + T",desc:"Open auto-rescan timer modal"},{key:"Ctrl + H",desc:"Set directory to home folder"},{key:"? or Ctrl + /",desc:"Show keyboard shortcuts"},{key:"Y / S / N",desc:"Answer workflow guard: Yes / Skip / No (prompt open)"},{key:"Enter",desc:"Confirm active workflow prompt (prompt open)"},{key:"Escape",desc:"Close dialogs / context menu"}];return y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:y.jsxs("div",{ref:t,role:"dialog","aria-modal":"true","aria-label":"Keyboard Shortcuts",onKeyDown:i,className:"animate-modal-in w-[450px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink",children:[y.jsx(iO,{className:"h-5 w-5 text-chip-indigo-text"}),y.jsx("span",{children:"Keyboard Shortcuts"})]}),y.jsx("button",{onClick:e,className:"focus-ring rounded-lg p-1 text-ink-muted hover:bg-elevated hover:text-ink",children:y.jsx(Ri,{className:"h-4 w-4"})})]}),y.jsx("div",{className:"max-h-[60vh] space-y-2 overflow-y-auto pr-1 text-xs",children:l.map(({key:o,desc:a})=>y.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-elevated/50 px-3 py-2",children:[y.jsx("span",{className:"text-ink-secondary",children:a}),y.jsx("kbd",{className:"rounded bg-app px-2 py-0.5 font-mono text-[11px] font-semibold text-chip-indigo-text border border-line",children:o})]},o))}),y.jsx("div",{className:"mt-5 flex justify-end",children:y.jsx("button",{onClick:e,className:"btn btn-primary rounded-lg px-4 py-2 font-semibold",children:"Close"})})]})})}function a8({isOpen:n,activeConfigPath:e,configExists:t=!0,onClose:i,onLoaded:l}){const[o,a]=M.useState(null),[u,f]=M.useState(""),[d,m]=M.useState(null),[g,b]=M.useState(!1),[v,w]=M.useState(null),S=M.useRef(null),C=M.useRef(null),N=M.useRef(null),j=t===!1;M.useEffect(()=>{var G;if(!n){(G=N.current)==null||G.focus();return}N.current=document.activeElement instanceof HTMLElement?document.activeElement:null,w(null);const T=e??"",z=Math.max(T.lastIndexOf("/"),T.lastIndexOf("\\")),te=z>0?T.slice(0,z):"";D(te);const q=requestAnimationFrame(()=>{var F;return(F=C.current)==null?void 0:F.focus()});return()=>{var F;cancelAnimationFrame(q),(F=N.current)==null||F.focus()}},[n,e]);const D=async T=>{b(!0),w(null);try{const z=await EM(T);a(z),f(z.current_path),e&&z.items.some(te=>te.path===e)?m(e):m(null)}catch(z){w(z.message||"Navigation failed")}finally{b(!1)}},I=T=>{var G;if(T.key==="Escape"){T.preventDefault(),i();return}if(T.key!=="Tab")return;const z=(G=S.current)==null?void 0:G.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(z!=null&&z.length))return;const te=z[0],q=z[z.length-1];T.shiftKey&&document.activeElement===te?(T.preventDefault(),q.focus()):!T.shiftKey&&document.activeElement===q&&(T.preventDefault(),te.focus())},U=async()=>{var z;const T=d||(((z=o==null?void 0:o.items.find(te=>te.is_config))==null?void 0:z.path)??null);if(!T){w("Select a configuration file to load.");return}try{b(!0);const te=await CM(T);l(te),i()}catch(te){w(te.message||"Unable to load configuration")}finally{b(!1)}},E=async()=>{const T=(u||(o==null?void 0:o.current_path)||"").trim();if(!T){w("Choose a directory before creating a configuration.");return}try{b(!0);const z=await NM(T);l(z),i()}catch(z){w(z.message||"Unable to create configuration")}finally{b(!1)}};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",onClick:i,children:y.jsxs("div",{ref:S,role:"dialog","aria-modal":"true","aria-labelledby":"load-config-title",onKeyDown:I,className:"animate-modal-in flex h-[min(84dvh,760px)] max-h-[calc(100dvh-1.5rem)] w-[min(94vw,960px)] min-h-0 flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",onClick:T=>T.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-line px-4 py-3 sm:px-5",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(oa,{className:"h-5 w-5 text-chip-indigo-text"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"load-config-title",className:"text-sm font-semibold text-ink",children:j?"Create configuration":"Load configuration"}),y.jsx("p",{className:"truncate font-mono text-xs text-ink-muted",children:(o==null?void 0:o.current_path)||""})]})]}),y.jsx($e,{text:"Close",block:!1,children:y.jsx("button",{type:"button",onClick:i,"aria-label":"Close configuration modal",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg text-ink-muted transition-colors hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Ri,{className:"h-4 w-4"})})})]}),j&&y.jsx("div",{className:"border-b border-line bg-chip-indigo-bg/20 px-4 py-3 text-xs text-ink-secondary",children:"No configuration file was found. Create one here?"}),y.jsxs("div",{className:"border-b border-line px-4 py-3 sm:px-5",children:[y.jsx("label",{htmlFor:"config-path-input",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"Configuration directory"}),y.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[y.jsx("input",{ref:C,id:"config-path-input",type:"text",value:u,onChange:T=>f(T.target.value),onKeyDown:T=>{T.key==="Enter"&&D(u.trim())},placeholder:"/path/to/directory",className:"h-10 min-w-0 flex-1 rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),y.jsx("button",{type:"button",onClick:()=>D(u.trim()),className:"inline-flex h-10 shrink-0 items-center gap-1.5 rounded-lg border border-line bg-elevated px-3.5 text-sm font-medium text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Go"}),y.jsx($e,{text:"Home directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>D(""),"aria-label":"Home directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx($d,{className:"h-4 w-4"})})}),(o==null?void 0:o.parent_path)&&y.jsx($e,{text:"Parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>D(o.parent_path),"aria-label":"Parent directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Xd,{className:"h-4 w-4 rotate-180"})})})]})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2 sm:px-3 sm:py-3","aria-busy":g,children:g?y.jsxs("div",{className:"flex h-full items-center justify-center gap-2.5 text-sm text-ink-muted",children:[y.jsx(sl,{className:"h-5 w-5 animate-spin text-chip-indigo-text"}),y.jsx("span",{role:"status",children:"Loading configuration files…"})]}):v?y.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2.5 text-center",children:[y.jsx("p",{className:"text-sm text-status-danger-text",children:v}),y.jsx("button",{type:"button",onClick:()=>D(u||(o==null?void 0:o.current_path)||""),className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Retry"})]}):y.jsxs("ul",{className:"space-y-1",children:[o==null?void 0:o.items.map(T=>{if(T.is_dir)return y.jsx("li",{children:y.jsx("button",{onClick:()=>D(T.path),onDoubleClick:()=>D(T.path),className:"flex w-full items-center justify-between rounded-md px-3 py-1.5 text-left text-xs text-ink-secondary hover:bg-elevated",children:y.jsxs("span",{className:"flex items-center gap-2",children:[y.jsx(Ou,{className:"h-3.5 w-3.5 text-chip-indigo-text"}),T.name]})})},T.path);const z=d===T.path;return y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>m(T.path),"aria-pressed":z,className:`flex w-full items-center justify-between rounded-lg px-3 py-1.5 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400 ${z?"bg-chip-indigo-bg text-chip-indigo-text":"text-ink-secondary hover:bg-elevated hover:text-ink"}`,children:[y.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx(ka,{className:"h-5 w-5 shrink-0 text-chip-amber-text"}),y.jsx("span",{className:"truncate",children:T.name})]}),T.is_config&&y.jsx(oa,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"}),z&&y.jsx(Lr,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"})]})},T.path)}),(o==null?void 0:o.items.filter(T=>T.is_config).length)===0&&y.jsxs("li",{className:"flex h-full min-h-36 flex-col items-center justify-center gap-2.5 text-center text-sm text-ink-muted",children:[y.jsx(ka,{className:"h-7 w-7 text-ink-faint"}),"No configuration files found"]})]})}),y.jsxs("div",{className:"flex flex-col gap-2 border-t border-line px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:px-5",children:[y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("p",{className:"mb-0.5 text-xs font-medium text-ink-muted",children:"Selected file"}),y.jsx("p",{className:"truncate font-mono text-sm text-ink",title:d||u,children:d||u||"—"})]}),y.jsxs("div",{className:"flex shrink-0 justify-end gap-1.5",children:[y.jsx("button",{type:"button",onClick:i,className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Cancel"}),j?y.jsxs("button",{type:"button",onClick:E,disabled:!u.trim(),className:"btn btn-primary min-h-10 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(oa,{className:"h-4 w-4"}),"Create configuration"]}):y.jsxs("button",{type:"button",onClick:U,disabled:!d,className:"btn btn-primary min-h-10 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(oa,{className:"h-4 w-4"}),"Load configuration"]})]})]})]})}):null}function xA({isOpen:n,onClose:e,initialFilePath:t,md5:i}){const[l,o]=M.useState(null),[a,u]=M.useState(""),[f,d]=M.useState([]),[m,g]=M.useState(!1),[b,v]=M.useState(null),[w,S]=M.useState(!1),[C,N]=M.useState(!1),[j,D]=M.useState(null),I=M.useRef(null),U=ds({isOpen:n,onClose:e,dialogRef:I});M.useEffect(()=>{if(!n)return;async function ne(){if(t){g(!0);try{const _=await qk({filePath:t});o(_.image),u(_.content),E(_.content)}catch(_){v(_.message)}finally{g(!1)}}}ne()},[n,t]);const E=ne=>{const _=ne.split(";").map(Z=>{const ie=Z.split("=");return{key:ie[0]||"",value:ie[1]||""}}).filter(Z=>Z.key||Z.value);d(_)},T=async ne=>{const _=ne.filter(Z=>Z.key.trim()).map(Z=>`${Z.key.trim()}=${Z.value.trim()}`).join(";");if(u(_),!_){o(null);return}try{const Z=await qk({content:_});o(Z.image)}catch(Z){console.error("Failed to re-generate barcode:",Z)}},z=(ne,_,Z)=>{const ie=[...f];ie[ne][_]=Z,d(ie),T(ie)},te=()=>{const ne=[...f,{key:"",value:""}];d(ne)},q=ne=>{const _=f.filter((Z,ie)=>ie!==ne);d(_),T(_)},G=()=>{if(!i||f.some(_=>_.key.toLowerCase()==="md5"))return;const ne=[...f,{key:"md5",value:i}];d(ne),T(ne)},F=async()=>{if(l){D("Saving…");try{const ne=await LM(l,`profiles-qr-${Date.now()}.png`);D(ne.path||ne.message)}catch(ne){D(`Save failed: ${(ne==null?void 0:ne.message)??ne}`)}finally{setTimeout(()=>D(null),6e3)}}},se=async()=>{try{await navigator.clipboard.writeText(a),S(!0),setTimeout(()=>S(!1),2e3)}catch(ne){console.error("Copy failed",ne)}},me=async()=>{if(l)try{const _=await(await fetch(l)).blob();await navigator.clipboard.write([new ClipboardItem({[_.type]:_})]),N(!0),setTimeout(()=>N(!1),2e3)}catch(ne){console.error("Image copy failed",ne)}};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4",onClick:e,children:y.jsxs("div",{ref:I,role:"dialog","aria-modal":"true","aria-label":"QR Code Settings",onKeyDown:U,className:"animate-modal-in w-full max-w-md rounded-xl border border-frame-line glass-panel p-6",onClick:ne=>ne.stopPropagation(),children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"text-sm font-semibold text-ink",children:"QR Code Settings"}),y.jsx("button",{onClick:e,className:"focus-ring rounded-md p-1 text-ink-muted hover:bg-elevated hover:text-ink",children:y.jsx(Ri,{className:"h-4 w-4"})})]}),m?y.jsx("div",{className:"flex h-48 items-center justify-center",children:y.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent"})}):b?y.jsx("div",{className:"rounded-md border border-status-danger-border bg-status-danger-bg p-4 text-center text-xs text-status-danger-text",children:b}):y.jsxs("div",{className:"space-y-6",children:[y.jsxs("div",{className:"flex flex-col items-center gap-4",children:[y.jsxs("div",{className:"relative group",children:[y.jsx("div",{className:"h-48 w-48 overflow-hidden rounded-lg border border-line bg-white p-2",children:l?y.jsx("img",{src:l,alt:"QR Code",className:"h-full w-full object-contain"}):y.jsx("div",{className:"flex h-full items-center justify-center text-xs text-slate-400",children:"No content"})}),l&&y.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/20 rounded-lg",children:y.jsxs("button",{onClick:me,className:"focus-ring flex items-center gap-2 rounded-md bg-white/90 p-2 text-xs font-medium text-slate-900 shadow-sm hover:bg-white",children:[C?y.jsx(Lr,{className:"h-3.5 w-3.5"}):y.jsx(fi,{className:"h-3.5 w-3.5"}),C?"Copied":"Copy Image"]})})]}),y.jsxs("div",{className:"flex w-full gap-2",children:[y.jsxs("button",{onClick:se,className:"btn btn-secondary flex-1 px-3 py-1.5",children:[w?y.jsx(Lr,{className:"h-3.5 w-3.5 text-status-success-text"}):y.jsx(fi,{className:"h-3.5 w-3.5"}),"Copy Content"]}),y.jsxs("button",{onClick:F,disabled:!l,className:"btn btn-primary flex-1 px-3 py-1.5",children:[y.jsx(tO,{className:"h-3.5 w-3.5"}),"Save Image"]})]}),j&&y.jsx("p",{className:"break-all text-center text-[11px] text-ink-muted",role:"status",children:j})]}),y.jsxs("div",{className:"space-y-3",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("label",{className:"text-xs font-medium text-ink-muted uppercase tracking-wider",children:"Payload Fields"}),y.jsxs("div",{className:"flex gap-2",children:[i&&!f.some(ne=>ne.key==="md5")&&y.jsxs("button",{onClick:G,className:"btn-chip flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-bold text-chip-purple-text border border-chip-purple-border",children:[y.jsx(aa,{className:"h-3 w-3"})," Inc. MD5"]}),y.jsxs("button",{onClick:te,className:"btn-chip flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-bold text-chip-indigo-text border border-chip-indigo-border",children:[y.jsx(sD,{className:"h-3 w-3"})," Add Field"]})]})]}),y.jsxs("div",{className:"max-h-48 space-y-2 overflow-y-auto pr-1 custom-scrollbar",children:[f.map((ne,_)=>y.jsxs("div",{className:"flex gap-2 items-center slide-in",children:[y.jsx("input",{type:"text",placeholder:"key",value:ne.key,onChange:Z=>z(_,"key",Z.target.value),className:"w-1/3 rounded border border-line bg-elevated px-2 py-1 text-xs text-ink focus:border-indigo-500 focus:outline-none"}),y.jsx("input",{type:"text",placeholder:"value",value:ne.value,onChange:Z=>z(_,"value",Z.target.value),className:"flex-1 rounded border border-line bg-elevated px-2 py-1 text-xs text-ink focus:border-indigo-500 focus:outline-none"}),y.jsx("button",{onClick:()=>q(_),className:"p-1 text-ink-muted hover:text-status-danger-text transition-colors","aria-label":"Remove field",children:y.jsx(oO,{className:"h-3.5 w-3.5"})})]},_)),f.length===0&&y.jsx("p",{className:"text-center py-4 text-xs text-ink-muted italic",children:"No fields defined"})]})]}),y.jsxs("div",{className:"pt-2 border-t border-line",children:[y.jsx("label",{className:"text-[10px] font-medium text-ink-muted uppercase tracking-wider block mb-1.5",children:"Raw Preview"}),y.jsx("div",{className:"rounded bg-elevated p-2 font-mono text-[10px] text-ink-secondary break-all border border-line",children:a||y.jsx("span",{className:"italic text-ink-muted/50",children:"empty"})})]})]})]})}):null}const K2=["Bytes","KB","MB","GB","TB"];function yA(n){if(n===0)return"0 Bytes";const e=1024,t=Math.max(0,Math.min(K2.length-1,Math.floor(Math.log(n)/Math.log(e))));return parseFloat((n/Math.pow(e,t)).toFixed(2))+" "+K2[t]}function c8(n){const e=Math.max(n.lastIndexOf("\\"),n.lastIndexOf("/"));return e===-1?"":n.slice(0,e)}function u8(n){const e=[`File Properties: ${n.name}`,`Path: ${n.path}`,`Type: ${n.type}`,`Size: ${yA(n.size_bytes)}`,`Created: ${n.created}`,`Modified: ${n.modified}`];return n.md5&&e.push(`MD5: ${n.md5}`),n.sha256&&e.push(`SHA256: ${n.sha256}`),e.join(` +`)}function D0(n,e,t){return n.length<=e+t+1?n:`${n.slice(0,e)}…${n.slice(-t)}`}function f8(n){const e=n.includes("\\")?"\\":"/",t=n.split(/[\\/]/);return t.length<=5?n:[t[0],t[1],"…",t[t.length-2],t[t.length-1]].join(e)}const h8=[{ms:1e3*60,unit:"minute"},{ms:1e3*60*60,unit:"hour"},{ms:1e3*60*60*24,unit:"day"},{ms:1e3*60*60*24*30,unit:"month"},{ms:1e3*60*60*24*365,unit:"year"}];function W2(n,e=new Date){const t=new Date(n.replace(" ","T"));if(Number.isNaN(t.getTime()))return"just now";const i=e.getTime()-t.getTime();if(i<6e4)return"just now";let l="just now";for(const{ms:o,unit:a}of h8){if(i{var F;n||((F=D.current)==null||F.focus(),v(!1))},[n]),M.useEffect(()=>{if(!n||!e)return;const F=new AbortController;return I.current=F,o(null),N(null),u(!0),d(null),(async()=>{try{const se=await jM(e.path,F.signal);if(I.current!==F)return;o(se)}catch(se){if(I.current!==F||se instanceof DOMException&&se.name==="AbortError")return;d(se instanceof Error?se.message:"Failed to load properties")}finally{I.current===F&&u(!1)}})(),()=>{I.current=null,F.abort()}},[n,e]),M.useEffect(()=>{if(!n)return;const F=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=F}},[n]),M.useEffect(()=>{if(!n)return;const F=se=>{if(se.key==="Escape"){if(b)return;t();return}if(se.key!=="Tab")return;const me=j.current;if(!me)return;const ne=Array.from(me.querySelectorAll('button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(re=>re.offsetParent!==null);if(ne.length===0)return;const _=ne[0],Z=ne[ne.length-1],ie=document.activeElement instanceof HTMLElement?document.activeElement:null;se.shiftKey?(ie===_||!me.contains(ie))&&(se.preventDefault(),Z.focus()):ie===Z&&(se.preventDefault(),_.focus())};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[n,b,t]),M.useEffect(()=>{if(!n)return;const F=document.activeElement instanceof HTMLElement?document.activeElement:null;D.current=F;const se=requestAnimationFrame(()=>{var me,ne;(ne=(me=j.current)==null?void 0:me.querySelector("button"))==null||ne.focus()});return()=>cancelAnimationFrame(se)},[n]);const U=async(F,se)=>{try{await navigator.clipboard.writeText(F),g(se),setTimeout(()=>g(null),2e3)}catch(me){console.error("Failed to copy:",me)}},E=async(F,se,me)=>{S(F),N(null);try{await me(),N(se)}catch{N("Action failed")}finally{S(null)}},T=F=>`btn btn-chip rounded-md border px-3 py-2 text-xs ${{reveal:"bg-chip-sky-bg text-chip-sky-text border-chip-sky-border",launch:"border-emerald-500/30 bg-emerald-600 font-semibold text-white hover:bg-emerald-500",folder:"bg-chip-amber-bg text-chip-amber-text border-chip-amber-border"}[F]??"bg-chip-indigo-bg text-chip-indigo-text border-chip-indigo-border"}`,z=(F,se,me,ne=!1,_)=>y.jsxs("div",{className:"flex items-start gap-2 py-1.5 group",children:[y.jsxs("span",{className:"text-ink-muted min-w-[100px] text-xs",children:[F,":"]}),y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("span",{className:`text-ink text-xs break-all ${ne?"font-mono":""}`,children:_??se})}),y.jsx($e,{text:"Copy to clipboard",block:!1,children:y.jsx("button",{onClick:()=>U(se,me),className:"opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-elevated","aria-label":`Copy ${F}`,children:m===me?y.jsx(Lr,{className:"h-3.5 w-3.5 text-status-success-text"}):y.jsx(fi,{className:"h-3.5 w-3.5 text-ink-muted"})})})]}),te=(F,se,me)=>y.jsxs("div",{className:"rounded-lg border border-line bg-elevated p-4",children:[y.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[se,y.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-ink-muted",children:F})]}),me]}),q=()=>y.jsx($e,{text:"Click to copy full path",children:y.jsxs("button",{onClick:()=>void U(l.path,"path"),className:"group mb-3 flex w-full items-center gap-2 rounded-lg border border-line bg-elevated px-3 py-2 text-left hover:bg-surface",children:[y.jsx(Ou,{className:"text-chip-amber-text h-4 w-4 flex-shrink-0"}),y.jsx("span",{className:"text-ink min-w-0 flex-1 truncate font-mono text-xs",children:f8(l.path)}),m==="path"?y.jsx(Lr,{className:"text-status-success-text h-3.5 w-3.5"}):y.jsx(fi,{className:"text-ink-muted h-3.5 w-3.5"})]})});if(!n||!e)return null;const G=e;return y.jsxs("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 backdrop-blur-md p-4",role:"dialog","aria-modal":"true","aria-labelledby":"properties-modal-title",children:[y.jsx("div",{className:"absolute inset-0",onClick:t,onContextMenu:F=>{F.preventDefault(),t()}}),y.jsxs("div",{ref:j,className:"animate-modal-in relative w-full max-w-4xl max-h-[90vh] overflow-hidden rounded-xl border border-frame-line glass-panel flex flex-col",children:[y.jsx("div",{className:"flex-shrink-0 border-b border-line px-6 py-4",children:y.jsxs("div",{className:"flex items-start justify-between gap-4",children:[y.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[y.jsx("div",{className:"rounded-lg bg-indigo-600 p-2 flex-shrink-0",children:y.jsx(Wg,{className:"h-5 w-5 text-white"})}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("h3",{id:"properties-modal-title",className:"text-base font-semibold text-ink truncate",children:"File Properties"}),y.jsx("p",{className:"text-xs text-ink-muted truncate",children:e.filename})]}),y.jsx($e,{text:"Copy all properties to clipboard",block:!1,children:y.jsx("button",{onClick:()=>{l&&U(u8(l),"all")},disabled:!l||a||f!==null,className:"btn-chip ml-2 flex items-center gap-1 rounded-md border border-chip-indigo-border bg-chip-indigo-bg p-1.5 text-chip-indigo-text","aria-label":"Copy all properties",children:m==="all"?y.jsx(Lr,{className:"h-4 w-4 text-status-success-text"}):y.jsx(fi,{className:"h-4 w-4"})})}),y.jsx($e,{text:"Generate Barcode/QR Code",block:!1,children:y.jsx("button",{onClick:()=>v(!0),className:"btn-chip rounded-md border border-chip-indigo-border bg-chip-indigo-bg p-1.5 text-chip-indigo-text",children:y.jsx(yy,{className:"h-4 w-4"})})})]}),y.jsx("button",{onClick:t,className:"focus-ring rounded-md p-1 text-ink-muted hover:bg-elevated hover:text-ink flex-shrink-0","aria-label":"Close",children:y.jsx(Ri,{className:"h-4 w-4"})})]})}),y.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:[a&&y.jsx("div",{className:"flex items-center justify-center py-8",children:y.jsxs("div",{className:"flex flex-col items-center gap-2",children:[y.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent"}),y.jsx("p",{className:"text-xs text-ink-muted",children:"Loading properties..."})]})}),f&&y.jsx("div",{className:"rounded-lg border border-status-danger-border bg-status-danger-bg p-4 text-center",children:y.jsx("p",{className:"text-xs text-status-danger-text",children:f})}),l&&!a&&!f&&y.jsxs("div",{children:[y.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 rounded-lg border border-line bg-elevated px-4 py-2.5",children:[y.jsx("span",{className:"inline-flex items-center gap-1 rounded-md border border-chip-indigo-border bg-chip-indigo-bg px-2 py-0.5 text-xs font-semibold text-chip-indigo-text",children:l.type}),l.attributes.extension&&y.jsx("span",{className:"inline-flex items-center rounded-md border border-line bg-surface px-2 py-0.5 text-xs font-medium text-ink-muted",children:l.attributes.extension}),y.jsxs("span",{className:"text-xs text-ink-muted",title:`${l.size_bytes} bytes`,children:["Size ",y.jsx("strong",{className:"text-ink font-medium",children:yA(l.size_bytes)})]}),y.jsxs("span",{className:"text-xs text-ink-muted",title:l.created,children:["Created ",y.jsx("strong",{className:"text-ink font-medium",children:W2(l.created)})]}),y.jsxs("span",{className:"text-xs text-ink-muted",title:l.modified,children:["Modified ",y.jsx("strong",{className:"text-ink font-medium",children:W2(l.modified)})]}),l.md5&&y.jsx("span",{className:"inline-flex items-center rounded-md border border-chip-purple-border bg-chip-purple-bg px-2 py-0.5 font-mono text-xs font-medium text-chip-purple-text",title:`MD5 ${l.md5}`,children:D0(l.md5,4,4)}),l.attributes.is_symlink&&y.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-chip-fuchsia-border bg-chip-fuchsia-bg px-2 py-0.5 text-xs font-medium text-chip-fuchsia-text",children:[y.jsx(K4,{className:"h-3 w-3"})," Symlink"]})]}),q(),y.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[te("Hashes",y.jsx(aa,{className:"text-chip-purple-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[z("MD5",l.md5,"md5",!0,D0(l.md5,10,6)),z("SHA256",l.sha256,"sha256",!0,D0(l.sha256,10,6))]})),te("Timestamps",y.jsx(r4,{className:"text-chip-sky-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[z("Created",l.created,"created",!0),z("Modified",l.modified,"modified",!0)]})),te("Identity",y.jsx(Wg,{className:"text-chip-indigo-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[z("Type",l.type,"type"),l.attributes.stem&&z("Stem",l.attributes.stem,"attrStem"),z("Extension",l.name.includes(".")?l.name.slice(l.name.lastIndexOf(".")):"None","extension"),z("Directory",c8(l.path)||"None","directory",!0)]})),te("System",y.jsx(Wg,{className:"text-status-success-text h-3.5 w-3.5"}),y.jsxs("div",{children:[y.jsxs("div",{className:"mb-1 flex min-h-[24px] flex-wrap items-center gap-1.5",children:[l.attributes.is_readonly&&y.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-status-danger-border bg-status-danger-bg px-2 py-0.5 text-xs text-status-danger-text",children:[y.jsx(J4,{className:"h-3 w-3"})," Read-only"]}),l.attributes.is_hidden&&y.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-slate-500/30 bg-slate-600/20 px-2 py-0.5 text-xs text-slate-300",children:[y.jsx(T4,{className:"h-3 w-3"})," Hidden"]}),!l.attributes.is_readonly&&!l.attributes.is_hidden&&!l.attributes.is_symlink&&y.jsx("span",{className:"text-xs text-ink-muted",children:"No special flags"})]}),y.jsxs("div",{className:"space-y-0.5",children:[z("File Type",l.attributes.is_file?"Regular File":l.attributes.is_dir?"Directory":"Other","fileType"),l.attributes.permissions&&z("Permissions",l.attributes.permissions,"permissions",!0),l.attributes.owner_uid!==void 0&&z("Owner UID",String(l.attributes.owner_uid),"ownerUid"),l.attributes.group_gid!==void 0&&z("Group GID",String(l.attributes.group_gid),"groupGid")]})]}))]})]})]}),y.jsx("div",{className:"flex-shrink-0 border-t border-line px-6 py-3",children:y.jsxs("div",{className:"flex justify-between items-center gap-2",children:[y.jsx("p",{className:"min-w-0 text-xs text-ink-muted truncate",children:C??"Click the copy icon next to any field to copy its value"}),y.jsxs("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[y.jsx($e,{text:"Show file in Explorer",block:!1,children:y.jsxs("button",{onClick:()=>void E("reveal","Revealed in Explorer",()=>WC(G.path)),disabled:w!==null,className:T("reveal"),children:[y.jsx(G0,{className:"h-3.5 w-3.5"})," Reveal"]})}),y.jsx($e,{text:"Launch file with default association",block:!1,children:y.jsxs("button",{onClick:()=>{i&&(S("launch"),Promise.resolve(i(G)).finally(()=>S(null)))},disabled:w!==null||!i,className:T("launch"),children:[y.jsx(ns,{className:"h-3.5 w-3.5"})," Launch"]})}),y.jsx($e,{text:"Open containing folder",block:!1,children:y.jsxs("button",{onClick:()=>void E("folder","Opened folder",()=>Y0(G.path)),disabled:w!==null,className:T("folder"),children:[y.jsx(es,{className:"h-3.5 w-3.5"})," Open Folder"]})}),y.jsx("button",{onClick:t,className:"btn btn-primary px-4 py-2",children:"Close"})]})]})})]}),y.jsx(xA,{isOpen:b,onClose:()=>v(!1),initialFilePath:e.path,md5:l==null?void 0:l.md5})]})}const m8=["qr_code","code_128","code_39","ean_13","ean_8","upc_a","upc_e","data_matrix"],p8=250,g8=400,x8=.7;function y8(n,e=g8,t=x8){const i=n.videoWidth,l=n.videoHeight;if(!i||!l)return null;const o=Math.min(i,l),a=document.createElement("canvas");a.width=Math.min(e,o),a.height=a.width;const u=a.getContext("2d");if(!u)return null;u.drawImage(n,(i-o)/2,(l-o)/2,o,o,0,0,a.width,a.height);const f=a.toDataURL("image/jpeg",t);return f.slice(f.indexOf(",")+1)}function b8(n,e){const t=n.intervalMs??p8;let i=!1,l=!1;const o=()=>{i=!0,clearInterval(a)},a=setInterval(()=>{if(i||l)return;const u=n.capture();u&&(l=!0,n.decode(u).then(f=>{i||f.decoded&&(o(),e.onDetected(f.decoded))}).catch(f=>{i||(o(),e.onError(f instanceof Error?f.message:"Frame decoding failed"))}).finally(()=>{l=!1}))},t);return o}const v8=8e3;function w8({isOpen:n,onClose:e,onDetected:t}){const i=M.useRef(null),l=M.useRef(null),o=ds({isOpen:n,onClose:e,dialogRef:l}),a=M.useRef(null),u=M.useRef(null),f=M.useRef(null),[d,m]=M.useState(null),[g,b]=M.useState(!1),v=()=>{f.current&&(f.current(),f.current=null),u.current&&(cancelAnimationFrame(u.current),u.current=null),a.current&&(a.current.getTracks().forEach(C=>C.stop()),a.current=null),i.current&&(i.current.srcObject=null)};M.useEffect(()=>{if(!n){v(),m(null);return}let C=!0;async function N(){var D,I,U,E,T;if(m(null),b(!1),typeof window<"u"&&!window.isSecureContext&&window.location.hostname!=="localhost"&&window.location.hostname!=="127.0.0.1"){m("Camera access requires HTTPS or localhost. If connecting across a local network IP (e.g. 192.168.x.x), modern browsers disable camera access for insecure HTTP.");return}const j=((I=(D=navigator.mediaDevices)==null?void 0:D.getUserMedia)==null?void 0:I.bind(navigator.mediaDevices))||((U=navigator.getUserMedia)==null?void 0:U.bind(navigator))||((E=navigator.webkitGetUserMedia)==null?void 0:E.bind(navigator))||((T=navigator.mozGetUserMedia)==null?void 0:T.bind(navigator));if(!j){m(window.isSecureContext?"Camera access is not supported by your browser or environment.":"Camera access is blocked because the page is not served over a secure origin (HTTPS or localhost/127.0.0.1).");return}try{let z;const te=await Promise.race([j({video:{facingMode:"environment",width:{ideal:1280},height:{ideal:720}}}),new Promise((q,G)=>{z=window.setTimeout(()=>G(new DOMException("Camera did not start in time","TimeoutError")),v8)})]).finally(()=>{z!==void 0&&window.clearTimeout(z)});if(!C){te.getTracks().forEach(q=>q.stop());return}a.current=te,i.current&&(i.current.srcObject=te,await i.current.play()),"BarcodeDetector"in window?S():w()}catch(z){if(!C)return;console.error("Camera access error:",z),m(z.name==="NotAllowedError"||z.name==="PermissionDeniedError"?"Camera permission denied. Please allow camera access in your browser settings.":z.name==="TimeoutError"?"The camera did not start in time. On macOS, camera capture needs the packaged desktop app — a bare Python process cannot access the camera. Alternatively, open ProFiles in Chrome, Edge or Safari.":`Could not access camera: ${z.message||"Unknown error"}`)}}return N(),()=>{C=!1,v()}},[n]);const w=()=>{b(!0),f.current=b8({capture:()=>i.current?y8(i.current):null,decode:C=>RM({imageBase64:C,formats:[...m8]})},{onDetected:C=>{v(),t(C)},onError:C=>{v(),m(C)}})},S=()=>{const C=["qr_code","code_128","code_39","ean_13","ean_8","upc_a","upc_e","data_matrix"];let N;try{N=new window.BarcodeDetector({formats:C})}catch(D){console.warn("BarcodeDetector formats unsupported:",D),N=new window.BarcodeDetector}const j=async()=>{if(!i.current||i.current.readyState<2){u.current=requestAnimationFrame(j);return}try{const D=await N.detect(i.current);if(D&&D.length>0){const I=D[0].rawValue;if(I){v(),t(I);return}}}catch(D){console.debug("Frame detection error:",D)}u.current=requestAnimationFrame(j)};u.current=requestAnimationFrame(j)};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm",onClick:e,children:y.jsxs("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":"Camera barcode scanner",onKeyDown:o,className:"relative w-full max-w-lg rounded-2xl border border-frame-line glass-panel p-6 flex flex-col",onClick:C=>C.stopPropagation(),children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink",children:[y.jsx(eO,{className:"h-5 w-5 text-chip-indigo-text"}),y.jsx("span",{children:"Scan with Camera"})]}),y.jsx("button",{onClick:e,className:"focus-ring rounded-lg p-1 text-ink-muted hover:bg-elevated hover:text-ink transition-colors","aria-label":"Close",children:y.jsx(Ri,{className:"h-4 w-4"})})]}),d?y.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[y.jsx("div",{className:"rounded-full bg-status-danger-bg p-3 text-status-danger-text mb-3",children:y.jsx(Gc,{className:"h-6 w-6"})}),y.jsx("p",{className:"text-xs text-status-danger-text max-w-xs",children:d}),y.jsx("button",{onClick:e,className:"btn btn-secondary mt-6 px-4 py-2",children:"Close"})]}):y.jsxs("div",{className:"flex flex-col items-center",children:[y.jsxs("div",{className:"relative aspect-video w-full overflow-hidden rounded-xl bg-black border border-line flex items-center justify-center",children:[y.jsx("video",{ref:i,playsInline:!0,muted:!0,className:"h-full w-full object-cover"}),y.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:y.jsxs("div",{className:"relative h-48 w-48 rounded-lg border-2 border-dashed border-indigo-400/80 bg-indigo-500/5 shadow-[0_0_0_9999px_rgba(0,0,0,0.45)]",children:[y.jsx("div",{className:"absolute top-0 left-0 h-4 w-4 border-t-2 border-l-2 border-indigo-400"}),y.jsx("div",{className:"absolute top-0 right-0 h-4 w-4 border-t-2 border-r-2 border-indigo-400"}),y.jsx("div",{className:"absolute bottom-0 left-0 h-4 w-4 border-b-2 border-l-2 border-indigo-400"}),y.jsx("div",{className:"absolute bottom-0 right-0 h-4 w-4 border-b-2 border-r-2 border-indigo-400"})]})})]}),y.jsx("p",{className:"mt-4 text-center text-xs text-ink-muted",children:g?"Hold a QR code or barcode steady in front of your camera — frames are decoded by the local ProFiles server (no native Barcode Detector in this browser).":"Hold a QR code or barcode steady in front of your camera to auto-scan."})]})]})}):null}function k8({isOpen:n,file:e,onConfirm:t,onDismiss:i}){const l=M.useRef(null);return M.useEffect(()=>{var o;if(n){const a=u=>{u.key==="Enter"?(u.preventDefault(),t()):u.key==="Escape"&&(u.preventDefault(),i())};return window.addEventListener("keydown",a),(o=l.current)==null||o.focus(),()=>window.removeEventListener("keydown",a)}},[n,t,i]),!n||!e?null:y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",onClick:i,children:y.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":`1 file matched: ${e.filename}`,className:"animate-modal-in w-full max-w-sm rounded-xl border border-frame-line glass-panel p-5 flex flex-col gap-4",onClick:o=>o.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink text-sm",children:[e.has_hook?y.jsx(ED,{className:"h-4 w-4 text-chip-purple-text"}):y.jsx(ns,{className:"h-4 w-4 text-status-success-text"}),y.jsx("span",{children:"1 File Matched"})]}),y.jsx("button",{onClick:i,className:"focus-ring rounded p-1 text-ink-muted hover:bg-elevated hover:text-ink","aria-label":"Dismiss",children:y.jsx(Ri,{className:"h-4 w-4"})})]}),y.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-line bg-elevated/50 p-3",children:[y.jsx(ka,{className:"h-5 w-5 text-chip-indigo-text shrink-0 mt-0.5"}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("h4",{className:"text-xs font-semibold text-ink truncate",children:e.filename}),y.jsx("p",{className:"text-[11px] text-ink-muted truncate mt-0.5",children:e.rel_path||e.path}),e.has_hook&&y.jsx("span",{className:"inline-block mt-1 text-[10px] text-chip-purple-text bg-chip-purple-bg px-1.5 py-0.5 rounded border border-chip-purple-border/50 font-medium",children:"Workflow Hook Configured"})]})]}),y.jsx("p",{className:"text-xs text-ink-muted text-center",children:"Launch this file now?"}),y.jsxs("div",{className:"flex gap-2",children:[y.jsx("button",{type:"button",onClick:i,className:"btn btn-secondary flex-1 px-3 py-1.5",children:"Dismiss (Esc)"}),y.jsxs("button",{ref:l,type:"button",onClick:t,className:"btn btn-primary flex-1 px-3 py-1.5 shadow-md",children:[y.jsx(ns,{className:"h-3 w-3 fill-current"}),"Launch (Enter)"]})]})]})})}function S8({systemInfo:n,fileCount:e,theme:t,onToggleTheme:i,onOpenLog:l,onOpenConfig:o,onShowShortcuts:a,onReloadConfig:u,onExport:f,exportDisabled:d=!1,language:m="en",onLanguageChange:g,lanEnabled:b,onToggleLan:v}){return y.jsxs("footer",{className:"flex items-center justify-between border-t border-line bg-app px-4 py-2 text-[11px] text-ink-muted transition-colors duration-200",children:[y.jsx("div",{className:"flex items-center gap-4",children:n&&y.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-line bg-surface px-2.5 py-0.5 text-ink-secondary",children:[y.jsx(XM,{className:"h-3 w-3 text-status-success-text"}),y.jsx("a",{href:`http://${n.hostname}:${window.location.port}`,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ProFiles on ${n.hostname}`,className:"font-mono hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 rounded px-1 py-0.5",children:n.hostname}),y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsx("a",{href:`http://${n.ip}:${window.location.port}`,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ProFiles on ${n.ip}`,className:"font-mono hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 rounded px-1 py-0.5",children:n.ip}),y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsxs("span",{className:"flex items-center gap-1",title:"Session user",children:[y.jsx(ND,{className:"h-3 w-3 text-ink-faint"}),y.jsx("span",{children:n.username||"operator"})]}),v!==void 0&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsx($e,{text:"LAN access",block:!1,children:y.jsxs("button",{onClick:()=>v(b!==!0),disabled:b===null,"aria-pressed":b===!0,className:`focus-ring flex items-center gap-1 rounded px-1 py-0.5 text-[10px] ${b===null?"text-ink-faint cursor-not-allowed":b===!0?"text-status-success-text":"text-ink-muted hover:text-ink"}`,children:[y.jsx(iD,{className:"h-3 w-3"}),y.jsx("span",{children:"LAN"})]})})]})]})}),y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsxs("span",{children:[y.jsx("strong",{className:"text-ink",children:e})," files found"]}),y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsx($e,{text:"Keyboard shortcuts (?)",block:!1,children:y.jsxs("button",{onClick:a,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(iO,{className:"h-3 w-3"}),y.jsx("span",{children:"Shortcuts"})]})}),y.jsx($e,{text:"Open the application log viewer",block:!1,children:y.jsxs("button",{onClick:l,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(ka,{className:"h-3 w-3"}),y.jsx("span",{children:"Logs"})]})}),y.jsx("span",{className:"text-ink-faint",children:"|"}),u&&y.jsx($e,{text:"Reload configuration from disk",block:!1,children:y.jsxs("button",{onClick:u,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(Yd,{className:"h-3 w-3"}),y.jsx("span",{children:"Reload"})]})}),f&&y.jsx($e,{text:"Export the current results as CSV",block:!1,children:y.jsxs("button",{onClick:f,disabled:d,className:"focus-ring flex items-center gap-1 rounded text-ink-muted hover:text-ink disabled:opacity-40 disabled:hover:text-ink-muted",children:[y.jsx(tO,{className:"h-3 w-3"}),y.jsx("span",{children:"Export CSV"})]})}),g&&y.jsxs("div",{className:"flex items-center overflow-hidden rounded border border-line text-[10px]",children:[y.jsx($e,{text:"English",block:!1,children:y.jsxs("button",{onClick:()=>g("en"),className:`flex items-center gap-1 px-1.5 py-0.5 transition-colors ${m==="en"?"bg-indigo-600 text-white focus-ring":"text-ink-muted hover:text-ink focus-ring"}`,children:[y.jsx(V4,{className:"h-3 w-3"}),y.jsx("span",{children:"EN"})]})}),y.jsx($e,{text:"Français",block:!1,children:y.jsx("button",{onClick:()=>g("fr"),className:`flex items-center gap-1 px-1.5 py-0.5 transition-colors ${m==="fr"?"bg-indigo-600 text-white focus-ring":"text-ink-muted hover:text-ink focus-ring"}`,children:y.jsx("span",{children:"FR"})})})]}),y.jsx($e,{text:"Open the configuration editor",block:!1,children:y.jsxs("button",{onClick:o,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(yD,{className:"h-3 w-3"}),y.jsx("span",{children:"Config"})]})}),y.jsx($e,{text:`Switch to ${t==="dark"?"light":"dark"} mode`,block:!1,children:y.jsxs("button",{onClick:i,className:"focus-ring flex items-center gap-1 rounded px-1.5 py-0.5 text-ink-muted hover:bg-elevated hover:text-status-warning-text",children:[t==="dark"?y.jsx(vD,{className:"h-3 w-3 text-status-warning-text"}):y.jsx(tD,{className:"h-3 w-3 text-chip-indigo-text"}),y.jsx("span",{children:t==="dark"?"Light":"Dark"})]})})]})]})}const C8=[{label:"5 seconds",seconds:5},{label:"10 seconds",seconds:10},{label:"30 seconds",seconds:30},{label:"1 minute",seconds:60},{label:"5 minutes",seconds:300}];function O8({isOpen:n,currentInterval:e,onClose:t,onSetInterval:i}){const l=M.useRef(null),o=ds({isOpen:n,onClose:t,dialogRef:l});if(!n)return null;const a=e>0,u=m=>{i(m)},f=m=>{m.preventDefault();const b=m.currentTarget.elements.namedItem("custom-interval"),v=parseInt(b.value,10);!isNaN(v)&&v>0&&i(v)},d=()=>{i(0)};return y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:y.jsxs("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":"Auto-Rescan Timer",onKeyDown:o,className:"animate-modal-in w-[420px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink",children:[y.jsx(sO,{className:"h-5 w-5 text-chip-indigo-text"}),y.jsx("span",{children:"Auto-Rescan Timer"})]}),y.jsx("button",{onClick:t,className:"focus-ring rounded-lg p-1 text-ink-muted hover:bg-elevated hover:text-ink",children:y.jsx(Ri,{className:"h-4 w-4"})})]}),y.jsx("div",{className:"mb-4 rounded-lg bg-elevated/50 px-3 py-2 text-xs",children:a?y.jsxs("div",{className:"flex items-center gap-2 text-status-success-text",children:[y.jsx(b4,{className:"h-4 w-4 animate-pulse"}),y.jsxs("span",{children:["Auto-rescan every ",e,"s"]})]}):y.jsxs("div",{className:"flex items-center gap-2 text-ink-secondary",children:[y.jsx(x4,{className:"h-4 w-4"}),y.jsx("span",{children:"Auto-rescan is disabled"})]})}),y.jsxs("div",{className:"mb-4 space-y-1 text-xs",children:[y.jsx("p",{className:"text-ink-muted",children:"Presets:"}),y.jsx("div",{className:"grid grid-cols-2 gap-2",children:C8.map(m=>y.jsx("button",{onClick:()=>u(m.seconds),className:"rounded-lg border border-line bg-elevated/50 px-3 py-1.5 text-left font-medium text-ink-secondary hover:border-chip-indigo-border hover:bg-chip-indigo-bg/40 hover:text-chip-indigo-text focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:m.label},m.seconds))})]}),y.jsxs("form",{onSubmit:f,className:"mb-4",children:[y.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-ink-secondary",children:[y.jsx(k4,{className:"h-3.5 w-3.5"}),y.jsx("span",{children:"Custom interval (seconds):"})]}),y.jsxs("div",{className:"mt-1 flex gap-2",children:[y.jsx("input",{type:"number",name:"custom-interval",min:"1",placeholder:"e.g. 45",className:"flex-1 rounded-lg border border-line bg-app px-2 py-1 text-xs text-ink placeholder-ink-faint focus:border-indigo-500 focus:outline-none"}),y.jsx("button",{type:"submit",className:"btn btn-primary rounded-lg px-3 py-1 font-semibold",children:"Set"})]})]}),a&&y.jsx("button",{onClick:d,className:"btn w-full rounded-lg border-line bg-elevated/50 px-3 py-2 text-status-warning-text hover:border-status-warning-border hover:bg-status-warning-bg/40",children:"Stop Auto-Rescan"}),y.jsx("div",{className:"flex justify-end gap-2 border-t border-line pt-3",children:y.jsx("button",{onClick:t,className:"rounded-lg border border-line bg-elevated px-4 py-2 text-xs font-semibold text-ink-secondary hover:bg-elevated/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:"Close"})})]})})}function N8(n,e){const t={};return(n[n.length-1]===""?[...n,""]:n).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}const T8=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,A8=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,E8={};function Z2(n,e){return(E8.jsx?A8:T8).test(n)}const M8=/[ \t\n\f\r]/g;function D8(n){return typeof n=="object"?n.type==="text"?J2(n.value):!1:J2(n)}function J2(n){return n.replace(M8,"")===""}class ju{constructor(e,t,i){this.normal=t,this.property=e,i&&(this.space=i)}}ju.prototype.normal={};ju.prototype.property={};ju.prototype.space=void 0;function bA(n,e){const t={},i={};for(const l of n)Object.assign(t,l.property),Object.assign(i,l.normal);return new ju(t,i,e)}function Jx(n){return n.toLowerCase()}class yi{constructor(e,t){this.attribute=t,this.property=e}}yi.prototype.attribute="";yi.prototype.booleanish=!1;yi.prototype.boolean=!1;yi.prototype.commaOrSpaceSeparated=!1;yi.prototype.commaSeparated=!1;yi.prototype.defined=!1;yi.prototype.mustUseProperty=!1;yi.prototype.number=!1;yi.prototype.overloadedBoolean=!1;yi.prototype.property="";yi.prototype.spaceSeparated=!1;yi.prototype.space=void 0;let R8=0;const Qe=co(),un=co(),ey=co(),xe=co(),Mt=co(),io=co(),Ei=co();function co(){return 2**++R8}const ty=Object.freeze(Object.defineProperty({__proto__:null,boolean:Qe,booleanish:un,commaOrSpaceSeparated:Ei,commaSeparated:io,number:xe,overloadedBoolean:ey,spaceSeparated:Mt},Symbol.toStringTag,{value:"Module"})),R0=Object.keys(ty);class lb extends yi{constructor(e,t,i,l){let o=-1;if(super(e,t),eC(this,"space",l),typeof i=="number")for(;++o4&&t.slice(0,4)==="data"&&B8.test(e)){if(e.charAt(4)==="-"){const o=e.slice(5).replace(tC,I8);i="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=e.slice(4);if(!tC.test(o)){let a=o.replace(z8,H8);a.charAt(0)!=="-"&&(a="-"+a),e="data"+a}}l=lb}return new l(i,e)}function H8(n){return"-"+n.toLowerCase()}function I8(n){return n.charAt(1).toUpperCase()}const U8=bA([vA,j8,SA,CA,OA],"html"),sb=bA([vA,_8,SA,CA,OA],"svg");function F8(n){return n.join(" ").trim()}var nC=/\/\*(?:[^*]|\*(?!\/))*\*\//g,q8=/\n/g,V8=/^\s*/,Q8=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,X8=/^:\s*/,$8=/^((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|url\((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|[^)]*)\)|[^};])+)/,Y8=/^[;\s]*/,G8=` +`,iC="/",rC="*",Uc="",K8="comment",W8="declaration";function Z8(n,e){if(typeof n!="string")throw new TypeError("First argument must be a string");if(!n)return[];e=e||{};var t=1,i=1;function l(w){var S=w.match(q8);S&&(t+=S.length);var C=w.lastIndexOf(G8);i=~C?w.length-C:i+w.length}function o(){var w={line:t,column:i};return function(S){return S.position=new a(w),d(),S}}function a(w){this.start=w,this.end={line:t,column:i},this.source=e.source}a.prototype.content=n;function u(w){var S=new Error(e.source+":"+t+":"+i+": "+w);if(S.reason=w,S.filename=e.source,S.line=t,S.column=i,S.source=n,!e.silent)throw S}function f(w){var S=w.exec(n);if(S){var C=S[0];return l(C),n=n.slice(C.length),S}}function d(){f(V8)}function m(w){for(var S;S=g();)w.push(S);return w}function g(){var w=o();if(!(iC!=n.charAt(0)||rC!=n.charAt(1))){for(var S=2;Uc!=n.charAt(S)&&(rC!=n.charAt(S)||iC!=n.charAt(S+1));)++S;if(S+=2,Uc===n.charAt(S-1))return u("End of comment missing");var C=n.slice(2,S-2);return i+=2,l(C),n=n.slice(S),i+=2,w({type:K8,comment:C})}}function b(){var w=o(),S=f(Q8);if(S){if(g(),!f(X8))return u("property missing ':'");var C=f($8),N=w({type:W8,property:S[0].replace(nC,Uc).trim(),value:C?C[0].replace(nC,Uc).trim():Uc});return f(Y8),N}}function v(){var w=[];m(w);for(var S;S=b();)w.push(S),m(w);return w}return d(),v()}function J8(n,e){let t=null;if(!n||typeof n!="string")return t;const i=Z8(n),l=typeof e=="function";return i.forEach(o=>{if(o.type!=="declaration")return;const{property:a,value:u}=o;l?e(a,u,o):u&&(t=t??{},t[a]=u)}),t}const NA=TA("end"),ob=TA("start");function TA(n){return e;function e(t){const i=t&&t.position&&t.position[n]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function eP(n){const e=ob(n),t=NA(n);if(e&&t)return{start:e,end:t}}function ru(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?lC(n.position):"start"in n||"end"in n?lC(n):"line"in n||"column"in n?ny(n):""}function ny(n){return sC(n&&n.line)+":"+sC(n&&n.column)}function lC(n){return ny(n&&n.start)+"-"+ny(n&&n.end)}function sC(n){return n&&typeof n=="number"?n:1}class Vn extends Error{constructor(e,t,i){super(),typeof t=="string"&&(i=t,t=void 0);let l="",o={},a=!1;if(t&&("line"in t&&"column"in t?o={place:t}:"start"in t&&"end"in t?o={place:t}:"type"in t?o={ancestors:[t],place:t.position}:o={...t}),typeof e=="string"?l=e:!o.cause&&e&&(a=!0,l=e.message,o.cause=e),!o.ruleId&&!o.source&&typeof i=="string"){const f=i.indexOf(":");f===-1?o.ruleId=i:(o.source=i.slice(0,f),o.ruleId=i.slice(f+1))}if(!o.place&&o.ancestors&&o.ancestors){const f=o.ancestors[o.ancestors.length-1];f&&(o.place=f.position)}const u=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=l,this.line=u?u.line:void 0,this.name=ru(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Vn.prototype.file="";Vn.prototype.name="";Vn.prototype.reason="";Vn.prototype.message="";Vn.prototype.stack="";Vn.prototype.column=void 0;Vn.prototype.line=void 0;Vn.prototype.ancestors=void 0;Vn.prototype.cause=void 0;Vn.prototype.fatal=void 0;Vn.prototype.place=void 0;Vn.prototype.ruleId=void 0;Vn.prototype.source=void 0;const ab={}.hasOwnProperty,tP=new Map,nP=/[A-Z]/g,iP=/-([a-z])/g,rP=new Set(["table","tbody","thead","tfoot","tr"]),lP=new Set(["td","th"]),AA="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function sP(n,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const t=e.filePath||void 0;let i;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=mP(t,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=dP(t,e.jsx,e.jsxs)}const l={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:i,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:t,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?sb:U8,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},o=EA(l,n,void 0);return o&&typeof o!="string"?o:l.create(n,l.Fragment,{children:o||void 0},void 0)}function EA(n,e,t){if(e.type==="element")return oP(n,e,t);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return aP(n,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return uP(n,e,t);if(e.type==="mdxjsEsm")return cP(n,e);if(e.type==="root")return fP(n,e,t);if(e.type==="text")return hP(n,e)}function oP(n,e,t){const i=n.schema;let l=i;e.tagName.toLowerCase()==="svg"&&i.space==="html"&&(l=sb,n.schema=l),n.ancestors.push(e);const o=DA(n,e.tagName,!1),a=pP(n,e);let u=ub(n,e);return rP.has(e.tagName)&&(u=u.filter(function(f){return typeof f=="string"?!D8(f):!0})),MA(n,a,o,e),cb(a,u),n.ancestors.pop(),n.schema=i,n.create(e,o,a,t)}function aP(n,e){if(e.data&&e.data.estree&&n.evaluater){const i=e.data.estree.body[0];return i.type,n.evaluater.evaluateExpression(i.expression)}Cu(n,e.position)}function cP(n,e){if(e.data&&e.data.estree&&n.evaluater)return n.evaluater.evaluateProgram(e.data.estree);Cu(n,e.position)}function uP(n,e,t){const i=n.schema;let l=i;e.name==="svg"&&i.space==="html"&&(l=sb,n.schema=l),n.ancestors.push(e);const o=e.name===null?n.Fragment:DA(n,e.name,!0),a=gP(n,e),u=ub(n,e);return MA(n,a,o,e),cb(a,u),n.ancestors.pop(),n.schema=i,n.create(e,o,a,t)}function fP(n,e,t){const i={};return cb(i,ub(n,e)),n.create(e,n.Fragment,i,t)}function hP(n,e){return e.value}function MA(n,e,t,i){typeof t!="string"&&t!==n.Fragment&&n.passNode&&(e.node=i)}function cb(n,e){if(e.length>0){const t=e.length>1?e:e[0];t&&(n.children=t)}}function dP(n,e,t){return i;function i(l,o,a,u){const d=Array.isArray(a.children)?t:e;return u?d(o,a,u):d(o,a)}}function mP(n,e){return t;function t(i,l,o,a){const u=Array.isArray(o.children),f=ob(i);return e(l,o,a,u,{columnNumber:f?f.column-1:void 0,fileName:n,lineNumber:f?f.line:void 0},void 0)}}function pP(n,e){const t={};let i,l;for(l in e.properties)if(l!=="children"&&ab.call(e.properties,l)){const o=xP(n,l,e.properties[l]);if(o){const[a,u]=o;n.tableCellAlignToStyle&&a==="align"&&typeof u=="string"&&lP.has(e.tagName)?i=u:t[a]=u}}if(i){const o=t.style||(t.style={});o[n.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return t}function gP(n,e){const t={};for(const i of e.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&n.evaluater){const o=i.data.estree.body[0];o.type;const a=o.expression;a.type;const u=a.properties[0];u.type,Object.assign(t,n.evaluater.evaluateExpression(u.argument))}else Cu(n,e.position);else{const{name:l}=i;let o;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&n.evaluater){const u=i.value.data.estree.body[0];u.type,o=n.evaluater.evaluateExpression(u.expression)}else Cu(n,e.position);else o=i.value===null?!0:i.value;t[l]=o}return t}function ub(n,e){const t=[];let i=-1;const l=n.passKeys?new Map:tP;for(;++il?0:l+e:e=e>l?l:e,t=t>0?t:0,i.length<1e4)a=Array.from(i),a.unshift(e,t),n.splice(...a);else for(t&&n.splice(e,t);o0?(rr(n,n.length,0,e),n):e}const cC={}.hasOwnProperty;function jA(n){const e={};let t=-1;for(;++t13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"�":String.fromCodePoint(t)}function lr(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ln=ms(/[A-Za-z]/),zn=ms(/[\dA-Za-z]/),TP=ms(/[#-'*+\--9=?A-Z^-~]/);function Ud(n){return n!==null&&(n<32||n===127)}const iy=ms(/\d/),AP=ms(/[\dA-Fa-f]/),LA=ms(/[!-/:-@[-`{-~]/);function Ie(n){return n!==null&&n<-2}function Rt(n){return n!==null&&(n<0||n===32)}function Je(n){return n===-2||n===-1||n===32}const fm=ms(new RegExp("\\p{P}|\\p{S}","u")),oo=ms(/\s/);function ms(n){return e;function e(t){return t!==null&&t>-1&&n.test(String.fromCharCode(t))}}function Ba(n){const e=[];let t=-1,i=0,l=0;for(;++t55295&&o<57344){const u=n.charCodeAt(t+1);o<56320&&u>56319&&u<57344?(a=String.fromCharCode(o,u),l=1):a="�"}else a=String.fromCharCode(o);a&&(e.push(n.slice(i,t),encodeURIComponent(a)),i=t+l+1,a=""),l&&(t+=l,l=0)}return e.join("")+n.slice(i)}function xt(n,e,t,i){const l=i?i-1:1/0;let o=0;return a;function a(f){return Je(f)?(n.enter(t),u(f)):e(f)}function u(f){return Je(f)&&o++=l?e(m):t(m)}}const EP={tokenize:MP};function MP(n){const e=n.attempt(this.parser.constructs.contentInitial,i,l);let t;return e;function i(u){if(u===null){n.consume(u);return}return n.enter("lineEnding"),n.consume(u),n.exit("lineEnding"),xt(n,e,"linePrefix")}function l(u){return n.enter("paragraph"),o(u)}function o(u){const f=n.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=f),t=f,a(u)}function a(u){if(u===null){n.exit("chunkText"),n.exit("paragraph"),n.consume(u);return}return Ie(u)?(n.consume(u),n.exit("chunkText"),o):(n.consume(u),a)}}let Fd=class{constructor(){this.index=new Map,this.map=[]}add(e,t,i){uC(this,e,t,i,!1)}addBefore(e,t,i){uC(this,e,t,i,!0)}consume(e){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let t=this.map.length;const i=[];for(;t>0;)t-=1,i.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];i.push(e.slice()),e.length=0;let l=i.pop();for(;l;){for(const o of l)e.push(o);l=i.pop()}this.map.length=0,this.index.clear()}};function uC(n,e,t,i,l){if(t===0&&i.length===0)return;const o=n.index.get(e);if(o){o[1]+=t,l?(i.push(...o[2]),o[2]=i):o[2].push(...i);return}const a=[e,t,i];n.map.push(a),n.index.set(e,a)}const DP={tokenize:RP},fC={tokenize:jP};function RP(n){const e=this,t=[];let i=0,l,o,a;return u;function u(D){if(ia))return;const T=e.events.length;let z=T,te,q;for(;z--;)if(e.events[z][0]==="exit"&&e.events[z][1].type==="chunkFlow"){if(te){q=e.events[z][1].end;break}te=!0}for(N(i),E=T;ED;){const U=t[I];e.containerState=U[1],U[0].exit.call(e,n)}t.length=D}function j(){l.write([null]),o=void 0,l=void 0,e.containerState._closeFlow=void 0}}function jP(n,e,t){return xt(n,n.attempt(this.parser.constructs.document,e,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function us(n){if(n===null||Rt(n)||oo(n))return 1;if(fm(n))return 2}function hm(n,e,t){const i=[];let l=-1;for(;++l1&&n[t][1].end.offset-n[t][1].start.offset>1?2:1,a={...n[l][1].end},u={...n[t][1].start};hC(a,-o),hC(u,o);const f={type:o>1?"strongSequence":"emphasisSequence",start:a,end:{...n[l][1].end}},d={type:o>1?"strongSequence":"emphasisSequence",start:{...n[t][1].start},end:u},m={type:o>1?"strongText":"emphasisText",start:{...n[l][1].end},end:{...n[t][1].start}},g={type:o>1?"strong":"emphasis",start:{...f.start},end:{...d.end}};n[l][1].end={...f.start},n[t][1].start={...d.end},i=[],n[l][1].end.offset-n[l][1].start.offset&&(i=Ui(i,[["enter",n[l][1],e],["exit",n[l][1],e]])),i=Ui(i,[["enter",g,e],["enter",f,e],["exit",f,e],["enter",m,e]]),i=Ui(i,hm(e.parser.constructs.insideSpan.null,n.slice(l+1,t),e)),i=Ui(i,[["exit",m,e],["enter",d,e],["exit",d,e],["exit",g,e]]);let b=0;n[t][1].end.offset-n[t][1].start.offset&&(b=2,i=Ui(i,[["enter",n[t][1],e],["exit",n[t][1],e]])),rr(n,l-1,t-l+3,i),t=l+i.length-b-2;break}}for(t=-1;++t0&&Je(E)?xt(n,j,"linePrefix",o+1)(E):j(E)}function j(E){return E===null||Ie(E)?n.check(ly,S,I)(E):(n.enter("codeFlowValue"),D(E))}function D(E){return E===null||Ie(E)?(n.exit("codeFlowValue"),j(E)):(n.consume(E),D)}function I(E){return n.exit("codeFenced"),e(E)}function U(E,T,z){let te=0;return q;function q(ne){return E.enter("lineEnding"),E.consume(ne),E.exit("lineEnding"),G}function G(ne){return E.enter("codeFencedFence"),Je(ne)?xt(E,F,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ne):F(ne)}function F(ne){return ne===u?(E.enter("codeFencedFenceSequence"),se(ne)):z(ne)}function se(ne){return ne===u?(te++,E.consume(ne),se):te>=a?(E.exit("codeFencedFenceSequence"),Je(ne)?xt(E,me,"whitespace")(ne):me(ne)):z(ne)}function me(ne){return ne===null||Ie(ne)?(E.exit("codeFencedFence"),T(ne)):z(ne)}}}const _0={name:"codeIndented",tokenize:$P},XP={partial:!0,tokenize:YP};function $P(n,e,t){return i;function i(u){return n.enter("codeIndented"),zA(n,l,t,"linePrefix",4,4)(u)}function l(u){return u===null?a(u):Ie(u)?n.attempt(XP,l,a)(u):(n.enter("codeFlowValue"),o(u))}function o(u){return u===null||Ie(u)?(n.exit("codeFlowValue"),l(u)):(n.consume(u),o)}function a(u){return n.exit("codeIndented"),e(u)}}function YP(n,e,t){const i=this;return l;function l(a){return i.parser.lazy[i.now().line]?t(a):Ie(a)?(n.enter("lineEnding"),n.consume(a),n.exit("lineEnding"),l):zA(n,e,o,"linePrefix",4,4)(a)}function o(a){return Ie(a)?l(a):t(a)}}const GP={name:"codeText",previous:WP,resolve:KP,tokenize:ZP};function KP(n){let e=n.length-4,t=3,i,l;if((n[t][1].type==="lineEnding"||n[t][1].type==="space")&&(n[e][1].type==="lineEnding"||n[e][1].type==="space")){for(i=t;++i=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return ethis.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(e,t,i){const l=t||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-l,Number.POSITIVE_INFINITY);return i&&Fc(this.left,i),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),Fc(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Fc(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e=4?e(a):n.interrupt(i.parser.constructs.flow,t,e)(a)}}function UA(n,e,t,i,l,o,a,u,f){const d=f||Number.POSITIVE_INFINITY;let m=0;return g;function g(N){return N===60?(n.enter(i),n.enter(l),n.enter(o),n.consume(N),n.exit(o),b):N===null||N===32||N===41||Ud(N)?t(N):(n.enter(i),n.enter(a),n.enter(u),n.enter("chunkString",{contentType:"string"}),S(N))}function b(N){return N===62?(n.enter(o),n.consume(N),n.exit(o),n.exit(l),n.exit(i),e):(n.enter(u),n.enter("chunkString",{contentType:"string"}),v(N))}function v(N){return N===62?(n.exit("chunkString"),n.exit(u),b(N)):N===null||N===60||Ie(N)?t(N):(n.consume(N),N===92?w:v)}function w(N){return N===60||N===62||N===92?(n.consume(N),v):v(N)}function S(N){return!m&&(N===null||N===41||Rt(N))?(n.exit("chunkString"),n.exit(u),n.exit(a),n.exit(i),e(N)):m999||v===null||v===91||v===93&&!f||v===94&&!u&&"_hiddenFootnoteSupport"in a.parser.constructs?t(v):v===93?(n.exit(o),n.enter(l),n.consume(v),n.exit(l),n.exit(i),e):Ie(v)?(n.enter("lineEnding"),n.consume(v),n.exit("lineEnding"),m):(n.enter("chunkString",{contentType:"string"}),g(v))}function g(v){return v===null||v===91||v===93||Ie(v)||u++>999?(n.exit("chunkString"),m(v)):(n.consume(v),f||(f=!Je(v)),v===92?b:g)}function b(v){return v===91||v===92||v===93?(n.consume(v),u++,g):g(v)}}function qA(n,e,t,i,l,o){let a;return u;function u(b){return b===34||b===39||b===40?(n.enter(i),n.enter(l),n.consume(b),n.exit(l),a=b===40?41:b,f):t(b)}function f(b){return b===a?(n.enter(l),n.consume(b),n.exit(l),n.exit(i),e):(n.enter(o),d(b))}function d(b){return b===a?(n.exit(o),f(a)):b===null?t(b):Ie(b)?(n.enter("lineEnding"),n.consume(b),n.exit("lineEnding"),xt(n,d,"linePrefix")):(n.enter("chunkString",{contentType:"string"}),m(b))}function m(b){return b===a||b===null||Ie(b)?(n.exit("chunkString"),d(b)):(n.consume(b),b===92?g:m)}function g(b){return b===a||b===92?(n.consume(b),m):m(b)}}function lu(n,e){let t;return i;function i(l){return Ie(l)?(n.enter("lineEnding"),n.consume(l),n.exit("lineEnding"),t=!0,i):Je(l)?xt(n,i,t?"linePrefix":"lineSuffix")(l):e(l)}}const sH={name:"definition",tokenize:aH},oH={partial:!0,tokenize:cH};function aH(n,e,t){const i=this;let l;return o;function o(v){return n.enter("definition"),a(v)}function a(v){return FA.call(i,n,u,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function u(v){return l=lr(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),v===58?(n.enter("definitionMarker"),n.consume(v),n.exit("definitionMarker"),f):t(v)}function f(v){return Rt(v)?lu(n,d)(v):d(v)}function d(v){return UA(n,m,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function m(v){return n.attempt(oH,g,g)(v)}function g(v){return Je(v)?xt(n,b,"whitespace")(v):b(v)}function b(v){return v===null||Ie(v)?(n.exit("definition"),i.parser.defined.push(l),e(v)):t(v)}}function cH(n,e,t){return i;function i(u){return Rt(u)?lu(n,l)(u):t(u)}function l(u){return qA(n,o,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function o(u){return Je(u)?xt(n,a,"whitespace")(u):a(u)}function a(u){return u===null||Ie(u)?e(u):t(u)}}const uH={name:"hardBreakEscape",tokenize:fH};function fH(n,e,t){return i;function i(o){return n.enter("hardBreakEscape"),n.consume(o),l}function l(o){return Ie(o)?(n.exit("hardBreakEscape"),e(o)):t(o)}}const hH={name:"headingAtx",resolve:dH,tokenize:mH};function dH(n,e){let t=n.length-2,i=3;if(n[i][1].type==="whitespace"&&(i+=2),t-2>i&&n[t][1].type==="whitespace"&&(t-=2),n[t][1].type==="atxHeadingSequence"&&(i===t-1||t-4>i&&n[t-2][1].type==="whitespace")&&(t-=i+1===t?2:4),t>i){const l={type:"atxHeadingText",start:n[i][1].start,end:n[t][1].end},o={type:"chunkText",start:n[i][1].start,end:n[t][1].end,contentType:"text"};rr(n,i,t-i+1,[["enter",l,e],["enter",o,e],["exit",o,e],["exit",l,e]])}return n}function mH(n,e,t){let i=0;return l;function l(m){return n.enter("atxHeading"),o(m)}function o(m){return n.enter("atxHeadingSequence"),a(m)}function a(m){return m===35&&i++<6?(n.consume(m),a):m===null||Rt(m)?(n.exit("atxHeadingSequence"),u(m)):t(m)}function u(m){return m===35?(n.enter("atxHeadingSequence"),f(m)):m===null||Ie(m)?(n.exit("atxHeading"),e(m)):Je(m)?xt(n,u,"whitespace")(m):(n.enter("atxHeadingText"),d(m))}function f(m){return m===35?(n.consume(m),f):(n.exit("atxHeadingSequence"),u(m))}function d(m){return m===null||m===35||Rt(m)?(n.exit("atxHeadingText"),u(m)):(n.consume(m),d)}}const VA=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],sy=["pre","script","style","textarea"],pH={concrete:!0,name:"htmlFlow",resolveTo:xH,tokenize:yH},gH={partial:!0,tokenize:bH};function xH(n){let e=n.length;for(;e--&&!(n[e][0]==="enter"&&n[e][1].type==="htmlFlow"););return e>1&&n[e-2][1].type==="linePrefix"&&(n[e][1].start=n[e-2][1].start,n[e+1][1].start=n[e-2][1].start,n.splice(e-2,2)),n}function yH(n,e,t){const i=this;let l,o,a,u,f;return d;function d(B){return m(B)}function m(B){return n.enter("htmlFlow"),n.enter("htmlFlowData"),n.consume(B),g}function g(B){return B===33?(n.consume(B),b):B===47?(n.consume(B),o=!0,S):B===63?(n.consume(B),l=3,i.interrupt?e:A):Ln(B)?(n.consume(B),a=String.fromCharCode(B),C):t(B)}function b(B){return B===45?(n.consume(B),l=2,v):B===91?(n.consume(B),l=5,u=0,w):Ln(B)?(n.consume(B),l=4,i.interrupt?e:A):t(B)}function v(B){return B===45?(n.consume(B),i.interrupt?e:A):t(B)}function w(B){const R="CDATA[";return B===R.charCodeAt(u++)?(n.consume(B),u===R.length?i.interrupt?e:F:w):t(B)}function S(B){return Ln(B)?(n.consume(B),a=String.fromCharCode(B),C):t(B)}function C(B){if(B===null||B===47||B===62||Rt(B)){const R=B===47,$=a.toLowerCase();return!R&&!o&&sy.includes($)?(l=1,i.interrupt?e(B):F(B)):VA.includes(a.toLowerCase())?(l=6,R?(n.consume(B),N):i.interrupt?e(B):F(B)):(l=7,i.interrupt&&!i.parser.lazy[i.now().line]?t(B):o?j(B):D(B))}return B===45||zn(B)?(n.consume(B),a+=String.fromCharCode(B),C):t(B)}function N(B){return B===62?(n.consume(B),i.interrupt?e:F):t(B)}function j(B){return Je(B)?(n.consume(B),j):q(B)}function D(B){return B===47?(n.consume(B),q):B===58||B===95||Ln(B)?(n.consume(B),I):Je(B)?(n.consume(B),D):q(B)}function I(B){return B===45||B===46||B===58||B===95||zn(B)?(n.consume(B),I):U(B)}function U(B){return B===61?(n.consume(B),E):Je(B)?(n.consume(B),U):D(B)}function E(B){return B===null||B===60||B===61||B===62||B===96?t(B):B===34||B===39?(n.consume(B),f=B,T):Je(B)?(n.consume(B),E):z(B)}function T(B){return B===f?(n.consume(B),f=null,te):B===null||Ie(B)?t(B):(n.consume(B),T)}function z(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||Rt(B)?U(B):(n.consume(B),z)}function te(B){return B===47||B===62||Je(B)?D(B):t(B)}function q(B){return B===62?(n.consume(B),G):t(B)}function G(B){return B===null||Ie(B)?F(B):Je(B)?(n.consume(B),G):t(B)}function F(B){return B===45&&l===2?(n.consume(B),_):B===60&&l===1?(n.consume(B),Z):B===62&&l===4?(n.consume(B),Be):B===63&&l===3?(n.consume(B),A):B===93&&l===5?(n.consume(B),re):Ie(B)&&(l===6||l===7)?(n.exit("htmlFlowData"),n.check(gH,ze,se)(B)):B===null||Ie(B)?(n.exit("htmlFlowData"),se(B)):(n.consume(B),F)}function se(B){return n.check(ly,me,ze)(B)}function me(B){return n.enter("lineEnding"),n.consume(B),n.exit("lineEnding"),ne}function ne(B){return B===null||Ie(B)?se(B):(n.enter("htmlFlowData"),F(B))}function _(B){return B===45?(n.consume(B),A):F(B)}function Z(B){return B===47?(n.consume(B),a="",ie):F(B)}function ie(B){if(B===62){const R=a.toLowerCase();return sy.includes(R)?(n.consume(B),Be):F(B)}return Ln(B)&&a.length<8?(n.consume(B),a+=String.fromCharCode(B),ie):F(B)}function re(B){return B===93?(n.consume(B),A):F(B)}function A(B){return B===62?(n.consume(B),Be):B===45&&l===2?(n.consume(B),A):F(B)}function Be(B){return B===null||Ie(B)?(n.exit("htmlFlowData"),ze(B)):(n.consume(B),Be)}function ze(B){return n.exit("htmlFlow"),e(B)}}function bH(n,e,t){return i;function i(l){return n.enter("lineEnding"),n.consume(l),n.exit("lineEnding"),n.attempt(_u,e,t)}}const vH={name:"htmlText",tokenize:wH};function wH(n,e,t){const i=this;let l,o,a;return u;function u(A){return n.enter("htmlText"),n.enter("htmlTextData"),n.consume(A),f}function f(A){return A===33?(n.consume(A),d):A===47?(n.consume(A),U):A===63?(n.consume(A),D):Ln(A)?(n.consume(A),z):t(A)}function d(A){return A===45?(n.consume(A),m):A===91?(n.consume(A),o=0,w):Ln(A)?(n.consume(A),j):t(A)}function m(A){return A===45?(n.consume(A),v):t(A)}function g(A){return A===null?t(A):A===45?(n.consume(A),b):Ie(A)?(a=g,Z(A)):(n.consume(A),g)}function b(A){return A===45?(n.consume(A),v):g(A)}function v(A){return A===62?_(A):A===45?b(A):g(A)}function w(A){const Be="CDATA[";return A===Be.charCodeAt(o++)?(n.consume(A),o===Be.length?S:w):t(A)}function S(A){return A===null?t(A):A===93?(n.consume(A),C):Ie(A)?(a=S,Z(A)):(n.consume(A),S)}function C(A){return A===93?(n.consume(A),N):S(A)}function N(A){return A===62?_(A):A===93?(n.consume(A),N):S(A)}function j(A){return A===null||A===62?_(A):Ie(A)?(a=j,Z(A)):(n.consume(A),j)}function D(A){return A===null?t(A):A===63?(n.consume(A),I):Ie(A)?(a=D,Z(A)):(n.consume(A),D)}function I(A){return A===62?_(A):D(A)}function U(A){return Ln(A)?(n.consume(A),E):t(A)}function E(A){return A===45||zn(A)?(n.consume(A),E):T(A)}function T(A){return Ie(A)?(a=T,Z(A)):Je(A)?(n.consume(A),T):_(A)}function z(A){return A===45||zn(A)?(n.consume(A),z):A===47||A===62||Rt(A)?te(A):t(A)}function te(A){return A===47?(n.consume(A),_):A===58||A===95||Ln(A)?(n.consume(A),q):Ie(A)?(a=te,Z(A)):Je(A)?(n.consume(A),te):_(A)}function q(A){return A===45||A===46||A===58||A===95||zn(A)?(n.consume(A),q):G(A)}function G(A){return A===61?(n.consume(A),F):Ie(A)?(a=G,Z(A)):Je(A)?(n.consume(A),G):te(A)}function F(A){return A===null||A===60||A===61||A===62||A===96?t(A):A===34||A===39?(n.consume(A),l=A,se):Ie(A)?(a=F,Z(A)):Je(A)?(n.consume(A),F):(n.consume(A),me)}function se(A){return A===l?(n.consume(A),l=void 0,ne):A===null?t(A):Ie(A)?(a=se,Z(A)):(n.consume(A),se)}function me(A){return A===null||A===34||A===39||A===60||A===61||A===96?t(A):A===47||A===62||Rt(A)?te(A):(n.consume(A),me)}function ne(A){return A===47||A===62||Rt(A)?te(A):t(A)}function _(A){return A===62?(n.consume(A),n.exit("htmlTextData"),n.exit("htmlText"),e):t(A)}function Z(A){return n.exit("htmlTextData"),n.enter("lineEnding"),n.consume(A),n.exit("lineEnding"),ie}function ie(A){return Je(A)?xt(n,re,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):re(A)}function re(A){return n.enter("htmlTextData"),a(A)}}const db={name:"labelEnd",resolveAll:OH,resolveTo:NH,tokenize:TH},kH={tokenize:AH},SH={tokenize:EH},CH={tokenize:MH};function OH(n){let e=-1;const t=[];for(;++e0&&l[l.length-1]._balanced;)l.pop();o=l[l.length-1]}return u;function u(b){return o?o._inactive?g(b):(a=i.parser.defined.includes(lr(i.sliceSerialize({start:o.end,end:i.now()}))),n.enter("labelEnd"),n.enter("labelMarker"),n.consume(b),n.exit("labelMarker"),n.exit("labelEnd"),f):t(b)}function f(b){return b===40?n.attempt(kH,m,a?m:g)(b):b===91?n.attempt(SH,m,a?d:g)(b):a?m(b):g(b)}function d(b){return n.attempt(CH,m,g)(b)}function m(b){return l.pop(),e(b)}function g(b){return o._balanced=!0,t(b)}}function AH(n,e,t){return i;function i(g){return n.enter("resource"),n.enter("resourceMarker"),n.consume(g),n.exit("resourceMarker"),l}function l(g){return Rt(g)?lu(n,o)(g):o(g)}function o(g){return g===41?m(g):UA(n,a,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function a(g){return Rt(g)?lu(n,f)(g):m(g)}function u(g){return t(g)}function f(g){return g===34||g===39||g===40?qA(n,d,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):m(g)}function d(g){return Rt(g)?lu(n,m)(g):m(g)}function m(g){return g===41?(n.enter("resourceMarker"),n.consume(g),n.exit("resourceMarker"),n.exit("resource"),e):t(g)}}function EH(n,e,t){const i=this;return l;function l(u){return FA.call(i,n,o,a,"reference","referenceMarker","referenceString")(u)}function o(u){return i.parser.defined.includes(lr(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?e(u):t(u)}function a(u){return t(u)}}function MH(n,e,t){return i;function i(o){return n.enter("reference"),n.enter("referenceMarker"),n.consume(o),n.exit("referenceMarker"),l}function l(o){return o===93?(n.enter("referenceMarker"),n.consume(o),n.exit("referenceMarker"),n.exit("reference"),e):t(o)}}const DH={name:"labelStartImage",resolveAll:db.resolveAll,tokenize:RH};function RH(n,e,t){const i=this;let l;return o;function o(f){return n.enter("labelImage"),n.enter("labelImageMarker"),n.consume(f),n.exit("labelImageMarker"),a}function a(f){return f===91?(n.enter("labelMarker"),n.consume(f),n.exit("labelMarker"),l=n.exit("labelImage"),u):t(f)}function u(f){return f===94&&"_hiddenFootnoteSupport"in i.parser.constructs?t(f):(i._labelStarts=i._labelStarts||[],i._labelStarts.push(l),e(f))}}const jH={name:"labelStartLink",resolveAll:db.resolveAll,tokenize:_H};function _H(n,e,t){const i=this;let l;return o;function o(u){return n.enter("labelLink"),n.enter("labelMarker"),n.consume(u),n.exit("labelMarker"),l=n.exit("labelLink"),a}function a(u){return u===94&&"_hiddenFootnoteSupport"in i.parser.constructs?t(u):(i._labelStarts=i._labelStarts||[],i._labelStarts.push(l),e(u))}}const L0={name:"lineEnding",tokenize:LH};function LH(n,e){return t;function t(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),xt(n,e,"linePrefix")}}const ad={name:"thematicBreak",tokenize:zH};function zH(n,e,t){let i=0,l;return o;function o(d){return n.enter("thematicBreak"),a(d)}function a(d){return l=d,u(d)}function u(d){return d===l?(n.enter("thematicBreakSequence"),f(d)):i>=3&&(d===null||Ie(d))?(n.exit("thematicBreak"),e(d)):t(d)}function f(d){return d===l?(n.consume(d),i++,f):(n.exit("thematicBreakSequence"),Je(d)?xt(n,u,"whitespace")(d):u(d))}}const ui={continuation:{tokenize:IH},exit:FH,name:"list",tokenize:HH},BH={partial:!0,tokenize:qH},PH={partial:!0,tokenize:UH};function HH(n,e,t){const i=this,l=i.events[i.events.length-1];let o=l&&l[1].type==="linePrefix"?l[2].sliceSerialize(l[1],!0).length:0,a=0;return u;function u(v){const w=i.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!i.containerState.marker||v===i.containerState.marker:iy(v)){if(i.containerState.type||(i.containerState.type=w,n.enter(w,{_container:!0})),w==="listUnordered")return n.enter("listItemPrefix"),v===42||v===45?n.check(ad,t,d)(v):d(v);if(!i.interrupt||v===49)return n.enter("listItemPrefix"),n.enter("listItemValue"),f(v)}return t(v)}function f(v){return iy(v)&&++a<10?(n.consume(v),f):(!i.interrupt||a<2)&&(i.containerState.marker?v===i.containerState.marker:v===41||v===46)?(n.exit("listItemValue"),d(v)):t(v)}function d(v){return n.enter("listItemMarker"),n.consume(v),n.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||v,n.check(_u,i.interrupt?t:m,n.attempt(BH,b,g))}function m(v){return i.containerState.initialBlankLine=!0,o++,b(v)}function g(v){return Je(v)?(n.enter("listItemPrefixWhitespace"),n.consume(v),n.exit("listItemPrefixWhitespace"),b):t(v)}function b(v){return i.containerState.size=o+i.sliceSerialize(n.exit("listItemPrefix"),!0).length,e(v)}}function IH(n,e,t){const i=this;return i.containerState._closeFlow=void 0,n.check(_u,l,o);function l(u){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,xt(n,e,"listItemIndent",i.containerState.size+1)(u)}function o(u){return i.containerState.furtherBlankLines||!Je(u)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,a(u)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,n.attempt(PH,e,a)(u))}function a(u){return i.containerState._closeFlow=!0,i.interrupt=void 0,xt(n,n.attempt(ui,e,t),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function UH(n,e,t){const i=this;return xt(n,l,"listItemIndent",i.containerState.size+1);function l(o){const a=i.events[i.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===i.containerState.size?e(o):t(o)}}function FH(n){n.exit(this.containerState.type)}function qH(n,e,t){const i=this;return xt(n,l,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function l(o){const a=i.events[i.events.length-1];return!Je(o)&&a&&a[1].type==="listItemPrefixWhitespace"?e(o):t(o)}}const mC={name:"setextUnderline",resolveTo:VH,tokenize:QH};function VH(n,e){const t=new Fd;let i=n.length,l,o,a;for(;i--;)if(n[i][0]==="enter"){if(n[i][1].type==="content"){l=i;break}n[i][1].type==="paragraph"&&(o=i)}else n[i][1].type==="content"&&t.add(i,1,[]),!a&&n[i][1].type==="definition"&&(a=i);const u={type:"setextHeading",start:{...n[l][1].start},end:{...n[n.length-1][1].end}};return n[o][1].type="setextHeadingText",a?(t.add(o,0,[["enter",u,e]]),t.add(a+1,0,[["exit",n[l][1],e]]),n[l][1].end={...n[a][1].end}):n[l][1]=u,t.add(n.length,0,[["exit",u,e]]),t.consume(n),n}function QH(n,e,t){const i=this;let l;return o;function o(d){let m=i.events.length,g;for(;m--;)if(i.events[m][1].type!=="lineEnding"&&i.events[m][1].type!=="linePrefix"&&i.events[m][1].type!=="content"){g=i.events[m][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||g)?(n.enter("setextHeadingLine"),l=d,a(d)):t(d)}function a(d){return n.enter("setextHeadingLineSequence"),u(d)}function u(d){return d===l?(n.consume(d),u):(n.exit("setextHeadingLineSequence"),Je(d)?xt(n,f,"lineSuffix")(d):f(d))}function f(d){return d===null||Ie(d)?(n.exit("setextHeadingLine"),e(d)):t(d)}}const XH={tokenize:$H};function $H(n){const e=this,t=n.attempt(_u,i,n.attempt(this.parser.constructs.flowInitial,l,xt(n,n.attempt(this.parser.constructs.flow,l,n.attempt(tH,l)),"linePrefix")));return t;function i(o){if(o===null){n.consume(o);return}return n.enter("lineEndingBlank"),n.consume(o),n.exit("lineEndingBlank"),e.currentConstruct=void 0,t}function l(o){if(o===null){n.consume(o);return}return n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),e.currentConstruct=void 0,t}}const YH={resolveAll:XA()},GH=QA("string"),KH=QA("text");function QA(n){return{resolveAll:XA(n==="text"?WH:void 0),tokenize:e};function e(t){const i=this,l=this.parser.constructs[n],o=t.attempt(l,a,u);return a;function a(m){return d(m)?o(m):u(m)}function u(m){if(m===null){t.consume(m);return}return t.enter("data"),t.consume(m),f}function f(m){return d(m)?(t.exit("data"),o(m)):(t.consume(m),f)}function d(m){if(m===null)return!0;const g=l[m];let b=-1;if(g)for(;++b-1){const u=a[0];typeof u=="string"?a[0]=u.slice(i):a.shift()}o>0&&a.push(n[l].slice(0,o))}return a}function u7(n,e){let t=-1;const i=[];let l;for(;++t0&&l(e.beforeEnter,{...Te,sliceSerialize:ee[pe][2].sliceSerialize},ee[pe][1]),$A.call(Ee,ee[pe][1].type)&&Ee[ee[pe][1].type].call({...Te,sliceSerialize:ee[pe][2].sliceSerialize},ee[pe][1]),ee[pe][0]==="exit"&&e.afterExit.length>0&&l(e.afterExit,{...Te,sliceSerialize:ee[pe][2].sliceSerialize},ee[pe][1])}if(Te.tokenStack.length>0){const Ee=Te.tokenStack[Te.tokenStack.length-1];(Ee[1]||gC).call(Te,void 0,Ee[0])}for(fe.position={start:Xl(ee.length>0?ee[0][1].start:{line:1,column:1,offset:0}),end:Xl(ee.length>0?ee[ee.length-2][1].end:{line:1,column:1,offset:0})},pe=-1;++pe0&&(i.className=["language-"+l[0]]);let o={type:"element",tagName:"code",properties:i,children:[{type:"text",value:t}]};return e.meta&&(o.data={meta:e.meta}),n.patch(e,o),o=n.applyData(e,o),o={type:"element",tagName:"pre",properties:{},children:[o]},n.patch(e,o),o}function C7(n,e){const t={type:"element",tagName:"del",properties:{},children:n.all(e)};return n.patch(e,t),n.applyData(e,t)}function O7(n,e){const t={type:"element",tagName:"em",properties:{},children:n.all(e)};return n.patch(e,t),n.applyData(e,t)}function N7(n,e){const t=typeof n.options.clobberPrefix=="string"?n.options.clobberPrefix:"user-content-",i=String(e.identifier).toUpperCase(),l=Ba(i.toLowerCase()),o=n.footnoteOrder.indexOf(i);let a,u=n.footnoteCounts.get(i);u===void 0?(u=0,n.footnoteOrder.push(i),a=n.footnoteOrder.length):a=o+1,u+=1,n.footnoteCounts.set(i,u);const f={type:"element",tagName:"a",properties:{href:"#"+t+"fn-"+l,id:t+"fnref-"+l+(u>1?"-"+u:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};n.patch(e,f);const d={type:"element",tagName:"sup",properties:{},children:[f]};return n.patch(e,d),n.applyData(e,d)}function T7(n,e){const t={type:"element",tagName:"h"+e.depth,properties:{},children:n.all(e)};return n.patch(e,t),n.applyData(e,t)}function A7(n,e){if(n.options.allowDangerousHtml){const t={type:"raw",value:e.value};return n.patch(e,t),n.applyData(e,t)}}function GA(n,e){const t=e.referenceType;let i="]";if(t==="collapsed"?i+="[]":t==="full"&&(i+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+i}];const l=n.all(e),o=l[0];o&&o.type==="text"?o.value="["+o.value:l.unshift({type:"text",value:"["});const a=l[l.length-1];return a&&a.type==="text"?a.value+=i:l.push({type:"text",value:i}),l}function E7(n,e){const t=String(e.identifier).toUpperCase(),i=n.definitionById.get(t);if(!i)return GA(n,e);const l={src:Ba(i.url||""),alt:e.alt};i.title!==null&&i.title!==void 0&&(l.title=i.title);const o={type:"element",tagName:"img",properties:l,children:[]};return n.patch(e,o),n.applyData(e,o)}function M7(n,e){const t={src:Ba(e.url)};e.alt!==null&&e.alt!==void 0&&(t.alt=e.alt),e.title!==null&&e.title!==void 0&&(t.title=e.title);const i={type:"element",tagName:"img",properties:t,children:[]};return n.patch(e,i),n.applyData(e,i)}function D7(n,e){const t={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};n.patch(e,t);const i={type:"element",tagName:"code",properties:{},children:[t]};return n.patch(e,i),n.applyData(e,i)}function R7(n,e){const t=String(e.identifier).toUpperCase(),i=n.definitionById.get(t);if(!i)return GA(n,e);const l={href:Ba(i.url||"")};i.title!==null&&i.title!==void 0&&(l.title=i.title);const o={type:"element",tagName:"a",properties:l,children:n.all(e)};return n.patch(e,o),n.applyData(e,o)}function j7(n,e){const t={href:Ba(e.url)};e.title!==null&&e.title!==void 0&&(t.title=e.title);const i={type:"element",tagName:"a",properties:t,children:n.all(e)};return n.patch(e,i),n.applyData(e,i)}function _7(n,e,t){const i=n.all(e),l=t?L7(t):KA(e),o={},a=[];if(typeof e.checked=="boolean"){const m=i[0];let g;m&&m.type==="element"&&m.tagName==="p"?g=m:(g={type:"element",tagName:"p",properties:{},children:[]},i.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let u=-1;for(;++u1}function z7(n,e){const t={},i=n.all(e);let l=-1;for(typeof e.start=="number"&&e.start!==1&&(t.start=e.start);++l0){const a={type:"element",tagName:"tbody",properties:{},children:n.wrap(t,!0)},u=ob(e.children[1]),f=NA(e.children[e.children.length-1]);u&&f&&(a.position={start:u,end:f}),l.push(a)}const o={type:"element",tagName:"table",properties:{},children:n.wrap(l,!0)};return n.patch(e,o),n.applyData(e,o)}function U7(n,e,t){const i=t?t.children:void 0,o=(i?i.indexOf(e):1)===0?"th":"td",a=t&&t.type==="table"?t.align:void 0,u=a?a.length:e.children.length;let f=-1;const d=[];for(;++f0,!0),i[0]),l=i.index+i[0].length,i=t.exec(e);return o.push(bC(e.slice(l),l>0,!1)),o.join("")}function bC(n,e,t){let i=0,l=n.length;if(e){let o=n.codePointAt(i);for(;o===xC||o===yC;)i++,o=n.codePointAt(i)}if(t){let o=n.codePointAt(l-1);for(;o===xC||o===yC;)l--,o=n.codePointAt(l-1)}return l>i?n.slice(i,l):""}function V7(n,e){const t={type:"text",value:q7(String(e.value))};return n.patch(e,t),n.applyData(e,t)}function Q7(n,e){const t={type:"element",tagName:"hr",properties:{},children:[]};return n.patch(e,t),n.applyData(e,t)}const X7={blockquote:w7,break:k7,code:S7,delete:C7,emphasis:O7,footnoteReference:N7,heading:T7,html:A7,imageReference:E7,image:M7,inlineCode:D7,linkReference:R7,link:j7,listItem:_7,list:z7,paragraph:B7,root:P7,strong:H7,table:I7,tableCell:F7,tableRow:U7,text:V7,thematicBreak:Q7,toml:Fh,yaml:Fh,definition:Fh,footnoteDefinition:Fh};function Fh(){}const WA=-1,dm=0,su=1,qd=2,mb=3,pb=4,gb=5,xb=6,ZA=7,JA=8,{defineProperty:$7}=Object,eE=typeof self=="object"?self:globalThis,vC=(n,e)=>{switch(n){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+n)}return new eE[n](e)},Y7=(n,e)=>{const t=(l,o)=>(n.set(o,l),l),i=l=>{if(n.has(l))return n.get(l);const[o,a]=e[l];switch(o){case dm:case WA:return t(a,l);case su:{const u=t([],l);for(const f of a)u.push(i(f));return u}case qd:{const u=t({},l);for(const[f,d]of a){const m=i(f),g=i(d);m==="__proto__"?$7(u,m,{value:g,configurable:!0,enumerable:!0,writable:!0}):u[m]=g}return u}case mb:return t(new Date(a),l);case pb:{const{source:u,flags:f}=a;return t(new RegExp(u,f),l)}case gb:{const u=t(new Map,l);for(const[f,d]of a)u.set(i(f),i(d));return u}case xb:{const u=t(new Set,l);for(const f of a)u.add(i(f));return u}case ZA:{const{name:u,message:f}=a;return t(typeof eE[u]=="function"?vC(u,f):new Error(f),l)}case JA:return t(BigInt(a),l);case"BigInt":return t(Object(BigInt(a)),l);case"ArrayBuffer":return t(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:u}=new Uint8Array(a);return t(new DataView(u),a)}case"-0":return-0}return t(vC(o,a),l)};return i},wC=n=>Y7(new Map,n)(0),Xs="",{toString:G7}={},{keys:K7,is:W7}=Object,qc=n=>{const e=typeof n;if(e!=="object"||!n)return[dm,e];const t=G7.call(n).slice(8,-1);switch(t){case"Array":return[su,Xs];case"Object":return[qd,Xs];case"Date":return[mb,Xs];case"RegExp":return[pb,Xs];case"Map":return[gb,Xs];case"Set":return[xb,Xs];case"DataView":return[su,t]}return t.includes("Array")?[su,t]:n instanceof Error?[ZA,n.name||"Error"]:[qd,t]},qh=([n,e])=>n===dm&&(e==="function"||e==="symbol"),Z7=(n,e,t,i)=>{const l=(a,u)=>{const f=i.push(a)-1;return t.set(u,f),f},o=a=>{if(t.has(a))return t.get(a);let[u,f]=qc(a);switch(u){case dm:{let m=a;switch(f){case"bigint":u=JA,m=a.toString();break;case"number":if(!a&&W7(a,-0))return i.push(["-0"])-1;break;case"function":case"symbol":if(n)throw new TypeError("unable to serialize "+f);m=null;break;case"undefined":return l([WA],a)}return l([u,m],a)}case su:{if(f){let b=a;return f==="DataView"?b=new Uint8Array(a.buffer):f==="ArrayBuffer"&&(b=new Uint8Array(a)),l([f,[...b]],a)}const m=[],g=l([u,m],a);for(const b of a)m.push(o(b));return g}case qd:{if(f)switch(f){case"BigInt":return l([f,a.toString()],a);case"Boolean":case"Number":case"String":return l([f,a.valueOf()],a)}if(e&&"toJSON"in a)return o(a.toJSON());const m=[],g=l([u,m],a);for(const b of K7(a))(n||!qh(qc(a[b])))&&m.push([o(b),o(a[b])]);return g}case mb:return l([u,isNaN(a.getTime())?Xs:a.toISOString()],a);case pb:{const{source:m,flags:g}=a;return l([u,{source:m,flags:g}],a)}case gb:{const m=[],g=l([u,m],a);for(const[b,v]of a)(n||!(qh(qc(b))||qh(qc(v))))&&m.push([o(b),o(v)]);return g}case xb:{const m=[],g=l([u,m],a);for(const b of a)(n||!qh(qc(b)))&&m.push(o(b));return g}}const{message:d}=a;return l([u,{name:f,message:d}],a)};return o},kC=(n,{json:e,lossy:t}={})=>{const i=[];return Z7(!(e||t),!!e,new Map,i)(n),i},Vd=typeof structuredClone=="function"?(n,e)=>e&&("json"in e||"lossy"in e)?wC(kC(n,e)):structuredClone(n):(n,e)=>wC(kC(n,e));function J7(n,e){const t=[{type:"text",value:"↩"}];return e>1&&t.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),t}function eI(n,e){return"Back to reference "+(n+1)+(e>1?"-"+e:"")}function tI(n){const e=typeof n.options.clobberPrefix=="string"?n.options.clobberPrefix:"user-content-",t=n.options.footnoteBackContent||J7,i=n.options.footnoteBackLabel||eI,l=n.options.footnoteLabel||"Footnotes",o=n.options.footnoteLabelTagName||"h2",a=n.options.footnoteLabelProperties||{className:["sr-only"]},u=[];let f=-1;for(;++f0&&w.push({type:"text",value:" "});let j=typeof t=="string"?t:t(f,v);typeof j=="string"&&(j={type:"text",value:j}),w.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+b+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(f,v),className:["data-footnote-backref"]},children:Array.isArray(j)?j:[j]})}const C=m[m.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const j=C.children[C.children.length-1];j&&j.type==="text"?j.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...w)}else m.push(...w);const N={type:"element",tagName:"li",properties:{id:e+"fn-"+b},children:n.wrap(m,!0)};n.patch(d,N),u.push(N)}if(u.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Vd(a),id:"footnote-label"},children:[{type:"text",value:l}]},{type:"text",value:` +`},{type:"element",tagName:"ol",properties:{},children:n.wrap(u,!0)},{type:"text",value:` +`}]}}const mm=(function(n){if(n==null)return lI;if(typeof n=="function")return pm(n);if(typeof n=="object")return Array.isArray(n)?nI(n):iI(n);if(typeof n=="string")return rI(n);throw new Error("Expected function, string, or object as test")});function nI(n){const e=[];let t=-1;for(;++t":""))+")"})}return C;function C(){const N=!o||d(b,v,w[w.length-1]||void 0);let j=tE;if(u&&N&&(j=SC(u(b,w,v)),j[0]===cd))return j;if("children"in b&&b.children){const D=b;if(D.children&&j[0]!==oy){let I=(l?-1:D.children.length)+m;const U=[...w,D];for(;I>-1&&I0&&t.push({type:"text",value:` +`}),t}function CC(n){let e=0,t=n.charCodeAt(e);for(;t===9||t===32;)e++,t=n.charCodeAt(e);return n.slice(e)}function OC(n,e){const t=uI(n,e),i=t.one(n,void 0),l=tI(t),o=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return l&&o.children.push({type:"text",value:` +`},l),o}function pI(n,e){return n&&"run"in n?async function(t,i){const l=OC(t,{file:i,...e});await n.run(l,i)}:function(t,i){return OC(t,{file:i,...n||e})}}function NC(n){if(n)throw n}var z0,TC;function gI(){if(TC)return z0;TC=1;var n=Object.prototype.hasOwnProperty,e=Object.prototype.toString,t=Object.defineProperty,i=Object.getOwnPropertyDescriptor,l=function(d){return typeof Array.isArray=="function"?Array.isArray(d):e.call(d)==="[object Array]"},o=function(d){if(!d||e.call(d)!=="[object Object]")return!1;var m=n.call(d,"constructor"),g=d.constructor&&d.constructor.prototype&&n.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!m&&!g)return!1;var b;for(b in d);return typeof b>"u"||n.call(d,b)},a=function(d,m){t&&m.name==="__proto__"?t(d,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):d[m.name]=m.newValue},u=function(d,m){if(m==="__proto__")if(n.call(d,m)){if(i)return i(d,m).value}else return;return d[m]};return z0=function f(){var d,m,g,b,v,w,S=arguments[0],C=1,N=arguments.length,j=!1;for(typeof S=="boolean"&&(j=S,S=arguments[1]||{},C=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});Ca.length;let f;u&&a.push(l);try{f=n.apply(this,a)}catch(d){const m=d;if(u&&t)throw m;return l(m)}u||(f&&f.then&&typeof f.then=="function"?f.then(o,l):f instanceof Error?l(f):o(f))}function l(a,...u){t||(t=!0,e(a,...u))}function o(a){l(null,a)}}const Tr={basename:vI,dirname:wI,extname:kI,join:SI,sep:"/"};function vI(n,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Lu(n);let t=0,i=-1,l=n.length,o;if(e===void 0||e.length===0||e.length>n.length){for(;l--;)if(n.codePointAt(l)===47){if(o){t=l+1;break}}else i<0&&(o=!0,i=l+1);return i<0?"":n.slice(t,i)}if(e===n)return"";let a=-1,u=e.length-1;for(;l--;)if(n.codePointAt(l)===47){if(o){t=l+1;break}}else a<0&&(o=!0,a=l+1),u>-1&&(n.codePointAt(l)===e.codePointAt(u--)?u<0&&(i=l):(u=-1,i=a));return t===i?i=a:i<0&&(i=n.length),n.slice(t,i)}function wI(n){if(Lu(n),n.length===0)return".";let e=-1,t=n.length,i;for(;--t;)if(n.codePointAt(t)===47){if(i){e=t;break}}else i||(i=!0);return e<0?n.codePointAt(0)===47?"/":".":e===1&&n.codePointAt(0)===47?"//":n.slice(0,e)}function kI(n){Lu(n);let e=n.length,t=-1,i=0,l=-1,o=0,a;for(;e--;){const u=n.codePointAt(e);if(u===47){if(a){i=e+1;break}continue}t<0&&(a=!0,t=e+1),u===46?l<0?l=e:o!==1&&(o=1):l>-1&&(o=-1)}return l<0||t<0||o===0||o===1&&l===t-1&&l===i+1?"":n.slice(l,t)}function SI(...n){let e=-1,t;for(;++e0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function OI(n,e){let t="",i=0,l=-1,o=0,a=-1,u,f;for(;++a<=n.length;){if(a2){if(f=t.lastIndexOf("/"),f!==t.length-1){f<0?(t="",i=0):(t=t.slice(0,f),i=t.length-1-t.lastIndexOf("/")),l=a,o=0;continue}}else if(t.length>0){t="",i=0,l=a,o=0;continue}}e&&(t=t.length>0?t+"/..":"..",i=2)}else t.length>0?t+="/"+n.slice(l+1,a):t=n.slice(l+1,a),i=a-l-1;l=a,o=0}else u===46&&o>-1?o++:o=-1}return t}function Lu(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}const NI={cwd:TI};function TI(){return"/"}function hy(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function AI(n){if(typeof n=="string")n=new URL(n);else if(!hy(n)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+n+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(n.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return EI(n)}function EI(n){if(n.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const e=n.pathname;let t=-1;for(;++t0){let[v,...w]=m;const S=i[b][1];fy(S)&&fy(v)&&(v=B0(!0,S,v)),i[b]=[d,v,...w]}}}}const jI=new bb().freeze();function U0(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function F0(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function q0(n,e){if(e)throw new Error("Cannot call `"+n+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function EC(n){if(!fy(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function MC(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function Vh(n){return _I(n)?n:new nE(n)}function _I(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function LI(n){return typeof n=="string"||zI(n)}function zI(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}const BI="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",DC=[],RC={allowDangerousHtml:!0},PI=/^(https?|ircs?|mailto|xmpp)$/i,HI=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function II(n){const e=UI(n),t=FI(n);return qI(e.runSync(e.parse(t),t),n)}function UI(n){const e=n.rehypePlugins||DC,t=n.remarkPlugins||DC,i=n.remarkRehypeOptions?{...n.remarkRehypeOptions,...RC}:RC;return jI().use(v7).use(t).use(pI,i).use(e)}function FI(n){const e=n.children||"",t=new nE;return typeof e=="string"&&(t.value=e),t}function qI(n,e){const t=e.allowedElements,i=e.allowElement,l=e.components,o=e.disallowedElements,a=e.skipHtml,u=e.unwrapDisallowed,f=e.urlTransform||VI;for(const m of HI)Object.hasOwn(e,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+BI+m.id,void 0);return yb(n,d),sP(n,{Fragment:y.Fragment,components:l,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function d(m,g,b){if(m.type==="raw"&&b&&typeof g=="number")return a?b.children.splice(g,1):b.children[g]={type:"text",value:m.value},g;if(m.type==="element"){let v;for(v in j0)if(Object.hasOwn(j0,v)&&Object.hasOwn(m.properties,v)){const w=m.properties[v],S=j0[v];(S===null||S.includes(m.tagName))&&(m.properties[v]=f(String(w||""),v,m))}}if(m.type==="element"){let v=t?!t.includes(m.tagName):o?o.includes(m.tagName):!1;if(!v&&i&&typeof g=="number"&&(v=!i(m,g,b)),v&&b&&typeof g=="number")return u&&m.children?b.children.splice(g,1,...m.children):b.children.splice(g,1),g}}}function VI(n){const e=n.indexOf(":"),t=n.indexOf("?"),i=n.indexOf("#"),l=n.indexOf("/");return e===-1||l!==-1&&e>l||t!==-1&&e>t||i!==-1&&e>i||PI.test(n.slice(0,e))?n:""}function QI(n){if(typeof n!="string")throw new TypeError("Expected a string");return n.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function iE(n,e,t){const l=mm((t||{}).ignore||[]),o=XI(e);let a=-1;for(;++a0?{type:"text",value:E}:void 0),E===!1)v.lastIndex=I+1;else{if(S!==I&&D({type:"text",value:d.value.slice(S,I)}),Array.isArray(E))for(const T of E)D(T);else E&&D(E);S=I+j[0].length,C=!0}if(!v.global)break;j=v.exec(d.value)}return C?(S?\]}]+$/.exec(n);if(!e)return[n,void 0];n=n.slice(0,e.index);let t=e[0],i=t.indexOf(")");const l=jC(n,"(");let o=jC(n,")");for(;i!==-1&&l>o;)n+=t.slice(0,i+1),t=t.slice(i+1),i=t.indexOf(")"),o++;return[n,t]}function rE(n,e){const t=n.input.charCodeAt(n.index-1);return(n.index===0||oo(t)||fm(t))&&(!e||t!==47)}lE.peek=yU;function uU(){this.buffer()}function fU(n){this.enter({type:"footnoteReference",identifier:"",label:""},n)}function hU(){this.buffer()}function dU(n){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},n)}function mU(n){const e=this.resume(),t=this.stack[this.stack.length-1];t.type,t.identifier=lr(this.sliceSerialize(n)).toLowerCase(),t.label=e}function pU(n){this.exit(n)}function gU(n){const e=this.resume(),t=this.stack[this.stack.length-1];t.type,t.identifier=lr(this.sliceSerialize(n)).toLowerCase(),t.label=e}function xU(n){this.exit(n)}function yU(){return"["}function lE(n,e,t,i){const l=t.createTracker(i);let o=l.move("[^");const a=t.enter("footnoteReference"),u=t.enter("reference");return o+=l.move(t.safe(t.associationId(n),{after:"]",before:o})),u(),a(),o+=l.move("]"),o}function bU(){return{enter:{gfmFootnoteCallString:uU,gfmFootnoteCall:fU,gfmFootnoteDefinitionLabelString:hU,gfmFootnoteDefinition:dU},exit:{gfmFootnoteCallString:mU,gfmFootnoteCall:pU,gfmFootnoteDefinitionLabelString:gU,gfmFootnoteDefinition:xU}}}function vU(n){let e=!1;return n&&n.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:t,footnoteReference:lE},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function t(i,l,o,a){const u=o.createTracker(a);let f=u.move("[^");const d=o.enter("footnoteDefinition"),m=o.enter("label");return f+=u.move(o.safe(o.associationId(i),{before:f,after:"]"})),m(),f+=u.move("]:"),i.children&&i.children.length>0&&(u.shift(4),f+=u.move((e?` +`:" ")+o.indentLines(o.containerFlow(i,u.current()),e?sE:wU))),d(),f}}function wU(n,e,t){return e===0?n:sE(n,e,t)}function sE(n,e,t){return(t?"":" ")+n}const kU=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];vb.attention=TU;vb.peek=AU;function SU(){return{canContainEols:["delete"],enter:{strikethrough:OU},exit:{strikethrough:NU}}}function CU(){return{handlers:{delete:vb},unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:kU}]}}function OU(n){this.enter({type:"delete",children:[],position:void 0},n)}function NU(n){this.exit(n)}function vb(n,e,t,i){const l=t.createTracker(i),o=t.stack.includes("strikethrough")?"~":"~~",a=t.enter("strikethrough");let u=l.move(o);return u+=t.containerPhrasing(n,{...l.current(),before:u,after:"~"}),u+=l.move(o),a(),u}function TU(){return{construct:"strikethrough",markers:["~"],sizes:[2,1]}}function AU(){return"~"}function EU(n){return n.length}function MU(n,e){const t=e||{},i=(t.align||[]).concat(),l=t.stringLength||EU,o=[],a=[],u=[],f=[];let d=0,m=-1;for(;++md&&(d=n[m].length);++Nf[N])&&(f[N]=D)}S.push(j)}a[m]=S,u[m]=C}let g=-1;if(typeof i=="object"&&"length"in i)for(;++gf[g]&&(f[g]=j),v[g]=j),b[g]=D}a.splice(1,0,b),u.splice(1,0,v),m=-1;const w=[];for(;++m "),o.shift(2);const a=t.indentLines(t.containerFlow(n,o.current()),_U);return l(),a}function _U(n,e,t){return">"+(t?"":" ")+n}function LU(n,e){return LC(n,e.inConstruct,!0)&&!LC(n,e.notInConstruct,!1)}function LC(n,e,t){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return t;let i=-1;for(;++ia&&(a=o):o=1,l=i+e.length,i=t.indexOf(e,l);return a}function BU(n,e){return!!(e.options.fences===!1&&n.value&&!n.lang&&/[^\n\r ]/.test(n.value)&&!/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(n.value))}function PU(n){const e=n.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function HU(n,e,t,i){const l=PU(t),o=n.value||"";if(BU(n,t)){const g=t.enter("codeIndented"),b=t.indentLines(o,IU);return g(),b}const a=t.createTracker(i),u=l.repeat(Math.max(zU(o,l)+1,3)),f=t.enter("codeFenced"),d=l==="`"?"GraveAccent":"Tilde";let m=a.move(u);if(n.lang){const g=t.enter(`codeFencedLang${d}`);m+=a.move(t.safe(n.lang,{before:m,after:" ",encode:["`"],...a.current()})),g()}if(n.lang&&n.meta){const g=t.enter(`codeFencedMeta${d}`);m+=a.move(" "),m+=a.move(t.safe(n.meta,{before:m,after:` +`,encode:["`"],...a.current()})),g()}return m+=a.move(` +`),o&&(m+=a.move(o+` +`)),m+=a.move(u),f(),m}function IU(n,e,t){return(t?"":" ")+n}function wb(n){const e=n.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function UU(n,e,t,i){const l=wb(t),o=l==='"'?"Quote":"Apostrophe",a=t.enter("definition");let u=t.enter("label");const f=t.createTracker(i);let d=f.move("[");return d+=f.move(t.safe(t.associationId(n),{before:d,after:"]",...f.current()})),d+=f.move("]: "),u(),!n.url||/[\0- \u007F]/.test(n.url)?(u=t.enter("destinationLiteral"),d+=f.move("<"),d+=f.move(t.safe(n.url,{before:d,after:">",...f.current()})),d+=f.move(">")):(u=t.enter("destinationRaw"),d+=f.move(t.safe(n.url,{before:d,after:n.title?" ":` +`,...f.current()}))),u(),n.title&&(u=t.enter(`title${o}`),d+=f.move(" "+l),d+=f.move(t.safe(n.title,{before:d,after:l,...f.current()})),d+=f.move(l),u()),a(),d}function FU(n){const e=n.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function Qd(n){const e=n.codePointAt(0);return e===void 0?"":String.fromCodePoint(e)}function wa(n){const e=n.codePointAt(n.length-2);return e!==void 0&&e>65535?n.slice(-2):n.slice(-1)}function oE(n){return"&#x"+n.toString(16).toUpperCase()+";"}function BC(n,e,t){const i=us(n),l=us(e);return i===void 0?l===void 0?t==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:l===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?l===void 0?{inside:!1,outside:!1}:l===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:l===void 0?{inside:!1,outside:!1}:l===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function qU(n){if(n.charCodeAt(0)!==60)return;const e=n.charCodeAt(1);if(e===33){const u=n.charCodeAt(2);return u===45?2:u===91?5:Ln(u)?4:void 0}if(e===63)return 3;const t=e===47,i=t?2:1;let l=i,o=n.charCodeAt(l);if(!Ln(o))return;for(;o===45||zn(o);)o=n.charCodeAt(++l);const a=n.slice(i,l).toLowerCase();return!t&&o!==47&&sy.includes(a)?1:VA.includes(a)?6:7}const VU=new Map([["*",!1],["_",!0]]);function QU(n,e,t){const i=new Set;for(const o of n){const a=t.get(o);if(a&&o.attention&&e.some(u=>u.attention===o.attention))for(const u of a.tokens)i.add(u.attention)}const l=[];for(const o of n)o.attention&&i.delete(o.attention)&&l.push(o.attention);return l.reverse(),l}function aE(n,e,t){const i=[],l=new Map,o=new Map;let a=0;for(;at.index)return{chosen:f,mistake:m,tokens:d}}}}function $U(n,e){const t=new Map;for(const i of n){const l=i.tokens[0].value.charAt(0);let o=t.get(l);o||(o=[],t.set(l,o));let a=i.close?o.length:0;for(;a--&&i.start1&&d>1?2:1:d,g=u.markers.slice(u.end-m,u.end),b=i.markers.slice(i.start,i.start+m),v=g[0],w=b[0];if(v===g[m-1]&&v.value.length===m&&w===b[m-1]&&w.value.length===m&&v.attention===w.attention)e.delete(v),e.delete(w);else{const S=[...new Set([...g,...b])];for(const C of S){const N=e.get(C);N&&N.push(...S)}}u.end-=m,i.start+=m,u.start===u.end&&o.splice(a,1),a=o.length}i.open&&i.start0?w[0].value:"",C=BC(b.charCodeAt(b.length-1),S.charCodeAt(0),m);C.inside&&Qh(w,!0);const N=w.length>0?wa(w[w.length-1].value):"",j=BC(v.charCodeAt(0),N.charCodeAt(N.length-1),m);j.inside&&Qh(w,!1),C.outside&&b!==` +`&&b!=="\r"&&Qh(l,!1),j.outside&&(o=v),l.push({value:d,attention:f},...w,{value:d,attention:f}),a=d.charAt(d.length-1)}return l}function gm(n,e,t){let i=new Map;const l=Sb(n,i,e,t);let o=l,a=aE(o,e,t);for(;a;){const f=XU(n,i,a,e,t);if(!f){o=l;break}i=f.chosen,o=f.tokens,a=f.mistake}let u="";for(const f of o)u+=f.value;return u}Cb.attention=cE;Cb.peek=KU;function Cb(n,e,t,i){const l=t.enter("phrasing"),o=kb(n,cE,t,t.createTracker(i)),a=gm([o],i.before,i.after);return l(),a}function cE(n,e){return{construct:"emphasis",markers:FU(e)==="*"?["*","_"]:["_","*"],sizes:[1]}}function KU(n,e,t){return t.options.emphasis||"*"}function WU(n,e){let t=!1;return yb(n,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return t=!0,cd}),!!((!n.depth||n.depth<3)&&fb(n)&&(e.options.setext||t))}function ZU(n,e,t,i){const l=Math.max(Math.min(6,n.depth||1),1),o=t.createTracker(i);if(WU(n,t)){const g=t.enter("headingSetext"),b=t.enter("phrasing"),v=t.containerPhrasing(n,{...o.current(),before:` +`,after:` +`});return b(),g(),v+` +`+(l===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(` +`))+1))}const a="#".repeat(l),u=t.enter("headingAtx"),f=t.enter("phrasing");o.move(a+" ");let d=t.containerPhrasing(n,{before:"# ",after:` +`,...o.current()});const m=d.charCodeAt(0);return(m===9||m===32)&&(d=oE(m)+d.slice(1)),d=d?a+" "+d:a,t.options.closeAtx&&(d+=" "+a),f(),u(),d}uE.peek=JU;function uE(n){return n.value||""}function JU(){return"<"}fE.peek=eF;function fE(n,e,t,i){const l=wb(t),o=l==='"'?"Quote":"Apostrophe",a=t.enter("image");let u=t.enter("label");const f=t.createTracker(i);let d=f.move("![");return d+=f.move(t.safe(n.alt,{before:d,after:"]",...f.current()})),d+=f.move("]("),u(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(u=t.enter("destinationLiteral"),d+=f.move("<"),d+=f.move(t.safe(n.url,{before:d,after:">",...f.current()})),d+=f.move(">")):(u=t.enter("destinationRaw"),d+=f.move(t.safe(n.url,{before:d,after:n.title?" ":")",...f.current()}))),u(),n.title&&(u=t.enter(`title${o}`),d+=f.move(" "+l),d+=f.move(t.safe(n.title,{before:d,after:l,...f.current()})),d+=f.move(l),u()),d+=f.move(")"),a(),d}function eF(){return"!"}hE.peek=tF;function hE(n,e,t,i){const l=n.referenceType,o=t.enter("imageReference");let a=t.enter("label");const u=t.createTracker(i);let f=u.move("![");const d=t.safe(n.alt,{before:f,after:"]",...u.current()});f+=u.move(d+"]["),a();const m=t.stack;t.stack=m.filter(function(b){return b!=="phrasing"}),a=t.enter("reference");const g=t.safe(t.associationId(n),{before:f,after:"]",...u.current()});return a(),t.stack=m,o(),l==="full"||!d||d!==g?f+=u.move(g+"]"):l==="shortcut"?f=f.slice(0,-1):f+=u.move("]"),f}function tF(){return"!"}dE.peek=nF;function dE(n,e,t){let i=n.value||"",l="`",o=-1;for(;new RegExp("(^|[^`])"+l+"([^`]|$)").test(i);)l+="`";for(/[^\n\r ]/.test(i)&&(/^[\n\r ]/.test(i)&&/[\n\r ]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++o\u007F]/.test(n.url))}pE.peek=iF;function pE(n,e,t,i){const l=wb(t),o=l==='"'?"Quote":"Apostrophe",a=t.createTracker(i);if(mE(n,t)){const w=t.stack;t.stack=w.filter(function(N){return N!=="phrasing"});const S=t.enter("autolink");let C=a.move("<");return C+=a.move(t.containerPhrasing(n,{before:C,after:">",...a.current()})),C+=a.move(">"),S(),t.stack=w,C}const u=t.enter("link");let f=t.enter("label"),d=a.move("[");const m=t.containerPhrasing(n,{before:d,after:"](",...a.current()});d+=a.move(m),f(),d+=a.move("](");const g=/[\0- \u007F]/.test(n.url),b=i.before.charAt(i.before.length-1);let v=n.title||void 0;if(!v&&!g&&(b===` +`||b==="\r")){let w=0;for(;w",...a.current()})),d+=a.move(">")):(f=t.enter("destinationRaw"),d+=a.move(t.safe(n.url,{before:d,after:typeof v=="string"?" ":")",...a.current()}))),f(),typeof v=="string"&&(f=t.enter(`title${o}`),d+=a.move(" "+l),d+=a.move(t.safe(v,{before:d,after:l,...a.current()})),d+=a.move(l),f()),d+=a.move(")"),u(),d}function iF(n,e,t){return mE(n,t)?"<":"["}gE.peek=rF;function gE(n,e,t,i){const l=n.referenceType,o=t.enter("linkReference");let a=t.enter("label");const u=t.createTracker(i);let f=u.move("[");const d=t.containerPhrasing(n,{before:f,after:"]",...u.current()});f+=u.move(d+"]["),a();const m=t.stack;t.stack=m.filter(function(b){return b!=="phrasing"}),a=t.enter("reference");const g=t.safe(t.associationId(n),{before:f,after:"]",...u.current()});return a(),t.stack=m,o(),l==="full"||!d||d!==g?f+=u.move(g+"]"):l==="shortcut"?f=f.slice(0,-1):f+=u.move("]"),f}function rF(){return"["}function Ob(n){const e=n.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function lF(n){const e=Ob(n),t=n.options.bulletOther;if(!t)return e==="*"?"-":"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(t===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+t+"`) to be different");return t}function sF(n){const e=n.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function xE(n){const e=n.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function oF(n,e,t,i){const l=t.enter("list"),o=t.bulletCurrent;let a=n.ordered?sF(t):Ob(t);const u=n.ordered?a==="."?")":".":lF(t);let f=e&&t.bulletLastUsed?a===t.bulletLastUsed:!1;if(!n.ordered){const m=n.children?n.children[0]:void 0;if((a==="*"||a==="-")&&m&&(!m.children||!m.children[0])&&t.stack[t.stack.length-1]==="list"&&t.stack[t.stack.length-2]==="listItem"&&t.stack[t.stack.length-3]==="list"&&t.stack[t.stack.length-4]==="listItem"&&t.indexStack[t.indexStack.length-1]===0&&t.indexStack[t.indexStack.length-2]===0&&t.indexStack[t.indexStack.length-3]===0&&(f=!0),xE(t)===a&&m){let g=-1;for(;++g-1?e.start:1)+(t.options.incrementListMarker===!1?0:e.children.indexOf(n))+o);let a=o.length+1;(l==="tab"||l==="mixed"&&(e&&e.type==="list"&&e.spread||n.spread))&&(a=Math.ceil(a/4)*4);const u=t.createTracker(i);u.move(o+" ".repeat(a-o.length)),u.shift(a);const f=t.enter("listItem"),d=t.indentLines(t.containerFlow(n,u.current()),m);return f(),d;function m(g,b,v){return b?(v?"":" ".repeat(a))+g:(v?o:o+" ".repeat(a-o.length))+g}}function uF(n,e,t,i){const l=t.enter("paragraph"),o=t.enter("phrasing"),a=t.containerPhrasing(n,i);return o(),l(),a}function fF(n,e,t,i){if(!n.children.some(function(u){return RU(u)}))return t.containerFlow(n,i);const o=t.enter("phrasing"),a=t.containerPhrasing(n,i);return o(),a}function hF(n){const e=n.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}Nb.attention=yE;Nb.peek=dF;function Nb(n,e,t,i){const l=t.enter("phrasing"),o=kb(n,yE,t,t.createTracker(i)),a=gm([o],i.before,i.after);return l(),a}function yE(n,e){return{construct:"strong",markers:hF(e)==="*"?["*","_"]:["_","*"],sizes:[2]}}function dF(n,e,t){return t.options.strong||"*"}function mF(n,e,t,i){const l=e?e.children:[],o=t.indexStack[t.indexStack.length-1];return t.safe(n.value,{...i,afterNode:l[o+1],beforeNode:l[o-1]})}function pF(n){const e=n.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function gF(n,e,t){const i=(xE(t)+(t.options.ruleSpaces?" ":"")).repeat(pF(t));return t.options.ruleSpaces?i.slice(0,-1):i}const bE={blockquote:jU,break:zC,code:HU,definition:UU,emphasis:Cb,hardBreak:zC,heading:ZU,html:uE,image:fE,imageReference:hE,inlineCode:dE,link:pE,linkReference:gE,list:oF,listItem:cF,paragraph:uF,root:fF,strong:Nb,text:mF,thematicBreak:gF};function xF(){return{enter:{table:yF,tableData:PC,tableHeader:PC,tableRow:vF},exit:{codeText:wF,table:bF,tableData:$0,tableHeader:$0,tableRow:$0}}}function yF(n){const e=n._align;this.enter({type:"table",align:e.map(function(t){return t==="none"?null:t}),children:[]},n),this.data.inTable=!0}function bF(n){this.exit(n),this.data.inTable=void 0}function vF(n){this.enter({type:"tableRow",children:[]},n)}function $0(n){this.exit(n)}function PC(n){this.enter({type:"tableCell",children:[]},n)}function wF(n){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,kF));const t=this.stack[this.stack.length-1];t.type,t.value=e,this.exit(n)}function kF(n,e){return e==="|"?e:n}function SF(n){const e=n||{},t=e.tableCellPadding,i=e.tablePipeAlign,l=e.stringLength,o=t?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` +`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:a,tableCell:f,tableRow:u}};function a(v,w,S,C){return d(m(v,S,C),v.align)}function u(v,w,S,C){const N=g(v,S,C),j=d([N]);return j.slice(0,j.indexOf(` +`))}function f(v,w,S,C){const N=S.enter("tableCell"),j=S.enter("phrasing"),D=S.containerPhrasing(v,{...C,before:o,after:o});return j(),N(),D}function d(v,w){return MU(v,{align:w,alignDelimiters:i,padding:t,stringLength:l})}function m(v,w,S){const C=v.children;let N=-1;const j=[],D=w.enter("table");for(;++N0&&!t&&(n[n.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),t}const UF={tokenize:GF,partial:!0};function FF(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:XF,continuation:{tokenize:$F},exit:YF}},text:{91:{name:"gfmFootnoteCall",tokenize:QF},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:qF,resolveTo:VF}}}}function qF(n,e,t){const i=this;let l=i.events.length;const o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let a;for(;l--;){const f=i.events[l][1];if(f.type==="labelImage"){a=f;break}if(f.type==="gfmFootnoteCall"||f.type==="labelLink"||f.type==="label"||f.type==="image"||f.type==="link")break}return u;function u(f){if(!a||!a._balanced)return t(f);const d=lr(i.sliceSerialize({start:a.end,end:i.now()}));return d.codePointAt(0)!==94||!o.includes(d.slice(1))?t(f):(n.enter("gfmFootnoteCallLabelMarker"),n.consume(f),n.exit("gfmFootnoteCallLabelMarker"),e(f))}}function VF(n,e){let t=n.length;for(;t--;)if(n[t][1].type==="labelImage"&&n[t][0]==="enter"){n[t][1];break}n[t+1][1].type="data",n[t+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},n[t+3][1].start),end:Object.assign({},n[n.length-1][1].end)},l={type:"gfmFootnoteCallMarker",start:Object.assign({},n[t+3][1].end),end:Object.assign({},n[t+3][1].end)};l.end.column++,l.end.offset++,l.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},l.end),end:Object.assign({},n[n.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},u=[n[t+1],n[t+2],["enter",i,e],n[t+3],n[t+4],["enter",l,e],["exit",l,e],["enter",o,e],["enter",a,e],["exit",a,e],["exit",o,e],n[n.length-2],n[n.length-1],["exit",i,e]];return n.splice(t,n.length-t+1,...u),n}function QF(n,e,t){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o=0,a;return u;function u(g){return n.enter("gfmFootnoteCall"),n.enter("gfmFootnoteCallLabelMarker"),n.consume(g),n.exit("gfmFootnoteCallLabelMarker"),f}function f(g){return g!==94?t(g):(n.enter("gfmFootnoteCallMarker"),n.consume(g),n.exit("gfmFootnoteCallMarker"),n.enter("gfmFootnoteCallString"),n.enter("chunkString").contentType="string",d)}function d(g){if(o>999||g===93&&!a||g===null||g===91||Rt(g))return t(g);if(g===93){n.exit("chunkString");const b=n.exit("gfmFootnoteCallString");return l.includes(lr(i.sliceSerialize(b)))?(n.enter("gfmFootnoteCallLabelMarker"),n.consume(g),n.exit("gfmFootnoteCallLabelMarker"),n.exit("gfmFootnoteCall"),e):t(g)}return Rt(g)||(a=!0),o++,n.consume(g),g===92?m:d}function m(g){return g===91||g===92||g===93?(n.consume(g),o++,d):d(g)}}function XF(n,e,t){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o,a=0,u;return f;function f(w){return n.enter("gfmFootnoteDefinition")._container=!0,n.enter("gfmFootnoteDefinitionLabel"),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(w),n.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(w){return w===94?(n.enter("gfmFootnoteDefinitionMarker"),n.consume(w),n.exit("gfmFootnoteDefinitionMarker"),n.enter("gfmFootnoteDefinitionLabelString"),n.enter("chunkString").contentType="string",m):t(w)}function m(w){if(a>999||w===93&&!u||w===null||w===91||Rt(w))return t(w);if(w===93){n.exit("chunkString");const S=n.exit("gfmFootnoteDefinitionLabelString");return o=lr(i.sliceSerialize(S)),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(w),n.exit("gfmFootnoteDefinitionLabelMarker"),n.exit("gfmFootnoteDefinitionLabel"),b}return Rt(w)||(u=!0),a++,n.consume(w),w===92?g:m}function g(w){return w===91||w===92||w===93?(n.consume(w),a++,m):m(w)}function b(w){return w===58?(n.enter("definitionMarker"),n.consume(w),n.exit("definitionMarker"),l.includes(o)||l.push(o),xt(n,v,"gfmFootnoteDefinitionWhitespace")):t(w)}function v(w){return e(w)}}function $F(n,e,t){return n.check(_u,e,n.attempt(UF,e,t))}function YF(n){n.exit("gfmFootnoteDefinition")}function GF(n,e,t){const i=this;return xt(n,l,"gfmFootnoteDefinitionIndent",5);function l(o){const a=i.events[i.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?e(o):t(o)}}function KF(n){let t=(n||{}).singleTilde;const i={name:"strikethrough",tokenize:o,resolveAll:l};return t==null&&(t=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function l(a,u){let f=-1;for(;++f1?f(w):(a.consume(w),g++,v);if(g<2&&!t)return f(w);const C=a.exit("strikethroughSequenceTemporary"),N=us(w);return C._open=!N||N===2&&!!S,C._close=!S||S===2&&!!N,u(w)}}}class WF{constructor(){this.map=[],this.index=new Map}add(e,t,i){ZF(this,e,t,i)}consume(e){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let t=this.map.length;const i=[];for(;t>0;)t-=1,i.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];i.push(e.slice()),e.length=0;let l=i.pop();for(;l;){for(const o of l)e.push(o);l=i.pop()}this.map.length=0,this.index.clear()}}function ZF(n,e,t,i){if(t===0&&i.length===0)return;const l=n.index.get(e);if(l){l[1]+=t,l[2].push(...i);return}const o=[e,t,i];n.map.push(o),n.index.set(e,o)}function JF(n,e){let t=!1;const i=[];for(;e-1;){const{type:me}=i.events[G][1];if(me==="lineEnding"||me==="linePrefix")G--;else break}const F=G>-1?i.events[G][1].type:null,se=F==="tableHead"||F==="tableRow"?E:f;return se===E&&i.parser.lazy[i.now().line]?t(q):se(q)}function f(q){return n.enter("tableHead"),n.enter("tableRow"),d(q)}function d(q){return q===124||(a=!0,o+=1),m(q)}function m(q){return q===null?t(q):Ie(q)?o>1?(o=0,i.interrupt=!0,n.exit("tableRow"),n.enter("lineEnding"),n.consume(q),n.exit("lineEnding"),v):t(q):Je(q)?xt(n,m,"whitespace")(q):(o+=1,a&&(a=!1,l+=1),q===124?(n.enter("tableCellDivider"),n.consume(q),n.exit("tableCellDivider"),a=!0,m):(n.enter("data"),g(q)))}function g(q){return q===null||q===124||Rt(q)?(n.exit("data"),m(q)):(n.consume(q),q===92?b:g)}function b(q){return q===92||q===124?(n.consume(q),g):g(q)}function v(q){return i.interrupt=!1,i.parser.lazy[i.now().line]?t(q):(n.enter("tableDelimiterRow"),a=!1,Je(q)?xt(n,w,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(q):w(q))}function w(q){return q===45||q===58?C(q):q===124?(a=!0,n.enter("tableCellDivider"),n.consume(q),n.exit("tableCellDivider"),S):U(q)}function S(q){return Je(q)?xt(n,C,"whitespace")(q):C(q)}function C(q){return q===58?(o+=1,a=!0,n.enter("tableDelimiterMarker"),n.consume(q),n.exit("tableDelimiterMarker"),N):q===45?(o+=1,N(q)):q===null||Ie(q)?I(q):U(q)}function N(q){return q===45?(n.enter("tableDelimiterFiller"),j(q)):U(q)}function j(q){return q===45?(n.consume(q),j):q===58?(a=!0,n.exit("tableDelimiterFiller"),n.enter("tableDelimiterMarker"),n.consume(q),n.exit("tableDelimiterMarker"),D):(n.exit("tableDelimiterFiller"),D(q))}function D(q){return Je(q)?xt(n,I,"whitespace")(q):I(q)}function I(q){return q===124?w(q):q===null||Ie(q)?!a||l!==o?U(q):(n.exit("tableDelimiterRow"),n.exit("tableHead"),e(q)):U(q)}function U(q){return t(q)}function E(q){return n.enter("tableRow"),T(q)}function T(q){return q===124?(n.enter("tableCellDivider"),n.consume(q),n.exit("tableCellDivider"),T):q===null||Ie(q)?(n.exit("tableRow"),e(q)):Je(q)?xt(n,T,"whitespace")(q):(n.enter("data"),z(q))}function z(q){return q===null||q===124||Rt(q)?(n.exit("data"),T(q)):(n.consume(q),q===92?te:z)}function te(q){return q===92||q===124?(n.consume(q),z):z(q)}}function nq(n,e){let t=-1,i=!0,l=0,o=[0,0,0,0],a=[0,0,0,0],u=!1,f=0,d,m,g;const b=new WF;for(;++tt[2]+1){const w=t[2]+1,S=t[3]-t[2]-1;n.add(w,S,[])}}n.add(t[3]+1,0,[["exit",g,e]])}return l!==void 0&&(o.end=Object.assign({},sa(e.events,l)),n.add(l,0,[["exit",o,e]]),o=void 0),o}function IC(n,e,t,i,l){const o=[],a=sa(e.events,t);l&&(l.end=Object.assign({},a),o.push(["exit",l,e])),i.end=Object.assign({},a),o.push(["exit",i,e]),n.add(t+1,0,o)}function sa(n,e){const t=n[e],i=t[0]==="enter"?"start":"end";return t[1][i]}const iq={name:"tasklistCheck",tokenize:lq};function rq(){return{text:{91:iq}}}function lq(n,e,t){const i=this;return l;function l(f){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?t(f):(n.enter("taskListCheck"),n.enter("taskListCheckMarker"),n.consume(f),n.exit("taskListCheckMarker"),o)}function o(f){return Rt(f)?(n.enter("taskListCheckValueUnchecked"),n.consume(f),n.exit("taskListCheckValueUnchecked"),a):f===88||f===120?(n.enter("taskListCheckValueChecked"),n.consume(f),n.exit("taskListCheckValueChecked"),a):t(f)}function a(f){return f===93?(n.enter("taskListCheckMarker"),n.consume(f),n.exit("taskListCheckMarker"),n.exit("taskListCheck"),u):t(f)}function u(f){return Ie(f)?e(f):Je(f)?n.check({tokenize:sq},e,t)(f):t(f)}}function sq(n,e,t){return xt(n,i,"whitespace");function i(l){return l===null?t(l):e(l)}}function oq(n){return jA([RF(),FF(),KF(n),eq(),rq()])}const aq={};function cq(n){const e=this,t=n||aq,i=e.data(),l=i.micromarkExtensions||(i.micromarkExtensions=[]),o=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),a=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);l.push(oq(t)),o.push(AF()),a.push(EF(t))}function uq(n){return n.replace(/\\n/g,` +`).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\")}const fq={h1:({children:n})=>y.jsx("h3",{className:"mt-3 mb-1.5 text-base font-bold text-ink first:mt-0",children:n}),h2:({children:n})=>y.jsx("h4",{className:"mt-3 mb-1 text-sm font-semibold text-ink first:mt-0",children:n}),h3:({children:n})=>y.jsx("h5",{className:"mt-2 mb-1 text-xs font-semibold text-ink first:mt-0",children:n}),p:({children:n})=>y.jsx("p",{className:"my-1.5 leading-relaxed first:mt-0 last:mb-0",children:n}),strong:({children:n})=>y.jsx("strong",{className:"font-semibold text-ink",children:n}),em:({children:n})=>y.jsx("em",{className:"italic text-ink-secondary",children:n}),del:({children:n})=>y.jsx("del",{className:"text-ink-muted line-through",children:n}),a:({children:n,href:e})=>y.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-chip-indigo-text underline underline-offset-2 hover:text-ink",children:n}),code:({children:n,className:e})=>y.jsx("code",{className:`break-words rounded bg-elevated px-1 py-0.5 font-mono text-chip-indigo-text whitespace-pre-wrap ${e??""}`,children:n}),pre:({children:n})=>y.jsx("pre",{className:"my-2 overflow-x-auto rounded-lg border border-line bg-elevated p-3 font-mono text-xs text-ink [&_code]:bg-transparent [&_code]:px-0 [&_code]:py-0 [&_code]:text-inherit",children:n}),ul:({children:n})=>y.jsx("ul",{className:"my-1.5 list-disc space-y-0.5 pl-5",children:n}),ol:({children:n})=>y.jsx("ol",{className:"my-1.5 list-decimal space-y-0.5 pl-5",children:n}),li:({children:n})=>y.jsx("li",{className:"leading-relaxed",children:n}),blockquote:({children:n})=>y.jsx("blockquote",{className:"my-2 border-l-2 border-line-strong pl-3 text-ink-secondary italic",children:n}),table:({children:n})=>y.jsx("div",{className:"my-2 overflow-x-auto",children:y.jsx("table",{className:"w-full border-collapse text-xs",children:n})}),th:({children:n})=>y.jsx("th",{className:"border border-line bg-elevated px-2 py-1 text-left font-semibold",children:n}),td:({children:n})=>y.jsx("td",{className:"border border-line px-2 py-1 align-top",children:n}),hr:()=>y.jsx("hr",{className:"my-3 border-line"}),img:({alt:n,src:e,title:t})=>y.jsx("img",{src:e,alt:n,title:t,loading:"lazy",referrerPolicy:"no-referrer",className:"my-2 max-w-full rounded-lg border border-line"})};function $h({text:n}){return n?y.jsx(II,{remarkPlugins:[cq,WI],components:fq,children:uq(n)}):null}function AE(n){return n==="completed"||n==="aborted"||n==="failed"}function Vc({label:n}){return y.jsx("kbd",{"aria-hidden":"true",className:"ml-1.5 inline-block rounded border border-line/60 bg-elevated/60 px-1 py-px font-mono text-[10px] font-normal leading-none opacity-90",children:n})}function UC(n){!n||AE(n.status)||PM(n.session_id).catch(()=>{})}const hq={running:"running",completed:"done",skipped:"skipped",failed:"failed",pending:"pending"};function Yh({text:n}){const[e,t]=M.useState(!1),i=M.useRef(void 0);M.useEffect(()=>()=>window.clearTimeout(i.current),[]);const l=async()=>{try{await navigator.clipboard.writeText(n),t(!0),window.clearTimeout(i.current),i.current=window.setTimeout(()=>t(!1),1500)}catch{}};return y.jsx("button",{type:"button",onClick:l,"aria-label":e?"Copied":"Copy content",title:e?"Copied!":"Copy content",className:"absolute right-2 top-2 rounded-md p-1.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:e?y.jsx(Lr,{className:"h-3.5 w-3.5"}):y.jsx(fi,{className:"h-3.5 w-3.5"})})}function dq({isOpen:n,onClose:e,directory:t,filename:i,release:l,args:o,onFinished:a}){var ze,B;const[u,f]=M.useState(null),[d,m]=M.useState(!1),[g,b]=M.useState(null),[v,w]=M.useState(null),[S,C]=M.useState(!1),[N,j]=M.useState(0),D=M.useRef(null),I=M.useRef(!1),U=M.useRef(null),E=M.useRef(!1);M.useEffect(()=>{if(!n||!t||!i){f(null),b(null),C(!1),w(null),E.current=!1;return}let R=!0;return m(!0),b(null),C(!1),w(null),zM({directory:t,filename:i,release:l,args:o}).then($=>{R&&(f($),m(!1),($.status==="completed"||$.status==="aborted"||$.status==="failed")&&(a==null||a($.status,$.final_message||"")))}).catch($=>{R&&(($==null?void 0:$.status)===404&&C(!0),b($.message||"Failed to start workflow"),m(!1))}),()=>{R=!1}},[n,t,i,l,o,N]);const T=async R=>{if(!(!u||I.current)){I.current=!0,m(!0);try{const $=await BM(u.session_id,R);f($),($.status==="completed"||$.status==="aborted"||$.status==="failed")&&(a==null||a($.status,$.final_message||""))}catch($){($==null?void 0:$.status)===404?(C(!0),b($.message||"Workflow session on the server has expired.")):b($.message||"Failed to process workflow response")}finally{I.current=!1,m(!1)}}},z=M.useRef(u);z.current=u;const te=M.useRef(T);te.current=T;const q=M.useRef(v);q.current=v;const G=M.useRef([]),F=(R,$)=>{var je,Ne;if(R.key!=="ArrowDown"&&R.key!=="ArrowUp"&&R.key!=="Home"&&R.key!=="End")return;R.preventDefault();const ue=((je=z.current)==null?void 0:je.steps.length)??0;if(ue===0)return;const ge=R.key==="ArrowDown"?($+1)%ue:R.key==="ArrowUp"?($-1+ue)%ue:R.key==="Home"?0:ue-1;w(ge),(Ne=G.current[ge])==null||Ne.focus()};M.useEffect(()=>()=>UC(z.current),[]);const se=()=>{E.current||(E.current=!0,UC(z.current),e())},me=()=>{f(null),b(null),C(!1),w(null),E.current=!1,j(R=>R+1)},ne=ds({isOpen:n,onClose:se,dialogRef:D,initialFocusRef:U});if(M.useEffect(()=>{if(!n)return;const R=$=>{var _e,Pt,tn;if($.key==="Escape"){$.preventDefault(),se();return}const ue=z.current;if(!ue)return;if(AE(ue.status)){$.key==="Enter"&&!$.repeat&&!$.ctrlKey&&!$.metaKey&&!$.altKey&&!I.current&&((_e=$.target)==null?void 0:_e.tagName)!=="BUTTON"&&((Pt=document.activeElement)==null?void 0:Pt.tagName)!=="BUTTON"&&($.preventDefault(),se());return}if(I.current||$.repeat||$.ctrlKey||$.metaKey||$.altKey)return;const ge=$.target;if((ge==null?void 0:ge.tagName)==="INPUT"||(ge==null?void 0:ge.tagName)==="TEXTAREA"||ge!=null&&ge.isContentEditable)return;const je=q.current,Ne=je===null||je===ue.current_index,Pe=ue.status==="waiting_ask"?"yes":ue.status==="waiting_notify"||ue.status==="waiting_notice"?"ack":null;if(!Ne||Pe===null)return;if($.key==="Enter"){const gn=$.target;if((gn==null?void 0:gn.tagName)==="BUTTON"||((tn=document.activeElement)==null?void 0:tn.tagName)==="BUTTON")return;$.preventDefault(),te.current(Pe);return}if(ue.status!=="waiting_ask")return;const be=$.key.toLowerCase();be==="y"?($.preventDefault(),te.current("yes")):be==="s"?($.preventDefault(),te.current("skip")):be==="n"&&($.preventDefault(),te.current("no"))};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[n,e]),M.useEffect(()=>{if(!n||!u)return;const R=requestAnimationFrame(()=>{var $;return($=U.current)==null?void 0:$.focus()});return()=>cancelAnimationFrame(R)},[n,u==null?void 0:u.status]),!n)return null;const _=v!==null?u==null?void 0:u.steps[v]:u==null?void 0:u.steps[u.current_index],Z=(u==null?void 0:u.status)==="completed"||(u==null?void 0:u.status)==="aborted"||(u==null?void 0:u.status)==="failed",ie=!!u&&!Z&&!S&&(((ze=u.status)==null?void 0:ze.startsWith("waiting"))??!1),re=(((B=u==null?void 0:u.steps[(u==null?void 0:u.current_index)??-1])==null?void 0:B.phase)??"pre")==="post",Be=!S&&(v===null||v===(u==null?void 0:u.current_index))&&(_!=null&&_.command)&&((u==null?void 0:u.status)==="waiting_notify"||(u==null?void 0:u.status)==="waiting_notice"||(u==null?void 0:u.status)==="waiting_ask")?y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Command:"}),y.jsxs("div",{className:"relative rounded-lg border border-line bg-surface-strong p-4 pr-10 font-mono text-xs text-ink leading-relaxed",children:[y.jsx(Yh,{text:_.command}),_.command]})]}):null;return y.jsx("div",{ref:D,role:"dialog","aria-modal":"true","aria-labelledby":"workflow-runner-title",onKeyDown:ne,className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-xs",children:y.jsxs("div",{className:"animate-modal-in flex h-[80vh] w-full max-w-5xl flex-col rounded-xl border border-frame-line glass-panel overflow-hidden",children:[y.jsxs("div",{className:"flex items-center justify-between border-b border-line px-5 py-3.5 bg-surface-strong/30 shrink-0",children:[y.jsxs("div",{className:"flex items-center gap-2.5",children:[y.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-chip-indigo-bg text-chip-indigo-text",children:y.jsx(aO,{className:"h-4 w-4"})}),y.jsxs("div",{children:[y.jsx("h2",{id:"workflow-runner-title",className:"text-sm font-semibold text-ink",children:"Launch Workflow Engine"}),y.jsxs("p",{className:"text-xs text-ink-muted",children:[i," ",u!=null&&u.pattern?`• Pattern: ${u.pattern}`:""]})]})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[u&&!Z&&!S&&y.jsxs("button",{type:"button",disabled:!ie||d,onClick:()=>T("bypass"),title:re?"Skip the remaining post-launch steps":"Skip the remaining steps and launch with the OS default app",className:"btn inline-flex items-center gap-1.5 rounded-md border border-line bg-surface px-3 py-1.5 text-xs font-medium text-status-warning-text hover:bg-status-warning-bg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 disabled:cursor-not-allowed disabled:opacity-40",children:[y.jsx(uD,{className:"h-3.5 w-3.5"}),re?"Skip rest":"Launch now"]}),y.jsx("button",{type:"button",onClick:se,className:"rounded-md p-1.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:y.jsx(Ri,{className:"h-4 w-4"})})]})]}),y.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[y.jsxs("div",{className:"w-72 border-r border-line bg-surface-strong/20 p-4 overflow-y-auto flex flex-col gap-2 shrink-0",children:[y.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-ink-muted px-1 mb-1",children:"Workflow Steps (Click to inspect)"}),u&&u.steps.length>0?y.jsx("ul",{role:"list",className:"flex flex-col gap-2",children:u.steps.map((R,$)=>{const ue=u.current_index===$&&!Z,ge=v===$||v===null&&ue,je=hq[R.status];return y.jsx("li",{children:y.jsxs("button",{ref:Ne=>{G.current[$]=Ne},type:"button",tabIndex:ge?0:-1,"aria-current":ge?"step":void 0,onKeyDown:Ne=>F(Ne,$),onClick:()=>w($),className:`flex items-start text-left gap-2.5 rounded-lg border px-3 py-2.5 transition-colors cursor-pointer w-full ${ge?"border-chip-indigo-border bg-chip-indigo-bg shadow-xs ring-1 ring-chip-indigo-border/40":"border-line/60 bg-surface/60 hover:bg-elevated/80"}`,children:[y.jsxs("div",{className:"mt-0.5 shrink-0",children:[R.status==="running"&&y.jsx(sl,{className:"h-4 w-4 animate-spin text-chip-indigo-text"}),R.status==="completed"&&y.jsx($k,{className:"h-4 w-4 text-status-success-text"}),R.status==="skipped"&&y.jsx(M4,{className:"h-4 w-4 text-status-warning-text"}),R.status==="failed"&&y.jsx(Gc,{className:"h-4 w-4 text-status-danger-text"}),R.status==="pending"&&y.jsx("div",{className:"h-4 w-4 rounded-full border border-line-strong flex items-center justify-center text-[10px] text-ink-faint font-mono",children:R.index})]}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"font-mono text-[11px] font-bold uppercase text-chip-indigo-text",children:R.action}),y.jsxs("span",{className:"text-[10px] font-mono text-ink-faint",children:["#",R.index," · ",je]})]}),y.jsx("p",{className:"truncate font-mono text-[11px] text-ink-secondary mt-0.5",title:R.command,children:R.message?R.message.split(` +`)[0]:R.command}),R.note&&y.jsx("p",{className:"mt-1 text-[10px] text-ink-faint italic",children:R.note})]})]})},R.index)})}):y.jsx("div",{className:"p-4 text-center text-xs text-ink-faint",children:g||S?"Session unavailable — see the error panel.":"Loading steps..."})]}),y.jsxs("div",{className:"flex-1 flex flex-col bg-app",children:[y.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-6",children:y.jsx("div",{className:"space-y-6",children:y.jsxs("div",{className:"rounded-xl border border-line bg-surface p-5 shadow-xs space-y-4",children:[y.jsxs("div",{className:"flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"rounded bg-chip-indigo-bg px-2 py-0.5 font-mono text-xs font-semibold uppercase text-chip-indigo-text",children:(_==null?void 0:_.action)||(u==null?void 0:u.status)}),y.jsx("span",{className:"text-xs text-ink-muted",children:_?`Step ${_.index} of ${u==null?void 0:u.steps.length}`:"Status"}),v!==null&&v!==(u==null?void 0:u.current_index)&&y.jsx("button",{type:"button",onClick:()=>w(null),className:"text-[11px] text-chip-indigo-text hover:underline ml-2",children:"(Return to active step)"})]}),d&&y.jsx(sl,{className:"h-4 w-4 animate-spin text-chip-indigo-text"})]}),y.jsxs("div",{className:"space-y-3 text-xs text-ink font-sans leading-relaxed",children:[(v===null||v===(u==null?void 0:u.current_index))&&(u==null?void 0:u.status)==="waiting_notify"&&u.notify_message&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Notification Message:"}),y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-ink",children:y.jsx($h,{text:u.notify_message})}),Be]}),(v===null||v===(u==null?void 0:u.current_index))&&(u==null?void 0:u.status)==="waiting_notice"&&u.notice_message&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Notice:"}),y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-ink",children:y.jsx($h,{text:u.notice_message})}),Be,y.jsx("p",{className:"text-[11px] text-ink-faint",children:"The command will run when you continue."})]}),(v===null||v===(u==null?void 0:u.current_index))&&(u==null?void 0:u.status)==="waiting_ask"&&u.ask_prompt&&y.jsxs("div",{className:"space-y-2",children:[u.ask_message&&y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-ink",children:y.jsx($h,{text:u.ask_message})}),y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-status-warning-text",children:"Confirmation Prompt:"}),y.jsx("div",{className:"rounded-lg border border-status-warning-border bg-status-warning-bg p-4 text-sm font-medium text-ink",children:u.ask_prompt}),Be]}),Z&&v===null&&y.jsxs("div",{className:`rounded-xl border p-8 text-center space-y-4 ${(u==null?void 0:u.status)==="completed"?"border-status-success-border bg-status-success-bg text-status-success-text":"border-status-danger-border bg-status-danger-bg text-status-danger-text"}`,children:[y.jsx("div",{className:"inline-flex h-12 w-12 items-center justify-center rounded-full bg-surface/50 mx-auto",children:(u==null?void 0:u.status)==="completed"?y.jsx($k,{className:"h-6 w-6 text-status-success-text"}):y.jsx(Gc,{className:"h-6 w-6 text-status-danger-text"})}),y.jsxs("div",{className:"space-y-1",children:[y.jsx("h3",{className:"text-base font-bold",children:(u==null?void 0:u.status)==="completed"?"Workflow Finished":"Workflow Terminated"}),y.jsx("p",{className:"text-xs text-ink-secondary max-w-md mx-auto",children:(u==null?void 0:u.final_message)||"The launch sequence has ended."})]}),y.jsx("div",{className:"pt-2",children:y.jsx("button",{type:"button",onClick:e,className:"btn btn-primary px-8 py-2.5 font-bold shadow-lg",children:"Close Engine Runner"})})]}),Z&&v===null&&(u==null?void 0:u.last_output)&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Command Output:"}),y.jsxs("div",{className:"relative",children:[y.jsx(Yh,{text:u.last_output}),y.jsx("pre",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-strong p-4 font-mono text-xs text-ink",children:u.last_output})]})]}),!S&&!(Z&&v===null)&&!((v===null||v===(u==null?void 0:u.current_index))&&((u==null?void 0:u.status)==="waiting_notify"||(u==null?void 0:u.status)==="waiting_ask"||(u==null?void 0:u.status)==="waiting_notice"))&&y.jsxs("div",{className:"space-y-4",children:[(_==null?void 0:_.message)&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Message:"}),y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-xs text-ink",children:y.jsx($h,{text:_.message})})]}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Command:"}),y.jsx("div",{className:"relative rounded-lg border border-line bg-surface-strong p-4 font-mono text-xs text-ink leading-relaxed",children:_!=null&&_.command?y.jsxs(y.Fragment,{children:[y.jsx(Yh,{text:_.command}),y.jsx("span",{className:"block pr-8",children:_.command})]}):"Waiting..."})]}),(_==null?void 0:_.output)&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Output:"}),y.jsxs("div",{className:"relative",children:[y.jsx(Yh,{text:_.output}),y.jsx("pre",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-strong p-4 font-mono text-xs text-ink",children:_.output})]})]}),(_==null?void 0:_.ask)&&y.jsxs("div",{className:"rounded-lg border border-status-warning-border bg-status-warning-bg p-3 text-xs text-status-warning-text",children:[y.jsx("span",{className:"font-semibold",children:"Workflow Guard:"})," ",_.ask]}),(_==null?void 0:_.note)&&y.jsxs("div",{className:"rounded-lg border border-line bg-surface-strong p-3 text-xs text-ink-muted italic",children:[y.jsx("span",{className:"font-semibold text-ink-secondary not-italic uppercase text-[10px]",children:"Log:"})," ",_.note]})]})]})]})})}),(g||S)&&y.jsx("div",{className:"shrink-0 px-6 pt-3",children:y.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-status-danger-border bg-status-danger-bg p-3 text-xs text-status-danger-text",children:[y.jsx(Gc,{className:"mt-0.5 h-4 w-4 shrink-0"}),y.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[y.jsx("p",{children:S?"Workflow session on the server has expired or ended.":g}),S?y.jsxs("div",{className:"space-y-2",children:[g&&y.jsxs("details",{className:"text-ink-muted",children:[y.jsx("summary",{className:"cursor-pointer select-none text-[11px] underline",children:"Raw error (for bug reports)"}),y.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap break-words font-mono text-[11px]",children:g})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("button",{type:"button",onClick:me,className:"btn btn-primary px-4 py-1.5 text-xs font-semibold",children:"Restart workflow"}),y.jsx("button",{type:"button",onClick:se,className:"btn rounded-md border-line bg-surface px-4 py-1.5 text-xs",children:"Close"})]})]}):null]})]})}),y.jsxs("div",{className:"shrink-0 px-6 pt-4 pb-4 border-t border-line flex items-center justify-between bg-app",children:[y.jsx("div",{className:"text-xs text-ink-muted","aria-live":"polite",children:S?"Session unavailable — restart or close above.":(u==null?void 0:u.status)==="waiting_ask"&&(v===null||v===u.current_index)?"Action required to proceed:":(u==null?void 0:u.status)==="waiting_notify"&&(v===null||v===u.current_index)?"Acknowledge message to proceed:":(u==null?void 0:u.status)==="waiting_notice"&&(v===null||v===u.current_index)?"Continue to run the command:":Z?"Session terminated.":"Step in progress..."}),y.jsxs("div",{className:"flex items-center gap-2",children:[!S&&(u==null?void 0:u.status)==="waiting_notice"&&(v===null||v===u.current_index)&&y.jsxs("button",{type:"button",ref:U,disabled:d,onClick:()=>T("ack"),className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:["Run Command",y.jsx(Vc,{label:"↵"})]}),!S&&(u==null?void 0:u.status)==="waiting_notify"&&(v===null||v===u.current_index)&&y.jsxs("button",{type:"button",ref:U,disabled:d,onClick:()=>T("ack"),className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:["Continue Workflow",y.jsx(Vc,{label:"↵"})]}),!S&&(u==null?void 0:u.status)==="waiting_ask"&&(v===null||v===u.current_index)&&y.jsxs(y.Fragment,{children:[y.jsxs("button",{type:"button",disabled:d,onClick:()=>T("no"),className:"btn rounded-md border-line bg-surface px-4 py-2 text-status-danger-text hover:bg-status-danger-bg",children:["Abort Launch",y.jsx(Vc,{label:"N"})]}),y.jsxs("button",{type:"button",disabled:d,onClick:()=>T("skip"),className:"btn rounded-md border-line bg-surface px-4 py-2 text-status-warning-text hover:bg-status-warning-bg",children:["Skip Step",y.jsx(Vc,{label:"S"})]}),y.jsxs("button",{type:"button",ref:U,disabled:d,onClick:()=>T("yes"),className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:["Execute Step",y.jsx(Vc,{label:"Y"})]})]}),Z&&y.jsx("button",{type:"button",ref:U,onClick:e,className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:"Close Runner"})]})]})]})]})]})})}function FC({url:n,label:e,className:t="",onCopied:i,onCopyError:l}){const o=async()=>{try{await navigator.clipboard.writeText(n),i==null||i(n)}catch{l==null||l(n)}};return y.jsxs("span",{className:`flex items-center justify-between gap-2 ${t}`.trim(),children:[y.jsx("code",{className:"truncate font-mono text-[11px] text-ink",children:n}),y.jsx("button",{type:"button",onClick:o,"aria-label":e??`Copy ${n}`,title:e??"Copy",className:"focus-ring shrink-0 rounded p-1 text-ink-faint transition-colors hover:bg-elevated hover:text-ink",children:y.jsx(fi,{className:"h-3.5 w-3.5"})})]})}const mq=";",qC="=";function pq(n){const e=n.trim().toLowerCase();return e==="extension"||e==="file_ext"||e==="filetype"?"ext":e==="directory"||e==="path"||e==="folder"?"dir":e==="recurse"||e==="recursive_search"?"recursive":e==="filter_text"||e==="query"||e==="search"?"filter":e}function VC(n){const e=n.trim();if(!e.includes(qC))return{values:{filter:e},isPlainFilter:!0};const t={};for(const i of e.split(mq)){const l=i.trim();if(!l)continue;const o=l.indexOf(qC);if(o===-1)continue;const a=pq(l.slice(0,o)),u=l.slice(o+1).trim();switch(a){case"filter":t.filter=u;break;case"ext":t.ext=u;break;case"recursive":t.recursive=QC(u,!0);break;case"dir":t.dir=u;break;case"scan":t.scan=QC(u,!1);break}}return{values:t,isPlainFilter:!1}}function QC(n,e){const t=n.toLowerCase();return["0","false","no","off"].includes(t)?!1:["1","true","yes","on"].includes(t)?!0:e}function Qc(n){return/[",\n\r]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}function gq(n,e,t,i){var f,d;const l=[],a=[["Exported",new Date().toISOString()],["App Version",(t==null?void 0:t.release)??"unknown"],["Config File",(t==null?void 0:t.config_path)??"none"],["Config Exists",String((t==null?void 0:t.config_exists)??!1)],["Directory",(t==null?void 0:t.active_directory)??""],["Extensions",((f=t==null?void 0:t.extensions)==null?void 0:f.join(" | "))??""],["Filter Text",i??((d=t==null?void 0:t.filters)==null?void 0:d[0])??""],["Recursive",String((t==null?void 0:t.recursive_search)??!0)],["Title",(t==null?void 0:t.title)??""],["Release",(t==null?void 0:t.release)??""]];for(const[m,g]of a)l.push(`${Qc(m)},${Qc(g)}`);l.push("");const u=e.length>0?e:["filename","path","rel_path"];l.push(u.map(Qc).join(","));for(const m of n){const g=u.map(b=>b in m?Qc(String(m[b]??"")):Qc(m.column_values[b]??""));l.push(g.join(","))}return l.join(`\r +`)}const xq=120,XC=800,yq=4e3,$C=20;function bq(){const[n,e]=M.useState("dark"),[t,i]=M.useState(null),[l,o]=M.useState(null),[a,u]=M.useState(""),[f,d]=M.useState(""),[m,g]=M.useState(""),[b,v]=M.useState(!0),[w,S]=M.useState([]),[C,N]=M.useState(0),[j,D]=M.useState(!1),[I,U]=M.useState(!1),[E,T]=M.useState(null),[z,te]=M.useState(!1),[q,G]=M.useState(null),[F,se]=M.useState(0),[me,ne]=M.useState(!1),_=M.useRef(0),Z=M.useRef(null),ie=M.useRef(null),[re,A]=M.useState(""),[Be,ze]=M.useState(null),[B,R]=M.useState(!1),[$,ue]=M.useState(null),[ge,je]=M.useState(!1),[Ne,Pe]=M.useState("en"),[be,_e]=M.useState(!1),[Pt,tn]=M.useState(!1),[gn,zt]=M.useState(!1),[Ct,ot]=M.useState(0),[nn,Pn]=M.useState(!1),[Ht,rn]=M.useState(null),[Se,Ve]=M.useState(null),[We,ft]=M.useState(!1),[ee,fe]=M.useState(!1),[Te,He]=M.useState(null),[de,pe]=M.useState(null),[Ee,nt]=M.useState(!1),at=M.useRef(""),[hn,Kt]=M.useState(!1),[bi,Vt]=M.useState(void 0),[xn,ti]=M.useState(!1),[yn,dl]=M.useState(null),[ps,zu]=M.useState(0),uo=M.useRef(null),gs=M.useRef(null),ye=(H,P="info")=>{H&&(ue({message:H,kind:P}),gs.current&&clearTimeout(gs.current),gs.current=setTimeout(()=>ue(null),P==="error"?1e4:3500))},Qn=()=>{gs.current&&clearTimeout(gs.current),ue(null)},cr=H=>{He(H)},Bt=()=>{var P;ie.current&&(clearTimeout(ie.current),ie.current=null),(P=Z.current)==null||P.abort(),Z.current=new AbortController;const H=++_.current;return ne(!0),U(!1),H},Qt=H=>H===_.current,ni=H=>{Qt(H)&&ne(!1)},ii=M.useRef(null);M.useEffect(()=>{if(!m.trim()){A("");return}const H=window.setTimeout(()=>A(m),xq);return()=>window.clearTimeout(H)},[m]);const At=M.useMemo(()=>re.trim()===""?w:w.filter(H=>e8(H.rel_path,re)),[w,re]),fo=m.trim()&&w.length{const H=ii.current,P=H?At.findIndex(le=>le.path===H):-1;if(P>=0){se(le=>P!==le?P:le);return}se(le=>Math.min(le,Math.max(0,At.length-1)))},[At]);const xs=async(H,P=q)=>{var Re;const le=await Kg({offset:0,limit:M0,sort_by:P==null?void 0:P.column,sort_dir:P==null?void 0:P.direction,signal:(Re=Z.current)==null?void 0:Re.signal});return Qt(H)?(S(le.items),N(le.count),D(!0),!0):!1},bn=async(H,P)=>{var le;return!Qt(H)||(await Ik(P,(le=Z.current)==null?void 0:le.signal),!Qt(H)||!await xs(H))?!1:(ii.current=null,se(0),!0)},ho=async()=>{if(I||w.length>=C)return;const H=_.current;U(!0);try{const P=await Kg({offset:w.length,limit:M0,sort_by:q==null?void 0:q.column,sort_dir:q==null?void 0:q.direction});if(!Qt(H))return;const le=new Set(w.map(Re=>Re.path||Re.filename));S(Re=>[...Re,...P.items.filter(et=>!le.has(et.path||et.filename))]),N(P.count)}catch{ye("Couldn't load more results — scroll to try again.","error")}finally{Qt(H)&&U(!1)}},ml=async()=>{if(ge)return;je(!0),ye("Reloading configuration...");const H=Bt();try{const P=await Gh();i(P);const le=await OM();o(le),e(Qk(le.theme));const Re=le.active_directory||a,et=le.extensions[0]??"",it=le.filters[0]??"";Re&&u(Re),d(et),g(it),v(le.recursive_search),le.reloaded===!1?ye(`Config file not found: ${le.config_path||"(unknown path)"} — kept current configuration.`,"error"):ye("Configuration reloaded."),Re&&await bn(H,{directory:Re,extension:et,filter_text:it,recursive:le.recursive_search})}catch(P){ye(`Failed to reload configuration: ${P.message}`,"error")}finally{je(!1),ni(H)}},ys=async H=>{const P=Bt();o(H),e(Qk(H.theme));const le=H.active_directory||a||(H.directories[0]??""),Re=H.extensions[0]??"",et=H.filters[0]??"";if(le&&u(le),d(Re),g(et),v(H.recursive_search),H.session_trial||ye(H.config_exists?`Loaded config: ${H.config_path}`:"Starter configuration created."),le)try{await bn(P,{directory:le,extension:Re,filter_text:et,recursive:H.recursive_search})}catch(it){ye(`Scan failed after config load: ${it.message}`,"error")}finally{ni(P)}else ni(P)},[xm,Bu]=M.useState(!1),bs=M.useRef(Kh()),ur=H=>{bs.current=H,Bu(H.overlayVisible)},Pa=M.useRef(()=>{}),Pu=async H=>{try{const P=await H.text(),le=await GC(H.name,P);await ys(le),ye(`Session config applied: ${H.name}`)}catch(P){ye(P.message||"Failed to apply dropped configuration","error")}};Pa.current=H=>{Pu(H)};const mo=M.useRef(0),Ha=M.useRef(async()=>{});M.useEffect(()=>{Ha.current=async()=>{const H=await Lk();await ys(H)}}),M.useEffect(()=>{const H=async()=>{let le=[];try{le=(await bM(mo.current)).events}catch{return}for(const Re of le){if(mo.current=Math.max(mo.current,Re.id),Re.config_applied)try{await Ha.current()}catch{}ye(Re.message)}},P=setInterval(()=>void H(),yq);return()=>clearInterval(P)},[]),M.useEffect(()=>{const H=it=>{var vn;return Array.from(((vn=it.dataTransfer)==null?void 0:vn.types)??[]).includes("Files")},P=it=>{ur(Vk(bs.current,"enter",H(it)))},le=it=>{H(it)&&it.preventDefault()},Re=it=>{ur(Vk(bs.current,"leave",H(it)))},et=it=>{var pt;it.preventDefault(),ur(Kh());const vn=Array.from(((pt=it.dataTransfer)==null?void 0:pt.files)??[]),Xe=UM(vn);if(!Xe){vn.length>0&&ye("Not a ProFiles configuration file.","error");return}Pa.current(Xe)};return window.addEventListener("dragenter",P),window.addEventListener("dragover",le),window.addEventListener("dragleave",Re),window.addEventListener("drop",et),()=>{window.removeEventListener("dragenter",P),window.removeEventListener("dragover",le),window.removeEventListener("dragleave",Re),window.removeEventListener("drop",et)}},[]);const Ia=()=>{_e(!0)},Ua=async H=>{const P=Bt();_e(!1),u(H),ye(`Directory selected: ${H}`);let le;try{le=await zk(H),o(le)}catch(it){console.error("select-directory failed:",it)}if(!Qt(P))return;const Re=le!=null&&le.extensions.includes(f)?f:(le==null?void 0:le.extensions[0])??f,et=le!=null&&le.filters.includes(m)?m:(le==null?void 0:le.filters[0])??m;d(Re),g(et);try{await bn(P,{directory:H,extension:Re,filter_text:et,recursive:b})}catch(it){Qt(P)&&ye(`Scan failed: ${it.message}`,"error")}finally{ni(P)}},Hu=async(H,P)=>{if(!Qt(P))return;const le=H.theme==="auto"?"dark":H.theme==="light"?"light":"dark";e(le);try{localStorage.setItem("profiles-theme",le)}catch{}o(H);const Re=H.active_directory||(H.directories.length>0?H.directories[0]:""),et=H.extensions.length>0?H.extensions[0]:"",it=H.filters.length>0?H.filters[0]:"";if(Re&&u(Re),et&&d(et),H.recursive_search!==void 0&&v(H.recursive_search),it&&g(it),H.config_exists||tn(!0),Re)try{await bn(P,{directory:Re,extension:et,filter_text:it,recursive:H.recursive_search})}catch(vn){Qt(P)&&ye(`Initial scan failed: ${vn.message}`,"error")}},Fa=async()=>{var P;(P=Z.current)==null||P.abort(),Z.current=new AbortController;const H=++_.current;T(null),te(!0);try{const le=await Gh();i(le);const Re=await Lk();await Hu(Re,H)}catch(le){T((le==null?void 0:le.message)||"Couldn't fetch system info or configuration.")}finally{te(!1)}};M.useEffect(()=>{Fa()},[]),M.useEffect(()=>()=>{var H;ie.current&&(clearTimeout(ie.current),ie.current=null),(H=Z.current)==null||H.abort()},[]);const ri=async H=>{const P=Bt();u(H);try{const le=await zk(H);if(!Qt(P))return;o(le);const Re=le.extensions.includes(f)?f:le.extensions[0]??"",et=le.filters.includes(m)?m:le.filters[0]??"";d(Re),g(et),await bn(P,{directory:H,extension:Re,filter_text:et,recursive:b})}catch(le){Qt(P)&&ye(`Directory change failed: ${le.message}`,"error")}finally{ni(P)}},It=async()=>{if(!a)return;const H=Bt();try{await bn(H,{directory:a,extension:f,filter_text:m,recursive:b})}catch(P){Qt(H)&&ye(`Scan failed: ${(P==null?void 0:P.message)??P}`,"error")}finally{ni(H)}},Wt=M.useRef(It);M.useEffect(()=>{Wt.current=It});const pl=H=>{g(H),ie.current&&clearTimeout(ie.current),ie.current=setTimeout(()=>{ie.current=null,Wt.current()},XC)},Iu=H=>{v(H),ie.current&&clearTimeout(ie.current),ie.current=setTimeout(()=>{ie.current=null,Wt.current()},XC)},ym=async()=>{if(g(""),!a)return;const H=Bt();try{await bn(H,{directory:a,extension:f,filter_text:"",recursive:b})}catch(P){Qt(H)&&ye(`Scan failed: ${(P==null?void 0:P.message)??P}`,"error")}finally{ni(H)}},bm=async()=>{if(v(!1),!a)return;const H=Bt();try{await bn(H,{directory:a,extension:f,filter_text:m,recursive:!1})}catch(P){Qt(H)&&ye(`Scan failed: ${P.message}`,"error")}finally{ni(H)}},Ir=async(H,P)=>{if(H.has_hook){pe({file:H,args:P});return}try{await MM({directory:a,filename:H.rel_path,release:l==null?void 0:l.release,args:P}),ye(`Launched ${H.filename}`)}catch(le){ye(`Launch error: ${le.message}`,"error")}},gl=()=>{At.length>0&&At[F]&&Ir(At[F])},po=H=>{var P;ii.current=((P=At[H])==null?void 0:P.path)??null,se(H)},go=async(H,P)=>{Ir(H,P)},Ur=async H=>{try{await WC(H.path),ye("Revealed in file manager.")}catch(P){ye(`Error: ${P.message}`,"error")}},xl=async H=>{try{await Y0(H.path),ye("Folder opened in file manager.")}catch(P){ye(`Error: ${P.message}`,"error")}},vs=async H=>{try{const P=await Uk(H.path);ye(P.message||"Terminal opened.")}catch(P){ye(`Error: ${P.message}`,"error")}},yl=async H=>{try{await ri(H),ye(`Scanned directory: ${H}`)}catch(P){ye(`Error: ${P.message}`,"error")}},ln=H=>{g(H);const P=Bt();bn(P,{directory:a,extension:f,filter_text:H,recursive:b}).catch(le=>{Qt(P)&&ye(`Scan failed: ${(le==null?void 0:le.message)??le}`,"error")}).finally(()=>ni(P))},Uu=H=>{d(H);const P=Bt();bn(P,{directory:a,extension:H,filter_text:m,recursive:b}).catch(le=>{Qt(P)&&ye(`Scan failed: ${(le==null?void 0:le.message)??le}`,"error")}).finally(()=>ni(P))},Fu=async(H,P)=>{const le=P?H.path.replace(/\\/g,"/"):H.path;try{await navigator.clipboard.writeText(le),ye("Path copied to clipboard.")}catch(Re){ye(`Copy failed: ${(Re==null?void 0:Re.message)??Re}`,"error")}},qu=async(H,P)=>{let le=H.filename;if(P){const Re=le.lastIndexOf(".");Re!==-1&&(le=le.slice(0,Re))}try{await navigator.clipboard.writeText(le),ye("Filename copied to clipboard.")}catch(Re){ye(`Copy failed: ${(Re==null?void 0:Re.message)??Re}`,"error")}},Fr=async(H,P)=>{try{ye(`Computing ${P.toUpperCase()}...`);const le=await Fk(H.path,P);await navigator.clipboard.writeText(le.hash),ye(`${P.toUpperCase()} hash copied: ${le.hash.slice(0,12)}...`)}catch(le){ye(`Hash computation failed: ${le.message}`,"error")}},bl=async H=>{try{const P=new URL("file:///").href+H.path.replace(/\\/g,"/");await navigator.clipboard.writeText(P),ye("File URI copied to clipboard.")}catch(P){ye(`URI copy failed: ${P.message}`,"error")}},vm=async(H,P)=>{try{const le=await navigator.clipboard.readText();if(!le.trim()){ye("Clipboard is empty — copy a hash first, then try again.");return}ye(`Computing ${P.toUpperCase()}...`);const et=(await Fk(H.path,P)).hash.toLowerCase()===le.trim().toLowerCase();ye(et?`✅ ${P.toUpperCase()} matches!`:`❌ ${P.toUpperCase()} mismatch`)}catch(le){ye(`Verification failed: ${le.message}`,"error")}},qa=H=>{Ve(H),Pn(!0)},Vu=H=>{rn(H)},wm=async()=>{const H=Ht;if(rn(null),!!H)try{if(ye("Deleting file..."),!(await fetch("/api/actions/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:H.path})})).ok)throw new Error("Failed to delete file");ye("File deleted successfully."),It()}catch(P){ye(`Delete failed: ${P.message}`,"error")}},ht=H=>{Vt(H.path),Kt(!0)},Va=async()=>{if(a)try{await Y0(a),ye("Directory opened in file manager.")}catch(H){ye(`Error: ${H.message}`,"error")}},xo=async H=>{if(H)try{await Uk(H),ye("Terminal opened in directory.")}catch(P){ye(`Error: ${P.message}`,"error")}},ws=async()=>{try{await ri("~"),ye("Directory set to home folder.")}catch(H){ye(`Error: ${H.message}`,"error")}},$i=async()=>{if(a)try{const H=await KC(a);H.parent_path?(await ri(H.parent_path),ye("Moved to parent directory.")):ye("Already at root directory.")}catch(H){ye(`Error: ${H.message}`,"error")}},Xn=async()=>{if(w.length===0){ye("No files to export.");return}try{const H=gq(w,(l==null?void 0:l.column_names)||[],l??void 0,m),P=`profiles-export-${new Date().toISOString().slice(0,19).replace(/[:.]/g,"-")}.csv`,le=await _M(H,P);ye(`Exported ${w.length} loaded row${w.length===1?"":"s"}${m?` matching "${m}"`:""} — ${le.message}`)}catch(H){ye(`Export failed: ${H.message}`,"error")}},Qu=async H=>{var Xe,pt;ti(!1),ye("Barcode detected!");const le=VC(H).values,Re=le.dir!==void 0?le.dir:a,et=le.ext!==void 0?le.ext:f,it=le.filter!==void 0?le.filter:m,vn=le.recursive!==void 0?le.recursive:b;if(le.dir!==void 0&&u(le.dir),le.ext!==void 0&&d(le.ext),le.filter!==void 0&&g(le.filter),le.recursive!==void 0&&v(le.recursive),Re){const vt=Bt();try{await Ik({directory:Re,extension:et,filter_text:it,recursive:vn},(Xe=Z.current)==null?void 0:Xe.signal);const fr=await Kg({offset:0,limit:M0,sort_by:q==null?void 0:q.column,sort_dir:q==null?void 0:q.direction,signal:(pt=Z.current)==null?void 0:pt.signal});if(!Qt(vt))return;S(fr.items),N(fr.count),D(!0),ii.current=null,se(0),fr.count===1&&fr.items.length===1&&dl(fr.items[0])}catch(fr){Qt(vt)&&ye(`Scan error: ${fr.message}`,"error")}finally{ni(vt)}}},km=()=>{nt(H=>{const P=!H;return P?(at.current="",ye("Barcode mode ON — scan a barcode now.")):(at.current="",ye("Barcode mode OFF.")),P})},Qa=H=>{H.filter!==void 0&&g(H.filter),H.ext!==void 0&&d(H.ext),H.recursive!==void 0&&v(H.recursive),H.dir!==void 0&&u(H.dir),(H.scan===!0||H.filter!==void 0||H.ext!==void 0||H.recursive!==void 0||H.dir!==void 0)&&(nt(!1),at.current="",setTimeout(()=>{Wt.current()},50))};M.useEffect(()=>{if(!Ee)return;const H=P=>{const le=P.target;if(!(le instanceof HTMLElement&&(le.isContentEditable||le instanceof HTMLInputElement||le instanceof HTMLTextAreaElement||le instanceof HTMLSelectElement)))if(P.key==="Enter"){const et=at.current;if(!et){at.current="";return}P.preventDefault(),at.current="";const it=VC(et);if(it.isPlainFilter)ye(`Barcode filter: ${it.values.filter}`),g(it.values.filter||""),nt(!1),setTimeout(()=>void Wt.current(),50);else{const vn=it.values,Xe=Object.entries(vn).map(([pt,vt])=>`${pt}=${vt}`).join(", ");ye(`Barcode applied: ${Xe}`),Qa(vn)}}else P.key==="Escape"?(nt(!1),at.current="",ye("Barcode mode cancelled.")):P.key.length===1&&!P.ctrlKey&&!P.metaKey&&!P.altKey&&(at.current+=P.key)};return document.addEventListener("keydown",H,!0),()=>document.removeEventListener("keydown",H,!0)},[Ee]),M.useEffect(()=>(ps>0&&(uo.current=setInterval(()=>{Wt.current()},ps*1e3)),()=>{uo.current&&(clearInterval(uo.current),uo.current=null)}),[ps]);const Xu=H=>{zu(H),H>0?ye(`Auto-rescan every ${H}s.`):ye("Auto-rescan disabled.")},$u=!!(Be||B||be||Pt||nn||We||ee||hn||xn||yn||de||Ht);return M.useEffect(()=>{const H=P=>{var Re,et,it,vn;if(P.key==="Escape"){ze(null),R(!1),ft(!1),fe(!1),ur(Kh());return}if($u)return;if(P.ctrlKey&&!P.shiftKey&&P.key.toLowerCase()==="l"){P.preventDefault(),(Re=document.querySelector("[data-testid='file-list']"))==null||Re.focus();return}const le=P.target;if(!(le instanceof HTMLElement&&le.closest("button, a, [role='menuitem'], [role='option'], [role='columnheader'], [role='separator']"))){if(le instanceof HTMLInputElement||le instanceof HTMLSelectElement){P.key==="Enter"&&It();return}if(P.key==="ContextMenu"||P.shiftKey&&P.key==="F10"){const Xe=At[F];if(!Xe)return;P.preventDefault();const pt=document.querySelector(`[data-row-index="${F}"]`),vt=pt==null?void 0:pt.getBoundingClientRect();ze({x:vt?vt.left+24:24,y:vt?vt.top+vt.height/2:24,file:Xe});return}if(P.key==="F5"){P.preventDefault(),It();return}if(P.ctrlKey&&P.key.toLowerCase()==="r"){P.preventDefault(),ml();return}if(P.ctrlKey&&P.key.toLowerCase()==="d"){P.preventDefault(),(et=document.querySelector("#directory-combobox"))==null||et.focus();return}if(P.ctrlKey&&P.key.toLowerCase()==="e"){P.preventDefault(),(it=document.querySelector("#extension-combobox"))==null||it.focus();return}if(P.ctrlKey&&P.key.toLowerCase()==="f"){P.preventDefault(),(vn=document.querySelector("#filter-combobox"))==null||vn.focus();return}if(P.ctrlKey&&P.shiftKey&&P.key.toLowerCase()==="l"){P.preventDefault(),ft(Xe=>!Xe);return}if(P.ctrlKey&&P.key===","){P.preventDefault(),zt(!0);return}if(P.ctrlKey&&P.shiftKey&&P.key.toLowerCase()==="t"){P.preventDefault(),e(Xe=>Xe==="dark"?"light":"dark");return}if(P.ctrlKey&&!P.shiftKey&&P.key.toLowerCase()==="b"){P.preventDefault(),nt(Xe=>!Xe);return}if(P.ctrlKey&&P.shiftKey&&P.key.toLowerCase()==="b"){P.preventDefault(),ti(Xe=>!Xe);return}if(P.ctrlKey&&!P.shiftKey&&P.key.toLowerCase()==="t"){P.preventDefault(),fe(!0);return}if(P.ctrlKey&&!P.shiftKey&&P.key.toLowerCase()==="h"){P.preventDefault(),ws();return}if(P.key==="?"||P.ctrlKey&&P.key==="/"){P.preventDefault(),R(Xe=>!Xe);return}if(P.key.toLowerCase()==="p"&&!P.ctrlKey&&!P.shiftKey&&!P.altKey){const Xe=At[F];Xe&&(P.preventDefault(),qa(Xe));return}P.key==="ArrowDown"?(P.preventDefault(),se(Xe=>{var vt;const pt=Math.min(Xe+1,Math.max(0,At.length-1));return ii.current=((vt=At[pt])==null?void 0:vt.path)??null,pt})):P.key==="ArrowUp"?(P.preventDefault(),se(Xe=>{var vt;const pt=Math.max(Xe-1,0);return ii.current=((vt=At[pt])==null?void 0:vt.path)??null,pt})):P.key==="Home"?(P.preventDefault(),se(Xe=>{var pt;return ii.current=((pt=At[0])==null?void 0:pt.path)??null,Xe===0?Xe:0})):P.key==="End"?(P.preventDefault(),se(Xe=>{var vt;const pt=Math.max(0,At.length-1);return ii.current=((vt=At[pt])==null?void 0:vt.path)??null,Xe===pt?Xe:pt})):P.key==="PageUp"?(P.preventDefault(),se(Xe=>{var vt;const pt=Math.max(Xe-$C,0);return ii.current=((vt=At[pt])==null?void 0:vt.path)??null,pt})):P.key==="PageDown"?(P.preventDefault(),se(Xe=>{var vt;const pt=Math.min(Xe+$C,Math.max(0,At.length-1));return ii.current=((vt=At[pt])==null?void 0:vt.path)??null,pt})):P.key==="Enter"&&(P.preventDefault(),gl())}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[$u,At,F,a,f,m,b,Ee]),M.useEffect(()=>{document.documentElement.setAttribute("data-theme",n);try{localStorage.setItem("profiles-theme",n)}catch{}},[n]),y.jsxs("div",{className:"flex h-dvh flex-col bg-elevated/30 p-1 font-sans text-ink transition-colors duration-200 sm:p-1.5",children:[y.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-frame-line bg-app shadow-[0_2px_6px_rgb(0_0_0/0.35)] transition-colors duration-200 sm:rounded-xl",children:[y.jsx($9,{title:(l==null?void 0:l.title)||"",release:(l==null?void 0:l.release)||"",directories:(l==null?void 0:l.directories)||[],activeDirectory:a,onDirectoryChange:ri,onBrowseDirectory:Ia,onGoToParentDirectory:$i,onGoToHomeDirectory:ws,onOpenActiveDirectory:Va,onOpenTerminal:xo}),y.jsx(n8,{extensions:(l==null?void 0:l.extensions)||[],activeExtension:f,onExtensionChange:d,filterOptions:(l==null?void 0:l.filters)||[],filterText:m,onFilterTextChange:pl,recursive:b,onRecursiveChange:Iu,onScan:It,scanning:me,barcodeMode:Ee,onBarcodeToggle:km,onCameraBarcodeClick:()=>ti(!0),autoRescanActive:ps>0,onTimerClick:()=>fe(!0)}),E?y.jsx(Y9,{message:E,onRetry:()=>void Fa(),retrying:z}):y.jsx(X9,{files:At,totalCount:C,rawLoadedCount:w.length,onLoadMore:ho,loadingMore:I,scanning:me,hasScanned:j,activeDirectory:a,recursive:b,onDisableRecursive:bm,onOpenDirectory:Va,onLoadConfig:()=>tn(!0),filterText:m,onClearFilter:ym,columnHeaders:(l==null?void 0:l.column_headers)||[],columnNames:(l==null?void 0:l.column_names)||[],selectedIndex:F,onSelectIndex:po,prefilterNote:fo,onLaunch:Ir,onContextMenu:(H,P,le)=>{H.preventDefault(),ii.current=P.path,se(le),ze({x:H.clientX,y:H.clientY,file:P})},rowColors:(l==null?void 0:l.row_colors)||[],sort:q,onSortChange:H=>{G(H),ii.current=null,se(0);const P=Bt();xs(P,H).catch(le=>{Qt(P)&&ye(`Sort failed: ${le.message}`,"error")}).finally(()=>ni(P))}}),y.jsx(_D,{onExecute:gl,scanning:me,scanningDirectory:a,hasSelection:At.length>0,fileCount:At.length,totalCount:C,toastMessage:$,onToastDismiss:Qn}),y.jsx(S8,{systemInfo:t,fileCount:C,theme:n,onToggleTheme:()=>e(H=>H==="dark"?"light":"dark"),onOpenLog:()=>ft(!0),onOpenConfig:()=>zt(!0),onShowShortcuts:()=>R(!0),onReloadConfig:ml,onExport:Xn,exportDisabled:w.length===0||me,language:Ne,onLanguageChange:Pe,lanEnabled:(t==null?void 0:t.lan_enabled)??null,onToggleLan:cr})]}),y.jsx(U9,{open:gn,onClose:()=>zt(!1),onApplied:ys,onLoadConfig:()=>tn(!0),reloadKey:Ct}),y.jsx(a8,{isOpen:Pt,activeConfigPath:l==null?void 0:l.config_path,configExists:l==null?void 0:l.config_exists,onClose:()=>tn(!1),onLoaded:H=>{ys(H),ot(P=>P+1)}}),y.jsx(V9,{visible:xm,onFileSelected:H=>Pa.current(H)}),y.jsx(q9,{isOpen:be,initialPath:a,onClose:()=>_e(!1),onSelect:Ua}),y.jsx(F9,{position:Be,onClose:()=>ze(null),onLaunch:Ir,onLaunchWithArgs:go,onReveal:Ur,onOpenFolder:xl,onOpenTerminal:vs,onScanDirectory:yl,onFilterFolder:ln,onFilterExtension:Uu,onCopyPath:Fu,onCopyFilename:qu,onCopyUri:bl,onComputeHash:Fr,onVerifyHash:vm,onProperties:qa,onClearFile:Vu,onGenerateBarcode:ht,showToast:ye}),y.jsx(o8,{isOpen:B,onClose:()=>R(!1)}),y.jsx(d8,{isOpen:nn,file:Se,onLaunch:Ir,onClose:()=>{Pn(!1),Ve(null)}}),y.jsx(O8,{isOpen:ee,currentInterval:ps,onClose:()=>fe(!1),onSetInterval:Xu}),y.jsx(s8,{isOpen:We,onClose:()=>ft(!1),onOpenExternally:()=>{vM().then(H=>ye(H.message))}}),y.jsx(dq,{isOpen:!!de,onClose:()=>pe(null),directory:a,filename:(de==null?void 0:de.file.rel_path)||"",release:l==null?void 0:l.release,args:de==null?void 0:de.args,onFinished:(H,P)=>{H==="completed"?ye(P||"Workflow launched successfully."):(H==="aborted"||H==="failed")&&ye(`Workflow stopped: ${P}`,"error")}}),y.jsx(xA,{isOpen:hn,onClose:()=>{Kt(!1),Vt(void 0)},initialFilePath:bi}),y.jsx(w8,{isOpen:xn,onClose:()=>ti(!1),onDetected:Qu}),y.jsx(Js,{isOpen:!!Ht,title:"Delete file",message:`Delete this file? + +${(Ht==null?void 0:Ht.path)??""} + +This action cannot be undone.`,confirmLabel:"Delete",danger:!0,onConfirm:wm,onCancel:()=>rn(null)}),y.jsx(Js,{isOpen:Te!==null,title:Te?"Enable LAN access?":"Restrict to this machine?",message:Te?y.jsxs("span",{className:"block",children:["ProFiles will be reachable by anyone on this network:",y.jsx(FC,{url:`http://${t==null?void 0:t.hostname}:${window.location.port}`,label:"Copy hostname URL",className:"mt-1.5",onCopied:()=>ye("URL copied to clipboard."),onCopyError:()=>ye("Failed to copy URL.","error")}),y.jsx(FC,{url:`http://${t==null?void 0:t.ip}:${window.location.port}`,label:"Copy IP URL",className:"mt-1.5",onCopied:()=>ye("URL copied to clipboard."),onCopyError:()=>ye("Failed to copy URL.","error")})]}):"ProFiles will be reachable only on this machine.",confirmLabel:Te?"Enable LAN":"Restrict",onConfirm:async()=>{const H=Te;He(null);try{await kM(H),ye(H?"Updating LAN binding…":"Restricting ProFiles to this machine…","info");const P=await SM(H);P&&i(P),(P==null?void 0:P.lan_enabled)===H?ye(H?"ProFiles is now reachable on the local network.":"ProFiles is restricted to this machine.","info"):ye("Failed to update LAN binding — the previous address is still active.","error")}catch(P){const le=P instanceof Error?P.message:"Failed to update LAN binding";ye(`Failed to update LAN binding: ${le}`,"error");const Re=await Gh();i(Re)}},onCancel:()=>He(null)}),y.jsx(k8,{isOpen:!!yn,file:yn,onConfirm:()=>{if(yn){const H=yn;dl(null),Ir(H)}},onDismiss:()=>dl(null)})]})}class vq extends M.Component{constructor(){super(...arguments);dh(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,i){console.error("Application render error:",t,i.componentStack)}render(){return this.state.error?y.jsx("main",{className:"flex min-h-screen items-center justify-center bg-app p-6 text-ink",children:y.jsxs("section",{className:"w-full max-w-lg rounded-lg border border-line bg-surface p-6",children:[y.jsx("h1",{className:"text-base font-semibold",children:"ProFiles encountered an error"}),y.jsx("p",{className:"mt-2 text-sm text-ink-secondary",children:"The interface could not continue. Reload the application to try again."}),y.jsxs("details",{className:"mt-4 text-xs text-ink-muted",children:[y.jsx("summary",{className:"cursor-pointer",children:"Error details"}),y.jsx("pre",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap",children:this.state.error.message})]}),y.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"btn btn-primary mt-5 px-4 py-2 text-sm font-semibold",children:"Reload application"})]})}):this.props.children}}yM.createRoot(document.getElementById("root")).render(y.jsx(fM.StrictMode,{children:y.jsx(vq,{children:y.jsx(bq,{})})})); diff --git a/src/profiles/web/dist/assets/index-Di9rzBmt.js b/src/profiles/web/dist/assets/index-Di9rzBmt.js deleted file mode 100644 index 58f3fde..0000000 --- a/src/profiles/web/dist/assets/index-Di9rzBmt.js +++ /dev/null @@ -1,445 +0,0 @@ -var lM=Object.defineProperty;var sM=(n,e,t)=>e in n?lM(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var dh=(n,e,t)=>sM(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const o of l)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(l){const o={};return l.integrity&&(o.integrity=l.integrity),l.referrerPolicy&&(o.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?o.credentials="include":l.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(l){if(l.ep)return;l.ep=!0;const o=t(l);fetch(l.href,o)}})();function my(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Vg={exports:{}},_c={};/** - * @license React - * react-jsx-runtime.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Ck;function oM(){if(Ck)return _c;Ck=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(i,l,o){var a=null;if(o!==void 0&&(a=""+o),l.key!==void 0&&(a=""+l.key),"key"in l){o={};for(var u in l)u!=="key"&&(o[u]=l[u])}else o=l;return l=o.ref,{$$typeof:n,type:i,key:a,ref:l!==void 0?l:null,props:o}}return _c.Fragment=e,_c.jsx=t,_c.jsxs=t,_c}var Ok;function aM(){return Ok||(Ok=1,Vg.exports=oM()),Vg.exports}var y=aM(),Qg={exports:{}},Ue={};/** - * @license React - * react.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Nk;function cM(){if(Nk)return Ue;Nk=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),b=Symbol.for("react.view_transition"),v=Symbol.iterator;function w(j){return j===null||typeof j!="object"?null:(j=v&&j[v]||j["@@iterator"],typeof j=="function"?j:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,N={};function R(j,$,fe){this.props=j,this.context=$,this.refs=N,this.updater=fe||S}R.prototype.isReactComponent={},R.prototype.setState=function(j,$){if(typeof j!="object"&&typeof j!="function"&&j!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,j,$,"setState")},R.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function M(){}M.prototype=R.prototype;function I(j,$,fe){this.props=j,this.context=$,this.refs=N,this.updater=fe||S}var U=I.prototype=new M;U.constructor=I,C(U,R.prototype),U.isPureReactComponent=!0;var E=Array.isArray;function T(){}var z={H:null,A:null,T:null,S:null},ie=Object.prototype.hasOwnProperty;function q(j,$,fe){var pe=fe.ref;return{$$typeof:n,type:j,key:$,ref:pe!==void 0?pe:null,props:fe}}function J(j,$){return q(j.type,$,j.props)}function F(j){return typeof j=="object"&&j!==null&&j.$$typeof===n}function se(j){var $={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(fe){return $[fe]})}var he=/\/+/g;function ne(j,$){return typeof j=="object"&&j!==null&&j.key!=null?se(""+j.key):$.toString(36)}function L(j){switch(j.status){case"fulfilled":return j.value;case"rejected":throw j.reason;default:switch(typeof j.status=="string"?j.then(T,T):(j.status="pending",j.then(function($){j.status==="pending"&&(j.status="fulfilled",j.value=$)},function($){j.status==="pending"&&(j.status="rejected",j.reason=$)})),j.status){case"fulfilled":return j.value;case"rejected":throw j.reason}}throw j}function ee(j,$,fe,pe,Ne){var Te=typeof j;(Te==="undefined"||Te==="boolean")&&(j=null);var ze=!1;if(j===null)ze=!0;else switch(Te){case"bigint":case"string":case"number":ze=!0;break;case"object":switch(j.$$typeof){case n:case e:ze=!0;break;case m:return ze=j._init,ee(ze(j._payload),$,fe,pe,Ne)}}if(ze)return Ne=Ne(j),ze=pe===""?"."+ne(j,0):pe,E(Ne)?(fe="",ze!=null&&(fe=ze.replace(he,"$&/")+"/"),ee(Ne,$,fe,"",function(It){return It})):Ne!=null&&(F(Ne)&&(Ne=J(Ne,fe+(Ne.key==null||j&&j.key===Ne.key?"":(""+Ne.key).replace(he,"$&/")+"/")+ze)),$.push(Ne)),1;ze=0;var ve=pe===""?".":pe+":";if(E(j))for(var je=0;je>>1,A=L[le];if(0>>1;lel(B,oe))jl($,B)?(L[le]=$,L[j]=oe,le=j):(L[le]=B,L[_e]=oe,le=_e);else if(jl($,oe))L[le]=$,L[j]=oe,le=j;else break e}}return ee}function l(L,ee){var oe=L.sortIndex-ee.sortIndex;return oe!==0?oe:L.id-ee.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;n.unstable_now=function(){return o.now()}}else{var a=Date,u=a.now();n.unstable_now=function(){return a.now()-u}}var f=[],d=[],m=1,g=null,b=3,v=!1,w=!1,S=!1,C=!1,N=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function I(L){for(var ee=t(d);ee!==null;){if(ee.callback===null)i(d);else if(ee.startTime<=L)i(d),ee.sortIndex=ee.expirationTime,e(f,ee);else break;ee=t(d)}}function U(L){if(S=!1,I(L),!w)if(t(f)!==null)w=!0,E||(E=!0,F());else{var ee=t(d);ee!==null&&ne(U,ee.startTime-L)}}var E=!1,T=-1,z=5,ie=-1;function q(){return C?!0:!(n.unstable_now()-ieL&&q());){var le=g.callback;if(typeof le=="function"){g.callback=null,b=g.priorityLevel;var A=le(g.expirationTime<=L);if(L=n.unstable_now(),typeof A=="function"){g.callback=A,I(L),ee=!0;break t}g===t(f)&&i(f),I(L)}else i(f);g=t(f)}if(g!==null)ee=!0;else{var Le=t(d);Le!==null&&ne(U,Le.startTime-L),ee=!1}}break e}finally{g=null,b=oe,v=!1}ee=void 0}}finally{ee?F():E=!1}}}var F;if(typeof M=="function")F=function(){M(J)};else if(typeof MessageChannel<"u"){var se=new MessageChannel,he=se.port2;se.port1.onmessage=J,F=function(){he.postMessage(null)}}else F=function(){N(J,0)};function ne(L,ee){T=N(function(){L(n.unstable_now())},ee)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(L){L.callback=null},n.unstable_forceFrameRate=function(L){0>L||125le?(L.sortIndex=oe,e(d,L),t(f)===null&&L===t(d)&&(S?(R(T),T=-1):S=!0,ne(U,oe-le))):(L.sortIndex=A,e(f,L),w||v||(w=!0,E||(E=!0,F()))),L},n.unstable_shouldYield=q,n.unstable_wrapCallback=function(L){var ee=b;return function(){var oe=b;b=ee;try{return L.apply(this,arguments)}finally{b=oe}}}})(Yg)),Yg}var Ek;function hM(){return Ek||(Ek=1,$g.exports=fM()),$g.exports}var Gg={exports:{}},Mn={};/** - * @license React - * react-dom.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Mk;function dM(){if(Mk)return Mn;Mk=1;var n=py();function e(m){var g="https://react.dev/errors/"+m;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),Gg.exports=dM(),Gg.exports}/** - * @license React - * react-dom-client.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var jk;function mM(){if(jk)return Lc;jk=1;var n=hM(),e=py(),t=XC();function i(r){var s="https://react.dev/errors/"+r;if(1un||(r.current=Gt[un],Gt[un]=null,un--)}function rt(r,s){un++,Gt[un]=r.current,r.current=s}var Ut=_t(null),zn=_t(null),Ft=_t(null),en=_t(null);function ke(r,s){switch(rt(Ft,s),rt(zn,r),rt(Ut,null),s.nodeType){case 9:case 11:r=(r=s.documentElement)&&(r=r.namespaceURI)?Rw(r):0;break;default:if(r=s.tagName,s=s.namespaceURI)s=Rw(s),r=_w(s,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}yt(Ut),rt(Ut,r)}function qe(){yt(Ut),yt(zn),yt(Ft)}function Ie(r){var s=r.memoizedState;s!==null&&(Wo._currentValue=s.memoizedState,rt(en,r)),s=Ut.current;var c=_w(s,r.type);s!==c&&(rt(zn,r),rt(Ut,c))}function at(r){zn.current===r&&(yt(Ut),yt(zn)),en.current===r&&(yt(en),Wo._currentValue=It)}var V,K;function de(r){if(V===void 0)try{throw Error()}catch(c){var s=c.stack.trim().match(/\n( *(at )?)/);V=s&&s[1]||"",K=-1)":-1p||_[h]!==G[p]){var te=` -`+_[h].replace(" at new "," at ");return r.displayName&&te.includes("")&&(te=te.replace("",r.displayName)),te}while(1<=h&&0<=p);break}}}finally{Se=!1,Error.prepareStackTrace=c}return(c=r?r.displayName||r.name:"")?de(c):""}function ot(r,s){switch(r.tag){case 26:case 27:case 5:return de(r.type);case 16:return de("Lazy");case 13:return r.child!==s&&s!==null?de("Suspense Fallback"):de("Suspense");case 19:return de("SuspenseList");case 0:case 15:return We(r.type,!1);case 11:return We(r.type.render,!1);case 1:return We(r.type,!0);case 31:return de("Activity");case 30:return de("ViewTransition");default:return""}}function gt(r){try{var s="",c=null;do s+=ot(r,c),c=r,r=r.return;while(r);return s}catch(h){return` -Error generating stack: `+h.message+` -`+h.stack}}var qt=Object.prototype.hasOwnProperty,mn=n.unstable_scheduleCallback,Mi=n.unstable_cancelCallback,or=n.unstable_shouldYield,ao=n.unstable_requestPaint,tn=n.unstable_now,pn=n.unstable_getCurrentPriorityLevel,Jn=n.unstable_ImmediatePriority,gn=n.unstable_UserBlockingPriority,hl=n.unstable_NormalPriority,ms=n.unstable_LowPriority,zu=n.unstable_IdlePriority,co=n.log,ps=n.unstable_setDisableYieldValue,xe=null,qn=null;function ar(r){if(typeof co=="function"&&ps(r),qn&&typeof qn.setStrictMode=="function")try{qn.setStrictMode(xe,r)}catch{}}var Lt=Math.clz32?Math.clz32:ti,Vt=Math.log,ei=Math.LN2;function ti(r){return r>>>=0,r===0?32:31-(Vt(r)/ei|0)|0}var Nt=256,uo=262144,gs=4194304;function xn(r){var s=r&42;if(s!==0)return s;switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return r&-r;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function fo(r,s,c){var h=r.pendingLanes;if(h===0)return 0;var p=0,x=r.suspendedLanes,k=r.pingedLanes;r=r.warmLanes;var O=h&134217727;return O!==0?(h=O&~x,h!==0?p=xn(h):(k&=O,k!==0?p=xn(k):c||(c=O&~r,c!==0&&(p=xn(c))))):(O=h&~x,O!==0?p=xn(O):k!==0?p=xn(k):c||(c=h&~r,c!==0&&(p=xn(c)))),p===0?0:s!==0&&s!==p&&(s&x)===0&&(x=p&-p,c=s&-s,x>=c||x===32&&(c&4194048)!==0)?s:p}function dl(r,s){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&s)===0}function xs(r,s){(s&8)!==0&&(s|=s&32);var c=r.entangledLanes;if(c!==0)for(r=r.entanglements,c&=s;0c;c++)s.push(r);return s}function cr(r,s){r.pendingLanes|=s,s!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function Pa(r,s,c,h,p,x){var k=r.pendingLanes;r.pendingLanes=c,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=c,r.entangledLanes&=c,r.errorRecoveryDisabledLanes&=c,r.shellSuspendCounter=0;var O=r.entanglements,_=r.expirationTimes,G=r.hiddenUpdates;for(c=k&~c;0"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Tm=!1;if(Fr)try{var $a={};Object.defineProperty($a,"passive",{get:function(){Tm=!0}}),window.addEventListener("test",$a,$a),window.removeEventListener("test",$a,$a)}catch{Tm=!1}var bl=null,Am=null,Gu=null;function Eb(){if(Gu)return Gu;var r,s=Am,c=s.length,h,p="value"in bl?bl.value:bl.textContent,x=p.length;for(r=0;r=Ka),Lb=" ",zb=!1;function Bb(r,s){switch(r){case"keyup":return n5.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Pb(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var bo=!1;function r5(r,s){switch(r){case"compositionend":return Pb(s);case"keypress":return s.which!==32?null:(zb=!0,Lb);case"textInput":return r=s.data,r===Lb&&zb?null:r;default:return null}}function l5(r,s){if(bo)return r==="compositionend"||!Rm&&Bb(r,s)?(r=Eb(),Gu=Am=bl=null,bo=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function Xb(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function $b(r,s){var c=Xb(r);r=0;for(var h;c;){if(c.nodeType===3){if(h=r+c.textContent.length,r<=s&&h>=s)return{node:c,offset:s-r};r=h}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=Xb(c)}}function Yb(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?Yb(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function Gb(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var s=zm(r.document);s instanceof r.HTMLIFrameElement;){try{var c=typeof s.contentWindow.location.href=="string"}catch{c=!1}if(c)r=s.contentWindow;else break;s=zm(r.document)}return s}function Bm(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}var d5=Fr&&"documentMode"in document&&11>=document.documentMode,vo=null,Pm=null,ec=null,Hm=!1;function Kb(r,s,c){var h=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;Hm||vo==null||vo!==zm(h)||(h=vo,"selectionStart"in h&&Bm(h)?h={start:h.selectionStart,end:h.selectionEnd}:(h=(h.ownerDocument&&h.ownerDocument.defaultView||window).getSelection(),h={anchorNode:h.anchorNode,anchorOffset:h.anchorOffset,focusNode:h.focusNode,focusOffset:h.focusOffset}),ec&&Ja(ec,h)||(ec=h,h=th(Pm,"onSelect"),0>=k,p-=k,hr=1<<32-Lt(s)+p|c<Pe?(on=Re,Re=null):on=Re.sibling;var ut=X(Y,Re,W[Pe],ce);if(ut===null){Re===null&&(Re=on);break}r&&Re&&ut.alternate===null&&s(Y,Re),Q=x(ut,Q,Pe),st===null?Ae=ut:st.sibling=ut,st=ut,Re=on}if(Pe===W.length)return c(Y,Re),Ge&&Xr(Y,Pe),Ae;if(Re===null){for(;PePe?(on=Re,Re=null):on=Re.sibling;var Vl=X(Y,Re,ut.value,ce);if(Vl===null){Re===null&&(Re=on);break}r&&Re&&Vl.alternate===null&&s(Y,Re),Q=x(Vl,Q,Pe),st===null?Ae=Vl:st.sibling=Vl,st=Vl,Re=on}if(ut.done)return c(Y,Re),Ge&&Xr(Y,Pe),Ae;if(Re===null){for(;!ut.done;Pe++,ut=W.next())ut=ue(Y,ut.value,ce),ut!==null&&(Q=x(ut,Q,Pe),st===null?Ae=ut:st.sibling=ut,st=ut);return Ge&&Xr(Y,Pe),Ae}for(Re=h(Re);!ut.done;Pe++,ut=W.next())ut=Z(Re,Y,Pe,ut.value,ce),ut!==null&&(r&&(on=ut.alternate,on!==null&&Re.delete(on.key===null?Pe:on.key)),Q=x(ut,Q,Pe),st===null?Ae=ut:st.sibling=ut,st=ut);return r&&Re.forEach(function(rM){return s(Y,rM)}),Ge&&Xr(Y,Pe),Ae}function $e(Y,Q,W,ce){if(typeof W=="object"&&W!==null&&W.type===J&&W.key===null&&W.props.ref===void 0&&(W=W.props.children),typeof W=="object"&&W!==null){switch(W.$$typeof){case ie:e:{for(var Ae=W.key;Q!==null;){if(Q.key===Ae){if(Ae=W.type,Ae===J){if(Q.tag===7){c(Y,Q.sibling),ce=p(Q,W.props.children),Ol(ce,W),ce.return=Y,Y=ce;break e}}else if(Q.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===A&&Ds(Ae)===Q.type){c(Y,Q.sibling),ce=p(Q,W.props),Ol(ce,W),ce.return=Y,Y=ce;break e}c(Y,Q);break}else s(Y,Q);Q=Q.sibling}W.type===J?(ce=Cs(W.props.children,Y.mode,ce,W.key),Ol(ce,W),ce.return=Y,Y=ce):(ce=sf(W.type,W.key,W.props,null,Y.mode,ce),Ol(ce,W),ce.return=Y,Y=ce)}return k(Y);case q:e:{for(Ae=W.key;Q!==null;){if(Q.key===Ae)if(Q.tag===4&&Q.stateNode.containerInfo===W.containerInfo&&Q.stateNode.implementation===W.implementation){c(Y,Q.sibling),ce=p(Q,W.children||[]),ce.return=Y,Y=ce;break e}else{c(Y,Q);break}else s(Y,Q);Q=Q.sibling}ce=Xm(W,Y.mode,ce),ce.return=Y,Y=ce}return k(Y);case A:return W=Ds(W),$e(Y,Q,W,ce)}if(ze(W))return ye(Y,Q,W,ce);if(pe(W)){if(Ae=pe(W),typeof Ae!="function")throw Error(i(150));return W=Ae.call(W),Ee(Y,Q,W,ce)}if(typeof W.then=="function")return $e(Y,Q,gf(W),ce);if(W.$$typeof===ne)return $e(Y,Q,hf(Y,W),ce);xf(Y,W)}return typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint"?(W=""+W,Q!==null&&Q.tag===6?(c(Y,Q.sibling),ce=p(Q,W),ce.return=Y,Y=ce):(c(Y,Q),ce=Qm(W,Y.mode,ce),ce.return=Y,Y=ce),k(Y)):c(Y,Q)}return function(Y,Q,W,ce){try{sc=0;var Ae=$e(Y,Q,W,ce);return Eo=null,Ae}catch(Re){if(Re===Ao||Re===mf)throw Re;var st=ii(29,Re,null,Y.mode);return st.lanes=ce,st.return=Y,st}finally{}}}var Rs=v1(!0),w1=v1(!1),Nl=!1;function np(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ip(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function Tl(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function Al(r,s,c){var h=r.updateQueue;if(h===null)return null;if(h=h.shared,(pt&2)!==0){var p=h.pending;return p===null?s.next=s:(s.next=p.next,p.next=s),h.pending=s,s=lf(r),r1(r,null,c),s}return rf(r,h,s,c),lf(r)}function oc(r,s,c){if(s=s.updateQueue,s!==null&&(s=s.shared,(c&4194048)!==0)){var h=s.lanes;h&=r.pendingLanes,c|=h,s.lanes=c,ho(r,c)}}function rp(r,s){var c=r.updateQueue,h=r.alternate;if(h!==null&&(h=h.updateQueue,c===h)){var p=null,x=null;if(c=c.firstBaseUpdate,c!==null){do{var k={lane:c.lane,tag:c.tag,payload:c.payload,callback:null,next:null};x===null?p=x=k:x=x.next=k,c=c.next}while(c!==null);x===null?p=x=s:x=x.next=s}else p=x=s;c={baseState:h.baseState,firstBaseUpdate:p,lastBaseUpdate:x,shared:h.shared,callbacks:h.callbacks},r.updateQueue=c;return}r=c.lastBaseUpdate,r===null?c.firstBaseUpdate=s:r.next=s,c.lastBaseUpdate=s}var lp=!1;function ac(){if(lp){var r=To;if(r!==null)throw r}}function cc(r,s,c,h){lp=!1;var p=r.updateQueue;Nl=!1;var x=p.firstBaseUpdate,k=p.lastBaseUpdate,O=p.shared.pending;if(O!==null){p.shared.pending=null;var _=O,G=_.next;_.next=null,k===null?x=G:k.next=G,k=_;var te=r.alternate;te!==null&&(te=te.updateQueue,O=te.lastBaseUpdate,O!==k&&(O===null?te.firstBaseUpdate=G:O.next=G,te.lastBaseUpdate=_))}if(x!==null){var ue=p.baseState;k=0,te=G=_=null,O=x;do{var X=O.lane&-536870913,Z=X!==O.lane;if(Z?(lt&X)===X:(h&X)===X){X!==0&&X===Es&&(lp=!0),te!==null&&(te=te.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var ye=r,Ee=O;X=s;var $e=c;switch(Ee.tag){case 1:if(ye=Ee.payload,typeof ye=="function"){ue=ye.call($e,ue,X);break e}ue=ye;break e;case 3:ye.flags=ye.flags&-65537|128;case 0:if(ye=Ee.payload,X=typeof ye=="function"?ye.call($e,ue,X):ye,X==null)break e;ue=T({},ue,X);break e;case 2:Nl=!0}}X=O.callback,X!==null&&(r.flags|=64,Z&&(r.flags|=8192),Z=p.callbacks,Z===null?p.callbacks=[X]:Z.push(X))}else Z={lane:X,tag:O.tag,payload:O.payload,callback:O.callback,next:null},te===null?(G=te=Z,_=ue):te=te.next=Z,k|=X;if(O=O.next,O===null){if(O=p.shared.pending,O===null)break;Z=O,O=Z.next,Z.next=null,p.lastBaseUpdate=Z,p.shared.pending=null}}while(!0);te===null&&(_=ue),p.baseState=_,p.firstBaseUpdate=G,p.lastBaseUpdate=te,x===null&&(p.shared.lanes=0),Ll|=k,r.lanes=k,r.memoizedState=ue}}function k1(r,s){if(typeof r!="function")throw Error(i(191,r));r.call(s)}function S1(r,s){var c=r.callbacks;if(c!==null)for(r.callbacks=null,r=0;rx?x:8;var k=ve.T,O={};O.types=k!==null?k.types:null,ve.T=O,Op(r,!1,s,c);try{var _=p(),G=ve.S;if(G!==null&&G(O,_),_!==null&&typeof _=="object"&&typeof _.then=="function"){var te=C5(_,h);dc(r,s,te,ki(r))}else dc(r,s,h,ki(r))}catch(ue){dc(r,s,{then:function(){},status:"rejected",reason:ue},ki())}finally{je.p=x,k!==null&&O.types!==null&&(k.types=O.types),ve.T=k}}function M5(){}function Sp(r,s,c,h){if(r.tag!==5)throw Error(i(476));var p=tv(r).queue;ev(r,p,s,It,c===null?M5:function(){return nv(r),c(h)})}function tv(r){var s=r.memoizedState;if(s!==null)return s;s={memoizedState:It,baseState:It,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Kr,lastRenderedState:It},next:null};var c={};return s.next={memoizedState:c,baseState:c,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Kr,lastRenderedState:c},next:null},r.memoizedState=s,r=r.alternate,r!==null&&(r.memoizedState=s),s}function nv(r){var s=tv(r);s.next===null&&(s=r.alternate.memoizedState),dc(r,s.next.queue,{},ki())}function Cp(){return On(Wo)}function iv(){return Wt().memoizedState}function rv(){return Wt().memoizedState}function D5(r){for(var s=r.return;s!==null;){switch(s.tag){case 24:case 3:var c=ki();r=Tl(c);var h=Al(s,r,c);h!==null&&(oi(h,s,c),oc(h,s,c)),s={cache:Zm()},r.payload=s;return}s=s.return}}function j5(r,s,c){var h=ki();c={lane:h,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Tf(r)?sv(s,c):(c=qm(r,s,c,h),c!==null&&(oi(c,r,h),ov(c,s,h)))}function lv(r,s,c){var h=ki();dc(r,s,c,h)}function dc(r,s,c,h){var p={lane:h,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null};if(Tf(r))sv(s,p);else{var x=r.alternate;if(r.lanes===0&&(x===null||x.lanes===0)&&(x=s.lastRenderedReducer,x!==null))try{var k=s.lastRenderedState,O=x(k,c);if(p.hasEagerState=!0,p.eagerState=O,xi(O,k))return rf(r,s,p,0),Tt===null&&nf(),!1}catch{}finally{}if(c=qm(r,s,p,h),c!==null)return oi(c,r,h),ov(c,s,h),!0}return!1}function Op(r,s,c,h){if(h={lane:2,revertLane:pg(),gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},Tf(r)){if(s)throw Error(i(479))}else s=qm(r,c,h,2),s!==null&&oi(s,r,2)}function Tf(r){var s=r.alternate;return r===Xe||s!==null&&s===Xe}function sv(r,s){Mo=vf=!0;var c=r.pending;c===null?s.next=s:(s.next=c.next,c.next=s),r.pending=s}function ov(r,s,c){if((c&4194048)!==0){var h=s.lanes;h&=r.pendingLanes,c|=h,s.lanes=c,ho(r,c)}}var Af={readContext:On,use:Sf,useCallback:Qt,useContext:Qt,useEffect:Qt,useImperativeHandle:Qt,useLayoutEffect:Qt,useInsertionEffect:Qt,useMemo:Qt,useReducer:Qt,useRef:Qt,useState:Qt,useDebugValue:Qt,useDeferredValue:Qt,useTransition:Qt,useSyncExternalStore:Qt,useId:Qt,useHostTransitionStatus:Qt,useFormState:Qt,useActionState:Qt,useOptimistic:Qt,useMemoCache:Qt,useCacheRefresh:Qt,useEffectEvent:Qt},av={readContext:On,use:Sf,useCallback:function(r,s){return Xn().memoizedState=[r,s===void 0?null:s],r},useContext:On,useEffect:Q1,useImperativeHandle:function(r,s,c){c=c!=null?c.concat([r]):null,Of(4194308,4,G1.bind(null,s,r),c)},useLayoutEffect:function(r,s){return Of(4194308,4,r,s)},useInsertionEffect:function(r,s){Of(4,2,r,s)},useMemo:function(r,s){var c=Xn();s=s===void 0?null:s;var h=r();if(_s){ar(!0);try{r()}finally{ar(!1)}}return c.memoizedState=[h,s],h},useReducer:function(r,s,c){var h=Xn();if(c!==void 0){var p=c(s);if(_s){ar(!0);try{c(s)}finally{ar(!1)}}}else p=s;return h.memoizedState=h.baseState=p,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:p},h.queue=r,r=r.dispatch=j5.bind(null,Xe,r),[h.memoizedState,r]},useRef:function(r){var s=Xn();return r={current:r},s.memoizedState=r},useState:function(r){r=yp(r);var s=r.queue,c=lv.bind(null,Xe,s);return s.dispatch=c,[r.memoizedState,c]},useDebugValue:wp,useDeferredValue:function(r,s){var c=Xn();return kp(c,r,s)},useTransition:function(){var r=yp(!1);return r=ev.bind(null,Xe,r.queue,!0,!1),Xn().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,s,c){var h=Xe,p=Xn();if(Ge){if(c===void 0)throw Error(i(407));c=c()}else{if(c=s(),Tt===null)throw Error(i(349));(lt&127)!==0||E1(h,s,c)}p.memoizedState=c;var x={value:c,getSnapshot:s};return p.queue=x,Q1(D1.bind(null,h,x,r),[r]),h.flags|=2048,jo(9,{destroy:void 0},M1.bind(null,h,x,c,s),null),c},useId:function(){var r=Xn(),s=Tt.identifierPrefix;if(Ge){var c=dr,h=hr;c=(h&~(1<<32-Lt(h)-1)).toString(32)+c,s="_"+s+"R_"+c,c=wf++,0<\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof h.is=="string"?k.createElement("select",{is:h.is}):k.createElement("select"),h.multiple?x.multiple=!0:h.size&&(x.size=h.size);break;default:x=typeof h.is=="string"?k.createElement(p,{is:h.is}):k.createElement(p)}}x[zt]=s,x[Kt]=h;e:for(k=s.child;k!==null;){if(k.tag===5||k.tag===6)x.appendChild(k.stateNode);else if(k.tag!==4&&k.tag!==27&&k.child!==null){k.child.return=k,k=k.child;continue}if(k===s)break e;for(;k.sibling===null;){if(k.return===null||k.return===s)break e;k=k.return}k.sibling.return=k.return,k=k.sibling}s.stateNode=x;e:switch(En(x,p,h),p){case"button":case"input":case"select":case"textarea":h=!!h.autoFocus;break e;case"img":h=!0;break e;default:h=!1}h&&Zr(s)}}return jt(s),s.subtreeFlags&=-33554433,Pp(s,s.type,r===null?null:r.memoizedProps,s.pendingProps,c),null;case 6:if(r&&s.stateNode!=null)r.memoizedProps!==h&&Zr(s);else{if(typeof h!="string"&&s.stateNode===null)throw Error(i(166));if(r=Ft.current,No(s)){if(r=s.stateNode,c=s.memoizedProps,h=null,p=bn,p!==null)switch(p.tag){case 27:case 5:h=p.memoizedProps}r[zt]=s,r=!!(r.nodeValue===c||h!==null&&h.suppressHydrationWarning===!0||Dw(r.nodeValue,c)),r||Sl(s,!0)}else r=Nc(r).createTextNode(h),r[zt]=s,s.stateNode=r}return jt(s),null;case 31:if(c=s.memoizedState,r===null||r.memoizedState!==null){if(h=No(s),c!==null){if(r===null){if(!h)throw Error(i(318));if(r=s.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(557));r[zt]=s}else Os(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;jt(s),r=!1}else c=Gm(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=c),r=!0;if(!r)return s.flags&256?(yi(s),s):(yi(s),null);if((s.flags&128)!==0)throw Error(i(558))}return jt(s),null;case 13:if(h=s.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(p=No(s),h!==null&&h.dehydrated!==null){if(r===null){if(!p)throw Error(i(318));if(p=s.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(i(317));p[zt]=s}else Os(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;jt(s),p=!1}else p=Gm(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=p),p=!0;if(!p)return s.flags&256?(yi(s),s):(yi(s),null)}return yi(s),(s.flags&128)!==0?(s.lanes=c,s):(c=h!==null,r=r!==null&&r.memoizedState!==null,c&&(h=s.child,p=null,h.alternate!==null&&h.alternate.memoizedState!==null&&h.alternate.memoizedState.cachePool!==null&&(p=h.alternate.memoizedState.cachePool.pool),x=null,h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(x=h.memoizedState.cachePool.pool),x!==p&&(h.flags|=2048)),c!==r&&c&&(s.child.flags|=8192),_f(s,s.updateQueue),jt(s),null);case 4:return qe(),r===null&&bg(s.stateNode.containerInfo),s.flags|=67108864,jt(s),null;case 10:return Yr(s.type),jt(s),null;case 19:if(cp(s),h=s.memoizedState,h===null)return jt(s),null;if(p=(s.flags&128)!==0,x=h.rendering,x===null)if(p)pc(h,!1);else{if(Xt!==0||r!==null&&(r.flags&128)!==0)for(r=s.child;r!==null;){if(x=bf(r),x!==null){for(s.flags|=128,pc(h,!1),r=x.updateQueue,s.updateQueue=r,_f(s,r),s.subtreeFlags=0,r=c,c=s.child;c!==null;)l1(c,r),c=c.sibling;return uc(s,Tn.current&1|2),Ge&&Xr(s,h.treeForkCount),s.child}r=r.sibling}h.tail!==null&&tn()>Xf&&(s.flags|=128,p=!0,pc(h,!1),s.lanes=4194304)}else{if(!p)if(r=bf(x),r!==null){if(s.flags|=128,p=!0,r=r.updateQueue,s.updateQueue=r,_f(s,r),pc(h,!0),h.tail===null&&h.tailMode!=="collapsed"&&h.tailMode!=="visible"&&!x.alternate&&!Ge)return jt(s),null}else 2*tn()-h.renderingStartTime>Xf&&c!==536870912&&(s.flags|=128,p=!0,pc(h,!1),s.lanes=4194304);h.isBackwards?(x.sibling=s.child,s.child=x):(r=h.last,r!==null?r.sibling=x:s.child=x,h.last=x)}if(h.tail!==null){r=h.tail;e:{for(c=r;c!==null;){if(c.alternate!==null){c=!1;break e}c=c.sibling}c=!0}return h.rendering=r,h.tail=r.sibling,h.renderingStartTime=tn(),r.sibling=null,x=Tn.current,x=p?x&1|2:x&1,h.tailMode==="visible"||h.tailMode==="collapsed"||!c||Ge?uc(s,x):(c=x,rt(Nn,s),rt(Tn,c),Bn===null&&(Bn=s)),Ge&&Xr(s,h.treeForkCount),r}return jt(s),null;case 22:case 23:return yi(s),op(),h=s.memoizedState!==null,r!==null?r.memoizedState!==null!==h&&(s.flags|=8192):h&&(s.flags|=8192),h?(c&536870912)!==0&&(s.flags&128)===0&&(jt(s),s.subtreeFlags&6&&(s.flags|=8192)):jt(s),c=s.updateQueue,c!==null&&_f(s,c.retryQueue),c=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(c=r.memoizedState.cachePool.pool),h=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(h=s.memoizedState.cachePool.pool),h!==c&&(s.flags|=2048),r!==null&&yt(Ms),null;case 24:return c=null,r!==null&&(c=r.memoizedState.cache),s.memoizedState.cache!==c&&(s.flags|=2048),Yr(rn),jt(s),null;case 25:return null;case 30:return s.flags|=33554432,jt(s),null}throw Error(i(156,s.tag))}function H5(r,s){switch($m(s),s.tag){case 1:return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return Yr(rn),qe(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 26:case 27:case 5:return at(s),null;case 31:if(s.memoizedState!==null){if(yi(s),s.alternate===null)throw Error(i(340));Os()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 13:if(yi(s),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(i(340));Os()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return cp(s),r=s.flags,r&65536?(s.flags=r&-65537|128,r=s.memoizedState,r!==null&&(r.rendering=null,r.tail=null),s.flags|=4,s):null;case 4:return qe(),null;case 10:return Yr(s.type),null;case 22:case 23:return yi(s),op(),r!==null&&yt(Ms),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 24:return Yr(rn),null;case 25:return null;default:return null}}function Rv(r,s){switch($m(s),s.tag){case 3:Yr(rn),qe();break;case 26:case 27:case 5:at(s);break;case 4:qe();break;case 31:s.memoizedState!==null&&yi(s);break;case 13:yi(s);break;case 19:cp(s);break;case 10:Yr(s.type);break;case 22:case 23:yi(s),op(),r!==null&&yt(Ms);break;case 24:Yr(rn)}}function gc(r,s){try{var c=s.updateQueue,h=c!==null?c.lastEffect:null;if(h!==null){var p=h.next;c=p;do{if((c.tag&r)===r){h=void 0;var x=c.create,k=c.inst;h=x(),k.destroy=h}c=c.next}while(c!==p)}}catch(O){wt(s,s.return,O)}}function jl(r,s,c){try{var h=s.updateQueue,p=h!==null?h.lastEffect:null;if(p!==null){var x=p.next;h=x;do{if((h.tag&r)===r){var k=h.inst,O=k.destroy;if(O!==void 0){k.destroy=void 0,p=s;var _=c,G=O;try{G()}catch(te){wt(p,_,te)}}}h=h.next}while(h!==x)}}catch(te){wt(s,s.return,te)}}function _v(r){var s=r.updateQueue;if(s!==null){var c=r.stateNode;try{S1(s,c)}catch(h){wt(r,r.return,h)}}}function Lv(r,s,c){c.props=Ls(r.type,r.memoizedProps),c.state=r.memoizedState;try{c.componentWillUnmount()}catch(h){wt(r,s,h)}}function mr(r,s){try{var c=r.ref;if(c!==null){switch(r.tag){case 26:case 27:case 5:var h=r.stateNode;break;case 30:var p=r.stateNode,x=qr(r.memoizedProps,p);(p.ref===null||p.ref.name!==x)&&(p.ref=Fw(x)),h=p.ref;break;case 7:if(r.stateNode===null){var k=new Si(r);g(r.child,!1,E3,k,void 0,void 0),r.stateNode=k}h=r.stateNode;break;default:h=r.stateNode}typeof c=="function"?r.refCleanup=c(h):c.current=h}}catch(O){wt(r,s,O)}}function An(r,s){var c=r.ref,h=r.refCleanup;if(c!==null)if(typeof h=="function")try{h()}catch(p){wt(r,s,p)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof c=="function")try{c(null)}catch(p){wt(r,s,p)}else c.current=null}function Lf(r,s){if((r.tag===5||r.tag===27||r.tag===6)&&r.alternate===null&&s!==null)for(var c=0;c title"))),En(h,s,c),h[zt]=r,nn(h),s=h;break e;case"link":if(x=lk("link","href",p).get(s+(c.href||""))){for(k=0;k$e&&(k=$e,$e=Ee,Ee=k);var Y=$b(O,Ee),Q=$b(O,$e);if(Y&&Q&&(Z.rangeCount!==1||Z.anchorNode!==Y.node||Z.anchorOffset!==Y.offset||Z.focusNode!==Q.node||Z.focusOffset!==Q.offset)){var W=ue.createRange();W.setStart(Y.node,Y.offset),Z.removeAllRanges(),Ee>$e?(Z.addRange(W),Z.extend(Q.node,Q.offset)):(W.setEnd(Q.node,Q.offset),Z.addRange(W))}}}}for(ue=[],Z=O;Z=Z.parentNode;)Z.nodeType===1&&ue.push({element:Z,left:Z.scrollLeft,top:Z.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;Oc?32:c,ve.T=null,c=lg,lg=null;var x=Ki,k=vr;if(Ht=0,Hs=Ki=null,vr=0,(pt&6)!==0)throw Error(i(331));var O=pt;if(pt|=4,rw(x.current),tw(x,x.current,k,c),pt=O,Sc(0,!1),qn&&typeof qn.onPostCommitFiberRoot=="function")try{qn.onPostCommitFiberRoot(xe,x)}catch{}return!0}finally{je.p=p,ve.T=h,bw(r,s)}}function vw(r,s,c){s=ji(c,s),s=Ap(r.stateNode,s,2),r=Al(r,s,2),r!==null&&(cr(r,2),wr(r))}function wt(r,s,c){if(r.tag===3)vw(r,r,c);else for(;s!==null;){if(s.tag===3){vw(s,r,c);break}else if(s.tag===1){var h=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(zl===null||!zl.has(h))){r=ji(c,r),c=gv(2),h=Al(s,c,2),h!==null&&(xv(c,h,s,r),cr(h,2),wr(h));break}}s=s.return}}function hg(r,s,c){var h=r.pingCache;if(h===null){h=r.pingCache=new q5;var p=new Set;h.set(s,p)}else p=h.get(s),p===void 0&&(p=new Set,h.set(s,p));p.has(c)||(ng=!0,p.add(c),r=W5.bind(null,r,s,c),s.then(r,r))}function W5(r,s,c){var h=r.pingCache;h!==null&&h.delete(s),r.pingedLanes|=r.suspendedLanes&c,r.warmLanes&=~c,Tt===r&&(lt&c)===c&&((Xt===4||Xt===3&&(lt&62914560)===lt&&300>tn()-Qf)&&(pt&2)===0?qo(r,0):Vf|=c,Po===lt&&(Po=0)),wr(r)}function ww(r,s){s===0&&(s=Bu()),r=Ss(r,s),r!==null&&(cr(r,s),wr(r))}function Z5(r){var s=r.memoizedState,c=0;s!==null&&(c=s.retryLane),ww(r,c)}function J5(r,s){var c=0;switch(r.tag){case 31:case 13:var h=r.stateNode,p=r.memoizedState;p!==null&&(c=p.retryLane);break;case 19:h=r.stateNode;break;case 22:h=r.stateNode._retryCache;break;default:throw Error(i(314))}h!==null&&h.delete(s),ww(r,c)}function e3(r,s){return mn(r,s)}var Qo=null,Xo=null,dg=!1,Jf=!1,mg=!1,Pl=0;function wr(r){r!==Xo&&r.next===null&&(Xo===null?Qo=Xo=r:Xo=Xo.next=r),Jf=!0,dg||(dg=!0,n3())}function Sc(r,s){if(!mg&&Jf){mg=!0;do for(var c=!1,h=Qo;h!==null;){if(r!==0){var p=h.pendingLanes;if(p===0)var x=0;else{var k=h.suspendedLanes,O=h.pingedLanes;x=(1<<31-Lt(42|r)+1)-1,x&=p&~(k&~O),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(c=!0,Ow(h,x))}else x=lt,x=fo(h,h===Tt?x:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),(x&3)===0||dl(h,x)||(c=!0,Ow(h,x));h=h.next}while(c);mg=!1}}function t3(){kw()}function kw(){Jf=dg=!1;var r=0;Pl!==0&&d3()&&(r=Pl);for(var s=tn(),c=null,h=Qo;h!==null;){var p=h.next,x=Sw(h,s);x===0?(h.next=null,c===null?Qo=p:c.next=p,p===null&&(Xo=c)):(c=h,(r!==0||(x&3)!==0)&&(Jf=!0)),h=p}Ht!==0&&Ht!==5||Sc(r),Pl!==0&&(Pl=0)}function Sw(r,s){for(var c=r.suspendedLanes,h=r.pingedLanes,p=r.expirationTimes,x=r.pendingLanes&-62914561;0O)break;var te=_.transferSize,ue=_.initiatorType;te&&jw(ue)&&(_=_.responseEnd,k+=te*(_rh){Ee.length=ye;break}W=new Promise(b3.bind(W)),Ee.push(W)}}}if(0"u"?null:document;function tk(r,s,c){var h=Yo;if(h&&typeof s=="string"&&s){var p=H(s);p='link[rel="'+r+'"][href="'+p+'"]',typeof c=="string"&&(p+='[crossorigin="'+c+'"]'),ek.has(p)||(ek.add(p),r={rel:r,crossOrigin:c,href:s},h.querySelector(p)===null&&(s=h.createElement("link"),En(s,"link",r),nn(s),h.head.appendChild(s)))}}function P3(r){el.D(r),tk("dns-prefetch",r,null)}function H3(r,s){el.C(r,s),tk("preconnect",r,s)}function I3(r,s,c){el.L(r,s,c);var h=Yo;if(h&&r&&s){var p='link[rel="preload"][as="'+H(s)+'"]';s==="image"&&c&&c.imageSrcSet?(p+='[imagesrcset="'+H(c.imageSrcSet)+'"]',typeof c.imageSizes=="string"&&(p+='[imagesizes="'+H(c.imageSizes)+'"]')):p+='[href="'+H(r)+'"]';var x=p;switch(s){case"style":x=Go(r);break;case"script":x=Ko(r)}if(!(Pi.has(x)||(r=T({rel:"preload",href:s==="image"&&c&&c.imageSrcSet?void 0:r,as:s},c),Pi.set(x,r),h.querySelector(p)!==null||s==="style"&&h.querySelector(Ac(x))||s==="script"&&h.querySelector(Ec(x))))){var k=h.createElement("link");En(k,"link",r),s==="style"&&(k[mo]=!0,k.onload=k.onerror=function(){Uu(k)}),nn(k),h.head.appendChild(k)}}}function U3(r,s){el.m(r,s);var c=Yo;if(c&&r){var h=s&&typeof s.as=="string"?s.as:"script",p='link[rel="modulepreload"][as="'+H(h)+'"][href="'+H(r)+'"]',x=p;switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Ko(r)}if(!Pi.has(x)&&(r=T({rel:"modulepreload",href:r},s),Pi.set(x,r),c.querySelector(p)===null)){switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(c.querySelector(Ec(x)))return}h=c.createElement("link"),En(h,"link",r),nn(h),c.head.appendChild(h)}}}function F3(r,s,c){el.S(r,s,c);var h=Yo;if(h&&r){var p=xl(h).hoistableStyles,x=Go(r);s=s||"default";var k=p.get(x);if(!k){var O={loading:0,preload:null};if(k=h.querySelector(Ac(x)))O.loading=5;else{r=T({rel:"stylesheet",href:r,"data-precedence":s},c),(c=Pi.get(x))&&Lg(r,c);var _=k=h.createElement("link");nn(_),En(_,"link",r),_._p=new Promise(function(G,te){_.onload=G,_.onerror=te}),_.addEventListener("load",function(){O.loading|=1}),_.addEventListener("error",function(){O.loading|=2}),O.loading|=4,nh(k,s,h)}k={type:"stylesheet",instance:k,count:1,state:O},p.set(x,k)}}}function q3(r,s){el.X(r,s);var c=Yo;if(c&&r){var h=xl(c).hoistableScripts,p=Ko(r),x=h.get(p);x||(x=c.querySelector(Ec(p)),x||(r=T({src:r,async:!0},s),(s=Pi.get(p))&&zg(r,s),x=c.createElement("script"),nn(x),En(x,"link",r),c.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},h.set(p,x))}}function V3(r,s){el.M(r,s);var c=Yo;if(c&&r){var h=xl(c).hoistableScripts,p=Ko(r),x=h.get(p);x||(x=c.querySelector(Ec(p)),x||(r=T({src:r,async:!0,type:"module"},s),(s=Pi.get(p))&&zg(r,s),x=c.createElement("script"),nn(x),En(x,"link",r),c.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},h.set(p,x))}}function nk(r,s,c,h){var p=(p=Ft.current)?Tc(p):null;if(!p)throw Error(i(446));switch(r){case"meta":case"title":return null;case"style":return typeof c.precedence=="string"&&typeof c.href=="string"?(c=Go(c.href),s=xl(p).hoistableStyles,h=s.get(c),h||(h={type:"style",instance:null,count:0,state:null},s.set(c,h)),h):{type:"void",instance:null,count:0,state:null};case"link":if(c.rel==="stylesheet"&&typeof c.href=="string"&&typeof c.precedence=="string"){r=Go(c.href);var x=xl(p).hoistableStyles,k=x.get(r);if(k||(p=p.ownerDocument||p,k={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(r,k),(x=p.querySelector(Ac(r)))?x._p||(k.instance=x,k.state.loading=5):(x=Pi.get(r),x||(x={rel:"preload",as:"style",href:c.href,crossOrigin:c.crossOrigin,integrity:c.integrity,media:c.media,hrefLang:c.hrefLang,referrerPolicy:c.referrerPolicy},Pi.set(r,x)),Q3(p,r,x,k.state))),s&&h===null)throw Error(i(528,""));return k}if(s&&h!==null)throw Error(i(529,""));return null;case"script":return s=c.async,c=c.src,typeof c=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(c=Ko(c),s=xl(p).hoistableScripts,h=s.get(c),h||(h={type:"script",instance:null,count:0,state:null},s.set(c,h)),h):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,r))}}function Go(r){return'href="'+H(r)+'"'}function Ac(r){return'link[rel="stylesheet"]['+r+"]"}function ik(r){return T({},r,{"data-precedence":r.precedence,precedence:null})}function Q3(r,s,c,h){if(s=r.querySelector('link[rel="preload"][as="style"]['+s+"]")){if(s[mo]!==!0){h.loading=1;return}}else s=r.createElement("link"),s[mo]=!0,s.onload=s.onerror=Uu.bind(null,s),En(s,"link",c),nn(s),r.head.appendChild(s);h.preload=s,s.addEventListener("load",function(){return h.loading|=1}),s.addEventListener("error",function(){return h.loading|=2})}function Ko(r){return'[src="'+H(r)+'"]'}function Ec(r){return"script[async]"+r}function rk(r,s,c){if(s.count++,s.instance===null)switch(s.type){case"style":var h=r.querySelector('style[data-href~="'+H(c.href)+'"]');if(h)return s.instance=h,nn(h),h;var p=T({},c,{"data-href":c.href,"data-precedence":c.precedence,href:null,precedence:null});return h=(r.ownerDocument||r).createElement("style"),nn(h),En(h,"style",p),nh(h,c.precedence,r),s.instance=h;case"stylesheet":p=Go(c.href);var x=r.querySelector(Ac(p));if(x)return s.state.loading|=4,s.instance=x,nn(x),x;h=ik(c),(p=Pi.get(p))&&Lg(h,p),x=(r.ownerDocument||r).createElement("link"),nn(x);var k=x;return k._p=new Promise(function(O,_){k.onload=O,k.onerror=_}),En(x,"link",h),s.state.loading|=4,nh(x,c.precedence,r),s.instance=x;case"script":return x=Ko(c.src),(p=r.querySelector(Ec(x)))?(s.instance=p,nn(p),p):(h=c,(p=Pi.get(x))&&(h=T({},c),zg(h,p)),r=r.ownerDocument||r,p=r.createElement("script"),nn(p),En(p,"link",h),r.head.appendChild(p),s.instance=p);case"void":return null;default:throw Error(i(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(h=s.instance,s.state.loading|=4,nh(h,c.precedence,r));return s.instance}function nh(r,s,c){for(var h=c.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=h.length?h[h.length-1]:null,x=p,k=0;k title"):null)}function X3(r,s,c){if(c===1||s.itemProp!=null)return!1;switch(r){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;switch(s.rel){case"stylesheet":return r=s.disabled,typeof s.precedence=="string"&&r==null;default:return!0}case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function sk(r,s){return r==="img"&&s.src!=null&&s.src!==""&&s.onLoad==null&&s.loading!=="lazy"}function ok(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function ak(r){return(r.width||100)*(r.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function ck(r,s){typeof s.decode=="function"&&(r.imgCount++,s.complete||(r.imgBytes+=ak(s),r.suspenseyImages.push(s)),r=G3.bind(r),s.decode().then(r,r))}function $3(r,s,c,h){if(c.type==="stylesheet"&&(typeof h.media!="string"||matchMedia(h.media).matches!==!1)&&(c.state.loading&4)===0){if(c.instance===null){var p=Go(h.href),x=s.querySelector(Ac(p));if(x){s=x._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(r.count++,r=Mc.bind(r),s.then(r,r)),c.state.loading|=4,c.instance=x,nn(x);return}x=s.ownerDocument||s,h=ik(h),(p=Pi.get(p))&&Lg(h,p),x=x.createElement("link"),nn(x);var k=x;k._p=new Promise(function(O,_){k.onload=O,k.onerror=_}),En(x,"link",h),c.instance=x}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(c,s),(s=c.state.preload)&&(c.state.loading&3)===0&&(r.count++,c=Mc.bind(r),s.addEventListener("load",c),s.addEventListener("error",c))}}var rh=0;function Y3(r,s){return r.stylesheets&&r.count===0&&sh(r,r.stylesheets),0rh?50:800)+s);return r.unsuspend=c,function(){r.unsuspend=null,clearTimeout(h),clearTimeout(p)}}:null}function uk(r){if(r.count===0&&(r.imgCount===0||!r.waitingForImages)){if(r.stylesheets)sh(r,r.stylesheets);else if(r.unsuspend){var s=r.unsuspend;r.unsuspend=null,s()}}}function Mc(){this.count--,uk(this)}function G3(){this.imgCount--,uk(this)}var lh=null;function sh(r,s){r.stylesheets=null,r.unsuspend!==null&&(r.count++,lh=new Map,s.forEach(K3,r),lh=null,Mc.call(r))}function K3(r,s){if(!(s.state.loading&4)){var c=lh.get(r);if(c)var h=c.get(null);else{c=new Map,lh.set(r,c);for(var p=r.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),Xg.exports=mM(),Xg.exports}var gM=pM();const xM=my(gM);class $C extends Error{constructor(t,i,l){super(t);dh(this,"status");dh(this,"detail");this.name="ApiError",this.status=i,this.detail=l}}async function us(n,e){let t=e,i;try{const l=await n.json();typeof(l==null?void 0:l.detail)=="string"&&l.detail?(t=l.detail,i=l.detail):Array.isArray(l==null?void 0:l.detail)&&(i=l.detail)}catch{}return new $C(t,n.status,i)}async function yM(n){const e=await fetch(`/api/notifications?after=${n}`);if(!e.ok)throw new Error("Failed to fetch notifications");return e.json()}async function bM(){const n=await fetch("/api/actions/open-log",{method:"POST"});if(!n.ok)throw new Error("Failed to open log file");return n.json()}async function vM(n){const e=new URLSearchParams;e.set("limit",String(n.limit)),n!=null&&n.level&&e.set("level",n.level),n!=null&&n.search&&e.set("search",n.search);const t=await fetch(`/api/logs?${e.toString()}`);if(!t.ok)throw new Error("Failed to fetch log entries");return t.json()}async function Gh(){const n=await fetch("/api/system");if(!n.ok)throw new Error("Failed to fetch system info");return n.json()}async function wM(n){const e=await fetch("/api/system/bind",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:n})});if(!e.ok){let t="Failed to update LAN binding";try{const i=await e.json();i!=null&&i.detail&&(t=i.detail)}catch{}throw new Error(t)}return e.json()}async function kM(n,e=1e4){const t=Date.now()+e;let i=null;for(;Date.now()setTimeout(l,500))}return i}async function _k(){const n=await fetch("/api/config");if(!n.ok)throw new Error("Failed to fetch app configuration");return n.json()}async function Lk(n){const e=await fetch("/api/config/select-directory",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:n})});if(!e.ok)throw new Error("Failed to select directory");return e.json()}async function SM(n){const e=await fetch("/api/config/load",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config_path:n})});if(!e.ok)throw new Error("Failed to load config file");return e.json()}async function YC(n,e){const t=await fetch("/api/config/load-content",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,content:e})});if(!t.ok){let i=`Failed to apply dropped config (${n})`;try{const l=await t.json();l!=null&&l.detail&&(i=l.detail)}catch{}throw new Error(i)}return t.json()}async function CM(){const n=await fetch("/api/config/reload",{method:"POST"});if(!n.ok){let e="Failed to reload configuration";try{const t=await n.json();t!=null&&t.detail&&(e=t.detail)}catch{}throw new Error(e)}return n.json()}async function OM(n){const e=await fetch("/api/config/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:n})});if(!e.ok)throw new Error("Failed to create config file");return e.json()}async function zk(){const n=await fetch("/api/config/content");if(!n.ok)throw await us(n,"Failed to fetch config content");return n.json()}async function Bk(n,e){const t=await fetch("/api/config/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,content:e})});if(!t.ok)throw await us(t,"Failed to validate config content");return t.json()}async function NM(){const n=await fetch("/api/config/template",{method:"POST"});if(!n.ok)throw await us(n,"Failed to fetch config template");return n.json()}async function TM(n,e){const t=await fetch("/api/config/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,force:e})});if(!t.ok)throw await us(t,"Failed to save configuration");return(await t.json()).config}async function AM(n){const e=await fetch("/api/config/save-as",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw await us(e,"Failed to save configuration as");return(await e.json()).config}async function EM(n){const e=`/api/fs/browse?path=${encodeURIComponent(n)}&include_hidden=true`,t=await fetch(e);if(!t.ok)throw new Error("Failed to browse config files");return t.json()}async function GC(n){const e=`/api/fs/browse?path=${encodeURIComponent(n)}`,t=await fetch(e);if(!t.ok)throw new Error("Failed to browse directory");return t.json()}async function Pk(n,e){const t=await fetch("/api/scan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),signal:e});if(!t.ok)throw new Error("Failed to execute scan");return t.json()}async function Kg(n){const e=new URLSearchParams;(n==null?void 0:n.offset)!=null&&e.set("offset",String(n.offset)),(n==null?void 0:n.limit)!=null&&e.set("limit",String(n.limit)),n!=null&&n.sort_by&&e.set("sort_by",n.sort_by),n!=null&&n.sort_dir&&e.set("sort_dir",n.sort_dir);const t=e.toString(),i=`/api/scan/results${t?`?${t}`:""}`,l=await fetch(i,{signal:n==null?void 0:n.signal});if(!l.ok)throw new Error("Failed to fetch scan results");return l.json()}async function MM(n){const e=await fetch("/api/actions/launch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw new Error("Failed to launch file");return e.json()}async function KC(n){const e=await fetch("/api/actions/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n})});if(!e.ok)throw new Error("Failed to reveal file");return e.json()}async function Y0(n){const e=await fetch("/api/actions/open-folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n})});if(!e.ok)throw new Error("Failed to open folder");return e.json()}async function Hk(n){const e=await fetch("/api/actions/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n})});if(!e.ok)throw new Error("Failed to open terminal");return e.json()}async function Ik(n,e){const t=await fetch("/api/actions/hash",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n,algorithm:e})});if(!t.ok)throw new Error("Failed to compute hash");return t.json()}async function DM(){const n=await fetch("/api/actions/open-config",{method:"POST"});if(!n.ok)throw new Error("Failed to open config file");return n.json()}async function Uk(n){const e={file_path:n.file_path||n.filePath,content:n.content},t=await fetch("/api/actions/barcode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error("Failed to generate barcode");return t.json()}async function jM(n){const e=await fetch("/api/actions/barcode/decode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image_base64:n.imageBase64,formats:n.formats})});if(!e.ok)throw e.status===503?new Error("Server-side barcode decoding is unavailable"):new Error(`Failed to decode frame (HTTP ${e.status})`);return e.json()}async function RM(n,e){const t=await fetch("/api/actions/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n}),signal:e});if(!t.ok)throw new Error("Failed to fetch metadata");return t.json()}async function _M(n,e){const t=await fetch("/api/actions/export-csv",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,filename:e})});if(!t.ok)throw new Error("Failed to export CSV");return t.json()}async function LM(n,e){const t=await fetch("/api/actions/save-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image_base64:n,filename:e})});if(!t.ok)throw new Error("Failed to save image");return t.json()}async function zM(n){const e=await fetch("/api/workflow/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw await us(e,"Failed to start workflow session");return e.json()}async function BM(n,e){const t=await fetch(`/api/workflow/${n}/respond`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e})});if(!t.ok)throw await us(t,"Failed to respond to workflow prompt");return t.json()}async function PM(n){const e=await fetch(`/api/workflow/${n}/abort`,{method:"POST"});if(!e.ok)throw await us(e,"Failed to abort workflow session");return e.json()}const HM=[".profiles",".profiles.yaml",".profiles.yml",".yaml",".yml"];function IM(n){const e=n.toLowerCase();return HM.some(t=>e.endsWith(t))}function UM(n){for(const e of n)if(IM(e.name))return e;return null}function Kh(){return{depth:0,overlayVisible:!1}}function Fk(n,e,t){switch(e){case"enter":return t?{depth:n.depth+1,overlayVisible:!0}:n;case"leave":{const i=Math.max(0,n.depth-1);return{depth:i,overlayVisible:n.depth>0&&i>0}}case"drop":return Kh()}}function qk(n){return n==="light"?"light":"dark"}/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const FM=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),WC=(...n)=>n.filter((e,t,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===t).join(" ").trim();/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */var qM={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const VM=D.forwardRef(({color:n="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:i,className:l="",children:o,iconNode:a,...u},f)=>D.createElement("svg",{ref:f,...qM,width:e,height:e,stroke:n,strokeWidth:i?Number(t)*24/Number(e):t,className:WC("lucide",l),...u},[...a.map(([d,m])=>D.createElement(d,m)),...Array.isArray(o)?o:[o]]));/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Me=(n,e)=>{const t=D.forwardRef(({className:i,...l},o)=>D.createElement(VM,{ref:o,iconNode:e,className:WC(`lucide-${FM(n)}`,i),...l}));return t.displayName=`${n}`,t};/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const QM=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],XM=Me("Activity",QM);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const $M=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],ZC=Me("ArrowDown",$M);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const YM=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],GM=Me("ArrowLeftRight",YM);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const KM=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],WM=Me("ArrowRight",KM);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ZM=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Vk=Me("ArrowUpDown",ZM);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const JM=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],e4=Me("ArrowUp",JM);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const t4=[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]],n4=Me("Bug",t4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const i4=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],r4=Me("Calendar",i4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const l4=[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],JC=Me("Camera",l4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const s4=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],_r=Me("Check",s4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const o4=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],a4=Me("ChevronDown",o4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const c4=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Xd=Me("ChevronRight",c4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const u4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Gc=Me("CircleAlert",u4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const f4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Qk=Me("CircleCheck",f4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const h4=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],d4=Me("CircleDashed",h4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const m4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],p4=Me("CircleDot",m4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const g4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],x4=Me("CirclePause",g4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const y4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]],b4=Me("CirclePlay",y4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const v4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],ou=Me("CircleX",v4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const w4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],k4=Me("Clock",w4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const S4=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],ci=Me("Copy",S4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const C4=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],eO=Me("Download",C4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const O4=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],tO=Me("ExternalLink",O4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const N4=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],T4=Me("EyeOff",N4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const A4=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],G0=Me("Eye",A4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const E4=[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]],M4=Me("FastForward",E4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const D4=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],j4=Me("FileCode2",D4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const R4=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],K0=Me("FileCode",R4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const _4=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3.2 12.9-.9-.4",key:"1i3dj5"}],["path",{d:"m3.2 15.1-.9.4",key:"1fvgj0"}],["path",{d:"M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5",key:"1yo3oz"}],["path",{d:"m4.9 11.2-.4-.9",key:"otmhb9"}],["path",{d:"m4.9 16.8-.4.9",key:"1b8z07"}],["path",{d:"m7.5 10.3-.4.9",key:"11k65u"}],["path",{d:"m7.5 17.7-.4-.9",key:"431x55"}],["path",{d:"m9.7 12.5-.9.4",key:"87sjan"}],["path",{d:"m9.7 15.5-.9-.4",key:"khqm91"}],["circle",{cx:"6",cy:"14",r:"3",key:"a1xfv6"}]],sa=Me("FileCog",_4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const L4=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]],z4=Me("FilePlus2",L4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const B4=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ka=Me("FileText",B4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const P4=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]],Wg=Me("File",P4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const H4=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],I4=Me("FlaskConical",H4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const U4=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Jl=Me("FolderOpen",U4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const F4=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Ou=Me("Folder",F4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const q4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],V4=Me("Globe",q4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Q4=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],oa=Me("Hash",Q4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const X4=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]],$d=Me("House",X4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const $4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],gy=Me("Info",$4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Y4=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],nO=Me("Keyboard",Y4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const G4=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],K4=Me("Link2",G4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const W4=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ll=Me("LoaderCircle",W4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Z4=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],J4=Me("Lock",Z4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const eD=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],tD=Me("Moon",eD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const nD=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],iD=Me("Network",nD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const rD=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],ts=Me("Play",rD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const lD=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],sD=Me("Plus",lD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const oD=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],xy=Me("QrCode",oD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const aD=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Yd=Me("RefreshCw",aD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const cD=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],uD=Me("Rocket",cD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const fD=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],hD=Me("RotateCcw",fD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const dD=[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]],mD=Me("SaveAll",dD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const pD=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],iO=Me("Save",pD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const gD=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],rO=Me("Search",gD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const xD=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],yD=Me("Settings",xD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const bD=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],vD=Me("Sun",bD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const wD=[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]],W0=Me("Terminal",wD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const kD=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],lO=Me("Timer",kD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const SD=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],sO=Me("Trash2",SD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const CD=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],yy=Me("TriangleAlert",CD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const OD=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],ND=Me("User",OD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const TD=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],oO=Me("Webhook",TD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const AD=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],ED=Me("Workflow",AD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const MD=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ei=Me("X",MD);function DD(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m${t.toString().padStart(2,"0")}s`}function jD(n){if(!n)return{label:"",cut:!1};const e=n.replace(/\\/g,"/").split("/").filter(Boolean);return e.length===0?{label:n,cut:!1}:{label:e[e.length-1],cut:e.length>1}}function RD({directory:n}){const[e,t]=D.useState(0);D.useEffect(()=>{t(0);const o=window.setInterval(()=>{t(a=>a+1)},1e3);return()=>window.clearInterval(o)},[]);const{label:i,cut:l}=jD(n);return y.jsxs("div",{"data-testid":"scan-status-strip",className:"flex min-w-0 items-center gap-1.5 text-[11px] text-ink-muted",children:[y.jsx(ll,{className:"h-3 w-3 shrink-0 animate-spin text-chip-indigo-text motion-reduce:animate-none","aria-hidden":"true"}),y.jsxs("span",{className:"min-w-0 truncate",children:["Scanning",n&&y.jsxs(y.Fragment,{children:[" ",y.jsxs("span",{className:"font-mono text-ink-secondary",title:n,children:[l?"…/":"",i]})]})," — ",y.jsx("span",{className:"font-mono tabular-nums text-ink-secondary",children:DD(e)})]})]})}function _D({onExecute:n,scanning:e,hasSelection:t,fileCount:i,totalCount:l,scanningDirectory:o="",toastMessage:a,onToastDismiss:u}){const f=(a==null?void 0:a.kind)==="error";return y.jsxs("div",{className:"relative flex items-center justify-between border-t border-line bg-surface-glass px-4 py-2.5 text-xs transition-colors duration-200",children:[a&&y.jsx("div",{role:"status","aria-live":f?"assertive":"polite","aria-atomic":"true",className:`animate-toast-in absolute left-1/2 top-1/2 z-[var(--z-toast)] max-w-[min(80vw,640px)] -translate-x-1/2 -translate-y-1/2 rounded-xl border px-4 py-2 text-xs font-medium glass-panel-strong ${f?"pointer-events-auto flex max-w-[min(70vw,560px)] items-center gap-2.5 border-status-danger-border text-left text-ink":"pointer-events-none max-w-[min(70vw,560px)] text-center text-ink"}`,children:f?y.jsxs(y.Fragment,{children:[y.jsx(ou,{className:"h-3.5 w-3.5 shrink-0 text-status-danger-text/80","aria-hidden":"true"}),y.jsx("span",{className:"min-w-0 flex-1",children:a.message}),u&&y.jsx("button",{type:"button",onClick:u,"aria-label":"Dismiss error",className:"shrink-0 rounded-md p-0.5 text-status-danger-text/60 hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-status-danger-border transition-colors",children:y.jsx(Ei,{className:"h-3.5 w-3.5"})})]}):a.message}),y.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e&&y.jsx(RD,{directory:o}),l!==void 0&&l!==i&&y.jsxs("span",{"data-testid":"action-bar-count",className:"text-ink-muted",children:["Showing ",i," of ",l]})]}),y.jsxs("button",{onClick:n,disabled:!t||e,className:"flex shrink-0 items-center gap-2 rounded-xl border border-emerald-300/50 bg-gradient-to-b from-emerald-400/90 to-emerald-600/90 px-5 py-2 font-semibold text-white shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_8px_24px_-6px_rgb(16_185_129/0.55)] transition-[filter,box-shadow,transform] hover:-translate-y-px hover:brightness-110 hover:shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_12px_30px_-6px_rgb(16_185_129/0.7)] disabled:opacity-40 disabled:hover:translate-y-0 disabled:hover:brightness-100 disabled:hover:shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_8px_24px_-6px_rgb(16_185_129/0.55)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400",children:[y.jsx(ts,{className:"h-3.5 w-3.5 fill-current"}),y.jsx("span",{children:"Execute"}),y.jsx("kbd",{className:"rounded bg-emerald-800/60 px-1.5 py-0.5 text-[10px] text-emerald-200 shadow-[inset_0_1px_0_rgb(255_255_255/0.12)]",children:"↵"})]})]})}let Z0=[],aO=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e>1;if(n=aO[i])e=i+1;else return!0;if(e==t)return!1}}function Xk(n){return n>=127462&&n<=127487}const $k=8205;function zD(n,e,t=!0,i=!0){return(t?cO:BD)(n,e,i)}function cO(n,e,t){if(e==n.length)return e;e&&uO(n.charCodeAt(e))&&fO(n.charCodeAt(e-1))&&e--;let i=Zg(n,e);for(e+=Yk(i);e=0&&Xk(Zg(n,a));)o++,a-=2;if(o%2==0)break;e+=2}else break}return e}function BD(n,e,t){for(;e>1;){let i=cO(n,e-2,t);if(i=56320&&n<57344}function fO(n){return n>=55296&&n<56320}function Yk(n){return n<65536?1:2}class ft{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Sa(this,e,t);let l=[];return this.decompose(0,e,l,2),i.length&&i.decompose(0,i.length,l,3),this.decompose(t,this.length,l,1),Ar.from(l,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Sa(this,e,t);let i=[];return this.decompose(e,t,i,0),Ar.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),l=new Kc(this),o=new Kc(e);for(let a=t,u=t;;){if(l.next(a),o.next(a),a=0,l.lineBreak!=o.lineBreak||l.done!=o.done||l.value!=o.value)return!1;if(u+=l.value.length,l.done||u>=i)return!0}}iter(e=1){return new Kc(this,e)}iterRange(e,t=this.length){return new hO(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let l=this.line(e).from;i=this.iterRange(l,Math.max(l,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new dO(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?ft.empty:e.length<=32?new Zt(e):Ar.from(Zt.split(e,[]))}}class Zt extends ft{constructor(e,t=PD(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,l){for(let o=0;;o++){let a=this.text[o],u=l+a.length;if((t?i:u)>=e)return new HD(l,u,i,a);l=u+1,i++}}decompose(e,t,i,l){let o=e<=0&&t>=this.length?this:new Zt(Gk(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(l&1){let a=i.pop(),u=Wh(o.text,a.text.slice(),0,o.length);if(u.length<=32)i.push(new Zt(u,a.length+o.length));else{let f=u.length>>1;i.push(new Zt(u.slice(0,f)),new Zt(u.slice(f)))}}else i.push(o)}replace(e,t,i){if(!(i instanceof Zt))return super.replace(e,t,i);[e,t]=Sa(this,e,t);let l=Wh(this.text,Wh(i.text,Gk(this.text,0,e)),t),o=this.length+i.length-(t-e);return l.length<=32?new Zt(l,o):Ar.from(Zt.split(l,[]),o)}sliceString(e,t=this.length,i=` -`){[e,t]=Sa(this,e,t);let l="";for(let o=0,a=0;o<=t&&ae&&a&&(l+=i),eo&&(l+=u.slice(Math.max(0,e-o),t-o)),o=f+1}return l}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],l=-1;for(let o of e)i.push(o),l+=o.length+1,i.length==32&&(t.push(new Zt(i,l)),i=[],l=-1);return l>-1&&t.push(new Zt(i,l)),t}}class Ar extends ft{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,l){for(let o=0;;o++){let a=this.children[o],u=l+a.length,f=i+a.lines-1;if((t?f:u)>=e)return a.lineInner(e,t,i,l);l=u+1,i=f+1}}decompose(e,t,i,l){for(let o=0,a=0;a<=t&&o=a){let d=l&((a<=e?1:0)|(f>=t?2:0));a>=e&&f<=t&&!d?i.push(u):u.decompose(e-a,t-a,i,d)}a=f+1}}replace(e,t,i){if([e,t]=Sa(this,e,t),i.lines=o&&t<=u){let f=a.replace(e-o,t-o,i),d=this.lines-a.lines+f.lines;if(f.lines>4&&f.lines>d>>6){let m=this.children.slice();return m[l]=f,new Ar(m,this.length-(t-e)+i.length)}return super.replace(o,u,f)}o=u+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` -`){[e,t]=Sa(this,e,t);let l="";for(let o=0,a=0;oe&&o&&(l+=i),ea&&(l+=u.sliceString(e-a,t-a,i)),a=f+1}return l}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Ar))return 0;let i=0,[l,o,a,u]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;l+=t,o+=t){if(l==a||o==u)return i;let f=this.children[l],d=e.children[o];if(f!=d)return i+f.scanIdentical(d,t);i+=f.length+1}}static from(e,t=e.reduce((i,l)=>i+l.length+1,-1)){let i=0;for(let v of e)i+=v.lines;if(i<32){let v=[];for(let w of e)w.flatten(v);return new Zt(v,t)}let l=Math.max(32,i>>5),o=l<<1,a=l>>1,u=[],f=0,d=-1,m=[];function g(v){let w;if(v.lines>o&&v instanceof Ar)for(let S of v.children)g(S);else v.lines>a&&(f>a||!f)?(b(),u.push(v)):v instanceof Zt&&f&&(w=m[m.length-1])instanceof Zt&&v.lines+w.lines<=32?(f+=v.lines,d+=v.length+1,m[m.length-1]=new Zt(w.text.concat(v.text),w.length+1+v.length)):(f+v.lines>l&&b(),f+=v.lines,d+=v.length+1,m.push(v))}function b(){f!=0&&(u.push(m.length==1?m[0]:Ar.from(m,d)),d=-1,f=m.length=0)}for(let v of e)g(v);return b(),u.length==1?u[0]:new Ar(u,t)}}ft.empty=new Zt([""],0);function PD(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Wh(n,e,t=0,i=1e9){for(let l=0,o=0,a=!0;o=t&&(f>i&&(u=u.slice(0,i-l)),l0?1:(e instanceof Zt?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,l=this.nodes[i],o=this.offsets[i],a=o>>1,u=l instanceof Zt?l.text.length:l.children.length;if(a==(t>0?u:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(l instanceof Zt){let f=l.text[a+(t<0?-1:0)];if(this.offsets[i]+=t,f.length>Math.max(0,e))return this.value=e==0?f:t>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=l.children[a+(t<0?-1:0)];e>f.length?(e-=f.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(f),this.offsets.push(t>0?1:(f instanceof Zt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class hO{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Kc(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:l}=this.cursor.next(e);return this.pos+=(l.length+e)*t,this.value=l.length<=i?l:t<0?l.slice(l.length-i):l.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class dO{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:l}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=l,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(ft.prototype[Symbol.iterator]=function(){return this.iter()},Kc.prototype[Symbol.iterator]=hO.prototype[Symbol.iterator]=dO.prototype[Symbol.iterator]=function(){return this});class HD{constructor(e,t,i,l){this.from=e,this.to=t,this.number=i,this.text=l}get length(){return this.to-this.from}}function Sa(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function Sn(n,e,t=!0,i=!0){return zD(n,e,t,i)}function ID(n){return n>=56320&&n<57344}function UD(n){return n>=55296&&n<56320}function ui(n,e){let t=n.charCodeAt(e);if(!UD(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return ID(i)?(t-55296<<10)+(i-56320)+65536:t}function by(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Er(n){return n<65536?1:2}const J0=/\r\n?|\n/;var Kn=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(Kn||(Kn={}));class Lr{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return o+(e-l);o+=u}else{if(i!=Kn.Simple&&d>=e&&(i==Kn.TrackDel&&le||i==Kn.TrackBefore&&le))return null;if(d>e||d==e&&t<0&&!u)return e==l||t<0?o:o+f;o+=f}l=d}if(e>l)throw new RangeError(`Position ${e} is out of range for changeset of length ${l}`);return o}touchesRange(e,t=e){for(let i=0,l=0;i=0&&l<=t&&u>=e)return lt?"cover":!0;l=u}return!1}toString(){let e="";for(let t=0;t=0?":"+l:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Lr(e)}static create(e){return new Lr(e)}}class hn extends Lr{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ex(this,(t,i,l,o,a)=>e=e.replace(l,l+(i-t),a),!1),e}mapDesc(e,t=!1){return tx(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let l=0,o=0;l=0){t[l]=u,t[l+1]=a;let f=l>>1;for(;i.length0&&Kl(i,t,o.text),o.forward(m),u+=m}let d=e[a++];for(;u>1].toJSON()))}return e}static of(e,t,i){let l=[],o=[],a=0,u=null;function f(m=!1){if(!m&&!l.length)return;ab||g<0||b>t)throw new RangeError(`Invalid change range ${g} to ${b} (in doc of length ${t})`);let w=v?typeof v=="string"?ft.of(v.split(i||J0)):v:ft.empty,S=w.length;if(g==b&&S==0)return;ga&&Pn(l,g-a,-1),Pn(l,b-g,S),Kl(o,l,w),a=b}}return d(e),f(!u),u}static empty(e){return new hn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let l=0;lu&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)t.push(o[0],0);else{for(;i.length=0&&t<=0&&t==n[l+1]?n[l]+=e:l>=0&&e==0&&n[l]==0?n[l+1]+=t:i?(n[l]+=e,n[l+1]+=t):n.push(e,t)}function Kl(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||a==n.sections.length||n.sections[a+1]<0);)u=n.sections[a++],f=n.sections[a++];e(l,d,o,m,g),l=d,o=m}}}function tx(n,e,t,i=!1){let l=[],o=i?[]:null,a=new au(n),u=new au(e);for(let f=-1;;){if(a.done&&u.len||u.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&u.ins==-1){let d=Math.min(a.len,u.len);Pn(l,d,-1),a.forward(d),u.forward(d)}else if(u.ins>=0&&(a.ins<0||f==a.i||a.off==0&&(u.len=0&&f=0){let d=0,m=a.len;for(;m;)if(u.ins==-1){let g=Math.min(m,u.len);d+=g,m-=g,u.forward(g)}else if(u.ins==0&&u.lenf||a.ins>=0&&a.len>f)&&(u||i.length>d),o.forward2(f),a.forward(f)}}}}class au{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?ft.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?ft.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Yl{constructor(e,t,i,l){this.from=e,this.to=t,this.flags=i,this.goalColumn=l}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,t=-1){let i,l;return this.empty?i=l=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),l=e.mapPos(this.to,-1)),i==this.from&&l==this.to?this:new Yl(i,l,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return ae.range(e,t,void 0,void 0,i);let l=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return ae.range(this.anchor,l,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ae.range(e.anchor,e.head)}static create(e,t,i,l){return new Yl(e,t,i,l)}}class ae{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:ae.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ae(e.ranges.map(t=>Yl.fromJSON(t)),e.main)}static single(e,t=e){return new ae([ae.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,l=0;ll.from-o.from),t=e.indexOf(i);for(let l=1;lo.head?ae.range(f,u):ae.range(u,f))}}return new ae(e,t)}}function pO(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let vy=0;class Ce{constructor(e,t,i,l,o){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=l,this.id=vy++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new Ce(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:wy),!!e.static,e.enables)}of(e){return new Zh([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Zh(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Zh(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function wy(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class Zh{constructor(e,t,i,l){this.dependencies=e,this.facet=t,this.type=i,this.value=l,this.id=vy++}dynamicSlot(e){var t;let i=this.value,l=this.facet.compareInput,o=this.id,a=e[o]>>1,u=this.type==2,f=!1,d=!1,m=[];for(let g of this.dependencies)g=="doc"?f=!0:g=="selection"?d=!0:(((t=e[g.id])!==null&&t!==void 0?t:1)&1)==0&&m.push(e[g.id]);return{create(g){return g.values[a]=i(g),1},update(g,b){if(f&&b.docChanged||d&&(b.docChanged||b.selection)||nx(g,m)){let v=i(g);if(u?!Kk(v,g.values[a],l):!l(v,g.values[a]))return g.values[a]=v,1}return 0},reconfigure:(g,b)=>{let v,w=b.config.address[o];if(w!=null){let S=fd(b,w);if(this.dependencies.every(C=>C instanceof Ce?b.facet(C)===g.facet(C):C instanceof In?b.field(C,!1)==g.field(C,!1):!0)||(u?Kk(v=i(g),S,l):l(v=i(g),S)))return g.values[a]=S,0}else v=i(g);return g.values[a]=v,1}}}get extension(){return this}}function Kk(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[f.id]),l=t.map(f=>f.type),o=i.filter(f=>!(f&1)),a=n[e.id]>>1;function u(f){let d=[];for(let m=0;mi===l),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(mh).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,l)=>{let o=i.values[t],a=this.updateF(o,l);return this.compareF(o,a)?0:(i.values[t]=a,1)},reconfigure:(i,l)=>{let o=i.facet(mh),a=l.facet(mh),u;return(u=o.find(f=>f.field==this))&&u!=a.find(f=>f.field==this)?(i.values[t]=u.create(i),1):l.config.address[this.id]!=null?(i.values[t]=l.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,mh.of({field:this,create:e})]}get extension(){return this}}const Xs={lowest:4,low:3,default:2,high:1,highest:0};function zc(n){return e=>new gO(e,n)}const so={highest:zc(Xs.highest),high:zc(Xs.high),default:zc(Xs.default),low:zc(Xs.low),lowest:zc(Xs.lowest)};class gO{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Gd{of(e){return new ix(this,e)}reconfigure(e){return Gd.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class ix{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class ud{constructor(e,t,i,l,o,a){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=l,this.staticValues=o,this.facets=a,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let l=[],o=Object.create(null),a=new Map;for(let b of qD(e,t,a))b instanceof In?l.push(b):(o[b.facet.id]||(o[b.facet.id]=[])).push(b);let u=Object.create(null),f=[],d=[];for(let b of l)u[b.id]=d.length<<1,d.push(v=>b.slot(v));let m=i==null?void 0:i.config.facets;for(let b in o){let v=o[b],w=v[0].facet,S=m&&m[b]||[];if(v.every(C=>C.type==0))if(u[w.id]=f.length<<1|1,wy(S,v))f.push(i.facet(w));else{let C=w.combine(v.map(N=>N.value));f.push(i&&w.compare(C,i.facet(w))?i.facet(w):C)}else{for(let C of v)C.type==0?(u[C.id]=f.length<<1|1,f.push(C.value)):(u[C.id]=d.length<<1,d.push(N=>C.dynamicSlot(N)));u[w.id]=d.length<<1,d.push(C=>FD(C,w,v))}}let g=d.map(b=>b(u));return new ud(e,a,g,u,f,o)}}function qD(n,e,t){let i=[[],[],[],[],[]],l=new Map;function o(a,u){let f=l.get(a);if(f!=null){if(f<=u)return;let d=i[f].indexOf(a);d>-1&&i[f].splice(d,1),a instanceof ix&&t.delete(a.compartment)}if(l.set(a,u),Array.isArray(a))for(let d of a)o(d,u);else if(a instanceof ix){if(t.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let d=e.get(a.compartment)||a.inner;t.set(a.compartment,d),o(d,u)}else if(a instanceof gO)o(a.inner,a.prec);else if(a instanceof In)i[u].push(a),a.provides&&o(a.provides,u);else if(a instanceof Zh)i[u].push(a),a.facet.extensions&&o(a.facet.extensions,Xs.default);else{let d=a.extension;if(!d)throw new Error(`Unrecognized extension value in extension set (${a}).`);if(d==a)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(d,u)}}return o(n,Xs.default),i.reduce((a,u)=>a.concat(u))}function Wc(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let l=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|l}function fd(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const xO=Ce.define(),rx=Ce.define({combine:n=>n.some(e=>e),static:!0}),yO=Ce.define({combine:n=>n.length?n[0]:void 0,static:!0}),bO=Ce.define(),vO=Ce.define(),wO=Ce.define(),kO=Ce.define({combine:n=>n.length?n[0]:!1});class cl{constructor(e,t){this.type=e,this.value=t}static define(){return new VD}}class VD{of(e){return new cl(this,e)}}class QD{constructor(e){this.map=e}of(e){return new Ye(this,e)}}class Ye{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new Ye(this.type,t)}is(e){return this.type==e}static define(e={}){return new QD(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let l of e){let o=l.map(t);o&&i.push(o)}return i}}Ye.reconfigure=Ye.define();Ye.appendConfig=Ye.define();class dn{constructor(e,t,i,l,o,a){this.startState=e,this.changes=t,this.selection=i,this.effects=l,this.annotations=o,this.scrollIntoView=a,this._doc=null,this._state=null,i&&pO(i,t.newLength),o.some(u=>u.type==dn.time)||(this.annotations=o.concat(dn.time.of(Date.now())))}static create(e,t,i,l,o,a){return new dn(e,t,i,l,o,a)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(dn.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}dn.time=cl.define();dn.userEvent=cl.define();dn.addToHistory=cl.define();dn.remote=cl.define();function XD(n,e){let t=[];for(let i=0,l=0;;){let o,a;if(i=n[i]))o=n[i++],a=n[i++];else if(l=0;l--){let o=i[l](n);o instanceof dn?n=o:Array.isArray(o)&&o.length==1&&o[0]instanceof dn?n=o[0]:n=CO(e,da(o),!1)}return n}function YD(n){let e=n.startState,t=e.facet(wO),i=n;for(let l=t.length-1;l>=0;l--){let o=t[l](n);o&&Object.keys(o).length&&(i=SO(i,lx(e,o,n.changes.newLength),!0))}return i==n?n:dn.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const GD=[];function da(n){return n==null?GD:Array.isArray(n)?n:[n]}var Pt=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(Pt||(Pt={}));const KD=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let sx;try{sx=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function WD(n){if(sx)return sx.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||KD.test(t)))return!0}return!1}function ZD(n){return e=>{if(!/\S/.test(e))return Pt.Space;if(WD(e))return Pt.Word;for(let t=0;t-1)return Pt.Word;return Pt.Other}}class dt{constructor(e,t,i,l,o,a){this.config=e,this.doc=t,this.selection=i,this.values=l,this.status=e.statusTemplate.slice(),this.computeSlot=o,a&&(a._state=this);for(let u=0;ul.set(d,f)),t=null),l.set(u.value.compartment,u.value.extension)):u.is(Ye.reconfigure)?(t=null,i=u.value):u.is(Ye.appendConfig)&&(t=null,i=da(i).concat(u.value));let o;t?o=e.startState.values.slice():(t=ud.resolve(i,l,this),o=new dt(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(f,d)=>d.reconfigure(f,this),null).values);let a=e.startState.facet(rx)?e.newSelection:e.newSelection.asSingle();new dt(t,e.newDoc,a,o,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:ae.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),l=this.changes(i.changes),o=[i.range],a=da(i.effects);for(let u=1;ua.spec.fromJSON(u,f)))}}return dt.create({doc:e.doc,selection:ae.fromJSON(e.selection),extensions:t.extensions?l.concat([t.extensions]):l})}static create(e={}){let t=ud.resolve(e.extensions||[],new Map),i=e.doc instanceof ft?e.doc:ft.of((e.doc||"").split(t.staticFacet(dt.lineSeparator)||J0)),l=e.selection?e.selection instanceof ae?e.selection:ae.single(e.selection.anchor,e.selection.head):ae.single(0);return pO(l,i.length),t.staticFacet(rx)||(l=l.asSingle()),new dt(t,i,l,t.dynamicSlots.map(()=>null),(o,a)=>a.create(o),null)}get tabSize(){return this.facet(dt.tabSize)}get lineBreak(){return this.facet(dt.lineSeparator)||` -`}get readOnly(){return this.facet(kO)}phrase(e,...t){for(let i of this.facet(dt.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,l)=>{if(l=="$")return"$";let o=+(l||1);return!o||o>t.length?i:t[o-1]})),e}languageDataAt(e,t,i=-1){let l=[];for(let o of this.facet(xO))for(let a of o(this,t,i))Object.prototype.hasOwnProperty.call(a,e)&&l.push(a[e]);return l}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return ZD(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:l}=this.doc.lineAt(e),o=this.charCategorizer(e),a=e-i,u=e-i;for(;a>0;){let f=Sn(t,a,!1);if(o(t.slice(f,a))!=Pt.Word)break;a=f}for(;un.length?n[0]:4});dt.lineSeparator=yO;dt.readOnly=kO;dt.phrases=Ce.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(l=>n[l]==e[l])}});dt.languageData=xO;dt.changeFilter=bO;dt.transactionFilter=vO;dt.transactionExtender=wO;Gd.reconfigure=Ye.define();function Br(n,e,t={}){let i={};for(let l of n)for(let o of Object.keys(l)){let a=l[o],u=i[o];if(u===void 0)i[o]=a;else if(!(u===a||a===void 0))if(Object.hasOwnProperty.call(t,o))i[o]=t[o](u,a);else throw new Error("Config merge conflict for field "+o)}for(let l in e)i[l]===void 0&&(i[l]=e[l]);return i}class ns{eq(e){return this==e}range(e,t=e){return ox.create(e,t,this)}}ns.prototype.startSide=ns.prototype.endSide=0;ns.prototype.point=!1;ns.prototype.mapMode=Kn.TrackDel;function ky(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}let ox=class OO{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new OO(e,t,i)}};function ax(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class Sy{constructor(e,t,i,l){this.from=e,this.to=t,this.value=i,this.maxPoint=l}get length(){return ea(this.to)}findIndex(e,t,i,l=0){let o=i?this.to:this.from;for(let a=l,u=o.length;;){if(a==u)return a;let f=a+u>>1,d=o[f]-e||(i?this.value[f].endSide:this.value[f].startSide)-t;if(f==a)return d>=0?a:u;d>=0?u=f:a=f+1}}between(e,t,i,l){for(let o=this.findIndex(t,-1e9,!0),a=this.findIndex(i,1e9,!1,o);oC||S==C&&b.startSide>0&&b.endSide<=0)continue;if(!((C-S||b.endSide-b.startSide)<0))if(d<0&&(d=S),b.point&&(m=Math.max(m,C-S)),(S-i||b.startSide-l)>=0)a.push(b),u.push(S-d),f.push(C-d),i=C,l=b.endSide;else{if(S==C)for(let N=a.length;N>0;N--){if((S-(f[N-1]+d)||b.startSide-a[N-1].endSide)>=0){a.splice(N,0,b),u.splice(N,0,S-d),f.splice(N,0,C-d);continue e}if((S-(u[N-1]+d)||b.endSide-a[N-1].startSide)>0)break}o(S,C,b)}}return{mapped:a.length?new Sy(u,f,a,m):null,pos:d}}}class it{constructor(e,t,i,l){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=l}static create(e,t,i,l){return new it(e,t,i,l)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:l=0,filterTo:o=this.length}=e,a=e.filter;if(t.length==0&&!a)return this;if(i&&(t=t.slice().sort(ax)),this.isEmpty)return t.length?it.of(t):this;let u=new NO(this,null,-1).goto(0),f=0,d=[],m=new zr;for(;u.value||f=0){let g=t[f++];m.addInner(g.from,g.to,g.value,!1)||d.push(g)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||ou.to||o{o||(o=new zr),o.addRange(f,d,m,!1)};for(let f=0;f=o&&e<=o+a.length&&a.between(o,e-o,t-o,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return cu.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return cu.from(e).goto(t)}static compare(e,t,i,l,o=-1){let a=e.filter(g=>g.maxPoint>0||!g.isEmpty&&g.maxPoint>=o),u=t.filter(g=>g.maxPoint>0||!g.isEmpty&&g.maxPoint>=o),f=Wk(a,u,i),d=new Bc(a,f,o),m=new Bc(u,f,o);i.iterGaps((g,b,v)=>Zk(d,g,m,b,v,l)),i.empty&&i.length==0&&Zk(d,0,m,0,0,l)}static eq(e,t,i=0,l){l==null&&(l=999999999);let o=e.filter(m=>!m.isEmpty&&t.indexOf(m)<0),a=t.filter(m=>!m.isEmpty&&e.indexOf(m)<0);if(o.length!=a.length)return!1;if(!o.length)return!0;let u=Wk(o,a),f=new Bc(o,u,0).goto(i),d=new Bc(a,u,0).goto(i);for(;;){if(f.to!=d.to||!cx(f.active,d.active)||f.point&&(!d.point||!ky(f.point,d.point)))return!1;if(f.to>l)return!0;f.next(),d.next()}}static spans(e,t,i,l,o=-1){let a=new Bc(e,null,o).goto(t),u=t,f=a.openStart;for(;;){let d=Math.min(a.to,i);if(a.point){let m=a.activeForPoint(a.to),g=a.pointFromu&&(l.span(u,d,a.active,f),f=a.openEnd(d));if(a.to>i)return f+(a.point&&a.to>i?1:0);u=a.to,a.next()}}static of(e,t=!1){let i=new zr;for(let l of e instanceof ox?[e]:t?JD(e):e)i.add(l.from,l.to,l.value);return i.finish()}static join(e){if(!e.length)return it.empty;let t=ea(e);for(let i=e.length-2;i>=0;i--)for(let l=e[i];l!=it.empty;l=l.nextLayer)t=new it(l.chunkPos,l.chunk,t,Math.max(l.maxPoint,t.maxPoint));return t}}it.empty=new it([],[],null,-1);function ea(n){return n[n.length-1]}function JD(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(ax);e=i}return n}it.empty.nextLayer=it.empty;class zr{finishChunk(e){this.chunks.push(new Sy(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addRange(e,t,i,!0)}addRange(e,t,i,l){this.addInner(e,t,i,l)||(this.nextLayer||(this.nextLayer=new zr)).addRange(e,t,i,l)}addInner(e,t,i,l){let o=e-this.lastTo||i.startSide-this.last.endSide;if(l&&o<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(it.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=it.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Wk(n,e,t){let i=new Map;for(let o of n)for(let a=0;a=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&l.push(new NO(a,t,i,o));return l.length==1?l[0]:new cu(l)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)Jg(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)Jg(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Jg(this.heap,0)}}}function Jg(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let l=n[i];if(i+1=0&&(l=n[i+1],i++),t.compare(l)<0)break;n[i]=t,n[e]=l,e=i}}class Bc{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=cu.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){ph(this.active,e),ph(this.activeTo,e),ph(this.activeRank,e),this.minActive=Jk(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:l,rank:o}=this.cursor;for(;t0;)t++;gh(this.active,t,i),gh(this.activeTo,t,l),gh(this.activeRank,t,o),e&&gh(e,t,this.cursor.from),this.minActive=Jk(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let l=this.minActive;if(l>-1&&(this.activeTo[l]-this.cursor.from||this.active[l].endSide-this.cursor.startSide)<0){if(this.activeTo[l]>e){this.to=this.activeTo[l],this.endSide=this.active[l].endSide;break}this.removeActive(l),i&&ph(i,l)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[l]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function Zk(n,e,t,i,l,o){n.goto(e),t.goto(i);let a=i+l,u=i,f=i-e,d=!!o.boundChange;for(let m=!1;;){let g=n.to+f-t.to,b=g||n.endSide-t.endSide,v=b<0?n.to+f:t.to,w=Math.min(v,a);if(n.point||t.point?(n.point&&t.point&&ky(n.point,t.point)&&cx(n.activeForPoint(n.to),t.activeForPoint(t.to))||o.comparePoint(u,w,n.point,t.point),m=!1):(m&&(o.boundChange(u),m=!1),w>u&&!cx(n.active,t.active)&&o.compareRange(u,w,n.active,t.active),d&&wa)break;u=v,b<=0&&n.next(),b>=0&&t.next()}}function cx(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function Jk(n,e){let t=-1,i=1e9;for(let l=0;l=e)return l;if(l==n.length)break;o+=n.charCodeAt(l)==9?t-o%t:1,l=Sn(n,l)}return i===!0?-1:n.length}const fx="ͼ",eS=typeof Symbol>"u"?"__"+fx:Symbol.for(fx),hx=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),tS=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class is{constructor(e,t){this.rules=[];let{finish:i}=t||{};function l(a){return/^@/.test(a)?[a]:a.split(/,\s*/)}function o(a,u,f,d){let m=[],g=/^@(\w+)\b/.exec(a[0]),b=g&&g[1]=="keyframes";if(g&&u==null)return f.push(a[0]+";");for(let v in u){let w=u[v];if(/&/.test(v))o(v.split(/,\s*/).map(S=>a.map(C=>S.replace(/&/,C))).reduce((S,C)=>S.concat(C)),w,f);else if(w&&typeof w=="object"){if(!g)throw new RangeError("The value of a property ("+v+") should be a primitive value.");o(l(v),w,m,b)}else w!=null&&m.push(v.replace(/_.*/,"").replace(/[A-Z]/g,S=>"-"+S.toLowerCase())+": "+w+";")}(m.length||b)&&f.push((i&&!g&&!d?a.map(i):a).join(", ")+" {"+m.join(" ")+"}")}for(let a in e)o(l(a),e[a],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=tS[eS]||1;return tS[eS]=e+1,fx+e.toString(36)}static mount(e,t,i){let l=e[hx],o=i&&i.nonce;l?o&&l.setNonce(o):l=new ej(e,o),l.mount(Array.isArray(t)?t:[t],e)}}let nS=new Map;class ej{constructor(e,t){let i=e.ownerDocument||e,l=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&l.CSSStyleSheet){let o=nS.get(i);if(o)return e[hx]=o;this.sheet=new l.CSSStyleSheet,nS.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[hx]=this}mount(e,t){let i=this.sheet,l=0,o=0,a=!1;for(let u=0;u-1&&(this.modules.splice(d,1),a=!0,o--,d=-1),d==-1){if(this.modules.splice(o++,0,f),a=!0,i)for(let m=0;m",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},tj=typeof navigator<"u"&&/Mac/.test(navigator.platform),nj=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var jn=0;jn<10;jn++)rs[48+jn]=rs[96+jn]=String(jn);for(var jn=1;jn<=24;jn++)rs[jn+111]="F"+jn;for(var jn=65;jn<=90;jn++)rs[jn]=String.fromCharCode(jn+32),uu[jn]=String.fromCharCode(jn);for(var e0 in rs)uu.hasOwnProperty(e0)||(uu[e0]=rs[e0]);function ij(n){var e=tj&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||nj&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?uu:rs)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function Ct(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var l=t[i];typeof l=="string"?n.setAttribute(i,l):l!=null&&(n[i]=l)}e++}for(;e2);var we={mac:lS||/Mac/.test(Gn.platform),windows:/Win/.test(Gn.platform),linux:/Linux|X11/.test(Gn.platform),ie:Kd,ie_version:AO?dx.documentMode||6:px?+px[1]:mx?+mx[1]:0,gecko:iS,gecko_version:iS?+(/Firefox\/(\d+)/.exec(Gn.userAgent)||[0,0])[1]:0,chrome:!!t0,chrome_version:t0?+t0[1]:0,ios:lS,android:/Android\b/.test(Gn.userAgent),webkit:rS,webkit_version:rS?+(/\bAppleWebKit\/(\d+)/.exec(Gn.userAgent)||[0,0])[1]:0,safari:gx,safari_version:gx?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Gn.userAgent)||[0,0])[1]:0,tabSize:dx.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Cy(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}const hd=Object.create(null);function Oy(n,e,t){if(n==e)return!0;n||(n=hd),e||(e=hd);let i=Object.keys(n),l=Object.keys(e);if(i.length-0!=l.length-0)return!1;for(let o of i)if(o!=t&&(l.indexOf(o)==-1||n[o]!==e[o]))return!1;return!0}function rj(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function sS(n,e,t){let i=!1;if(e)for(let l in e)t&&l in t||(i=!0,l=="style"?n.style.cssText="":n.removeAttribute(l));if(t)for(let l in t)e&&e[l]==t[l]||(i=!0,l=="style"?n.style.cssText=t[l]:n.setAttribute(l,t[l]));return i}function lj(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new no(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,l;if(e.isBlockGap)i=-5e8,l=4e8;else{let{start:o,end:a}=EO(e,t);i=(o?t?-3e8:-1:5e8)-1,l=(a?t?2e8:1:-6e8)+1}return new no(e,i,l,t,e.widget||null,!0)}static line(e){return new Tu(e)}static set(e,t=!1){return it.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}He.none=it.empty;class Nu extends He{constructor(e){let{start:t,end:i}=EO(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Cy(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||hd}eq(e){return this==e||e instanceof Nu&&this.tagName==e.tagName&&Oy(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Nu.prototype.point=!1;class Tu extends He{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Tu&&this.spec.class==e.spec.class&&Oy(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Tu.prototype.mapMode=Kn.TrackBefore;Tu.prototype.point=!0;class no extends He{constructor(e,t,i,l,o,a){super(t,i,o,e),this.block=l,this.isReplace=a,this.mapMode=l?t<=0?Kn.TrackBefore:Kn.TrackAfter:Kn.TrackDel}get type(){return this.startSide!=this.endSide?Ln.WidgetRange:this.startSide<=0?Ln.WidgetBefore:Ln.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof no&&sj(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}no.prototype.point=!0;function EO(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function sj(n,e){return n==e||!!(n&&e&&n.compare(e))}function ma(n,e,t,i=0){let l=t.length-1;l>=0&&t[l]+i>=n?t[l]=Math.max(t[l],e):t.push(n,e)}class fu extends ns{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof fu&&this.tagName==e.tagName&&Oy(this.attributes,e.attributes)}static create(e){return new fu(e.tagName,e.attributes||hd,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return it.of(e,t)}}fu.prototype.startSide=fu.prototype.endSide=-1;const Cn=n=>n.nodeType==1,Ca=n=>n.nodeType==3;function hu(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function xx(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Zc(n,e){if(!e.anchorNode)return!1;try{return xx(n,e.anchorNode)}catch{return!1}}function Jh(n){return Ca(n)?du(n,0,n.nodeValue.length).getClientRects():Cn(n)?n.getClientRects():[]}function Jc(n,e,t,i){return t?oS(n,e,t,i,-1)||oS(n,e,t,i,1):!1}function ls(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function dd(n){return Cn(n)&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function oS(n,e,t,i,l){for(;;){if(n==t&&e==i)return!0;if(e==(l<0?0:sl(n))){if(n.nodeName=="DIV")return!1;let o=n.parentNode;if(!o||!Cn(o))return!1;e=ls(n)+(l<0?0:1),n=o}else if(Cn(n)){if(n=n.childNodes[e+(l<0?-1:0)],Cn(n)&&(n.nodeName=="IMG"||n.nodeName=="BR"||n.contentEditable=="false"))return!1;e=l<0?sl(n):0}else return!1}}function sl(n){return Ca(n)?n.nodeValue.length:n.childNodes.length}function md(n,e){let{left:t,right:i}=n;if(t==i)return n;let l=e?t:i;return{left:l,right:l,top:n.top,bottom:n.bottom}}function oj(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function MO(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function aj(n,e,t,i,l,o,a,u){let f=n.ownerDocument,d=f.defaultView||window;for(let m=n,g=!1;m&&!g;)if(Cn(m)){let b,v=m==f.body,w=1,S=1,C=!0,N=!0;if(v)b=oj(d);else{let I=getComputedStyle(m);if(/^(fixed|sticky)$/.test(I.position)&&(g=!0),(m.scrollHeight<=m.clientHeight||!/auto|scroll/.test(I.overflowY))&&(N=!1),(m.scrollWidth<=m.clientWidth||!/auto|scroll/.test(I.overflowX))&&(C=!1),!C&&!N){m=m.assignedSlot||m.parentNode;continue}let U=m.getBoundingClientRect();({scaleX:w,scaleY:S}=MO(m,U)),b={left:U.left,right:U.left+m.clientWidth*w,top:U.top,bottom:U.top+m.clientHeight*S}}let R=0,M=0;if(N)if(l=="nearest")e.top0&&e.bottom>b.bottom+M&&(M=e.bottom-b.bottom+a)):e.bottom>b.bottom-a&&(M=e.bottom-b.bottom+a,t<0&&e.top-M0&&e.right>b.right+R&&(R=e.right-b.right+o)):e.right>b.right-o&&(R=e.right-b.right+o,t<0&&e.leftb.bottom||e.leftb.right)&&(e={left:Math.max(e.left,b.left),right:Math.min(e.right,b.right),top:Math.max(e.top,b.top),bottom:Math.min(e.bottom,b.bottom)}),m=m.assignedSlot||m.parentNode}else if(m.nodeType==11)m=m.host;else break}function DO(n,e=!0){let t=n.ownerDocument,i=null,l=null;for(let o=n.parentNode;o&&!(o==t.body||(!e||i)&&l);)if(Cn(o))!l&&o.scrollHeight>o.clientHeight&&/scroll|auto/.test(getComputedStyle(o).overflowY)&&(l=o),e&&!i&&o.scrollWidth>o.clientWidth&&/scroll|auto/.test(getComputedStyle(o).overflowX)&&(i=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:i,y:l}}class cj{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?sl(t):0),i,Math.min(e.focusOffset,i?sl(i):0))}set(e,t,i,l){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=l}}function jO(n){let e=[];for(let t=n;t;t=t.nodeType==11?t.host:t.parentNode)Cn(t)&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function RO(n,e=!0){for(let{node:t,left:i,top:l}of n)e&&t.scrollTop!=l&&(t.scrollTop=l),t.scrollLeft!=i&&(t.scrollLeft=i)}let Vs=null;we.safari&&we.safari_version>=26&&(Vs=!1);function _O(n){if(n.setActive)return n.setActive();if(Vs)return n.focus(Vs);let e=jO(n);n.focus(Vs==null?{get preventScroll(){return Vs={preventScroll:!0},!0}}:void 0),Vs||(Vs=!1,RO(e))}let aS;function du(n,e,t=e){let i=aS||(aS=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function pa(n,e,t,i){let l={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:l.altKey,ctrlKey:l.ctrlKey,shiftKey:l.shiftKey,metaKey:l.metaKey}=i);let o=new KeyboardEvent("keydown",l);o.synthetic=!0,n.dispatchEvent(o);let a=new KeyboardEvent("keyup",l);return a.synthetic=!0,n.dispatchEvent(a),o.defaultPrevented||a.defaultPrevented}function uj(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function fj(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,sl(t));;)if(i){if(!Cn(t))return!1;let l=t.childNodes[i-1];l.contentEditable=="false"?i--:(t=l,i=sl(t))}else{if(t==n)return!0;i=ls(t),t=t.parentNode}}function LO(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function zO(n,e){for(let t=n,i=e;;){if(Ca(t)&&i>0)return{node:t,offset:i};if(Cn(t)&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=sl(t)}else if(t.parentNode&&!dd(t))i=ls(t),t=t.parentNode;else return null}}function BO(n,e){for(let t=n,i=e;;){if(Ca(t)&&i=t){if(u.level==i)return a;(o<0||(l!=0?l<0?u.fromt:e[o].level>u.level))&&(o=a)}}if(o<0)throw new RangeError("Index out of range");return o}}function IO(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;S-=3)if(kr[S+1]==-v){let C=kr[S+2],N=C&2?l:C&4?C&1?o:l:0;N&&(Et[g]=Et[kr[S]]=N),u=S;break}}else{if(kr.length==189)break;kr[u++]=g,kr[u++]=b,kr[u++]=f}else if((w=Et[g])==2||w==1){let S=w==l;f=S?0:1;for(let C=u-3;C>=0;C-=3){let N=kr[C+2];if(N&2)break;if(S)kr[C+2]|=2;else{if(N&4)break;kr[C+2]|=4}}}}}function xj(n,e,t,i){for(let l=0,o=i;l<=t.length;l++){let a=l?t[l-1].to:n,u=lf;)w==C&&(w=t[--S].from,C=S?t[S-1].to:n),Et[--w]=v;f=m}else o=d,f++}}}function bx(n,e,t,i,l,o,a){let u=i%2?2:1;if(i%2==l%2)for(let f=e,d=0;ff&&a.push(new Dr(f,S.from,v));let C=S.direction==Oa!=!(v%2);vx(n,C?i+1:i,l,S.inner,S.from,S.to,a),f=S.to}w=S.to}else{if(w==t||(m?Et[w]!=u:Et[w]==u))break;w++}b?bx(n,f,w,i+1,l,b,a):fe;){let m=!0,g=!1;if(!d||f>o[d-1].to){let S=Et[f-1];S!=u&&(m=!1,g=S==16)}let b=!m&&u==1?[]:null,v=m?i:i+1,w=f;e:for(;;)if(d&&w==o[d-1].to){if(g)break e;let S=o[--d];if(!m)for(let C=S.from,N=d;;){if(C==e)break e;if(N&&o[N-1].to==C)C=o[--N].from;else{if(Et[C-1]==u)break e;break}}if(b)b.push(S);else{S.toEt.length;)Et[Et.length]=256;let i=[],l=e==Oa?0:1;return vx(n,l,l,t,0,n.length,i),i}function UO(n){return[new Dr(0,n,0)]}let FO="";function bj(n,e,t,i,l){var o;if(!n.length)return null;let a=i.head-n.from,u;if(i.head==n.from&&i.assoc<0){if(!l)return null;a=e[u=0].side(!1,t)}else if(i.head==n.to&&i.assoc>0){if(l)return null;a=e[u=e.length-1].side(!0,t)}else u=Dr.find(e,a,(o=i.bidiLevel)!==null&&o!==void 0?o:-1,i.assoc);let f=e[u],d=f.side(l,t);if(a==d){let b=u+=l?1:-1;if(b<0||b>=e.length)return null;f=e[u=b],a=f.side(!l,t),d=f.side(l,t)}let m=Sn(n.text,a,f.forward(l,t));(mf.to)&&(m=d),FO=n.text.slice(Math.min(a,m),Math.max(a,m));let g=u==(l?e.length-1:0)?null:e[u+(l?1:-1)];if(m==d){if(!g)return l?ae.cursor(n.to,1):ae.cursor(n.from,-1);if(g.level+(l?0:1)n.some(e=>e)}),KO=Ce.define({combine:n=>n.some(e=>e)}),WO=Ce.define();class ga{constructor(e,t,i,l,o,a=!1){this.range=e,this.y=t,this.x=i,this.yMargin=l,this.xMargin=o,this.isSnapshot=a}map(e){return e.empty?this:new ga(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ga(ae.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const xh=Ye.define({map:(n,e)=>n.map(e)}),ZO=Ye.define();function di(n,e,t){let i=n.facet(XO);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const il=Ce.define({combine:n=>n.length?n[0]:!0});let wj=0;const aa=Ce.define({combine(n){return n.filter((e,t)=>{for(let i=0;i{let f=[];return a&&f.push(Wd.of(d=>{let m=d.plugin(u);return m?a(m):He.none})),o&&f.push(o(u)),f})}static fromClass(e,t){return Jt.define((i,l)=>new e(i,l),t)}}class n0{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(di(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){di(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){di(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const JO=Ce.define(),Ey=Ce.define(),Wd=Ce.define(),eN=Ce.define(),My=Ce.define(),Au=Ce.define(),tN=Ce.define();function cS(n,e){let t=n.state.facet(tN);if(!t.length)return t;let i=t.map(o=>o instanceof Function?o(n):o),l=[];return it.spans(i,e.from,e.to,{point(){},span(o,a,u,f){let d=o-e.from,m=a-e.from,g=l;for(let b=u.length-1;b>=0;b--,f--){let v=u[b].spec.bidiIsolate,w;if(f>0&&g.length&&(w=g[g.length-1]).to==d&&w.direction==v)w.to=m,g=w.inner;else{let S={from:d,to:m,direction:v,inner:[]};g.push(S),g=S.inner}}}}),nN(e.text,l)}function nN(n,e){for(let t of e){if(t.direction==null){for(let i=t.from,l=0;i0;t--){let l=e[t-1];if(!(l.fromA>i.toA)){if(l.toAl.push(new Ii(o,a,u,f))),this.changedRanges=l}static create(e,t,i){return new pd(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const kj=[];class Yt{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return kj}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&rj(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let l of this.children){if(l==e)return i;i+=l.length+l.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=ls(this.dom),l=this.length?e>0:t>0;return new er(this.parent.dom,i+(l?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Jd)return e;return null}static get(e){return e.cmTile}}class Zd extends Yt{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,l,o=(e==null?void 0:e.node)==t?e:null,a=0;for(let u of this.children){if(u.sync(e),a+=u.length+u.breakAfter,l=i?i.nextSibling:t.firstChild,o&&l!=u.dom&&(o.written=!0),u.dom.parentNode==t)for(;l&&l!=u.dom;)l=uS(l);else t.insertBefore(u.dom,l);i=u.dom}for(l=i?i.nextSibling:t.firstChild,o&&l&&(o.written=!0);l;)l=uS(l);this.length=a}}function uS(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Jd extends Zd{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Yt.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,l=0,o=0;;)if(l==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&o++,l=t.pop()}else{let a=i.children[l++];if(a instanceof rl)t.push(l),i=a,l=0;else{let u=o+a.length,f=e(a,o);if(f!==void 0)return f;o=u+a.breakAfter}}}resolveBlock(e,t){let i,l=-1,o,a=-1;if(this.blockTiles((u,f)=>{let d=f+u.length;if(e>=f&&e<=d){if(u.isWidget()&&t>=-1&&t<=1){if(u.flags&32)return!0;u.flags&16&&(i=void 0)}(fe||e==f&&(t>1?u.length:u.covers(-1)))&&(!o||!u.isWidget()&&o.isWidget())&&(o=u,a=e-f)}}),!i&&!o)throw new Error("No tile at position "+e);return i&&t<0||!o?{tile:i,offset:l}:{tile:o,offset:a}}}class rl extends Zd{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new rl(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Na extends Zd{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let l=new Na(t||document.createElement("div"),e);return(!t||!i)&&(l.flags|=4),l}get domAttrs(){return this.attrs}resolveInline(e,t,i=!1){let l=null,o=-1,a=null,u=-1;function f(m,g){for(let b=0,v=0;b=g&&(w.isComposite()?f(w,g-v):(!a||i&&a.isHidden&&(t>0&&!(a.flags&32)||i&&Cj(a,w)))&&(S>g||w.flags&32&&t<=1)?(a=w,u=g-v):(v=-1)&&(l=w,o=g-v)),v=S}}f(this,e);let d=(t<0?l:a)||l||a;return d?{tile:d,offset:d==l?o:u}:null}coordsIn(e,t,i){let l=this.resolveInline(e,t,!0);return l?l.tile.coordsIn(Math.max(0,l.offset),t,i):Sj(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:l,offset:o}=i;if(this.dom.contains(l.dom))return l.isText()?new er(l.dom,Math.min(l.dom.nodeValue.length,o)):l.domPosFor(o,l.flags&16?1:l.flags&32?-1:t);let a=i.tile.parent,u=!1;for(let f of a.children){if(u)return new er(f.dom,0);f==i.tile&&(u=!0)}}return new er(this.dom,0)}}function Sj(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=Jh(e);return t[t.length-1]||null}function Cj(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.topl&&(e=l);let o=e,a=e,u=0;e==0&&t<0||e==l&&t>=0?we.chrome||we.gecko||(e?(o--,u=1):a=0)?0:f.length-1];return we.safari&&!u&&d.width==0&&(d=Array.prototype.find.call(f,m=>m.width)||d),i==null?d:md(d,(u?u>0:t<0)==i)}static of(e,t){let i=new Gs(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class io extends Yt{constructor(e,t,i,l){super(e,t,l),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let l=this.widget.coordsAt(this.dom,e,t);if(l)return l;if(i)return md(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let o=this.dom.getClientRects(),a=null;if(!o.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?o.length-1:0;a=o[f],!(e>0?f==0:f==o.length-1||a.top0==i)}}class Oj{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:l,index:o,beforeBreak:a,parents:u}=this;for(;e||t>0;)if(l.isComposite())if(a){if(!e)break;i&&i.break(),e--,a=!1}else if(o==l.children.length){if(!e&&!u.length)break;i&&i.leave(l),a=!!l.breakAfter,{tile:l,index:o}=u.pop(),o++}else{let f=l.children[o],d=f.breakAfter;(t>0?f.length<=e:f.length=0;u--){let f=t.marks[u],d=l.lastChild;if(d instanceof hi&&d.mark.eq(f.mark))d.dom!=f.dom&&d.setDOM(i0(f.dom)),l=d;else{let{dom:m}=f;this.cache.reused.get(f)&&Yt.get(f.dom)&&(m=i0(f.dom));let g=hi.of(f.mark,m);l.append(g),l=g}this.cache.reused.set(f,2)}let o=Yt.get(e.text);o&&this.cache.reused.set(o,2);let a=new Gs(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,l.append(a)}addInlineWidget(e,t,i){let l=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);l||this.flushBuffer();let o=this.ensureMarks(t,i);!l&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=rN);let l=Na.start(e,t||((i=this.cache.find(Na))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=l)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let l=this.curLine;for(let o=e.length-1;o>=0;o--){let a=e[o],u;if(t>0&&(u=l.lastChild)&&u instanceof hi&&u.mark.eq(a))l=u,t--;else{let f=hi.of(a,(i=this.cache.find(hi,d=>d.mark.eq(a)))===null||i===void 0?void 0:i.dom);l.append(f),l=f,t=0}}return l}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!fS(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(we.ios&&fS(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(r0,0,32)||new io(r0.toDOM(),0,r0,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let t=e.rank*102+e.value.rank,i=new Nj(e.from,e.to,e.value,t),l=this.wrappers.length;for(;l>0&&(this.wrappers[l-1].rank-i.rank||this.wrappers[l-1].to-i.to)<0;)l--;this.wrappers.splice(l,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let l=t.lastChild;if(i.froma.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(o),t=o}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(gd,void 0,1);return i&&(i.flags=t),i||new gd(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class Aj{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:l,lineBreak:o,done:a}=this.cursor.next(this.skipCount);if(this.skipCount=0,a)throw new Error("Ran out of text content when drawing inline views");this.text=l;let u=this.textOff=Math.min(e,l.length);return o?null:l.slice(0,u)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const xd=[io,Na,Gs,hi,gd,rl,Jd];for(let n=0;n[]),this.index=xd.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let l=e.bucket,o=this.buckets[l],a=this.index[l];for(let u=0;u{if(this.cache.add(a),a.isComposite())return!1},enter:a=>this.cache.add(a),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let l=0,o=0,a=0;;){let u=al){let d=f-l;this.preserve(d,!a,!u),l=f,o+=d}if(!u)break;t&&u.fromA<=t.range.fromA&&u.toA>=t.range.toA?(this.forward(u.fromA,t.range.fromA,t.range.fromA{if(a.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let d=f>0||u{a.isLine()?this.builder.addLineStart(a.attrs,this.cache.maybeReuse(a)):(this.cache.add(a),a instanceof hi&&l.unshift(a.mark)),this.openWidget=!1},leave:a=>{a.isLine()?l.length&&(l.length=o=0):a instanceof hi&&(l.shift(),o=Math.min(o,l.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,l=this.builder,o=-1,a=it.spans(this.decorations,e,t,{point:(u,f,d,m,g,b)=>{if(d instanceof no){if(this.disallowBlockEffectsFor[b]){if(d.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=m.length,g>m.length)l.continueWidget(f-u);else{let v=d.widget||(d.block?Ta.block:Ta.inline),w=Dj(d),S=this.cache.findWidget(v,f-u,w)||io.of(v,this.view,f-u,w);d.block?(d.startSide>0&&l.addLineStartIfNotCovered(i),l.addBlockWidget(S)):(l.ensureLine(i),l.addInlineWidget(S,m,g))}i=null}else i=jj(i,d);f>u&&this.text.skip(f-u)},span:(u,f,d,m)=>{for(let g=u;g-1&&(this.openWidget=a>o),this.openWidget||l.addLineStartIfNotCovered(i),this.openMarks=a}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let l=e.parentNode;;l=l.parentNode){let o=Yt.get(l);if(l==this.view.contentDOM)break;o instanceof hi?t.push(o):o!=null&&o.isLine()?i=o:o instanceof rl||(l.nodeName=="DIV"&&!i?i=new Na(l,rN):i||t.push(hi.of(new Nu({tagName:l.nodeName.toLowerCase(),attributes:lj(l)}),l)))}return i?{line:i,marks:t}:null}}function fS(n,e){let t=i=>{for(let l of i.children)if((e?l.isText():l.length)||t(l))return!0;return!1};return t(n)}function Dj(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}const rN={class:"cm-line"};function jj(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&Cy(t,n),i&&(n.class+=" "+i)),n}function Rj(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof hi&&e.push(i.mark)}return e}function i0(n){let e=Yt.get(n);return e&&e.setDOM(n.cloneNode()),n}class Ta extends ul{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Ta.inline=new Ta("span");Ta.block=new Ta("div");const r0=new class extends ul{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class hS{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=He.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Jd(e,e.contentDOM),this.updateInner([new Ii(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:m,toA:g})=>gthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let l=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?l=this.domChanged.newSel.head:!Fj(e.changes,this.hasComposition)&&!e.selectionSet&&(l=e.state.selection.main.head));let o=l>-1?Lj(this.view,e.changes,l):null;if(this.domChanged=null,this.hasComposition){let{from:m,to:g}=this.hasComposition;i=new Ii(m,g,e.changes.mapPos(m,-1),e.changes.mapPos(g,1)).addToSet(i.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(we.ie||we.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,u=this.blockWrappers;this.updateDeco();let f=Pj(a,this.decorations,e.changes);f.length&&(i=Ii.extendWithRanges(i,f));let d=Ij(u,this.blockWrappers,e.changes);return d.length&&(i=Ii.extendWithRanges(i,d)),o&&!i.some(m=>m.fromA<=o.range.fromA&&m.toA>=o.range.toA)&&(i=o.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let a=this.tile,u=new Mj(this.view,a,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Yt.get(t.text)&&u.cache.reused.set(Yt.get(t.text),2),this.tile=u.run(e,t),kx(a,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=we.chrome||we.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||i.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let l=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Zc(i,this.view.observer.selectionRange)&&!(l&&i.contains(l));if(!(o||t||a))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,d,m;if(f.empty?m=d=this.inlineDOMNearPos(f.anchor,f.assoc||1):(m=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),d=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),we.gecko&&f.empty&&!this.hasComposition&&_j(d)){let b=document.createTextNode("");this.view.observer.ignore(()=>d.node.insertBefore(b,d.node.childNodes[d.offset]||null)),d=m=new er(b,0),u=!0}let g=this.view.observer.selectionRange;(u||!g.focusNode||(!Jc(d.node,d.offset,g.anchorNode,g.anchorOffset)||!Jc(m.node,m.offset,g.focusNode,g.focusOffset))&&!this.suppressWidgetCursorChange(g,f))&&(this.view.observer.ignore(()=>{we.android&&we.chrome&&i.contains(g.focusNode)&&Uj(g.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let b=hu(this.view.root);if(b)if(f.empty){if(we.gecko){let v=zj(d.node,d.offset);if(v&&v!=3){let w=(v==1?zO:BO)(d.node,d.offset);w&&(d=new er(w.node,w.offset))}}b.collapse(d.node,d.offset),f.bidiLevel!=null&&b.caretBidiLevel!==void 0&&(b.caretBidiLevel=f.bidiLevel)}else if(b.extend){b.collapse(d.node,d.offset);try{b.extend(m.node,m.offset)}catch{}}else{let v=document.createRange();f.anchor>f.head&&([d,m]=[m,d]),v.setEnd(m.node,m.offset),v.setStart(d.node,d.offset),b.removeAllRanges(),b.addRange(v)}a&&this.view.root.activeElement==i&&(i.blur(),l&&l.focus())}),this.view.observer.setSelectionRange(d,m)),this.impreciseAnchor=d.precise?null:new er(g.anchorNode,g.anchorOffset),this.impreciseHead=m.precise?null:new er(g.focusNode,g.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Jc(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=hu(e.root),{anchorNode:l,anchorOffset:o}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let u=a.posAtStart;if(t.head==u||t.head==u+a.length)return;let f=this.coordsAt(t.head,-1),d=this.coordsAt(t.head,1);if(!f||!d||f.bottom>d.top)return;let m=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(m.node,m.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let g=e.observer.selectionRange;e.docView.posFromDOM(g.anchorNode,g.anchorOffset)!=t.from&&i.collapse(l,o)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let l=i.posAtStart;if(i.isComposite()){let o;if(e==i.dom)o=i.dom.childNodes[t];else{let a=sl(e)==0?0:t==0?-1:1;for(;;){let u=e.parentNode;if(u==i.dom)break;a==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?a=-1:a=1),e=u}a<0?o=e:o=e.nextSibling}if(o==i.dom.firstChild)return l;for(;o&&!Yt.get(o);)o=o.nextSibling;if(!o)return l+i.length;for(let a=0,u=l;;a++){let f=i.children[a];if(f.dom==o)return u;u+=f.length+f.breakAfter}}else return i.isText()?e==i.dom?l+t:l+(t?i.length:0):l}domAtPos(e,t){let{tile:i,offset:l}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(l,t):i.domIn(l,t)}inlineDOMNearPos(e,t){let i,l=-1,o=!1,a,u=-1,f=!1;return this.tile.blockTiles((d,m)=>{if(d.isWidget()){if(d.flags&32&&m>=e)return!0;d.flags&16&&(o=!0)}else{let g=m+d.length;if(m<=e&&(i=d,l=e-m,o=g=e&&!a&&(a=d,u=e-m,f=m>e),m>e&&a)return!0}}),!i&&!a?this.domAtPos(e,t):(o&&a?i=null:f&&i&&(a=null),i&&t<0||!a?i.domIn(l,t):a.domIn(u,t))}coordsAt(e,t,i){let{tile:l,offset:o}=this.tile.resolveBlock(e,t);return l.isWidget()?l.widget instanceof l0?null:l.coordsInWidget(o,t,!0):l.coordsIn(o,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function l(o,a){if(o.isComposite())for(let u of o.children){if(u.length>=a){let f=l(u,a);if(f)return f}if(a-=u.length,a<0)break}else if(o.isText()&&aMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Ot.LTR,d=0,m=(g,b,v)=>{for(let w=0;wl);w++){let S=g.children[w],C=b+S.length,N=S.dom.getBoundingClientRect(),{height:R}=N;if(v&&!w&&(d+=N.top-v.top),S instanceof rl)C>i&&m(S,b,N);else if(b>=i&&(d>0&&t.push(-d),t.push(R+d),d=0,a)){let M=S.dom.lastChild,I=M?Jh(M):[];if(I.length){let U=I[I.length-1],E=f?U.right-N.left:N.right-U.left;E>u&&(u=E,this.minWidth=o,this.minWidthFrom=b,this.minWidthTo=C)}}v&&w==g.children.length-1&&(d+=v.bottom-N.bottom),b=C+S.breakAfter}};return m(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?Ot.RTL:Ot.LTR}measureTextSize(){let e=this.tile.blockTiles(a=>{if(a.isLine()&&a.children.length&&a.length<=20){let u=0,f;for(let d of a.children){if(!d.isText()||/[^ -~]/.test(d.text))return;let m=Jh(d.dom);if(m.length!=1)return;u+=m[0].width,f=m[0].height}if(u)return{lineHeight:a.dom.getBoundingClientRect().height,charWidth:u/a.length,textHeight:f}}});if(e)return e;let t=document.createElement("div"),i,l,o;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let a=Jh(t.firstChild)[0];i=t.getBoundingClientRect().height,l=a&&a.width?a.width/27:7,o=a&&a.height?a.height:i,t.remove()}),{lineHeight:i,charWidth:l,textHeight:o}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,l=0;;l++){let o=l==t.viewports.length?null:t.viewports[l],a=o?o.from-1:this.view.state.doc.length;if(a>i){let u=(t.lineBlockAt(a).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(He.replace({widget:new l0(u),block:!0,inclusive:!0,isBlockGap:!0}).range(i,a))}if(!o)break;i=o.to+1}return He.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Wd).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),i=!1,l=this.view.state.facet(My).map((o,a)=>{let u=typeof o=="function";return u&&(i=!0),u?o(this.view):o});for(l.length&&(this.dynamicDecorationMap[e++]=i,t.push(it.join(l))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof o=="function"?o(this.view):o)}scrollIntoView(e){if(e.isSnapshot){let d=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=d.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let d of this.view.state.facet(WO))try{if(d(this.view,e.range,e))return!0}catch(m){di(this.view.state,m,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),l;if(!i)return;!t.empty&&(l=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,l.left),top:Math.min(i.top,l.top),right:Math.max(i.right,l.right),bottom:Math.max(i.bottom,l.bottom)});let o=Dy(this.view),a={left:i.left-o.left,top:i.top-o.top,right:i.right+o.right,bottom:i.bottom+o.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(aj(this.view.scrollDOM,a,t.head1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottomi.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){kx(this.tile)}}function kx(n,e){let t=e==null?void 0:e.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)kx(i,e)}}function _j(n){return Cn(n.node)&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function lN(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=zO(t.focusNode,t.focusOffset),l=BO(t.focusNode,t.focusOffset),o=i||l;if(l&&i&&l.node!=i.node){let u=Yt.get(l.node);if(!u||u.isText()&&u.text!=l.node.nodeValue)o=l;else if(n.docView.lastCompositionAfterCursor){let f=Yt.get(i.node);!f||f.isText()&&f.text!=i.node.nodeValue||(o=l)}}if(n.docView.lastCompositionAfterCursor=o!=i,!o)return null;let a=e-o.offset;return{from:a,to:a+o.node.nodeValue.length,node:o.node}}function Lj(n,e,t){let i=lN(n,t);if(!i)return null;let{node:l,from:o,to:a}=i,u=l.nodeValue;if(/[\n\r]/.test(u)||n.state.doc.sliceString(i.from,i.to)!=u)return null;let f=e.invertedDesc;return{range:new Ii(f.mapPos(o),f.mapPos(a),o,a),text:l}}function zj(n,e){return Cn(n)?(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}class l0 extends ul{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function qj(n,e,t=1){let i=n.charCategorizer(e),l=n.doc.lineAt(e),o=e-l.from;if(l.length==0)return ae.cursor(e);o==0?t=1:o==l.length&&(t=-1);let a=o,u=o;t<0?a=Sn(l.text,o,!1):u=Sn(l.text,o);let f=i(l.text.slice(a,u));for(;a>0;){let d=Sn(l.text,a,!1);if(i(l.text.slice(d,a))!=f)break;a=d}for(;un.defaultLineHeight*1.5){let u=n.viewState.heightOracle.textHeight,f=Math.floor((l-t.top-(n.defaultLineHeight-u)*.5)/u);o+=f*n.viewState.heightOracle.lineLength}let a=n.state.sliceDoc(t.from,t.to);return t.from+ux(a,o,n.state.tabSize)}function Sx(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let l;for(let o of i.type){if(o.from>e)break;if(!(o.toe)return o;(!l||o.type==Ln.Text&&(l.type!=o.type||(t<0?o.frome)))&&(l=o)}}return l||i}return i}function Qj(n,e,t,i){let l=Sx(n,e.head,e.assoc||-1),o=!i||l.type!=Ln.Text||!(n.lineWrapping||l.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>l.from?e.head-1:e.head);if(o){let a=n.dom.getBoundingClientRect(),u=n.textDirectionAt(l.from),f=n.posAndSideAtCoords({x:t==(u==Ot.LTR)?a.right-1:a.left+1,y:(o.top+o.bottom)/2});if(f)return ae.cursor(f.pos,f.assoc)}return ae.cursor(t?l.to:l.from,t?1:-1)}function dS(n,e,t,i){let l=n.state.doc.lineAt(e.head),o=n.bidiSpans(l),a=n.textDirectionAt(l.from);for(let u=e,f=null;;){let d=bj(l,o,a,u,t),m=FO;if(!d){if(l.number==(t?n.state.doc.lines:1))return u;m=` -`,l=n.state.doc.line(l.number+(t?1:-1)),o=n.bidiSpans(l),d=t?ae.cursor(l.from,-1):ae.cursor(l.to,1)}if(f){if(!f(m))return u}else{if(!i)return d;f=i(m)}u=d}}function Xj(n,e,t){let i=n.state.charCategorizer(e),l=i(t);return o=>{let a=i(o);return l==Pt.Space&&(l=a),l==a}}function $j(n,e,t,i){let l=e.head,o=t?1:-1;if(l==(t?n.state.doc.length:0))return ae.cursor(l,e.assoc);let a=e.goalColumn,u,f=n.contentDOM.getBoundingClientRect(),d=n.coordsAtPos(l,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),m=n.documentTop;if(d)a==null&&(a=d.left-f.left),u=o<0?d.top:d.bottom;else{let w=n.viewState.lineBlockAt(l);a==null&&(a=Math.min(f.right-f.left,n.defaultCharacterWidth*(l-w.from))),u=(o<0?w.top:w.bottom)+m}let g=f.left+a,b=n.viewState.heightOracle.textHeight>>1,v=i??b;for(let w=0;;w+=b){let S=u+(v+w)*o,C=Cx(n,{x:g,y:S},!1,o);if(t?S>f.bottom:Su:R{if(e>o&&el(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:ae.cursor(i,in.viewState.docHeight)return new Mr(n.state.doc.length,-1);if(d=n.elementAtHeight(f),i==null)break;if(d.type==Ln.Text){if(i<0?d.ton.viewport.to)break;let b=n.docView.coordsAt(i<0?d.from:d.to,i>0?-1:1);if(b&&(i<0?b.top<=f+o:b.bottom>=f+o))break}let g=n.viewState.heightOracle.textHeight/2;f=i>0?d.bottom+g:d.top-g}if(n.viewport.from>=d.to||n.viewport.to<=d.from){if(t)return null;if(d.type==Ln.Text){let g=Vj(n,l,d,a,u);return new Mr(g,g==d.from?1:-1)}}if(d.type!=Ln.Text)return f<(d.top+d.bottom)/2?new Mr(d.from,1):new Mr(d.to,-1);let m=n.docView.lineAt(d.from,2);return(!m||m.length!=d.length)&&(m=n.docView.lineAt(d.from,-2)),new Yj(n,a,u,n.textDirectionAt(d.from)).scanTile(m,d.from)}class Yj{constructor(e,t,i,l){this.view=e,this.x=t,this.y=i,this.baseDir=l,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+l.from>1;t:if(a.has(S)){for(let R=1;R=o&&(M-=w),!a.has(M)){S=M;break t}}break e}a.add(S);let C=t(S),N=0;if(C)for(let R=0;R1))if(M.bottomthis.y)(!d||d.top>M.top)&&(d=M),N=-1;else{let I=M.left>this.x?this.x-M.left:M.right(w+w+S)/3)return this.y=f.bottom-1,this.scan(e,t,!0);if(d&&d.top<(w+S+S)/3)return this.y=d.top+1,this.scan(e,t,!0)}let v=(u?this.dirAt(e[m],1):this.baseDir)==Ot.LTR;return{i:m,after:this.x>(b.left+b.right)/2==v}}scanText(e,t){let i=[];for(let o=0;o{let a=i[o]-t,u=i[o+1]-t;return du(e.dom,a,u).getClientRects()});return l.after?new Mr(i[l.i+1],-1):new Mr(i[l.i],1)}scanTile(e,t){if(!e.length)return new Mr(t,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,t);if(u.isComposite())return this.scanTile(u,t)}let i=[t];for(let u=0,f=t;u{let f=e.children[u];return f.flags&48?null:(Cn(f.dom)?f.dom:du(f.dom,0,f.length)).getClientRects()}),o=e.children[l.i],a=i[l.i];return o.isText()?this.scanText(o,a):o.isComposite()?this.scanTile(o,a):l.after?new Mr(i[l.i+1],-1):new Mr(a,1)}}const ta="￿";class Gj{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(dt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ta}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let l=e;;){this.findPointBefore(i,l);let o=this.text.length;this.readNode(l);let a=Yt.get(l),u=l.nextSibling;if(u==t){a!=null&&a.breakAfter&&!u&&i!=this.view.contentDOM&&this.lineBreak();break}let f=Yt.get(u);(a&&f?a.breakAfter:(a?a.breakAfter:dd(l))||dd(u)&&(l.nodeName!="BR"||a!=null&&a.isWidget())&&this.text.length>o)&&!Wj(u,t)&&this.lineBreak(),l=u}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,l=this.lineSeparator?null:/\r\n?|\n/g;;){let o=-1,a=1,u;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,i),a=this.lineSeparator.length):(u=l.exec(t))&&(o=u.index,a=u[0].length),this.append(t.slice(i,o<0?t.length:o)),o<0)break;if(this.lineBreak(),a>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=a-1);i=o+a}}readNode(e){let t=Yt.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let l=i.iter();!l.next().done;)l.lineBreak?this.lineBreak():this.append(l.value)}else Ca(e)?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():Cn(e)&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(Ca(e)?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(Kj(e,i.node,i.offset)?t:0))}}function Kj(n,e,t){for(;;){if(!e||t-1;let{impreciseHead:o,impreciseAnchor:a}=e.docView,u=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=oN(e.docView.tile,t,i,0))){let f=o||a?[]:eR(e),d=new Gj(f,e);d.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=d.text,this.newSel=tR(f,this.bounds.from)}else{let f=e.observer.selectionRange,d=o&&o.node==f.focusNode&&o.offset==f.focusOffset||!xx(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),m=a&&a.node==f.anchorNode&&a.offset==f.anchorOffset||!xx(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),g=e.viewport;if((we.ios||we.chrome)&&d!=m&&Math.min(d,m)<=u.main.from&&Math.max(d,m)>=u.main.to&&(g.from>0||g.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ae.range(m,d));else if(e.lineWrapping&&m==d&&!(u.main.empty&&u.main.head==d)&&e.inputState.lastTouchTime>Date.now()-100){let b=e.coordsAtPos(d,-1),v=0;b&&(v=e.inputState.lastTouchY<=b.bottom?-1:1),this.newSel=ae.create([ae.cursor(d,v)])}else this.newSel=ae.single(m,d)}}}function oN(n,e,t,i){if(n.isComposite()){let l=-1,o=-1,a=-1,u=-1;for(let f=0,d=i,m=i;ft)return oN(g,e,t,d);if(b>=e&&l==-1&&(l=f,o=d),d>t&&g.dom.parentNode==n.dom){a=f,u=m;break}m=b,d=b+g.breakAfter}return{from:o,to:u<0?i+n.length:u,startDOM:(l?n.children[l-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:a=0?n.children[a].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function aN(n,e){let t,{newSel:i}=e,{state:l}=n,o=l.selection.main,a=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,d=o.from,m=null;(a===8||we.android&&e.text.length=u&&o.to<=f&&(e.typeOver||g!=e.text)&&g.slice(0,o.from-u)==e.text.slice(0,o.from-u)&&g.slice(o.to-u)==e.text.slice(b=e.text.length-(g.length-(o.to-u)))?t={from:o.from,to:o.to,insert:ft.of(e.text.slice(o.from-u,b).split(ta))}:(v=cN(g,e.text,d-u,m))&&(we.chrome&&a==13&&v.toB==v.from+2&&e.text.slice(v.from,v.toB)==ta+ta&&v.toB--,t={from:u+v.from,to:u+v.toA,insert:ft.of(e.text.slice(v.from,v.toB).split(ta))})}else i&&(!n.hasFocus&&l.facet(il)||Ox(i,o))&&(i=null);if(!t&&!i)return!1;if((we.mac||we.android)&&t&&t.from==t.to&&t.from==o.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=ae.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:ft.of([t.insert.toString().replace("."," ")])}):l.doc.lineAt(o.from).toDate.now()-50?t={from:o.from,to:o.to,insert:l.toText(n.inputState.insertingText)}:we.chrome&&t&&t.from==t.to&&t.from==o.head&&t.insert.toString()==` - `&&n.lineWrapping&&(i&&(i=ae.single(i.main.anchor-1,i.main.head-1)),t={from:o.from,to:o.to,insert:ft.of([" "])}),t)return jy(n,t,i,a);if(i&&!Ox(i,o)){let u=!1,f="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(u=!0),f=n.inputState.lastSelectionOrigin,f=="select.pointer"&&(i=sN(l.facet(Au).map(d=>d(n)),i))),n.dispatch({selection:i,scrollIntoView:u,userEvent:f}),!0}else return!1}function jy(n,e,t,i=-1){if(we.ios&&n.inputState.flushIOSKey(e))return!0;let l=n.state.selection.main;if(we.android&&(e.to==l.to&&(e.from==l.from||e.from==l.from-1&&n.state.sliceDoc(e.from,l.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&pa(n.contentDOM,"Enter",13)||(e.from==l.from-1&&e.to==l.to&&e.insert.length==0||i==8&&e.insert.lengthl.head)&&pa(n.contentDOM,"Backspace",8)||e.from==l.from&&e.to==l.to+1&&e.insert.length==0&&pa(n.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let a,u=()=>a||(a=Jj(n,e,t));return n.state.facet($O).some(f=>f(n,e.from,e.to,o,u))||n.dispatch(u()),!0}function Jj(n,e,t){let i,l=n.state,o=l.selection.main,a=-1;if(e.from==e.to&&e.fromo.to){let f=e.fromg(n)),d,f);e.from==m&&(a=m)}if(a>-1)i={changes:e,selection:ae.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let f=o.frome.to?l.sliceDoc(e.to,o.to):"";i=l.replaceSelection(n.state.toText(f+e.insert.sliceString(0,void 0,n.state.lineBreak)+d))}else{let f=l.changes(e),d=t&&t.main.to<=f.newLength?t.main:void 0;if(l.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let m=n.state.sliceDoc(e.from,e.to),g,b=t&&lN(n,t.main.head);if(b){let w=e.insert.length-(e.to-e.from);g={from:b.from,to:b.to-w}}else g=n.state.doc.lineAt(o.head);let v=o.to-e.to;i=l.changeByRange(w=>{if(w.from==o.from&&w.to==o.to)return{changes:f,range:d||w.map(f)};let S=w.to-v,C=S-m.length;if(n.state.sliceDoc(C,S)!=m||S>=g.from&&C<=g.to)return{range:w};let N=l.changes({from:C,to:S,insert:e.insert}),R=w.to-o.to;return{changes:N,range:d?ae.range(Math.max(0,d.anchor+R),Math.max(0,d.head+R)):w.map(N)}})}else i={changes:f,selection:d&&l.selection.replaceRange(d)}}let u="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,u+=".compose",n.inputState.compositionFirstChange&&(u+=".start",n.inputState.compositionFirstChange=!1)),l.update(i,{userEvent:u,scrollIntoView:!0})}function cN(n,e,t,i){let l=Math.min(n.length,e.length),o=0;for(;o0&&u>0&&n.charCodeAt(a-1)==e.charCodeAt(u-1);)a--,u--;if(i=="end"){let f=Math.max(0,o-Math.min(a,u));t-=a+f-o}if(a=a?o-t:0;o-=f,u=o+(u-a),a=o}else if(u=u?o-t:0;o-=f,a=o+(a-u),u=o}return{from:o,toA:a,toB:u}}function eR(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:l,focusOffset:o}=n.observer.selectionRange;return t&&(e.push(new mS(t,i)),(l!=t||o!=i)&&e.push(new mS(l,o))),e}function tR(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t<0||i<0?null:t==i?ae.create([ae.cursor(i+e,-1)]):ae.single(t+e,i+e)}function Ox(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}class nR{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,we.safari&&e.contentDOM.addEventListener("input",()=>null),we.gecko&&yR(e.contentDOM.ownerDocument)}handleEvent(e){!fR(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let l of i.observers)l(this.view,t);for(let l of i.handlers){if(t.defaultPrevented)break;if(l(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=rR(e),i=this.handlers,l=this.view.contentDOM;for(let o in t)if(o!="scroll"){let a=!t[o].handlers.length,u=i[o];u&&a!=!u.handlers.length&&(l.removeEventListener(o,this.handleEvent),u=null),u||l.addEventListener(o,this.handleEvent,{passive:a})}for(let o in i)o!="scroll"&&!t[o]&&l.removeEventListener(o,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&fN.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),we.android&&we.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(we.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(uN.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||lR.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&we.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&iR(this.view.win)&&(t.shiftKey=!1);let i=this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t};return setTimeout(()=>{this.pendingIOSKey==i&&this.flushIOSKey()},50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key=="Enter"&&e&&e.from0?!0:we.safari&&!we.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function iR(n){return n.visualViewport?n.visualViewport.height*n.visualViewport.scale/n.document.documentElement.clientHeight<.85:!1}function pS(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(l){di(t.state,l)}}}function rR(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let l=i.spec,o=l&&l.plugin.domEventHandlers,a=l&&l.plugin.domEventObservers;if(o)for(let u in o){let f=o[u];f&&t(u).handlers.push(pS(i.value,f))}if(a)for(let u in a){let f=a[u];f&&t(u).observers.push(pS(i.value,f))}}for(let i in rr)t(i).handlers.push(rr[i]);for(let i in Zn)t(i).observers.push(Zn[i]);return e}const uN=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],lR="dthko",fN=[16,17,18,20,91,92,224,225],yh=6;function bh(n){return Math.max(0,n)*.7+8}function sR(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class oR{constructor(e,t,i,l){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=l,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=DO(e.contentDOM),this.atoms=e.state.facet(Au).map(a=>a(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(dt.allowMultipleSelections)&&aR(e,t),this.dragging=uR(e,t)&&mN(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&sR(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,l=0,o=0,a=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:l,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Dy(this.view);e.clientX-f.left<=l+yh?t=-bh(l-e.clientX):e.clientX+f.right>=a-yh&&(t=bh(e.clientX-a)),e.clientY-f.top<=o+yh?i=-bh(o-e.clientY):e.clientY+f.bottom>=u-yh&&(i=bh(e.clientY-u)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,i=sN(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function aR(n,e){let t=n.state.facet(qO);return t.length?t[0](e):we.mac?e.metaKey:e.ctrlKey}function cR(n,e){let t=n.state.facet(VO);return t.length?t[0](e):we.mac?!e.altKey:!e.ctrlKey}function uR(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=hu(n.root);if(!i||i.rangeCount==0)return!0;let l=i.getRangeAt(0).getClientRects();for(let o=0;o=e.clientX&&a.top<=e.clientY&&a.bottom>=e.clientY)return!0}return!1}function fR(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=Yt.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const rr=Object.create(null),Zn=Object.create(null),hN=we.ie&&we.ie_version<15||we.ios&&we.webkit_version<604;function hR(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),dN(n,t.value)},50)}function em(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function dN(n,e){e=em(n.state,Ty,e);let{state:t}=n,i,l=1,o=t.toText(e),a=o.lines==t.selection.ranges.length;if(Nx!=null&&t.selection.ranges.every(f=>f.empty)&&Nx==o.toString()){let f=-1;i=t.changeByRange(d=>{let m=t.doc.lineAt(d.from);if(m.from==f)return{range:d};f=m.from;let g=t.toText((a?o.line(l++).text:e)+t.lineBreak);return{changes:{from:m.from,insert:g},range:ae.cursor(d.from+g.length,-1)}})}else a?i=t.changeByRange(f=>{let d=o.line(l++);return{changes:{from:f.from,to:f.to,insert:d.text},range:ae.cursor(f.from+d.length,-1)}}):i=t.replaceSelection(o);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Zn.scroll=n=>{let e=n.inputState;e.lastScrollTop=n.scrollDOM.scrollTop,e.lastScrollLeft=n.scrollDOM.scrollLeft,we.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};Zn.wheel=Zn.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};rr.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);Zn.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};Zn.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};Zn.touchend=(n,e)=>{n.inputState.touchActive=!1};rr.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(QO))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=mR(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new oR(n,e,t,i)),i&&n.observer.ignore(()=>{_O(n.contentDOM);let o=n.root.activeElement;o&&!o.contains(n.contentDOM)&&o.blur()});let l=n.inputState.mouseSelection;if(l)return l.start(e),l.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function gS(n,e,t,i){if(i==1)return ae.cursor(e,t);if(i==2)return qj(n.state,e,t);{let l=n.docView.lineAt(e,t),o=n.state.doc.lineAt(l?l.posAtEnd:e),a=l?l.posAtStart:o.from,u=l?l.posAtEnd:o.to;return uDate.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(yS+1)%3:1}function mR(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=mN(e),l=n.state.selection;return{update(o){o.docChanged&&(t.pos=o.changes.mapPos(t.pos),l=l.map(o.changes))},get(o,a,u){let f=n.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),d,m=gS(n,f.pos,f.assoc,i);if(t.pos!=f.pos&&!a){let g=gS(n,t.pos,t.assoc,i),b=Math.min(g.from,m.from),v=Math.max(g.to,m.to);m=b1&&(d=pR(l,f.pos))?d:u?l.addRange(m):ae.create([m])}}}function pR(n,e){for(let t=0;t=e)return ae.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}rr.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let l=n.docView.tile.nearest(e.target);if(l&&l.isWidget()){let o=l.posAtStart,a=o+l.length;(o>=t.to||a<=t.from)&&(t=ae.undirectionalRange(o,a))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",em(n.state,Ay,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};rr.dragend=n=>(n.inputState.draggedContent=null,!1);function vS(n,e,t,i){if(t=em(n.state,Ty,t),!t)return;let l=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=n.inputState,a=i&&o&&cR(n,e)?{from:o.from,to:o.to}:null,u={from:l,insert:t},f=n.state.changes(a?[a,u]:u);n.focus(),n.dispatch({changes:f,selection:{anchor:f.mapPos(l,-1),head:f.mapPos(l,1)},userEvent:a?"move.drop":"input.drop"}),n.inputState.draggedContent=null}rr.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),l=0,o=()=>{++l==t.length&&vS(n,e,i.filter(a=>a!=null).join(n.state.lineBreak),!1)};for(let a=0;a{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(i[a]=u.result),o()},u.readAsText(t[a])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return vS(n,e,i,!0),!0}return!1};rr.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=hN?null:e.clipboardData;return t?(dN(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(hR(n),!1)};function gR(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function xR(n){let e=[],t=[],i=!1;for(let l of n.selection.ranges)l.empty||(e.push(n.sliceDoc(l.from,l.to)),t.push(l));if(!e.length){let l=-1;for(let{from:o}of n.selection.ranges){let a=n.doc.lineAt(o);a.number>l&&(e.push(a.text),t.push({from:a.from,to:Math.min(n.doc.length,a.to+1)})),l=a.number}i=!0}return{text:em(n,Ay,e.join(n.lineBreak)),ranges:t,linewise:i}}let Nx=null;rr.copy=rr.cut=(n,e)=>{if(!Zc(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:l}=xR(n.state);if(!t&&!l)return!1;Nx=l?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let o=hN?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",t),!0):(gR(n,t),!1)};const pN=cl.define();function gN(n,e){let t=[];for(let i of n.facet(YO)){let l=i(n,e);l&&t.push(l)}return t.length?n.update({effects:t,annotations:pN.of(!0)}):null}function xN(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=gN(n.state,e);t?n.dispatch(t):n.update([])}},10)}Zn.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),xN(n)};Zn.blur=n=>{n.observer.clearSelectionRange(),xN(n)};Zn.compositionstart=Zn.compositionupdate=(n,e)=>{if(!n.observer.editContext&&(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0)){let{main:t}=n.state.selection;!t.empty&&n.lineBlockAt(t.from).from!=n.lineBlockAt(t.to).from&&!n.state.readOnly&&n.dispatch({changes:n.state.selection.ranges.filter(i=>!i.empty).map(i=>({from:i.from,to:i.to})),userEvent:"input"}),n.inputState.composing=0}};Zn.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,we.chrome&&we.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};Zn.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};rr.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let o=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),a=e.getTargetRanges();if(o&&a.length){let u=a[0],f=n.posAtDOM(u.startContainer,u.startOffset),d=n.posAtDOM(u.endContainer,u.endOffset);return jy(n,{from:f,to:d,insert:n.state.toText(o)},null),!0}}let l;if(we.chrome&&we.android&&(l=uN.find(o=>o.inputType==e.inputType))&&(n.observer.delayAndroidKey(l.key,l.keyCode),l.key=="Backspace"||l.key=="Delete")){let o=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var a;(((a=window.visualViewport)===null||a===void 0?void 0:a.height)||0)>o+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return we.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),we.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>Zn.compositionend(n,e),20),!1};const wS=new Set;function yR(n){wS.has(n)||(wS.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const kS=["pre-wrap","normal","pre-line","break-spaces"];let Aa=!1;function SS(){Aa=!1}class bR{constructor(e){this.lineWrapping=e,this.doc=ft.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return kS.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,f=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=t,this.charWidth=i,this.textHeight=l,this.lineLength=o,f){this.heightSamples={};for(let d=0;d0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>ed&&(Aa=!0),this.height=e)}replace(e,t,i){return Wn.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,l){let o=this,a=i.doc;for(let u=l.length-1;u>=0;u--){let{fromA:f,toA:d,fromB:m,toB:g}=l[u],b=o.lineAt(f,Rt.ByPosNoHeight,i.setDoc(t),0,0),v=b.to>=d?b:o.lineAt(d,Rt.ByPosNoHeight,i,0,0);for(g+=v.to-d,d=v.to;u>0&&b.from<=l[u-1].toA;)f=l[u-1].fromA,m=l[u-1].fromB,u--,fo*2){let u=e[t-1];u.break?e.splice(--t,1,u.left,null,u.right):e.splice(--t,1,u.left,u.right),i+=1+u.break,l-=u.size}else if(o>l*2){let u=e[i];u.break?e.splice(i,1,u.left,null,u.right):e.splice(i,1,u.left,u.right),i+=2+u.break,o-=u.size}else break;else if(l=o&&a(this.lineAt(0,Rt.ByPos,i,l,o))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,i=!1,l){return l&&l.from<=t&&l.more&&this.setMeasuredHeight(l),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Ti extends yN{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new Ji(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let l=i[0];return i.length==1&&(l instanceof Ti||l instanceof Dn&&l.flags&4)&&Math.abs(this.length-l.length)<10?(l instanceof Dn?l=new Ti(l.length,this.height,this.spaceAbove):l.height=this.height,this.outdated||(l.outdated=!1),l):Wn.of(i)}updateHeight(e,t=0,i=!1,l){return l&&l.from<=t&&l.more?this.setMeasuredHeight(l):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Dn extends Wn{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,l=e.doc.lineAt(t+this.length).number,o=l-i+1,a,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*o);a=f/o,this.length>o+1&&(u=(this.height-f)/(this.length-o-1))}else a=this.height/o;return{firstLine:i,lastLine:l,perLine:a,perChar:u}}blockAt(e,t,i,l){let{firstLine:o,lastLine:a,perLine:u,perChar:f}=this.heightMetrics(t,l);if(t.lineWrapping){let d=l+(e0){let o=i[i.length-1];o instanceof Dn?i[i.length-1]=new Dn(o.length+l):i.push(null,new Dn(l-1))}if(e>0){let o=i[0];o instanceof Dn?i[0]=new Dn(e+o.length):i.unshift(new Dn(e-1),null)}return Wn.of(i)}decomposeLeft(e,t){t.push(new Dn(e-1),null)}decomposeRight(e,t){t.push(null,new Dn(this.length-e-1))}updateHeight(e,t=0,i=!1,l){let o=t+this.length;if(l&&l.from<=t+this.length&&l.more){let a=[],u=Math.max(t,l.from),f=-1;for(l.from>t&&a.push(new Dn(l.from-t-1).updateHeight(e,t));u<=o&&l.more;){let m=e.doc.lineAt(u).length;a.length&&a.push(null);let g=l.heights[l.index++],b=0;g<0&&(b=-g,g=l.heights[l.index++]),f==-1?f=g:Math.abs(g-f)>=ed&&(f=-2);let v=new Ti(m,g,b);v.outdated=!1,a.push(v),u+=m+1}u<=o&&a.push(null,new Dn(o-u).updateHeight(e,u));let d=Wn.of(a);return(f<0||Math.abs(d.height-this.height)>=ed||Math.abs(f-this.heightMetrics(e,t).perLine)>=ed)&&(Aa=!0),yd(this,d)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class kR extends Wn{constructor(e,t,i){super(e.length+(t?1:0)+i.length,e.height+i.height,(t?1:0)|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,l){let o=i+this.left.height;return eu))return d;let m=t==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?d.join(this.right.lineAt(u,m,i,a,u)):this.left.lineAt(u,m,i,l,o).join(d)}forEachLine(e,t,i,l,o,a){let u=l+this.left.height,f=o+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,t,i,u,f,a);else{let d=this.lineAt(f,Rt.ByPos,i,l,o);e=e&&d.from<=t&&a(d),t>d.to&&this.right.forEachLine(Math.max(e,d.to+1),t,i,u,f,a)}}replace(e,t,i){let l=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-l,t-l,i));let o=[];e>0&&this.decomposeLeft(e,o);let a=o.length;for(let u of i)o.push(u);if(e>0&&CS(o,a-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,l=i+this.break;if(e>=l)return this.right.decomposeRight(e-l,t);e2*t.size||t.size>2*e.size?Wn.of(this.break?[e,null,t]:[e,t]):(this.left=yd(this.left,e),this.right=yd(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,l){let{left:o,right:a}=this,u=t+o.length+this.break,f=null;return l&&l.from<=t+o.length&&l.more?f=o=o.updateHeight(e,t,i,l):o.updateHeight(e,t,i),l&&l.from<=u+a.length&&l.more?f=a=a.updateHeight(e,u,i,l):a.updateHeight(e,u,i),f?this.balanced(o,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function CS(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof Dn&&(i=n[e+1])instanceof Dn&&n.splice(e-1,3,new Dn(t.length+1+i.length))}const SR=5;class Ry{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),l=this.nodes[this.nodes.length-1];l instanceof Ti?l.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Ti(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=SR)&&this.addLineDeco(l,o,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new Ti(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new Dn(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ti)return e;let t=new Ti(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let l=this.ensureLine();l.length+=i,l.collapsed+=i,l.widgetHeight=Math.max(l.widgetHeight,e),l.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Ti)&&!this.isCovered?this.nodes.push(new Ti(0,-1,0)):(this.writtenTod.clientHeight||d.scrollWidth>d.clientWidth)&&m.overflow!="visible"){let g=d.getBoundingClientRect();o=Math.max(o,g.left),a=Math.min(a,g.right),u=Math.max(u,g.top),f=Math.min(d==n.parentNode?l.innerHeight:f,g.bottom)}d=m.position=="absolute"||m.position=="fixed"?d.offsetParent:d.parentNode}else if(d.nodeType==11)d=d.host;else break;return{left:o-t.left,right:Math.max(o,a)-t.left,top:u-(t.top+e),bottom:Math.max(u,f)-(t.top+e)}}function TR(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function AR(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class o0{constructor(e,t,i,l){this.from=e,this.to=t,this.size=i,this.displaySize=l}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof l!="function"&&l.class=="cm-lineWrapping");this.heightOracle=new bR(i),this.stateDeco=NS(t),this.heightMap=Wn.empty().applyChanges(this.stateDeco,ft.empty,this.heightOracle.setDoc(t.doc),[new Ii(0,0,0,t.doc.length)]);for(let l=0;l<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());l++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=He.set(this.lineGaps.map(l=>l.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let l=i?t.head:t.anchor;if(!e.some(({from:o,to:a})=>l>=o&&l<=a)){let{from:o,to:a}=this.lineBlockAt(l);e.push(new vh(o,a))}}return this.viewports=e.sort((i,l)=>i.from-l.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Tx:bd.get(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push($c(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=NS(this.state);let l=e.changedRanges,o=Ii.extendWithRanges(l,CR(i,this.stateDeco,e?e.changes:hn.empty(this.state.doc.length))),a=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);SS(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=a||Aa)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let f=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,t));let d=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(d||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(KO)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),l=this.heightOracle,o=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?Ot.RTL:Ot.LTR;let a=this.heightOracle.mustRefreshForWrapping(o)||this.mustMeasureContent==="refresh",u=t.getBoundingClientRect(),f=a||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let d=0,m=0;if(u.width&&u.height){let{scaleX:U,scaleY:E}=MO(t,u);(U>.005&&Math.abs(this.scaleX-U)>.005||E>.005&&Math.abs(this.scaleY-E)>.005)&&(this.scaleX=U,this.scaleY=E,d|=16,a=f=!0)}let g=(parseInt(i.paddingTop)||0)*this.scaleY,b=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=g||this.paddingBottom!=b)&&(this.paddingTop=g,this.paddingBottom=b,d|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(l.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,d|=16);let v=DO(this.view.contentDOM,!1).y;v!=this.scrollParent&&(this.scrollParent=v,this.scrollAnchorHeight=-1,this.scrollOffset=0);let w=this.getScrollOffset();this.scrollOffset!=w&&(this.scrollAnchorHeight=-1,this.scrollOffset=w),this.scrolledToBottom=LO(this.scrollParent||e.win);let S=(this.printing?AR:NR)(t,this.paddingTop),C=S.top-this.pixelViewport.top,N=S.bottom-this.pixelViewport.bottom;this.pixelViewport=S;let R=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(R!=this.inView&&(this.inView=R,R&&(f=!0)),!this.inView&&!this.scrollTarget&&!TR(e.dom))return 0;let M=u.width;if((this.contentDOMWidth!=M||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,d|=16),f){let U=e.docView.measureVisibleLineHeights(this.viewport);if(l.mustRefreshForHeights(U)&&(a=!0),a||l.lineWrapping&&Math.abs(M-this.contentDOMWidth)>l.charWidth){let{lineHeight:E,charWidth:T,textHeight:z}=e.docView.measureTextSize();a=E>0&&l.refresh(o,E,T,z,Math.max(5,M/T),U),a&&(e.docView.minWidth=0,d|=16)}C>0&&N>0?m=Math.max(C,N):C<0&&N<0&&(m=Math.min(C,N)),SS();for(let E of this.viewports){let T=E.from==this.viewport.from?U:e.docView.measureVisibleLineHeights(E);this.heightMap=(a?Wn.empty().applyChanges(this.stateDeco,ft.empty,this.heightOracle,[new Ii(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(l,0,a,new vR(E.from,T))}Aa&&(d|=2)}let I=!this.viewportIsAppropriate(this.viewport,m)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return I&&(d&2&&(d|=this.updateScaler()),this.viewport=this.getViewport(m,this.scrollTarget),d|=this.updateForViewport()),(d&2||I)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),d|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),d}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),l=this.heightMap,o=this.heightOracle,{visibleTop:a,visibleBottom:u}=this,f=new vh(l.lineAt(a-i*1e3,Rt.ByHeight,o,0,0).from,l.lineAt(u+(1-i)*1e3,Rt.ByHeight,o,0,0).to);if(t){let{head:d}=t.range;if(df.to){let m=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),g=l.lineAt(d,Rt.ByPos,o,0,0),b;t.y=="center"?b=(g.top+g.bottom)/2-m/2:t.y=="start"||t.y=="nearest"&&d=u+Math.max(10,Math.min(i,250)))&&l>a-2*1e3&&o>1,a=l<<1;if(this.defaultTextDirection!=Ot.LTR&&!i)return[];let u=[],f=(m,g,b,v)=>{if(g-mm&&NN.from>=b.from&&N.to<=b.to&&Math.abs(N.from-m)N.fromR));if(!C){if(gM.from<=g&&M.to>=g)){let M=t.moveToLineBoundary(ae.cursor(g),!1,!0).head;M>m&&(g=M)}let N=this.gapSize(b,m,g,v),R=i||N<2e6?N:2e6;C=new o0(m,g,N,R)}u.push(C)},d=m=>{if(m.length2e6)for(let E of e)E.from>=m.from&&E.fromm.from&&f(m.from,v,m,g),wt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];it.spans(t,this.viewport.from,this.viewport.to,{span(o,a){i.push({from:o,to:a})},point(){}},20);let l=0;if(i.length!=this.visibleRanges.length)l=12;else for(let o=0;o=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||$c(this.heightMap.lineAt(e,Rt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||$c(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+12-this.paddingTop);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return $c(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class vh{constructor(e,t){this.from=e,this.to=t}}function MR(n,e,t){let i=[],l=n,o=0;return it.spans(t,n,e,{span(){},point(a,u){a>l&&(i.push({from:l,to:a}),o+=a-l),l=u}},20),l=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let l=0;;l++){let{from:o,to:a}=e[l],u=a-o;if(i<=u)return o+i;i-=u}}function kh(n,e){let t=0;for(let{from:i,to:l}of n.ranges){if(e<=l){t+=e-i;break}t+=l-i}return t/n.total}function DR(n,e){for(let t of n)if(e(t))return t}const Tx={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function NS(n){let e=n.facet(Wd).filter(i=>typeof i!="function"),t=n.facet(My).filter(i=>typeof i!="function");return t.length&&e.push(it.join(t)),e}class bd{constructor(e,t){this.scale=e,this.viewports=t}static get(e,t,i){let l=0,o=0,a=0,u=i.map(({from:d,to:m})=>{let g=t.lineAt(d,Rt.ByPos,e,0,0).top,b=t.lineAt(m,Rt.ByPos,e,0,0).bottom;return l+=b-g,{from:d,to:m,top:g,bottom:b,domTop:0,domBottom:0}});if(t.height-l<10)return Tx;let f=(7e6-l)/(t.height-l);for(let d of u)d.domTop=a+(d.top-o)*f,a=d.domBottom=d.domTop+(d.bottom-d.top),o=d.bottom;return new bd(f,u)}toDOM(e){for(let t=0,i=0,l=0;;t++){let o=tt.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function $c(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new Ji(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(l=>$c(l,e)):n._content)}const Sh=Ce.define({combine:n=>n.join(" ")}),Ax=Ce.define({combine:n=>n.indexOf(!0)>-1}),Ex=is.newName(),bN=is.newName(),vN=is.newName(),wN={"&light":"."+bN,"&dark":"."+vN};function Mx(n,e,t){return new is(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,l=>{if(l=="&")return n;if(!t||!t[l])throw new RangeError(`Unsupported selector: ${l}`);return t[l]}):n+" "+i}})}const jR=Mx("."+Ex,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"baseline",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},wN),RR={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},a0=we.ie&&we.ie_version<=11;class _R{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new cj,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(we.ie&&we.ie_version<=11||we.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&we.android&&e.constructor.EDIT_CONTEXT!==!1&&!(we.chrome&&we.chrome_version<126)&&(this.editContext=new zR(e),e.state.facet(il)&&(e.contentDOM.editContext=this.editContext.editContext)),a0&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(this.pendingRecords().length>0),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,l=this.selectionRange;if(i.state.facet(il)?i.root.activeElement!=this.dom:!Zc(this.dom,l))return;let o=l.anchorNode&&i.docView.tile.nearest(l.anchorNode);if(o&&o.isWidget()&&o.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(we.ie&&we.ie_version<=11||we.android&&we.chrome)&&!i.state.selection.main.empty&&l.focusNode&&Jc(l.focusNode,l.focusOffset,l.anchorNode,l.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=hu(e.root);if(!t)return!1;let i=we.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&LR(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let l=Zc(this.dom,i);return l&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&pa(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(l)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,l=!1;for(let o of e){let a=this.readMutation(o);a&&(a.typeOver&&(l=!0),t==-1?{from:t,to:i}=a:(t=Math.min(a.from,t),i=Math.max(a.to,i)))}return{from:t,to:i,typeOver:l}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),l=this.selectionChanged&&Zc(this.dom,this.selectionRange);if(e<0&&!l)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new Zj(this.view,e,t,i);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.selectionChanged,i=this.readChange();if(!i)return this.view.requestMeasure(),!1;let l=this.view.state,o=aN(this.view,i);return this.view.state==l&&(i.domChanged||t)&&this.view.update([]),o}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let i=TS(t,e.previousSibling||e.target.previousSibling,-1),l=TS(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:l?t.posBefore(l):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(il)!=e.state.facet(il)&&(e.view.contentDOM.editContext=e.state.facet(il)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let l of this.scrollTargets)l.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function TS(n,e,t){for(;e;){let i=Yt.get(e);if(i&&i.parent==n)return i;let l=e.parentNode;e=l!=n.dom?l:t>0?e.nextSibling:e.previousSibling}return null}function AS(n,e){let t=e.startContainer,i=e.startOffset,l=e.endContainer,o=e.endOffset,a=n.docView.domAtPos(n.state.selection.main.anchor,1);return Jc(a.node,a.offset,l,o)&&([t,i,l,o]=[l,o,t,i]),{anchorNode:t,anchorOffset:i,focusNode:l,focusOffset:o}}function LR(n,e){if(e.getComposedRanges){let l=e.getComposedRanges(n.root)[0];if(l)return AS(n,l)}let t=null;function i(l){l.preventDefault(),l.stopImmediatePropagation(),t=l.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?AS(n,t):null}class zR{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let l=e.state.selection.main,{anchor:o,head:a}=l,u=this.toEditorPos(i.updateRangeStart),f=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:u,drifted:!1});let d=f-u>i.text.length;u==this.from&&othis.to&&(f=o);let m=cN(e.state.sliceDoc(u,f),i.text,(d?l.from:l.to)-u,d?"end":null);if(!m){let b=ae.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Ox(b,l)||e.dispatch({selection:b,userEvent:"select"});return}let g={from:m.from+u,to:m.toA+u,insert:ft.of(i.text.slice(m.from,m.toB).split(` -`))};if((we.mac||we.android)&&g.from==a-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(g={from:u,to:f,insert:ft.of([i.text.replace("."," ")])}),this.pendingContextChange=g,!e.state.readOnly){let b=this.to-this.from+(g.to-g.from+g.insert.length);jy(e,g,ae.single(this.toEditorPos(i.selectionStart,b),this.toEditorPos(i.selectionEnd,b)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),g.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let l=[],o=null;for(let a=this.toEditorPos(i.rangeStart),u=this.toEditorPos(i.rangeEnd);a{let l=[];for(let o of i.getTextFormats()){let a=o.underlineStyle,u=o.underlineThickness;if(!/none/i.test(a)&&!/none/i.test(u)){let f=this.toEditorPos(o.rangeStart),d=this.toEditorPos(o.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let l=hu(i.root);l&&l.rangeCount&&this.editContext.updateSelectionBounds(l.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,l=this.pendingContextChange;return e.changes.iterChanges((o,a,u,f,d)=>{if(i)return;let m=d.length-(a-o);if(l&&a>=l.to)if(l.from==o&&l.to==a&&l.insert.eq(d)){l=this.pendingContextChange=null,t+=m,this.to+=m;return}else l=null,this.revertPending(e.state);if(o+=t,a+=t,a<=this.from)this.from+=m,this.to+=m;else if(othis.to||this.to-this.from+d.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(a),d.toString()),this.to+=m}t+=m}),l&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(l=>!l.isUserEvent("input.type")&&l.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),l=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=l)&&this.editContext.updateSelection(i,l)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Oe{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(l=>l.forEach(o=>i(o,this)))||(l=>this.update(l)),this.dispatch=this.dispatch.bind(this),this._root=e.root||uj(e.parent)||document,this.viewState=new OS(this,e.state||dt.create(e)),e.scrollTo&&e.scrollTo.is(xh)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(aa).map(l=>new n0(l));for(let l of this.plugins)l.update(this);this.observer=new _R(this),this.inputState=new nR(this),this.inputState.ensureHandlers(this.plugins),this.docView=new hS(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof dn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,l,o=this.state;for(let b of e){if(b.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=b.state}if(this.destroyed){this.viewState.state=o;return}let a=this.hasFocus,u=0,f=null;e.some(b=>b.annotation(pN))?(this.inputState.notifiedFocused=a,u=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,f=gN(o,a),f||(u=1));let d=this.observer.delayedAndroidKey,m=null;if(d?(this.observer.clearDelayedAndroidKey(),m=this.observer.readChange(),(m&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(m=null)):this.observer.clear(),o.facet(dt.phrases)!=this.state.facet(dt.phrases))return this.setState(o);l=pd.create(this,o,e),l.flags|=u;let g=this.viewState.scrollTarget;try{this.updateState=2;for(let b of e){if(g&&(g=g.map(b.changes)),b.scrollIntoView){let{main:v}=b.state.selection,{x:w,y:S}=this.state.facet(Oe.cursorScrollMargin);g=new ga(v.empty?v:ae.cursor(v.head,v.head>v.anchor?-1:1),"nearest","nearest",S,w)}for(let v of b.effects)v.is(xh)&&(g=v.value.clip(this.state))}this.viewState.update(l,g),this.bidiCache=vd.update(this.bidiCache,l.changes),l.empty||(this.updatePlugins(l),this.inputState.update(l)),t=this.docView.update(l),this.state.facet(Xc)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(b=>b.isUserEvent("select.pointer")))}finally{this.updateState=0}if(l.startState.facet(Sh)!=l.state.facet(Sh)&&(this.viewState.mustMeasureContent=!0),(t||i||g||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!l.empty)for(let b of this.state.facet(wx))try{b(l)}catch(v){di(this.state,v,"update listener")}(f||m)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),m&&!aN(this,m)&&d.force&&pa(this.contentDOM,d.key,d.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new OS(this,e),this.plugins=e.facet(aa).map(i=>new n0(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new hS(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(aa),i=e.state.facet(aa);if(t!=i){let l=[];for(let o of i){let a=t.indexOf(o);if(a<0)l.push(new n0(o));else{let u=this.plugins[a];u.mustUpdate=e,l.push(u)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=l,this.pluginMap.clear()}else for(let l of this.plugins)l.mustUpdate=e;for(let l=0;l-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,l=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:a,scaleY:u}=this.viewState;Math.abs(l-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(a<0){if(LO(i||this.win))o=-1,a=this.viewState.heightMap.height/this.viewState.scaleY;else{let w=this.viewState.scrollAnchorAt(l);o=w.from,a=w.top}u=this.viewState.scaleY}this.updateState=1;let d=this.viewState.measure();if(!d&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let m=[];d&4||([this.measureRequests,m]=[m,this.measureRequests]);let g=m.map(w=>{try{return w.read(this)}catch(S){return di(this.state,S),ES}}),b=pd.create(this,this.state,[]),v=!1;b.flags|=d,t?t.flags|=d:t=b,this.updateState=2,b.empty||(this.updatePlugins(b),this.inputState.update(b),this.updateAttrs(),v=this.docView.update(b),v&&this.docViewUpdate());for(let w=0;w1||S<-1)&&!(we.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){l=l+S,i?o<0?i.scrollTop=i.scrollHeight:i.scrollTop+=S:this.win.scrollBy(0,S),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let f of this.state.facet(wx))f(t)}get themeClasses(){return Ex+" "+(this.state.facet(Ax)?vN:bN)+" "+this.state.facet(Sh)}updateAttrs(){let e=MS(this,JO,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(il)?"true":"false",class:"cm-content",style:`${we.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),MS(this,Ey,t);let i=this.observer.ignore(()=>{let l=sS(this.contentDOM,this.contentAttrs,t),o=sS(this.dom,this.editorAttrs,e);return l||o});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let l of i.effects)if(l.is(Oe.announce)){t&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=" "},200),t=!1);let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=l.value}}mountStyles(){this.styleModules=this.state.facet(Xc);let e=this.state.facet(Oe.cspNonce);is.mount(this.root,this.styleModules.concat(jR).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ti.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return s0(this,e,dS(this,e,t,i))}moveByGroup(e,t){return s0(this,e,dS(this,e,t,i=>Xj(this,e.head,i)))}visualLineSide(e,t){return t?ae.cursor(e.to,1):ae.cursor(e.from,-1)}moveToLineBoundary(e,t,i=!0){return Qj(this,e,t,i)}moveVertically(e,t,i){return s0(this,e,$j(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=Cx(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Cx(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),l=this.bidiSpans(i),o=l[Dr.find(l,e-i.from,-1,t)];return i.length&&(e==i.from&&t<0||e==i.to&&t>0)&&o.dir!=this.textDirectionAt(i.from)&&(e==i.to?(e=i.from+o.from,t=1):(e=i.from+o.to,t=-1)),this.docView.coordsAt(e,t,o.dir==Ot.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(GO)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>BR)return UO(e.length);let t=this.textDirectionAt(e.from),i;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==t&&(o.fresh||IO(o.isolates,i=cS(this,e))))return o.order;i||(i=cS(this,e));let l=yj(e.text,t,i);return this.bidiCache.push(new vd(e.from,e.to,t,i,!0,l)),l}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||we.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{_O(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,l,o,a;return xh.of(new ga(typeof e=="number"?ae.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(l=t.x)!==null&&l!==void 0?l:"nearest",(o=t.yMargin)!==null&&o!==void 0?o:5,(a=t.xMargin)!==null&&a!==void 0?a:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return xh.of(new ga(ae.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Jt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Jt.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=is.newName(),l=[Sh.of(i),Xc.of(Mx(`.${i}`,e))];return t&&t.dark&&l.push(Ax.of(!0)),l}static baseTheme(e){return so.lowest(Xc.of(Mx("."+Ex,e,wN)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),l=i&&Yt.get(i)||Yt.get(e);return((t=l==null?void 0:l.root)===null||t===void 0?void 0:t.view)||null}}Oe.styleModule=Xc;Oe.inputHandler=$O;Oe.clipboardInputFilter=Ty;Oe.clipboardOutputFilter=Ay;Oe.scrollHandler=WO;Oe.focusChangeEffect=YO;Oe.perLineTextDirection=GO;Oe.exceptionSink=XO;Oe.updateListener=wx;Oe.editable=il;Oe.mouseSelectionStyle=QO;Oe.dragMovesSelection=VO;Oe.clickAddsSelectionRange=qO;Oe.decorations=Wd;Oe.blockWrappers=eN;Oe.outerDecorations=My;Oe.atomicRanges=Au;Oe.bidiIsolatedRanges=tN;Oe.cursorScrollMargin=Ce.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});Oe.scrollMargins=iN;Oe.darkTheme=Ax;Oe.cspNonce=Ce.define({combine:n=>n.length?n[0]:""});Oe.contentAttributes=Ey;Oe.editorAttributes=JO;Oe.lineWrapping=Oe.contentAttributes.of({class:"cm-lineWrapping"});Oe.announce=Ye.define();const BR=4096,ES={};class vd{constructor(e,t,i,l,o,a){this.from=e,this.to=t,this.dir=i,this.isolates=l,this.fresh=o,this.order=a}static update(e,t){if(t.empty&&!e.some(o=>o.fresh))return e;let i=[],l=e.length?e[e.length-1].dir:Ot.LTR;for(let o=Math.max(0,e.length-10);o=0;l--){let o=i[l],a=typeof o=="function"?o(n):o;a&&Cy(a,t)}return t}const PR=we.mac?"mac":we.windows?"win":we.linux?"linux":"key";function HR(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let l,o,a,u;for(let f=0;fi.concat(l),[]))),t}function UR(n,e,t){return SN(kN(n.state),e,n,t)}let Gl=null;const FR=4e3;function qR(n,e=PR){let t=Object.create(null),i=Object.create(null),l=(a,u)=>{let f=i[a];if(f==null)i[a]=u;else if(f!=u)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},o=(a,u,f,d,m)=>{var g,b;let v=t[a]||(t[a]=Object.create(null)),w=u.split(/ (?!$)/).map(N=>HR(N,e));for(let N=1;N{let I=Gl={view:M,prefix:R,scope:a};return setTimeout(()=>{Gl==I&&(Gl=null)},FR),!0}]})}let S=w.join(" ");l(S,!1);let C=v[S]||(v[S]={preventDefault:!1,stopPropagation:!1,run:((b=(g=v._any)===null||g===void 0?void 0:g.run)===null||b===void 0?void 0:b.slice())||[]});f&&C.run.push(f),d&&(C.preventDefault=!0),m&&(C.stopPropagation=!0)};for(let a of n){let u=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let d of u){let m=t[d]||(t[d]=Object.create(null));m._any||(m._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:g}=a;for(let b in m)m[b].run.push(v=>g(v,Dx))}let f=a[e]||a.key;if(f)for(let d of u)o(d,f,a.run,a.preventDefault,a.stopPropagation),a.shift&&o(d,"Shift-"+f,a.shift,a.preventDefault,a.stopPropagation)}return t}let Dx=null;function SN(n,e,t,i){Dx=e;let l=ij(e),o=ui(l,0),a=Er(o)==l.length&&l!=" ",u="",f=!1,d=!1,m=!1;Gl&&Gl.view==t&&Gl.scope==i&&(u=Gl.prefix+" ",fN.indexOf(e.keyCode)<0&&(d=!0,Gl=null));let g=new Set,b=C=>{if(C){for(let N of C.run)if(!g.has(N)&&(g.add(N),N(t)))return C.stopPropagation&&(m=!0),!0;C.preventDefault&&(C.stopPropagation&&(m=!0),d=!0)}return!1},v=n[i],w,S;return v&&(b(v[u+Ch(l,e,!a)])?f=!0:a&&(e.altKey||e.metaKey||e.ctrlKey)&&!(we.windows&&e.ctrlKey&&e.altKey)&&!(we.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(w=rs[e.keyCode])&&w!=l?(b(v[u+Ch(w,e,!0)])||e.shiftKey&&(S=uu[e.keyCode])!=l&&S!=w&&b(v[u+Ch(S,e,!1)]))&&(f=!0):a&&e.shiftKey&&b(v[u+Ch(l,e,!0)])&&(f=!0),!f&&b(v._any)&&(f=!0)),d&&(f=!0),f&&m&&e.stopPropagation(),Dx=null,f}class Zs{constructor(e,t,i,l,o){this.className=e,this.left=t,this.top=i,this.width=l,this.height=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let l=e.coordsAtPos(i.head,i.assoc||1);if(!l)return[];let o=CN(e);return[new Zs(t,l.left-o.left,l.top-o.top,null,l.bottom-l.top)]}else return VR(e,t,i)}}function CN(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==Ot.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function jS(n,e,t,i){let l=n.coordsAtPos(e,t*2);if(!l)return i;let o=n.dom.getBoundingClientRect(),a=(l.top+l.bottom)/2,u=n.posAtCoords({x:o.left+1,y:a}),f=n.posAtCoords({x:o.right-1,y:a});return u==null||f==null?i:{from:Math.max(i.from,Math.min(u,f)),to:Math.min(i.to,Math.max(u,f))}}function VR(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),l=Math.min(t.to,n.viewport.to),o=n.textDirection==Ot.LTR,a=n.contentDOM,u=a.getBoundingClientRect(),f=CN(n),d=a.querySelector(".cm-line"),m=d&&window.getComputedStyle(d),g=u.left+(m?parseInt(m.paddingLeft)+Math.min(0,parseInt(m.textIndent)):0),b=u.right-(m?parseInt(m.paddingRight):0),v=Sx(n,i,1),w=Sx(n,l,-1),S=v.type==Ln.Text?v:null,C=w.type==Ln.Text?w:null;if(S&&(n.lineWrapping||v.widgetLineBreaks)&&(S=jS(n,i,1,S)),C&&(n.lineWrapping||w.widgetLineBreaks)&&(C=jS(n,l,-1,C)),S&&C&&S.from==C.from&&S.to==C.to)return R(M(t.from,t.to,S));{let U=S?M(t.from,null,S):I(v,!1),E=C?M(null,t.to,C):I(w,!0),T=[];return(S||v).to<(C||w).from-(S&&C?1:0)||v.widgetLineBreaks>1&&U.bottom+n.defaultLineHeight/2F&&he.from=L)break;A>ne&&J(Math.max(le,ne),U==null&&le<=F,Math.min(A,L),E==null&&A>=se,oe.dir)}if(ne=ee.to+1,ne>=L)break}return q.length==0&&J(F,U==null,se,E==null,n.textDirection),{top:z,bottom:ie,horizontal:q}}function I(U,E){let T=u.top+(E?U.top:U.bottom);return{top:T,bottom:T,horizontal:[]}}}function QR(n,e){return n.constructor==e.constructor&&n.eq(e)}class XR{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(td)!=e.state.facet(td)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(td);for(;t!QR(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let l of e)l.update&&t&&l.constructor&&this.drawn[i].constructor&&l.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(l.draw(),t);for(;t;){let l=t.nextSibling;t.remove(),t=l}this.drawn=e,we.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const td=Ce.define();function ON(n){return[Jt.define(e=>new XR(e,n)),td.of(n)]}const jx=!we.ios,Ea=Ce.define({combine(n){return Br(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function $R(n={}){return[Ea.of(n),YR,GR,WR,KO.of(!0)]}function NN(n){return n.startState.facet(Ea)!=n.state.facet(Ea)}const YR=ON({above:!0,markers(n){let{state:e}=n,t=e.facet(Ea),i=[];for(let l of e.selection.ranges){let o=l==e.selection.main;if(l.empty||t.drawRangeCursor&&!(o&&we.ios&&t.iosSelectionHandles)){let a=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=l.empty?l:ae.cursor(l.head,l.assoc);for(let f of Zs.forRange(n,a,u))i.push(f)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=NN(n);return t&&RS(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){RS(e.state,n)},class:"cm-cursorLayer"});function RS(n,e){e.style.animationDuration=n.facet(Ea).cursorBlinkRate+"ms"}const GR=ON({above:!1,markers(n){let e=[],{main:t,ranges:i}=n.state.selection;for(let l of i)if(!l.empty&&(jx||l!=t))for(let o of Zs.forRange(n,"cm-selectionBackground",l))e.push(o);if(we.ios&&!t.empty&&n.state.facet(Ea).iosSelectionHandles){for(let l of Zs.forRange(n,"cm-selectionHandle cm-selectionHandle-start",ae.cursor(t.from,1)))e.push(l);for(let l of Zs.forRange(n,"cm-selectionHandle cm-selectionHandle-end",ae.cursor(t.to,1)))e.push(l)}return e},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||NN(n)},class:"cm-selectionLayer"}),KR=we.gecko&&we.gecko_version==153?"#ffffff01":"transparent",WR=so.highest(Oe.theme({".cm-line":{...jx?{"& ::selection, &::selection":{backgroundColor:`${KR} !important`}}:{},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important",...jx?{"&::selection, & ::selection":{backgroundColor:"Highlight !important"}}:{}}}})),TN=Ye.define({map(n,e){return n==null?null:e.mapPos(n)}}),Yc=In.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(TN)?i.value:t,n)}}),ZR=Jt.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(Yc);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(Yc)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(Yc),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(Yc)!=n&&this.view.dispatch({effects:TN.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function JR(){return[Yc,ZR]}function _S(n,e,t,i,l){e.lastIndex=0;for(let o=n.iterRange(t,i),a=t,u;!o.next().done;a+=o.value.length)if(!o.lineBreak)for(;u=e.exec(o.value);)l(a+u.index,u)}function e_(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:l,to:o}of t)l=Math.max(n.state.doc.lineAt(l).from,l-e),o=Math.min(n.state.doc.lineAt(o).to,o+e),i.length&&i[i.length-1].to>=l?i[i.length-1].to=o:i.push({from:l,to:o});return i}class t_{constructor(e){const{regexp:t,decoration:i,decorate:l,boundary:o,maxLength:a=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,l)this.addMatch=(u,f,d,m)=>l(m,d,d+u[0].length,u,f);else if(typeof i=="function")this.addMatch=(u,f,d,m)=>{let g=i(u,f,d);g&&m(d,d+u[0].length,g)};else if(i)this.addMatch=(u,f,d,m)=>m(d,d+u[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=o,this.maxLength=a}createDeco(e){let t=new zr,i=t.add.bind(t);for(let{from:l,to:o}of e_(e,this.maxLength))_S(e.state.doc,this.regexp,l,o,(a,u)=>this.addMatch(u,e,a,i));return t.finish()}updateDeco(e,t){let i=1e9,l=-1;return e.docChanged&&e.changes.iterChanges((o,a,u,f)=>{f>=e.view.viewport.from&&u<=e.view.viewport.to&&(i=Math.min(u,i),l=Math.max(f,l))}),e.viewportMoved||l-i>1e3?this.createDeco(e.view):l>-1?this.updateRange(e.view,t.map(e.changes),i,l):t}updateRange(e,t,i,l){for(let o of e.visibleRanges){let a=Math.max(o.from,i),u=Math.min(o.to,l);if(u>=a){let f=e.state.doc.lineAt(a),d=f.tof.from;a--)if(this.boundary.test(f.text[a-1-f.from])){m=a;break}for(;ub.push(N.range(S,C));if(f==d)for(this.regexp.lastIndex=m-f.from;(v=this.regexp.exec(f.text))&&v.indexthis.addMatch(C,e,S,w));t=t.update({filterFrom:m,filterTo:g,filter:(S,C)=>Sg,add:b})}}return t}}const Rx=/x/.unicode!=null?"gu":"g",n_=new RegExp(`[\0-\b ---Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,Rx),i_={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let c0=null;function r_(){var n;if(c0==null&&typeof document<"u"&&document.body){let e=document.body.style;c0=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return c0||!1}const nd=Ce.define({combine(n){let e=Br(n,{render:null,specialChars:n_,addSpecialChars:null});return(e.replaceTabs=!r_())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Rx)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Rx)),e}});function l_(n={}){return[nd.of(n),s_()]}let LS=null;function s_(){return LS||(LS=Jt.fromClass(class{constructor(n){this.view=n,this.decorations=He.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(nd)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new t_({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:l}=t.state,o=ui(e[0],0);if(o==9){let a=l.lineAt(i),u=t.state.tabSize,f=Ra(a.text,u,i-a.from);return He.replace({widget:new u_((u-f%u)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=He.replace({widget:new c_(n,o)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(nd);n.startState.facet(nd)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const o_="•";function a_(n){return n>=32?o_:n==10?"␤":String.fromCharCode(9216+n)}class c_ extends ul{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=a_(this.code),i=e.state.phrase("Control character")+" "+(i_[this.code]||"0x"+this.code.toString(16)),l=this.options.render&&this.options.render(this.code,i,t);if(l)return l;let o=document.createElement("span");return o.textContent=t,o.title=i,o.setAttribute("aria-label",i),o.className="cm-specialChar",o}ignoreEvent(){return!1}}class u_ extends ul{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function f_(){return d_}const h_=He.line({class:"cm-activeLine"}),d_=Jt.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let l=n.lineBlockAt(i.head);l.from>e&&(t.push(h_.range(l.from)),e=l.from)}return He.set(t)}},{decorations:n=>n.decorations}),_x=2e3;function m_(n,e,t){let i=Math.min(e.line,t.line),l=Math.max(e.line,t.line),o=[];if(e.off>_x||t.off>_x||e.col<0||t.col<0){let a=Math.min(e.off,t.off),u=Math.max(e.off,t.off);for(let f=i;f<=l;f++){let d=n.doc.line(f);d.length<=u&&o.push(ae.range(d.from+a,d.to+u))}}else{let a=Math.min(e.col,t.col),u=Math.max(e.col,t.col);for(let f=i;f<=l;f++){let d=n.doc.line(f),m=ux(d.text,a,n.tabSize,!0);if(m<0)o.push(ae.cursor(d.to));else{let g=ux(d.text,u,n.tabSize);o.push(ae.range(d.from+m,d.from+g))}}}return o}function p_(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function zS(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),l=t-i.from,o=l>_x?-1:l==i.length?p_(n,e.clientX):Ra(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:o,off:l}}function g_(n,e){let t=zS(n,e),i=n.state.selection;return t?{update(l){if(l.docChanged){let o=l.changes.mapPos(l.startState.doc.line(t.line).from),a=l.state.doc.lineAt(o);t={line:a.number,col:t.col,off:Math.min(t.off,a.length)},i=i.map(l.changes)}},get(l,o,a){let u=zS(n,l);if(!u)return i;let f=m_(n.state,t,u);return f.length?a?ae.create(f.concat(i.ranges)):ae.create(f):i}}:null}function x_(n){let e=(t=>t.altKey&&t.button==0);return Oe.mouseSelectionStyle.of((t,i)=>e(i)?g_(t,i):null)}const y_={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},b_={style:"cursor: crosshair"};function v_(n={}){let[e,t]=y_[n.key||"Alt"],i=Jt.fromClass(class{constructor(l){this.view=l,this.isDown=!1}set(l){this.isDown!=l&&(this.isDown=l,this.view.update([]))}},{eventObservers:{keydown(l){this.set(l.keyCode==e||t(l))},keyup(l){(l.keyCode==e||!t(l))&&this.set(!1)},mousemove(l){this.set(t(l))}}});return[i,Oe.contentAttributes.of(l=>{var o;return!((o=l.plugin(i))===null||o===void 0)&&o.isDown?b_:null})]}const Oh="-10000px";class AN{constructor(e,t,i,l){this.facet=t,this.createTooltipView=i,this.removeTooltipView=l,this.input=e.state.facet(t),this.tooltips=this.input.filter(a=>a);let o=null;this.tooltipViews=this.tooltips.map(a=>o=i(a,o))}update(e,t){var i;let l=e.state.facet(this.facet),o=l.filter(f=>f);if(l===this.input){for(let f of this.tooltipViews)f.update&&f.update(e);return!1}let a=[],u=t?[]:null;for(let f=0;ft[d]=f),t.length=u.length),this.input=l,this.tooltips=o,this.tooltipViews=a,!0}}function EN(n){let e=n.dom.ownerDocument.documentElement,t=e.clientWidth,i=getComputedStyle(e);if(!/stable/.test(i.scrollbarGutter||""))return{left:0,right:t};let l=e.getBoundingClientRect(),o=n.win.scrollX;return{left:Math.max(0,l.left+o-parseFloat(i.marginLeft)),right:Math.min(t,l.right+o+parseFloat(i.marginRight))}}function w_(n){let{left:e,right:t}=EN(n);return{top:0,left:e,right:t,bottom:n.dom.ownerDocument.documentElement.clientHeight}}const u0=Ce.define({combine:n=>{var e,t,i;return{position:we.ios?"absolute":((e=n.find(l=>l.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(l=>l.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(l=>l.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||w_}}}),BS=new WeakMap,Ly=Jt.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(u0);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new AN(n,zy,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(u0);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let l of this.manager.tooltipViews)l.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let l of this.manager.tooltipViews)this.container.appendChild(l.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let l=document.createElement("div");l.className="cm-tooltip-arrow",t.dom.appendChild(l)}return t.dom.style.position=this.position,t.dom.style.top=Oh,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1,i=0;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:a}=this.manager.tooltipViews[0];if(we.safari){let u=a.getBoundingClientRect();t=Math.abs(u.top+1e4)>1||Math.abs(u.left)>1}else t=!!a.offsetParent&&a.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let a=this.parent.getBoundingClientRect();a.width&&a.height&&(n=a.width/this.parent.offsetWidth,e=a.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);else i=EN(this.view).left;let l=this.view.scrollDOM.getBoundingClientRect(),o=Dy(this.view);return{visible:{left:l.left+o.left,top:l.top+o.top,right:l.right-o.right,bottom:l.bottom-o.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((a,u)=>{let f=this.manager.tooltipViews[u];return f.getCoords?f.getCoords(a.pos):this.view.coordsAtPos(a.pos)}),size:this.manager.tooltipViews.map(({dom:a})=>a.getBoundingClientRect()),space:this.view.state.facet(u0).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t,fixedLeft:i}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let u of this.manager.tooltipViews)u.dom.style.position="absolute"}let{visible:t,space:i,scaleX:l,scaleY:o}=n,a=[];for(let u=0;u=Math.min(t.bottom,i.bottom)||g.rightMath.min(t.right,i.right)+.1)){m.style.top=Oh;continue}let v=f.arrow?d.dom.querySelector(".cm-tooltip-arrow"):null,w=v?7:0,S=b.right-b.left,C=(e=BS.get(d))!==null&&e!==void 0?e:b.bottom-b.top,N=d.offset||S_,R=this.view.textDirection==Ot.LTR,M=b.width>i.right-i.left?R?i.left:i.right-b.width:R?Math.max(i.left,Math.min(g.left-(v?14:0)+N.x,i.right-S)):Math.min(Math.max(i.left,g.left-S+(v?14:0)-N.x),i.right-S),I=this.above[u];!f.strictSide&&(I?g.top-C-w-N.yi.bottom)&&I==i.bottom-g.bottom>g.top-i.top&&(I=this.above[u]=!I);let U=(I?g.top-i.top:i.bottom-g.bottom)-w;if(UM&&z.topE&&(E=I?z.top-C-2-w:z.bottom+w+2);if(this.position=="absolute"?(m.style.top=(E-n.parent.top)/o+"px",PS(m,(M-n.parent.left)/l)):(m.style.top=E/o+"px",PS(m,(M-n.fixedLeft)/l)),v){let z=g.left+(R?N.x:-N.x)-(M+14-7);v.style.left=z/l+"px"}d.overlap!==!0&&a.push({left:M,top:E,right:T,bottom:E+C}),m.classList.toggle("cm-tooltip-above",I),m.classList.toggle("cm-tooltip-below",!I),d.positioned&&d.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=Oh}},{eventObservers:{scroll(){this.maybeMeasure()}}});function PS(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}const k_=Oe.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),S_={x:0,y:0},zy=Ce.define({enables:[Ly,k_]}),wd=Ce.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class tm{static create(e){return new tm(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new AN(e,wd,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let l=i[e];if(l!==void 0){if(t===void 0)t=l;else if(t!==l)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const C_=zy.compute([wd],n=>{let e=n.facet(wd);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:tm.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),MN=Ce.define();class O_{constructor(e,t,i,l,o,a){this.view=e,this.source=t,this.field=i,this.locked=l,this.setHover=o,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;ea.bottom||t.xa.right+e.defaultCharacterWidth)return;let u=e.bidiSpans(e.state.doc.lineAt(l)).find(d=>d.from<=l&&d.to>=l),f=u&&u.dir==Ot.RTL?-1:1;o=t.x{if(u&&!(Array.isArray(u)&&!u.length)){let f=Array.isArray(u)?u:[u];l&&this.locked.set(f,l),e.dispatch({effects:this.setHover.of(f)})}};if(o&&"then"in o){let u=this.pending={pos:t};o.then(f=>{this.pending==u&&(this.pending=null,a(f))},f=>di(e.state,f,"hover tooltip"))}else a(o)}get tooltip(){let e=this.view.plugin(Ly),t=e?e.manager.tooltips.findIndex(i=>i.create==tm.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:l,tooltip:o}=this;if(l.length&&!this.locked.has(l)&&o&&!N_(o.dom,e)||this.pending){let{pos:a}=l[0]||this.pending,u=(i=(t=l[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:a;(a==u?this.view.posAtCoords(this.lastMove)!=a:!T_(this.view,a,u,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:l}=this;l.length&&!this.locked.has(l)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Nh=4;function N_(n,e){let{left:t,right:i,top:l,bottom:o}=n.getBoundingClientRect(),a;if(a=n.querySelector(".cm-tooltip-arrow")){let u=a.getBoundingClientRect();l=Math.min(u.top,l),o=Math.max(u.bottom,o)}return e.clientX>=t-Nh&&e.clientX<=i+Nh&&e.clientY>=l-Nh&&e.clientY<=o+Nh}function T_(n,e,t,i,l,o){let a=n.scrollDOM.getBoundingClientRect(),u=n.documentTop+n.documentPadding.top+n.contentHeight;if(a.left>i||a.rightl||Math.min(a.bottom,u)=e&&f<=t}function A_(n,e={}){let t=Ye.define(),i=new WeakMap,l=In.define({create(){return[]},update(a,u){let f=i.get(a);if(a.length&&(e.hideOnChange&&(u.docChanged||u.selection)?a=[]:f&&f(u)?a=[]:e.hideOn&&(a=a.filter(d=>!e.hideOn(u,d)))),u.docChanged&&a.length){let d=[];for(let m of a){let g=u.changes.mapPos(m.pos,-1,Kn.TrackDel);if(g!=null){let b=Object.assign(Object.create(null),m);b.pos=g,b.end!=null&&(b.end=u.changes.mapPos(b.end)),d.push(b)}}a=d}for(let d of u.effects)d.is(t)&&(a=d.value,f=void 0),(d.is(M_)&&!d.value||d.value==l)&&(a=[]);return a.length&&f&&i.set(a,f),a},provide:a=>wd.from(a)});const o=Jt.define(a=>new O_(a,n,l,i,t,e.hoverTime||300));return{active:l,extension:[l,o,MN.of(o),C_]}}function E_(n,e,t,i={}){var l;let o=n.state.facet(MN).map(a=>n.plugin(a)).filter(a=>!!a);if(i.tooltip&&i.tooltip.active){let a=o.find(u=>u.field==i.tooltip.active);a&&(o=[a])}for(let a of o)a.activateHover(n,e,t,(l=i.until)!==null&&l!==void 0?l:(()=>!1))}function DN(n,e){let t=n.plugin(Ly);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const M_=Ye.define(),HS=Ce.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function nm(n,e){let t=n.plugin(jN),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const jN=Jt.fromClass(class{constructor(n){this.input=n.state.facet(mu),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(HS);this.top=new Th(n,!0,e.topContainer),this.bottom=new Th(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(HS);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Th(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Th(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(mu);if(t!=this.input){let i=t.filter(f=>f),l=[],o=[],a=[],u=[];for(let f of i){let d=this.specs.indexOf(f),m;d<0?(m=f(n.view),u.push(m)):(m=this.panels[d],m.update&&m.update(n)),l.push(m),(m.top?o:a).push(m)}this.specs=i,this.panels=l,this.top.sync(o),this.bottom.sync(a);for(let f of u)f.dom.classList.add("cm-panel"),f.mount&&f.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>Oe.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Th{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=IS(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=IS(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function IS(n){let e=n.nextSibling;return n.remove(),e}const mu=Ce.define({enables:jN});function D_(n,e){let t,i=new Promise(a=>t=a),l=a=>R_(a,e,t);n.state.field(id,!1)?n.dispatch({effects:RN.of(l)}):n.dispatch({effects:Ye.appendConfig.of(id.init(()=>[l]))});let o=_N.of(l);return{close:o,result:i.then(a=>((n.win.queueMicrotask||(f=>n.win.setTimeout(f,10)))(()=>{n.state.field(id).indexOf(l)>-1&&n.dispatch({effects:o})}),a))}}function j_(n,e){let t=n.state.field(id,!1)||[];for(let i of t){let l=nm(n,i);if(l&&l.dom.classList.contains(e))return l}return null}const id=In.define({create(){return[]},update(n,e){for(let t of e.effects)t.is(RN)?n=[t.value].concat(n):t.is(_N)&&(n=n.filter(i=>i!=t.value));return n},provide:n=>mu.computeN([n],e=>e.field(n))}),RN=Ye.define(),_N=Ye.define();function R_(n,e,t){let i=e.content?e.content(n,()=>u(null)):null;if(!i){if(i=Ct("form"),e.input){let f=Ct("input",e.input);/^(text|password|number|email|tel|url)$/.test(f.type)&&f.classList.add("cm-textfield"),f.name||(f.name="input"),i.appendChild(Ct("label",(e.label||"")+": ",f))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(Ct("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let l=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let f=0;f{m.keyCode==27?(m.preventDefault(),u(null)):m.keyCode==13&&(m.preventDefault(),u(d))}),d.addEventListener("submit",m=>{m.preventDefault(),u(d)})}let o=Ct("div",i,Ct("button",{onclick:()=>u(null),"aria-label":n.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(o.className=e.class),o.classList.add("cm-dialog");let a=typeof e.focus=="string"?i.querySelector(e.focus):e.focus?i.querySelector("input")||i.querySelector("button"):null;function u(f){o.contains(o.ownerDocument.activeElement)&&n.focus(),t(f)}return{dom:o,top:e.top,mount:()=>{a&&("select"in a?a.select():"focus"in a&&a.focus())},destroy:()=>t(null)}}class ol extends ns{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}ol.prototype.elementClass="";ol.prototype.toDOM=void 0;ol.prototype.mapMode=Kn.TrackBefore;ol.prototype.startSide=ol.prototype.endSide=-1;ol.prototype.point=!0;const rd=Ce.define(),__=Ce.define(),L_={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>it.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},tu=Ce.define();function z_(n){return[LN(),tu.of({...L_,...n})]}const US=Ce.define({combine:n=>n.some(e=>e)});function LN(n){return[B_]}const B_=Jt.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=n.state.facet(tu).map(e=>new qS(n,e)),this.fixed=!n.state.facet(US);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(US)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=it.iter(this.view.state.facet(rd),this.view.viewport.from),i=[],l=this.gutters.map(o=>new P_(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(o.type)){let a=!0;for(let u of o.type)if(u.type==Ln.Text&&a){Lx(t,i,u.from);for(let f of l)f.line(this.view,u,i);a=!1}else if(u.widget)for(let f of l)f.widget(this.view,u)}else if(o.type==Ln.Text){Lx(t,i,o.from);for(let a of l)a.line(this.view,o,i)}else if(o.widget)for(let a of l)a.widget(this.view,o);for(let o of l)o.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(tu),t=n.state.facet(tu),i=n.docChanged||n.heightChanged||n.viewportChanged||!it.eq(n.startState.facet(rd),n.state.facet(rd),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let l of this.gutters)l.update(n)&&(i=!0);else{i=!0;let l=[];for(let o of t){let a=e.indexOf(o);a<0?l.push(new qS(this.view,o)):(this.gutters[a].update(n),l.push(this.gutters[a]))}for(let o of this.gutters)o.dom.remove(),l.indexOf(o)<0&&o.destroy();for(let o of l)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=l}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>Oe.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,l=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Ot.LTR?{left:i,right:l}:{right:i,left:l}})});function FS(n){return Array.isArray(n)?n:[n]}function Lx(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class P_{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=it.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:l}=this,o=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==l.elements.length){let u=new zN(e,a,o,i);l.elements.push(u),l.dom.appendChild(u.dom)}else l.elements[this.i].update(e,a,o,i);this.height=t.bottom,this.i++}line(e,t,i){let l=[];Lx(this.cursor,l,t.from),i.length&&(l=l.concat(i));let o=this.gutter.config.lineMarker(e,t,l);o&&l.unshift(o);let a=this.gutter;l.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,l)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),l=i?[i]:null;for(let o of e.state.facet(__)){let a=o(e,t.widget,t);a&&(l||(l=[])).push(a)}l&&this.addElement(e,t,l)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class qS{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,l=>{let o=l.target,a;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let f=o.getBoundingClientRect();a=(f.top+f.bottom)/2}else a=l.clientY;let u=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[i](e,u,l)&&l.preventDefault()});this.markers=FS(t.markers(e)),t.initialSpacer&&(this.spacer=new zN(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=FS(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let l=this.config.updateSpacer(this.spacer.markers[0],e);l!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[l])}let i=e.view.viewport;return!it.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class zN{constructor(e,t,i,l){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,l)}update(e,t,i,l){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),H_(this.markers,l)||this.setMarkers(e,l)}setMarkers(e,t){let i="cm-gutterElement",l=this.dom.firstChild;for(let o=0,a=0;;){let u=a,f=oo(u,f,d)||a(u,f,d):a}return i}})}});class f0 extends ol{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function h0(n,e){return n.state.facet(ca).formatNumber(e,n.state)}const F_=tu.compute([ca],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(I_)},lineMarker(e,t,i){return i.some(l=>l.toDOM)?null:new f0(h0(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let l of e.state.facet(U_)){let o=l(e,t,i);if(o)return o}return null},lineMarkerChange:e=>e.startState.facet(ca)!=e.state.facet(ca),initialSpacer(e){return new f0(h0(e,VS(e.state.doc.lines)))},updateSpacer(e,t){let i=h0(t.view,VS(t.view.state.doc.lines));return i==e.number?e:new f0(i)},domEventHandlers:n.facet(ca).domEventHandlers,side:"before"}));function q_(n={}){return[ca.of(n),LN(),F_]}function VS(n){let e=9;for(;e{let e=[],t=-1;for(let i of n.selection.ranges){let l=n.doc.lineAt(i.head).from;l>t&&(t=l,e.push(V_.range(l)))}return it.of(e)});function X_(){return Q_}const BN=1024;let $_=0;class d0{constructor(e,t){this.from=e,this.to=t}}class Je{constructor(e={}){this.id=$_++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=pi.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}Je.closedBy=new Je({deserialize:n=>n.split(" ")});Je.openedBy=new Je({deserialize:n=>n.split(" ")});Je.group=new Je({deserialize:n=>n.split(" ")});Je.isolate=new Je({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});Je.contextHash=new Je({perNode:!0});Je.lookAhead=new Je({perNode:!0});Je.mounted=new Je({perNode:!0});class nu{constructor(e,t,i,l=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=l}static get(e){return e&&e.props&&e.props[Je.mounted.id]}}const Y_=Object.create(null);class pi{constructor(e,t,i,l=0){this.name=e,this.props=t,this.id=i,this.flags=l}static define(e){let t=e.props&&e.props.length?Object.create(null):Y_,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),l=new pi(e.name||"",t,e.id,i);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(l)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[o[0].id]=o[1]}}return l}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(Je.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let l of i.split(" "))t[l]=e[i];return i=>{for(let l=i.prop(Je.group),o=-1;o<(l?l.length:0);o++){let a=t[o<0?i.name:l[o]];if(a)return a}}}}pi.none=new pi("",Object.create(null),0,8);class By{constructor(e){this.types=e;for(let t=0;t0;for(let f=this.cursor(a|$t.IncludeAnonymous);;){let d=!1;if(f.from<=o&&f.to>=l&&(!u&&f.type.isAnonymous||t(f)!==!1)){if(f.firstChild())continue;d=!0}for(;d&&i&&(u||!f.type.isAnonymous)&&i(f),!f.nextSibling();){if(!f.parent())return;d=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:Iy(pi.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,l)=>new cn(this.type,t,i,l,this.propValues),e.makeTree||((t,i,l)=>new cn(pi.none,t,i,l)))}static build(e){return Z_(e)}}cn.empty=new cn(pi.none,[],[],0);class Py{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Py(this.buffer,this.index)}}class ss{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return pi.none}toString(){let e=[];for(let t=0;t0));f=a[f+3]);return u}slice(e,t,i){let l=this.buffer,o=new Uint16Array(t-e),a=0;for(let u=e,f=0;u=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function pu(n,e,t,i){for(var l;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?u.length:-1;e!=d;e+=t){let m=u[e],g=f[e]+a.from,b;if(!(!(o&$t.EnterBracketed&&m instanceof cn&&(b=nu.get(m))&&!b.overlay&&b.bracketed&&i>=g&&i<=g+m.length)&&!PN(l,i,g,g+m.length))){if(m instanceof ss){if(o&$t.ExcludeBuffers)continue;let v=m.findChild(0,m.buffer.length,t,i-g,l);if(v>-1)return new Wl(new G_(a,m,e,g),null,v)}else if(o&$t.IncludeAnonymous||!m.type.isAnonymous||Hy(m)){let v;if(!(o&$t.IgnoreMounts)&&(v=nu.get(m))&&!v.overlay)return new qi(v.tree,g,e,a);let w=new qi(m,g,e,a);return o&$t.IncludeAnonymous||!w.type.isAnonymous?w:w.nextChild(t<0?m.children.length-1:0,t,i,l,o)}}}if(o&$t.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+t:e=t<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let l;if(!(i&$t.IgnoreOverlays)&&(l=nu.get(this._tree))&&l.overlay){let o=e-this.from,a=i&$t.EnterBracketed&&l.bracketed;for(let{from:u,to:f}of l.overlay)if((t>0||a?u<=o:u=o:f>o))return new qi(l.tree,l.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function XS(n,e,t,i){let l=n.cursor(),o=[];if(!l.firstChild())return o;if(t!=null){for(let a=!1;!a;)if(a=l.type.is(t),!l.nextSibling())return o}for(;;){if(i!=null&&l.type.is(i))return o;if(l.type.is(e)&&o.push(l.node),!l.nextSibling())return i==null?o:[]}}function zx(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class G_{constructor(e,t,i,l){this.parent=e,this.buffer=t,this.index=i,this.start=l}}class Wl extends HN{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:l}=this.context,o=l.findChild(this.index+4,l.buffer[this.index+3],e,t-this.context.start,i);return o<0?null:new Wl(this.context,this,o)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&$t.ExcludeBuffers)return null;let{buffer:l}=this.context,o=l.findChild(this.index+4,l.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return o<0?null:new Wl(this.context,this,o)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Wl(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Wl(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,l=this.index+4,o=i.buffer[this.index+3];if(o>l){let a=i.buffer[this.index+1];e.push(i.slice(l,o,a)),t.push(0)}return new cn(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function IN(n){if(!n.length)return null;let e=0,t=n[0];for(let o=1;ot.from||a.to=e){let u=new qi(a.tree,a.overlay[0].from+o.from,-1,o);(l||(l=[i])).push(pu(u,e,t,!1))}}return l?IN(l):i}class Bx{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~$t.EnterBracketed,e instanceof qi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:l}=this.buffer;return this.type=t||l.set.types[l.buffer[e]],this.from=i+l.buffer[e+1],this.to=i+l.buffer[e+2],!0}yield(e){return e?e instanceof qi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:l}=this.buffer,o=l.findChild(this.index+4,l.buffer[this.index+3],e,t-this.buffer.start,i);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&$t.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&$t.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&$t.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let l=i<0?0:this.stack[i]+4;if(this.index!=l)return this.yieldBuf(t.findChild(l,this.index,-1,0,4))}else{let l=t.buffer[this.index+3];if(l<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(l)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:l}=this;if(l){if(e>0){if(this.index-1)for(let o=t+e,a=e<0?-1:i._tree.children.length;o!=a;o+=e){let u=i._tree.children[o];if(this.mode&$t.IncludeAnonymous||u instanceof ss||!u.type.isAnonymous||Hy(u))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let a=e;a;a=a._parent)if(a.index==l){if(l==this.index)return a;t=a,i=o+1;break e}l=this.stack[--o]}for(let l=i;l=0;o--){if(o<0)return zx(this._tree,e,l);let a=i[t.buffer[this.stack[o]]];if(!a.isAnonymous){if(e[l]&&e[l]!=a.name)return!1;l--}}return!0}}function Hy(n){return n.children.some(e=>e instanceof ss||!e.type.isAnonymous||Hy(e))}function Z_(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:l=BN,reused:o=[],minRepeatType:a=i.types.length}=n,u=Array.isArray(t)?new Py(t,t.length):t,f=i.types,d=0,m=0;function g(U,E,T,z,ie,q){let{id:J,start:F,end:se,size:he}=u,ne=m,L=d;if(he<0)if(u.next(),he==-1){let Le=o[J];T.push(Le),z.push(F-U);return}else if(he==-3){d=J;return}else if(he==-4){m=J;return}else throw new RangeError(`Unrecognized record size: ${he}`);let ee=f[J],oe,le,A=F-U;if(se-F<=l&&(le=C(u.pos-E,ie))){let Le=new Uint16Array(le.size-le.skip),_e=u.pos-le.size,B=Le.length;for(;u.pos>_e;)B=N(le.start,Le,B);oe=new ss(Le,se-le.start,i),A=le.start-U}else{let Le=u.pos-he;u.next();let _e=[],B=[],j=J>=a?J:-1,$=0,fe=se,pe=ne;for(;u.pos>Le;)j>=0&&u.id==j&&u.size>=0?(u.end<=fe-l&&(w(_e,B,F,$,u.end,fe,j,pe,L),$=_e.length,fe=u.end,pe=m),u.next()):q>2500?b(F,Le,_e,B):(j>=0&&u.size==-1&&o[u.id].type==i.types[j]&&($<_e.length&&w(_e,B,F,$,u.end,fe,j,pe,L),$=_e.length+1,fe=u.start,pe=m),g(F,Le,_e,B,j,q+1));if(j>=0&&$>0&&$<_e.length&&w(_e,B,F,$,F,fe,j,pe,L),_e.reverse(),B.reverse(),j>-1&&$>0){let Ne=v(ee,L);oe=Iy(ee,_e,B,0,_e.length,0,se-F,Ne,Ne)}else oe=S(ee,_e,B,se-F,ne-se,L)}T.push(oe),z.push(A)}function b(U,E,T,z){let ie=[],q=0,J=-1;for(;u.pos>E;){let{id:F,start:se,end:he,size:ne}=u;if(ne>4)u.next();else{if(J>-1&&se=0;he-=3)F[ne++]=ie[he],F[ne++]=ie[he+1]-se,F[ne++]=ie[he+2]-se,F[ne++]=ne;T.push(new ss(F,ie[2]-se,i)),z.push(se-U)}}function v(U,E){return(T,z,ie)=>{let q=0,J=T.length-1,F,se;if(J>=0&&(F=T[J])instanceof cn){if(!J&&F.type==U&&F.length==ie)return F;(se=F.prop(Je.lookAhead))&&(q=z[J]+F.length+se-ie)}return S(U,T,z,ie,q,E)}}function w(U,E,T,z,ie,q,J,F,se){let he=[],ne=[];for(;U.length>z;)he.push(U.pop()),ne.push(E.pop()+T-ie);U.push(S(i.types[J],he,ne,q-ie,F-q,se)),E.push(ie-T)}function S(U,E,T,z,ie,q,J){if(q){let F=[Je.contextHash,q];J=J?[F].concat(J):[F]}if(ie>25){let F=[Je.lookAhead,ie];J=J?[F].concat(J):[F]}return new cn(U,E,T,z,J)}function C(U,E){let T=u.fork(),z=0,ie=0,q=0,J=T.end-l,F={size:0,start:0,skip:0};e:for(let se=T.pos-U;T.pos>se;){let he=T.size;if(T.id==E&&he>=0){F.size=z,F.start=ie,F.skip=q,q+=4,z+=4,T.next();continue}let ne=T.pos-he;if(he<0||ne=a?4:0,ee=T.start;for(T.next();T.pos>ne;){if(T.size<0)if(T.size==-3||T.size==-4)L+=4;else break e;else T.id>=a&&(L+=4);T.next()}ie=ee,z+=he,q+=L}return(E<0||z==U)&&(F.size=z,F.start=ie,F.skip=q),F.size>4?F:void 0}function N(U,E,T){let{id:z,start:ie,end:q,size:J}=u;if(u.next(),J>=0&&z4){let se=u.pos-(J-4);for(;u.pos>se;)T=N(U,E,T)}E[--T]=F,E[--T]=q-U,E[--T]=ie-U,E[--T]=z}else J==-3?d=z:J==-4&&(m=z);return T}let R=[],M=[];for(;u.pos>0;)g(n.start||0,n.bufferStart||0,R,M,-1,0);let I=(e=n.length)!==null&&e!==void 0?e:R.length?M[0]+R[0].length:0;return new cn(f[n.topID],R.reverse(),M.reverse(),I)}const $S=new WeakMap;function ld(n,e){if(!n.isAnonymous||e instanceof ss||e.type!=n)return 1;let t=$S.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof cn)){t=1;break}t+=ld(n,i)}$S.set(e,t)}return t}function Iy(n,e,t,i,l,o,a,u,f){let d=0;for(let w=i;w=m)break;E+=T}if(M==I+1){if(E>m){let T=w[I];v(T.children,T.positions,0,T.children.length,S[I]+R);continue}g.push(w[I])}else{let T=S[M-1]+w[M-1].length-U;g.push(Iy(n,w,S,I,M,U,T,null,f))}b.push(U+R-o)}}return v(e,t,i,l,0),(u||f)(g,b,a)}class Js{constructor(e,t,i,l,o=!1,a=!1){this.from=e,this.to=t,this.tree=i,this.offset=l,this.open=(o?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let l=[new Js(0,e.length,e,0,!1,i)];for(let o of t)o.to>e.length&&l.push(o);return l}static applyChanges(e,t,i=128){if(!t.length)return e;let l=[],o=1,a=e.length?e[0]:null;for(let u=0,f=0,d=0;;u++){let m=u=i)for(;a&&a.from=b.from||g<=b.to||d){let v=Math.max(b.from,f)-d,w=Math.min(b.to,g)-d;b=v>=w?null:new Js(v,w,b.tree,b.offset+d,u>0,!!m)}if(b&&l.push(b),a.to>g)break;a=onew d0(l.from,l.to)):[new d0(0,0)]:[new d0(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let l=this.startParse(e,t,i);for(;;){let o=l.advance();if(o)return o}}}class J_{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new Je({perNode:!0});let eL=0,tl=class Px{constructor(e,t,i,l){this.name=e,this.set=t,this.base=i,this.modified=l,this.id=eL++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof Px&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let l=new Px(i,[],null,[]);if(l.set.push(l),t)for(let o of t.set)l.set.push(o);return l}static defineModifier(e){let t=new kd(e);return i=>i.modified.indexOf(t)>-1?i:kd.get(i.base||i,i.modified.concat(t).sort((l,o)=>l.id-o.id))}},tL=0;class kd{constructor(e){this.name=e,this.instances=[],this.id=tL++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(u=>u.base==e&&nL(t,u.modified));if(i)return i;let l=[],o=new tl(e.name,l,e,t);for(let u of t)u.instances.push(o);let a=iL(t);for(let u of e.set)if(!u.modified.length)for(let f of a)l.push(kd.get(u,f));return o}}function nL(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function iL(n){let e=[[]];for(let t=0;ti.length-t.length)}function FN(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let l of t.split(" "))if(l){let o=[],a=2,u=l;for(let g=0;;){if(u=="..."&&g>0&&g+3==l.length){a=1;break}let b=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!b)throw new RangeError("Invalid path: "+l);if(o.push(b[0]=="*"?"":b[0][0]=='"'?JSON.parse(b[0]):b[0]),g+=b[0].length,g==l.length)break;let v=l[g++];if(g==l.length&&v=="!"){a=0;break}if(v!="/")throw new RangeError("Invalid path: "+l);u=l.slice(g)}let f=o.length-1,d=o[f];if(!d)throw new RangeError("Invalid path: "+l);let m=new gu(i,a,f>0?o.slice(0,f):null);e[d]=m.sort(e[d])}}return qN.add(e)}const qN=new Je({combine(n,e){let t,i,l;for(;n||e;){if(!n||e&&n.depth<=e.depth?(l=e,e=e.next):(l=n,n=n.next),t&&t.mode==l.mode&&!l.context&&!t.context)continue;let o=new gu(l.tags,l.mode,l.context);t?t.next=o:i=o,t=o}return i}});class gu{constructor(e,t,i,l){this.tags=e,this.mode=t,this.context=i,this.next=l}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let a=l;for(let u of o)for(let f of u.set){let d=t[f.id];if(d){a=a?a+" "+d:d;break}}return a},scope:i}}function rL(n,e){let t=null;for(let i of n){let l=i.style(e);l&&(t=t?t+" "+l:l)}return t}function lL(n,e,t,i=0,l=n.length){let o=new sL(i,Array.isArray(e)?e:[e],t);o.highlightRange(n.cursor(),i,l,"",o.highlighters),o.flush(l)}class sL{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,l,o){let{type:a,from:u,to:f}=e;if(u>=i||f<=t)return;a.isTop&&(o=this.highlighters.filter(v=>!v.scope||v.scope(a)));let d=l,m=oL(e)||gu.empty,g=rL(o,m.tags);if(g&&(d&&(d+=" "),d+=g,m.mode==1&&(l+=(l?" ":"")+g)),this.startSpan(Math.max(t,u),d),m.opaque)return;let b=e.tree&&e.tree.prop(Je.mounted);if(b&&b.overlay){let v=e.node.enter(b.overlay[0].from+u,1),w=this.highlighters.filter(C=>!C.scope||C.scope(b.tree.type)),S=e.firstChild();for(let C=0,N=u;;C++){let R=C=M||!e.nextSibling())););if(!R||M>i)break;N=R.to+u,N>t&&(this.highlightRange(v.cursor(),Math.max(t,R.from+u),Math.min(i,N),"",w),this.startSpan(Math.min(i,N),d))}S&&e.parent()}else if(e.firstChild()){b&&(l="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,l,o),this.startSpan(Math.min(i,e.to),d)}while(e.nextSibling());e.parent()}}}function oL(n){let e=n.type.prop(qN);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const be=tl.define,Eh=be(),Xl=be(),YS=be(Xl),GS=be(Xl),$l=be(),Mh=be($l),m0=be($l),Or=be(),Us=be(Or),Sr=be(),Cr=be(),Hx=be(),Pc=be(Hx),Dh=be(),me={comment:Eh,lineComment:be(Eh),blockComment:be(Eh),docComment:be(Eh),name:Xl,variableName:be(Xl),typeName:YS,tagName:be(YS),propertyName:GS,attributeName:be(GS),className:be(Xl),labelName:be(Xl),namespace:be(Xl),macroName:be(Xl),literal:$l,string:Mh,docString:be(Mh),character:be(Mh),attributeValue:be(Mh),number:m0,integer:be(m0),float:be(m0),bool:be($l),regexp:be($l),escape:be($l),color:be($l),url:be($l),keyword:Sr,self:be(Sr),null:be(Sr),atom:be(Sr),unit:be(Sr),modifier:be(Sr),operatorKeyword:be(Sr),controlKeyword:be(Sr),definitionKeyword:be(Sr),moduleKeyword:be(Sr),operator:Cr,derefOperator:be(Cr),arithmeticOperator:be(Cr),logicOperator:be(Cr),bitwiseOperator:be(Cr),compareOperator:be(Cr),updateOperator:be(Cr),definitionOperator:be(Cr),typeOperator:be(Cr),controlOperator:be(Cr),punctuation:Hx,separator:be(Hx),bracket:Pc,angleBracket:be(Pc),squareBracket:be(Pc),paren:be(Pc),brace:be(Pc),content:Or,heading:Us,heading1:be(Us),heading2:be(Us),heading3:be(Us),heading4:be(Us),heading5:be(Us),heading6:be(Us),contentSeparator:be(Or),list:be(Or),quote:be(Or),emphasis:be(Or),strong:be(Or),link:be(Or),monospace:be(Or),strikethrough:be(Or),inserted:be(),deleted:be(),changed:be(),invalid:be(),meta:Dh,documentMeta:be(Dh),annotation:be(Dh),processingInstruction:be(Dh),definition:tl.defineModifier("definition"),constant:tl.defineModifier("constant"),function:tl.defineModifier("function"),standard:tl.defineModifier("standard"),local:tl.defineModifier("local"),special:tl.defineModifier("special")};for(let n in me){let e=me[n];e instanceof tl&&(e.name=n)}VN([{tag:me.link,class:"tok-link"},{tag:me.heading,class:"tok-heading"},{tag:me.emphasis,class:"tok-emphasis"},{tag:me.strong,class:"tok-strong"},{tag:me.keyword,class:"tok-keyword"},{tag:me.atom,class:"tok-atom"},{tag:me.bool,class:"tok-bool"},{tag:me.url,class:"tok-url"},{tag:me.labelName,class:"tok-labelName"},{tag:me.inserted,class:"tok-inserted"},{tag:me.deleted,class:"tok-deleted"},{tag:me.literal,class:"tok-literal"},{tag:me.string,class:"tok-string"},{tag:me.number,class:"tok-number"},{tag:[me.regexp,me.escape,me.special(me.string)],class:"tok-string2"},{tag:me.variableName,class:"tok-variableName"},{tag:me.local(me.variableName),class:"tok-variableName tok-local"},{tag:me.definition(me.variableName),class:"tok-variableName tok-definition"},{tag:me.special(me.variableName),class:"tok-variableName2"},{tag:me.definition(me.propertyName),class:"tok-propertyName tok-definition"},{tag:me.typeName,class:"tok-typeName"},{tag:me.namespace,class:"tok-namespace"},{tag:me.className,class:"tok-className"},{tag:me.macroName,class:"tok-macroName"},{tag:me.propertyName,class:"tok-propertyName"},{tag:me.operator,class:"tok-operator"},{tag:me.comment,class:"tok-comment"},{tag:me.meta,class:"tok-meta"},{tag:me.invalid,class:"tok-invalid"},{tag:me.punctuation,class:"tok-punctuation"}]);var p0;const ua=new Je;function aL(n){return Ce.define({combine:n?e=>e.concat(n):void 0})}const cL=new Je;class tr{constructor(e,t,i=[],l=""){this.data=e,this.name=l,dt.prototype.hasOwnProperty("tree")||Object.defineProperty(dt.prototype,"tree",{get(){return Hn(this)}}),this.parser=t,this.extension=[os.of(this),dt.languageData.of((o,a,u)=>{let f=KS(o,a,u),d=f.type.prop(ua);if(!d)return[];let m=o.facet(d),g=f.type.prop(cL);if(g){let b=f.resolve(a-f.from,u);for(let v of g)if(v.test(b,o)){let w=o.facet(v.facet);return v.type=="replace"?w:w.concat(m)}}return m})].concat(i)}isActiveAt(e,t,i=-1){return KS(e,t,i).type.prop(ua)==this.data}findRegions(e){let t=e.facet(os);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],l=(o,a)=>{if(o.prop(ua)==this.data){i.push({from:a,to:a+o.length});return}let u=o.prop(Je.mounted);if(u){if(u.tree.prop(ua)==this.data){if(u.overlay)for(let f of u.overlay)i.push({from:f.from+a,to:f.to+a});else i.push({from:a,to:a+o.length});return}else if(u.overlay){let f=i.length;if(l(u.tree,u.overlay[0].from+a),i.length>f)return}}for(let f=0;fi.isTop?t:void 0)]}),e.name)}configure(e,t){return new Sd(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Hn(n){let e=n.field(tr.state,!1);return e?e.tree:cn.empty}class uL{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let Hc=null;class Cd{constructor(e,t,i=[],l,o,a,u,f){this.parser=e,this.state=t,this.fragments=i,this.tree=l,this.treeLen=o,this.viewport=a,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Cd(e,t,[],cn.empty,0,i,[],null)}startParse(){return this.parser.startParse(new uL(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=cn.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let l=Date.now()+e;e=()=>Date.now()>l}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Js.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Hc;Hc=this;try{return e()}finally{Hc=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=WS(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:l,treeLen:o,viewport:a,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((d,m,g,b)=>f.push({fromA:d,toA:m,fromB:g,toB:b})),i=Js.applyChanges(i,f),l=cn.empty,o=0,a={from:e.mapPos(a.from,-1),to:e.mapPos(a.to,1)},this.skipped.length){u=[];for(let d of this.skipped){let m=e.mapPos(d.from,1),g=e.mapPos(d.to,-1);me.from&&(this.fragments=WS(this.fragments,l,o),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends UN{createParse(t,i,l){let o=l[0].from,a=l[l.length-1].to;return{parsedPos:o,advance(){let f=Hc;if(f){for(let d of l)f.tempSkipped.push(d);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=a,new cn(pi.none,[],[],a-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Hc}}function WS(n,e,t){return Js.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class Ma{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new Ma(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Cd.create(e.facet(os).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new Ma(i)}}tr.state=In.define({create:Ma.init,update(n,e){for(let t of e.effects)if(t.is(tr.setState))return t.value;return e.startState.facet(os)!=e.state.facet(os)?Ma.init(e.state):n.apply(e)}});let QN=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(QN=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const g0=typeof navigator<"u"&&(!((p0=navigator.scheduling)===null||p0===void 0)&&p0.isInputPending)?()=>navigator.scheduling.isInputPending():null,fL=Jt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(tr.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(tr.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=QN(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndl+1e3,f=o.context.work(()=>g0&&g0()||Date.now()>a,l+(u?0:1e5));this.chunkBudget-=Date.now()-t,(f||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:tr.setState.of(new Ma(o.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>di(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),os=Ce.define({combine(n){return n.length?n[0]:null},enables:n=>[tr.state,fL,Oe.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class hL{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const dL=Ce.define(),Uy=Ce.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Od(n){let e=n.facet(Uy);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function xu(n,e){let t="",i=n.tabSize,l=n.facet(Uy)[0];if(l==" "){for(;e>=i;)t+=" ",e-=i;l=" "}for(let o=0;o=e?mL(n,t,e):null}class im{constructor(e,t={}){this.state=e,this.options=t,this.unit=Od(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:l,simulateDoubleBreak:o}=this.options;return l!=null&&l>=i.from&&l<=i.to?o&&l==e?{text:"",from:e}:(t<0?l-1&&(o+=a-this.countColumn(i,i.search(/\S|$/))),o}countColumn(e,t=e.length){return Ra(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:l}=this.lineAt(e,t),o=this.options.overrideIndentation;if(o){let a=o(l);if(a>-1)return a}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const XN=new Je;function mL(n,e,t){let i=e.resolveStack(t),l=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(l!=i.node){let o=[];for(let a=l;a&&!(a.fromi.node.to||a.from==i.node.from&&a.type==i.node.type);a=a.parent)o.push(a);for(let a=o.length-1;a>=0;a--)i={node:o[a],next:i}}return $N(i,n,t)}function $N(n,e,t){for(let i=n;i;i=i.next){let l=gL(i.node);if(l)return l(qy.create(e,t,i))}return 0}function pL(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function gL(n){let e=n.type.prop(XN);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(Je.closedBy))){let l=n.lastChild,o=l&&i.indexOf(l.name)>-1;return a=>YN(a,!0,1,void 0,o&&!pL(a)?l.from:void 0)}return n.parent==null?xL:null}function xL(){return 0}class qy extends im{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new qy(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(yL(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return $N(this.context.next,this.base,this.pos)}}function yL(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function bL(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let l=n.options.simulateBreak,o=n.state.doc.lineAt(t.from),a=l==null||l<=o.from?o.to:Math.min(o.to,l);for(let u=t.to;;){let f=e.childAfter(u);if(!f||f==i)return null;if(!f.type.isSkipped){if(f.from>=a)return null;let d=/^ */.exec(o.text.slice(t.to-o.from))[0].length;return{from:t.from,to:t.to+d}}u=f.to}}function ZS({closing:n,align:e=!0,units:t=1}){return i=>YN(i,e,t,n)}function YN(n,e,t,i,l){let o=n.textAfter,a=o.match(/^\s*/)[0].length,u=i&&o.slice(a,a+i.length)==i||l==n.pos+a,f=e?bL(n):null;return f?u?n.column(f.from):n.column(f.to):n.baseIndent+(u?0:n.unit*t)}const vL=200;function wL(){return dt.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,l=t.lineAt(i);if(i>l.from+vL)return n;let o=t.sliceString(l.from,i);if(!e.some(d=>d.test(o)))return n;let{state:a}=n,u=-1,f=[];for(let{head:d}of a.selection.ranges){let m=a.doc.lineAt(d);if(m.from==u)continue;u=m.from;let g=Fy(a,m.from);if(g==null)continue;let b=/^\s*/.exec(m.text)[0],v=xu(a,g);b!=v&&f.push({from:m.from,to:m.from+b.length,insert:v})}return f.length?[n,{changes:f,sequential:!0}]:n})}const kL=Ce.define(),GN=new Je;function SL(n){let e=n.firstChild,t=n.lastChild;return e&&e.tot)continue;if(o&&u.from=e&&d.to>t&&(o=d)}}return o}function OL(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function Nd(n,e,t){for(let i of n.facet(kL)){let l=i(n,e,t);if(l)return l}return CL(n,e,t)}function KN(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const rm=Ye.define({map:KN}),Eu=Ye.define({map:KN});function WN(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const ro=In.define({create(){return He.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,l)=>n=JS(n,i,l)),n=n.map(e.changes);let t=[];for(let i of e.effects)i.is(rm)&&!NL(n,i.value.from,i.value.to)?t.push(i.value):i.is(Eu)&&(n=n.update({filter:(l,o)=>i.value.from!=l||i.value.to!=o,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(eT),l=t.map(o=>(i?He.replace({widget:new RL(i(e.state,o))}):e2).range(o.from,o.to));n=n.update({add:l})}return e.selection&&(n=JS(n,e.selection.main.head)),n},provide:n=>Oe.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,l)=>{t.push(i,l)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{le&&(i=!0)}),i?n.update({filterFrom:e,filterTo:t,filter:(l,o)=>l>=t||o<=e}):n}function Td(n,e,t){var i;let l=null;return(i=n.field(ro,!1))===null||i===void 0||i.between(e,t,(o,a)=>{(!l||l.from>o)&&(l={from:o,to:a})}),l}function NL(n,e,t){let i=!1;return n.between(e,e,(l,o)=>{l==e&&o==t&&(i=!0)}),i}function ZN(n,e){return n.field(ro,!1)?e:e.concat(Ye.appendConfig.of(tT()))}const TL=n=>{for(let e of WN(n)){let t=Nd(n.state,e.from,e.to);if(t)return n.dispatch({effects:ZN(n.state,[rm.of(t),JN(n,t)])}),!0}return!1},AL=n=>{if(!n.state.field(ro,!1))return!1;let e=[];for(let t of WN(n)){let i=Td(n.state,t.from,t.to);i&&e.push(Eu.of(i),JN(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function JN(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,l=n.state.doc.lineAt(e.to).number;return Oe.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${l}.`)}const EL=n=>{let{state:e}=n,t=[];for(let i=0;i{let e=n.state.field(ro,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,l)=>{t.push(Eu.of({from:i,to:l}))}),n.dispatch({effects:t}),!0},DL=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:TL},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:AL},{key:"Ctrl-Alt-[",run:EL},{key:"Ctrl-Alt-]",run:ML}],jL={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},eT=Ce.define({combine(n){return Br(n,jL)}});function tT(n){return[ro,zL]}function nT(n,e){let{state:t}=n,i=t.facet(eT),l=a=>{let u=n.lineBlockAt(n.posAtDOM(a.target)),f=Td(n.state,u.from,u.to);f&&n.dispatch({effects:Eu.of(f)}),a.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,l,e);let o=document.createElement("span");return o.textContent=i.placeholderText,o.setAttribute("aria-label",t.phrase("folded code")),o.title=t.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=l,o}const e2=He.replace({widget:new class extends ul{toDOM(n){return nT(n,null)}}});class RL extends ul{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return nT(e,this.value)}}const _L={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class x0 extends ol{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function LL(n={}){let e={..._L,...n},t=new x0(e,!0),i=new x0(e,!1),l=Jt.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(os)!=a.state.facet(os)||a.startState.field(ro,!1)!=a.state.field(ro,!1)||Hn(a.startState)!=Hn(a.state)||e.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let u=new zr;for(let f of a.viewportLineBlocks){let d=Td(a.state,f.from,f.to)?i:Nd(a.state,f.from,f.to)?t:null;d&&u.add(f.from,f.from,d)}return u.finish()}}),{domEventHandlers:o}=e;return[l,z_({class:"cm-foldGutter",markers(a){var u;return((u=a.plugin(l))===null||u===void 0?void 0:u.markers)||it.empty},initialSpacer(){return new x0(e,!1)},domEventHandlers:{...o,click:(a,u,f)=>{if(o.click&&o.click(a,u,f))return!0;let d=Td(a.state,u.from,u.to);if(d)return a.dispatch({effects:Eu.of(d)}),!0;let m=Nd(a.state,u.from,u.to);return m?(a.dispatch({effects:rm.of(m)}),!0):!1}}}),tT()]}const zL=Oe.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Mu{constructor(e,t){this.specs=e;let i;function l(u){let f=is.newName();return(i||(i=Object.create(null)))["."+f]=u,f}const o=typeof t.all=="string"?t.all:t.all?l(t.all):void 0,a=t.scope;this.scope=a instanceof tr?u=>u.prop(ua)==a.data:a?u=>u==a:void 0,this.style=VN(e.map(u=>({tag:u.tag,class:u.class||l(Object.assign({},u,{tag:null}))})),{all:o}).style,this.module=i?new is(i):null,this.themeType=t.themeType}static define(e,t){return new Mu(e,t||{})}}const Ix=Ce.define(),iT=Ce.define({combine(n){return n.length?[n[0]]:null}});function y0(n){let e=n.facet(Ix);return e.length?e:n.facet(iT)}function rT(n,e){let t=[PL],i;return n instanceof Mu&&(n.module&&t.push(Oe.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(iT.of(n)):i?t.push(Ix.computeN([Oe.darkTheme],l=>l.facet(Oe.darkTheme)==(i=="dark")?[n]:[])):t.push(Ix.of(n)),t}class BL{constructor(e){this.markCache=Object.create(null),this.tree=Hn(e.state),this.decorations=this.buildDeco(e,y0(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Hn(e.state),i=y0(e.state),l=i!=y0(e.startState),{viewport:o}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length=o.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||l)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=o.to)}buildDeco(e,t){if(!t||!this.tree.length)return He.none;let i=new zr;for(let{from:l,to:o}of e.visibleRanges)lL(this.tree,t,(a,u,f)=>{i.add(a,u,this.markCache[f]||(this.markCache[f]=He.mark({class:f})))},l,o);return i.finish()}}const PL=so.high(Jt.fromClass(BL,{decorations:n=>n.decorations})),HL=Mu.define([{tag:me.meta,color:"#404740"},{tag:me.link,textDecoration:"underline"},{tag:me.heading,textDecoration:"underline",fontWeight:"bold"},{tag:me.emphasis,fontStyle:"italic"},{tag:me.strong,fontWeight:"bold"},{tag:me.strikethrough,textDecoration:"line-through"},{tag:me.keyword,color:"#708"},{tag:[me.atom,me.bool,me.url,me.contentSeparator,me.labelName],color:"#219"},{tag:[me.literal,me.inserted],color:"#164"},{tag:[me.string,me.deleted],color:"#a11"},{tag:[me.regexp,me.escape,me.special(me.string)],color:"#e40"},{tag:me.definition(me.variableName),color:"#00f"},{tag:me.local(me.variableName),color:"#30a"},{tag:[me.typeName,me.namespace],color:"#085"},{tag:me.className,color:"#167"},{tag:[me.special(me.variableName),me.macroName],color:"#256"},{tag:me.definition(me.propertyName),color:"#00c"},{tag:me.comment,color:"#940"},{tag:me.invalid,color:"#f00"}]),IL=Oe.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),lT=1e4,sT="()[]{}",oT=Ce.define({combine(n){return Br(n,{afterCursor:!0,brackets:sT,maxScanDistance:lT,renderMatch:qL})}}),UL=He.mark({class:"cm-matchingBracket"}),FL=He.mark({class:"cm-nonmatchingBracket"});function qL(n){let e=[],t=n.matched?UL:FL;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function t2(n){let e=[],t=n.facet(oT);for(let i of n.selection.ranges){if(!i.empty)continue;let l=jr(n,i.head,-1,t)||i.head>0&&jr(n,i.head-1,1,t)||t.afterCursor&&(jr(n,i.head,1,t)||i.headn.decorations}),QL=[VL,IL];function XL(n={}){return[oT.of(n),QL]}const $L=new Je;function Ux(n,e,t){let i=n.prop(e<0?Je.openedBy:Je.closedBy);if(i)return i;if(n.name.length==1){let l=t.indexOf(n.name);if(l>-1&&l%2==(e<0?1:0))return[t[l+e]]}return null}function Fx(n){let e=n.type.prop($L);return e?e(n.node):n}function jr(n,e,t,i={}){let l=i.maxScanDistance||lT,o=i.brackets||sT,a=Hn(n),u=a.resolveInner(e,t);for(let f=u;f;f=f.parent){let d=Ux(f.type,t,o);if(d&&f.from0?e>=m.from&&em.from&&e<=m.to))return YL(n,e,t,f,m,d,o)}}return GL(n,e,t,a,u.type,l,o)}function YL(n,e,t,i,l,o,a){let u=i.parent,f={from:l.from,to:l.to},d=0,m=u==null?void 0:u.cursor();if(m&&(t<0?m.childBefore(i.from):m.childAfter(i.to)))do if(t<0?m.to<=i.from:m.from>=i.to){if(d==0&&o.indexOf(m.type.name)>-1&&m.from0)return null;let d={from:t<0?e-1:e,to:t>0?e+1:e},m=n.doc.iterRange(e,t>0?n.doc.length:0),g=0;for(let b=0;!m.next().done&&b<=o;){let v=m.value;t<0&&(b+=v.length);let w=e+b*t;for(let S=t>0?0:v.length-1,C=t>0?v.length:-1;S!=C;S+=t){let N=a.indexOf(v[S]);if(!(N<0||i.resolveInner(w+S,1).type!=l))if(N%2==0==t>0)g++;else{if(g==1)return{start:d,end:{from:w+S,to:w+S+1},matched:N>>1==f>>1};g--}}t>0&&(b+=v.length)}return m.done?{start:d,matched:!1}:null}const KL=Object.create(null),n2=[pi.none],i2=[],r2=Object.create(null),WL=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])WL[n]=ZL(KL,e);function b0(n,e){i2.indexOf(n)>-1||(i2.push(n),console.warn(e))}function ZL(n,e){let t=[];for(let u of e.split(" ")){let f=[];for(let d of u.split(".")){let m=n[d]||me[d];m?typeof m=="function"?f.length?f=f.map(m):b0(d,`Modifier ${d} used at start of tag`):f.length?b0(d,`Tag ${d} used as modifier`):f=Array.isArray(m)?m:[m]:b0(d,`Unknown highlighting tag ${d}`)}for(let d of f)t.push(d)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),l=i+" "+t.map(u=>u.id),o=r2[l];if(o)return o.id;let a=r2[l]=pi.define({id:n2.length,name:i,props:[FN({[i]:t})]});return n2.push(a),a.id}Ot.RTL,Ot.LTR;const JL=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Qy(n.state,t.from);return i.line?ez(n):i.block?nz(n):!1};function Vy(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let l=n(e,t);return l?(i(t.update(l)),!0):!1}}const ez=Vy(lz,0),tz=Vy(aT,0),nz=Vy((n,e)=>aT(n,e,rz(e)),0);function Qy(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const Ic=50;function iz(n,{open:e,close:t},i,l){let o=n.sliceDoc(i-Ic,i),a=n.sliceDoc(l,l+Ic),u=/\s*$/.exec(o)[0].length,f=/^\s*/.exec(a)[0].length,d=o.length-u;if(o.slice(d-e.length,d)==e&&a.slice(f,f+t.length)==t)return{open:{pos:i-u,margin:u&&1},close:{pos:l+f,margin:f&&1}};let m,g;l-i<=2*Ic?m=g=n.sliceDoc(i,l):(m=n.sliceDoc(i,i+Ic),g=n.sliceDoc(l-Ic,l));let b=/^\s*/.exec(m)[0].length,v=/\s*$/.exec(g)[0].length,w=g.length-v-t.length;return m.slice(b,b+e.length)==e&&g.slice(w,w+t.length)==t?{open:{pos:i+b+e.length,margin:/\s/.test(m.charAt(b+e.length))?1:0},close:{pos:l-v-t.length,margin:/\s/.test(g.charAt(w-1))?1:0}}:null}function rz(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),l=t.to<=i.to?i:n.doc.lineAt(t.to);l.from>i.from&&l.from==t.to&&(l=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let o=e.length-1;o>=0&&e[o].to>i.from?e[o].to=l.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:l.to})}return e}function aT(n,e,t=e.selection.ranges){let i=t.map(o=>Qy(e,o.from).block);if(!i.every(o=>o))return null;let l=t.map((o,a)=>iz(e,i[a],o.from,o.to));if(n!=2&&!l.every(o=>o))return{changes:e.changes(t.map((o,a)=>l[a]?[]:[{from:o.from,insert:i[a].open+" "},{from:o.to,insert:" "+i[a].close}]))};if(n!=1&&l.some(o=>o)){let o=[];for(let a=0,u;al&&(o==a||a>g.from)){l=g.from;let b=/^\s*/.exec(g.text)[0].length,v=b==g.length,w=g.text.slice(b,b+d.length)==d?b:-1;bo.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:u,token:f,indent:d,empty:m,single:g}of i)(g||!m)&&o.push({from:u.from+d,insert:f+" "});let a=e.changes(o);return{changes:a,selection:e.selection.map(a,1)}}else if(n!=1&&i.some(o=>o.comment>=0)){let o=[];for(let{line:a,comment:u,token:f}of i)if(u>=0){let d=a.from+u,m=d+f.length;a.text[m-a.from]==" "&&m++,o.push({from:d,to:m})}return{changes:o}}return null}const qx=cl.define(),sz=cl.define(),oz=Ce.define(),cT=Ce.define({combine(n){return Br(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,l)=>e(i,l)||t(i,l)})}}),uT=In.define({create(){return Rr.empty},update(n,e){let t=e.state.facet(cT),i=e.annotation(qx);if(i){let f=mi.fromTransaction(e,i.selection),d=i.side,m=d==0?n.undone:n.done;return f?m=Ad(m,m.length,t.minDepth,f):m=dT(m,e.startState.selection),new Rr(d==0?i.rest:m,d==0?m:i.rest)}let l=e.annotation(sz);if((l=="full"||l=="before")&&(n=n.isolate()),e.annotation(dn.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let o=mi.fromTransaction(e),a=e.annotation(dn.time),u=e.annotation(dn.userEvent);return o?n=n.addChanges(o,a,u,t,e):e.selection&&(n=n.addSelection(e.startState.selection,a,u,t.newGroupDelay)),(l=="full"||l=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new Rr(n.done.map(mi.fromJSON),n.undone.map(mi.fromJSON))}});function az(n={}){return[uT,cT.of(n),Oe.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?fT:e.inputType=="historyRedo"?Vx:null;return i?(e.preventDefault(),i(t)):!1}})]}function lm(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let l=t.field(uT,!1);if(!l)return!1;let o=l.pop(n,t,e);return o?(i(o),!0):!1}}const fT=lm(0,!1),Vx=lm(1,!1),cz=lm(0,!0),uz=lm(1,!0);class mi{constructor(e,t,i,l,o){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=l,this.selectionsAfter=o}setSelAfter(e){return new mi(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(e){return new mi(e.changes&&hn.fromJSON(e.changes),[],e.mapped&&Lr.fromJSON(e.mapped),e.startSelection&&ae.fromJSON(e.startSelection),e.selectionsAfter.map(ae.fromJSON))}static fromTransaction(e,t){let i=Ui;for(let l of e.startState.facet(oz)){let o=l(e);o.length&&(i=i.concat(o))}return!i.length&&e.changes.empty?null:new mi(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Ui)}static selection(e){return new mi(void 0,Ui,void 0,void 0,e)}}function Ad(n,e,t,i){let l=e+1>t+20?e-t-1:0,o=n.slice(l,e);return o.push(i),o}function fz(n,e){let t=[],i=!1;return n.iterChangedRanges((l,o)=>t.push(l,o)),e.iterChangedRanges((l,o,a,u)=>{for(let f=0;f=d&&a<=m&&(i=!0)}}),i}function hz(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function hT(n,e){return n.length?e.length?n.concat(e):n:e}const Ui=[],dz=200;function dT(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-dz));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),Ad(n,n.length-1,1e9,t.setSelAfter(i)))}else return[mi.selection([e])]}function mz(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function v0(n,e){if(!n.length)return n;let t=n.length,i=Ui;for(;t;){let l=pz(n[t-1],e,i);if(l.changes&&!l.changes.empty||l.effects.length){let o=n.slice(0,t);return o[t-1]=l,o}else e=l.mapped,t--,i=l.selectionsAfter}return i.length?[mi.selection(i)]:Ui}function pz(n,e,t){let i=hT(n.selectionsAfter.length?n.selectionsAfter.map(u=>u.map(e)):Ui,t);if(!n.changes)return mi.selection(i);let l=n.changes.map(e),o=e.mapDesc(n.changes,!0),a=n.mapped?n.mapped.composeDesc(o):o;return new mi(l,Ye.mapEffects(n.effects,e),a,n.startSelection.map(o),i)}const gz=/^(input\.type|delete)($|\.)/;class Rr{constructor(e,t,i=0,l=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=l}isolate(){return this.prevTime?new Rr(this.done,this.undone):this}addChanges(e,t,i,l,o){let a=this.done,u=a[a.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!i||gz.test(i))&&(!u.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):sm(t,e))}function Un(n){return n.textDirectionAt(n.state.selection.main.head)==Ot.LTR}const pT=n=>mT(n,!Un(n)),gT=n=>mT(n,Un(n));function xT(n,e){return sr(n,t=>t.empty?n.moveByGroup(t,e):sm(t,e))}const yz=n=>xT(n,!Un(n)),bz=n=>xT(n,Un(n));function vz(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function om(n,e,t){let i=Hn(n).resolveInner(e.head),l=t?Je.closedBy:Je.openedBy;for(let f=e.head;;){let d=t?i.childAfter(f):i.childBefore(f);if(!d)break;vz(n,d,l)?i=d:f=t?d.to:d.from}let o=i.type.prop(l),a,u;return o&&(a=t?jr(n,i.from,1):jr(n,i.to,-1))&&a.matched?u=t?a.end.to:a.end.from:u=t?i.to:i.from,ae.cursor(u,t?-1:1)}const wz=n=>sr(n,e=>om(n.state,e,!Un(n))),kz=n=>sr(n,e=>om(n.state,e,Un(n)));function yT(n,e){return sr(n,t=>{if(!t.empty)return sm(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const bT=n=>yT(n,!1),vT=n=>yT(n,!0);function wT(n){let e=n.scrollDOM.clientHeighta.empty?n.moveVertically(a,e,t.height):sm(a,e));if(l.eq(i.selection))return!1;let o;if(t.selfScroll){let a=n.coordsAtPos(i.selection.main.head),u=n.scrollDOM.getBoundingClientRect(),f=u.top+t.marginTop,d=u.bottom-t.marginBottom;a&&a.top>f&&a.bottomkT(n,!1),Qx=n=>kT(n,!0);function fs(n,e,t){let i=n.lineBlockAt(e.head),l=n.moveToLineBoundary(e,t);if(l.head==e.head&&l.head!=(t?i.to:i.from)&&(l=n.moveToLineBoundary(e,t,!1)),!t&&l.head==i.from&&i.length){let o=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;o&&e.head!=i.from+o&&(l=ae.cursor(i.from+o))}return l}const Sz=n=>sr(n,e=>fs(n,e,!0)),Cz=n=>sr(n,e=>fs(n,e,!1)),Oz=n=>sr(n,e=>fs(n,e,!Un(n))),Nz=n=>sr(n,e=>fs(n,e,Un(n))),Tz=n=>sr(n,e=>n.moveToLineBoundary(e,!1,!1)),Az=n=>sr(n,e=>n.moveToLineBoundary(e,!0,!1));function Ez(n,e,t){let i=!1,l=_a(n.selection,o=>{let a=jr(n,o.head,-1)||jr(n,o.head,1)||o.head>0&&jr(n,o.head-1,1)||o.headEz(n,e);function Vi(n,e,t){let i=_a(n.state.selection,l=>{l.undirectional&&l.head>=l.anchor!=e&&(l=ae.range(l.head,l.anchor));let o=t(l);return ae.range(l.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return i.eq(n.state.selection)?!1:(n.dispatch(lr(n.state,i)),!0)}function ST(n,e){return Vi(n,e,t=>n.moveByChar(t,e))}const CT=n=>ST(n,!Un(n)),OT=n=>ST(n,Un(n));function NT(n,e){return Vi(n,e,t=>n.moveByGroup(t,e))}const Dz=n=>NT(n,!Un(n)),jz=n=>NT(n,Un(n)),Rz=n=>{let e=!Un(n);return Vi(n,e,t=>om(n.state,t,e))},_z=n=>{let e=Un(n);return Vi(n,e,t=>om(n.state,t,e))};function TT(n,e){return Vi(n,e,t=>n.moveVertically(t,e))}const AT=n=>TT(n,!1),ET=n=>TT(n,!0);function MT(n,e){return Vi(n,e,t=>n.moveVertically(t,e,wT(n).height))}const s2=n=>MT(n,!1),o2=n=>MT(n,!0),Lz=n=>Vi(n,!0,e=>fs(n,e,!0)),zz=n=>Vi(n,!1,e=>fs(n,e,!1)),Bz=n=>{let e=!Un(n);return Vi(n,e,t=>fs(n,t,e))},Pz=n=>{let e=Un(n);return Vi(n,e,t=>fs(n,t,e))},Hz=n=>Vi(n,!1,e=>ae.cursor(n.lineBlockAt(e.head).from)),Iz=n=>Vi(n,!0,e=>ae.cursor(n.lineBlockAt(e.head).to)),a2=({state:n,dispatch:e})=>(e(lr(n,{anchor:0})),!0),c2=({state:n,dispatch:e})=>(e(lr(n,{anchor:n.doc.length})),!0),u2=({state:n,dispatch:e})=>(e(lr(n,{anchor:n.selection.main.anchor,head:0})),!0),f2=({state:n,dispatch:e})=>(e(lr(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),Uz=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Fz=({state:n,dispatch:e})=>{let t=am(n).map(({from:i,to:l})=>ae.undirectionalRange(i,Math.min(l+1,n.doc.length)));return e(n.update({selection:ae.create(t),userEvent:"select"})),!0},qz=({state:n,dispatch:e})=>{let t=_a(n.selection,i=>{let l=Hn(n),o=l.resolveStack(i.from,1);if(i.empty){let a=l.resolveStack(i.from,-1);a.node.from>=o.node.from&&a.node.to<=o.node.to&&(o=a)}for(let a=o;a;a=a.next){let{node:u}=a;if((u.from=i.to||u.to>i.to&&u.from<=i.from)&&a.next)return ae.undirectionalRange(u.from,u.to)}return i});return t.eq(n.selection)?!1:(e(lr(n,t)),!0)};function DT(n,e){let{state:t}=n,i=t.selection,l=t.selection.ranges.slice();for(let o of t.selection.ranges){let a=t.doc.lineAt(o.head);if(e?a.to0)for(let u=o;;){let f=n.moveVertically(u,e);if(f.heada.to){l.some(d=>d.head==f.head)||l.push(f);break}else{if(f.head==u.head)break;u=f}}}return l.length==i.ranges.length?!1:(n.dispatch(lr(t,ae.create(l,l.length-1))),!0)}const Vz=n=>DT(n,!1),Qz=n=>DT(n,!0),Xz=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=ae.create([t.main]):t.main.empty||(i=ae.create([ae.cursor(t.main.head)])),i?(e(lr(n,i)),!0):!1};function Du(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,l=i.changeByRange(o=>{let{from:a,to:u}=o;if(a==u){let f=e(o);fa&&(t="delete.forward",f=jh(n,f,!0)),a=Math.min(a,f),u=Math.max(u,f)}else a=jh(n,a,!1),u=jh(n,u,!0);return a==u?{range:o}:{changes:{from:a,to:u},range:ae.cursor(a,al(n)))i.between(e,e,(l,o)=>{le&&(e=t?o:l)});return e}const jT=(n,e,t)=>Du(n,i=>{let l=i.from,{state:o}=n,a=o.doc.lineAt(l),u,f;if(t&&!e&&l>a.from&&ljT(n,!1,!0),RT=n=>jT(n,!0,!1),_T=(n,e)=>Du(n,t=>{let i=t.head,{state:l}=n,o=l.doc.lineAt(i),a=l.charCategorizer(i);for(let u=null;;){if(i==(e?o.to:o.from)){i==t.head&&o.number!=(e?l.doc.lines:1)&&(i+=e?1:-1);break}let f=Sn(o.text,i-o.from,e)+o.from,d=o.text.slice(Math.min(i,f)-o.from,Math.max(i,f)-o.from),m=a(d);if(u!=null&&m!=u)break;(d!=" "||i!=t.head)&&(u=m),i=f}return i}),LT=n=>_T(n,!1),$z=n=>_T(n,!0),Yz=n=>Du(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headDu(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Kz=n=>Du(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:ft.of(["",""])},range:ae.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Zz=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let l=i.from,o=n.doc.lineAt(l),a=l==o.from?l-1:Sn(o.text,l-o.from,!1)+o.from,u=l==o.to?l+1:Sn(o.text,l-o.from,!0)+o.from;return{changes:{from:a,to:u,insert:n.doc.slice(l,u).append(n.doc.slice(a,l))},range:ae.cursor(u)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function am(n){let e=[],t=-1;for(let i of n.selection.ranges){let l=n.doc.lineAt(i.from),o=n.doc.lineAt(i.to);if(!i.empty&&i.to==o.from&&(o=n.doc.lineAt(i.to-1)),t>=l.number){let a=e[e.length-1];a.to=o.to,a.ranges.push(i)}else e.push({from:l.from,to:o.to,ranges:[i]});t=o.number+1}return e}function zT(n,e,t){if(n.readOnly)return!1;let i=[],l=[];for(let o of am(n)){if(t?o.to==n.doc.length:o.from==0)continue;let a=n.doc.lineAt(t?o.to+1:o.from-1),u=a.length+1;if(t){i.push({from:o.to,to:a.to},{from:o.from,insert:a.text+n.lineBreak});for(let f of o.ranges)l.push(ae.range(Math.min(n.doc.length,f.anchor+u),Math.min(n.doc.length,f.head+u)))}else{i.push({from:a.from,to:o.from},{from:o.to,insert:n.lineBreak+a.text});for(let f of o.ranges)l.push(ae.range(f.anchor-u,f.head-u))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:ae.create(l,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Jz=({state:n,dispatch:e})=>zT(n,e,!1),e6=({state:n,dispatch:e})=>zT(n,e,!0);function BT(n,e,t){if(n.readOnly)return!1;let i=[];for(let o of am(n))t?i.push({from:o.from,insert:n.doc.slice(o.from,o.to)+n.lineBreak}):i.push({from:o.to,insert:n.lineBreak+n.doc.slice(o.from,o.to)});let l=n.changes(i);return e(n.update({changes:l,selection:n.selection.map(l,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const t6=({state:n,dispatch:e})=>BT(n,e,!1),n6=({state:n,dispatch:e})=>BT(n,e,!0),i6=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(am(e).map(({from:l,to:o})=>(l>0?l--:o{let o;if(n.lineWrapping){let a=n.lineBlockAt(l.head),u=n.coordsAtPos(l.head,l.assoc||1);u&&(o=a.bottom+n.documentTop-u.bottom+n.defaultLineHeight/2)}return n.moveVertically(l,!0,o)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function r6(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Hn(n).resolveInner(e),i=t.childBefore(e),l=t.childAfter(e),o;return i&&l&&i.to<=e&&l.from>=e&&(o=i.type.prop(Je.closedBy))&&o.indexOf(l.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(l.from).from&&!/\S/.test(n.sliceDoc(i.to,l.from))?{from:i.to,to:l.from}:null}const h2=PT(!1),l6=PT(!0);function PT(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(l=>{let{from:o,to:a}=l,u=e.doc.lineAt(o),f=!n&&o==a&&r6(e,o);n&&(o=a=(a<=u.to?u:e.doc.lineAt(a)).to);let d=new im(e,{simulateBreak:o,simulateDoubleBreak:!!f}),m=Fy(d,o);for(m==null&&(m=Ra(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));au.from&&o{let l=[];for(let a=i.from;a<=i.to;){let u=n.doc.lineAt(a);u.number>t&&(i.empty||i.to>u.from)&&(e(u,l,i),t=u.number),a=u.to+1}let o=n.changes(l);return{changes:l,range:ae.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}})}const s6=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new im(n,{overrideIndentation:o=>{let a=t[o];return a??-1}}),l=Xy(n,(o,a,u)=>{let f=Fy(i,o.from);if(f==null)return;/\S/.test(o.text)||(f=0);let d=/^\s*/.exec(o.text)[0],m=xu(n,f);(d!=m||u.fromn.readOnly?!1:(e(n.update(Xy(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Uy)})}),{userEvent:"input.indent"})),!0),a6=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Xy(n,(t,i)=>{let l=/^\s*/.exec(t.text)[0];if(!l)return;let o=Ra(l,n.tabSize),a=0,u=xu(n,Math.max(0,o-Od(n)));for(;a(n.setTabFocusMode(),!0),u6=[{key:"Ctrl-b",run:pT,shift:CT,preventDefault:!0},{key:"Ctrl-f",run:gT,shift:OT},{key:"Ctrl-p",run:bT,shift:AT},{key:"Ctrl-n",run:vT,shift:ET},{key:"Ctrl-a",run:Tz,shift:Hz},{key:"Ctrl-e",run:Az,shift:Iz},{key:"Ctrl-d",run:RT},{key:"Ctrl-h",run:Xx},{key:"Ctrl-k",run:Yz},{key:"Ctrl-Alt-h",run:LT},{key:"Ctrl-o",run:Wz},{key:"Ctrl-t",run:Zz},{key:"Ctrl-v",run:Qx}],f6=[{key:"ArrowLeft",run:pT,shift:CT,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:yz,shift:Dz,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Oz,shift:Bz,preventDefault:!0},{key:"ArrowRight",run:gT,shift:OT,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:bz,shift:jz,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Nz,shift:Pz,preventDefault:!0},{key:"ArrowUp",run:bT,shift:AT,preventDefault:!0},{mac:"Cmd-ArrowUp",run:a2,shift:u2},{mac:"Ctrl-ArrowUp",run:l2,shift:s2},{key:"ArrowDown",run:vT,shift:ET,preventDefault:!0},{mac:"Cmd-ArrowDown",run:c2,shift:f2},{mac:"Ctrl-ArrowDown",run:Qx,shift:o2},{key:"PageUp",run:l2,shift:s2},{key:"PageDown",run:Qx,shift:o2},{key:"Home",run:Cz,shift:zz,preventDefault:!0},{key:"Mod-Home",run:a2,shift:u2},{key:"End",run:Sz,shift:Lz,preventDefault:!0},{key:"Mod-End",run:c2,shift:f2},{key:"Enter",run:h2,shift:h2},{key:"Mod-a",run:Uz},{key:"Backspace",run:Xx,shift:Xx,preventDefault:!0},{key:"Delete",run:RT,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:LT,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:$z,preventDefault:!0},{mac:"Mod-Backspace",run:Gz,preventDefault:!0},{mac:"Mod-Delete",run:Kz,preventDefault:!0}].concat(u6.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),h6=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:wz,shift:Rz},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:kz,shift:_z},{key:"Alt-ArrowUp",run:Jz},{key:"Shift-Alt-ArrowUp",run:t6},{key:"Alt-ArrowDown",run:e6},{key:"Shift-Alt-ArrowDown",run:n6},{key:"Mod-Alt-ArrowUp",run:Vz},{key:"Mod-Alt-ArrowDown",run:Qz},{key:"Escape",run:Xz},{key:"Mod-Enter",run:l6},{key:"Alt-l",mac:"Ctrl-l",run:Fz},{key:"Mod-i",run:qz,preventDefault:!0},{key:"Mod-[",run:a6},{key:"Mod-]",run:o6},{key:"Mod-Alt-\\",run:s6},{key:"Shift-Mod-k",run:i6},{key:"Shift-Mod-\\",run:Mz},{key:"Mod-/",run:JL},{key:"Alt-A",mac:"Ctrl-A",run:tz},{key:"Ctrl-m",mac:"Shift-Alt-m",run:c6}].concat(f6),d2=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class Da{constructor(e,t,i=0,l=e.length,o,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,l),this.bufferStart=i,this.normalize=o?u=>o(d2(u)):d2,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ui(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=by(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Er(e);let l=this.normalize(t);if(l.length)for(let o=0,a=i,u=!0;;o++){let f=l.charCodeAt(o),d=this.match(f,a,u,this.bufferPos+this.bufferStart,o==l.length-1);if(d)return this.value=d,this;if(o==l.length-1)break;u&&othis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let i=this.curLineStart+t.index,l=i+t[0].length;if(this.matchPos=Ed(this.text,l+(i==l?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,l,t)))return this.value={from:i,to:l,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=i||l.to<=t){let u=new xa(t,e.sliceString(t,i));return w0.set(e,u),u}if(l.from==t&&l.to==i)return l;let{text:o,from:a}=l;return a>t&&(o=e.sliceString(t,a)+o,a=t),l.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let i=this.flat.from+t.index,l=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,l,t)))return this.value={from:i,to:l,precise:!0,match:t},this.matchPos=Ed(this.text,l+(i==l?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=xa.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(IT.prototype[Symbol.iterator]=UT.prototype[Symbol.iterator]=function(){return this});function d6(n){try{return new RegExp(n,$y),!0}catch{return!1}}function Ed(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e=56320&&i<57344;)e++;return e}const m6=n=>{let e=j_(n,"cm-goto-line");if(e){let a=e.dom.querySelector("input[type=text]");return a&&a.select(),!0}let{state:t}=n,i=String(t.doc.lineAt(n.state.selection.main.head).number),{close:l,result:o}=D_(n,{class:"cm-goto-line",label:t.phrase("Go to line"),input:{type:"text",name:"line",value:i},focus:!0,submitLabel:t.phrase("go")});return o.then(a=>{let u=a&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(a.elements.line.value);if(!u){n.dispatch({effects:l});return}let f=t.doc.lineAt(t.selection.main.head),[,d,m,g,b]=u,v=g?+g.slice(1):0,w=m?+m:f.number;if(m&&b){let N=w/100;d&&(N=N*(d=="-"?-1:1)+f.number/t.doc.lines),w=Math.round(t.doc.lines*N)}else m&&d&&(w=w*(d=="-"?-1:1)+f.number);let S=t.doc.line(Math.max(1,Math.min(t.doc.lines,w))),C=ae.cursor(S.from+Math.max(0,Math.min(v,S.length)));n.dispatch({effects:[l,Oe.scrollIntoView(C.from,{y:"center"})],selection:C})}),!0},p6={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},g6=Ce.define({combine(n){return Br(n,p6,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function x6(n){return[k6,w6]}const y6=He.mark({class:"cm-selectionMatch"}),b6=He.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function m2(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=Pt.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=Pt.Word)}function v6(n,e,t,i){return n(e.sliceDoc(t,t+1))==Pt.Word&&n(e.sliceDoc(i-1,i))==Pt.Word}const w6=Jt.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(g6),{state:t}=n,i=t.selection;if(i.ranges.length>1)return He.none;let l=i.main,o,a=null;if(l.empty){if(!e.highlightWordAroundCursor)return He.none;let f=t.wordAt(l.head);if(!f)return He.none;a=t.charCategorizer(l.head),o=t.sliceDoc(f.from,f.to)}else{let f=l.to-l.from;if(f200)return He.none;if(e.wholeWords){if(o=t.sliceDoc(l.from,l.to),a=t.charCategorizer(l.head),!(m2(a,t,l.from,l.to)&&v6(a,t,l.from,l.to)))return He.none}else if(o=t.sliceDoc(l.from,l.to),!o)return He.none}let u=[];for(let f of n.visibleRanges){let d=new Da(t.doc,o,f.from,f.to);for(;!d.next().done;){let{from:m,to:g}=d.value;if((!a||m2(a,t,m,g))&&(l.empty&&m<=l.from&&g>=l.to?u.push(b6.range(m,g)):(m>=l.to||g<=l.from)&&u.push(y6.range(m,g)),u.length>e.maxMatches))return He.none}}return He.set(u)}},{decorations:n=>n.decorations}),k6=Oe.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),S6=({state:n,dispatch:e})=>{let{selection:t}=n,i=ae.create(t.ranges.map(l=>n.wordAt(l.head)||ae.cursor(l.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function C6(n,e){let{main:t,ranges:i}=n.selection,l=n.wordAt(t.head),o=l&&l.from==t.from&&l.to==t.to;for(let a=!1,u=new Da(n.doc,e,i[i.length-1].to);;)if(u.next(),u.done){if(a)return null;u=new Da(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),a=!0}else{if(a&&i.some(f=>f.from==u.value.from))continue;if(o){let f=n.wordAt(u.value.from);if(!f||f.from!=u.value.from||f.to!=u.value.to)continue}return u.value}}const O6=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(o=>o.from===o.to))return S6({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(o=>n.sliceDoc(o.from,o.to)!=i))return!1;let l=C6(n,i);return l?(e(n.update({selection:n.selection.addRange(ae.range(l.from,l.to),!1),effects:Oe.scrollIntoView(l.to)})),!0):!1},La=Ce.define({combine(n){return Br(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new H6(e),scrollToMatch:e=>Oe.scrollIntoView(e)})}});class FT{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||d6(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,i)=>i=="n"?` -`:i=="r"?"\r":i=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new D6(this):new A6(this)}getCursor(e,t=0,i){let l=e.doc?e:dt.create({doc:e});return i==null&&(i=l.doc.length),this.regexp?ia(this,l,t,i):na(this,l,t,i)}}class qT{constructor(e){this.spec=e}}function N6(n,e,t){return(i,l,o,a)=>{if(t&&!t(i,l,o,a))return!1;let u=i>=a&&l<=a+o.length?o.slice(i-a,l-a):e.doc.sliceString(i,l);return n(u,e,i,l)}}function na(n,e,t,i){let l;return n.wholeWord&&(l=T6(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(l=N6(n.test,e,l)),new Da(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:o=>o.toLowerCase(),l)}function T6(n,e){return(t,i,l,o)=>((o>t||o+l.length=t)return null;l.push(i.value)}return l}highlight(e,t,i,l){let o=na(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!o.next().done;)l(o.value.from,o.value.to)}}function E6(n,e,t){return(i,l,o)=>(!t||t(i,l,o))&&n(o[0],e,i,l)}function ia(n,e,t,i){let l;return n.wholeWord&&(l=M6(e.charCategorizer(e.selection.main.head))),n.test&&(l=E6(n.test,e,l)),new IT(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:l},t,i)}function Md(n,e){return n.slice(Sn(n,e,!1),e)}function Dd(n,e){return n.slice(e,Sn(n,e))}function M6(n){return(e,t,i)=>!i[0].length||(n(Md(i.input,i.index))!=Pt.Word||n(Dd(i.input,i.index))!=Pt.Word)&&(n(Dd(i.input,i.index+i[0].length))!=Pt.Word||n(Md(i.input,i.index+i[0].length))!=Pt.Word)}class D6 extends qT{nextMatch(e,t,i){let l=ia(this.spec,e,i,e.doc.length).next();return l.done&&(l=ia(this.spec,e,0,t).next()),l.done?null:l.value}prevMatchInRange(e,t,i){for(let l=1;;l++){let o=Math.max(t,i-l*1e4),a=ia(this.spec,e,o,i),u=null;for(;!a.next().done;)u=a.value;if(u&&(o==t||u.from>o+10))return u;if(o==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let l=i.length;l>0;l--){let o=+i.slice(0,l);if(o>0&&o=t)return null;l.push(i.value)}return l}highlight(e,t,i,l){let o=ia(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!o.next().done;)l(o.value.from,o.value.to)}}const yu=Ye.define(),Yy=Ye.define(),es=In.define({create(n){return new k0($x(n).create(),null)},update(n,e){for(let t of e.effects)t.is(yu)?n=new k0(t.value.create(),n.panel):t.is(Yy)&&(n=new k0(n.query,t.value?Gy:null));return n},provide:n=>mu.from(n,e=>e.panel)});class k0{constructor(e,t){this.query=e,this.panel=t}}const j6=He.mark({class:"cm-searchMatch"}),R6=He.mark({class:"cm-searchMatch cm-searchMatch-selected"}),_6=Jt.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(es))}update(n){let e=n.state.field(es);(e!=n.startState.field(es)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return He.none;let{view:t}=this,i=new zr;for(let l=0,o=t.visibleRanges,a=o.length;lo[l+1].from-500;)f=o[++l].to;n.highlight(t.state,u,f,(d,m)=>{let g=t.state.selection.ranges.some(b=>b.from==d&&b.to==m);i.add(d,m,g?R6:j6)})}return i.finish()}},{decorations:n=>n.decorations});function ju(n){return e=>{let t=e.state.field(es,!1);return t&&t.query.spec.valid?n(e,t):XT(e)}}const jd=ju((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let l=ae.single(i.from,i.to),o=n.state.facet(La);return n.dispatch({selection:l,effects:[Ky(n,i),o.scrollToMatch(l.main,n)],userEvent:"select.search"}),QT(n),!0}),Rd=ju((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,l=e.prevMatch(t,i,i);if(!l)return!1;let o=ae.single(l.from,l.to),a=n.state.facet(La);return n.dispatch({selection:o,effects:[Ky(n,l),a.scrollToMatch(o.main,n)],userEvent:"select.search"}),QT(n),!0}),L6=ju((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:ae.create(t.map(i=>ae.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),z6=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:l}=t.main,o=[],a=0;for(let u=new Da(n.doc,n.sliceDoc(i,l));!u.next().done;){if(o.length>1e3)return!1;u.value.from==i&&(a=o.length),o.push(ae.range(u.value.from,u.value.to))}return e(n.update({selection:ae.create(o,a),userEvent:"select.search.matches"})),!0},p2=ju((n,{query:e})=>{let{state:t}=n,{from:i,to:l}=t.selection.main;if(t.readOnly)return!1;let o=e.nextMatch(t,i,i);if(!o)return!1;let a=o,u=[],f,d,m=[];a.precise?a.from==i&&a.to==l&&(d=t.toText(e.getReplacement(a)),u.push({from:a.from,to:a.to,insert:d}),a=e.nextMatch(t,a.from,a.to),m.push(Oe.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):a=e.nextMatch(t,a.from,a.to);let g=n.state.changes(u);return a&&(f=ae.single(a.from,a.to).map(g),m.push(Ky(n,a)),m.push(t.facet(La).scrollToMatch(f.main,n))),n.dispatch({changes:g,selection:f,effects:m,userEvent:"input.replace"}),!0}),B6=ju((n,{query:e})=>{if(n.state.readOnly)return!1;let t=[];for(let l of e.matchAll(n.state,1e9)){let{from:o,to:a,precise:u}=l;u&&t.push({from:o,to:a,insert:e.getReplacement(l)})}if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:Oe.announce.of(i),userEvent:"input.replace.all"}),!0});function Gy(n){return n.state.facet(La).createPanel(n)}function $x(n,e){var t,i,l,o,a;let u=n.selection.main,f=u.empty||u.to>u.from+100?"":n.sliceDoc(u.from,u.to);if(e&&!f)return e;let d=n.facet(La);return new FT({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:d.literal)?f:f.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:d.caseSensitive,literal:(l=e==null?void 0:e.literal)!==null&&l!==void 0?l:d.literal,regexp:(o=e==null?void 0:e.regexp)!==null&&o!==void 0?o:d.regexp,wholeWord:(a=e==null?void 0:e.wholeWord)!==null&&a!==void 0?a:d.wholeWord})}function VT(n){let e=nm(n,Gy);return e&&e.dom.querySelector("[main-field]")}function QT(n){let e=VT(n);e&&e==n.root.activeElement&&e.select()}const XT=n=>{let e=n.state.field(es,!1);if(e&&e.panel){let t=VT(n);if(t&&t!=n.root.activeElement){let i=$x(n.state,e.query.spec);i.valid&&n.dispatch({effects:yu.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Yy.of(!0),e?yu.of($x(n.state,e.query.spec)):Ye.appendConfig.of(U6)]});return!0},$T=n=>{let e=n.state.field(es,!1);if(!e||!e.panel)return!1;let t=nm(n,Gy);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Yy.of(!1)}),!0},P6=[{key:"Mod-f",run:XT,scope:"editor search-panel"},{key:"F3",run:jd,shift:Rd,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:jd,shift:Rd,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:$T,scope:"editor search-panel"},{key:"Mod-Shift-l",run:z6},{key:"Mod-Alt-g",run:m6},{key:"Mod-d",run:O6,preventDefault:!0}];class H6{constructor(e){this.view=e;let t=this.query=e.state.field(es).query.spec;this.commit=this.commit.bind(this),this.searchField=Ct("input",{value:t.search,placeholder:Ci(e,"Find"),"aria-label":Ci(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Ct("input",{value:t.replace,placeholder:Ci(e,"Replace"),"aria-label":Ci(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Ct("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Ct("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Ct("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(l,o,a){return Ct("button",{class:"cm-button",name:l,onclick:o,type:"button"},a)}this.dom=Ct("div",{onkeydown:l=>this.keydown(l),class:"cm-search"},[this.searchField,i("next",()=>jd(e),[Ci(e,"next")]),i("prev",()=>Rd(e),[Ci(e,"previous")]),i("select",()=>L6(e),[Ci(e,"all")]),Ct("label",null,[this.caseField,Ci(e,"match case")]),Ct("label",null,[this.reField,Ci(e,"regexp")]),Ct("label",null,[this.wordField,Ci(e,"by word")]),...e.state.readOnly?[]:[Ct("br"),this.replaceField,i("replace",()=>p2(e),[Ci(e,"replace")]),i("replaceAll",()=>B6(e),[Ci(e,"replace all")])],Ct("button",{name:"close",onclick:()=>$T(e),"aria-label":Ci(e,"close"),type:"button"},["×"])])}commit(){let e=new FT({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:yu.of(e)}))}keydown(e){UR(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Rd:jd)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),p2(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(yu)&&!i.value.eq(this.query)&&this.setQuery(i.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(La).top}}function Ci(n,e){return n.state.phrase(e)}const Rh=30,_h=/[\s\.,:;?!]/;function Ky(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),l=n.state.doc.lineAt(t).to,o=Math.max(i.from,e-Rh),a=Math.min(l,t+Rh),u=n.state.sliceDoc(o,a);if(o!=i.from){for(let f=0;fu.length-Rh;f--)if(!_h.test(u[f-1])&&_h.test(u[f])){u=u.slice(0,f);break}}return Oe.announce.of(`${n.state.phrase("current match")}. ${u} ${n.state.phrase("on line")} ${i.number}.`)}const I6=Oe.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),U6=[es,so.low(_6),I6];class YT{constructor(e,t,i,l){this.state=e,this.pos=t,this.explicit=i,this.view=l,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Hn(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),l=t.text.slice(i-t.from,this.pos-t.from),o=l.search(GT(e,!1));return o<0?null:{from:i+o,to:this.pos,text:l.slice(o)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function g2(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function F6(n){let e=Object.create(null),t=Object.create(null);for(let{label:l}of n){e[l[0]]=!0;for(let o=1;otypeof l=="string"?{label:l}:l),[t,i]=e.every(l=>/^\w+$/.test(l.label))?[/\w*$/,/\w+$/]:F6(e);return l=>{let o=l.matchBefore(i);return o||l.explicit?{from:o?o.from:l.pos,options:e,validFor:t}:null}}class x2{constructor(e,t,i,l){this.completion=e,this.source=t,this.match=i,this.score=l}}function eo(n){return n.selection.main.from}function GT(n,e){var t;let{source:i}=n,l=e&&i[0]!="^",o=i[i.length-1]!="$";return!l&&!o?n:new RegExp(`${l?"^":""}(?:${i})${o?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const KT=cl.define();function V6(n,e,t,i){let{main:l}=n.selection,o=t-l.from,a=i-l.from;return{...n.changeByRange(u=>{if(u!=l&&t!=i&&n.sliceDoc(u.from+o,u.from+a)!=n.sliceDoc(t,i))return{range:u};let f=n.toText(e);return{changes:{from:u.from+o,to:i==l.from?u.to:u.from+a,insert:f},range:ae.cursor(u.from+o+f.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const y2=new WeakMap;function Q6(n){if(!Array.isArray(n))return n;let e=y2.get(n);return e||y2.set(n,e=q6(n)),e}const _d=Ye.define(),bu=Ye.define();class X6{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&U<=57||U>=97&&U<=122?2:U>=65&&U<=90?1:0:(E=by(U))!=E.toLowerCase()?1:E!=E.toUpperCase()?2:0;(!R||T==1&&C||I==0&&T!=0)&&(t[g]==U||i[g]==U&&(b=!0)?a[g++]=R:a.length&&(N=!1)),I=T,R+=Er(U)}return g==f&&a[0]==0&&N?this.result(-100+(b?-200:0),a,e):v==f&&w==0?this.ret(-200-e.length+(S==e.length?0:-100),[0,S]):u>-1?this.ret(-700-e.length,[u,u+this.pattern.length]):v==f?this.ret(-900-e.length,[w,S]):g==f?this.result(-100+(b?-200:0)+-700+(N?0:-1100),a,e):t.length==2?null:this.result((l[0]?-700:0)+-200+-1100,l,e)}result(e,t,i){let l=[],o=0;for(let a of t){let u=a+(this.astral?Er(ui(i,a)):1);o&&l[o-1]==a?l[o-1]=u:(l[o++]=a,l[o++]=u)}return this.ret(e-i.length,l)}}class $6{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Y6,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>b2(e(i),t(i)),optionClass:(e,t)=>i=>b2(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function b2(n,e){return n?e?n+" "+e:n:e}function Y6(n,e,t,i,l,o){let a=n.textDirection==Ot.RTL,u=a,f=!1,d="top",m,g,b=e.left-l.left,v=l.right-e.right,w=i.right-i.left,S=i.bottom-i.top;if(u&&b=S||R>e.top?m=t.bottom-e.top:(d="bottom",m=e.bottom-t.top)}let C=(e.bottom-e.top)/o.offsetHeight,N=(e.right-e.left)/o.offsetWidth;return{style:`${d}: ${m/C}px; max-width: ${g/N}px`,class:"cm-completionInfo-"+(f?a?"left-narrow":"right-narrow":u?"left":"right")}}const Wy=Ye.define();function G6(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(l=>"cm-completionIcon-"+l)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,l,o){let a=document.createElement("span");a.className="cm-completionLabel";let u=t.displayLabel||t.label,f=0;for(let d=0;df&&a.appendChild(document.createTextNode(u.slice(f,m)));let b=a.appendChild(document.createElement("span"));b.appendChild(document.createTextNode(u.slice(m,g))),b.className="cm-completionMatchedText",f=g}return ft.position-i.position).map(t=>t.render)}function S0(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let l=Math.floor(e/t);return{from:l*t,to:(l+1)*t}}let i=Math.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}class K6{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:f=>this.placeInfo(f),key:this},this.space=null,this.currentClass="";let l=e.state.field(t),{options:o,selected:a}=l.open,u=e.state.facet(kn);this.optionContent=G6(u),this.optionClass=u.optionClass,this.tooltipClass=u.tooltipClass,this.range=S0(o.length,a,u.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",f=>{let{options:d}=e.state.field(t).open;for(let m=f.target,g;m&&m!=this.dom;m=m.parentNode)if(m.nodeName=="LI"&&(g=/-(\d+)$/.exec(m.id))&&+g[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;m!=null&&(e.dispatch({effects:Wy.of(m)}),f.preventDefault())}}),this.dom.addEventListener("focusout",f=>{let d=e.state.field(this.stateField,!1);d&&d.tooltip&&e.state.facet(kn).closeOnBlur&&f.relatedTarget!=e.contentDOM&&e.dispatch({effects:bu.of(null)})}),this.showOptions(o,l.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),l=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=l){let{options:o,selected:a,disabled:u}=i.open;(!l.open||l.open.options!=o)&&(this.range=S0(o.length,a,e.state.facet(kn).maxRenderedOptions),this.showOptions(o,i.id)),this.updateSel(),u!=((t=l.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!u)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected=this.range.to)&&(this.range=S0(t.options.length,t.selected,this.view.state.facet(kn).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:l}=t.options[t.selected],{info:o}=l;if(!o)return;let a=typeof o=="string"?document.createTextNode(o):o(l);if(!a)return;"then"in a?a.then(u=>{u&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(u,l)}).catch(u=>di(this.view.state,u,"completion info")):(this.addInfoPane(a,l),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:l,destroy:o}=e;i.appendChild(l),this.infoDestroy=o||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,l=this.range.from;i;i=i.nextSibling,l++)i.nodeName!="LI"||!i.id?l--:l==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&Z6(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),l=e.getBoundingClientRect(),o=this.space;if(!o){let a=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:a.clientWidth,bottom:a.clientHeight}}return l.top>Math.min(o.bottom,t.bottom)-10||l.bottom{a.target==l&&a.preventDefault()});let o=null;for(let a=i.from;ai.from||i.from==0))if(o=b,typeof d!="string"&&d.header)l.appendChild(d.header(d));else{let v=l.appendChild(document.createElement("completion-section"));v.textContent=b}}const m=l.appendChild(document.createElement("li"));m.id=t+"-"+a,m.setAttribute("role","option");let g=this.optionClass(u);g&&(m.className=g);for(let b of this.optionContent){let v=b(u,this.view.state,this.view,f);v&&m.appendChild(v)}}return i.from&&l.classList.add("cm-completionListIncompleteTop"),i.tonew K6(t,n,e)}function Z6(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),l=t.height/n.offsetHeight;i.topt.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/l)}function v2(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function J6(n,e){let t=[],i=null,l=null,o=m=>{t.push(m);let{section:g}=m.completion;if(g){i||(i=[]);let b=typeof g=="string"?g:g.name;i.some(v=>v.name==b)||i.push(typeof g=="string"?{name:b}:g)}},a=e.facet(kn);for(let m of n)if(m.hasResult()){let g=m.result.getMatch;if(m.result.filter===!1)for(let b of m.result.options)o(new x2(b,m.source,g?g(b):[],1e9-t.length));else{let b=e.sliceDoc(m.from,m.to),v,w=a.filterStrict?new $6(b):new X6(b);for(let S of m.result.options)if(v=w.match(S.label)){let C=S.displayLabel?g?g(S,v.matched):[]:v.matched,N=v.score+(S.boost||0);if(o(new x2(S,m.source,C,N)),typeof S.section=="object"&&S.section.rank==="dynamic"){let{name:R}=S.section;l||(l=Object.create(null)),l[R]=Math.max(N,l[R]||-1e9)}}}}if(i){let m=Object.create(null),g=0,b=(v,w)=>(v.rank==="dynamic"&&w.rank==="dynamic"?l[w.name]-l[v.name]:0)||(typeof v.rank=="number"?v.rank:1e9)-(typeof w.rank=="number"?w.rank:1e9)||(v.nameb.score-g.score||d(g.completion,b.completion))){let g=m.completion;!f||f.label!=g.label||f.detail!=g.detail||f.type!=null&&g.type!=null&&f.type!=g.type||f.apply!=g.apply||f.boost!=g.boost?u.push(m):v2(m.completion)>v2(f)&&(u[u.length-1]=m),f=m.completion}return u}class fa{constructor(e,t,i,l,o,a){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=l,this.selected=o,this.disabled=a}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new fa(this.options,w2(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,l,o,a){if(l&&!a&&e.some(d=>d.isPending))return l.setDisabled();let u=J6(e,t);if(!u.length)return l&&e.some(d=>d.isPending)?l.setDisabled():null;let f=t.facet(kn).selectOnOpen?0:-1;if(l&&l.selected!=f&&l.selected!=-1){let d=l.options[l.selected].completion;for(let m=0;mm.hasResult()?Math.min(d,m.from):d,1e8),create:lB,above:o.aboveCursor},l?l.timestamp:Date.now(),f,!1)}map(e){return new fa(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new fa(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Ld{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Ld(iB,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(kn),o=(i.override||t.languageDataAt("autocomplete",eo(t)).map(Q6)).map(f=>(this.active.find(m=>m.source==f)||new Fi(f,this.active.some(m=>m.state!=0)?1:0)).update(e,i));o.length==this.active.length&&o.every((f,d)=>f==this.active[d])&&(o=this.active);let a=this.open,u=e.effects.some(f=>f.is(Zy));a&&e.docChanged&&(a=a.map(e.changes)),e.selection||o.some(f=>f.hasResult()&&e.changes.touchesRange(f.from,f.to))||!eB(o,this.active)||u?a=fa.build(o,t,this.id,a,i,u):a&&a.disabled&&!o.some(f=>f.isPending)&&(a=null),!a&&o.every(f=>!f.isPending)&&o.some(f=>f.hasResult())&&(o=o.map(f=>f.hasResult()?new Fi(f.source,0):f));for(let f of e.effects)f.is(Wy)&&(a=a&&a.setSelected(f.value,this.id));return o==this.active&&a==this.open?this:new Ld(o,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?tB:nB}}function eB(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}const iB=[];function WT(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(KT);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class Fi{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=WT(e,t),l=this;(i&8||i&16&&this.touches(e))&&(l=new Fi(l.source,0)),i&4&&l.state==0&&(l=new Fi(this.source,1)),l=l.updateFor(e,i);for(let o of e.effects)if(o.is(_d))l=new Fi(l.source,1,o.value);else if(o.is(bu))l=new Fi(l.source,0);else if(o.is(Zy))for(let a of o.value)a.source==l.source&&(l=a);return l}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(eo(e.state))}}class ya extends Fi{constructor(e,t,i,l,o,a){super(e,3,t),this.limit=i,this.result=l,this.from=o,this.to=a}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let l=this.result;l.map&&!e.changes.empty&&(l=l.map(l,e.changes));let o=e.changes.mapPos(this.from),a=e.changes.mapPos(this.to,1),u=eo(e.state);if(u>a||!l||t&2&&(eo(e.startState)==this.from||ut.map(e))}}),fi=In.define({create(){return Ld.start()},update(n,e){return n.update(e)},provide:n=>[zy.from(n,e=>e.tooltip),Oe.contentAttributes.from(n,e=>e.attrs)]});function Jy(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(fi).active.find(l=>l.source==e.source);return i instanceof ya?(typeof t=="string"?n.dispatch({...V6(n.state,t,i.from,i.to),annotations:KT.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}const lB=W6(fi,Jy);function Lh(n,e="option"){return t=>{let i=t.state.field(fi,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+l*(n?1:-1):n?0:a-1;return u<0?u=e=="page"?0:a-1:u>=a&&(u=e=="page"?a-1:0),t.dispatch({effects:Wy.of(u)}),!0}}const sB=n=>{let e=n.state.field(fi,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampn.state.field(fi,!1)?(n.dispatch({effects:_d.of(!0)}),!0):!1,oB=n=>{let e=n.state.field(fi,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:bu.of(null)}),!0)};class aB{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const cB=50,uB=1e3,fB=Jt.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(fi).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(fi),t=n.state.facet(kn);if(!n.selectionSet&&!n.docChanged&&n.startState.field(fi)==e)return;let i=n.transactions.some(o=>{let a=WT(o,t);return a&8||(o.selection||o.docChanged)&&!(a&3)});for(let o=0;ocB&&Date.now()-a.time>uB){for(let u of a.context.abortListeners)try{u()}catch(f){di(this.view.state,f)}a.context.abortListeners=null,this.running.splice(o--,1)}else a.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(o=>o.effects.some(a=>a.is(_d)))&&(this.pendingStart=!0);let l=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(o=>o.isPending&&!this.running.some(a=>a.active.source==o.source))?setTimeout(()=>this.startUpdate(),l):-1,this.composing!=0)for(let o of n.transactions)o.isUserEvent("input.type")?this.composing=2:this.composing==2&&o.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(fi);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(kn).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=eo(e),i=new YT(e,t,n.explicit,this.view),l=new aB(n,i);this.running.push(l),Promise.resolve(n.source(i)).then(o=>{l.context.aborted||(l.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:bu.of(null)}),di(this.view.state,o)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(kn).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(kn),i=this.view.state.field(fi);for(let l=0;lu.source==o.active.source);if(a&&a.isPending)if(o.done==null){let u=new Fi(o.active.source,0);for(let f of o.updates)u=u.update(f,t);u.isPending||e.push(u)}else this.startQuery(a)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Zy.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(fi,!1);if(e&&e.tooltip&&this.view.state.facet(kn).closeOnBlur){let t=e.open&&DN(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:bu.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:_d.of(!1)}),20),this.composing=0}}}),hB=typeof navigator=="object"&&/Win/.test(navigator.platform),dB=so.highest(Oe.domEventHandlers({keydown(n,e){let t=e.state.field(fi,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||!n.key||n.key.length>1||n.ctrlKey&&!(hB&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],l=t.active.find(a=>a.source==i.source),o=i.completion.commitCharacters||l.result.commitCharacters;return o&&o.indexOf(n.key)>-1&&Jy(e,i),!1}})),mB=Oe.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),vu={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Ks=Ye.define({map(n,e){let t=e.mapPos(n,-1,Kn.TrackAfter);return t??void 0}}),eb=new class extends ns{};eb.startSide=1;eb.endSide=-1;const ZT=In.define({create(){return it.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Ks)&&(n=n.update({add:[eb.range(t.value,t.value+1)]}));return n}});function pB(){return[xB,ZT]}const O0="()[]{}<>«»»«[]{}";function JT(n){for(let e=0;e{if((gB?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let l=n.state.selection.main;if(i.length>2||i.length==2&&Er(ui(i,0))==1||e!=l.from||t!=l.to)return!1;let o=vB(n.state,i);return o?(n.dispatch(o),!0):!1}),yB=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=eA(n,n.selection.main.head).brackets||vu.brackets,l=null,o=n.changeByRange(a=>{if(a.empty){let u=wB(n.doc,a.head);for(let f of i)if(f==u&&cm(n.doc,a.head)==JT(ui(f,0)))return{changes:{from:a.head-f.length,to:a.head+f.length},range:ae.cursor(a.head-f.length)}}return{range:l=a}});return l||e(n.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!l},bB=[{key:"Backspace",run:yB}];function vB(n,e){let t=eA(n,n.selection.main.head),i=t.brackets||vu.brackets;for(let l of i){let o=JT(ui(l,0));if(e==l)return o==l?CB(n,l,i.indexOf(l+l+l)>-1,t):kB(n,l,o,t.before||vu.before);if(e==o&&tA(n,n.selection.main.from))return SB(n,l,o)}return null}function tA(n,e){let t=!1;return n.field(ZT).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function cm(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Er(ui(t,0)))}function wB(n,e){let t=n.sliceString(e-2,e);return Er(ui(t,0))==t.length?t:t.slice(1)}function kB(n,e,t,i){let l=null,o=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:t,from:a.to}],effects:Ks.of(a.to+e.length),range:ae.range(a.anchor+e.length,a.head+e.length)};let u=cm(n.doc,a.head);return!u||/\s/.test(u)||i.indexOf(u)>-1?{changes:{insert:e+t,from:a.head},effects:Ks.of(a.head+e.length),range:ae.cursor(a.head+e.length)}:{range:l=a}});return l?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function SB(n,e,t){let i=null,l=n.changeByRange(o=>o.empty&&cm(n.doc,o.head)==t?{changes:{from:o.head,to:o.head+t.length,insert:t},range:ae.cursor(o.head+t.length)}:i={range:o});return i?null:n.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function CB(n,e,t,i){let l=i.stringPrefixes||vu.stringPrefixes,o=null,a=n.changeByRange(u=>{if(!u.empty)return{changes:[{insert:e,from:u.from},{insert:e,from:u.to}],effects:Ks.of(u.to+e.length),range:ae.range(u.anchor+e.length,u.head+e.length)};let f=u.head,d=cm(n.doc,f),m;if(d==e){if(k2(n,f))return{changes:{insert:e+e,from:f},effects:Ks.of(f+e.length),range:ae.cursor(f+e.length)};if(tA(n,f)){let b=t&&n.sliceDoc(f,f+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:f,to:f+b.length,insert:b},range:ae.cursor(f+b.length)}}}else{if(t&&n.sliceDoc(f-2*e.length,f)==e+e&&(m=S2(n,f-2*e.length,l))>-1&&k2(n,m))return{changes:{insert:e+e+e+e,from:f},effects:Ks.of(f+e.length),range:ae.cursor(f+e.length)};if(n.charCategorizer(f)(d)!=Pt.Word&&S2(n,f,l)>-1&&!OB(n,f,e,l))return{changes:{insert:e+e,from:f},effects:Ks.of(f+e.length),range:ae.cursor(f+e.length)}}return{range:o=u}});return o?null:n.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function k2(n,e){let t=Hn(n).resolveInner(e+1);return t.parent&&t.from==e}function OB(n,e,t,i){let l=Hn(n).resolveInner(e,-1),o=i.reduce((a,u)=>Math.max(a,u.length),0);for(let a=0;a<5;a++){let u=n.sliceDoc(l.from,Math.min(l.to,l.from+t.length+o)),f=u.indexOf(t);if(!f||f>-1&&i.indexOf(u.slice(0,f))>-1){let m=l.firstChild;for(;m&&m.from==l.from&&m.to-m.from>t.length+f;){if(n.sliceDoc(m.to-t.length,m.to)==t)return!1;m=m.firstChild}return!0}let d=l.to==e&&l.parent;if(!d)break;l=d}return!1}function S2(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=Pt.Word)return e;for(let l of t){let o=e-l.length;if(n.sliceDoc(o,e)==l&&i(n.sliceDoc(o-1,o))!=Pt.Word)return o}return-1}function NB(n={}){return[dB,fi,kn.of(n),fB,TB,mB]}const nA=[{key:"Ctrl-Space",run:C0},{mac:"Alt-`",run:C0},{mac:"Alt-i",run:C0},{key:"Escape",run:oB},{key:"ArrowDown",run:Lh(!0)},{key:"ArrowUp",run:Lh(!1)},{key:"PageDown",run:Lh(!0,"page")},{key:"PageUp",run:Lh(!1,"page")},{key:"Enter",run:sB}],TB=so.highest(_y.computeN([kn],n=>n.facet(kn).defaultKeymap?[nA]:[]));class C2{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class $s{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let l=i.facet(wu).markerFilter;l&&(e=l(e,i));let o=e.slice().sort((v,w)=>v.from-w.from||v.to-w.to),a=new zr,u=[],f=0,d=i.doc.iter(),m=0,g=i.doc.length;for(let v=0;;){let w=v==o.length?null:o[v];if(!w&&!u.length)break;let S,C;if(u.length)S=f,C=u.reduce((M,I)=>Math.min(M,I.to),w&&w.from>S?w.from:1e8);else{if(S=w.from,S>g)break;C=w.to,u.push(w),v++}for(;vM.from||M.to==S))u.push(M),v++,C=Math.min(M.to,C);else{C=Math.min(M.from,C);break}}C=Math.min(C,g);let N=!1;if(u.some(M=>M.from==S&&(M.to==C||C==g))&&(N=S==C,!N&&C-S<10)){let M=S-(m+d.value.length);M>0&&(d.next(M),m=S);for(let I=S;;){if(I>=C){N=!0;break}if(!d.lineBreak&&m+d.value.length>I)break;I=m+d.value.length,m+=d.value.length,d.next()}}let R=IB(u);if(N)a.add(S,S,He.widget({widget:new zB(R),diagnostics:u.slice()}));else{let M=u.reduce((I,U)=>U.markClass?I+" "+U.markClass:I,"");a.add(S,C,He.mark({class:"cm-lintRange cm-lintRange-"+R+M,diagnostics:u.slice(),inclusiveEnd:u.some(I=>I.to>C)}))}if(f=C,f==g)break;for(let M=0;M{if(!(e&&a.diagnostics.indexOf(e)<0))if(!i)i=new C2(l,o,e||a.diagnostics[0]);else{if(a.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new C2(i.from,o,i.diagnostic)}}),i}function AB(n,e){let t=e.pos,i=e.end||t,l=n.state.facet(wu).hideOn(n,t,i);if(l!=null)return l;let o=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(a=>a.is(iA))||n.changes.touchesRange(o.from,Math.max(o.to,i)))}function EB(n,e){return n.field(Ai,!1)?e:e.concat(Ye.appendConfig.of(UB))}const iA=Ye.define(),tb=Ye.define(),rA=Ye.define(),Ai=In.define({create(){return new $s(He.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,l=n.panel;if(n.selected){let o=e.changes.mapPos(n.selected.from,1);i=as(t,n.selected.diagnostic,o)||as(t,null,o)}!t.size&&l&&e.state.facet(wu).autoPanel&&(l=null),n=new $s(t,l,i)}for(let t of e.effects)if(t.is(iA)){let i=e.state.facet(wu).autoPanel?t.value.length?ku.open:null:n.panel;n=$s.init(t.value,i,e.state)}else t.is(tb)?n=new $s(n.diagnostics,t.value?ku.open:null,n.selected):t.is(rA)&&(n=new $s(n.diagnostics,n.panel,t.value));return n},provide:n=>[mu.from(n,e=>e.panel),Oe.decorations.from(n,e=>e.diagnostics)]}),MB=He.mark({class:"cm-lintRange cm-lintRange-active"});function DB(n,e,t){let{diagnostics:i}=n.state.field(Ai),l,o=-1,a=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(f,d,{spec:m})=>{if(e>=f&&e<=d&&(f==d||(e>f||t>0)&&(esA(n,t,!1)))}const RB=n=>{let e=n.state.field(Ai,!1);(!e||!e.panel)&&n.dispatch({effects:EB(n.state,[tb.of(!0)])});let t=nm(n,ku.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},O2=n=>{let e=n.state.field(Ai,!1);return!e||!e.panel?!1:(n.dispatch({effects:tb.of(!1)}),!0)},_B=n=>{let e=n.state.field(Ai,!1);if(!e)return!1;let t=n.state.selection.main,i=as(e.diagnostics,null,t.to+1);return!i&&(i=as(e.diagnostics,null,0),!i||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),E_(n,i.from,1,{tooltip:oA,until:l=>l.docChanged||l.newSelection.main.headi.to}),!0)},LB=[{key:"Mod-Shift-m",run:RB,preventDefault:!0},{key:"F8",run:_B}],wu=Ce.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...Br(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:N2,tooltipFilter:N2,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,l,o)=>e(i,l,o)||t(i,l,o):e:t,autoPanel:(e,t)=>e||t})}}});function N2(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function lA(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;io.toLowerCase()==l.toLowerCase())){e.push(l);continue e}}e.push("")}return e}function sA(n,e,t){var i;let l=t?lA(e.actions):[];return Ct("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Ct("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((o,a)=>{let u=!1,f=v=>{if(v.preventDefault(),u)return;u=!0;let w=as(n.state.field(Ai).diagnostics,e);w&&o.apply(n,w.from,w.to)},{name:d}=o,m=l[a]?d.indexOf(l[a]):-1,g=m<0?d:[d.slice(0,m),Ct("u",d.slice(m,m+1)),d.slice(m+1)],b=o.markClass?" "+o.markClass:"";return Ct("button",{type:"button",class:"cm-diagnosticAction"+b,onclick:f,onmousedown:f,"aria-label":` Action: ${d}${m<0?"":` (access key "${l[a]})"`}.`},g)}),e.source&&Ct("div",{class:"cm-diagnosticSource"},e.source))}class zB extends ul{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Ct("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class T2{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=sA(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ku{constructor(e){this.view=e,this.items=[];let t=l=>{if(!(l.ctrlKey||l.altKey||l.metaKey)){if(l.keyCode==27)O2(this.view),this.view.focus();else if(l.keyCode==38||l.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(l.keyCode==40||l.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(l.keyCode==36)this.moveSelection(0);else if(l.keyCode==35)this.moveSelection(this.items.length-1);else if(l.keyCode==13)this.view.focus();else if(l.keyCode>=65&&l.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],a=lA(o.actions);for(let u=0;u{for(let o=0;oO2(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Ai).selected;if(!e)return-1;for(let t=0;t{for(let m of d.diagnostics){if(a.has(m))continue;a.add(m);let g=-1,b;for(let v=i;vi&&(this.items.splice(i,g-i),l=!0)),t&&b.diagnostic==t.diagnostic?b.dom.hasAttribute("aria-selected")||(b.dom.setAttribute("aria-selected","true"),o=b):b.dom.hasAttribute("aria-selected")&&b.dom.removeAttribute("aria-selected"),i++}});i({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:u,panel:f})=>{let d=f.height/this.list.offsetHeight;u.topf.bottom&&(this.list.scrollTop+=(u.bottom-f.bottom)/d)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),l&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Ai),i=as(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:rA.of(i)})}static open(e){return new ku(e)}}function BB(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function zh(n){return BB(``,'width="6" height="3"')}const PB=Oe.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:zh("#f11")},".cm-lintRange-warning":{backgroundImage:zh("orange")},".cm-lintRange-info":{backgroundImage:zh("#999")},".cm-lintRange-hint":{backgroundImage:zh("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function HB(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function IB(n){let e="hint",t=1;for(let i of n){let l=HB(i.severity);l>t&&(t=l,e=i.severity)}return e}const oA=A_(DB,{hideOn:AB}),UB=[Ai,Oe.decorations.compute([Ai],n=>{let{selected:e,panel:t}=n.field(Ai);return!e||!t||e.from==e.to?He.none:He.set([MB.range(e.from,e.to)])}),oA,PB],FB=[q_(),X_(),l_(),az(),LL(),$R(),JR(),dt.allowMultipleSelections.of(!0),wL(),rT(HL,{fallback:!0}),XL(),pB(),NB(),x_(),v_(),f_(),x6(),_y.of([...bB,...h6,...P6,...xz,...DL,...nA,...LB])];var A2={};class zd{constructor(e,t,i,l,o,a,u,f,d,m=0,g){this.p=e,this.stack=t,this.state=i,this.reducePos=l,this.pos=o,this.score=a,this.buffer=u,this.bufferBase=f,this.curContext=d,this.lookAhead=m,this.parent=g}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let l=e.parser.context;return new zd(e,[],t,i,i,0,[],0,l?new E2(l,l.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,l=e&65535,{parser:o}=this.p,a=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[l])===null||t===void 0)&&t.isAnonymous)&&(d==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=m):this.p.lastBigReductionSizef;)this.stack.pop();this.reduceContext(l,d)}storeNode(e,t,i,l=4,o=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[a-4]==0&&this.buffer[a-1]>-1){if(t==i)return;if(this.buffer[a-2]>=t){this.buffer[a-2]=i;return}}}if(!o||this.pos==i)this.buffer.push(e,t,i,l);else{let a=this.buffer.length;if(a>0&&(this.buffer[a-4]!=0||this.buffer[a-1]<0)){let u=!1;for(let f=a;f>0&&this.buffer[f-2]>i;f-=4)if(this.buffer[f-1]>=0){u=!0;break}if(u)for(;a>0&&this.buffer[a-2]>i;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,l>4&&(l-=4)}this.buffer[a]=e,this.buffer[a+1]=t,this.buffer[a+2]=i,this.buffer[a+3]=l}}shift(e,t,i,l){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let o=e,{parser:a}=this.p;this.pos=l;let u=a.stateFlag(o,1);!u&&(l>i||t<=a.maxNode)&&(this.reducePos=l),this.pushState(o,u?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=a.maxNode&&this.buffer.push(t,i,l,4)}else this.pos=l,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,l,4)}apply(e,t,i,l){e&65536?this.reduce(e):this.shift(e,t,i,l)}useNode(e,t,i){let l=this.p.reused.length-1;(l<0||this.p.reused[l]!=e)&&(this.p.reused.push(e),l++);let o=this.reducePos=this.pos=i+e.length;this.pushState(t,i),this.buffer.push(l,i,o,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),l=e.bufferBase+t;for(;e&&l==e.bufferBase;)e=e.parent;return new zd(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,l,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new qB(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let l=[];for(let o=0,a;of&1&&u==a)||l.push(t[o],a)}t=l}let i=[];for(let l=0;l>19,l=t&65535,o=this.stack.length-i*3;if(o<0||e.getGoto(this.stack[o],l,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;t=a}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(l,o)=>{if(!t.includes(l))return t.push(l),e.allActions(l,a=>{if(!(a&393216))if(a&65536){let u=(a>>19)-o;if(u>1){let f=a&65535,d=this.stack.length-u*3;if(d>=0&&e.getGoto(this.stack[d],f,!1)>=0)return u<<19|65536|f}}else{let u=i(a,o+1);if(u!=null)return u}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t0&&this.emitLookAhead()}}class E2{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class qB{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let l=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=l}}class Bd{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Bd(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Bd(this.stack,this.pos,this.index)}}function Bh(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,l=0;i=92&&a--,a>=34&&a--;let f=a-32;if(f>=46&&(f-=46,u=!0),o+=f,u)break;o*=46}t?t[l++]=o:t=new e(o)}return t}class sd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const M2=new sd;class VB{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=M2,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,l=this.rangeIndex,o=this.pos+e;for(;oi.to:o>=i.to;){if(l==this.ranges.length-1)return null;let a=this.ranges[++l];o+=a.from-i.to,i=a}return o}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,l;if(t>=0&&t=this.chunk2Pos&&iu.to&&(this.chunk2=this.chunk2.slice(0,u.to-i)),l=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),l}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=M2,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let l of this.ranges){if(l.from>=t)break;l.to>e&&(i+=this.input.read(Math.max(l.from,e),Math.min(l.to,t)))}return i}}class ba{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;QB(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}ba.prototype.contextual=ba.prototype.fallback=ba.prototype.extend=!1;ba.prototype.fallback=ba.prototype.extend=!1;class um{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function QB(n,e,t,i,l,o){let a=0,u=1<0){let w=n[v];if(f.allows(w)&&(e.token.value==-1||e.token.value==w||XB(w,e.token.value,l,o))){e.acceptToken(w);break}}let m=e.next,g=0,b=n[a+2];if(e.next<0&&b>g&&n[d+b*3-3]==65535){a=n[d+b*3-1];continue e}for(;g>1,w=d+v+(v<<1),S=n[w],C=n[w+1]||65536;if(m=C)g=v+1;else{a=n[w+2],e.advance();continue e}}break}}function D2(n,e,t){for(let i=e,l;(l=n[i])!=65535;i++)if(l==t)return i-e;return-1}function XB(n,e,t,i){let l=D2(t,i,e);return l<0||D2(t,i,n)e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class $B{constructor(e,t){this.fragments=e,this.minRepeat=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.lastRepeat=null,this.lastRepeatPos=-1,this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?j2(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?j2(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=a,null;if(o instanceof cn){let u=a>this.lastRepeatPos&&o.type.id>=this.minRepeat;if(a==e||u){let f=a+o.length,d;if(a>=this.safeFrom&&f<=this.safeTo&&(!(d=o.prop(Je.lookAhead))||f+d=Math.max(this.safeFrom,e)&&(this.trees.push(o),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+o.length}}}class YB{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new sd)}getActions(e){let t=0,i=null,{parser:l}=e.p,{tokenizers:o}=l,a=l.stateSlot(e.state,3),u=e.curContext?e.curContext.hash:0,f=0;for(let d=0;dg.end+25&&(f=Math.max(g.lookAhead,f)),g.value!=0)){let b=t;if(g.extended>-1&&(t=this.addActions(e,g.extended,g.end,t)),t=this.addActions(e,g.value,g.end,t),!m.extend&&(i=g,t>b))break}}for(;this.actions.length>t;)this.actions.pop();return f&&e.setLookAhead(f),!i&&e.pos==this.stream.end&&(i=new sd,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new sd,{pos:i,p:l}=e;return t.start=i,t.end=Math.min(i+1,l.stream.end),t.value=i==l.stream.end?l.parser.eofTerm:0,t}updateCachedToken(e,t,i){let l=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(l,e),i),e.value>-1){let{parser:o}=i.p;for(let a=0;a=0&&i.p.parser.dialect.allows(u>>1)){(u&1)==0?e.value=u>>1:e.extended=u>>1;break}}}else e.value=0,e.end=this.stream.clipPos(l+1)}putAction(e,t,i,l){for(let o=0;oe.bufferLength*4?new $B(i,e.minRepeatTerm):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],l,o;if(this.bigReductionCount>300&&e.length==1){let[a]=e;for(;a.forceReduce()&&a.stack.length&&a.stack[a.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;at)i.push(u);else{if(this.advanceStack(u,i,e))continue;{l||(l=[],o=[]),l.push(u);let f=this.tokens.getMainToken(u);o.push(f.value,f.end)}}break}}if(!i.length){let a=l&&ZB(l);if(a)return Oi&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw Oi&&l&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&l){let a=this.stoppedAt!=null&&l[0].pos>this.stoppedAt?l[0]:this.runRecovery(l,o,i);if(a)return Oi&&console.log("Force-finish "+this.stackID(a)),this.stackToTree(a.forceAll())}if(this.recovering){let a=this.recovering==1?1:this.recovering*3;if(i.length>a)for(i.sort((u,f)=>f.score-u.score);i.length>a;)i.pop();i.some(u=>u.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let a=0;a500&&d.buffer.length>500)if((u.score-d.score||u.buffer.length-d.buffer.length)>0)i.splice(f--,1);else{i.splice(a--,1);continue e}}}i.length>12&&(i.sort((a,u)=>u.score-a.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let a=1;a-1&&i.length&&(!o||(i.prop(Je.contextHash)||0)==a))return e.useNode(i,u,t),i;if(i.children.length==0||i.positions[0]>0)break;let f=i.children[0];if(f instanceof cn&&(!l||f.type.id>=this.parser.minRepeatTerm))i=f;else break}return null}advanceStack(e,t,i){let l=e.pos,{parser:o}=this,a=Oi?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&l>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let d=e.reducePos0)return e.reduce(u),Oi&&console.log(a+this.stackID(e)+` (via always-reduce ${o.getName(u&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let f=this.tokens.getActions(e);for(let d=0;dl?t.push(w):i.push(w)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return R2(e,t),!0}}runRecovery(e,t,i){let l=null,o=!1;for(let a=0;a ":"";if(u.deadEnd&&(o||(o=!0,u.restart(),Oi&&console.log(m+this.stackID(u)+" (restarted)"),this.advanceFully(u,i))))continue;let g=u.split(),b=m;for(let v=0;v<10&&g.forceReduce()&&(Oi&&console.log(b+this.stackID(g)+" (via force-reduce)"),!this.advanceFully(g,i));v++)Oi&&(b=this.stackID(g)+" -> ");for(let v of u.recoverByInsert(f))Oi&&console.log(m+this.stackID(v)+" (via recover-insert)"),this.advanceFully(v,i);this.stream.end>u.pos?(d==u.pos&&(d++,f=0),u.recoverByDelete(f,d),Oi&&console.log(m+this.stackID(u)+` (via recover-delete ${this.parser.getName(f)})`),R2(u,i)):(!l||l.scoren;class WB{constructor(e){this.start=e.start,this.shift=e.shift||T0,this.reduce=e.reduce||T0,this.reuse=e.reuse||T0,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class Pd extends UN{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let u=0;ue.topRules[u][1]),l=[];for(let u=0;u=0)o(m,f,u[d++]);else{let g=u[d+-m];for(let b=-m;b>0;b--)o(u[d++],f,g);d++}}}this.nodeSet=new By(t.map((u,f)=>pi.define({name:f>=this.minRepeatTerm?void 0:u,id:f,props:l[f],top:i.indexOf(f)>-1,error:f==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(f)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=BN;let a=Bh(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let u=0;utypeof u=="number"?new ba(a,u):u),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let l=new GB(this,e,t,i);for(let o of this.wrappers)l=o(l,e,t,i);return l}getGoto(e,t,i=!1){let l=this.goto;if(t>=l[0])return-1;for(let o=l[t+1];;){let a=l[o++],u=a&1,f=l[o++];if(u&&i)return f;for(let d=o+(a>>1);o0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),l=i?t(i):void 0;for(let o=this.stateSlot(e,1);l==null;o+=3){if(this.data[o]==65535)if(this.data[o+1]==1)o=nl(this.data,o+2);else break;l=t(nl(this.data,o+1))}return l}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=nl(this.data,i+2);else break;if((this.data[i+2]&1)==0){let l=this.data[i+1];t.some((o,a)=>a&1&&o==l)||t.push(this.data[i],l)}}return t}configure(e){let t=Object.assign(Object.create(Pd.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let l=e.tokenizers.find(o=>o.from==i);return l?l.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,l)=>{let o=e.specializers.find(u=>u.from==i.external);if(!o)return i;let a=Object.assign(Object.assign({},i),{external:o.to});return t.specializers[l]=_2(a),a})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let o of e.split(" ")){let a=t.indexOf(o);a>=0&&(i[a]=!0)}let l=null;for(let o=0;oi)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}const ra=63,L2=64,JB=1,e9=2,aA=3,t9=4,cA=5,n9=6,i9=7,uA=65,r9=66,l9=8,s9=9,o9=10,a9=11,c9=12,fA=13,u9=19,f9=20,h9=29,d9=33,m9=34,p9=47,g9=0,nb=1,Yx=2,Su=3,Gx=4;class Ys{constructor(e,t,i){this.parent=e,this.depth=t,this.type=i,this.hash=(e?e.hash+e.hash<<8:0)+t+(t<<4)+i}}Ys.top=new Ys(null,-1,g9);function iu(n,e){for(let t=0,i=e-n.pos-1;;i--,t++){let l=n.peek(i);if(al(l)||l==-1)return t}}function Kx(n){return n==32||n==9}function al(n){return n==10||n==13}function hA(n){return Kx(n)||al(n)}function Ws(n){return n<0||hA(n)}const x9=new WB({start:Ys.top,reduce(n,e){return n.type==Su&&(e==f9||e==m9)?n.parent:n},shift(n,e,t,i){if(e==aA)return new Ys(n,iu(i,i.pos),nb);if(e==uA||e==cA)return new Ys(n,iu(i,i.pos),Yx);if(e==ra)return n.parent;if(e==u9||e==d9)return new Ys(n,0,Su);if(e==fA&&n.type==Gx)return n.parent;if(e==p9){let l=/[1-9]/.exec(i.read(i.pos,t.pos));if(l)return new Ys(n,n.depth+ +l[0],Gx)}return n},hash(n){return n.hash}});function ja(n,e,t=0){return n.peek(t)==e&&n.peek(t+1)==e&&n.peek(t+2)==e&&Ws(n.peek(t+3))}const y9=new um((n,e)=>{if(n.next==-1&&e.canShift(L2))return n.acceptToken(L2);let t=n.peek(-1);if((al(t)||t<0)&&e.context.type!=Su){if(ja(n,45))if(e.canShift(ra))n.acceptToken(ra);else return n.acceptToken(JB,3);if(ja(n,46))if(e.canShift(ra))n.acceptToken(ra);else return n.acceptToken(e9,3);let i=0;for(;n.next==32;)i++,n.advance();(i{if(e.context.type==Su){n.next==63&&(n.advance(),Ws(n.next)&&n.acceptToken(i9));return}if(n.next==45)n.advance(),Ws(n.next)&&n.acceptToken(e.context.type==nb&&e.context.depth==iu(n,n.pos-1)?t9:aA);else if(n.next==63)n.advance(),Ws(n.next)&&n.acceptToken(e.context.type==Yx&&e.context.depth==iu(n,n.pos-1)?n9:cA);else{let t=n.pos;for(;;)if(Kx(n.next)){if(n.pos==t)return;n.advance()}else if(n.next==33)dA(n);else if(n.next==38)Wx(n);else if(n.next==42){Wx(n);break}else if(n.next==39||n.next==34){if(ib(n,!0))break;return}else if(n.next==91||n.next==123){if(!w9(n))return;break}else{mA(n,!0,!1,0);break}for(;Kx(n.next);)n.advance();if(n.next==58){if(n.pos==t&&e.canShift(h9))return;let i=n.peek(1);Ws(i)&&n.acceptTokenTo(e.context.type==Yx&&e.context.depth==iu(n,t)?r9:uA,t)}}},{contextual:!0});function v9(n){return n>32&&n<127&&n!=34&&n!=37&&n!=44&&n!=60&&n!=62&&n!=92&&n!=94&&n!=96&&n!=123&&n!=124&&n!=125}function z2(n){return n>=48&&n<=57||n>=97&&n<=102||n>=65&&n<=70}function B2(n,e){return n.next==37?(n.advance(),z2(n.next)&&n.advance(),z2(n.next)&&n.advance(),!0):v9(n.next)||e&&n.next==44?(n.advance(),!0):!1}function dA(n){if(n.advance(),n.next==60){for(n.advance();;)if(!B2(n,!0)){n.next==62&&n.advance();break}}else for(;B2(n,!1););}function Wx(n){for(n.advance();!Ws(n.next)&&Hd(n.next)!="f";)n.advance()}function ib(n,e){let t=n.next,i=!1,l=n.pos;for(n.advance();;){let o=n.next;if(o<0)break;if(n.advance(),o==t)if(o==39)if(n.next==39)n.advance();else break;else break;else if(o==92&&t==34)n.next>=0&&n.advance();else if(al(o)){if(e)return!1;i=!0}else if(e&&n.pos>=l+1024)return!1}return!i}function w9(n){for(let e=[],t=n.pos+1024;;)if(n.next==91||n.next==123)e.push(n.next),n.advance();else if(n.next==39||n.next==34){if(!ib(n,!0))return!1}else if(n.next==93||n.next==125){if(e[e.length-1]!=n.next-2)return!1;if(e.pop(),n.advance(),!e.length)return!0}else{if(n.next<0||n.pos>t||al(n.next))return!1;n.advance()}}const k9="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function Hd(n){return n<33?"u":n>125?"s":k9[n-33]}function A0(n,e){let t=Hd(n);return t!="u"&&!(e&&t=="f")}function mA(n,e,t,i){if(Hd(n.next)=="s"||(n.next==63||n.next==58||n.next==45)&&A0(n.peek(1),t))n.advance();else return!1;let l=n.pos;for(;;){let o=n.next,a=0,u=i+1;for(;hA(o);){if(al(o)){if(e)return!1;u=0}else u++;o=n.peek(++a)}if(!(o>=0&&(o==58?A0(n.peek(a+1),t):o==35?n.peek(a-1)!=32:A0(o,t)))||!t&&u<=i||u==0&&!t&&(ja(n,45,a)||ja(n,46,a)))break;if(e&&Hd(o)=="f")return!1;for(let d=a;d>=0;d--)n.advance();if(e&&n.pos>l+1024)return!1}return!0}const S9=new um((n,e)=>{if(n.next==33)dA(n),n.acceptToken(c9);else if(n.next==38||n.next==42){let t=n.next==38?o9:a9;Wx(n),n.acceptToken(t)}else n.next==39||n.next==34?(ib(n,!1),n.acceptToken(s9)):mA(n,!1,e.context.type==Su,e.context.depth)&&n.acceptToken(l9)}),C9=new um((n,e)=>{let t=e.context.type==Gx?e.context.depth:-1,i=n.pos;e:for(;;){let l=0,o=n.next;for(;o==32;)o=n.peek(++l);if(!l&&(ja(n,45,l)||ja(n,46,l))||!al(o)&&(t<0&&(t=Math.max(e.context.depth+1,l)),lYAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:x9,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[O9],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[y9,b9,S9,C9,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),T9=Sd.define({name:"yaml",parser:N9.configure({props:[XN.add({Stream:n=>{for(let e=n.node.resolve(n.pos,-1);e&&e.to>=n.pos;e=e.parent){if(e.name=="BlockLiteralContent"&&e.fromn.pos)return null}}return null},FlowMapping:ZS({closing:"}"}),FlowSequence:ZS({closing:"]"})}),GN.add({"FlowMapping FlowSequence":SL,"Item Pair BlockLiteral":(n,e)=>({from:e.doc.lineAt(n.from).to,to:n.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function A9(){return new hL(T9)}const P2='button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], video[tabindex], [tabindex]:not([tabindex="-1"])';function hs({isOpen:n,onClose:e,dialogRef:t,initialFocusRef:i}){return D.useEffect(()=>{if(!n)return;const l=document.activeElement instanceof HTMLElement?document.activeElement:null,o=requestAnimationFrame(()=>{var f;const u=(i==null?void 0:i.current)??((f=t.current)==null?void 0:f.querySelector(P2))??t.current;u==null||u.focus()}),a=u=>{if(u.key!=="Tab")return;const f=t.current;if(!f)return;const d=Array.from(f.querySelectorAll(P2));if(!d.length)return;const m=d[0],g=d[d.length-1],b=document.activeElement;if(!(b instanceof Node&&f.contains(b))){u.preventDefault(),(u.shiftKey?g:m).focus();return}u.shiftKey&&(b===m||b===f)?(u.preventDefault(),g.focus()):!u.shiftKey&&(b===g||b===f)&&(u.preventDefault(),m.focus())};return window.addEventListener("keydown",a,!0),()=>{cancelAnimationFrame(o),l==null||l.focus(),window.removeEventListener("keydown",a,!0)}},[n]),l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),e())}}function va({isOpen:n,title:e,message:t,confirmLabel:i="Confirm",cancelLabel:l="Cancel",danger:o=!1,onConfirm:a,onCancel:u}){const f=D.useRef(null),d=D.useRef(null),m=hs({isOpen:n,onClose:u,dialogRef:f,initialFocusRef:d});return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",onClick:u,children:y.jsxs("div",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"confirm-dialog-title",onKeyDown:m,onClick:g=>g.stopPropagation(),className:"animate-modal-in w-[400px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("div",{className:"mb-3 flex items-center gap-2.5",children:[y.jsx("span",{className:`grid h-9 w-9 shrink-0 place-items-center rounded-lg ${o?"bg-status-danger-bg text-status-danger-text":"bg-chip-indigo-bg text-chip-indigo-text"}`,children:y.jsx(yy,{className:"h-5 w-5"})}),y.jsx("h2",{id:"confirm-dialog-title",className:"text-sm font-semibold text-ink",children:e})]}),y.jsx("div",{className:"mb-5 whitespace-pre-line text-xs text-ink-secondary",children:t}),y.jsxs("div",{className:"flex justify-end gap-2",children:[y.jsx("button",{ref:d,type:"button",onClick:u,className:"min-h-9 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:l}),y.jsx("button",{type:"button",onClick:a,className:`min-h-9 rounded-lg border px-4 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 ${o?"border-status-danger-border bg-status-danger-bg/30 text-status-danger-text hover:bg-status-danger-bg/60":"btn-primary border-transparent bg-indigo-600 text-white hover:bg-indigo-500"}`,children:i})]})]})}):null}var E9=XC();const Tr=8,Zl=8,M9=400,H2={top:"bottom",bottom:"top",left:"right",right:"left"},D9={top:"-bottom-1 left-1/2 -translate-x-1/2",bottom:"-top-1 left-1/2 -translate-x-1/2",left:"-right-1 top-1/2 -translate-y-1/2",right:"-left-1 top-1/2 -translate-y-1/2"},j9={top:"border-b border-r",bottom:"border-t border-l",left:"border-t border-r",right:"border-b border-l"},I2=(n,e,t)=>{switch(n){case"top":return e.top-Zl-t.h>=Tr;case"bottom":return e.bottom+Zl+t.h<=window.innerHeight-Tr;case"left":return e.left-Zl-t.w>=Tr;default:return e.right+Zl+t.w<=window.innerWidth-Tr}},R9=(n,e,t)=>{if(n==="top"||n==="bottom"){const a=e.left+e.width/2-t.w/2,u=window.innerWidth-t.w-Tr;return{x:Math.min(Math.max(a,Tr),Math.max(Tr,u))-a,y:0}}const i=e.top+e.height/2-t.h/2,l=window.innerHeight-t.h-Tr;return{x:0,y:Math.min(Math.max(i,Tr),Math.max(Tr,l))-i}},Qe=({text:n,children:e,block:t=!0,placement:i="top",suppress:l=!1})=>{const o=D.useRef(null),a=D.useRef(null),u=D.useId(),f=D.useRef(null),[d,m]=D.useState(!1),[g,b]=D.useState(i),[v,w]=D.useState({x:0,y:0}),[S,C]=D.useState({left:-9999,top:-9999}),N=()=>{f.current!==null&&(window.clearTimeout(f.current),f.current=null)};D.useEffect(()=>{l&&(N(),m(!1))},[l]),D.useEffect(()=>()=>N(),[]);const R=D.useCallback(()=>{const E=o.current,T=a.current;if(!E||!T)return;const z=E.getBoundingClientRect(),ie={w:T.offsetWidth,h:T.offsetHeight},q=I2(i,z,ie)?i:I2(H2[i],z,ie)?H2[i]:i,J=R9(q,z,ie);b(q),w(J);const F=z.left+z.width/2,se=z.top+z.height/2;C(q==="top"?{left:F,top:z.top-Zl-ie.h}:q==="bottom"?{left:F,top:z.bottom+Zl}:q==="left"?{left:z.left-Zl-ie.w,top:se}:{left:z.right+Zl,top:se})},[i]);D.useEffect(()=>{if(!d)return;const E=()=>m(!1);return window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[d]);const M=E=>{if(l)return;N();const T=()=>{R(),m(!0)};E?T():f.current=window.setTimeout(T,M9)},I=()=>{N(),m(!1)};D.useEffect(()=>{if(!d)return;const E=T=>{T.key==="Escape"&&m(!1)};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[d]),D.useEffect(()=>{if(!d)return;const E=()=>!!document.querySelector('[role="dialog"][aria-modal="true"], dialog[open]');if(E()){m(!1);return}const T=new MutationObserver(()=>{E()&&m(!1)});return T.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","open","class"]}),()=>T.disconnect()},[d]);const U={onMouseEnter:()=>M(!1),onMouseLeave:I,onFocus:()=>M(!0),onBlur:I,"aria-describedby":u};return y.jsxs("div",{ref:o,className:`group relative ${t?"flex min-w-0 flex-1 items-center":"inline-flex shrink-0 items-center"}`,onMouseEnter:()=>M(!1),onMouseLeave:I,onFocus:()=>M(!0),onBlur:I,children:[D.cloneElement(e,U),E9.createPortal(y.jsxs("span",{ref:a,id:u,role:"tooltip",className:`pointer-events-none invisible fixed z-[var(--z-tooltip)] w-max max-w-[calc(100vw-16px)] rounded-md border border-line bg-elevated px-2 py-1 text-left text-[11px] leading-relaxed text-ink shadow-lg ${d?"visible opacity-100":"opacity-0"}`,style:{left:S.left,top:S.top,transform:g==="top"||g==="bottom"?`translateX(calc(-50% + ${v.x}px))`:`translateY(calc(-50% + ${v.y}px))`},children:[n,y.jsx("span",{className:`absolute h-2 w-2 rotate-45 border-line bg-elevated ${D9[g]} ${j9[g]}`,style:g==="top"||g==="bottom"?{left:`calc(50% - ${v.x}px)`}:void 0})]}),document.body)]})},_9=[".profiles",".profiles.yaml"];function L9(n){const e=n.trim();if(!e)return null;const t=e.toLowerCase(),i=_9.find(l=>t.endsWith(l));if(i!==void 0){const l=e.slice(0,e.length-i.length);return!l.trim()||l!==l.trimEnd()?null:e}return t.includes(".")?null:`${e}.profiles`}function z9({open:n,onCancel:e,onConfirm:t}){const[i,l]=D.useState(null),[o,a]=D.useState(""),[u,f]=D.useState(""),[d,m]=D.useState(null),[g,b]=D.useState(!1),[v,w]=D.useState(null),[S,C]=D.useState(null),N=D.useRef(null),R=D.useRef(null),M=D.useRef(null),I=D.useCallback(async z=>{b(!0),w(null);try{const ie=await GC(z);l(ie),a(ie.current_path)}catch(ie){w(ie instanceof Error?ie.message:String(ie))}finally{b(!1)}},[]);D.useEffect(()=>{if(!n)return;f(""),m(null),C(null),I(o);const z=requestAnimationFrame(()=>{var ie;return(ie=R.current)==null?void 0:ie.focus()});return()=>cancelAnimationFrame(z)},[n]);const U=hs({isOpen:n,onClose:e,dialogRef:N,initialFocusRef:R});function E(){if(!i)return;const z=L9(u);if(z===null){m("Not a ProFiles configuration file. Allowed extensions: .profiles, .profiles.yaml");return}m(null);const ie=o.trim()||i.current_path;if(o.trim()===i.current_path&&i.items.some(F=>!F.is_dir&&F.name===z)){C({filename:z,directory:ie});return}t({filename:z,directory:ie,overwrite:!1})}if(!n)return null;const T=(i==null?void 0:i.items.filter(z=>z.is_dir))??[];return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-4 backdrop-blur-sm",onClick:e,children:y.jsxs("div",{ref:N,role:"dialog","aria-modal":"true","aria-labelledby":"save-as-dialog-title",onKeyDown:U,onClick:z=>z.stopPropagation(),className:"animate-modal-in flex max-h-[calc(100dvh-2rem)] w-[min(94vw,560px)] flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",children:[y.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-line px-5 py-3",children:y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(iO,{className:"h-4 w-4 text-chip-indigo-text"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"save-as-dialog-title",className:"text-sm font-semibold text-ink",children:"Save configuration as"}),y.jsx("p",{className:"truncate font-mono text-xs text-ink-muted",children:(i==null?void 0:i.current_path)||"…"})]})]})}),y.jsxs("div",{className:"border-b border-line px-5 py-3",children:[y.jsx("label",{htmlFor:"save-as-path",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"Location"}),y.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[y.jsx("input",{ref:M,id:"save-as-path",type:"text",value:o,onChange:z=>a(z.target.value),onKeyDown:z=>{z.key==="Enter"&&I(o.trim())},placeholder:"/path/to/directory",className:"h-9 min-w-0 flex-1 rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),y.jsx("button",{type:"button",onClick:()=>void I(o.trim()),className:"inline-flex h-9 shrink-0 items-center rounded-lg border border-line bg-elevated px-3 text-sm font-medium text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Go"}),y.jsx(Qe,{text:"Home directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void I(""),"aria-label":"Home directory",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx($d,{className:"h-4 w-4"})})}),(i==null?void 0:i.parent_path)&&y.jsx(Qe,{text:"Parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void I(i.parent_path),"aria-label":"Parent directory",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Xd,{className:"h-4 w-4 rotate-180"})})})]})]}),y.jsx("div",{className:"min-h-24 flex-1 overflow-y-auto px-2 py-2 sm:px-3","aria-busy":g,children:g?y.jsxs("div",{className:"flex h-full items-center justify-center gap-2.5 text-sm text-ink-muted",children:[y.jsx(ll,{className:"h-5 w-5 animate-spin text-chip-indigo-text"}),y.jsx("span",{role:"status",children:"Loading directories…"})]}):v?y.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2.5 text-center",children:[y.jsx("p",{className:"text-sm text-status-danger-text",children:v}),y.jsx("button",{type:"button",onClick:()=>void I(o||(i==null?void 0:i.current_path)||""),className:"min-h-9 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Retry"})]}):y.jsxs("ul",{className:"space-y-0.5",children:[T.map(z=>y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>void I(z.path),className:"flex min-h-9 w-full items-center gap-2.5 rounded-lg px-3 py-1.5 text-left text-sm text-ink-secondary transition-colors hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400",children:[y.jsx(Ou,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"}),y.jsx("span",{className:"truncate",children:z.name})]})},z.path)),T.length===0&&y.jsxs("li",{className:"flex min-h-16 flex-col items-center justify-center gap-2 text-center text-sm text-ink-muted",children:[y.jsx(Jl,{className:"h-6 w-6 text-ink-faint"}),"No subdirectories found"]})]})}),y.jsxs("div",{className:"shrink-0 border-t border-line px-5 py-3",children:[y.jsx("label",{htmlFor:"save-as-filename",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"File name"}),y.jsx("input",{ref:R,id:"save-as-filename",type:"text",value:u,onChange:z=>{f(z.target.value),m(null)},onKeyDown:z=>{z.key==="Enter"&&u.trim()&&E()},placeholder:"machine.profiles",className:"h-9 w-full rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),d&&y.jsx("p",{role:"alert","data-testid":"save-as-error",className:"mt-1.5 text-xs text-status-danger-text",children:d}),y.jsxs("div",{className:"mt-3 flex justify-end gap-1.5",children:[y.jsx("button",{type:"button",onClick:e,className:"min-h-9 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Cancel"}),y.jsxs("button",{type:"button",onClick:E,disabled:!u.trim()||!i||g,title:"Save the configuration to the selected folder",className:"btn btn-primary min-h-9 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(_r,{className:"h-4 w-4"}),"Save"]})]})]})]})}),y.jsx(va,{isOpen:S!==null,title:"Replace configuration?",message:`A configuration named "${S==null?void 0:S.filename}" already exists in this folder. -Saving will replace it.`,confirmLabel:"Replace",cancelLabel:"Keep existing",danger:!0,onConfirm:()=>{const z=S;C(null),z&&t({...z,overwrite:!0})},onCancel:()=>C(null)})]})}const B9=800,P9=Oe.theme({"&":{height:"100%",fontSize:"12.5px",color:"var(--app-text-primary)",backgroundColor:"var(--app-editor-bg)"},".cm-scroller":{fontFamily:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",lineHeight:"1.6"},".cm-content":{caretColor:"var(--color-indigo-500, #6366f1)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--color-indigo-500, #6366f1)"},"&.cm-focused":{outline:"none"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:"var(--app-editor-selection)"},".cm-activeLine":{backgroundColor:"var(--app-editor-active-line)"},".cm-matchingBracket":{color:"inherit",backgroundColor:"var(--app-editor-selection)",outline:"1px solid var(--app-editor-border)"},".cm-nonmatchingBracket":{color:"inherit",outline:"1px solid var(--status-danger-border, #fb7185)"},".cm-gutters":{backgroundColor:"var(--app-editor-gutter-bg)",color:"var(--app-text-faint)",border:"none",borderRight:"1px solid var(--app-editor-border)"},".cm-activeLineGutter":{backgroundColor:"var(--app-editor-active-line)",color:"var(--app-text-secondary)"},".cm-panels":{backgroundColor:"var(--app-editor-bg)",color:"var(--app-text-primary)"},".cm-tooltip":{border:"1px solid var(--app-border)",backgroundColor:"var(--app-glass-panel-strong)",color:"var(--app-text-primary)"}}),H9=Mu.define([{tag:me.lineComment,color:"var(--app-editor-syntax-comment)"},{tag:[me.propertyName,me.definition(me.propertyName)],color:"var(--app-editor-syntax-key)"},{tag:[me.string,me.special(me.string)],color:"var(--app-editor-syntax-string)"},{tag:me.content,color:"var(--app-editor-syntax-string)"},{tag:[me.keyword,me.typeName],color:"var(--app-editor-syntax-keyword)"},{tag:me.labelName,color:"var(--app-editor-syntax-label)"}]);function E0(n){return n.replace(/\r\n?/g,` -`)}function Ph(n,e){return n!==null&&n.state.doc.toString()!==e}function I9(n){return n instanceof $C&&Array.isArray(n.detail)?{text:n.message,issues:n.detail}:{text:n instanceof Error?n.message:String(n),issues:[]}}function U9({open:n,onClose:e,onApplied:t,onLoadConfig:i,reloadKey:l=0}){const[o,a]=D.useState({status:"loading"}),[u,f]=D.useState(!1),[d,m]=D.useState(!1),[g,b]=D.useState(null),[v,w]=D.useState([]),[S,C]=D.useState({kind:"unknown"}),[N,R]=D.useState(!1),[M,I]=D.useState({line:1,col:1}),[U,E]=D.useState(null),[T,z]=D.useState(null),[ie,q]=D.useState(null),J=D.useRef(null),F=D.useRef(null),se=D.useRef(null),he=D.useRef(""),ne=D.useRef(0),L=D.useRef(new Map),ee=D.useRef(null),oe=D.useRef(null),le=D.useRef(!1),A=D.useRef(()=>{}),Le=D.useRef(()=>{});le.current=T!==null||ie!==null;const _e=hs({isOpen:n,onClose:$,dialogRef:J});D.useEffect(()=>{if(!n){he.current="",se.current=null,a({status:"loading"}),f(!1),m(!1),b(null),w([]),C({kind:"unknown"}),R(!1),I({line:1,col:1}),E(null),z(null),q(null),ee.current!==null&&(clearTimeout(ee.current),ee.current=null),oe.current=null,ne.current+=1,L.current.clear();return}let V=!1;return zk().then(K=>{if(V)return;const de=E0(K.content);he.current=de,oe.current=de,a({status:"ready",data:{...K,content:de}})}).catch(K=>{V||(he.current="",a({status:"error",message:K instanceof Error?K.message:String(K)}))}),()=>{V=!0}},[n,l]);const B=D.useCallback(()=>{ee.current!==null&&(clearTimeout(ee.current),ee.current=null)},[]),j=D.useCallback(V=>{le.current||V!==oe.current&&(B(),ee.current=window.setTimeout(()=>{if(ee.current=null,L.current.has("test")){Le.current(V);return}A.current()},B9))},[B]);D.useEffect(()=>{if(!n||o.status!=="ready")return;const V=F.current;if(!V)return;const K=new Oe({doc:o.data.content,extensions:[FB,A9(),rT(H9),P9,Oe.updateListener.of(de=>{if(de.selectionSet||de.docChanged){const Se=de.state.selection.main.head,We=de.state.doc.lineAt(Se);I({line:We.number,col:Se-We.from+1})}de.docChanged&&(f(Ph(de.view,he.current)),b(null),w([]),C({kind:"unknown"}),R(!1),j(de.state.doc.toString()))})],parent:V});return se.current=K,()=>{K.destroy(),se.current=null,B()}},[n,o]);function $(){if(Ph(se.current,he.current)){m(!0);return}e()}const fe=D.useCallback(()=>{DM().catch(V=>{console.error("Failed to open config file in OS editor:",V)})},[]);function pe(){var V;return((V=se.current)==null?void 0:V.state.doc.toString())??he.current}const Ne=D.useCallback(async(V,K)=>{if(L.current.has(V))return;const de=++ne.current;L.current.set(V,de);try{await K(de)}finally{L.current.get(V)===de&&L.current.delete(V)}},[]),Te=D.useCallback(()=>Ne("new",async V=>{b(null),w([]);try{const K=await NM();if(V!==ne.current)return;const de=E0(K.content);he.current=de,f(!1),a(Se=>Se.status==="ready"?{status:"ready",data:{...Se.data,filename:K.filename,content:de,config_path:null}}:Se),b({kind:"ok",text:"New configuration template loaded."})}catch(K){if(V!==ne.current)return;b({kind:"error",text:K instanceof Error?K.message:String(K)})}}),[Ne]),ze=D.useCallback(()=>Ne("revert",async V=>{b(null),w([]);try{const K=await zk();if(V!==ne.current)return;const de=E0(K.content);he.current=de,f(!1),a({status:"ready",data:{...K,content:de}}),b({kind:"ok",text:"Configuration reloaded from disk."})}catch(K){if(V!==ne.current)return;b({kind:"error",text:K instanceof Error?K.message:String(K)})}}),[Ne]);function ve(){if(Ph(se.current,he.current)){E("new");return}Te()}function je(){if(Ph(se.current,he.current)){E("revert");return}ze()}const It=D.useCallback(()=>Ne("test",async V=>{if(o.status!=="ready")return;B();const K=pe();oe.current=K,C({kind:"validating"});try{const de=await Bk(o.data.filename,K);if(V!==ne.current)return;w(de.issues),de.valid?(C({kind:"valid"}),b({kind:"ok",text:"Configuration is valid."})):(C({kind:"invalid",count:de.issues.length}),R(!0),b({kind:"error",text:`Validation failed with ${de.issues.length} issue${de.issues.length===1?"":"s"}.`}))}catch(de){if(V!==ne.current)return;w([]),C({kind:"unknown"}),b({kind:"error",text:de instanceof Error?de.message:String(de)})}}),[o,Ne]);A.current=()=>void It(),Le.current=j;const Gt=D.useCallback(()=>Ne("apply",async V=>{if(o.status==="ready")try{const K=await YC(o.data.filename,pe());if(V!==ne.current)return;b({kind:"ok",text:"Configuration applied (session trial)."}),t==null||t(K)}catch(K){if(V!==ne.current)return;b({kind:"error",text:K instanceof Error?K.message:String(K)})}}),[o,t,Ne]),un=D.useCallback(V=>new Promise(K=>{z({issues:V,resolve:de=>{z(null),K(de)}})}),[]),_t=D.useCallback(()=>new Promise(V=>{q({resolve:K=>{q(null),V(K)}})}),[]),yt=D.useCallback((V,K)=>{if(he.current=K,f(!1),w([]),C({kind:"unknown"}),z(null),q(null),V.config_path){const de=V.config_path.split(/[\\/]/).pop()||V.title||"configuration";a(Se=>Se.status!=="ready"||!(Se.data.filename!==de||Se.data.config_path!==V.config_path||Se.data.session_trial)?Se:{status:"ready",data:{...Se.data,filename:de,config_path:V.config_path,session_trial:!1,content:K}})}t==null||t(V)},[t]),rt=D.useCallback(V=>{const K=I9(V);z(null),q(null),w(K.issues),K.issues.length>0?(C({kind:"invalid",count:K.issues.length}),R(!0)):C({kind:"unknown"}),b({kind:"error",text:K.text})},[]),Ut=D.useCallback((V,K)=>Ne(V,async de=>{if(o.status!=="ready")return;const Se=pe();b(null),w([]),C({kind:"validating"});try{const We=await Bk(K,Se);if(de!==ne.current)return;let ot=!1;if(We.valid)C({kind:"valid"});else{if(C({kind:"invalid",count:We.issues.length}),w(We.issues),R(!0),ot=await un(We.issues),de!==ne.current)return;if(!ot){b({kind:"error",text:"Save cancelled — fix the listed issues, or force-save anyway."});return}}if(V==="save-as"){const gt=await _t();if(de!==ne.current||gt===null)return;const qt=await AM({content:Se,filename:gt.filename,directory:gt.directory,force:ot,overwrite:gt.overwrite});if(de!==ne.current)return;yt(qt,Se),b({kind:"ok",text:`Configuration saved as ${gt.filename}.`})}else{const gt=await TM(Se,ot);if(de!==ne.current)return;yt(gt,Se),b({kind:"ok",text:`Configuration saved to ${K}.`})}}catch(We){if(de!==ne.current)return;rt(We)}}),[un,_t,o,yt,rt,Ne]),zn=D.useCallback(()=>Ut("save",o.status==="ready"?o.data.filename:""),[o,Ut]),Ft=D.useCallback(()=>Ut("save-as",o.status==="ready"?o.data.filename:""),[o,Ut]),en=D.useRef(()=>{});if(en.current=()=>{o.status==="ready"&&(T!==null||ie!==null||d||U!==null||(o.data.config_path!==null?zn():Gt()))},D.useEffect(()=>{if(!n)return;const V=K=>{(K.metaKey||K.ctrlKey)&&!K.altKey&&!K.shiftKey&&K.key.toLowerCase()==="s"&&(K.preventDefault(),K.stopPropagation(),en.current())};return window.addEventListener("keydown",V,!0),()=>window.removeEventListener("keydown",V,!0)},[n]),!n)return null;const ke=o.status==="ready"?o.data.filename:"",qe=o.status==="ready"?o.data.session_trial:!1,Ie=o.status!=="ready",at=o.status==="ready"&&o.data.config_path!==null;return y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:J,role:"dialog","aria-modal":"true","aria-labelledby":"config-editor-title",onKeyDown:_e,onClick:$,className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",children:y.jsxs("div",{className:"animate-modal-in flex h-[90vh] w-full max-w-6xl flex-col overflow-hidden rounded-xl border border-frame-line glass-panel",onClick:V=>V.stopPropagation(),children:[y.jsxs("div",{"data-testid":"editor-header",className:"flex shrink-0 items-center justify-between gap-3 border-b border-line px-5 py-3",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-chip-indigo-bg text-chip-indigo-text",children:y.jsx(j4,{className:"h-4 w-4"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"config-editor-title",className:"text-sm font-semibold text-ink",children:"Configuration Editor"}),y.jsxs("p",{className:"truncate text-xs text-ink-muted",children:[ke||"…",qe?" • session trial (not anchored to disk)":""]})]})]}),y.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[y.jsxs("button",{type:"button",onClick:ve,disabled:Ie,title:"Load the starter configuration template",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(z4,{className:"h-3.5 w-3.5"}),"New"]}),y.jsxs("button",{type:"button",onClick:()=>void It(),disabled:Ie,title:"Validate the editor content in memory",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(I4,{className:"h-3.5 w-3.5"}),"Test"]}),y.jsxs("button",{type:"button",onClick:je,disabled:Ie,title:"Discard edits and reload the file from disk",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(hD,{className:"h-3.5 w-3.5"}),"Revert"]}),at&&y.jsxs("button",{type:"button",onClick:()=>void zn(),disabled:Ie,title:"Save to the configuration file on disk (Ctrl/Cmd+S)",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(iO,{className:"h-3.5 w-3.5"}),"Save"]}),y.jsxs("button",{type:"button",onClick:()=>void Ft(),disabled:Ie,title:"Save the configuration to a new file — also anchors a session trial onto disk",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(mD,{className:"h-3.5 w-3.5"}),"Save As"]}),y.jsxs("button",{type:"button",onClick:()=>void Gt(),disabled:Ie,title:"Trial the editor content as the session configuration",className:"btn btn-primary px-2.5 py-1.5 font-semibold",children:[y.jsx(ts,{className:"h-3.5 w-3.5"}),"Apply"]}),i&&y.jsxs("button",{type:"button",onClick:i,title:"Load a different .profiles file",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(sa,{className:"h-3.5 w-3.5"}),"Load config file…"]}),at&&y.jsxs("button",{type:"button",onClick:fe,title:"Open the configuration file with the OS default editor",className:"btn inline-flex items-center gap-1.5 rounded-md border border-line bg-surface px-2.5 py-1.5 text-xs font-medium text-ink-secondary hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:[y.jsx(tO,{className:"h-3.5 w-3.5"}),"Open in OS"]}),y.jsx("button",{type:"button",onClick:$,"aria-label":"Close editor",className:"rounded-md p-1.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:y.jsx(Ei,{className:"h-4 w-4"})})]})]}),y.jsxs("div",{className:"flex min-h-0 flex-1 gap-2 p-3 sm:p-4",children:[y.jsx("div",{"data-testid":"editor-card",className:"min-w-0 flex-1 overflow-hidden rounded-lg border border-[var(--app-editor-border)] bg-[var(--app-editor-bg)]",children:o.status==="loading"?y.jsx("div",{className:"flex h-full items-center justify-center",children:y.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent"})}):o.status==="error"?y.jsx("div",{className:"flex h-full items-center justify-center p-6",children:y.jsx("div",{className:"max-w-md rounded-md border border-status-danger-border bg-status-danger-bg p-4 text-center text-xs text-status-danger-text",children:o.message})}):y.jsx("div",{ref:F,className:"h-full"})}),o.status==="ready"&&N&&y.jsxs("aside",{"data-testid":"problems-panel","aria-live":"polite",className:"flex w-[280px] shrink-0 flex-col overflow-hidden rounded-lg border border-line bg-surface",children:[y.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-line px-3 py-1.5",children:[y.jsx("span",{className:"text-xs font-semibold text-ink-secondary",children:"Problems"}),y.jsx("button",{type:"button",onClick:()=>R(!1),"aria-label":"Close problems",className:"rounded-md p-1 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:y.jsx(Ei,{className:"h-3.5 w-3.5"})})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:v.length===0?y.jsx("p",{className:"px-2 py-1 text-xs text-ink-faint",children:"No problems detected."}):y.jsx("ul",{"data-testid":"editor-issues",className:"space-y-1",children:v.map((V,K)=>y.jsxs("li",{tabIndex:0,className:`flex items-start gap-2 rounded-md border px-2.5 py-1.5 text-xs ${V.severity==="error"?"border-status-danger-border bg-status-danger-bg text-status-danger-text":V.severity==="warning"?"border-chip-amber-border bg-chip-amber-bg text-chip-amber-text":"border-line bg-surface text-ink-secondary"}`,children:[V.severity==="error"?y.jsx(ou,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}):V.severity==="warning"?y.jsx(yy,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}):y.jsx(gy,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),y.jsx("span",{className:"min-w-0",children:V.message})]},`${V.severity}-${K}`))})})]})]}),o.status==="ready"&&y.jsxs("footer",{"data-testid":"editor-footer",className:"flex shrink-0 items-center justify-between gap-3 border-t border-line px-5 py-1.5 text-xs",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[y.jsxs("button",{type:"button","data-testid":"validity-chip",onClick:()=>R(V=>!V),title:"Toggle the problems panel","aria-pressed":N,className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-bold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 ${S.kind==="valid"?"border-status-success-border bg-status-success-bg text-status-success-text":S.kind==="invalid"?"border-status-danger-border bg-status-danger-bg text-status-danger-text":"border-line bg-surface text-ink-muted"}`,children:[S.kind==="valid"?y.jsx(_r,{className:"h-3 w-3"}):S.kind==="invalid"?y.jsx(ou,{className:"h-3 w-3"}):S.kind==="validating"?y.jsx(ll,{className:"h-3 w-3 animate-spin"}):y.jsx(d4,{className:"h-3 w-3"}),S.kind==="valid"?"Valid":S.kind==="invalid"?`${S.count} issue${S.count===1?"":"s"}`:S.kind==="validating"?"Validating…":"Not validated"]}),u&&y.jsxs("span",{role:"status",className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-chip-amber-border bg-chip-amber-bg px-2 py-0.5 text-[10px] font-bold text-chip-amber-text",children:[y.jsx(p4,{className:"h-3 w-3"}),"Unsaved changes"]}),g!==null&&y.jsx("div",{"data-testid":"editor-status","aria-live":"polite",className:`min-w-0 truncate rounded-md border px-2 py-0.5 font-medium ${g.kind==="ok"?"border-status-success-border bg-status-success-bg text-status-success-text":"border-status-danger-border bg-status-danger-bg text-status-danger-text"}`,children:g.text})]}),y.jsxs("div",{className:"flex shrink-0 items-center gap-3 text-ink-muted",children:[y.jsxs("span",{className:"font-mono",children:["Ln ",M.line,", Col ",M.col]}),y.jsx("span",{className:"text-ink-faint",children:"YAML"}),y.jsx("span",{className:"max-w-[220px] truncate font-mono",children:ke})]})]})]})}),y.jsx(va,{isOpen:d,title:"Discard changes?",message:`The editor contains unsaved changes. -Closing now will discard them.`,confirmLabel:"Discard",cancelLabel:"Keep editing",danger:!0,onConfirm:()=>{m(!1),e()},onCancel:()=>m(!1)}),y.jsx(va,{isOpen:U!==null,title:"Replace current edits?",message:U==="revert"?`The editor contains unsaved changes. -Reverting will discard them and reload the file from disk.`:`The editor contains unsaved changes. -Loading the starter template will discard them.`,confirmLabel:"Replace",cancelLabel:"Keep editing",danger:!0,onConfirm:()=>{const V=U;E(null),V==="new"?Te():V==="revert"&&ze()},onCancel:()=>E(null)}),y.jsx(va,{isOpen:T!==null,title:"Save with validation issues?",danger:!0,message:y.jsxs(y.Fragment,{children:[y.jsx("p",{children:"Saving will write these issues to disk; the file may fail to load until they are fixed."}),y.jsx("ul",{className:"mt-2 space-y-1",children:T==null?void 0:T.issues.map((V,K)=>y.jsx("li",{className:`rounded-md border px-3 py-1.5 text-xs ${V.severity==="error"?"border-status-danger-border bg-status-danger-bg text-status-danger-text":"border-chip-amber-border bg-chip-amber-bg text-chip-amber-text"}`,children:V.message},`${V.severity}-${K}`))})]}),confirmLabel:"Force save anyway",cancelLabel:"Go back and fix",onConfirm:()=>T==null?void 0:T.resolve(!0),onCancel:()=>T==null?void 0:T.resolve(!1)}),y.jsx(z9,{open:ie!==null,onCancel:()=>ie==null?void 0:ie.resolve(null),onConfirm:V=>ie==null?void 0:ie.resolve(V)})]})}function F9({position:n,onClose:e,onLaunch:t,onLaunchWithArgs:i,onReveal:l,onOpenFolder:o,onOpenTerminal:a,onScanDirectory:u,onFilterFolder:f,onFilterExtension:d,onCopyPath:m,onCopyFilename:g,onCopyUri:b,onComputeHash:v,onVerifyHash:w,onProperties:S,onClearFile:C,onGenerateBarcode:N,showToast:R}){const[M,I]=D.useState(!1),[U,E]=D.useState(""),T=D.useRef(null),z=D.useRef(null),ie=D.useRef(null),[q,J]=D.useState(null);if(D.useEffect(()=>{var le;M&&((le=z.current)==null||le.showModal())},[M]),D.useLayoutEffect(()=>{if(!n){J(null);return}const le=()=>{const A=T.current;if(!A)return;const Le=A.getBoundingClientRect(),_e=8;J({left:Math.max(_e,Math.min(n.x,window.innerWidth-Le.width-_e)),top:Math.max(_e,Math.min(n.y,window.innerHeight-Le.height-_e))})};return le(),window.addEventListener("resize",le),()=>window.removeEventListener("resize",le)},[n]),D.useEffect(()=>{if(!n)return;ie.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const le=window.requestAnimationFrame(()=>{var A,Le;(Le=(A=T.current)==null?void 0:A.querySelector("[role='menuitem']"))==null||Le.focus()});return()=>{var A;window.cancelAnimationFrame(le),(A=ie.current)==null||A.focus()}},[n]),!n)return null;const{file:F,x:se,y:he}=n,ne=()=>{i(F,U),I(!1),e()},L=le=>{const A=le.lastIndexOf(".");return A!==-1?le.slice(A):""},ee=le=>{const A=Math.max(le.lastIndexOf("/"),le.lastIndexOf("\\"));return A!==-1?le.slice(0,A):le},oe=le=>{const A=Math.max(le.lastIndexOf("/"),le.lastIndexOf("\\"));return A!==-1?le.slice(0,A):""};return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"fixed inset-0 z-[calc(var(--z-context-menu)-1)]",onClick:e,onContextMenu:le=>{le.preventDefault(),e()},"aria-hidden":"true"}),y.jsxs("div",{ref:T,role:"menu","aria-label":`Actions for ${F.filename}`,tabIndex:0,onKeyDown:le=>{var _e,B,j,$;["Escape","ArrowDown","ArrowUp","Home","End"].includes(le.key)&&le.stopPropagation();const A=Array.from(((_e=T.current)==null?void 0:_e.querySelectorAll("[role='menuitem']"))??[]),Le=A.indexOf(document.activeElement);if(le.key==="Escape")le.preventDefault(),e();else if(le.key==="ArrowDown"||le.key==="ArrowUp"){le.preventDefault();const fe=le.key==="ArrowDown"?1:-1;(B=A[(Le+fe+A.length)%A.length])==null||B.focus()}else le.key==="Home"?(le.preventDefault(),(j=A[0])==null||j.focus()):le.key==="End"&&(le.preventDefault(),($=A.at(-1))==null||$.focus())},className:"animate-modal-in fixed z-[var(--z-context-menu)] max-h-[calc(100dvh-16px)] w-56 max-w-[calc(100vw-16px)] overflow-y-auto rounded-lg border border-line bg-surface-glass py-1 text-xs text-ink shadow-2xl backdrop-blur-md",style:q??{left:se,top:he,visibility:"hidden"},children:[y.jsx("div",{className:"border-b border-line px-3 py-2 font-medium text-ink-muted truncate",children:F.filename}),y.jsxs("button",{role:"menuitem",onClick:()=>{t(F),e()},className:"flex w-full items-center gap-2 px-3 py-3 min-h-[44px] hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Launch ${F.filename}`,children:[y.jsx(ts,{className:"h-3.5 w-3.5 fill-current text-status-success-text group-hover:text-white"}),y.jsx("span",{children:"Launch"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{I(!0)},className:"flex w-full items-center gap-2 px-3 py-3 min-h-[44px] hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Launch ${F.filename} with arguments`,children:[y.jsx(ts,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Launch with arguments..."})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{l(F),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Reveal ${F.filename} in file manager`,children:[y.jsx(G0,{className:"h-3.5 w-3.5 text-chip-sky-text group-hover:text-white"}),y.jsx("span",{children:"Reveal in File Manager"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{o(F),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Open folder containing ${F.filename}`,children:[y.jsx(Jl,{className:"h-3.5 w-3.5 text-chip-amber-text group-hover:text-white"}),y.jsx("span",{children:"Open Folder"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{a(F),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Open terminal in directory containing ${F.filename}`,children:[y.jsx(W0,{className:"h-3.5 w-3.5 text-status-success-text group-hover:text-white"}),y.jsx("span",{children:"Open Terminal in Directory"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{N(F),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":"Generate QR Code",children:[y.jsx(xy,{className:"h-3.5 w-3.5 text-chip-fuchsia-text group-hover:text-white"}),y.jsx("span",{children:"Generate QR Code"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{const le=ee(F.path);u(le),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":"Scan to Directory",children:[y.jsx(Jl,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Scan to Directory"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{const le=oe(F.rel_path);le&&f(le),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Filter view to folder ${F.filename} is in`,children:[y.jsx(K0,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Filter to Folder"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{const le=L(F.filename);le&&d(le),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Filter view by extension ${L(F.filename)}`,children:[y.jsx(K0,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Filter by Extension"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{m(F,!1),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy full path of ${F.filename}`,children:[y.jsx(ci,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Full Path"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{m(F,!0),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy path of ${F.filename} with forward slashes`,children:[y.jsx(ci,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Path (Forward Slashes)"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{g(F,!1),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy filename of ${F.filename}`,children:[y.jsx(ci,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Filename"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{g(F,!0),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy filename of ${F.filename} without extension`,children:[y.jsx(ci,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Filename (no ext)"})]}),y.jsxs("button",{role:"menuitem",onClick:async()=>{const le=ee(F.path);e();try{await navigator.clipboard.writeText(le),R==null||R(`Copied: ${le}`)}catch(A){R==null||R(`Copy failed: ${(A==null?void 0:A.message)??A}`,"error")}},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":"Copy Directory",children:[y.jsx(ci,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Directory"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{b(F),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy URI of ${F.filename}`,children:[y.jsx(ci,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy URI"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{v(F,"md5"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Compute MD5 hash of ${F.filename}`,children:[y.jsx(oa,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Compute MD5 Hash"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{v(F,"sha256"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Compute SHA256 hash of ${F.filename}`,children:[y.jsx(oa,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Compute SHA256 Hash"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{w(F,"md5"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Verify MD5 hash of ${F.filename}`,children:[y.jsx(oa,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Verify MD5 Hash"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{w(F,"sha256"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Verify SHA256 hash of ${F.filename}`,children:[y.jsx(oa,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Verify SHA256 Hash"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{S(F),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`View properties of ${F.filename}`,children:[y.jsx(G0,{className:"h-3.5 w-3.5 text-chip-sky-text group-hover:text-white"}),y.jsx("span",{children:"Properties"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{C(F),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Remove ${F.filename} from list`,children:[y.jsx(sO,{className:"h-3.5 w-3.5 text-status-danger-text group-hover:text-white"}),y.jsx("span",{children:"Delete"})]})]}),M&&y.jsx("dialog",{ref:z,className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 rounded-xl","aria-labelledby":"args-modal-title",onClick:le=>{le.target===z.current&&I(!1)},onCancel:le=>{le.preventDefault(),I(!1)},children:y.jsxs("div",{className:"animate-modal-in w-96 rounded-xl border border-frame-line glass-panel p-4",children:[y.jsx("h3",{id:"args-modal-title",className:"mb-2 text-sm font-semibold text-ink",children:"Launch with Arguments"}),y.jsx("p",{className:"mb-3 text-xs text-ink-muted truncate",children:F.filename}),y.jsx("input",{type:"text",autoFocus:!0,placeholder:"Arguments (e.g. --verbose --port 80)",value:U,onChange:le=>E(le.target.value),onKeyDown:le=>{le.key==="Enter"&&ne(),le.key==="Escape"&&I(!1)},className:"mb-4 w-full rounded-md border border-line bg-elevated px-3 py-2 text-xs text-ink outline-none focus:border-indigo-500 focus:ring-2 focus:ring-indigo-500","aria-label":"Command line arguments"}),y.jsxs("div",{className:"flex justify-end gap-2",children:[y.jsx("button",{onClick:()=>I(!1),className:"rounded-md px-3 py-1.5 text-xs text-ink-muted hover:bg-elevated hover:text-ink focus:outline-none focus:ring-2 focus:ring-indigo-500","aria-label":"Cancel launch",children:"Cancel"}),y.jsx("button",{onClick:ne,className:"btn btn-primary px-3 py-1.5","aria-label":`Launch ${F.filename} with arguments`,children:"Launch"})]})]})})]})}function q9({isOpen:n,initialPath:e,onClose:t,onSelect:i}){const[l,o]=D.useState(null),[a,u]=D.useState(null),[f,d]=D.useState(""),[m,g]=D.useState(!1),[b,v]=D.useState(null),w=D.useRef(null),S=D.useRef(null),C=D.useRef(null);D.useEffect(()=>{var U;if(!n){(U=C.current)==null||U.focus();return}C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,v(null),N(e||"");const I=requestAnimationFrame(()=>{var E;return(E=S.current)==null?void 0:E.focus()});return()=>{var E;cancelAnimationFrame(I),(E=C.current)==null||E.focus()}},[n]);const N=async I=>{g(!0),v(null);try{const U=await fetch(`/api/fs/browse?path=${encodeURIComponent(I)}`);if(!U.ok)throw new Error("Failed to browse directory");const E=await U.json();o(E),u(E.current_path),d(E.current_path)}catch(U){v(U.message||"Navigation failed")}finally{g(!1)}},R=()=>{const I=f.trim()||a;I&&(i(I),t())},M=I=>{var z;if(I.key==="Escape"){I.preventDefault(),t();return}if(I.key!=="Tab")return;const U=(z=w.current)==null?void 0:z.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(U!=null&&U.length))return;const E=U[0],T=U[U.length-1];I.shiftKey&&document.activeElement===E?(I.preventDefault(),T.focus()):!I.shiftKey&&document.activeElement===T&&(I.preventDefault(),E.focus())};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",onClick:t,children:y.jsxs("div",{ref:w,role:"dialog","aria-modal":"true","aria-labelledby":"directory-picker-title",onKeyDown:M,className:"animate-modal-in flex h-[min(84dvh,760px)] max-h-[calc(100dvh-1.5rem)] w-[min(94vw,960px)] min-h-0 flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",onClick:I=>I.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-line px-4 py-3 sm:px-5",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(Jl,{className:"h-5 w-5 text-chip-indigo-text"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"directory-picker-title",className:"text-sm font-semibold text-ink",children:"Select a directory"}),y.jsx("p",{className:"truncate font-mono text-xs text-ink-muted",children:(l==null?void 0:l.current_path)||""})]})]}),y.jsx(Qe,{text:"Close",block:!1,children:y.jsx("button",{type:"button",onClick:t,"aria-label":"Close directory picker",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg text-ink-muted transition-colors hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Ei,{className:"h-4 w-4"})})})]}),y.jsxs("div",{className:"border-b border-line px-4 py-3 sm:px-5",children:[y.jsx("label",{htmlFor:"directory-picker-path",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"Location"}),y.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[y.jsx("input",{ref:S,id:"directory-picker-path",type:"text",value:f,onChange:I=>d(I.target.value),onKeyDown:I=>{I.key==="Enter"&&N(f.trim())},placeholder:"/path/to/directory",className:"h-10 min-w-0 flex-1 rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),y.jsx("button",{type:"button",onClick:()=>N(f.trim()),className:"inline-flex h-10 shrink-0 items-center gap-1.5 rounded-lg border border-line bg-elevated px-3.5 text-sm font-medium text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Go"}),y.jsx(Qe,{text:"Home directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>N(""),"aria-label":"Home directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx($d,{className:"h-4 w-4"})})}),(l==null?void 0:l.parent_path)&&y.jsx(Qe,{text:"Parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>N(l.parent_path),"aria-label":"Parent directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Xd,{className:"h-4 w-4 rotate-180"})})})]})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2 sm:px-3 sm:py-3","aria-busy":m,children:m?y.jsxs("div",{className:"flex h-full items-center justify-center gap-2.5 text-sm text-ink-muted",children:[y.jsx(ll,{className:"h-5 w-5 animate-spin text-chip-indigo-text"}),y.jsx("span",{role:"status",children:"Loading directories…"})]}):b?y.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2.5 text-center",children:[y.jsx("p",{className:"text-sm text-status-danger-text",children:b}),y.jsx("button",{type:"button",onClick:()=>N(f||(l==null?void 0:l.current_path)||""),className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Retry"})]}):y.jsxs("ul",{className:"space-y-0.5",children:[l==null?void 0:l.items.filter(I=>I.is_dir).map(I=>y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>N(I.path),onDoubleClick:()=>{d(I.path),i(I.path),t()},className:`flex min-h-10 w-full items-center justify-between rounded-lg px-3 py-1.5 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400 ${a===I.path?"bg-chip-indigo-bg text-chip-indigo-text":"text-ink-secondary hover:bg-elevated hover:text-ink"}`,children:[y.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx(Ou,{className:"h-5 w-5 shrink-0 text-chip-indigo-text"}),y.jsx("span",{className:"truncate",children:I.name})]}),a===I.path&&y.jsx(_r,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"})]})},I.path)),(l==null?void 0:l.items.filter(I=>I.is_dir).length)===0&&y.jsxs("li",{className:"flex h-full min-h-36 flex-col items-center justify-center gap-2.5 text-center text-sm text-ink-muted",children:[y.jsx(Jl,{className:"h-7 w-7 text-ink-faint"}),"No subdirectories found"]})]})}),y.jsxs("div",{className:"flex flex-col gap-2 border-t border-line px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:px-5",children:[y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("p",{className:"mb-0.5 text-xs font-medium text-ink-muted",children:"Selected folder"}),y.jsx("p",{className:"truncate font-mono text-sm text-ink",title:a||f,children:a||f||"—"})]}),y.jsxs("div",{className:"flex shrink-0 justify-end gap-1.5",children:[y.jsx("button",{type:"button",onClick:t,className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Cancel"}),y.jsxs("button",{type:"button",onClick:R,disabled:!f.trim(),className:"btn btn-primary min-h-10 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(Jl,{className:"h-4 w-4"}),"Select folder"]})]})]})]})}):null}function V9({visible:n,onFileSelected:e}){const t=D.useRef(null);return n?y.jsxs("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-drop-overlay)] flex items-center justify-center bg-black/65 backdrop-blur-sm",onClick:()=>{var i;return(i=t.current)==null?void 0:i.click()},"data-testid":"drop-config-overlay",children:[y.jsx("input",{ref:t,type:"file",accept:".profiles,.profiles.yaml,.profiles.yml,.yaml,.yml",className:"hidden",onChange:i=>{var o;const l=(o=i.target.files)==null?void 0:o[0];l&&e(l),i.target.value=""}}),y.jsxs("div",{className:"rounded-xl border-2 border-dashed border-chip-indigo-border bg-surface px-8 py-6 text-center shadow-2xl",children:[y.jsx("span",{className:"mx-auto mb-3 grid h-9 w-9 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(sa,{className:"h-5 w-5 text-chip-indigo-text"})}),y.jsx("p",{className:"text-sm font-semibold text-ink",children:"Drop configuration file"}),y.jsx("p",{className:"mt-1 text-xs text-ink-muted",children:".profiles, .profiles.yaml, .yml, .yaml — session-only preview"})]})]}):null}function Q9({items:n,columnTemplate:e,resizePointerRef:t,resizeMovedRef:i}){return y.jsx("div",{className:"grid select-none items-center border-b border-l-2 border-l-transparent border-line/40 bg-surface/60 font-medium text-ink-muted shadow-sm backdrop-blur-md",role:"row","aria-rowindex":1,"data-file-list-header":!0,style:{gridTemplateColumns:e},children:n.map((l,o)=>{const a=!!(l.onSort&&l.sortKey),u=l.active?l.direction==="asc"?"ascending":"descending":"none";return y.jsxs("div",{role:"columnheader","data-column-key":l.sortKey,className:`group relative flex items-center gap-1.5 truncate px-3 py-2 ${a?"cursor-pointer hover:text-ink transition-colors":""} ${l.active?"text-ink":""}`,...a?{"aria-sort":u,tabIndex:0,onClick:l.onSort,onKeyDown:f=>{var d;(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),(d=l.onSort)==null||d.call(l))}}:{},children:[l.icon,y.jsx("span",{className:"truncate",children:l.label}),a?l.active?l.direction==="asc"?y.jsx(e4,{className:"ml-auto h-3 w-3 shrink-0 text-chip-indigo-text"}):y.jsx(ZC,{className:"ml-auto h-3 w-3 shrink-0 text-chip-indigo-text"}):y.jsx(Vk,{className:"ml-auto h-3 w-3 shrink-0 opacity-0 transition-opacity group-hover:opacity-40 hover:opacity-40"}):o>0&&y.jsx(Vk,{className:"ml-auto h-3 w-3 shrink-0 opacity-40"}),l.canResize&&l.onResizeBy&&y.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${l.label} column`,"aria-valuemin":ha,"aria-valuemax":Id,"aria-valuenow":l.width??l.defaultWidth??od,"aria-valuetext":`${l.width??l.defaultWidth??od} pixels wide`,title:"Drag to resize; use arrow keys or click either side to adjust",tabIndex:0,onClick:f=>{var g;f.preventDefault(),f.stopPropagation();const d=i.current;if(i.current=!1,d)return;const m=f.currentTarget.getBoundingClientRect();(g=l.onResizeBy)==null||g.call(l,f.clientX{f.preventDefault(),f.stopPropagation();const d=f.currentTarget.parentElement;i.current=!1,t.current={pointerId:f.pointerId,startX:f.clientX,startWidth:l.width??(d==null?void 0:d.getBoundingClientRect().width)??l.defaultWidth??od,resizeTo:l.onResizeTo},f.currentTarget.setPointerCapture(f.pointerId)},onPointerMove:f=>{const d=t.current;if(!d||d.pointerId!==f.pointerId)return;const m=f.clientX-d.startX;Math.abs(m)>2&&(i.current=!0),d.resizeTo(d.startWidth+m)},onPointerUp:f=>{var d;((d=t.current)==null?void 0:d.pointerId)===f.pointerId&&(f.currentTarget.releasePointerCapture(f.pointerId),t.current=null,window.setTimeout(()=>{i.current=!1},0))},onPointerCancel:()=>{t.current=null,i.current=!1},onKeyDown:f=>{var d,m;f.stopPropagation(),f.key==="ArrowLeft"||f.key==="ArrowRight"?(f.preventDefault(),(d=l.onResizeBy)==null||d.call(l,f.key==="ArrowLeft"?-Ih:Ih)):(f.key==="Home"||f.key==="End")&&(f.preventDefault(),(m=l.onResizeTo)==null||m.call(l,f.key==="Home"?ha:Id))},className:"absolute inset-y-0 right-0 z-10 w-3 cursor-col-resize touch-none border-r border-transparent transition-colors hover:border-indigo-400 focus-visible:border-indigo-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500"})]},o)})})}const Zi=28,Hh=12,M0=500,ha=80,Id=960,od=160,Ih=24,U2=44,Uh={File:2,Path:3,FileName:1,Type:1,Version:1};function X9({files:n,totalCount:e,rawLoadedCount:t,onLoadMore:i,loadingMore:l=!1,scanning:o=!1,hasScanned:a=!1,activeDirectory:u="",recursive:f=!1,onDisableRecursive:d,onOpenDirectory:m,onLoadConfig:g,filterText:b,onClearFilter:v,prefilterNote:w,columnHeaders:S,columnNames:C,selectedIndex:N,onSelectIndex:R,onLaunch:M,onContextMenu:I,rowColors:U,sort:E,onSortChange:T}){const z=["File"],ie=C.length>0?C:z,q=S.length>0?S:ie,J=Array.from({length:Math.max(ie.length,q.length)},(ke,qe)=>({key:ie[qe]??z[0],header:q[qe]??ie[qe]??z[0]})),F=D.useRef(null),[se,he]=D.useState(0),[ne,L]=D.useState(600),[ee,oe]=D.useState(0),[le,A]=D.useState({}),Le=D.useRef(null),_e=D.useRef(!1),B=ie.reduce((ke,qe)=>ke+(Uh[qe]??1),1),j=(ke,qe)=>{const Ie=Math.min(Id,Math.max(ha,Math.round(qe)));A(at=>({...at,[ke]:Ie}))},$=(ke,qe)=>{var V;const Ie=Array.from(((V=F.current)==null?void 0:V.querySelectorAll("[data-column-key]"))??[]).find(K=>K.dataset.columnKey===ke),at=le[ke]??(Ie==null?void 0:Ie.getBoundingClientRect().width)??od;j(ke,at+qe)},fe=[`${U2}px`,...ie.map(ke=>le[ke]?`${le[ke]}px`:`minmax(${ha}px, ${Uh[ke]??1}fr)`)].join(" "),pe=D.useRef(!1),Ne=D.useRef(null),Te=n.length,ze=t??Te,ve=e??ze,je=ze{const ke=F.current;if(!ke)return;const qe=new ResizeObserver(Ie=>{for(const at of Ie)L(at.contentRect.height),oe(at.contentRect.width)});return qe.observe(ke),L(ke.clientHeight||600),oe(ke.clientWidth||0),()=>qe.disconnect()},[]),D.useEffect(()=>{var K;const ke=F.current;if(!ke||N<0||N>=Te)return;const qe=((K=ke.querySelector("[data-file-list-header]"))==null?void 0:K.offsetHeight)??0,Ie=qe+N*Zi,at=Ie+Zi;let V=ke.scrollTop;Ieke.scrollTop+ke.clientHeight&&(V=at-ke.clientHeight),V!==ke.scrollTop&&(ke.scrollTop=V,he(V))},[N,Te]),D.useEffect(()=>{const ke=F.current;if(!ke)return;const qe=()=>{if(pe.current||!Gt||!i)return;const Ie=ke.scrollTop+ke.clientHeight,at=Te*Zi;at-IeIe&&(pe.current=!0,window.setTimeout(()=>{pe.current=!1},200),i())};return ke.addEventListener("scroll",qe,{passive:!0}),window.addEventListener("scroll",qe,{passive:!0}),()=>{ke.removeEventListener("scroll",qe),window.removeEventListener("scroll",qe)}},[n,Gt,i,Te]),D.useEffect(()=>{if(pe.current||!Gt||!i)return;const ke=Te*Zi,qe=se+ne;if(!(ke-qeqe))return;const at=`${Te}:${ze}:${ve}`;Ne.current=at,i()});const un=D.useCallback(ke=>{he(ke.currentTarget.scrollTop)},[]),_t=Math.max(0,Math.floor(se/Zi)-Hh),yt=Math.ceil(ne/Zi)+Hh*2,rt=Math.min(Te,_t+yt),Ut=_t*Zi,zn=(ke,qe)=>{if(qe)return{className:"bg-chip-indigo-bg border-l-4 border-chip-indigo-border text-ink",style:{}};for(const[Ie,at]of U)if(ke.toLowerCase().includes(Ie.toLowerCase()))return{className:"hover:bg-elevated border-l-4 text-ink",style:{borderLeftColor:at,borderLeftWidth:"4px"}};return{className:"border-l-4 border-transparent text-ink-secondary hover:bg-elevated/60",style:{borderLeftColor:"transparent",borderLeftWidth:"4px"}}},Ft=(Gt?Te+yt:Te)*Zi,en="btn btn-secondary px-3 py-1.5";return y.jsxs("div",{ref:F,onScroll:un,className:"flex-1 overflow-auto bg-app text-xs transition-colors duration-200 focus-visible:outline focus-visible:outline-2 focus-visible:outline-indigo-500 focus-visible:outline-offset-[-2px]","data-testid":"file-list","data-loaded-count":ze,"aria-busy":o,role:"grid","aria-label":"Discovered files","aria-rowcount":Math.max(ve,Te===0?1:0)+1,"aria-colcount":ie.length+1,"aria-activedescendant":Te>0?`file-row-${N}`:void 0,tabIndex:0,children:[y.jsx("div",{className:"sticky top-0 z-10",role:"presentation",children:y.jsx(Q9,{columnTemplate:fe,resizePointerRef:Le,resizeMovedRef:_e,items:[{label:"#",icon:y.jsx(K0,{className:"h-3.5 w-3.5"})},...J.map(({key:ke,header:qe})=>({label:qe,weight:Uh[ke]??1,width:le[ke],defaultWidth:Math.min(Id,Math.max(ha,Math.round((ee-U2)*(Uh[ke]??1)/B))),canResize:!0,onResizeBy:Ie=>$(ke,Ie),onResizeTo:Ie=>j(ke,Ie),sortKey:ke,active:(E==null?void 0:E.column)===ke,direction:E==null?void 0:E.direction,onSort:()=>{(E==null?void 0:E.column)!==ke?T({column:ke,direction:"asc"}):E.direction==="asc"?T({column:ke,direction:"desc"}):T(null)}}))]})}),w&&Te>0&&y.jsxs("div",{role:"note","data-testid":"prefilter-note",className:"flex items-center gap-1.5 border-b border-line/40 bg-surface px-3 py-1 text-[11px] text-ink-faint",children:[y.jsx(gy,{className:"h-3 w-3 shrink-0 text-ink-faint","aria-hidden":"true"}),y.jsx("span",{className:"min-w-0 truncate",children:w})]}),Te===0?y.jsx("div",{role:"row","aria-rowindex":2,"data-testid":"file-list-empty",children:y.jsx("div",{role:"gridcell","aria-colspan":ie.length+1,className:"p-8 text-center text-ink-faint",children:o?y.jsxs("div",{className:"flex flex-col items-center gap-2",children:[y.jsx(ll,{className:"h-5 w-5 animate-spin text-chip-indigo-text motion-reduce:animate-none"}),y.jsx("span",{children:"Scanning files..."})]}):!u.trim()&&g?y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsx("span",{children:"Select a directory first."}),y.jsx("button",{type:"button",onClick:g,className:en,children:"Choose configuration"})]}):a?b.trim()?y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsxs("span",{children:["No files match “",b,"”."]}),y.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[y.jsx("button",{type:"button",onClick:v,className:en,children:"Clear filter"}),f&&d&&y.jsx("button",{type:"button",onClick:d,className:en,children:"Turn off recursive"}),m&&y.jsx("button",{type:"button",onClick:m,className:en,children:"Open directory"})]})]}):y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsx("span",{children:"No files found for the current directory and extension."}),y.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[f&&d&&y.jsx("button",{type:"button",onClick:d,className:en,children:"Turn off recursive"}),m&&y.jsx("button",{type:"button",onClick:m,className:en,children:"Open directory"})]})]}):y.jsx("span",{children:"Select a directory and scan to find files."})})}):y.jsxs("div",{className:"relative",style:{height:Ft},role:"rowgroup",children:[l&&y.jsx("div",{className:"pointer-events-none absolute left-1/2 top-2 z-20 -translate-x-1/2","aria-hidden":"true",children:y.jsx(ll,{className:"h-4 w-4 animate-spin text-chip-indigo-text"})}),y.jsx("div",{style:{transform:`translateY(${Ut}px)`},"data-testid":"file-list-window",role:"presentation",children:n.slice(_t,rt).map((ke,qe)=>{const Ie=_t+qe,at=Ie===N,V=zn(ke.filename,at);return y.jsxs("div",{id:`file-row-${Ie}`,"data-row-index":Ie,role:"row","aria-rowindex":Ie+2,"aria-selected":at,onClick:()=>{var K;R(Ie),(K=F.current)==null||K.focus()},onDoubleClick:()=>M(ke),onContextMenu:K=>I(K,ke,Ie),className:`grid cursor-pointer items-center transition-colors ${V.className}`,style:{...V.style,height:Zi,gridTemplateColumns:fe},children:[y.jsxs("div",{className:"flex items-center justify-end gap-1 px-3 font-mono text-ink-faint",children:[ke.has_hook&&y.jsx("span",{title:ke.hook_pattern?`Launch workflow: ${ke.hook_pattern}`:"Launch workflow configured","aria-label":"Workflow hook attached",className:"inline-flex items-center text-status-warning-text hover:brightness-95",children:y.jsx(oO,{className:"h-3 w-3 shrink-0"})}),y.jsx("span",{className:"hidden sm:inline",children:Ie+1})]}),ie.map((K,de)=>{const Se=ke.column_values[K]||(K==="File"?ke.filename:"-");return y.jsx("div",{role:"gridcell","data-column-key":K,className:"truncate px-3 font-mono",style:{minWidth:ha},title:K==="Path"?ke.path:Se,children:Se},de)})]},ke.path||Ie)})}),je&&y.jsxs("div",{className:"pointer-events-none absolute bottom-2 left-1/2 -translate-x-1/2 rounded-full border border-line bg-surface-strong px-3 py-1 text-[11px] text-ink-muted shadow","data-testid":"file-list-paging",children:[l?y.jsx(GM,{className:"mr-1.5 h-4 w-4 animate-spin motion-reduce:animate-none text-ink-muted"}):null,"(",ze," of ",ve," loaded)"]})]})]})}function Zx({id:n,ariaLabel:e,value:t,options:i,onChange:l,placeholder:o,className:a="",inputClassName:u="",optionLabel:f=m=>m,onOpenChange:d}){const m=D.useId(),g=D.useRef(null),[b,v]=D.useState(!1),[w,S]=D.useState(""),[C,N]=D.useState(-1),R=i.filter(T=>f(T).toLocaleLowerCase().includes(w.toLocaleLowerCase())),M=C>=0&&R[C]?`${m}-option-${C}`:void 0;D.useEffect(()=>{const T=z=>{var ie;(ie=g.current)!=null&&ie.contains(z.target)||v(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),D.useEffect(()=>{d==null||d(b)},[b,d]),D.useEffect(()=>{var T;C<0||(T=document.getElementById(`${m}-option-${C}`))==null||T.scrollIntoView({block:"nearest"})},[C,m]);const I=()=>{S(""),N(-1),v(!0)},U=T=>{l(T),S(""),N(-1),v(!1)},E=T=>{if(T.key==="ArrowDown"){if(T.preventDefault(),!b){I(),N(0);return}N(z=>Math.min(z+1,R.length-1))}else if(T.key==="ArrowUp"){if(T.preventDefault(),!b){I(),N(R.length-1);return}N(z=>z<=0?R.length-1:z-1)}else T.key==="Enter"&&b&&R[C]!==void 0?(T.preventDefault(),U(R[C])):T.key==="Escape"&&v(!1)};return y.jsxs("div",{ref:g,onBlur:T=>{var z;(z=g.current)!=null&&z.contains(T.relatedTarget)||v(!1)},className:`relative flex min-w-0 ${a}`,children:[y.jsx("input",{id:n,type:"text",role:"combobox","aria-label":e,"aria-autocomplete":"list","aria-expanded":b,"aria-controls":m,"aria-activedescendant":M,value:t,placeholder:o,onChange:T=>{l(T.target.value),S(T.target.value),N(-1),v(!0)},onKeyDown:E,className:`min-w-0 flex-1 rounded-l-md border border-line bg-elevated px-3 py-1.5 text-ink outline-none transition-colors hover:bg-surface-strong focus:border-indigo-500 ${u}`}),y.jsx("button",{type:"button","aria-label":`Show ${e.toLowerCase()} options`,"aria-expanded":b,title:`Show ${e.toLowerCase()} options`,onMouseDown:T=>T.preventDefault(),onClick:()=>b?v(!1):I(),className:"shrink-0 rounded-r-md border border-l-0 border-line bg-elevated px-2 text-ink-muted hover:bg-surface-strong hover:text-ink focus-visible:z-10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-indigo-500 transition-colors",children:y.jsx(a4,{className:`h-3.5 w-3.5 transition-transform ${b?"rotate-180":""}`})}),b&&y.jsx("ul",{id:m,role:"listbox","aria-label":`${e} options`,className:"absolute left-0 top-full z-[var(--z-combobox-list)] mt-1 max-h-60 w-full min-w-48 overflow-y-auto rounded-md border border-line bg-surface py-1 text-ink shadow-xl",children:R.length>0?R.map((T,z)=>{const ie=f(T),q=z===C,J=T===t;return y.jsx("li",{id:`${m}-option-${z}`,role:"option","aria-selected":J,title:ie||void 0,onMouseEnter:()=>N(z),onMouseDown:F=>F.preventDefault(),onClick:()=>U(T),className:`cursor-pointer truncate px-3 py-1.5 ${q?"bg-elevated text-ink":"text-ink-secondary"} ${J?"font-semibold":""}`,children:ie||"(No filter)"},`${T}-${z}`)}):y.jsx("li",{className:"px-3 py-1.5 text-ink-muted",children:"No matching presets"})})]})}function $9({title:n,release:e,directories:t,activeDirectory:i,onDirectoryChange:l,onBrowseDirectory:o,onGoToParentDirectory:a,onGoToHomeDirectory:u,onOpenActiveDirectory:f,onOpenTerminal:d}){const[m,g]=D.useState(!1);return y.jsxs("header",{className:"relative z-30 flex flex-wrap items-center gap-3 border-b border-line bg-app/90 px-5 py-2 text-xs backdrop-blur-xl shadow-xs transition-all duration-200",children:[y.jsx("div",{className:"flex shrink-0 items-center gap-3",children:y.jsxs("div",{className:"flex items-center gap-3.5",children:[y.jsxs("div",{className:"relative flex h-9 w-9 items-center justify-center rounded-xl bg-gradient-to-br from-chip-indigo-bg to-chip-purple-bg text-chip-indigo-text border border-chip-indigo-border shadow-xs",children:[y.jsx(W0,{className:"h-4 w-4"}),y.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 flex h-2.5 w-2.5 items-center justify-center rounded-full bg-emerald-500 ring-2 ring-app"})]}),y.jsxs("div",{children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("h1",{className:"text-sm font-bold tracking-tight text-ink font-heading",children:"ProFiles"}),n&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-ink-faint",children:"/"}),y.jsx("span",{className:"text-xs font-medium text-chip-indigo-text bg-chip-indigo-bg px-2 py-0.5 rounded-md border border-chip-indigo-border/50",children:n})]})]}),y.jsxs("p",{className:"text-[11px] font-medium text-ink-muted tracking-wide mt-0.5",children:["Crafted by ",y.jsx("span",{className:"text-ink font-semibold",children:"Florent ALBANY"})," • ",y.jsxs("span",{className:"font-mono text-chip-indigo-text",children:["v",e||"0.11.0-rc.2"]})]})]})]})}),y.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[y.jsxs("label",{className:"flex shrink-0 items-center gap-1.5 font-medium text-ink-secondary text-xs",children:[y.jsx(Ou,{className:"h-3.5 w-3.5 text-chip-indigo-text"}),y.jsx("span",{children:"Directory:"})]}),y.jsx(Qe,{text:"Select or type a directory path to scan files from.",suppress:m,children:y.jsx(Zx,{id:"directory-combobox",ariaLabel:"Directory",value:i,options:t,onChange:l,onOpenChange:g,placeholder:"/path/to/directory",className:"w-full",inputClassName:"font-mono"})}),f&&y.jsx(Qe,{text:"Open the active directory in the OS file manager",block:!1,children:y.jsx("button",{type:"button",onClick:f,"aria-label":"Open active directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(WM,{className:"h-3.5 w-3.5"})})}),a&&y.jsx(Qe,{text:"Go to parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:a,"aria-label":"Go to parent directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(Xd,{className:"h-3.5 w-3.5 rotate-180"})})}),o&&y.jsx(Qe,{text:"Browse for a folder on this system",block:!1,children:y.jsx("button",{type:"button",onClick:o,"aria-label":"Browse directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(Jl,{className:"h-3.5 w-3.5"})})}),d&&y.jsx(Qe,{text:"Open the active directory in a terminal",block:!1,children:y.jsx("button",{type:"button",onClick:()=>d(i),"aria-label":"Open directory in terminal",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(W0,{className:"h-3.5 w-3.5"})})}),u&&y.jsx(Qe,{text:"Set directory to your home folder",block:!1,children:y.jsx("button",{type:"button",onClick:u,"aria-label":"Go to home directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx($d,{className:"h-3.5 w-3.5"})})})]})]})}function Y9({message:n,onRetry:e,retrying:t=!1}){return y.jsx("div",{className:"flex flex-1 items-center justify-center p-8",role:"alert","data-testid":"init-error-panel",children:y.jsxs("div",{className:"w-full max-w-sm rounded-xl border border-line bg-surface p-6 text-center shadow-xl",children:[y.jsx("div",{className:"mx-auto mb-3 flex h-10 w-10 items-center justify-center rounded-full border border-status-danger-border bg-status-danger-bg",children:y.jsx(Gc,{className:"h-5 w-5 text-status-danger-text/80"})}),y.jsx("h3",{className:"text-sm font-semibold text-ink",children:"Couldn't load the app"}),y.jsx("p",{className:"mt-1 break-words text-xs text-ink-secondary",children:n}),y.jsxs("button",{type:"button",onClick:e,disabled:t,className:"btn btn-primary mx-auto mt-4 px-3.5 py-1.5 font-semibold shadow-sm",children:[y.jsx(Yd,{className:`h-3.5 w-3.5 ${t?"animate-spin motion-reduce:animate-none":""}`}),y.jsx("span",{children:t?"Retrying...":"Retry"})]})]})})}const F2=/"([^"]*)"|(\S+)/g,q2=/"([^"]*)"/g,G9="Unmatched quote";function K9(n){const e=[];let t;for(F2.lastIndex=0;(t=F2.exec(n))!==null;){const a=t[1]!==void 0?t[1]:t[2];a&&a.trim()&&e.push(a)}let i="",l=0;q2.lastIndex=0;let o;for(;(o=q2.exec(n))!==null;)i+=n.slice(l,o.index),l=o.index+o[0].length;return i+=n.slice(l),{terms:e,error:i.includes('"')?G9:null}}function pA(n){const e=n.trim();if(!e)return{error:null,groups:[]};const{terms:t,error:i}=K9(e);if(t.length===0)return{error:i,groups:[]};const l=[];let o={includes:[],excludes:[]};for(const a of t){if(a.toUpperCase()==="OR"){l.push(o),o={includes:[],excludes:[]};continue}a==="-"||a==="+"||(a.startsWith("-")&&a.length>1?o.excludes.push(a.slice(1)):a.startsWith("+")&&a.length>1?o.includes.push(a.slice(1)):o.includes.push(a))}return l.push(o),{error:i,groups:l}}const W9=256,Fs=new Map;function V2(n){return n.toLowerCase()}function Z9(n){const e=Fs.get(n);if(e)return Fs.delete(n),Fs.set(n,e),e;const{groups:t}=pA(n),i={groups:t.map(l=>({includes:l.includes.map(V2),excludes:l.excludes.map(V2)}))};if(Fs.size>=W9){const l=Fs.keys().next().value;l!==void 0&&Fs.delete(l)}return Fs.set(n,i),i}function J9(n,e){return e.includes.every(t=>n.includes(t))&&!e.excludes.some(t=>n.includes(t))}function e8(n,e){const{groups:t}=Z9(e);if(t.length===0)return!0;const i=n.toLowerCase();return t.some(l=>J9(i,l))}function t8({query:n,visible:e}){if(!e)return null;const t=pA(n);return t.error?y.jsx("div",{"data-testid":"filter-syntax-helper",className:"pointer-events-none absolute left-0 right-0 top-full z-[var(--z-syntax-helper)] mt-1 rounded-md border border-status-danger-border bg-surface-strong px-3 py-2 text-[11px] leading-5 text-status-danger-text/90 shadow-xl",children:t.error}):t.groups.length===0?null:y.jsxs("div",{"data-testid":"filter-syntax-helper",className:"pointer-events-none absolute left-0 right-0 top-full z-[var(--z-syntax-helper)] mt-1 rounded-md border border-line bg-surface-strong px-3 py-2 text-[11px] leading-5 text-ink-secondary shadow-xl",children:[y.jsx("span",{className:"mr-1.5 align-[1px] text-[10px] uppercase tracking-wide text-ink-muted",children:"reads as"}),t.groups.map((i,l)=>y.jsxs("span",{"data-testid":"filter-syntax-group",children:[l>0&&y.jsx("span",{className:"mx-1 font-mono text-chip-indigo-text",children:"OR"}),i.includes.map((o,a)=>y.jsxs("span",{children:[a>0&&y.jsx("span",{className:"text-ink-muted",children:" · "}),y.jsx("span",{className:"font-mono text-chip-indigo-text",children:o})]},`i-${a}`)),i.includes.length>0&&i.excludes.length>0&&y.jsx("span",{className:"text-ink-muted",children:" · "}),i.excludes.map((o,a)=>y.jsxs("span",{children:[a>0&&y.jsx("span",{className:"text-ink-muted",children:" · "}),y.jsx("span",{className:"text-ink-muted",children:"✕ "}),y.jsx("span",{className:"font-mono text-status-danger-text/70 line-through",children:o})]},`x-${a}`))]},l))]})}const Q2=y.jsxs("span",{className:"flex flex-col gap-1 whitespace-nowrap text-left",children:[y.jsx("span",{className:"font-semibold",children:"Supported operators"}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"a b"})," — AND (both terms)"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"a OR b"})," — either term"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"-a"})," — NOT (exclude)"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"+a"})," — force include"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:'"a b"'})," — exact phrase"]})]});function n8({extensions:n,activeExtension:e,onExtensionChange:t,filterOptions:i,filterText:l,onFilterTextChange:o,recursive:a,onRecursiveChange:u,onScan:f,scanning:d,barcodeMode:m,onBarcodeToggle:g,onCameraBarcodeClick:b,autoRescanActive:v,onTimerClick:w}){const[S,C]=D.useState(!1),[N,R]=D.useState(!1),[M,I]=D.useState(!1);return y.jsxs("div",{className:"flex w-full flex-wrap items-center gap-3 border-b border-line bg-surface-glass p-3 text-xs",children:[y.jsx(Qe,{text:Q2,suppress:N,children:y.jsxs("div",{className:"relative min-w-0 flex-1 basis-64",onFocusCapture:U=>{U.target.tagName==="INPUT"&&C(!0)},onBlurCapture:U=>{U.target.tagName==="INPUT"&&C(!1)},children:[y.jsx(rO,{className:"pointer-events-none absolute left-3 top-1/2 z-10 h-4 w-4 -translate-y-1/2 text-ink-secondary"}),y.jsx(Zx,{id:"filter-combobox",ariaLabel:"File filter",value:l,options:i||[],onChange:o,onOpenChange:R,placeholder:"Filter files: keyword, a OR b, -tag, exact phrase...",className:"w-full",inputClassName:"pl-9 pr-3",optionLabel:U=>U||"(No filter)"}),y.jsx(t8,{query:l,visible:S&&!N&&l.trim().length>0})]})}),y.jsx(Qe,{text:Q2,block:!1,suppress:M,children:y.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[y.jsx("span",{className:"text-ink-muted",children:"Ext:"}),y.jsx(Zx,{id:"extension-combobox",ariaLabel:"Extension filter",value:e,options:n,onChange:t,onOpenChange:I,placeholder:".py OR .toml",className:"w-44",inputClassName:"font-mono px-2.5"})]})}),y.jsx(Qe,{text:"Include subdirectories when scanning",block:!1,children:y.jsxs("label",{className:"flex shrink-0 cursor-pointer select-none items-center gap-1.5 text-ink-secondary",children:[y.jsx("input",{type:"checkbox",checked:a,onChange:U=>u(U.target.checked),className:"rounded border-line text-chip-indigo-text focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-1 focus-visible:ring-offset-app"}),y.jsx("span",{children:"Recursive"})]})}),y.jsx(Qe,{text:"Run the scan with the current criteria (Enter)",block:!1,children:y.jsxs("button",{onClick:f,disabled:d,className:"btn btn-primary shrink-0 px-3.5 py-1.5 font-semibold shadow-sm",children:[d?y.jsx(Yd,{className:"h-3.5 w-3.5 animate-spin motion-reduce:animate-none"}):y.jsx(ts,{className:"h-3.5 w-3.5 fill-current"}),y.jsx("span",{children:d?"Scanning...":"Scan"})]})}),y.jsx(Qe,{text:v?"Auto-rescan is active. Click to configure.":"Configure periodic auto-rescan (hot-folder mode)",block:!1,children:y.jsx("button",{type:"button",onClick:w,"aria-label":"Configure timer / auto-rescan",className:`flex shrink-0 items-center justify-center rounded-md border p-1.5 text-ink-secondary hover:border-indigo-500 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 transition-colors ${v?"border-chip-indigo-border bg-chip-indigo-bg text-chip-indigo-text":"border-line bg-elevated"}`,children:y.jsx(lO,{className:`h-3.5 w-3.5 ${v?"animate-pulse":""}`})})}),y.jsx(Qe,{text:"Toggle barcode scanner mode (USB HID). When active, scan a barcode to auto-fill controls and trigger a scan.",block:!1,children:y.jsx("button",{type:"button",onClick:g,"aria-label":m?"Disable barcode mode":"Enable barcode mode",className:`flex shrink-0 items-center justify-center rounded-md border p-1.5 text-ink-secondary hover:border-indigo-500 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 transition-colors ${m?"border-chip-indigo-border bg-chip-indigo-bg text-chip-indigo-text":"border-line bg-elevated"}`,children:y.jsx(xy,{className:`h-3.5 w-3.5 ${m?"animate-pulse":""}`})})}),b&&y.jsx(Qe,{text:"Scan barcode or QR code using webcam / camera (Ctrl + Shift + B)",block:!1,children:y.jsx("button",{type:"button",onClick:b,"aria-label":"Scan barcode with camera",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(JC,{className:"h-3.5 w-3.5"})})})]})}const i8=2e3,r8=500,l8=[{value:null,label:"ALL"},{value:"DEBUG",label:"DEBUG"},{value:"INFO",label:"INFO"},{value:"WARNING",label:"WARNING"},{value:"ERROR",label:"ERROR"},{value:"CRITICAL",label:"CRITICAL"}],X2={DEBUG:{icon:n4,className:"text-chip-sky-text"},INFO:{icon:gy,className:"text-status-success-text"},WARNING:{icon:yy,className:"text-status-warning-text"},ERROR:{icon:ou,className:"text-status-danger-text"},CRITICAL:{icon:ou,className:"text-status-danger-text"},UNKNOWN:{icon:ka,className:"text-ink-faint"}};function s8({isOpen:n,onClose:e,onOpenExternally:t}){const[i,l]=D.useState([]),[o,a]=D.useState("profiles.log"),[u,f]=D.useState(0),[d,m]=D.useState(null),[g,b]=D.useState(""),[v,w]=D.useState(!1),[S,C]=D.useState(!0),[N,R]=D.useState(null),[M,I]=D.useState(!0),U=D.useRef(null),E=D.useRef(null),T=D.useRef(null),z=D.useRef(null),ie=D.useRef(S),q=D.useRef({level:d,search:g});ie.current=S,q.current={level:d,search:g};const J=D.useCallback(async()=>{const{level:L,search:ee}=q.current;w(!0);try{const oe=await vM({limit:r8,level:L,search:ee});l(oe.entries),a(oe.path),f(oe.size_bytes),R(null)}catch(oe){R((oe==null?void 0:oe.message)||"Failed to read the log file")}finally{w(!1)}},[]);D.useEffect(()=>{n&&J()},[n,J]),D.useEffect(()=>{if(!n||!S)return;const L=window.setInterval(()=>{J()},i8);return()=>window.clearInterval(L)},[n,S,J]),D.useEffect(()=>{if(!n)return;const L=window.setTimeout(()=>void J(),250);return()=>window.clearTimeout(L)},[n,d,g,J]),D.useEffect(()=>{if(!M)return;const L=T.current;L&&(L.scrollTop=L.scrollHeight)},[i,M]),D.useEffect(()=>{if(!n)return;const L=document.activeElement instanceof HTMLElement?document.activeElement:null,ee=requestAnimationFrame(()=>{var oe;return(oe=E.current)==null?void 0:oe.focus()});return()=>{cancelAnimationFrame(ee),L==null||L.focus()}},[n]);const F=L=>{var A;if(L.key==="Escape"){L.preventDefault(),e();return}if(L.key!=="Tab")return;const ee=(A=U.current)==null?void 0:A.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(ee!=null&&ee.length))return;const oe=ee[0],le=ee[ee.length-1];L.shiftKey&&document.activeElement===oe?(L.preventDefault(),le.focus()):!L.shiftKey&&document.activeElement===le&&(L.preventDefault(),oe.focus())},se=()=>{const L=T.current;if(!L)return;const ee=L.scrollHeight-L.scrollTop-L.clientHeight<24;I(ee)},he=async()=>{try{await navigator.clipboard.writeText(i.map(L=>L.raw).join(` -`))}catch{}},ne=D.useMemo(()=>{const L=new Map;for(const ee of i)L.set(ee.level,(L.get(ee.level)??0)+1);return L},[i]);return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",onClick:e,children:y.jsxs("div",{ref:U,role:"dialog","aria-modal":"true","aria-labelledby":"log-viewer-title",onKeyDown:F,className:"animate-modal-in flex h-[min(84dvh,760px)] w-[clamp(560px,85vw,1500px)] min-h-0 flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",onClick:L=>L.stopPropagation(),children:[y.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b border-line px-5 py-4 sm:px-6",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[y.jsx("span",{className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(ka,{className:"h-5 w-5 text-chip-indigo-text","aria-hidden":"true"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"log-viewer-title",className:"text-base font-semibold text-ink",children:"Application logs"}),y.jsxs("p",{className:"truncate font-mono text-xs text-ink-muted",children:[o,y.jsxs("span",{className:"text-ink-faint",children:[" · ",$2(u)]})]})]})]}),y.jsxs("div",{className:"relative min-w-[220px] flex-1",children:[y.jsx(rO,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-ink-faint","aria-hidden":"true"}),y.jsx("input",{ref:z,type:"search",value:g,onChange:L=>b(L.target.value),placeholder:"Filter log lines…","aria-label":"Filter log lines",className:"w-full rounded-lg border border-line bg-elevated py-1.5 pl-8 pr-2.5 font-mono text-xs text-ink placeholder:text-ink-faint focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400"})]}),y.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[y.jsx(Qe,{text:S?"Pause live tail":"Resume live tail",block:!1,children:y.jsxs("button",{type:"button",onClick:()=>C(L=>!L),"aria-pressed":S,className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 ${S?"border-status-success-border bg-status-success-bg text-status-success-text":"border-line bg-elevated text-ink-muted hover:text-ink"}`,children:[y.jsx("span",{className:`h-2 w-2 rounded-full ${S?"bg-emerald-400":"bg-ink-faint"}`,"aria-hidden":"true"}),S?"Live":"Paused"]})}),y.jsx(Qe,{text:"Refresh now",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void J(),disabled:v,className:"rounded-lg border border-line bg-elevated p-2 text-ink-muted hover:text-ink disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Yd,{className:`h-4 w-4 ${v?"animate-spin":""}`,"aria-hidden":"true"})})}),y.jsx(Qe,{text:"Copy visible lines",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void he(),disabled:i.length===0,className:"rounded-lg border border-line bg-elevated p-2 text-ink-muted hover:text-ink disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(ci,{className:"h-4 w-4","aria-hidden":"true"})})}),y.jsx(Qe,{text:"Open log file in the default application",block:!1,children:y.jsx("button",{type:"button",onClick:()=>{t==null||t(),e()},className:"rounded-lg border border-line bg-elevated p-2 text-ink-muted hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(tO,{className:"h-4 w-4","aria-hidden":"true"})})}),y.jsx(Qe,{text:"Close",block:!1,children:y.jsx("button",{ref:E,type:"button",onClick:e,className:"rounded-lg p-2 text-ink-muted hover:bg-hover-surface hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Ei,{className:"h-4 w-4","aria-hidden":"true"})})})]})]}),y.jsxs("div",{ref:T,onScroll:se,className:"min-h-0 flex-1 overflow-y-auto overscroll-contain bg-app px-2 py-2 font-mono text-xs leading-relaxed sm:px-3",children:[y.jsxs("div",{className:"sticky top-0 z-10 mb-1 flex items-center gap-2 rounded-md border border-line/40 bg-surface/60 px-2 py-1 text-[10px] font-bold uppercase tracking-wider text-ink-muted shadow-sm backdrop-blur-md",role:"row",children:[y.jsx("span",{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),y.jsx("span",{className:"w-[138px] shrink-0 text-ink/70",children:"Time"}),y.jsx("span",{className:"w-[52px] shrink-0 text-ink/70",children:"Level"}),y.jsx("span",{className:"w-[150px] shrink-0 text-ink/70",children:"Source"}),y.jsx("span",{className:"min-w-0 flex-1 text-ink/70",children:"Message"})]}),N&&y.jsx("p",{role:"alert",className:"px-3 py-6 text-center text-xs text-status-danger-text",children:N}),!N&&i.length===0&&!v&&y.jsx("p",{className:"px-3 py-6 text-center text-xs text-ink-faint",children:"No log entries match the current filters."}),y.jsx("ul",{className:"space-y-0.5",children:i.map((L,ee)=>{const oe=X2[L.level]??X2.UNKNOWN,le=oe.icon,A=L.level==="ERROR"||L.level==="CRITICAL";return y.jsxs("li",{className:`group flex items-start gap-2 rounded px-2 py-1 ${A?"bg-status-danger-bg/40":"hover:bg-elevated/50"}`,children:[y.jsx("span",{className:oe.className,children:y.jsx(le,{className:"mt-0.5 h-3.5 w-3.5","aria-hidden":"true"})}),y.jsx("span",{className:"w-[138px] shrink-0 text-ink-faint",children:L.timestamp}),y.jsx("span",{className:`w-[52px] shrink-0 text-[10px] font-semibold ${oe.className}`,children:L.level}),y.jsx("span",{className:"w-[150px] shrink-0 truncate text-ink-faint",title:L.source,children:L.source}),y.jsx("span",{className:"min-w-0 flex-1 break-words text-ink-secondary",children:L.message})]},`${ee}-${L.raw}`)})})]}),y.jsx("div",{className:"border-t border-line/60 bg-elevated/50 px-5 py-2.5 text-[11px] text-ink-faint shadow-sm backdrop-blur-md sm:px-6",children:y.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[y.jsx("span",{className:"mr-auto min-w-0 max-w-full basis-full truncate sm:basis-auto",role:"status","aria-atomic":"true",children:v&&i.length===0?"Loading log entries…":`${i.length} of ${$2(u)} shown`}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("div",{className:"flex overflow-hidden rounded-lg border border-line/60 text-[11px] backdrop-blur-sm",role:"group","aria-label":"Filter by log level",children:l8.map(L=>{const ee=d===L.value,oe=L.value?ne.get(L.value)??0:i.length;return y.jsxs("button",{type:"button",onClick:()=>m(L.value),"aria-pressed":ee,title:L.value?`Show ${L.value} and above`:"Show all levels",className:`flex items-center gap-1 px-2.5 py-1 font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400 ${ee?"bg-indigo-600 text-white":"text-ink-muted hover:bg-elevated hover:text-ink"}`,children:[L.label,y.jsx("span",{className:ee?"text-chip-indigo-text":"text-ink-faint",children:oe})]},L.label)})}),y.jsx(Qe,{text:"Scroll to the newest entry",block:!1,children:y.jsxs("button",{type:"button",onClick:()=>I(!0),"aria-pressed":M,className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 ${M?"border-chip-indigo-border bg-chip-indigo-bg text-chip-indigo-text":"border-line bg-elevated text-ink-muted hover:text-ink"}`,children:[y.jsx(ZC,{className:"h-3.5 w-3.5","aria-hidden":"true"}),y.jsx("span",{className:"hidden sm:inline",children:"Follow tail"})]})})]}),y.jsxs("span",{className:"hidden items-center gap-1.5 lg:flex",children:[y.jsx("span",{className:"hidden sm:inline",children:"Ctrl + Shift + L"}),y.jsx("span",{children:"opens externally"})]})]})})]})}):null}function $2(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}function o8({isOpen:n,onClose:e}){const t=D.useRef(null),i=hs({isOpen:n,onClose:e,dialogRef:t});if(!n)return null;const l=[{key:"F5",desc:"Refresh / re-scan file list"},{key:"Ctrl + R",desc:"Reload configuration & scan"},{key:"Enter",desc:"Execute / launch selected file"},{key:"P",desc:"Open properties for selected file"},{key:"↑ / ↓",desc:"Navigate file list"},{key:"Home / End",desc:"Jump to first / last file"},{key:"PageUp / PageDown",desc:"Page through the file list"},{key:"Ctrl + D",desc:"Focus Directory field"},{key:"Ctrl + E",desc:"Focus Extension field"},{key:"Ctrl + F",desc:"Focus Filter / Search field"},{key:"Ctrl + L",desc:"Focus File List"},{key:"Ctrl + Shift + L",desc:"Open the log viewer"},{key:"Ctrl + ,",desc:"Open the config editor"},{key:"Ctrl + Shift + T",desc:"Toggle theme (Dark / Light)"},{key:"Ctrl + B",desc:"Toggle barcode scanner mode"},{key:"Ctrl + Shift + B",desc:"Open webcam / camera barcode scanner"},{key:"Ctrl + T",desc:"Open auto-rescan timer modal"},{key:"Ctrl + H",desc:"Set directory to home folder"},{key:"? or Ctrl + /",desc:"Show keyboard shortcuts"},{key:"Y / S / N",desc:"Answer workflow guard: Yes / Skip / No (prompt open)"},{key:"Enter",desc:"Confirm active workflow prompt (prompt open)"},{key:"Escape",desc:"Close dialogs / context menu"}];return y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:y.jsxs("div",{ref:t,role:"dialog","aria-modal":"true","aria-label":"Keyboard Shortcuts",onKeyDown:i,className:"animate-modal-in w-[450px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink",children:[y.jsx(nO,{className:"h-5 w-5 text-chip-indigo-text"}),y.jsx("span",{children:"Keyboard Shortcuts"})]}),y.jsx("button",{onClick:e,className:"focus-ring rounded-lg p-1 text-ink-muted hover:bg-elevated hover:text-ink",children:y.jsx(Ei,{className:"h-4 w-4"})})]}),y.jsx("div",{className:"max-h-[60vh] space-y-2 overflow-y-auto pr-1 text-xs",children:l.map(({key:o,desc:a})=>y.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-elevated/50 px-3 py-2",children:[y.jsx("span",{className:"text-ink-secondary",children:a}),y.jsx("kbd",{className:"rounded bg-app px-2 py-0.5 font-mono text-[11px] font-semibold text-chip-indigo-text border border-line",children:o})]},o))}),y.jsx("div",{className:"mt-5 flex justify-end",children:y.jsx("button",{onClick:e,className:"btn btn-primary rounded-lg px-4 py-2 font-semibold",children:"Close"})})]})})}function a8({isOpen:n,activeConfigPath:e,configExists:t=!0,onClose:i,onLoaded:l}){const[o,a]=D.useState(null),[u,f]=D.useState(""),[d,m]=D.useState(null),[g,b]=D.useState(!1),[v,w]=D.useState(null),S=D.useRef(null),C=D.useRef(null),N=D.useRef(null),R=t===!1;D.useEffect(()=>{var J;if(!n){(J=N.current)==null||J.focus();return}N.current=document.activeElement instanceof HTMLElement?document.activeElement:null,w(null);const T=e??"",z=Math.max(T.lastIndexOf("/"),T.lastIndexOf("\\")),ie=z>0?T.slice(0,z):"";M(ie);const q=requestAnimationFrame(()=>{var F;return(F=C.current)==null?void 0:F.focus()});return()=>{var F;cancelAnimationFrame(q),(F=N.current)==null||F.focus()}},[n,e]);const M=async T=>{b(!0),w(null);try{const z=await EM(T);a(z),f(z.current_path),e&&z.items.some(ie=>ie.path===e)?m(e):m(null)}catch(z){w(z.message||"Navigation failed")}finally{b(!1)}},I=T=>{var J;if(T.key==="Escape"){T.preventDefault(),i();return}if(T.key!=="Tab")return;const z=(J=S.current)==null?void 0:J.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(z!=null&&z.length))return;const ie=z[0],q=z[z.length-1];T.shiftKey&&document.activeElement===ie?(T.preventDefault(),q.focus()):!T.shiftKey&&document.activeElement===q&&(T.preventDefault(),ie.focus())},U=async()=>{var z;const T=d||(((z=o==null?void 0:o.items.find(ie=>ie.is_config))==null?void 0:z.path)??null);if(!T){w("Select a configuration file to load.");return}try{b(!0);const ie=await SM(T);l(ie),i()}catch(ie){w(ie.message||"Unable to load configuration")}finally{b(!1)}},E=async()=>{const T=(u||(o==null?void 0:o.current_path)||"").trim();if(!T){w("Choose a directory before creating a configuration.");return}try{b(!0);const z=await OM(T);l(z),i()}catch(z){w(z.message||"Unable to create configuration")}finally{b(!1)}};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",onClick:i,children:y.jsxs("div",{ref:S,role:"dialog","aria-modal":"true","aria-labelledby":"load-config-title",onKeyDown:I,className:"animate-modal-in flex h-[min(84dvh,760px)] max-h-[calc(100dvh-1.5rem)] w-[min(94vw,960px)] min-h-0 flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",onClick:T=>T.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-line px-4 py-3 sm:px-5",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(sa,{className:"h-5 w-5 text-chip-indigo-text"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"load-config-title",className:"text-sm font-semibold text-ink",children:R?"Create configuration":"Load configuration"}),y.jsx("p",{className:"truncate font-mono text-xs text-ink-muted",children:(o==null?void 0:o.current_path)||""})]})]}),y.jsx(Qe,{text:"Close",block:!1,children:y.jsx("button",{type:"button",onClick:i,"aria-label":"Close configuration modal",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg text-ink-muted transition-colors hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Ei,{className:"h-4 w-4"})})})]}),R&&y.jsx("div",{className:"border-b border-line bg-chip-indigo-bg/20 px-4 py-3 text-xs text-ink-secondary",children:"No configuration file was found. Create one here?"}),y.jsxs("div",{className:"border-b border-line px-4 py-3 sm:px-5",children:[y.jsx("label",{htmlFor:"config-path-input",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"Configuration directory"}),y.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[y.jsx("input",{ref:C,id:"config-path-input",type:"text",value:u,onChange:T=>f(T.target.value),onKeyDown:T=>{T.key==="Enter"&&M(u.trim())},placeholder:"/path/to/directory",className:"h-10 min-w-0 flex-1 rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),y.jsx("button",{type:"button",onClick:()=>M(u.trim()),className:"inline-flex h-10 shrink-0 items-center gap-1.5 rounded-lg border border-line bg-elevated px-3.5 text-sm font-medium text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Go"}),y.jsx(Qe,{text:"Home directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>M(""),"aria-label":"Home directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx($d,{className:"h-4 w-4"})})}),(o==null?void 0:o.parent_path)&&y.jsx(Qe,{text:"Parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>M(o.parent_path),"aria-label":"Parent directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Xd,{className:"h-4 w-4 rotate-180"})})})]})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2 sm:px-3 sm:py-3","aria-busy":g,children:g?y.jsxs("div",{className:"flex h-full items-center justify-center gap-2.5 text-sm text-ink-muted",children:[y.jsx(ll,{className:"h-5 w-5 animate-spin text-chip-indigo-text"}),y.jsx("span",{role:"status",children:"Loading configuration files…"})]}):v?y.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2.5 text-center",children:[y.jsx("p",{className:"text-sm text-status-danger-text",children:v}),y.jsx("button",{type:"button",onClick:()=>M(u||(o==null?void 0:o.current_path)||""),className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Retry"})]}):y.jsxs("ul",{className:"space-y-1",children:[o==null?void 0:o.items.map(T=>{if(T.is_dir)return y.jsx("li",{children:y.jsx("button",{onClick:()=>M(T.path),onDoubleClick:()=>M(T.path),className:"flex w-full items-center justify-between rounded-md px-3 py-1.5 text-left text-xs text-ink-secondary hover:bg-elevated",children:y.jsxs("span",{className:"flex items-center gap-2",children:[y.jsx(Ou,{className:"h-3.5 w-3.5 text-chip-indigo-text"}),T.name]})})},T.path);const z=d===T.path;return y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>m(T.path),"aria-pressed":z,className:`flex w-full items-center justify-between rounded-lg px-3 py-1.5 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400 ${z?"bg-chip-indigo-bg text-chip-indigo-text":"text-ink-secondary hover:bg-elevated hover:text-ink"}`,children:[y.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx(ka,{className:"h-5 w-5 shrink-0 text-chip-amber-text"}),y.jsx("span",{className:"truncate",children:T.name})]}),T.is_config&&y.jsx(sa,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"}),z&&y.jsx(_r,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"})]})},T.path)}),(o==null?void 0:o.items.filter(T=>T.is_config).length)===0&&y.jsxs("li",{className:"flex h-full min-h-36 flex-col items-center justify-center gap-2.5 text-center text-sm text-ink-muted",children:[y.jsx(ka,{className:"h-7 w-7 text-ink-faint"}),"No configuration files found"]})]})}),y.jsxs("div",{className:"flex flex-col gap-2 border-t border-line px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:px-5",children:[y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("p",{className:"mb-0.5 text-xs font-medium text-ink-muted",children:"Selected file"}),y.jsx("p",{className:"truncate font-mono text-sm text-ink",title:d||u,children:d||u||"—"})]}),y.jsxs("div",{className:"flex shrink-0 justify-end gap-1.5",children:[y.jsx("button",{type:"button",onClick:i,className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Cancel"}),R?y.jsxs("button",{type:"button",onClick:E,disabled:!u.trim(),className:"btn btn-primary min-h-10 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(sa,{className:"h-4 w-4"}),"Create configuration"]}):y.jsxs("button",{type:"button",onClick:U,disabled:!d,className:"btn btn-primary min-h-10 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(sa,{className:"h-4 w-4"}),"Load configuration"]})]})]})]})}):null}function gA({isOpen:n,onClose:e,initialFilePath:t,md5:i}){const[l,o]=D.useState(null),[a,u]=D.useState(""),[f,d]=D.useState([]),[m,g]=D.useState(!1),[b,v]=D.useState(null),[w,S]=D.useState(!1),[C,N]=D.useState(!1),[R,M]=D.useState(null),I=D.useRef(null),U=hs({isOpen:n,onClose:e,dialogRef:I});D.useEffect(()=>{if(!n)return;async function ne(){if(t){g(!0);try{const L=await Uk({filePath:t});o(L.image),u(L.content),E(L.content)}catch(L){v(L.message)}finally{g(!1)}}}ne()},[n,t]);const E=ne=>{const L=ne.split(";").map(ee=>{const oe=ee.split("=");return{key:oe[0]||"",value:oe[1]||""}}).filter(ee=>ee.key||ee.value);d(L)},T=async ne=>{const L=ne.filter(ee=>ee.key.trim()).map(ee=>`${ee.key.trim()}=${ee.value.trim()}`).join(";");if(u(L),!L){o(null);return}try{const ee=await Uk({content:L});o(ee.image)}catch(ee){console.error("Failed to re-generate barcode:",ee)}},z=(ne,L,ee)=>{const oe=[...f];oe[ne][L]=ee,d(oe),T(oe)},ie=()=>{const ne=[...f,{key:"",value:""}];d(ne)},q=ne=>{const L=f.filter((ee,oe)=>oe!==ne);d(L),T(L)},J=()=>{if(!i||f.some(L=>L.key.toLowerCase()==="md5"))return;const ne=[...f,{key:"md5",value:i}];d(ne),T(ne)},F=async()=>{if(l){M("Saving…");try{const ne=await LM(l,`profiles-qr-${Date.now()}.png`);M(ne.path||ne.message)}catch(ne){M(`Save failed: ${(ne==null?void 0:ne.message)??ne}`)}finally{setTimeout(()=>M(null),6e3)}}},se=async()=>{try{await navigator.clipboard.writeText(a),S(!0),setTimeout(()=>S(!1),2e3)}catch(ne){console.error("Copy failed",ne)}},he=async()=>{if(l)try{const L=await(await fetch(l)).blob();await navigator.clipboard.write([new ClipboardItem({[L.type]:L})]),N(!0),setTimeout(()=>N(!1),2e3)}catch(ne){console.error("Image copy failed",ne)}};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4",onClick:e,children:y.jsxs("div",{ref:I,role:"dialog","aria-modal":"true","aria-label":"QR Code Settings",onKeyDown:U,className:"animate-modal-in w-full max-w-md rounded-xl border border-frame-line glass-panel p-6",onClick:ne=>ne.stopPropagation(),children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"text-sm font-semibold text-ink",children:"QR Code Settings"}),y.jsx("button",{onClick:e,className:"focus-ring rounded-md p-1 text-ink-muted hover:bg-elevated hover:text-ink",children:y.jsx(Ei,{className:"h-4 w-4"})})]}),m?y.jsx("div",{className:"flex h-48 items-center justify-center",children:y.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent"})}):b?y.jsx("div",{className:"rounded-md border border-status-danger-border bg-status-danger-bg p-4 text-center text-xs text-status-danger-text",children:b}):y.jsxs("div",{className:"space-y-6",children:[y.jsxs("div",{className:"flex flex-col items-center gap-4",children:[y.jsxs("div",{className:"relative group",children:[y.jsx("div",{className:"h-48 w-48 overflow-hidden rounded-lg border border-line bg-white p-2",children:l?y.jsx("img",{src:l,alt:"QR Code",className:"h-full w-full object-contain"}):y.jsx("div",{className:"flex h-full items-center justify-center text-xs text-slate-400",children:"No content"})}),l&&y.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/20 rounded-lg",children:y.jsxs("button",{onClick:he,className:"focus-ring flex items-center gap-2 rounded-md bg-white/90 p-2 text-xs font-medium text-slate-900 shadow-sm hover:bg-white",children:[C?y.jsx(_r,{className:"h-3.5 w-3.5"}):y.jsx(ci,{className:"h-3.5 w-3.5"}),C?"Copied":"Copy Image"]})})]}),y.jsxs("div",{className:"flex w-full gap-2",children:[y.jsxs("button",{onClick:se,className:"btn btn-secondary flex-1 px-3 py-1.5",children:[w?y.jsx(_r,{className:"h-3.5 w-3.5 text-status-success-text"}):y.jsx(ci,{className:"h-3.5 w-3.5"}),"Copy Content"]}),y.jsxs("button",{onClick:F,disabled:!l,className:"btn btn-primary flex-1 px-3 py-1.5",children:[y.jsx(eO,{className:"h-3.5 w-3.5"}),"Save Image"]})]}),R&&y.jsx("p",{className:"break-all text-center text-[11px] text-ink-muted",role:"status",children:R})]}),y.jsxs("div",{className:"space-y-3",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("label",{className:"text-xs font-medium text-ink-muted uppercase tracking-wider",children:"Payload Fields"}),y.jsxs("div",{className:"flex gap-2",children:[i&&!f.some(ne=>ne.key==="md5")&&y.jsxs("button",{onClick:J,className:"btn-chip flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-bold text-chip-purple-text border border-chip-purple-border",children:[y.jsx(oa,{className:"h-3 w-3"})," Inc. MD5"]}),y.jsxs("button",{onClick:ie,className:"btn-chip flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-bold text-chip-indigo-text border border-chip-indigo-border",children:[y.jsx(sD,{className:"h-3 w-3"})," Add Field"]})]})]}),y.jsxs("div",{className:"max-h-48 space-y-2 overflow-y-auto pr-1 custom-scrollbar",children:[f.map((ne,L)=>y.jsxs("div",{className:"flex gap-2 items-center slide-in",children:[y.jsx("input",{type:"text",placeholder:"key",value:ne.key,onChange:ee=>z(L,"key",ee.target.value),className:"w-1/3 rounded border border-line bg-elevated px-2 py-1 text-xs text-ink focus:border-indigo-500 focus:outline-none"}),y.jsx("input",{type:"text",placeholder:"value",value:ne.value,onChange:ee=>z(L,"value",ee.target.value),className:"flex-1 rounded border border-line bg-elevated px-2 py-1 text-xs text-ink focus:border-indigo-500 focus:outline-none"}),y.jsx("button",{onClick:()=>q(L),className:"p-1 text-ink-muted hover:text-status-danger-text transition-colors","aria-label":"Remove field",children:y.jsx(sO,{className:"h-3.5 w-3.5"})})]},L)),f.length===0&&y.jsx("p",{className:"text-center py-4 text-xs text-ink-muted italic",children:"No fields defined"})]})]}),y.jsxs("div",{className:"pt-2 border-t border-line",children:[y.jsx("label",{className:"text-[10px] font-medium text-ink-muted uppercase tracking-wider block mb-1.5",children:"Raw Preview"}),y.jsx("div",{className:"rounded bg-elevated p-2 font-mono text-[10px] text-ink-secondary break-all border border-line",children:a||y.jsx("span",{className:"italic text-ink-muted/50",children:"empty"})})]})]})]})}):null}const Y2=["Bytes","KB","MB","GB","TB"];function xA(n){if(n===0)return"0 Bytes";const e=1024,t=Math.max(0,Math.min(Y2.length-1,Math.floor(Math.log(n)/Math.log(e))));return parseFloat((n/Math.pow(e,t)).toFixed(2))+" "+Y2[t]}function c8(n){const e=Math.max(n.lastIndexOf("\\"),n.lastIndexOf("/"));return e===-1?"":n.slice(0,e)}function u8(n){const e=[`File Properties: ${n.name}`,`Path: ${n.path}`,`Type: ${n.type}`,`Size: ${xA(n.size_bytes)}`,`Created: ${n.created}`,`Modified: ${n.modified}`];return n.md5&&e.push(`MD5: ${n.md5}`),n.sha256&&e.push(`SHA256: ${n.sha256}`),e.join(` -`)}function D0(n,e,t){return n.length<=e+t+1?n:`${n.slice(0,e)}…${n.slice(-t)}`}function f8(n){const e=n.includes("\\")?"\\":"/",t=n.split(/[\\/]/);return t.length<=5?n:[t[0],t[1],"…",t[t.length-2],t[t.length-1]].join(e)}const h8=[{ms:1e3*60,unit:"minute"},{ms:1e3*60*60,unit:"hour"},{ms:1e3*60*60*24,unit:"day"},{ms:1e3*60*60*24*30,unit:"month"},{ms:1e3*60*60*24*365,unit:"year"}];function G2(n,e=new Date){const t=new Date(n.replace(" ","T"));if(Number.isNaN(t.getTime()))return"just now";const i=e.getTime()-t.getTime();if(i<6e4)return"just now";let l="just now";for(const{ms:o,unit:a}of h8){if(i{var F;n||((F=M.current)==null||F.focus(),v(!1))},[n]),D.useEffect(()=>{if(!n||!e)return;const F=new AbortController;return I.current=F,o(null),N(null),u(!0),d(null),(async()=>{try{const se=await RM(e.path,F.signal);if(I.current!==F)return;o(se)}catch(se){if(I.current!==F||se instanceof DOMException&&se.name==="AbortError")return;d(se instanceof Error?se.message:"Failed to load properties")}finally{I.current===F&&u(!1)}})(),()=>{I.current=null,F.abort()}},[n,e]),D.useEffect(()=>{if(!n)return;const F=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=F}},[n]),D.useEffect(()=>{if(!n)return;const F=se=>{if(se.key==="Escape"){if(b)return;t();return}if(se.key!=="Tab")return;const he=R.current;if(!he)return;const ne=Array.from(he.querySelectorAll('button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(le=>le.offsetParent!==null);if(ne.length===0)return;const L=ne[0],ee=ne[ne.length-1],oe=document.activeElement instanceof HTMLElement?document.activeElement:null;se.shiftKey?(oe===L||!he.contains(oe))&&(se.preventDefault(),ee.focus()):oe===ee&&(se.preventDefault(),L.focus())};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[n,b,t]),D.useEffect(()=>{if(!n)return;const F=document.activeElement instanceof HTMLElement?document.activeElement:null;M.current=F;const se=requestAnimationFrame(()=>{var he,ne;(ne=(he=R.current)==null?void 0:he.querySelector("button"))==null||ne.focus()});return()=>cancelAnimationFrame(se)},[n]);const U=async(F,se)=>{try{await navigator.clipboard.writeText(F),g(se),setTimeout(()=>g(null),2e3)}catch(he){console.error("Failed to copy:",he)}},E=async(F,se,he)=>{S(F),N(null);try{await he(),N(se)}catch{N("Action failed")}finally{S(null)}},T=F=>`btn btn-chip rounded-md border px-3 py-2 text-xs ${{reveal:"bg-chip-sky-bg text-chip-sky-text border-chip-sky-border",launch:"border-emerald-500/30 bg-emerald-600 font-semibold text-white hover:bg-emerald-500",folder:"bg-chip-amber-bg text-chip-amber-text border-chip-amber-border"}[F]??"bg-chip-indigo-bg text-chip-indigo-text border-chip-indigo-border"}`,z=(F,se,he,ne=!1,L)=>y.jsxs("div",{className:"flex items-start gap-2 py-1.5 group",children:[y.jsxs("span",{className:"text-ink-muted min-w-[100px] text-xs",children:[F,":"]}),y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("span",{className:`text-ink text-xs break-all ${ne?"font-mono":""}`,children:L??se})}),y.jsx(Qe,{text:"Copy to clipboard",block:!1,children:y.jsx("button",{onClick:()=>U(se,he),className:"opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-elevated","aria-label":`Copy ${F}`,children:m===he?y.jsx(_r,{className:"h-3.5 w-3.5 text-status-success-text"}):y.jsx(ci,{className:"h-3.5 w-3.5 text-ink-muted"})})})]}),ie=(F,se,he)=>y.jsxs("div",{className:"rounded-lg border border-line bg-elevated p-4",children:[y.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[se,y.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-ink-muted",children:F})]}),he]}),q=()=>y.jsx(Qe,{text:"Click to copy full path",children:y.jsxs("button",{onClick:()=>void U(l.path,"path"),className:"group mb-3 flex w-full items-center gap-2 rounded-lg border border-line bg-elevated px-3 py-2 text-left hover:bg-surface",children:[y.jsx(Ou,{className:"text-chip-amber-text h-4 w-4 flex-shrink-0"}),y.jsx("span",{className:"text-ink min-w-0 flex-1 truncate font-mono text-xs",children:f8(l.path)}),m==="path"?y.jsx(_r,{className:"text-status-success-text h-3.5 w-3.5"}):y.jsx(ci,{className:"text-ink-muted h-3.5 w-3.5"})]})});if(!n||!e)return null;const J=e;return y.jsxs("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 backdrop-blur-md p-4",role:"dialog","aria-modal":"true","aria-labelledby":"properties-modal-title",children:[y.jsx("div",{className:"absolute inset-0",onClick:t,onContextMenu:F=>{F.preventDefault(),t()}}),y.jsxs("div",{ref:R,className:"animate-modal-in relative w-full max-w-4xl max-h-[90vh] overflow-hidden rounded-xl border border-frame-line glass-panel flex flex-col",children:[y.jsx("div",{className:"flex-shrink-0 border-b border-line px-6 py-4",children:y.jsxs("div",{className:"flex items-start justify-between gap-4",children:[y.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[y.jsx("div",{className:"rounded-lg bg-indigo-600 p-2 flex-shrink-0",children:y.jsx(Wg,{className:"h-5 w-5 text-white"})}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("h3",{id:"properties-modal-title",className:"text-base font-semibold text-ink truncate",children:"File Properties"}),y.jsx("p",{className:"text-xs text-ink-muted truncate",children:e.filename})]}),y.jsx(Qe,{text:"Copy all properties to clipboard",block:!1,children:y.jsx("button",{onClick:()=>{l&&U(u8(l),"all")},disabled:!l||a||f!==null,className:"btn-chip ml-2 flex items-center gap-1 rounded-md border border-chip-indigo-border bg-chip-indigo-bg p-1.5 text-chip-indigo-text","aria-label":"Copy all properties",children:m==="all"?y.jsx(_r,{className:"h-4 w-4 text-status-success-text"}):y.jsx(ci,{className:"h-4 w-4"})})}),y.jsx(Qe,{text:"Generate Barcode/QR Code",block:!1,children:y.jsx("button",{onClick:()=>v(!0),className:"btn-chip rounded-md border border-chip-indigo-border bg-chip-indigo-bg p-1.5 text-chip-indigo-text",children:y.jsx(xy,{className:"h-4 w-4"})})})]}),y.jsx("button",{onClick:t,className:"focus-ring rounded-md p-1 text-ink-muted hover:bg-elevated hover:text-ink flex-shrink-0","aria-label":"Close",children:y.jsx(Ei,{className:"h-4 w-4"})})]})}),y.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:[a&&y.jsx("div",{className:"flex items-center justify-center py-8",children:y.jsxs("div",{className:"flex flex-col items-center gap-2",children:[y.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent"}),y.jsx("p",{className:"text-xs text-ink-muted",children:"Loading properties..."})]})}),f&&y.jsx("div",{className:"rounded-lg border border-status-danger-border bg-status-danger-bg p-4 text-center",children:y.jsx("p",{className:"text-xs text-status-danger-text",children:f})}),l&&!a&&!f&&y.jsxs("div",{children:[y.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 rounded-lg border border-line bg-elevated px-4 py-2.5",children:[y.jsx("span",{className:"inline-flex items-center gap-1 rounded-md border border-chip-indigo-border bg-chip-indigo-bg px-2 py-0.5 text-xs font-semibold text-chip-indigo-text",children:l.type}),l.attributes.extension&&y.jsx("span",{className:"inline-flex items-center rounded-md border border-line bg-surface px-2 py-0.5 text-xs font-medium text-ink-muted",children:l.attributes.extension}),y.jsxs("span",{className:"text-xs text-ink-muted",title:`${l.size_bytes} bytes`,children:["Size ",y.jsx("strong",{className:"text-ink font-medium",children:xA(l.size_bytes)})]}),y.jsxs("span",{className:"text-xs text-ink-muted",title:l.created,children:["Created ",y.jsx("strong",{className:"text-ink font-medium",children:G2(l.created)})]}),y.jsxs("span",{className:"text-xs text-ink-muted",title:l.modified,children:["Modified ",y.jsx("strong",{className:"text-ink font-medium",children:G2(l.modified)})]}),l.md5&&y.jsx("span",{className:"inline-flex items-center rounded-md border border-chip-purple-border bg-chip-purple-bg px-2 py-0.5 font-mono text-xs font-medium text-chip-purple-text",title:`MD5 ${l.md5}`,children:D0(l.md5,4,4)}),l.attributes.is_symlink&&y.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-chip-fuchsia-border bg-chip-fuchsia-bg px-2 py-0.5 text-xs font-medium text-chip-fuchsia-text",children:[y.jsx(K4,{className:"h-3 w-3"})," Symlink"]})]}),q(),y.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[ie("Hashes",y.jsx(oa,{className:"text-chip-purple-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[z("MD5",l.md5,"md5",!0,D0(l.md5,10,6)),z("SHA256",l.sha256,"sha256",!0,D0(l.sha256,10,6))]})),ie("Timestamps",y.jsx(r4,{className:"text-chip-sky-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[z("Created",l.created,"created",!0),z("Modified",l.modified,"modified",!0)]})),ie("Identity",y.jsx(Wg,{className:"text-chip-indigo-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[z("Type",l.type,"type"),l.attributes.stem&&z("Stem",l.attributes.stem,"attrStem"),z("Extension",l.name.includes(".")?l.name.slice(l.name.lastIndexOf(".")):"None","extension"),z("Directory",c8(l.path)||"None","directory",!0)]})),ie("System",y.jsx(Wg,{className:"text-status-success-text h-3.5 w-3.5"}),y.jsxs("div",{children:[y.jsxs("div",{className:"mb-1 flex min-h-[24px] flex-wrap items-center gap-1.5",children:[l.attributes.is_readonly&&y.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-status-danger-border bg-status-danger-bg px-2 py-0.5 text-xs text-status-danger-text",children:[y.jsx(J4,{className:"h-3 w-3"})," Read-only"]}),l.attributes.is_hidden&&y.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-slate-500/30 bg-slate-600/20 px-2 py-0.5 text-xs text-slate-300",children:[y.jsx(T4,{className:"h-3 w-3"})," Hidden"]}),!l.attributes.is_readonly&&!l.attributes.is_hidden&&!l.attributes.is_symlink&&y.jsx("span",{className:"text-xs text-ink-muted",children:"No special flags"})]}),y.jsxs("div",{className:"space-y-0.5",children:[z("File Type",l.attributes.is_file?"Regular File":l.attributes.is_dir?"Directory":"Other","fileType"),l.attributes.permissions&&z("Permissions",l.attributes.permissions,"permissions",!0),l.attributes.owner_uid!==void 0&&z("Owner UID",String(l.attributes.owner_uid),"ownerUid"),l.attributes.group_gid!==void 0&&z("Group GID",String(l.attributes.group_gid),"groupGid")]})]}))]})]})]}),y.jsx("div",{className:"flex-shrink-0 border-t border-line px-6 py-3",children:y.jsxs("div",{className:"flex justify-between items-center gap-2",children:[y.jsx("p",{className:"min-w-0 text-xs text-ink-muted truncate",children:C??"Click the copy icon next to any field to copy its value"}),y.jsxs("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[y.jsx(Qe,{text:"Show file in Explorer",block:!1,children:y.jsxs("button",{onClick:()=>void E("reveal","Revealed in Explorer",()=>KC(J.path)),disabled:w!==null,className:T("reveal"),children:[y.jsx(G0,{className:"h-3.5 w-3.5"})," Reveal"]})}),y.jsx(Qe,{text:"Launch file with default association",block:!1,children:y.jsxs("button",{onClick:()=>{i&&(S("launch"),Promise.resolve(i(J)).finally(()=>S(null)))},disabled:w!==null||!i,className:T("launch"),children:[y.jsx(ts,{className:"h-3.5 w-3.5"})," Launch"]})}),y.jsx(Qe,{text:"Open containing folder",block:!1,children:y.jsxs("button",{onClick:()=>void E("folder","Opened folder",()=>Y0(J.path)),disabled:w!==null,className:T("folder"),children:[y.jsx(Jl,{className:"h-3.5 w-3.5"})," Open Folder"]})}),y.jsx("button",{onClick:t,className:"btn btn-primary px-4 py-2",children:"Close"})]})]})})]}),y.jsx(gA,{isOpen:b,onClose:()=>v(!1),initialFilePath:e.path,md5:l==null?void 0:l.md5})]})}const m8=["qr_code","code_128","code_39","ean_13","ean_8","upc_a","upc_e","data_matrix"],p8=250,g8=400,x8=.7;function y8(n,e=g8,t=x8){const i=n.videoWidth,l=n.videoHeight;if(!i||!l)return null;const o=Math.min(i,l),a=document.createElement("canvas");a.width=Math.min(e,o),a.height=a.width;const u=a.getContext("2d");if(!u)return null;u.drawImage(n,(i-o)/2,(l-o)/2,o,o,0,0,a.width,a.height);const f=a.toDataURL("image/jpeg",t);return f.slice(f.indexOf(",")+1)}function b8(n,e){const t=n.intervalMs??p8;let i=!1,l=!1;const o=()=>{i=!0,clearInterval(a)},a=setInterval(()=>{if(i||l)return;const u=n.capture();u&&(l=!0,n.decode(u).then(f=>{i||f.decoded&&(o(),e.onDetected(f.decoded))}).catch(f=>{i||(o(),e.onError(f instanceof Error?f.message:"Frame decoding failed"))}).finally(()=>{l=!1}))},t);return o}const v8=8e3;function w8({isOpen:n,onClose:e,onDetected:t}){const i=D.useRef(null),l=D.useRef(null),o=hs({isOpen:n,onClose:e,dialogRef:l}),a=D.useRef(null),u=D.useRef(null),f=D.useRef(null),[d,m]=D.useState(null),[g,b]=D.useState(!1),v=()=>{f.current&&(f.current(),f.current=null),u.current&&(cancelAnimationFrame(u.current),u.current=null),a.current&&(a.current.getTracks().forEach(C=>C.stop()),a.current=null),i.current&&(i.current.srcObject=null)};D.useEffect(()=>{if(!n){v(),m(null);return}let C=!0;async function N(){var M,I,U,E,T;if(m(null),b(!1),typeof window<"u"&&!window.isSecureContext&&window.location.hostname!=="localhost"&&window.location.hostname!=="127.0.0.1"){m("Camera access requires HTTPS or localhost. If connecting across a local network IP (e.g. 192.168.x.x), modern browsers disable camera access for insecure HTTP.");return}const R=((I=(M=navigator.mediaDevices)==null?void 0:M.getUserMedia)==null?void 0:I.bind(navigator.mediaDevices))||((U=navigator.getUserMedia)==null?void 0:U.bind(navigator))||((E=navigator.webkitGetUserMedia)==null?void 0:E.bind(navigator))||((T=navigator.mozGetUserMedia)==null?void 0:T.bind(navigator));if(!R){m(window.isSecureContext?"Camera access is not supported by your browser or environment.":"Camera access is blocked because the page is not served over a secure origin (HTTPS or localhost/127.0.0.1).");return}try{let z;const ie=await Promise.race([R({video:{facingMode:"environment",width:{ideal:1280},height:{ideal:720}}}),new Promise((q,J)=>{z=window.setTimeout(()=>J(new DOMException("Camera did not start in time","TimeoutError")),v8)})]).finally(()=>{z!==void 0&&window.clearTimeout(z)});if(!C){ie.getTracks().forEach(q=>q.stop());return}a.current=ie,i.current&&(i.current.srcObject=ie,await i.current.play()),"BarcodeDetector"in window?S():w()}catch(z){if(!C)return;console.error("Camera access error:",z),m(z.name==="NotAllowedError"||z.name==="PermissionDeniedError"?"Camera permission denied. Please allow camera access in your browser settings.":z.name==="TimeoutError"?"The camera did not start in time. On macOS, camera capture needs the packaged desktop app — a bare Python process cannot access the camera. Alternatively, open ProFiles in Chrome, Edge or Safari.":`Could not access camera: ${z.message||"Unknown error"}`)}}return N(),()=>{C=!1,v()}},[n]);const w=()=>{b(!0),f.current=b8({capture:()=>i.current?y8(i.current):null,decode:C=>jM({imageBase64:C,formats:[...m8]})},{onDetected:C=>{v(),t(C)},onError:C=>{v(),m(C)}})},S=()=>{const C=["qr_code","code_128","code_39","ean_13","ean_8","upc_a","upc_e","data_matrix"];let N;try{N=new window.BarcodeDetector({formats:C})}catch(M){console.warn("BarcodeDetector formats unsupported:",M),N=new window.BarcodeDetector}const R=async()=>{if(!i.current||i.current.readyState<2){u.current=requestAnimationFrame(R);return}try{const M=await N.detect(i.current);if(M&&M.length>0){const I=M[0].rawValue;if(I){v(),t(I);return}}}catch(M){console.debug("Frame detection error:",M)}u.current=requestAnimationFrame(R)};u.current=requestAnimationFrame(R)};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm",onClick:e,children:y.jsxs("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":"Camera barcode scanner",onKeyDown:o,className:"relative w-full max-w-lg rounded-2xl border border-frame-line glass-panel p-6 flex flex-col",onClick:C=>C.stopPropagation(),children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink",children:[y.jsx(JC,{className:"h-5 w-5 text-chip-indigo-text"}),y.jsx("span",{children:"Scan with Camera"})]}),y.jsx("button",{onClick:e,className:"focus-ring rounded-lg p-1 text-ink-muted hover:bg-elevated hover:text-ink transition-colors","aria-label":"Close",children:y.jsx(Ei,{className:"h-4 w-4"})})]}),d?y.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[y.jsx("div",{className:"rounded-full bg-status-danger-bg p-3 text-status-danger-text mb-3",children:y.jsx(Gc,{className:"h-6 w-6"})}),y.jsx("p",{className:"text-xs text-status-danger-text max-w-xs",children:d}),y.jsx("button",{onClick:e,className:"btn btn-secondary mt-6 px-4 py-2",children:"Close"})]}):y.jsxs("div",{className:"flex flex-col items-center",children:[y.jsxs("div",{className:"relative aspect-video w-full overflow-hidden rounded-xl bg-black border border-line flex items-center justify-center",children:[y.jsx("video",{ref:i,playsInline:!0,muted:!0,className:"h-full w-full object-cover"}),y.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:y.jsxs("div",{className:"relative h-48 w-48 rounded-lg border-2 border-dashed border-indigo-400/80 bg-indigo-500/5 shadow-[0_0_0_9999px_rgba(0,0,0,0.45)]",children:[y.jsx("div",{className:"absolute top-0 left-0 h-4 w-4 border-t-2 border-l-2 border-indigo-400"}),y.jsx("div",{className:"absolute top-0 right-0 h-4 w-4 border-t-2 border-r-2 border-indigo-400"}),y.jsx("div",{className:"absolute bottom-0 left-0 h-4 w-4 border-b-2 border-l-2 border-indigo-400"}),y.jsx("div",{className:"absolute bottom-0 right-0 h-4 w-4 border-b-2 border-r-2 border-indigo-400"})]})})]}),y.jsx("p",{className:"mt-4 text-center text-xs text-ink-muted",children:g?"Hold a QR code or barcode steady in front of your camera — frames are decoded by the local ProFiles server (no native Barcode Detector in this browser).":"Hold a QR code or barcode steady in front of your camera to auto-scan."})]})]})}):null}function k8({isOpen:n,file:e,onConfirm:t,onDismiss:i}){const l=D.useRef(null);return D.useEffect(()=>{var o;if(n){const a=u=>{u.key==="Enter"?(u.preventDefault(),t()):u.key==="Escape"&&(u.preventDefault(),i())};return window.addEventListener("keydown",a),(o=l.current)==null||o.focus(),()=>window.removeEventListener("keydown",a)}},[n,t,i]),!n||!e?null:y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",onClick:i,children:y.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":`1 file matched: ${e.filename}`,className:"animate-modal-in w-full max-w-sm rounded-xl border border-frame-line glass-panel p-5 flex flex-col gap-4",onClick:o=>o.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink text-sm",children:[e.has_hook?y.jsx(ED,{className:"h-4 w-4 text-chip-purple-text"}):y.jsx(ts,{className:"h-4 w-4 text-status-success-text"}),y.jsx("span",{children:"1 File Matched"})]}),y.jsx("button",{onClick:i,className:"focus-ring rounded p-1 text-ink-muted hover:bg-elevated hover:text-ink","aria-label":"Dismiss",children:y.jsx(Ei,{className:"h-4 w-4"})})]}),y.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-line bg-elevated/50 p-3",children:[y.jsx(ka,{className:"h-5 w-5 text-chip-indigo-text shrink-0 mt-0.5"}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("h4",{className:"text-xs font-semibold text-ink truncate",children:e.filename}),y.jsx("p",{className:"text-[11px] text-ink-muted truncate mt-0.5",children:e.rel_path||e.path}),e.has_hook&&y.jsx("span",{className:"inline-block mt-1 text-[10px] text-chip-purple-text bg-chip-purple-bg px-1.5 py-0.5 rounded border border-chip-purple-border/50 font-medium",children:"Workflow Hook Configured"})]})]}),y.jsx("p",{className:"text-xs text-ink-muted text-center",children:"Launch this file now?"}),y.jsxs("div",{className:"flex gap-2",children:[y.jsx("button",{type:"button",onClick:i,className:"btn btn-secondary flex-1 px-3 py-1.5",children:"Dismiss (Esc)"}),y.jsxs("button",{ref:l,type:"button",onClick:t,className:"btn btn-primary flex-1 px-3 py-1.5 shadow-md",children:[y.jsx(ts,{className:"h-3 w-3 fill-current"}),"Launch (Enter)"]})]})]})})}function S8({systemInfo:n,fileCount:e,theme:t,onToggleTheme:i,onOpenLog:l,onOpenConfig:o,onShowShortcuts:a,onReloadConfig:u,onExport:f,exportDisabled:d=!1,language:m="en",onLanguageChange:g,lanEnabled:b,onToggleLan:v}){return y.jsxs("footer",{className:"flex items-center justify-between border-t border-line bg-app px-4 py-2 text-[11px] text-ink-muted transition-colors duration-200",children:[y.jsx("div",{className:"flex items-center gap-4",children:n&&y.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-line bg-surface px-2.5 py-0.5 text-ink-secondary",children:[y.jsx(XM,{className:"h-3 w-3 text-status-success-text"}),y.jsx("a",{href:`http://${n.hostname}:${window.location.port}`,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ProFiles on ${n.hostname}`,className:"font-mono hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 rounded px-1 py-0.5",children:n.hostname}),y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsx("a",{href:`http://${n.ip}:${window.location.port}`,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ProFiles on ${n.ip}`,className:"font-mono hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 rounded px-1 py-0.5",children:n.ip}),y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsxs("span",{className:"flex items-center gap-1",title:"Session user",children:[y.jsx(ND,{className:"h-3 w-3 text-ink-faint"}),y.jsx("span",{children:n.username||"operator"})]}),v!==void 0&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsx(Qe,{text:"LAN access",block:!1,children:y.jsxs("button",{onClick:()=>v(b!==!0),disabled:b===null,"aria-pressed":b===!0,className:`focus-ring flex items-center gap-1 rounded px-1 py-0.5 text-[10px] ${b===null?"text-ink-faint cursor-not-allowed":b===!0?"text-status-success-text":"text-ink-muted hover:text-ink"}`,children:[y.jsx(iD,{className:"h-3 w-3"}),y.jsx("span",{children:"LAN"})]})})]})]})}),y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsxs("span",{children:[y.jsx("strong",{className:"text-ink",children:e})," files found"]}),y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsx(Qe,{text:"Keyboard shortcuts (?)",block:!1,children:y.jsxs("button",{onClick:a,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(nO,{className:"h-3 w-3"}),y.jsx("span",{children:"Shortcuts"})]})}),y.jsx(Qe,{text:"Open the application log viewer",block:!1,children:y.jsxs("button",{onClick:l,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(ka,{className:"h-3 w-3"}),y.jsx("span",{children:"Logs"})]})}),y.jsx("span",{className:"text-ink-faint",children:"|"}),u&&y.jsx(Qe,{text:"Reload configuration from disk",block:!1,children:y.jsxs("button",{onClick:u,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(Yd,{className:"h-3 w-3"}),y.jsx("span",{children:"Reload"})]})}),f&&y.jsx(Qe,{text:"Export the current results as CSV",block:!1,children:y.jsxs("button",{onClick:f,disabled:d,className:"focus-ring flex items-center gap-1 rounded text-ink-muted hover:text-ink disabled:opacity-40 disabled:hover:text-ink-muted",children:[y.jsx(eO,{className:"h-3 w-3"}),y.jsx("span",{children:"Export CSV"})]})}),g&&y.jsxs("div",{className:"flex items-center overflow-hidden rounded border border-line text-[10px]",children:[y.jsx(Qe,{text:"English",block:!1,children:y.jsxs("button",{onClick:()=>g("en"),className:`flex items-center gap-1 px-1.5 py-0.5 transition-colors ${m==="en"?"bg-indigo-600 text-white focus-ring":"text-ink-muted hover:text-ink focus-ring"}`,children:[y.jsx(V4,{className:"h-3 w-3"}),y.jsx("span",{children:"EN"})]})}),y.jsx(Qe,{text:"Français",block:!1,children:y.jsx("button",{onClick:()=>g("fr"),className:`flex items-center gap-1 px-1.5 py-0.5 transition-colors ${m==="fr"?"bg-indigo-600 text-white focus-ring":"text-ink-muted hover:text-ink focus-ring"}`,children:y.jsx("span",{children:"FR"})})})]}),y.jsx(Qe,{text:"Open the configuration editor",block:!1,children:y.jsxs("button",{onClick:o,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(yD,{className:"h-3 w-3"}),y.jsx("span",{children:"Config"})]})}),y.jsx(Qe,{text:`Switch to ${t==="dark"?"light":"dark"} mode`,block:!1,children:y.jsxs("button",{onClick:i,className:"focus-ring flex items-center gap-1 rounded px-1.5 py-0.5 text-ink-muted hover:bg-elevated hover:text-status-warning-text",children:[t==="dark"?y.jsx(vD,{className:"h-3 w-3 text-status-warning-text"}):y.jsx(tD,{className:"h-3 w-3 text-chip-indigo-text"}),y.jsx("span",{children:t==="dark"?"Light":"Dark"})]})})]})]})}const C8=[{label:"5 seconds",seconds:5},{label:"10 seconds",seconds:10},{label:"30 seconds",seconds:30},{label:"1 minute",seconds:60},{label:"5 minutes",seconds:300}];function O8({isOpen:n,currentInterval:e,onClose:t,onSetInterval:i}){const l=D.useRef(null),o=hs({isOpen:n,onClose:t,dialogRef:l});if(!n)return null;const a=e>0,u=m=>{i(m)},f=m=>{m.preventDefault();const b=m.currentTarget.elements.namedItem("custom-interval"),v=parseInt(b.value,10);!isNaN(v)&&v>0&&i(v)},d=()=>{i(0)};return y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:y.jsxs("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":"Auto-Rescan Timer",onKeyDown:o,className:"animate-modal-in w-[420px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink",children:[y.jsx(lO,{className:"h-5 w-5 text-chip-indigo-text"}),y.jsx("span",{children:"Auto-Rescan Timer"})]}),y.jsx("button",{onClick:t,className:"focus-ring rounded-lg p-1 text-ink-muted hover:bg-elevated hover:text-ink",children:y.jsx(Ei,{className:"h-4 w-4"})})]}),y.jsx("div",{className:"mb-4 rounded-lg bg-elevated/50 px-3 py-2 text-xs",children:a?y.jsxs("div",{className:"flex items-center gap-2 text-status-success-text",children:[y.jsx(b4,{className:"h-4 w-4 animate-pulse"}),y.jsxs("span",{children:["Auto-rescan every ",e,"s"]})]}):y.jsxs("div",{className:"flex items-center gap-2 text-ink-secondary",children:[y.jsx(x4,{className:"h-4 w-4"}),y.jsx("span",{children:"Auto-rescan is disabled"})]})}),y.jsxs("div",{className:"mb-4 space-y-1 text-xs",children:[y.jsx("p",{className:"text-ink-muted",children:"Presets:"}),y.jsx("div",{className:"grid grid-cols-2 gap-2",children:C8.map(m=>y.jsx("button",{onClick:()=>u(m.seconds),className:"rounded-lg border border-line bg-elevated/50 px-3 py-1.5 text-left font-medium text-ink-secondary hover:border-chip-indigo-border hover:bg-chip-indigo-bg/40 hover:text-chip-indigo-text focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:m.label},m.seconds))})]}),y.jsxs("form",{onSubmit:f,className:"mb-4",children:[y.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-ink-secondary",children:[y.jsx(k4,{className:"h-3.5 w-3.5"}),y.jsx("span",{children:"Custom interval (seconds):"})]}),y.jsxs("div",{className:"mt-1 flex gap-2",children:[y.jsx("input",{type:"number",name:"custom-interval",min:"1",placeholder:"e.g. 45",className:"flex-1 rounded-lg border border-line bg-app px-2 py-1 text-xs text-ink placeholder-ink-faint focus:border-indigo-500 focus:outline-none"}),y.jsx("button",{type:"submit",className:"btn btn-primary rounded-lg px-3 py-1 font-semibold",children:"Set"})]})]}),a&&y.jsx("button",{onClick:d,className:"btn w-full rounded-lg border-line bg-elevated/50 px-3 py-2 text-status-warning-text hover:border-status-warning-border hover:bg-status-warning-bg/40",children:"Stop Auto-Rescan"}),y.jsx("div",{className:"flex justify-end gap-2 border-t border-line pt-3",children:y.jsx("button",{onClick:t,className:"rounded-lg border border-line bg-elevated px-4 py-2 text-xs font-semibold text-ink-secondary hover:bg-elevated/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:"Close"})})]})})}function N8(n,e){const t={};return(n[n.length-1]===""?[...n,""]:n).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}const T8=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,A8=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,E8={};function K2(n,e){return(E8.jsx?A8:T8).test(n)}const M8=/[ \t\n\f\r]/g;function D8(n){return typeof n=="object"?n.type==="text"?W2(n.value):!1:W2(n)}function W2(n){return n.replace(M8,"")===""}class Ru{constructor(e,t,i){this.normal=t,this.property=e,i&&(this.space=i)}}Ru.prototype.normal={};Ru.prototype.property={};Ru.prototype.space=void 0;function yA(n,e){const t={},i={};for(const l of n)Object.assign(t,l.property),Object.assign(i,l.normal);return new Ru(t,i,e)}function Jx(n){return n.toLowerCase()}class gi{constructor(e,t){this.attribute=t,this.property=e}}gi.prototype.attribute="";gi.prototype.booleanish=!1;gi.prototype.boolean=!1;gi.prototype.commaOrSpaceSeparated=!1;gi.prototype.commaSeparated=!1;gi.prototype.defined=!1;gi.prototype.mustUseProperty=!1;gi.prototype.number=!1;gi.prototype.overloadedBoolean=!1;gi.prototype.property="";gi.prototype.spaceSeparated=!1;gi.prototype.space=void 0;let j8=0;const Fe=oo(),an=oo(),ey=oo(),ge=oo(),At=oo(),to=oo(),Ni=oo();function oo(){return 2**++j8}const ty=Object.freeze(Object.defineProperty({__proto__:null,boolean:Fe,booleanish:an,commaOrSpaceSeparated:Ni,commaSeparated:to,number:ge,overloadedBoolean:ey,spaceSeparated:At},Symbol.toStringTag,{value:"Module"})),j0=Object.keys(ty);class rb extends gi{constructor(e,t,i,l){let o=-1;if(super(e,t),Z2(this,"space",l),typeof i=="number")for(;++o4&&t.slice(0,4)==="data"&&B8.test(e)){if(e.charAt(4)==="-"){const o=e.slice(5).replace(J2,I8);i="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=e.slice(4);if(!J2.test(o)){let a=o.replace(z8,H8);a.charAt(0)!=="-"&&(a="-"+a),e="data"+a}}l=rb}return new l(i,e)}function H8(n){return"-"+n.toLowerCase()}function I8(n){return n.charAt(1).toUpperCase()}const U8=yA([bA,R8,kA,SA,CA],"html"),lb=yA([bA,_8,kA,SA,CA],"svg");function F8(n){return n.join(" ").trim()}var eC=/\/\*(?:[^*]|\*(?!\/))*\*\//g,q8=/\n/g,V8=/^\s*/,Q8=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,X8=/^:\s*/,$8=/^((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|url\((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|[^)]*)\)|[^};])+)/,Y8=/^[;\s]*/,G8=` -`,tC="/",nC="*",Uc="",K8="comment",W8="declaration";function Z8(n,e){if(typeof n!="string")throw new TypeError("First argument must be a string");if(!n)return[];e=e||{};var t=1,i=1;function l(w){var S=w.match(q8);S&&(t+=S.length);var C=w.lastIndexOf(G8);i=~C?w.length-C:i+w.length}function o(){var w={line:t,column:i};return function(S){return S.position=new a(w),d(),S}}function a(w){this.start=w,this.end={line:t,column:i},this.source=e.source}a.prototype.content=n;function u(w){var S=new Error(e.source+":"+t+":"+i+": "+w);if(S.reason=w,S.filename=e.source,S.line=t,S.column=i,S.source=n,!e.silent)throw S}function f(w){var S=w.exec(n);if(S){var C=S[0];return l(C),n=n.slice(C.length),S}}function d(){f(V8)}function m(w){for(var S;S=g();)w.push(S);return w}function g(){var w=o();if(!(tC!=n.charAt(0)||nC!=n.charAt(1))){for(var S=2;Uc!=n.charAt(S)&&(nC!=n.charAt(S)||tC!=n.charAt(S+1));)++S;if(S+=2,Uc===n.charAt(S-1))return u("End of comment missing");var C=n.slice(2,S-2);return i+=2,l(C),n=n.slice(S),i+=2,w({type:K8,comment:C})}}function b(){var w=o(),S=f(Q8);if(S){if(g(),!f(X8))return u("property missing ':'");var C=f($8),N=w({type:W8,property:S[0].replace(eC,Uc).trim(),value:C?C[0].replace(eC,Uc).trim():Uc});return f(Y8),N}}function v(){var w=[];m(w);for(var S;S=b();)w.push(S),m(w);return w}return d(),v()}function J8(n,e){let t=null;if(!n||typeof n!="string")return t;const i=Z8(n),l=typeof e=="function";return i.forEach(o=>{if(o.type!=="declaration")return;const{property:a,value:u}=o;l?e(a,u,o):u&&(t=t??{},t[a]=u)}),t}const OA=NA("end"),sb=NA("start");function NA(n){return e;function e(t){const i=t&&t.position&&t.position[n]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function eP(n){const e=sb(n),t=OA(n);if(e&&t)return{start:e,end:t}}function ru(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?iC(n.position):"start"in n||"end"in n?iC(n):"line"in n||"column"in n?ny(n):""}function ny(n){return rC(n&&n.line)+":"+rC(n&&n.column)}function iC(n){return ny(n&&n.start)+"-"+ny(n&&n.end)}function rC(n){return n&&typeof n=="number"?n:1}class Fn extends Error{constructor(e,t,i){super(),typeof t=="string"&&(i=t,t=void 0);let l="",o={},a=!1;if(t&&("line"in t&&"column"in t?o={place:t}:"start"in t&&"end"in t?o={place:t}:"type"in t?o={ancestors:[t],place:t.position}:o={...t}),typeof e=="string"?l=e:!o.cause&&e&&(a=!0,l=e.message,o.cause=e),!o.ruleId&&!o.source&&typeof i=="string"){const f=i.indexOf(":");f===-1?o.ruleId=i:(o.source=i.slice(0,f),o.ruleId=i.slice(f+1))}if(!o.place&&o.ancestors&&o.ancestors){const f=o.ancestors[o.ancestors.length-1];f&&(o.place=f.position)}const u=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=l,this.line=u?u.line:void 0,this.name=ru(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Fn.prototype.file="";Fn.prototype.name="";Fn.prototype.reason="";Fn.prototype.message="";Fn.prototype.stack="";Fn.prototype.column=void 0;Fn.prototype.line=void 0;Fn.prototype.ancestors=void 0;Fn.prototype.cause=void 0;Fn.prototype.fatal=void 0;Fn.prototype.place=void 0;Fn.prototype.ruleId=void 0;Fn.prototype.source=void 0;const ob={}.hasOwnProperty,tP=new Map,nP=/[A-Z]/g,iP=/-([a-z])/g,rP=new Set(["table","tbody","thead","tfoot","tr"]),lP=new Set(["td","th"]),TA="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function sP(n,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const t=e.filePath||void 0;let i;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=mP(t,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=dP(t,e.jsx,e.jsxs)}const l={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:i,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:t,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?lb:U8,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},o=AA(l,n,void 0);return o&&typeof o!="string"?o:l.create(n,l.Fragment,{children:o||void 0},void 0)}function AA(n,e,t){if(e.type==="element")return oP(n,e,t);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return aP(n,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return uP(n,e,t);if(e.type==="mdxjsEsm")return cP(n,e);if(e.type==="root")return fP(n,e,t);if(e.type==="text")return hP(n,e)}function oP(n,e,t){const i=n.schema;let l=i;e.tagName.toLowerCase()==="svg"&&i.space==="html"&&(l=lb,n.schema=l),n.ancestors.push(e);const o=MA(n,e.tagName,!1),a=pP(n,e);let u=cb(n,e);return rP.has(e.tagName)&&(u=u.filter(function(f){return typeof f=="string"?!D8(f):!0})),EA(n,a,o,e),ab(a,u),n.ancestors.pop(),n.schema=i,n.create(e,o,a,t)}function aP(n,e){if(e.data&&e.data.estree&&n.evaluater){const i=e.data.estree.body[0];return i.type,n.evaluater.evaluateExpression(i.expression)}Cu(n,e.position)}function cP(n,e){if(e.data&&e.data.estree&&n.evaluater)return n.evaluater.evaluateProgram(e.data.estree);Cu(n,e.position)}function uP(n,e,t){const i=n.schema;let l=i;e.name==="svg"&&i.space==="html"&&(l=lb,n.schema=l),n.ancestors.push(e);const o=e.name===null?n.Fragment:MA(n,e.name,!0),a=gP(n,e),u=cb(n,e);return EA(n,a,o,e),ab(a,u),n.ancestors.pop(),n.schema=i,n.create(e,o,a,t)}function fP(n,e,t){const i={};return ab(i,cb(n,e)),n.create(e,n.Fragment,i,t)}function hP(n,e){return e.value}function EA(n,e,t,i){typeof t!="string"&&t!==n.Fragment&&n.passNode&&(e.node=i)}function ab(n,e){if(e.length>0){const t=e.length>1?e:e[0];t&&(n.children=t)}}function dP(n,e,t){return i;function i(l,o,a,u){const d=Array.isArray(a.children)?t:e;return u?d(o,a,u):d(o,a)}}function mP(n,e){return t;function t(i,l,o,a){const u=Array.isArray(o.children),f=sb(i);return e(l,o,a,u,{columnNumber:f?f.column-1:void 0,fileName:n,lineNumber:f?f.line:void 0},void 0)}}function pP(n,e){const t={};let i,l;for(l in e.properties)if(l!=="children"&&ob.call(e.properties,l)){const o=xP(n,l,e.properties[l]);if(o){const[a,u]=o;n.tableCellAlignToStyle&&a==="align"&&typeof u=="string"&&lP.has(e.tagName)?i=u:t[a]=u}}if(i){const o=t.style||(t.style={});o[n.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return t}function gP(n,e){const t={};for(const i of e.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&n.evaluater){const o=i.data.estree.body[0];o.type;const a=o.expression;a.type;const u=a.properties[0];u.type,Object.assign(t,n.evaluater.evaluateExpression(u.argument))}else Cu(n,e.position);else{const{name:l}=i;let o;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&n.evaluater){const u=i.value.data.estree.body[0];u.type,o=n.evaluater.evaluateExpression(u.expression)}else Cu(n,e.position);else o=i.value===null?!0:i.value;t[l]=o}return t}function cb(n,e){const t=[];let i=-1;const l=n.passKeys?new Map:tP;for(;++il?0:l+e:e=e>l?l:e,t=t>0?t:0,i.length<1e4)a=Array.from(i),a.unshift(e,t),n.splice(...a);else for(t&&n.splice(e,t);o0?(nr(n,n.length,0,e),n):e}const oC={}.hasOwnProperty;function jA(n){const e={};let t=-1;for(;++t13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"�":String.fromCodePoint(t)}function ir(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Rn=ds(/[A-Za-z]/),_n=ds(/[\dA-Za-z]/),TP=ds(/[#-'*+\--9=?A-Z^-~]/);function Ud(n){return n!==null&&(n<32||n===127)}const iy=ds(/\d/),AP=ds(/[\dA-Fa-f]/),_A=ds(/[!-/:-@[-`{-~]/);function Be(n){return n!==null&&n<-2}function Mt(n){return n!==null&&(n<0||n===32)}function Ke(n){return n===-2||n===-1||n===32}const fm=ds(new RegExp("\\p{P}|\\p{S}","u")),lo=ds(/\s/);function ds(n){return e;function e(t){return t!==null&&t>-1&&n.test(String.fromCharCode(t))}}function Ba(n){const e=[];let t=-1,i=0,l=0;for(;++t55295&&o<57344){const u=n.charCodeAt(t+1);o<56320&&u>56319&&u<57344?(a=String.fromCharCode(o,u),l=1):a="�"}else a=String.fromCharCode(o);a&&(e.push(n.slice(i,t),encodeURIComponent(a)),i=t+l+1,a=""),l&&(t+=l,l=0)}return e.join("")+n.slice(i)}function mt(n,e,t,i){const l=i?i-1:1/0;let o=0;return a;function a(f){return Ke(f)?(n.enter(t),u(f)):e(f)}function u(f){return Ke(f)&&o++=l?e(m):t(m)}}const EP={tokenize:MP};function MP(n){const e=n.attempt(this.parser.constructs.contentInitial,i,l);let t;return e;function i(u){if(u===null){n.consume(u);return}return n.enter("lineEnding"),n.consume(u),n.exit("lineEnding"),mt(n,e,"linePrefix")}function l(u){return n.enter("paragraph"),o(u)}function o(u){const f=n.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=f),t=f,a(u)}function a(u){if(u===null){n.exit("chunkText"),n.exit("paragraph"),n.consume(u);return}return Be(u)?(n.consume(u),n.exit("chunkText"),o):(n.consume(u),a)}}let Fd=class{constructor(){this.index=new Map,this.map=[]}add(e,t,i){aC(this,e,t,i,!1)}addBefore(e,t,i){aC(this,e,t,i,!0)}consume(e){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let t=this.map.length;const i=[];for(;t>0;)t-=1,i.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];i.push(e.slice()),e.length=0;let l=i.pop();for(;l;){for(const o of l)e.push(o);l=i.pop()}this.map.length=0,this.index.clear()}};function aC(n,e,t,i,l){if(t===0&&i.length===0)return;const o=n.index.get(e);if(o){o[1]+=t,l?(i.push(...o[2]),o[2]=i):o[2].push(...i);return}const a=[e,t,i];n.map.push(a),n.index.set(e,a)}const DP={tokenize:jP},cC={tokenize:RP};function jP(n){const e=this,t=[];let i=0,l,o,a;return u;function u(M){if(ia))return;const T=e.events.length;let z=T,ie,q;for(;z--;)if(e.events[z][0]==="exit"&&e.events[z][1].type==="chunkFlow"){if(ie){q=e.events[z][1].end;break}ie=!0}for(N(i),E=T;EM;){const U=t[I];e.containerState=U[1],U[0].exit.call(e,n)}t.length=M}function R(){l.write([null]),o=void 0,l=void 0,e.containerState._closeFlow=void 0}}function RP(n,e,t){return mt(n,n.attempt(this.parser.constructs.document,e,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function cs(n){if(n===null||Mt(n)||lo(n))return 1;if(fm(n))return 2}function hm(n,e,t){const i=[];let l=-1;for(;++l1&&n[t][1].end.offset-n[t][1].start.offset>1?2:1,a={...n[l][1].end},u={...n[t][1].start};uC(a,-o),uC(u,o);const f={type:o>1?"strongSequence":"emphasisSequence",start:a,end:{...n[l][1].end}},d={type:o>1?"strongSequence":"emphasisSequence",start:{...n[t][1].start},end:u},m={type:o>1?"strongText":"emphasisText",start:{...n[l][1].end},end:{...n[t][1].start}},g={type:o>1?"strong":"emphasis",start:{...f.start},end:{...d.end}};n[l][1].end={...f.start},n[t][1].start={...d.end},i=[],n[l][1].end.offset-n[l][1].start.offset&&(i=Hi(i,[["enter",n[l][1],e],["exit",n[l][1],e]])),i=Hi(i,[["enter",g,e],["enter",f,e],["exit",f,e],["enter",m,e]]),i=Hi(i,hm(e.parser.constructs.insideSpan.null,n.slice(l+1,t),e)),i=Hi(i,[["exit",m,e],["enter",d,e],["exit",d,e],["exit",g,e]]);let b=0;n[t][1].end.offset-n[t][1].start.offset&&(b=2,i=Hi(i,[["enter",n[t][1],e],["exit",n[t][1],e]])),nr(n,l-1,t-l+3,i),t=l+i.length-b-2;break}}for(t=-1;++t0&&Ke(E)?mt(n,R,"linePrefix",o+1)(E):R(E)}function R(E){return E===null||Be(E)?n.check(ly,S,I)(E):(n.enter("codeFlowValue"),M(E))}function M(E){return E===null||Be(E)?(n.exit("codeFlowValue"),R(E)):(n.consume(E),M)}function I(E){return n.exit("codeFenced"),e(E)}function U(E,T,z){let ie=0;return q;function q(ne){return E.enter("lineEnding"),E.consume(ne),E.exit("lineEnding"),J}function J(ne){return E.enter("codeFencedFence"),Ke(ne)?mt(E,F,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ne):F(ne)}function F(ne){return ne===u?(E.enter("codeFencedFenceSequence"),se(ne)):z(ne)}function se(ne){return ne===u?(ie++,E.consume(ne),se):ie>=a?(E.exit("codeFencedFenceSequence"),Ke(ne)?mt(E,he,"whitespace")(ne):he(ne)):z(ne)}function he(ne){return ne===null||Be(ne)?(E.exit("codeFencedFence"),T(ne)):z(ne)}}}const _0={name:"codeIndented",tokenize:$P},XP={partial:!0,tokenize:YP};function $P(n,e,t){return i;function i(u){return n.enter("codeIndented"),LA(n,l,t,"linePrefix",4,4)(u)}function l(u){return u===null?a(u):Be(u)?n.attempt(XP,l,a)(u):(n.enter("codeFlowValue"),o(u))}function o(u){return u===null||Be(u)?(n.exit("codeFlowValue"),l(u)):(n.consume(u),o)}function a(u){return n.exit("codeIndented"),e(u)}}function YP(n,e,t){const i=this;return l;function l(a){return i.parser.lazy[i.now().line]?t(a):Be(a)?(n.enter("lineEnding"),n.consume(a),n.exit("lineEnding"),l):LA(n,e,o,"linePrefix",4,4)(a)}function o(a){return Be(a)?l(a):t(a)}}const GP={name:"codeText",previous:WP,resolve:KP,tokenize:ZP};function KP(n){let e=n.length-4,t=3,i,l;if((n[t][1].type==="lineEnding"||n[t][1].type==="space")&&(n[e][1].type==="lineEnding"||n[e][1].type==="space")){for(i=t;++i=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return ethis.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(e,t,i){const l=t||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-l,Number.POSITIVE_INFINITY);return i&&Fc(this.left,i),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),Fc(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Fc(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e=4?e(a):n.interrupt(i.parser.constructs.flow,t,e)(a)}}function IA(n,e,t,i,l,o,a,u,f){const d=f||Number.POSITIVE_INFINITY;let m=0;return g;function g(N){return N===60?(n.enter(i),n.enter(l),n.enter(o),n.consume(N),n.exit(o),b):N===null||N===32||N===41||Ud(N)?t(N):(n.enter(i),n.enter(a),n.enter(u),n.enter("chunkString",{contentType:"string"}),S(N))}function b(N){return N===62?(n.enter(o),n.consume(N),n.exit(o),n.exit(l),n.exit(i),e):(n.enter(u),n.enter("chunkString",{contentType:"string"}),v(N))}function v(N){return N===62?(n.exit("chunkString"),n.exit(u),b(N)):N===null||N===60||Be(N)?t(N):(n.consume(N),N===92?w:v)}function w(N){return N===60||N===62||N===92?(n.consume(N),v):v(N)}function S(N){return!m&&(N===null||N===41||Mt(N))?(n.exit("chunkString"),n.exit(u),n.exit(a),n.exit(i),e(N)):m999||v===null||v===91||v===93&&!f||v===94&&!u&&"_hiddenFootnoteSupport"in a.parser.constructs?t(v):v===93?(n.exit(o),n.enter(l),n.consume(v),n.exit(l),n.exit(i),e):Be(v)?(n.enter("lineEnding"),n.consume(v),n.exit("lineEnding"),m):(n.enter("chunkString",{contentType:"string"}),g(v))}function g(v){return v===null||v===91||v===93||Be(v)||u++>999?(n.exit("chunkString"),m(v)):(n.consume(v),f||(f=!Ke(v)),v===92?b:g)}function b(v){return v===91||v===92||v===93?(n.consume(v),u++,g):g(v)}}function FA(n,e,t,i,l,o){let a;return u;function u(b){return b===34||b===39||b===40?(n.enter(i),n.enter(l),n.consume(b),n.exit(l),a=b===40?41:b,f):t(b)}function f(b){return b===a?(n.enter(l),n.consume(b),n.exit(l),n.exit(i),e):(n.enter(o),d(b))}function d(b){return b===a?(n.exit(o),f(a)):b===null?t(b):Be(b)?(n.enter("lineEnding"),n.consume(b),n.exit("lineEnding"),mt(n,d,"linePrefix")):(n.enter("chunkString",{contentType:"string"}),m(b))}function m(b){return b===a||b===null||Be(b)?(n.exit("chunkString"),d(b)):(n.consume(b),b===92?g:m)}function g(b){return b===a||b===92?(n.consume(b),m):m(b)}}function lu(n,e){let t;return i;function i(l){return Be(l)?(n.enter("lineEnding"),n.consume(l),n.exit("lineEnding"),t=!0,i):Ke(l)?mt(n,i,t?"linePrefix":"lineSuffix")(l):e(l)}}const sH={name:"definition",tokenize:aH},oH={partial:!0,tokenize:cH};function aH(n,e,t){const i=this;let l;return o;function o(v){return n.enter("definition"),a(v)}function a(v){return UA.call(i,n,u,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function u(v){return l=ir(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),v===58?(n.enter("definitionMarker"),n.consume(v),n.exit("definitionMarker"),f):t(v)}function f(v){return Mt(v)?lu(n,d)(v):d(v)}function d(v){return IA(n,m,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function m(v){return n.attempt(oH,g,g)(v)}function g(v){return Ke(v)?mt(n,b,"whitespace")(v):b(v)}function b(v){return v===null||Be(v)?(n.exit("definition"),i.parser.defined.push(l),e(v)):t(v)}}function cH(n,e,t){return i;function i(u){return Mt(u)?lu(n,l)(u):t(u)}function l(u){return FA(n,o,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function o(u){return Ke(u)?mt(n,a,"whitespace")(u):a(u)}function a(u){return u===null||Be(u)?e(u):t(u)}}const uH={name:"hardBreakEscape",tokenize:fH};function fH(n,e,t){return i;function i(o){return n.enter("hardBreakEscape"),n.consume(o),l}function l(o){return Be(o)?(n.exit("hardBreakEscape"),e(o)):t(o)}}const hH={name:"headingAtx",resolve:dH,tokenize:mH};function dH(n,e){let t=n.length-2,i=3;if(n[i][1].type==="whitespace"&&(i+=2),t-2>i&&n[t][1].type==="whitespace"&&(t-=2),n[t][1].type==="atxHeadingSequence"&&(i===t-1||t-4>i&&n[t-2][1].type==="whitespace")&&(t-=i+1===t?2:4),t>i){const l={type:"atxHeadingText",start:n[i][1].start,end:n[t][1].end},o={type:"chunkText",start:n[i][1].start,end:n[t][1].end,contentType:"text"};nr(n,i,t-i+1,[["enter",l,e],["enter",o,e],["exit",o,e],["exit",l,e]])}return n}function mH(n,e,t){let i=0;return l;function l(m){return n.enter("atxHeading"),o(m)}function o(m){return n.enter("atxHeadingSequence"),a(m)}function a(m){return m===35&&i++<6?(n.consume(m),a):m===null||Mt(m)?(n.exit("atxHeadingSequence"),u(m)):t(m)}function u(m){return m===35?(n.enter("atxHeadingSequence"),f(m)):m===null||Be(m)?(n.exit("atxHeading"),e(m)):Ke(m)?mt(n,u,"whitespace")(m):(n.enter("atxHeadingText"),d(m))}function f(m){return m===35?(n.consume(m),f):(n.exit("atxHeadingSequence"),u(m))}function d(m){return m===null||m===35||Mt(m)?(n.exit("atxHeadingText"),u(m)):(n.consume(m),d)}}const qA=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],sy=["pre","script","style","textarea"],pH={concrete:!0,name:"htmlFlow",resolveTo:xH,tokenize:yH},gH={partial:!0,tokenize:bH};function xH(n){let e=n.length;for(;e--&&!(n[e][0]==="enter"&&n[e][1].type==="htmlFlow"););return e>1&&n[e-2][1].type==="linePrefix"&&(n[e][1].start=n[e-2][1].start,n[e+1][1].start=n[e-2][1].start,n.splice(e-2,2)),n}function yH(n,e,t){const i=this;let l,o,a,u,f;return d;function d(B){return m(B)}function m(B){return n.enter("htmlFlow"),n.enter("htmlFlowData"),n.consume(B),g}function g(B){return B===33?(n.consume(B),b):B===47?(n.consume(B),o=!0,S):B===63?(n.consume(B),l=3,i.interrupt?e:A):Rn(B)?(n.consume(B),a=String.fromCharCode(B),C):t(B)}function b(B){return B===45?(n.consume(B),l=2,v):B===91?(n.consume(B),l=5,u=0,w):Rn(B)?(n.consume(B),l=4,i.interrupt?e:A):t(B)}function v(B){return B===45?(n.consume(B),i.interrupt?e:A):t(B)}function w(B){const j="CDATA[";return B===j.charCodeAt(u++)?(n.consume(B),u===j.length?i.interrupt?e:F:w):t(B)}function S(B){return Rn(B)?(n.consume(B),a=String.fromCharCode(B),C):t(B)}function C(B){if(B===null||B===47||B===62||Mt(B)){const j=B===47,$=a.toLowerCase();return!j&&!o&&sy.includes($)?(l=1,i.interrupt?e(B):F(B)):qA.includes(a.toLowerCase())?(l=6,j?(n.consume(B),N):i.interrupt?e(B):F(B)):(l=7,i.interrupt&&!i.parser.lazy[i.now().line]?t(B):o?R(B):M(B))}return B===45||_n(B)?(n.consume(B),a+=String.fromCharCode(B),C):t(B)}function N(B){return B===62?(n.consume(B),i.interrupt?e:F):t(B)}function R(B){return Ke(B)?(n.consume(B),R):q(B)}function M(B){return B===47?(n.consume(B),q):B===58||B===95||Rn(B)?(n.consume(B),I):Ke(B)?(n.consume(B),M):q(B)}function I(B){return B===45||B===46||B===58||B===95||_n(B)?(n.consume(B),I):U(B)}function U(B){return B===61?(n.consume(B),E):Ke(B)?(n.consume(B),U):M(B)}function E(B){return B===null||B===60||B===61||B===62||B===96?t(B):B===34||B===39?(n.consume(B),f=B,T):Ke(B)?(n.consume(B),E):z(B)}function T(B){return B===f?(n.consume(B),f=null,ie):B===null||Be(B)?t(B):(n.consume(B),T)}function z(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||Mt(B)?U(B):(n.consume(B),z)}function ie(B){return B===47||B===62||Ke(B)?M(B):t(B)}function q(B){return B===62?(n.consume(B),J):t(B)}function J(B){return B===null||Be(B)?F(B):Ke(B)?(n.consume(B),J):t(B)}function F(B){return B===45&&l===2?(n.consume(B),L):B===60&&l===1?(n.consume(B),ee):B===62&&l===4?(n.consume(B),Le):B===63&&l===3?(n.consume(B),A):B===93&&l===5?(n.consume(B),le):Be(B)&&(l===6||l===7)?(n.exit("htmlFlowData"),n.check(gH,_e,se)(B)):B===null||Be(B)?(n.exit("htmlFlowData"),se(B)):(n.consume(B),F)}function se(B){return n.check(ly,he,_e)(B)}function he(B){return n.enter("lineEnding"),n.consume(B),n.exit("lineEnding"),ne}function ne(B){return B===null||Be(B)?se(B):(n.enter("htmlFlowData"),F(B))}function L(B){return B===45?(n.consume(B),A):F(B)}function ee(B){return B===47?(n.consume(B),a="",oe):F(B)}function oe(B){if(B===62){const j=a.toLowerCase();return sy.includes(j)?(n.consume(B),Le):F(B)}return Rn(B)&&a.length<8?(n.consume(B),a+=String.fromCharCode(B),oe):F(B)}function le(B){return B===93?(n.consume(B),A):F(B)}function A(B){return B===62?(n.consume(B),Le):B===45&&l===2?(n.consume(B),A):F(B)}function Le(B){return B===null||Be(B)?(n.exit("htmlFlowData"),_e(B)):(n.consume(B),Le)}function _e(B){return n.exit("htmlFlow"),e(B)}}function bH(n,e,t){return i;function i(l){return n.enter("lineEnding"),n.consume(l),n.exit("lineEnding"),n.attempt(_u,e,t)}}const vH={name:"htmlText",tokenize:wH};function wH(n,e,t){const i=this;let l,o,a;return u;function u(A){return n.enter("htmlText"),n.enter("htmlTextData"),n.consume(A),f}function f(A){return A===33?(n.consume(A),d):A===47?(n.consume(A),U):A===63?(n.consume(A),M):Rn(A)?(n.consume(A),z):t(A)}function d(A){return A===45?(n.consume(A),m):A===91?(n.consume(A),o=0,w):Rn(A)?(n.consume(A),R):t(A)}function m(A){return A===45?(n.consume(A),v):t(A)}function g(A){return A===null?t(A):A===45?(n.consume(A),b):Be(A)?(a=g,ee(A)):(n.consume(A),g)}function b(A){return A===45?(n.consume(A),v):g(A)}function v(A){return A===62?L(A):A===45?b(A):g(A)}function w(A){const Le="CDATA[";return A===Le.charCodeAt(o++)?(n.consume(A),o===Le.length?S:w):t(A)}function S(A){return A===null?t(A):A===93?(n.consume(A),C):Be(A)?(a=S,ee(A)):(n.consume(A),S)}function C(A){return A===93?(n.consume(A),N):S(A)}function N(A){return A===62?L(A):A===93?(n.consume(A),N):S(A)}function R(A){return A===null||A===62?L(A):Be(A)?(a=R,ee(A)):(n.consume(A),R)}function M(A){return A===null?t(A):A===63?(n.consume(A),I):Be(A)?(a=M,ee(A)):(n.consume(A),M)}function I(A){return A===62?L(A):M(A)}function U(A){return Rn(A)?(n.consume(A),E):t(A)}function E(A){return A===45||_n(A)?(n.consume(A),E):T(A)}function T(A){return Be(A)?(a=T,ee(A)):Ke(A)?(n.consume(A),T):L(A)}function z(A){return A===45||_n(A)?(n.consume(A),z):A===47||A===62||Mt(A)?ie(A):t(A)}function ie(A){return A===47?(n.consume(A),L):A===58||A===95||Rn(A)?(n.consume(A),q):Be(A)?(a=ie,ee(A)):Ke(A)?(n.consume(A),ie):L(A)}function q(A){return A===45||A===46||A===58||A===95||_n(A)?(n.consume(A),q):J(A)}function J(A){return A===61?(n.consume(A),F):Be(A)?(a=J,ee(A)):Ke(A)?(n.consume(A),J):ie(A)}function F(A){return A===null||A===60||A===61||A===62||A===96?t(A):A===34||A===39?(n.consume(A),l=A,se):Be(A)?(a=F,ee(A)):Ke(A)?(n.consume(A),F):(n.consume(A),he)}function se(A){return A===l?(n.consume(A),l=void 0,ne):A===null?t(A):Be(A)?(a=se,ee(A)):(n.consume(A),se)}function he(A){return A===null||A===34||A===39||A===60||A===61||A===96?t(A):A===47||A===62||Mt(A)?ie(A):(n.consume(A),he)}function ne(A){return A===47||A===62||Mt(A)?ie(A):t(A)}function L(A){return A===62?(n.consume(A),n.exit("htmlTextData"),n.exit("htmlText"),e):t(A)}function ee(A){return n.exit("htmlTextData"),n.enter("lineEnding"),n.consume(A),n.exit("lineEnding"),oe}function oe(A){return Ke(A)?mt(n,le,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):le(A)}function le(A){return n.enter("htmlTextData"),a(A)}}const hb={name:"labelEnd",resolveAll:OH,resolveTo:NH,tokenize:TH},kH={tokenize:AH},SH={tokenize:EH},CH={tokenize:MH};function OH(n){let e=-1;const t=[];for(;++e0&&l[l.length-1]._balanced;)l.pop();o=l[l.length-1]}return u;function u(b){return o?o._inactive?g(b):(a=i.parser.defined.includes(ir(i.sliceSerialize({start:o.end,end:i.now()}))),n.enter("labelEnd"),n.enter("labelMarker"),n.consume(b),n.exit("labelMarker"),n.exit("labelEnd"),f):t(b)}function f(b){return b===40?n.attempt(kH,m,a?m:g)(b):b===91?n.attempt(SH,m,a?d:g)(b):a?m(b):g(b)}function d(b){return n.attempt(CH,m,g)(b)}function m(b){return l.pop(),e(b)}function g(b){return o._balanced=!0,t(b)}}function AH(n,e,t){return i;function i(g){return n.enter("resource"),n.enter("resourceMarker"),n.consume(g),n.exit("resourceMarker"),l}function l(g){return Mt(g)?lu(n,o)(g):o(g)}function o(g){return g===41?m(g):IA(n,a,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function a(g){return Mt(g)?lu(n,f)(g):m(g)}function u(g){return t(g)}function f(g){return g===34||g===39||g===40?FA(n,d,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):m(g)}function d(g){return Mt(g)?lu(n,m)(g):m(g)}function m(g){return g===41?(n.enter("resourceMarker"),n.consume(g),n.exit("resourceMarker"),n.exit("resource"),e):t(g)}}function EH(n,e,t){const i=this;return l;function l(u){return UA.call(i,n,o,a,"reference","referenceMarker","referenceString")(u)}function o(u){return i.parser.defined.includes(ir(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?e(u):t(u)}function a(u){return t(u)}}function MH(n,e,t){return i;function i(o){return n.enter("reference"),n.enter("referenceMarker"),n.consume(o),n.exit("referenceMarker"),l}function l(o){return o===93?(n.enter("referenceMarker"),n.consume(o),n.exit("referenceMarker"),n.exit("reference"),e):t(o)}}const DH={name:"labelStartImage",resolveAll:hb.resolveAll,tokenize:jH};function jH(n,e,t){const i=this;let l;return o;function o(f){return n.enter("labelImage"),n.enter("labelImageMarker"),n.consume(f),n.exit("labelImageMarker"),a}function a(f){return f===91?(n.enter("labelMarker"),n.consume(f),n.exit("labelMarker"),l=n.exit("labelImage"),u):t(f)}function u(f){return f===94&&"_hiddenFootnoteSupport"in i.parser.constructs?t(f):(i._labelStarts=i._labelStarts||[],i._labelStarts.push(l),e(f))}}const RH={name:"labelStartLink",resolveAll:hb.resolveAll,tokenize:_H};function _H(n,e,t){const i=this;let l;return o;function o(u){return n.enter("labelLink"),n.enter("labelMarker"),n.consume(u),n.exit("labelMarker"),l=n.exit("labelLink"),a}function a(u){return u===94&&"_hiddenFootnoteSupport"in i.parser.constructs?t(u):(i._labelStarts=i._labelStarts||[],i._labelStarts.push(l),e(u))}}const L0={name:"lineEnding",tokenize:LH};function LH(n,e){return t;function t(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),mt(n,e,"linePrefix")}}const ad={name:"thematicBreak",tokenize:zH};function zH(n,e,t){let i=0,l;return o;function o(d){return n.enter("thematicBreak"),a(d)}function a(d){return l=d,u(d)}function u(d){return d===l?(n.enter("thematicBreakSequence"),f(d)):i>=3&&(d===null||Be(d))?(n.exit("thematicBreak"),e(d)):t(d)}function f(d){return d===l?(n.consume(d),i++,f):(n.exit("thematicBreakSequence"),Ke(d)?mt(n,u,"whitespace")(d):u(d))}}const ai={continuation:{tokenize:IH},exit:FH,name:"list",tokenize:HH},BH={partial:!0,tokenize:qH},PH={partial:!0,tokenize:UH};function HH(n,e,t){const i=this,l=i.events[i.events.length-1];let o=l&&l[1].type==="linePrefix"?l[2].sliceSerialize(l[1],!0).length:0,a=0;return u;function u(v){const w=i.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!i.containerState.marker||v===i.containerState.marker:iy(v)){if(i.containerState.type||(i.containerState.type=w,n.enter(w,{_container:!0})),w==="listUnordered")return n.enter("listItemPrefix"),v===42||v===45?n.check(ad,t,d)(v):d(v);if(!i.interrupt||v===49)return n.enter("listItemPrefix"),n.enter("listItemValue"),f(v)}return t(v)}function f(v){return iy(v)&&++a<10?(n.consume(v),f):(!i.interrupt||a<2)&&(i.containerState.marker?v===i.containerState.marker:v===41||v===46)?(n.exit("listItemValue"),d(v)):t(v)}function d(v){return n.enter("listItemMarker"),n.consume(v),n.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||v,n.check(_u,i.interrupt?t:m,n.attempt(BH,b,g))}function m(v){return i.containerState.initialBlankLine=!0,o++,b(v)}function g(v){return Ke(v)?(n.enter("listItemPrefixWhitespace"),n.consume(v),n.exit("listItemPrefixWhitespace"),b):t(v)}function b(v){return i.containerState.size=o+i.sliceSerialize(n.exit("listItemPrefix"),!0).length,e(v)}}function IH(n,e,t){const i=this;return i.containerState._closeFlow=void 0,n.check(_u,l,o);function l(u){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,mt(n,e,"listItemIndent",i.containerState.size+1)(u)}function o(u){return i.containerState.furtherBlankLines||!Ke(u)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,a(u)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,n.attempt(PH,e,a)(u))}function a(u){return i.containerState._closeFlow=!0,i.interrupt=void 0,mt(n,n.attempt(ai,e,t),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function UH(n,e,t){const i=this;return mt(n,l,"listItemIndent",i.containerState.size+1);function l(o){const a=i.events[i.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===i.containerState.size?e(o):t(o)}}function FH(n){n.exit(this.containerState.type)}function qH(n,e,t){const i=this;return mt(n,l,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function l(o){const a=i.events[i.events.length-1];return!Ke(o)&&a&&a[1].type==="listItemPrefixWhitespace"?e(o):t(o)}}const hC={name:"setextUnderline",resolveTo:VH,tokenize:QH};function VH(n,e){const t=new Fd;let i=n.length,l,o,a;for(;i--;)if(n[i][0]==="enter"){if(n[i][1].type==="content"){l=i;break}n[i][1].type==="paragraph"&&(o=i)}else n[i][1].type==="content"&&t.add(i,1,[]),!a&&n[i][1].type==="definition"&&(a=i);const u={type:"setextHeading",start:{...n[l][1].start},end:{...n[n.length-1][1].end}};return n[o][1].type="setextHeadingText",a?(t.add(o,0,[["enter",u,e]]),t.add(a+1,0,[["exit",n[l][1],e]]),n[l][1].end={...n[a][1].end}):n[l][1]=u,t.add(n.length,0,[["exit",u,e]]),t.consume(n),n}function QH(n,e,t){const i=this;let l;return o;function o(d){let m=i.events.length,g;for(;m--;)if(i.events[m][1].type!=="lineEnding"&&i.events[m][1].type!=="linePrefix"&&i.events[m][1].type!=="content"){g=i.events[m][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||g)?(n.enter("setextHeadingLine"),l=d,a(d)):t(d)}function a(d){return n.enter("setextHeadingLineSequence"),u(d)}function u(d){return d===l?(n.consume(d),u):(n.exit("setextHeadingLineSequence"),Ke(d)?mt(n,f,"lineSuffix")(d):f(d))}function f(d){return d===null||Be(d)?(n.exit("setextHeadingLine"),e(d)):t(d)}}const XH={tokenize:$H};function $H(n){const e=this,t=n.attempt(_u,i,n.attempt(this.parser.constructs.flowInitial,l,mt(n,n.attempt(this.parser.constructs.flow,l,n.attempt(tH,l)),"linePrefix")));return t;function i(o){if(o===null){n.consume(o);return}return n.enter("lineEndingBlank"),n.consume(o),n.exit("lineEndingBlank"),e.currentConstruct=void 0,t}function l(o){if(o===null){n.consume(o);return}return n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),e.currentConstruct=void 0,t}}const YH={resolveAll:QA()},GH=VA("string"),KH=VA("text");function VA(n){return{resolveAll:QA(n==="text"?WH:void 0),tokenize:e};function e(t){const i=this,l=this.parser.constructs[n],o=t.attempt(l,a,u);return a;function a(m){return d(m)?o(m):u(m)}function u(m){if(m===null){t.consume(m);return}return t.enter("data"),t.consume(m),f}function f(m){return d(m)?(t.exit("data"),o(m)):(t.consume(m),f)}function d(m){if(m===null)return!0;const g=l[m];let b=-1;if(g)for(;++b-1){const u=a[0];typeof u=="string"?a[0]=u.slice(i):a.shift()}o>0&&a.push(n[l].slice(0,o))}return a}function u7(n,e){let t=-1;const i=[];let l;for(;++t0&&l(e.beforeEnter,{...de,sliceSerialize:V[ot][2].sliceSerialize},V[ot][1]),XA.call(gt,V[ot][1].type)&>[V[ot][1].type].call({...de,sliceSerialize:V[ot][2].sliceSerialize},V[ot][1]),V[ot][0]==="exit"&&e.afterExit.length>0&&l(e.afterExit,{...de,sliceSerialize:V[ot][2].sliceSerialize},V[ot][1])}if(de.tokenStack.length>0){const gt=de.tokenStack[de.tokenStack.length-1];(gt[1]||mC).call(de,void 0,gt[0])}for(K.position={start:Ql(V.length>0?V[0][1].start:{line:1,column:1,offset:0}),end:Ql(V.length>0?V[V.length-2][1].end:{line:1,column:1,offset:0})},ot=-1;++ot0&&(i.className=["language-"+l[0]]);let o={type:"element",tagName:"code",properties:i,children:[{type:"text",value:t}]};return e.meta&&(o.data={meta:e.meta}),n.patch(e,o),o=n.applyData(e,o),o={type:"element",tagName:"pre",properties:{},children:[o]},n.patch(e,o),o}function C7(n,e){const t={type:"element",tagName:"del",properties:{},children:n.all(e)};return n.patch(e,t),n.applyData(e,t)}function O7(n,e){const t={type:"element",tagName:"em",properties:{},children:n.all(e)};return n.patch(e,t),n.applyData(e,t)}function N7(n,e){const t=typeof n.options.clobberPrefix=="string"?n.options.clobberPrefix:"user-content-",i=String(e.identifier).toUpperCase(),l=Ba(i.toLowerCase()),o=n.footnoteOrder.indexOf(i);let a,u=n.footnoteCounts.get(i);u===void 0?(u=0,n.footnoteOrder.push(i),a=n.footnoteOrder.length):a=o+1,u+=1,n.footnoteCounts.set(i,u);const f={type:"element",tagName:"a",properties:{href:"#"+t+"fn-"+l,id:t+"fnref-"+l+(u>1?"-"+u:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};n.patch(e,f);const d={type:"element",tagName:"sup",properties:{},children:[f]};return n.patch(e,d),n.applyData(e,d)}function T7(n,e){const t={type:"element",tagName:"h"+e.depth,properties:{},children:n.all(e)};return n.patch(e,t),n.applyData(e,t)}function A7(n,e){if(n.options.allowDangerousHtml){const t={type:"raw",value:e.value};return n.patch(e,t),n.applyData(e,t)}}function YA(n,e){const t=e.referenceType;let i="]";if(t==="collapsed"?i+="[]":t==="full"&&(i+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+i}];const l=n.all(e),o=l[0];o&&o.type==="text"?o.value="["+o.value:l.unshift({type:"text",value:"["});const a=l[l.length-1];return a&&a.type==="text"?a.value+=i:l.push({type:"text",value:i}),l}function E7(n,e){const t=String(e.identifier).toUpperCase(),i=n.definitionById.get(t);if(!i)return YA(n,e);const l={src:Ba(i.url||""),alt:e.alt};i.title!==null&&i.title!==void 0&&(l.title=i.title);const o={type:"element",tagName:"img",properties:l,children:[]};return n.patch(e,o),n.applyData(e,o)}function M7(n,e){const t={src:Ba(e.url)};e.alt!==null&&e.alt!==void 0&&(t.alt=e.alt),e.title!==null&&e.title!==void 0&&(t.title=e.title);const i={type:"element",tagName:"img",properties:t,children:[]};return n.patch(e,i),n.applyData(e,i)}function D7(n,e){const t={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};n.patch(e,t);const i={type:"element",tagName:"code",properties:{},children:[t]};return n.patch(e,i),n.applyData(e,i)}function j7(n,e){const t=String(e.identifier).toUpperCase(),i=n.definitionById.get(t);if(!i)return YA(n,e);const l={href:Ba(i.url||"")};i.title!==null&&i.title!==void 0&&(l.title=i.title);const o={type:"element",tagName:"a",properties:l,children:n.all(e)};return n.patch(e,o),n.applyData(e,o)}function R7(n,e){const t={href:Ba(e.url)};e.title!==null&&e.title!==void 0&&(t.title=e.title);const i={type:"element",tagName:"a",properties:t,children:n.all(e)};return n.patch(e,i),n.applyData(e,i)}function _7(n,e,t){const i=n.all(e),l=t?L7(t):GA(e),o={},a=[];if(typeof e.checked=="boolean"){const m=i[0];let g;m&&m.type==="element"&&m.tagName==="p"?g=m:(g={type:"element",tagName:"p",properties:{},children:[]},i.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let u=-1;for(;++u1}function z7(n,e){const t={},i=n.all(e);let l=-1;for(typeof e.start=="number"&&e.start!==1&&(t.start=e.start);++l0){const a={type:"element",tagName:"tbody",properties:{},children:n.wrap(t,!0)},u=sb(e.children[1]),f=OA(e.children[e.children.length-1]);u&&f&&(a.position={start:u,end:f}),l.push(a)}const o={type:"element",tagName:"table",properties:{},children:n.wrap(l,!0)};return n.patch(e,o),n.applyData(e,o)}function U7(n,e,t){const i=t?t.children:void 0,o=(i?i.indexOf(e):1)===0?"th":"td",a=t&&t.type==="table"?t.align:void 0,u=a?a.length:e.children.length;let f=-1;const d=[];for(;++f0,!0),i[0]),l=i.index+i[0].length,i=t.exec(e);return o.push(xC(e.slice(l),l>0,!1)),o.join("")}function xC(n,e,t){let i=0,l=n.length;if(e){let o=n.codePointAt(i);for(;o===pC||o===gC;)i++,o=n.codePointAt(i)}if(t){let o=n.codePointAt(l-1);for(;o===pC||o===gC;)l--,o=n.codePointAt(l-1)}return l>i?n.slice(i,l):""}function V7(n,e){const t={type:"text",value:q7(String(e.value))};return n.patch(e,t),n.applyData(e,t)}function Q7(n,e){const t={type:"element",tagName:"hr",properties:{},children:[]};return n.patch(e,t),n.applyData(e,t)}const X7={blockquote:w7,break:k7,code:S7,delete:C7,emphasis:O7,footnoteReference:N7,heading:T7,html:A7,imageReference:E7,image:M7,inlineCode:D7,linkReference:j7,link:R7,listItem:_7,list:z7,paragraph:B7,root:P7,strong:H7,table:I7,tableCell:F7,tableRow:U7,text:V7,thematicBreak:Q7,toml:Fh,yaml:Fh,definition:Fh,footnoteDefinition:Fh};function Fh(){}const KA=-1,dm=0,su=1,qd=2,db=3,mb=4,pb=5,gb=6,WA=7,ZA=8,{defineProperty:$7}=Object,JA=typeof self=="object"?self:globalThis,yC=(n,e)=>{switch(n){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+n)}return new JA[n](e)},Y7=(n,e)=>{const t=(l,o)=>(n.set(o,l),l),i=l=>{if(n.has(l))return n.get(l);const[o,a]=e[l];switch(o){case dm:case KA:return t(a,l);case su:{const u=t([],l);for(const f of a)u.push(i(f));return u}case qd:{const u=t({},l);for(const[f,d]of a){const m=i(f),g=i(d);m==="__proto__"?$7(u,m,{value:g,configurable:!0,enumerable:!0,writable:!0}):u[m]=g}return u}case db:return t(new Date(a),l);case mb:{const{source:u,flags:f}=a;return t(new RegExp(u,f),l)}case pb:{const u=t(new Map,l);for(const[f,d]of a)u.set(i(f),i(d));return u}case gb:{const u=t(new Set,l);for(const f of a)u.add(i(f));return u}case WA:{const{name:u,message:f}=a;return t(typeof JA[u]=="function"?yC(u,f):new Error(f),l)}case ZA:return t(BigInt(a),l);case"BigInt":return t(Object(BigInt(a)),l);case"ArrayBuffer":return t(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:u}=new Uint8Array(a);return t(new DataView(u),a)}case"-0":return-0}return t(yC(o,a),l)};return i},bC=n=>Y7(new Map,n)(0),Qs="",{toString:G7}={},{keys:K7,is:W7}=Object,qc=n=>{const e=typeof n;if(e!=="object"||!n)return[dm,e];const t=G7.call(n).slice(8,-1);switch(t){case"Array":return[su,Qs];case"Object":return[qd,Qs];case"Date":return[db,Qs];case"RegExp":return[mb,Qs];case"Map":return[pb,Qs];case"Set":return[gb,Qs];case"DataView":return[su,t]}return t.includes("Array")?[su,t]:n instanceof Error?[WA,n.name||"Error"]:[qd,t]},qh=([n,e])=>n===dm&&(e==="function"||e==="symbol"),Z7=(n,e,t,i)=>{const l=(a,u)=>{const f=i.push(a)-1;return t.set(u,f),f},o=a=>{if(t.has(a))return t.get(a);let[u,f]=qc(a);switch(u){case dm:{let m=a;switch(f){case"bigint":u=ZA,m=a.toString();break;case"number":if(!a&&W7(a,-0))return i.push(["-0"])-1;break;case"function":case"symbol":if(n)throw new TypeError("unable to serialize "+f);m=null;break;case"undefined":return l([KA],a)}return l([u,m],a)}case su:{if(f){let b=a;return f==="DataView"?b=new Uint8Array(a.buffer):f==="ArrayBuffer"&&(b=new Uint8Array(a)),l([f,[...b]],a)}const m=[],g=l([u,m],a);for(const b of a)m.push(o(b));return g}case qd:{if(f)switch(f){case"BigInt":return l([f,a.toString()],a);case"Boolean":case"Number":case"String":return l([f,a.valueOf()],a)}if(e&&"toJSON"in a)return o(a.toJSON());const m=[],g=l([u,m],a);for(const b of K7(a))(n||!qh(qc(a[b])))&&m.push([o(b),o(a[b])]);return g}case db:return l([u,isNaN(a.getTime())?Qs:a.toISOString()],a);case mb:{const{source:m,flags:g}=a;return l([u,{source:m,flags:g}],a)}case pb:{const m=[],g=l([u,m],a);for(const[b,v]of a)(n||!(qh(qc(b))||qh(qc(v))))&&m.push([o(b),o(v)]);return g}case gb:{const m=[],g=l([u,m],a);for(const b of a)(n||!qh(qc(b)))&&m.push(o(b));return g}}const{message:d}=a;return l([u,{name:f,message:d}],a)};return o},vC=(n,{json:e,lossy:t}={})=>{const i=[];return Z7(!(e||t),!!e,new Map,i)(n),i},Vd=typeof structuredClone=="function"?(n,e)=>e&&("json"in e||"lossy"in e)?bC(vC(n,e)):structuredClone(n):(n,e)=>bC(vC(n,e));function J7(n,e){const t=[{type:"text",value:"↩"}];return e>1&&t.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),t}function eI(n,e){return"Back to reference "+(n+1)+(e>1?"-"+e:"")}function tI(n){const e=typeof n.options.clobberPrefix=="string"?n.options.clobberPrefix:"user-content-",t=n.options.footnoteBackContent||J7,i=n.options.footnoteBackLabel||eI,l=n.options.footnoteLabel||"Footnotes",o=n.options.footnoteLabelTagName||"h2",a=n.options.footnoteLabelProperties||{className:["sr-only"]},u=[];let f=-1;for(;++f0&&w.push({type:"text",value:" "});let R=typeof t=="string"?t:t(f,v);typeof R=="string"&&(R={type:"text",value:R}),w.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+b+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(f,v),className:["data-footnote-backref"]},children:Array.isArray(R)?R:[R]})}const C=m[m.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const R=C.children[C.children.length-1];R&&R.type==="text"?R.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...w)}else m.push(...w);const N={type:"element",tagName:"li",properties:{id:e+"fn-"+b},children:n.wrap(m,!0)};n.patch(d,N),u.push(N)}if(u.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Vd(a),id:"footnote-label"},children:[{type:"text",value:l}]},{type:"text",value:` -`},{type:"element",tagName:"ol",properties:{},children:n.wrap(u,!0)},{type:"text",value:` -`}]}}const mm=(function(n){if(n==null)return lI;if(typeof n=="function")return pm(n);if(typeof n=="object")return Array.isArray(n)?nI(n):iI(n);if(typeof n=="string")return rI(n);throw new Error("Expected function, string, or object as test")});function nI(n){const e=[];let t=-1;for(;++t":""))+")"})}return C;function C(){const N=!o||d(b,v,w[w.length-1]||void 0);let R=eE;if(u&&N&&(R=wC(u(b,w,v)),R[0]===cd))return R;if("children"in b&&b.children){const M=b;if(M.children&&R[0]!==oy){let I=(l?-1:M.children.length)+m;const U=[...w,M];for(;I>-1&&I0&&t.push({type:"text",value:` -`}),t}function kC(n){let e=0,t=n.charCodeAt(e);for(;t===9||t===32;)e++,t=n.charCodeAt(e);return n.slice(e)}function SC(n,e){const t=uI(n,e),i=t.one(n,void 0),l=tI(t),o=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return l&&o.children.push({type:"text",value:` -`},l),o}function pI(n,e){return n&&"run"in n?async function(t,i){const l=SC(t,{file:i,...e});await n.run(l,i)}:function(t,i){return SC(t,{file:i,...n||e})}}function CC(n){if(n)throw n}var z0,OC;function gI(){if(OC)return z0;OC=1;var n=Object.prototype.hasOwnProperty,e=Object.prototype.toString,t=Object.defineProperty,i=Object.getOwnPropertyDescriptor,l=function(d){return typeof Array.isArray=="function"?Array.isArray(d):e.call(d)==="[object Array]"},o=function(d){if(!d||e.call(d)!=="[object Object]")return!1;var m=n.call(d,"constructor"),g=d.constructor&&d.constructor.prototype&&n.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!m&&!g)return!1;var b;for(b in d);return typeof b>"u"||n.call(d,b)},a=function(d,m){t&&m.name==="__proto__"?t(d,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):d[m.name]=m.newValue},u=function(d,m){if(m==="__proto__")if(n.call(d,m)){if(i)return i(d,m).value}else return;return d[m]};return z0=function f(){var d,m,g,b,v,w,S=arguments[0],C=1,N=arguments.length,R=!1;for(typeof S=="boolean"&&(R=S,S=arguments[1]||{},C=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});Ca.length;let f;u&&a.push(l);try{f=n.apply(this,a)}catch(d){const m=d;if(u&&t)throw m;return l(m)}u||(f&&f.then&&typeof f.then=="function"?f.then(o,l):f instanceof Error?l(f):o(f))}function l(a,...u){t||(t=!0,e(a,...u))}function o(a){l(null,a)}}const Nr={basename:vI,dirname:wI,extname:kI,join:SI,sep:"/"};function vI(n,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Lu(n);let t=0,i=-1,l=n.length,o;if(e===void 0||e.length===0||e.length>n.length){for(;l--;)if(n.codePointAt(l)===47){if(o){t=l+1;break}}else i<0&&(o=!0,i=l+1);return i<0?"":n.slice(t,i)}if(e===n)return"";let a=-1,u=e.length-1;for(;l--;)if(n.codePointAt(l)===47){if(o){t=l+1;break}}else a<0&&(o=!0,a=l+1),u>-1&&(n.codePointAt(l)===e.codePointAt(u--)?u<0&&(i=l):(u=-1,i=a));return t===i?i=a:i<0&&(i=n.length),n.slice(t,i)}function wI(n){if(Lu(n),n.length===0)return".";let e=-1,t=n.length,i;for(;--t;)if(n.codePointAt(t)===47){if(i){e=t;break}}else i||(i=!0);return e<0?n.codePointAt(0)===47?"/":".":e===1&&n.codePointAt(0)===47?"//":n.slice(0,e)}function kI(n){Lu(n);let e=n.length,t=-1,i=0,l=-1,o=0,a;for(;e--;){const u=n.codePointAt(e);if(u===47){if(a){i=e+1;break}continue}t<0&&(a=!0,t=e+1),u===46?l<0?l=e:o!==1&&(o=1):l>-1&&(o=-1)}return l<0||t<0||o===0||o===1&&l===t-1&&l===i+1?"":n.slice(l,t)}function SI(...n){let e=-1,t;for(;++e0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function OI(n,e){let t="",i=0,l=-1,o=0,a=-1,u,f;for(;++a<=n.length;){if(a2){if(f=t.lastIndexOf("/"),f!==t.length-1){f<0?(t="",i=0):(t=t.slice(0,f),i=t.length-1-t.lastIndexOf("/")),l=a,o=0;continue}}else if(t.length>0){t="",i=0,l=a,o=0;continue}}e&&(t=t.length>0?t+"/..":"..",i=2)}else t.length>0?t+="/"+n.slice(l+1,a):t=n.slice(l+1,a),i=a-l-1;l=a,o=0}else u===46&&o>-1?o++:o=-1}return t}function Lu(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}const NI={cwd:TI};function TI(){return"/"}function hy(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function AI(n){if(typeof n=="string")n=new URL(n);else if(!hy(n)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+n+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(n.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return EI(n)}function EI(n){if(n.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const e=n.pathname;let t=-1;for(;++t0){let[v,...w]=m;const S=i[b][1];fy(S)&&fy(v)&&(v=B0(!0,S,v)),i[b]=[d,v,...w]}}}}const RI=new yb().freeze();function U0(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function F0(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function q0(n,e){if(e)throw new Error("Cannot call `"+n+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function TC(n){if(!fy(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function AC(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function Vh(n){return _I(n)?n:new tE(n)}function _I(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function LI(n){return typeof n=="string"||zI(n)}function zI(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}const BI="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",EC=[],MC={allowDangerousHtml:!0},PI=/^(https?|ircs?|mailto|xmpp)$/i,HI=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function II(n){const e=UI(n),t=FI(n);return qI(e.runSync(e.parse(t),t),n)}function UI(n){const e=n.rehypePlugins||EC,t=n.remarkPlugins||EC,i=n.remarkRehypeOptions?{...n.remarkRehypeOptions,...MC}:MC;return RI().use(v7).use(t).use(pI,i).use(e)}function FI(n){const e=n.children||"",t=new tE;return typeof e=="string"&&(t.value=e),t}function qI(n,e){const t=e.allowedElements,i=e.allowElement,l=e.components,o=e.disallowedElements,a=e.skipHtml,u=e.unwrapDisallowed,f=e.urlTransform||VI;for(const m of HI)Object.hasOwn(e,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+BI+m.id,void 0);return xb(n,d),sP(n,{Fragment:y.Fragment,components:l,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function d(m,g,b){if(m.type==="raw"&&b&&typeof g=="number")return a?b.children.splice(g,1):b.children[g]={type:"text",value:m.value},g;if(m.type==="element"){let v;for(v in R0)if(Object.hasOwn(R0,v)&&Object.hasOwn(m.properties,v)){const w=m.properties[v],S=R0[v];(S===null||S.includes(m.tagName))&&(m.properties[v]=f(String(w||""),v,m))}}if(m.type==="element"){let v=t?!t.includes(m.tagName):o?o.includes(m.tagName):!1;if(!v&&i&&typeof g=="number"&&(v=!i(m,g,b)),v&&b&&typeof g=="number")return u&&m.children?b.children.splice(g,1,...m.children):b.children.splice(g,1),g}}}function VI(n){const e=n.indexOf(":"),t=n.indexOf("?"),i=n.indexOf("#"),l=n.indexOf("/");return e===-1||l!==-1&&e>l||t!==-1&&e>t||i!==-1&&e>i||PI.test(n.slice(0,e))?n:""}function QI(n){if(typeof n!="string")throw new TypeError("Expected a string");return n.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function nE(n,e,t){const l=mm((t||{}).ignore||[]),o=XI(e);let a=-1;for(;++a0?{type:"text",value:E}:void 0),E===!1)v.lastIndex=I+1;else{if(S!==I&&M({type:"text",value:d.value.slice(S,I)}),Array.isArray(E))for(const T of E)M(T);else E&&M(E);S=I+R[0].length,C=!0}if(!v.global)break;R=v.exec(d.value)}return C?(S?\]}]+$/.exec(n);if(!e)return[n,void 0];n=n.slice(0,e.index);let t=e[0],i=t.indexOf(")");const l=DC(n,"(");let o=DC(n,")");for(;i!==-1&&l>o;)n+=t.slice(0,i+1),t=t.slice(i+1),i=t.indexOf(")"),o++;return[n,t]}function iE(n,e){const t=n.input.charCodeAt(n.index-1);return(n.index===0||lo(t)||fm(t))&&(!e||t!==47)}rE.peek=yU;function uU(){this.buffer()}function fU(n){this.enter({type:"footnoteReference",identifier:"",label:""},n)}function hU(){this.buffer()}function dU(n){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},n)}function mU(n){const e=this.resume(),t=this.stack[this.stack.length-1];t.type,t.identifier=ir(this.sliceSerialize(n)).toLowerCase(),t.label=e}function pU(n){this.exit(n)}function gU(n){const e=this.resume(),t=this.stack[this.stack.length-1];t.type,t.identifier=ir(this.sliceSerialize(n)).toLowerCase(),t.label=e}function xU(n){this.exit(n)}function yU(){return"["}function rE(n,e,t,i){const l=t.createTracker(i);let o=l.move("[^");const a=t.enter("footnoteReference"),u=t.enter("reference");return o+=l.move(t.safe(t.associationId(n),{after:"]",before:o})),u(),a(),o+=l.move("]"),o}function bU(){return{enter:{gfmFootnoteCallString:uU,gfmFootnoteCall:fU,gfmFootnoteDefinitionLabelString:hU,gfmFootnoteDefinition:dU},exit:{gfmFootnoteCallString:mU,gfmFootnoteCall:pU,gfmFootnoteDefinitionLabelString:gU,gfmFootnoteDefinition:xU}}}function vU(n){let e=!1;return n&&n.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:t,footnoteReference:rE},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function t(i,l,o,a){const u=o.createTracker(a);let f=u.move("[^");const d=o.enter("footnoteDefinition"),m=o.enter("label");return f+=u.move(o.safe(o.associationId(i),{before:f,after:"]"})),m(),f+=u.move("]:"),i.children&&i.children.length>0&&(u.shift(4),f+=u.move((e?` -`:" ")+o.indentLines(o.containerFlow(i,u.current()),e?lE:wU))),d(),f}}function wU(n,e,t){return e===0?n:lE(n,e,t)}function lE(n,e,t){return(t?"":" ")+n}const kU=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];bb.attention=TU;bb.peek=AU;function SU(){return{canContainEols:["delete"],enter:{strikethrough:OU},exit:{strikethrough:NU}}}function CU(){return{handlers:{delete:bb},unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:kU}]}}function OU(n){this.enter({type:"delete",children:[],position:void 0},n)}function NU(n){this.exit(n)}function bb(n,e,t,i){const l=t.createTracker(i),o=t.stack.includes("strikethrough")?"~":"~~",a=t.enter("strikethrough");let u=l.move(o);return u+=t.containerPhrasing(n,{...l.current(),before:u,after:"~"}),u+=l.move(o),a(),u}function TU(){return{construct:"strikethrough",markers:["~"],sizes:[2,1]}}function AU(){return"~"}function EU(n){return n.length}function MU(n,e){const t=e||{},i=(t.align||[]).concat(),l=t.stringLength||EU,o=[],a=[],u=[],f=[];let d=0,m=-1;for(;++md&&(d=n[m].length);++Nf[N])&&(f[N]=M)}S.push(R)}a[m]=S,u[m]=C}let g=-1;if(typeof i=="object"&&"length"in i)for(;++gf[g]&&(f[g]=R),v[g]=R),b[g]=M}a.splice(1,0,b),u.splice(1,0,v),m=-1;const w=[];for(;++m "),o.shift(2);const a=t.indentLines(t.containerFlow(n,o.current()),_U);return l(),a}function _U(n,e,t){return">"+(t?"":" ")+n}function LU(n,e){return RC(n,e.inConstruct,!0)&&!RC(n,e.notInConstruct,!1)}function RC(n,e,t){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return t;let i=-1;for(;++ia&&(a=o):o=1,l=i+e.length,i=t.indexOf(e,l);return a}function BU(n,e){return!!(e.options.fences===!1&&n.value&&!n.lang&&/[^\n\r ]/.test(n.value)&&!/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(n.value))}function PU(n){const e=n.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function HU(n,e,t,i){const l=PU(t),o=n.value||"";if(BU(n,t)){const g=t.enter("codeIndented"),b=t.indentLines(o,IU);return g(),b}const a=t.createTracker(i),u=l.repeat(Math.max(zU(o,l)+1,3)),f=t.enter("codeFenced"),d=l==="`"?"GraveAccent":"Tilde";let m=a.move(u);if(n.lang){const g=t.enter(`codeFencedLang${d}`);m+=a.move(t.safe(n.lang,{before:m,after:" ",encode:["`"],...a.current()})),g()}if(n.lang&&n.meta){const g=t.enter(`codeFencedMeta${d}`);m+=a.move(" "),m+=a.move(t.safe(n.meta,{before:m,after:` -`,encode:["`"],...a.current()})),g()}return m+=a.move(` -`),o&&(m+=a.move(o+` -`)),m+=a.move(u),f(),m}function IU(n,e,t){return(t?"":" ")+n}function vb(n){const e=n.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function UU(n,e,t,i){const l=vb(t),o=l==='"'?"Quote":"Apostrophe",a=t.enter("definition");let u=t.enter("label");const f=t.createTracker(i);let d=f.move("[");return d+=f.move(t.safe(t.associationId(n),{before:d,after:"]",...f.current()})),d+=f.move("]: "),u(),!n.url||/[\0- \u007F]/.test(n.url)?(u=t.enter("destinationLiteral"),d+=f.move("<"),d+=f.move(t.safe(n.url,{before:d,after:">",...f.current()})),d+=f.move(">")):(u=t.enter("destinationRaw"),d+=f.move(t.safe(n.url,{before:d,after:n.title?" ":` -`,...f.current()}))),u(),n.title&&(u=t.enter(`title${o}`),d+=f.move(" "+l),d+=f.move(t.safe(n.title,{before:d,after:l,...f.current()})),d+=f.move(l),u()),a(),d}function FU(n){const e=n.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function Qd(n){const e=n.codePointAt(0);return e===void 0?"":String.fromCodePoint(e)}function wa(n){const e=n.codePointAt(n.length-2);return e!==void 0&&e>65535?n.slice(-2):n.slice(-1)}function sE(n){return"&#x"+n.toString(16).toUpperCase()+";"}function LC(n,e,t){const i=cs(n),l=cs(e);return i===void 0?l===void 0?t==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:l===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?l===void 0?{inside:!1,outside:!1}:l===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:l===void 0?{inside:!1,outside:!1}:l===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function qU(n){if(n.charCodeAt(0)!==60)return;const e=n.charCodeAt(1);if(e===33){const u=n.charCodeAt(2);return u===45?2:u===91?5:Rn(u)?4:void 0}if(e===63)return 3;const t=e===47,i=t?2:1;let l=i,o=n.charCodeAt(l);if(!Rn(o))return;for(;o===45||_n(o);)o=n.charCodeAt(++l);const a=n.slice(i,l).toLowerCase();return!t&&o!==47&&sy.includes(a)?1:qA.includes(a)?6:7}const VU=new Map([["*",!1],["_",!0]]);function QU(n,e,t){const i=new Set;for(const o of n){const a=t.get(o);if(a&&o.attention&&e.some(u=>u.attention===o.attention))for(const u of a.tokens)i.add(u.attention)}const l=[];for(const o of n)o.attention&&i.delete(o.attention)&&l.push(o.attention);return l.reverse(),l}function oE(n,e,t){const i=[],l=new Map,o=new Map;let a=0;for(;at.index)return{chosen:f,mistake:m,tokens:d}}}}function $U(n,e){const t=new Map;for(const i of n){const l=i.tokens[0].value.charAt(0);let o=t.get(l);o||(o=[],t.set(l,o));let a=i.close?o.length:0;for(;a--&&i.start1&&d>1?2:1:d,g=u.markers.slice(u.end-m,u.end),b=i.markers.slice(i.start,i.start+m),v=g[0],w=b[0];if(v===g[m-1]&&v.value.length===m&&w===b[m-1]&&w.value.length===m&&v.attention===w.attention)e.delete(v),e.delete(w);else{const S=[...new Set([...g,...b])];for(const C of S){const N=e.get(C);N&&N.push(...S)}}u.end-=m,i.start+=m,u.start===u.end&&o.splice(a,1),a=o.length}i.open&&i.start0?w[0].value:"",C=LC(b.charCodeAt(b.length-1),S.charCodeAt(0),m);C.inside&&Qh(w,!0);const N=w.length>0?wa(w[w.length-1].value):"",R=LC(v.charCodeAt(0),N.charCodeAt(N.length-1),m);R.inside&&Qh(w,!1),C.outside&&b!==` -`&&b!=="\r"&&Qh(l,!1),R.outside&&(o=v),l.push({value:d,attention:f},...w,{value:d,attention:f}),a=d.charAt(d.length-1)}return l}function gm(n,e,t){let i=new Map;const l=kb(n,i,e,t);let o=l,a=oE(o,e,t);for(;a;){const f=XU(n,i,a,e,t);if(!f){o=l;break}i=f.chosen,o=f.tokens,a=f.mistake}let u="";for(const f of o)u+=f.value;return u}Sb.attention=aE;Sb.peek=KU;function Sb(n,e,t,i){const l=t.enter("phrasing"),o=wb(n,aE,t,t.createTracker(i)),a=gm([o],i.before,i.after);return l(),a}function aE(n,e){return{construct:"emphasis",markers:FU(e)==="*"?["*","_"]:["_","*"],sizes:[1]}}function KU(n,e,t){return t.options.emphasis||"*"}function WU(n,e){let t=!1;return xb(n,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return t=!0,cd}),!!((!n.depth||n.depth<3)&&ub(n)&&(e.options.setext||t))}function ZU(n,e,t,i){const l=Math.max(Math.min(6,n.depth||1),1),o=t.createTracker(i);if(WU(n,t)){const g=t.enter("headingSetext"),b=t.enter("phrasing"),v=t.containerPhrasing(n,{...o.current(),before:` -`,after:` -`});return b(),g(),v+` -`+(l===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(` -`))+1))}const a="#".repeat(l),u=t.enter("headingAtx"),f=t.enter("phrasing");o.move(a+" ");let d=t.containerPhrasing(n,{before:"# ",after:` -`,...o.current()});const m=d.charCodeAt(0);return(m===9||m===32)&&(d=sE(m)+d.slice(1)),d=d?a+" "+d:a,t.options.closeAtx&&(d+=" "+a),f(),u(),d}cE.peek=JU;function cE(n){return n.value||""}function JU(){return"<"}uE.peek=eF;function uE(n,e,t,i){const l=vb(t),o=l==='"'?"Quote":"Apostrophe",a=t.enter("image");let u=t.enter("label");const f=t.createTracker(i);let d=f.move("![");return d+=f.move(t.safe(n.alt,{before:d,after:"]",...f.current()})),d+=f.move("]("),u(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(u=t.enter("destinationLiteral"),d+=f.move("<"),d+=f.move(t.safe(n.url,{before:d,after:">",...f.current()})),d+=f.move(">")):(u=t.enter("destinationRaw"),d+=f.move(t.safe(n.url,{before:d,after:n.title?" ":")",...f.current()}))),u(),n.title&&(u=t.enter(`title${o}`),d+=f.move(" "+l),d+=f.move(t.safe(n.title,{before:d,after:l,...f.current()})),d+=f.move(l),u()),d+=f.move(")"),a(),d}function eF(){return"!"}fE.peek=tF;function fE(n,e,t,i){const l=n.referenceType,o=t.enter("imageReference");let a=t.enter("label");const u=t.createTracker(i);let f=u.move("![");const d=t.safe(n.alt,{before:f,after:"]",...u.current()});f+=u.move(d+"]["),a();const m=t.stack;t.stack=m.filter(function(b){return b!=="phrasing"}),a=t.enter("reference");const g=t.safe(t.associationId(n),{before:f,after:"]",...u.current()});return a(),t.stack=m,o(),l==="full"||!d||d!==g?f+=u.move(g+"]"):l==="shortcut"?f=f.slice(0,-1):f+=u.move("]"),f}function tF(){return"!"}hE.peek=nF;function hE(n,e,t){let i=n.value||"",l="`",o=-1;for(;new RegExp("(^|[^`])"+l+"([^`]|$)").test(i);)l+="`";for(/[^\n\r ]/.test(i)&&(/^[\n\r ]/.test(i)&&/[\n\r ]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++o\u007F]/.test(n.url))}mE.peek=iF;function mE(n,e,t,i){const l=vb(t),o=l==='"'?"Quote":"Apostrophe",a=t.createTracker(i);if(dE(n,t)){const w=t.stack;t.stack=w.filter(function(N){return N!=="phrasing"});const S=t.enter("autolink");let C=a.move("<");return C+=a.move(t.containerPhrasing(n,{before:C,after:">",...a.current()})),C+=a.move(">"),S(),t.stack=w,C}const u=t.enter("link");let f=t.enter("label"),d=a.move("[");const m=t.containerPhrasing(n,{before:d,after:"](",...a.current()});d+=a.move(m),f(),d+=a.move("](");const g=/[\0- \u007F]/.test(n.url),b=i.before.charAt(i.before.length-1);let v=n.title||void 0;if(!v&&!g&&(b===` -`||b==="\r")){let w=0;for(;w",...a.current()})),d+=a.move(">")):(f=t.enter("destinationRaw"),d+=a.move(t.safe(n.url,{before:d,after:typeof v=="string"?" ":")",...a.current()}))),f(),typeof v=="string"&&(f=t.enter(`title${o}`),d+=a.move(" "+l),d+=a.move(t.safe(v,{before:d,after:l,...a.current()})),d+=a.move(l),f()),d+=a.move(")"),u(),d}function iF(n,e,t){return dE(n,t)?"<":"["}pE.peek=rF;function pE(n,e,t,i){const l=n.referenceType,o=t.enter("linkReference");let a=t.enter("label");const u=t.createTracker(i);let f=u.move("[");const d=t.containerPhrasing(n,{before:f,after:"]",...u.current()});f+=u.move(d+"]["),a();const m=t.stack;t.stack=m.filter(function(b){return b!=="phrasing"}),a=t.enter("reference");const g=t.safe(t.associationId(n),{before:f,after:"]",...u.current()});return a(),t.stack=m,o(),l==="full"||!d||d!==g?f+=u.move(g+"]"):l==="shortcut"?f=f.slice(0,-1):f+=u.move("]"),f}function rF(){return"["}function Cb(n){const e=n.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function lF(n){const e=Cb(n),t=n.options.bulletOther;if(!t)return e==="*"?"-":"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(t===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+t+"`) to be different");return t}function sF(n){const e=n.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function gE(n){const e=n.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function oF(n,e,t,i){const l=t.enter("list"),o=t.bulletCurrent;let a=n.ordered?sF(t):Cb(t);const u=n.ordered?a==="."?")":".":lF(t);let f=e&&t.bulletLastUsed?a===t.bulletLastUsed:!1;if(!n.ordered){const m=n.children?n.children[0]:void 0;if((a==="*"||a==="-")&&m&&(!m.children||!m.children[0])&&t.stack[t.stack.length-1]==="list"&&t.stack[t.stack.length-2]==="listItem"&&t.stack[t.stack.length-3]==="list"&&t.stack[t.stack.length-4]==="listItem"&&t.indexStack[t.indexStack.length-1]===0&&t.indexStack[t.indexStack.length-2]===0&&t.indexStack[t.indexStack.length-3]===0&&(f=!0),gE(t)===a&&m){let g=-1;for(;++g-1?e.start:1)+(t.options.incrementListMarker===!1?0:e.children.indexOf(n))+o);let a=o.length+1;(l==="tab"||l==="mixed"&&(e&&e.type==="list"&&e.spread||n.spread))&&(a=Math.ceil(a/4)*4);const u=t.createTracker(i);u.move(o+" ".repeat(a-o.length)),u.shift(a);const f=t.enter("listItem"),d=t.indentLines(t.containerFlow(n,u.current()),m);return f(),d;function m(g,b,v){return b?(v?"":" ".repeat(a))+g:(v?o:o+" ".repeat(a-o.length))+g}}function uF(n,e,t,i){const l=t.enter("paragraph"),o=t.enter("phrasing"),a=t.containerPhrasing(n,i);return o(),l(),a}function fF(n,e,t,i){if(!n.children.some(function(u){return jU(u)}))return t.containerFlow(n,i);const o=t.enter("phrasing"),a=t.containerPhrasing(n,i);return o(),a}function hF(n){const e=n.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}Ob.attention=xE;Ob.peek=dF;function Ob(n,e,t,i){const l=t.enter("phrasing"),o=wb(n,xE,t,t.createTracker(i)),a=gm([o],i.before,i.after);return l(),a}function xE(n,e){return{construct:"strong",markers:hF(e)==="*"?["*","_"]:["_","*"],sizes:[2]}}function dF(n,e,t){return t.options.strong||"*"}function mF(n,e,t,i){const l=e?e.children:[],o=t.indexStack[t.indexStack.length-1];return t.safe(n.value,{...i,afterNode:l[o+1],beforeNode:l[o-1]})}function pF(n){const e=n.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function gF(n,e,t){const i=(gE(t)+(t.options.ruleSpaces?" ":"")).repeat(pF(t));return t.options.ruleSpaces?i.slice(0,-1):i}const yE={blockquote:RU,break:_C,code:HU,definition:UU,emphasis:Sb,hardBreak:_C,heading:ZU,html:cE,image:uE,imageReference:fE,inlineCode:hE,link:mE,linkReference:pE,list:oF,listItem:cF,paragraph:uF,root:fF,strong:Ob,text:mF,thematicBreak:gF};function xF(){return{enter:{table:yF,tableData:zC,tableHeader:zC,tableRow:vF},exit:{codeText:wF,table:bF,tableData:$0,tableHeader:$0,tableRow:$0}}}function yF(n){const e=n._align;this.enter({type:"table",align:e.map(function(t){return t==="none"?null:t}),children:[]},n),this.data.inTable=!0}function bF(n){this.exit(n),this.data.inTable=void 0}function vF(n){this.enter({type:"tableRow",children:[]},n)}function $0(n){this.exit(n)}function zC(n){this.enter({type:"tableCell",children:[]},n)}function wF(n){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,kF));const t=this.stack[this.stack.length-1];t.type,t.value=e,this.exit(n)}function kF(n,e){return e==="|"?e:n}function SF(n){const e=n||{},t=e.tableCellPadding,i=e.tablePipeAlign,l=e.stringLength,o=t?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` -`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:a,tableCell:f,tableRow:u}};function a(v,w,S,C){return d(m(v,S,C),v.align)}function u(v,w,S,C){const N=g(v,S,C),R=d([N]);return R.slice(0,R.indexOf(` -`))}function f(v,w,S,C){const N=S.enter("tableCell"),R=S.enter("phrasing"),M=S.containerPhrasing(v,{...C,before:o,after:o});return R(),N(),M}function d(v,w){return MU(v,{align:w,alignDelimiters:i,padding:t,stringLength:l})}function m(v,w,S){const C=v.children;let N=-1;const R=[],M=w.enter("table");for(;++N0&&!t&&(n[n.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),t}const UF={tokenize:GF,partial:!0};function FF(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:XF,continuation:{tokenize:$F},exit:YF}},text:{91:{name:"gfmFootnoteCall",tokenize:QF},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:qF,resolveTo:VF}}}}function qF(n,e,t){const i=this;let l=i.events.length;const o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let a;for(;l--;){const f=i.events[l][1];if(f.type==="labelImage"){a=f;break}if(f.type==="gfmFootnoteCall"||f.type==="labelLink"||f.type==="label"||f.type==="image"||f.type==="link")break}return u;function u(f){if(!a||!a._balanced)return t(f);const d=ir(i.sliceSerialize({start:a.end,end:i.now()}));return d.codePointAt(0)!==94||!o.includes(d.slice(1))?t(f):(n.enter("gfmFootnoteCallLabelMarker"),n.consume(f),n.exit("gfmFootnoteCallLabelMarker"),e(f))}}function VF(n,e){let t=n.length;for(;t--;)if(n[t][1].type==="labelImage"&&n[t][0]==="enter"){n[t][1];break}n[t+1][1].type="data",n[t+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},n[t+3][1].start),end:Object.assign({},n[n.length-1][1].end)},l={type:"gfmFootnoteCallMarker",start:Object.assign({},n[t+3][1].end),end:Object.assign({},n[t+3][1].end)};l.end.column++,l.end.offset++,l.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},l.end),end:Object.assign({},n[n.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},u=[n[t+1],n[t+2],["enter",i,e],n[t+3],n[t+4],["enter",l,e],["exit",l,e],["enter",o,e],["enter",a,e],["exit",a,e],["exit",o,e],n[n.length-2],n[n.length-1],["exit",i,e]];return n.splice(t,n.length-t+1,...u),n}function QF(n,e,t){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o=0,a;return u;function u(g){return n.enter("gfmFootnoteCall"),n.enter("gfmFootnoteCallLabelMarker"),n.consume(g),n.exit("gfmFootnoteCallLabelMarker"),f}function f(g){return g!==94?t(g):(n.enter("gfmFootnoteCallMarker"),n.consume(g),n.exit("gfmFootnoteCallMarker"),n.enter("gfmFootnoteCallString"),n.enter("chunkString").contentType="string",d)}function d(g){if(o>999||g===93&&!a||g===null||g===91||Mt(g))return t(g);if(g===93){n.exit("chunkString");const b=n.exit("gfmFootnoteCallString");return l.includes(ir(i.sliceSerialize(b)))?(n.enter("gfmFootnoteCallLabelMarker"),n.consume(g),n.exit("gfmFootnoteCallLabelMarker"),n.exit("gfmFootnoteCall"),e):t(g)}return Mt(g)||(a=!0),o++,n.consume(g),g===92?m:d}function m(g){return g===91||g===92||g===93?(n.consume(g),o++,d):d(g)}}function XF(n,e,t){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o,a=0,u;return f;function f(w){return n.enter("gfmFootnoteDefinition")._container=!0,n.enter("gfmFootnoteDefinitionLabel"),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(w),n.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(w){return w===94?(n.enter("gfmFootnoteDefinitionMarker"),n.consume(w),n.exit("gfmFootnoteDefinitionMarker"),n.enter("gfmFootnoteDefinitionLabelString"),n.enter("chunkString").contentType="string",m):t(w)}function m(w){if(a>999||w===93&&!u||w===null||w===91||Mt(w))return t(w);if(w===93){n.exit("chunkString");const S=n.exit("gfmFootnoteDefinitionLabelString");return o=ir(i.sliceSerialize(S)),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(w),n.exit("gfmFootnoteDefinitionLabelMarker"),n.exit("gfmFootnoteDefinitionLabel"),b}return Mt(w)||(u=!0),a++,n.consume(w),w===92?g:m}function g(w){return w===91||w===92||w===93?(n.consume(w),a++,m):m(w)}function b(w){return w===58?(n.enter("definitionMarker"),n.consume(w),n.exit("definitionMarker"),l.includes(o)||l.push(o),mt(n,v,"gfmFootnoteDefinitionWhitespace")):t(w)}function v(w){return e(w)}}function $F(n,e,t){return n.check(_u,e,n.attempt(UF,e,t))}function YF(n){n.exit("gfmFootnoteDefinition")}function GF(n,e,t){const i=this;return mt(n,l,"gfmFootnoteDefinitionIndent",5);function l(o){const a=i.events[i.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?e(o):t(o)}}function KF(n){let t=(n||{}).singleTilde;const i={name:"strikethrough",tokenize:o,resolveAll:l};return t==null&&(t=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function l(a,u){let f=-1;for(;++f1?f(w):(a.consume(w),g++,v);if(g<2&&!t)return f(w);const C=a.exit("strikethroughSequenceTemporary"),N=cs(w);return C._open=!N||N===2&&!!S,C._close=!S||S===2&&!!N,u(w)}}}class WF{constructor(){this.map=[],this.index=new Map}add(e,t,i){ZF(this,e,t,i)}consume(e){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let t=this.map.length;const i=[];for(;t>0;)t-=1,i.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];i.push(e.slice()),e.length=0;let l=i.pop();for(;l;){for(const o of l)e.push(o);l=i.pop()}this.map.length=0,this.index.clear()}}function ZF(n,e,t,i){if(t===0&&i.length===0)return;const l=n.index.get(e);if(l){l[1]+=t,l[2].push(...i);return}const o=[e,t,i];n.map.push(o),n.index.set(e,o)}function JF(n,e){let t=!1;const i=[];for(;e-1;){const{type:he}=i.events[J][1];if(he==="lineEnding"||he==="linePrefix")J--;else break}const F=J>-1?i.events[J][1].type:null,se=F==="tableHead"||F==="tableRow"?E:f;return se===E&&i.parser.lazy[i.now().line]?t(q):se(q)}function f(q){return n.enter("tableHead"),n.enter("tableRow"),d(q)}function d(q){return q===124||(a=!0,o+=1),m(q)}function m(q){return q===null?t(q):Be(q)?o>1?(o=0,i.interrupt=!0,n.exit("tableRow"),n.enter("lineEnding"),n.consume(q),n.exit("lineEnding"),v):t(q):Ke(q)?mt(n,m,"whitespace")(q):(o+=1,a&&(a=!1,l+=1),q===124?(n.enter("tableCellDivider"),n.consume(q),n.exit("tableCellDivider"),a=!0,m):(n.enter("data"),g(q)))}function g(q){return q===null||q===124||Mt(q)?(n.exit("data"),m(q)):(n.consume(q),q===92?b:g)}function b(q){return q===92||q===124?(n.consume(q),g):g(q)}function v(q){return i.interrupt=!1,i.parser.lazy[i.now().line]?t(q):(n.enter("tableDelimiterRow"),a=!1,Ke(q)?mt(n,w,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(q):w(q))}function w(q){return q===45||q===58?C(q):q===124?(a=!0,n.enter("tableCellDivider"),n.consume(q),n.exit("tableCellDivider"),S):U(q)}function S(q){return Ke(q)?mt(n,C,"whitespace")(q):C(q)}function C(q){return q===58?(o+=1,a=!0,n.enter("tableDelimiterMarker"),n.consume(q),n.exit("tableDelimiterMarker"),N):q===45?(o+=1,N(q)):q===null||Be(q)?I(q):U(q)}function N(q){return q===45?(n.enter("tableDelimiterFiller"),R(q)):U(q)}function R(q){return q===45?(n.consume(q),R):q===58?(a=!0,n.exit("tableDelimiterFiller"),n.enter("tableDelimiterMarker"),n.consume(q),n.exit("tableDelimiterMarker"),M):(n.exit("tableDelimiterFiller"),M(q))}function M(q){return Ke(q)?mt(n,I,"whitespace")(q):I(q)}function I(q){return q===124?w(q):q===null||Be(q)?!a||l!==o?U(q):(n.exit("tableDelimiterRow"),n.exit("tableHead"),e(q)):U(q)}function U(q){return t(q)}function E(q){return n.enter("tableRow"),T(q)}function T(q){return q===124?(n.enter("tableCellDivider"),n.consume(q),n.exit("tableCellDivider"),T):q===null||Be(q)?(n.exit("tableRow"),e(q)):Ke(q)?mt(n,T,"whitespace")(q):(n.enter("data"),z(q))}function z(q){return q===null||q===124||Mt(q)?(n.exit("data"),T(q)):(n.consume(q),q===92?ie:z)}function ie(q){return q===92||q===124?(n.consume(q),z):z(q)}}function nq(n,e){let t=-1,i=!0,l=0,o=[0,0,0,0],a=[0,0,0,0],u=!1,f=0,d,m,g;const b=new WF;for(;++tt[2]+1){const w=t[2]+1,S=t[3]-t[2]-1;n.add(w,S,[])}}n.add(t[3]+1,0,[["exit",g,e]])}return l!==void 0&&(o.end=Object.assign({},la(e.events,l)),n.add(l,0,[["exit",o,e]]),o=void 0),o}function PC(n,e,t,i,l){const o=[],a=la(e.events,t);l&&(l.end=Object.assign({},a),o.push(["exit",l,e])),i.end=Object.assign({},a),o.push(["exit",i,e]),n.add(t+1,0,o)}function la(n,e){const t=n[e],i=t[0]==="enter"?"start":"end";return t[1][i]}const iq={name:"tasklistCheck",tokenize:lq};function rq(){return{text:{91:iq}}}function lq(n,e,t){const i=this;return l;function l(f){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?t(f):(n.enter("taskListCheck"),n.enter("taskListCheckMarker"),n.consume(f),n.exit("taskListCheckMarker"),o)}function o(f){return Mt(f)?(n.enter("taskListCheckValueUnchecked"),n.consume(f),n.exit("taskListCheckValueUnchecked"),a):f===88||f===120?(n.enter("taskListCheckValueChecked"),n.consume(f),n.exit("taskListCheckValueChecked"),a):t(f)}function a(f){return f===93?(n.enter("taskListCheckMarker"),n.consume(f),n.exit("taskListCheckMarker"),n.exit("taskListCheck"),u):t(f)}function u(f){return Be(f)?e(f):Ke(f)?n.check({tokenize:sq},e,t)(f):t(f)}}function sq(n,e,t){return mt(n,i,"whitespace");function i(l){return l===null?t(l):e(l)}}function oq(n){return jA([jF(),FF(),KF(n),eq(),rq()])}const aq={};function cq(n){const e=this,t=n||aq,i=e.data(),l=i.micromarkExtensions||(i.micromarkExtensions=[]),o=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),a=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);l.push(oq(t)),o.push(AF()),a.push(EF(t))}function uq(n){return n.replace(/\\n/g,` -`).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\")}const fq={h1:({children:n})=>y.jsx("h3",{className:"mt-3 mb-1.5 text-base font-bold text-ink first:mt-0",children:n}),h2:({children:n})=>y.jsx("h4",{className:"mt-3 mb-1 text-sm font-semibold text-ink first:mt-0",children:n}),h3:({children:n})=>y.jsx("h5",{className:"mt-2 mb-1 text-xs font-semibold text-ink first:mt-0",children:n}),p:({children:n})=>y.jsx("p",{className:"my-1.5 leading-relaxed first:mt-0 last:mb-0",children:n}),strong:({children:n})=>y.jsx("strong",{className:"font-semibold text-ink",children:n}),em:({children:n})=>y.jsx("em",{className:"italic text-ink-secondary",children:n}),del:({children:n})=>y.jsx("del",{className:"text-ink-muted line-through",children:n}),a:({children:n,href:e})=>y.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-chip-indigo-text underline underline-offset-2 hover:text-ink",children:n}),code:({children:n,className:e})=>y.jsx("code",{className:`break-words rounded bg-elevated px-1 py-0.5 font-mono text-chip-indigo-text whitespace-pre-wrap ${e??""}`,children:n}),pre:({children:n})=>y.jsx("pre",{className:"my-2 overflow-x-auto rounded-lg border border-line bg-elevated p-3 font-mono text-xs text-ink [&_code]:bg-transparent [&_code]:px-0 [&_code]:py-0 [&_code]:text-inherit",children:n}),ul:({children:n})=>y.jsx("ul",{className:"my-1.5 list-disc space-y-0.5 pl-5",children:n}),ol:({children:n})=>y.jsx("ol",{className:"my-1.5 list-decimal space-y-0.5 pl-5",children:n}),li:({children:n})=>y.jsx("li",{className:"leading-relaxed",children:n}),blockquote:({children:n})=>y.jsx("blockquote",{className:"my-2 border-l-2 border-line-strong pl-3 text-ink-secondary italic",children:n}),table:({children:n})=>y.jsx("div",{className:"my-2 overflow-x-auto",children:y.jsx("table",{className:"w-full border-collapse text-xs",children:n})}),th:({children:n})=>y.jsx("th",{className:"border border-line bg-elevated px-2 py-1 text-left font-semibold",children:n}),td:({children:n})=>y.jsx("td",{className:"border border-line px-2 py-1 align-top",children:n}),hr:()=>y.jsx("hr",{className:"my-3 border-line"}),img:({alt:n,src:e,title:t})=>y.jsx("img",{src:e,alt:n,title:t,loading:"lazy",referrerPolicy:"no-referrer",className:"my-2 max-w-full rounded-lg border border-line"})};function $h({text:n}){return n?y.jsx(II,{remarkPlugins:[cq,WI],components:fq,children:uq(n)}):null}function TE(n){return n==="completed"||n==="aborted"||n==="failed"}function Vc({label:n}){return y.jsx("kbd",{"aria-hidden":"true",className:"ml-1.5 inline-block rounded border border-line/60 bg-elevated/60 px-1 py-px font-mono text-[10px] font-normal leading-none opacity-90",children:n})}function HC(n){!n||TE(n.status)||PM(n.session_id).catch(()=>{})}const hq={running:"running",completed:"done",skipped:"skipped",failed:"failed",pending:"pending"};function Yh({text:n}){const[e,t]=D.useState(!1),i=D.useRef(void 0);D.useEffect(()=>()=>window.clearTimeout(i.current),[]);const l=async()=>{try{await navigator.clipboard.writeText(n),t(!0),window.clearTimeout(i.current),i.current=window.setTimeout(()=>t(!1),1500)}catch{}};return y.jsx("button",{type:"button",onClick:l,"aria-label":e?"Copied":"Copy content",title:e?"Copied!":"Copy content",className:"absolute right-2 top-2 rounded-md p-1.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:e?y.jsx(_r,{className:"h-3.5 w-3.5"}):y.jsx(ci,{className:"h-3.5 w-3.5"})})}function dq({isOpen:n,onClose:e,directory:t,filename:i,release:l,args:o,onFinished:a}){var _e,B;const[u,f]=D.useState(null),[d,m]=D.useState(!1),[g,b]=D.useState(null),[v,w]=D.useState(null),[S,C]=D.useState(!1),[N,R]=D.useState(0),M=D.useRef(null),I=D.useRef(!1),U=D.useRef(null),E=D.useRef(!1);D.useEffect(()=>{if(!n||!t||!i){f(null),b(null),C(!1),w(null),E.current=!1;return}let j=!0;return m(!0),b(null),C(!1),w(null),zM({directory:t,filename:i,release:l,args:o}).then($=>{j&&(f($),m(!1),($.status==="completed"||$.status==="aborted"||$.status==="failed")&&(a==null||a($.status,$.final_message||"")))}).catch($=>{j&&(($==null?void 0:$.status)===404&&C(!0),b($.message||"Failed to start workflow"),m(!1))}),()=>{j=!1}},[n,t,i,l,o,N]);const T=async j=>{if(!(!u||I.current)){I.current=!0,m(!0);try{const $=await BM(u.session_id,j);f($),($.status==="completed"||$.status==="aborted"||$.status==="failed")&&(a==null||a($.status,$.final_message||""))}catch($){($==null?void 0:$.status)===404?(C(!0),b($.message||"Workflow session on the server has expired.")):b($.message||"Failed to process workflow response")}finally{I.current=!1,m(!1)}}},z=D.useRef(u);z.current=u;const ie=D.useRef(T);ie.current=T;const q=D.useRef(v);q.current=v;const J=D.useRef([]),F=(j,$)=>{var Ne,Te;if(j.key!=="ArrowDown"&&j.key!=="ArrowUp"&&j.key!=="Home"&&j.key!=="End")return;j.preventDefault();const fe=((Ne=z.current)==null?void 0:Ne.steps.length)??0;if(fe===0)return;const pe=j.key==="ArrowDown"?($+1)%fe:j.key==="ArrowUp"?($-1+fe)%fe:j.key==="Home"?0:fe-1;w(pe),(Te=J.current[pe])==null||Te.focus()};D.useEffect(()=>()=>HC(z.current),[]);const se=()=>{E.current||(E.current=!0,HC(z.current),e())},he=()=>{f(null),b(null),C(!1),w(null),E.current=!1,R(j=>j+1)},ne=hs({isOpen:n,onClose:se,dialogRef:M,initialFocusRef:U});if(D.useEffect(()=>{if(!n)return;const j=$=>{var je,It,Gt;if($.key==="Escape"){$.preventDefault(),se();return}const fe=z.current;if(!fe)return;if(TE(fe.status)){$.key==="Enter"&&!$.repeat&&!$.ctrlKey&&!$.metaKey&&!$.altKey&&!I.current&&((je=$.target)==null?void 0:je.tagName)!=="BUTTON"&&((It=document.activeElement)==null?void 0:It.tagName)!=="BUTTON"&&($.preventDefault(),se());return}if(I.current||$.repeat||$.ctrlKey||$.metaKey||$.altKey)return;const pe=$.target;if((pe==null?void 0:pe.tagName)==="INPUT"||(pe==null?void 0:pe.tagName)==="TEXTAREA"||pe!=null&&pe.isContentEditable)return;const Ne=q.current,Te=Ne===null||Ne===fe.current_index,ze=fe.status==="waiting_ask"?"yes":fe.status==="waiting_notify"||fe.status==="waiting_notice"?"ack":null;if(!Te||ze===null)return;if($.key==="Enter"){const un=$.target;if((un==null?void 0:un.tagName)==="BUTTON"||((Gt=document.activeElement)==null?void 0:Gt.tagName)==="BUTTON")return;$.preventDefault(),ie.current(ze);return}if(fe.status!=="waiting_ask")return;const ve=$.key.toLowerCase();ve==="y"?($.preventDefault(),ie.current("yes")):ve==="s"?($.preventDefault(),ie.current("skip")):ve==="n"&&($.preventDefault(),ie.current("no"))};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[n,e]),D.useEffect(()=>{if(!n||!u)return;const j=requestAnimationFrame(()=>{var $;return($=U.current)==null?void 0:$.focus()});return()=>cancelAnimationFrame(j)},[n,u==null?void 0:u.status]),!n)return null;const L=v!==null?u==null?void 0:u.steps[v]:u==null?void 0:u.steps[u.current_index],ee=(u==null?void 0:u.status)==="completed"||(u==null?void 0:u.status)==="aborted"||(u==null?void 0:u.status)==="failed",oe=!!u&&!ee&&!S&&(((_e=u.status)==null?void 0:_e.startsWith("waiting"))??!1),le=(((B=u==null?void 0:u.steps[(u==null?void 0:u.current_index)??-1])==null?void 0:B.phase)??"pre")==="post",Le=!S&&(v===null||v===(u==null?void 0:u.current_index))&&(L!=null&&L.command)&&((u==null?void 0:u.status)==="waiting_notify"||(u==null?void 0:u.status)==="waiting_notice"||(u==null?void 0:u.status)==="waiting_ask")?y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Command:"}),y.jsxs("div",{className:"relative rounded-lg border border-line bg-surface-strong p-4 pr-10 font-mono text-xs text-ink leading-relaxed",children:[y.jsx(Yh,{text:L.command}),L.command]})]}):null;return y.jsx("div",{ref:M,role:"dialog","aria-modal":"true","aria-labelledby":"workflow-runner-title",onKeyDown:ne,className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-xs",children:y.jsxs("div",{className:"animate-modal-in flex h-[80vh] w-full max-w-5xl flex-col rounded-xl border border-frame-line glass-panel overflow-hidden",children:[y.jsxs("div",{className:"flex items-center justify-between border-b border-line px-5 py-3.5 bg-surface-strong/30 shrink-0",children:[y.jsxs("div",{className:"flex items-center gap-2.5",children:[y.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-chip-indigo-bg text-chip-indigo-text",children:y.jsx(oO,{className:"h-4 w-4"})}),y.jsxs("div",{children:[y.jsx("h2",{id:"workflow-runner-title",className:"text-sm font-semibold text-ink",children:"Launch Workflow Engine"}),y.jsxs("p",{className:"text-xs text-ink-muted",children:[i," ",u!=null&&u.pattern?`• Pattern: ${u.pattern}`:""]})]})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[u&&!ee&&!S&&y.jsxs("button",{type:"button",disabled:!oe||d,onClick:()=>T("bypass"),title:le?"Skip the remaining post-launch steps":"Skip the remaining steps and launch with the OS default app",className:"btn inline-flex items-center gap-1.5 rounded-md border border-line bg-surface px-3 py-1.5 text-xs font-medium text-status-warning-text hover:bg-status-warning-bg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 disabled:cursor-not-allowed disabled:opacity-40",children:[y.jsx(uD,{className:"h-3.5 w-3.5"}),le?"Skip rest":"Launch now"]}),y.jsx("button",{type:"button",onClick:se,className:"rounded-md p-1.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:y.jsx(Ei,{className:"h-4 w-4"})})]})]}),y.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[y.jsxs("div",{className:"w-72 border-r border-line bg-surface-strong/20 p-4 overflow-y-auto flex flex-col gap-2 shrink-0",children:[y.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-ink-muted px-1 mb-1",children:"Workflow Steps (Click to inspect)"}),u&&u.steps.length>0?y.jsx("ul",{role:"list",className:"flex flex-col gap-2",children:u.steps.map((j,$)=>{const fe=u.current_index===$&&!ee,pe=v===$||v===null&&fe,Ne=hq[j.status];return y.jsx("li",{children:y.jsxs("button",{ref:Te=>{J.current[$]=Te},type:"button",tabIndex:pe?0:-1,"aria-current":pe?"step":void 0,onKeyDown:Te=>F(Te,$),onClick:()=>w($),className:`flex items-start text-left gap-2.5 rounded-lg border px-3 py-2.5 transition-colors cursor-pointer w-full ${pe?"border-chip-indigo-border bg-chip-indigo-bg shadow-xs ring-1 ring-chip-indigo-border/40":"border-line/60 bg-surface/60 hover:bg-elevated/80"}`,children:[y.jsxs("div",{className:"mt-0.5 shrink-0",children:[j.status==="running"&&y.jsx(ll,{className:"h-4 w-4 animate-spin text-chip-indigo-text"}),j.status==="completed"&&y.jsx(Qk,{className:"h-4 w-4 text-status-success-text"}),j.status==="skipped"&&y.jsx(M4,{className:"h-4 w-4 text-status-warning-text"}),j.status==="failed"&&y.jsx(Gc,{className:"h-4 w-4 text-status-danger-text"}),j.status==="pending"&&y.jsx("div",{className:"h-4 w-4 rounded-full border border-line-strong flex items-center justify-center text-[10px] text-ink-faint font-mono",children:j.index})]}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"font-mono text-[11px] font-bold uppercase text-chip-indigo-text",children:j.action}),y.jsxs("span",{className:"text-[10px] font-mono text-ink-faint",children:["#",j.index," · ",Ne]})]}),y.jsx("p",{className:"truncate font-mono text-[11px] text-ink-secondary mt-0.5",title:j.command,children:j.message?j.message.split(` -`)[0]:j.command}),j.note&&y.jsx("p",{className:"mt-1 text-[10px] text-ink-faint italic",children:j.note})]})]})},j.index)})}):y.jsx("div",{className:"p-4 text-center text-xs text-ink-faint",children:g||S?"Session unavailable — see the error panel.":"Loading steps..."})]}),y.jsxs("div",{className:"flex-1 flex flex-col bg-app",children:[y.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-6",children:y.jsx("div",{className:"space-y-6",children:y.jsxs("div",{className:"rounded-xl border border-line bg-surface p-5 shadow-xs space-y-4",children:[y.jsxs("div",{className:"flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"rounded bg-chip-indigo-bg px-2 py-0.5 font-mono text-xs font-semibold uppercase text-chip-indigo-text",children:(L==null?void 0:L.action)||(u==null?void 0:u.status)}),y.jsx("span",{className:"text-xs text-ink-muted",children:L?`Step ${L.index} of ${u==null?void 0:u.steps.length}`:"Status"}),v!==null&&v!==(u==null?void 0:u.current_index)&&y.jsx("button",{type:"button",onClick:()=>w(null),className:"text-[11px] text-chip-indigo-text hover:underline ml-2",children:"(Return to active step)"})]}),d&&y.jsx(ll,{className:"h-4 w-4 animate-spin text-chip-indigo-text"})]}),y.jsxs("div",{className:"space-y-3 text-xs text-ink font-sans leading-relaxed",children:[(v===null||v===(u==null?void 0:u.current_index))&&(u==null?void 0:u.status)==="waiting_notify"&&u.notify_message&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Notification Message:"}),y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-ink",children:y.jsx($h,{text:u.notify_message})}),Le]}),(v===null||v===(u==null?void 0:u.current_index))&&(u==null?void 0:u.status)==="waiting_notice"&&u.notice_message&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Notice:"}),y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-ink",children:y.jsx($h,{text:u.notice_message})}),Le,y.jsx("p",{className:"text-[11px] text-ink-faint",children:"The command will run when you continue."})]}),(v===null||v===(u==null?void 0:u.current_index))&&(u==null?void 0:u.status)==="waiting_ask"&&u.ask_prompt&&y.jsxs("div",{className:"space-y-2",children:[u.ask_message&&y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-ink",children:y.jsx($h,{text:u.ask_message})}),y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-status-warning-text",children:"Confirmation Prompt:"}),y.jsx("div",{className:"rounded-lg border border-status-warning-border bg-status-warning-bg p-4 text-sm font-medium text-ink",children:u.ask_prompt}),Le]}),ee&&v===null&&y.jsxs("div",{className:`rounded-xl border p-8 text-center space-y-4 ${(u==null?void 0:u.status)==="completed"?"border-status-success-border bg-status-success-bg text-status-success-text":"border-status-danger-border bg-status-danger-bg text-status-danger-text"}`,children:[y.jsx("div",{className:"inline-flex h-12 w-12 items-center justify-center rounded-full bg-surface/50 mx-auto",children:(u==null?void 0:u.status)==="completed"?y.jsx(Qk,{className:"h-6 w-6 text-status-success-text"}):y.jsx(Gc,{className:"h-6 w-6 text-status-danger-text"})}),y.jsxs("div",{className:"space-y-1",children:[y.jsx("h3",{className:"text-base font-bold",children:(u==null?void 0:u.status)==="completed"?"Workflow Finished":"Workflow Terminated"}),y.jsx("p",{className:"text-xs text-ink-secondary max-w-md mx-auto",children:(u==null?void 0:u.final_message)||"The launch sequence has ended."})]}),y.jsx("div",{className:"pt-2",children:y.jsx("button",{type:"button",onClick:e,className:"btn btn-primary px-8 py-2.5 font-bold shadow-lg",children:"Close Engine Runner"})})]}),ee&&v===null&&(u==null?void 0:u.last_output)&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Command Output:"}),y.jsxs("div",{className:"relative",children:[y.jsx(Yh,{text:u.last_output}),y.jsx("pre",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-strong p-4 font-mono text-xs text-ink",children:u.last_output})]})]}),!S&&!(ee&&v===null)&&!((v===null||v===(u==null?void 0:u.current_index))&&((u==null?void 0:u.status)==="waiting_notify"||(u==null?void 0:u.status)==="waiting_ask"||(u==null?void 0:u.status)==="waiting_notice"))&&y.jsxs("div",{className:"space-y-4",children:[(L==null?void 0:L.message)&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Message:"}),y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-xs text-ink",children:y.jsx($h,{text:L.message})})]}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Command:"}),y.jsx("div",{className:"relative rounded-lg border border-line bg-surface-strong p-4 font-mono text-xs text-ink leading-relaxed",children:L!=null&&L.command?y.jsxs(y.Fragment,{children:[y.jsx(Yh,{text:L.command}),y.jsx("span",{className:"block pr-8",children:L.command})]}):"Waiting..."})]}),(L==null?void 0:L.output)&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Output:"}),y.jsxs("div",{className:"relative",children:[y.jsx(Yh,{text:L.output}),y.jsx("pre",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-strong p-4 font-mono text-xs text-ink",children:L.output})]})]}),(L==null?void 0:L.ask)&&y.jsxs("div",{className:"rounded-lg border border-status-warning-border bg-status-warning-bg p-3 text-xs text-status-warning-text",children:[y.jsx("span",{className:"font-semibold",children:"Workflow Guard:"})," ",L.ask]}),(L==null?void 0:L.note)&&y.jsxs("div",{className:"rounded-lg border border-line bg-surface-strong p-3 text-xs text-ink-muted italic",children:[y.jsx("span",{className:"font-semibold text-ink-secondary not-italic uppercase text-[10px]",children:"Log:"})," ",L.note]})]})]})]})})}),(g||S)&&y.jsx("div",{className:"shrink-0 px-6 pt-3",children:y.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-status-danger-border bg-status-danger-bg p-3 text-xs text-status-danger-text",children:[y.jsx(Gc,{className:"mt-0.5 h-4 w-4 shrink-0"}),y.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[y.jsx("p",{children:S?"Workflow session on the server has expired or ended.":g}),S?y.jsxs("div",{className:"space-y-2",children:[g&&y.jsxs("details",{className:"text-ink-muted",children:[y.jsx("summary",{className:"cursor-pointer select-none text-[11px] underline",children:"Raw error (for bug reports)"}),y.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap break-words font-mono text-[11px]",children:g})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("button",{type:"button",onClick:he,className:"btn btn-primary px-4 py-1.5 text-xs font-semibold",children:"Restart workflow"}),y.jsx("button",{type:"button",onClick:se,className:"btn rounded-md border-line bg-surface px-4 py-1.5 text-xs",children:"Close"})]})]}):null]})]})}),y.jsxs("div",{className:"shrink-0 px-6 pt-4 pb-4 border-t border-line flex items-center justify-between bg-app",children:[y.jsx("div",{className:"text-xs text-ink-muted","aria-live":"polite",children:S?"Session unavailable — restart or close above.":(u==null?void 0:u.status)==="waiting_ask"&&(v===null||v===u.current_index)?"Action required to proceed:":(u==null?void 0:u.status)==="waiting_notify"&&(v===null||v===u.current_index)?"Acknowledge message to proceed:":(u==null?void 0:u.status)==="waiting_notice"&&(v===null||v===u.current_index)?"Continue to run the command:":ee?"Session terminated.":"Step in progress..."}),y.jsxs("div",{className:"flex items-center gap-2",children:[!S&&(u==null?void 0:u.status)==="waiting_notice"&&(v===null||v===u.current_index)&&y.jsxs("button",{type:"button",ref:U,disabled:d,onClick:()=>T("ack"),className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:["Run Command",y.jsx(Vc,{label:"↵"})]}),!S&&(u==null?void 0:u.status)==="waiting_notify"&&(v===null||v===u.current_index)&&y.jsxs("button",{type:"button",ref:U,disabled:d,onClick:()=>T("ack"),className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:["Continue Workflow",y.jsx(Vc,{label:"↵"})]}),!S&&(u==null?void 0:u.status)==="waiting_ask"&&(v===null||v===u.current_index)&&y.jsxs(y.Fragment,{children:[y.jsxs("button",{type:"button",disabled:d,onClick:()=>T("no"),className:"btn rounded-md border-line bg-surface px-4 py-2 text-status-danger-text hover:bg-status-danger-bg",children:["Abort Launch",y.jsx(Vc,{label:"N"})]}),y.jsxs("button",{type:"button",disabled:d,onClick:()=>T("skip"),className:"btn rounded-md border-line bg-surface px-4 py-2 text-status-warning-text hover:bg-status-warning-bg",children:["Skip Step",y.jsx(Vc,{label:"S"})]}),y.jsxs("button",{type:"button",ref:U,disabled:d,onClick:()=>T("yes"),className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:["Execute Step",y.jsx(Vc,{label:"Y"})]})]}),ee&&y.jsx("button",{type:"button",ref:U,onClick:e,className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:"Close Runner"})]})]})]})]})]})})}function IC({url:n,label:e,className:t="",onCopied:i,onCopyError:l}){const o=async()=>{try{await navigator.clipboard.writeText(n),i==null||i(n)}catch{l==null||l(n)}};return y.jsxs("span",{className:`flex items-center justify-between gap-2 ${t}`.trim(),children:[y.jsx("code",{className:"truncate font-mono text-[11px] text-ink",children:n}),y.jsx("button",{type:"button",onClick:o,"aria-label":e??`Copy ${n}`,title:e??"Copy",className:"focus-ring shrink-0 rounded p-1 text-ink-faint transition-colors hover:bg-elevated hover:text-ink",children:y.jsx(ci,{className:"h-3.5 w-3.5"})})]})}const mq=";",UC="=";function pq(n){const e=n.trim().toLowerCase();return e==="extension"||e==="file_ext"||e==="filetype"?"ext":e==="directory"||e==="path"||e==="folder"?"dir":e==="recurse"||e==="recursive_search"?"recursive":e==="filter_text"||e==="query"||e==="search"?"filter":e}function FC(n){const e=n.trim();if(!e.includes(UC))return{values:{filter:e},isPlainFilter:!0};const t={};for(const i of e.split(mq)){const l=i.trim();if(!l)continue;const o=l.indexOf(UC);if(o===-1)continue;const a=pq(l.slice(0,o)),u=l.slice(o+1).trim();switch(a){case"filter":t.filter=u;break;case"ext":t.ext=u;break;case"recursive":t.recursive=qC(u,!0);break;case"dir":t.dir=u;break;case"scan":t.scan=qC(u,!1);break}}return{values:t,isPlainFilter:!1}}function qC(n,e){const t=n.toLowerCase();return["0","false","no","off"].includes(t)?!1:["1","true","yes","on"].includes(t)?!0:e}function Qc(n){return/[",\n\r]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}function gq(n,e,t,i){var f,d;const l=[],a=[["Exported",new Date().toISOString()],["App Version",(t==null?void 0:t.release)??"unknown"],["Config File",(t==null?void 0:t.config_path)??"none"],["Config Exists",String((t==null?void 0:t.config_exists)??!1)],["Directory",(t==null?void 0:t.active_directory)??""],["Extensions",((f=t==null?void 0:t.extensions)==null?void 0:f.join(" | "))??""],["Filter Text",i??((d=t==null?void 0:t.filters)==null?void 0:d[0])??""],["Recursive",String((t==null?void 0:t.recursive_search)??!0)],["Title",(t==null?void 0:t.title)??""],["Release",(t==null?void 0:t.release)??""]];for(const[m,g]of a)l.push(`${Qc(m)},${Qc(g)}`);l.push("");const u=e.length>0?e:["filename","path","rel_path"];l.push(u.map(Qc).join(","));for(const m of n){const g=u.map(b=>b in m?Qc(String(m[b]??"")):Qc(m.column_values[b]??""));l.push(g.join(","))}return l.join(`\r -`)}const xq=120,VC=800,yq=4e3,QC=20;function bq(){const[n,e]=D.useState("dark"),[t,i]=D.useState(null),[l,o]=D.useState(null),[a,u]=D.useState(""),[f,d]=D.useState(""),[m,g]=D.useState(""),[b,v]=D.useState(!0),[w,S]=D.useState([]),[C,N]=D.useState(0),[R,M]=D.useState(!1),[I,U]=D.useState(!1),[E,T]=D.useState(null),[z,ie]=D.useState(!1),[q,J]=D.useState(null),[F,se]=D.useState(0),[he,ne]=D.useState(!1),L=D.useRef(0),ee=D.useRef(null),oe=D.useRef(null),[le,A]=D.useState(""),[Le,_e]=D.useState(null),[B,j]=D.useState(!1),[$,fe]=D.useState(null),[pe,Ne]=D.useState(!1),[Te,ze]=D.useState("en"),[ve,je]=D.useState(!1),[It,Gt]=D.useState(!1),[un,_t]=D.useState(!1),[yt,rt]=D.useState(0),[Ut,zn]=D.useState(!1),[Ft,en]=D.useState(null),[ke,qe]=D.useState(null),[Ie,at]=D.useState(!1),[V,K]=D.useState(!1),[de,Se]=D.useState(null),[We,ot]=D.useState(null),[gt,qt]=D.useState(!1),mn=D.useRef(""),[Mi,or]=D.useState(!1),[ao,tn]=D.useState(void 0),[pn,Jn]=D.useState(!1),[gn,hl]=D.useState(null),[ms,zu]=D.useState(0),co=D.useRef(null),ps=D.useRef(null),xe=(H,P="info")=>{H&&(fe({message:H,kind:P}),ps.current&&clearTimeout(ps.current),ps.current=setTimeout(()=>fe(null),P==="error"?1e4:3500))},qn=()=>{ps.current&&clearTimeout(ps.current),fe(null)},ar=H=>{Se(H)},Lt=()=>{var P;oe.current&&(clearTimeout(oe.current),oe.current=null),(P=ee.current)==null||P.abort(),ee.current=new AbortController;const H=++L.current;return ne(!0),U(!1),H},Vt=H=>H===L.current,ei=H=>{Vt(H)&&ne(!1)},ti=D.useRef(null);D.useEffect(()=>{if(!m.trim()){A("");return}const H=window.setTimeout(()=>A(m),xq);return()=>window.clearTimeout(H)},[m]);const Nt=D.useMemo(()=>le.trim()===""?w:w.filter(H=>e8(H.rel_path,le)),[w,le]),uo=m.trim()&&w.length{const H=ti.current,P=H?Nt.findIndex(re=>re.path===H):-1;if(P>=0){se(re=>P!==re?P:re);return}se(re=>Math.min(re,Math.max(0,Nt.length-1)))},[Nt]);const gs=async(H,P=q)=>{var De;const re=await Kg({offset:0,limit:M0,sort_by:P==null?void 0:P.column,sort_dir:P==null?void 0:P.direction,signal:(De=ee.current)==null?void 0:De.signal});return Vt(H)?(S(re.items),N(re.count),M(!0),!0):!1},xn=async(H,P)=>{var re;return!Vt(H)||(await Pk(P,(re=ee.current)==null?void 0:re.signal),!Vt(H)||!await gs(H))?!1:(ti.current=null,se(0),!0)},fo=async()=>{if(I||w.length>=C)return;const H=L.current;U(!0);try{const P=await Kg({offset:w.length,limit:M0,sort_by:q==null?void 0:q.column,sort_dir:q==null?void 0:q.direction});if(!Vt(H))return;const re=new Set(w.map(De=>De.path||De.filename));S(De=>[...De,...P.items.filter(Ze=>!re.has(Ze.path||Ze.filename))]),N(P.count)}catch{xe("Couldn't load more results — scroll to try again.","error")}finally{Vt(H)&&U(!1)}},dl=async()=>{if(pe)return;Ne(!0),xe("Reloading configuration...");const H=Lt();try{const P=await Gh();i(P);const re=await CM();o(re),e(qk(re.theme));const De=re.active_directory||a,Ze=re.extensions[0]??"",et=re.filters[0]??"";De&&u(De),d(Ze),g(et),v(re.recursive_search),re.reloaded===!1?xe(`Config file not found: ${re.config_path||"(unknown path)"} — kept current configuration.`,"error"):xe("Configuration reloaded."),De&&await xn(H,{directory:De,extension:Ze,filter_text:et,recursive:re.recursive_search})}catch(P){xe(`Failed to reload configuration: ${P.message}`,"error")}finally{Ne(!1),ei(H)}},xs=async H=>{const P=Lt();o(H),e(qk(H.theme));const re=H.active_directory||a||(H.directories[0]??""),De=H.extensions[0]??"",Ze=H.filters[0]??"";if(re&&u(re),d(De),g(Ze),v(H.recursive_search),H.session_trial||xe(H.config_exists?`Loaded config: ${H.config_path}`:"Starter configuration created."),re)try{await xn(P,{directory:re,extension:De,filter_text:Ze,recursive:H.recursive_search})}catch(et){xe(`Scan failed after config load: ${et.message}`,"error")}finally{ei(P)}else ei(P)},[xm,Bu]=D.useState(!1),ys=D.useRef(Kh()),cr=H=>{ys.current=H,Bu(H.overlayVisible)},Pa=D.useRef(()=>{}),Pu=async H=>{try{const P=await H.text(),re=await YC(H.name,P);await xs(re),xe(`Session config applied: ${H.name}`)}catch(P){xe(P.message||"Failed to apply dropped configuration","error")}};Pa.current=H=>{Pu(H)};const ho=D.useRef(0),Ha=D.useRef(async()=>{});D.useEffect(()=>{Ha.current=async()=>{const H=await _k();await xs(H)}}),D.useEffect(()=>{const H=async()=>{let re=[];try{re=(await yM(ho.current)).events}catch{return}for(const De of re){if(ho.current=Math.max(ho.current,De.id),De.config_applied)try{await Ha.current()}catch{}xe(De.message)}},P=setInterval(()=>void H(),yq);return()=>clearInterval(P)},[]),D.useEffect(()=>{const H=et=>{var yn;return Array.from(((yn=et.dataTransfer)==null?void 0:yn.types)??[]).includes("Files")},P=et=>{cr(Fk(ys.current,"enter",H(et)))},re=et=>{H(et)&&et.preventDefault()},De=et=>{cr(Fk(ys.current,"leave",H(et)))},Ze=et=>{var ht;et.preventDefault(),cr(Kh());const yn=Array.from(((ht=et.dataTransfer)==null?void 0:ht.files)??[]),Ve=UM(yn);if(!Ve){yn.length>0&&xe("Not a ProFiles configuration file.","error");return}Pa.current(Ve)};return window.addEventListener("dragenter",P),window.addEventListener("dragover",re),window.addEventListener("dragleave",De),window.addEventListener("drop",Ze),()=>{window.removeEventListener("dragenter",P),window.removeEventListener("dragover",re),window.removeEventListener("dragleave",De),window.removeEventListener("drop",Ze)}},[]);const Ia=()=>{je(!0)},Ua=async H=>{const P=Lt();je(!1),u(H),xe(`Directory selected: ${H}`);let re;try{re=await Lk(H),o(re)}catch(et){console.error("select-directory failed:",et)}if(!Vt(P))return;const De=re!=null&&re.extensions.includes(f)?f:(re==null?void 0:re.extensions[0])??f,Ze=re!=null&&re.filters.includes(m)?m:(re==null?void 0:re.filters[0])??m;d(De),g(Ze);try{await xn(P,{directory:H,extension:De,filter_text:Ze,recursive:b})}catch(et){Vt(P)&&xe(`Scan failed: ${et.message}`,"error")}finally{ei(P)}},Hu=async(H,P)=>{if(!Vt(P))return;const re=H.theme==="auto"?"dark":H.theme==="light"?"light":"dark";e(re);try{localStorage.setItem("profiles-theme",re)}catch{}o(H);const De=H.active_directory||(H.directories.length>0?H.directories[0]:""),Ze=H.extensions.length>0?H.extensions[0]:"",et=H.filters.length>0?H.filters[0]:"";if(De&&u(De),Ze&&d(Ze),H.recursive_search!==void 0&&v(H.recursive_search),et&&g(et),H.config_exists||Gt(!0),De)try{await xn(P,{directory:De,extension:Ze,filter_text:et,recursive:H.recursive_search})}catch(yn){Vt(P)&&xe(`Initial scan failed: ${yn.message}`,"error")}},Fa=async()=>{var P;(P=ee.current)==null||P.abort(),ee.current=new AbortController;const H=++L.current;T(null),ie(!0);try{const re=await Gh();i(re);const De=await _k();await Hu(De,H)}catch(re){T((re==null?void 0:re.message)||"Couldn't fetch system info or configuration.")}finally{ie(!1)}};D.useEffect(()=>{Fa()},[]),D.useEffect(()=>()=>{var H;oe.current&&(clearTimeout(oe.current),oe.current=null),(H=ee.current)==null||H.abort()},[]);const ni=async H=>{const P=Lt();u(H);try{const re=await Lk(H);if(!Vt(P))return;o(re);const De=re.extensions.includes(f)?f:re.extensions[0]??"",Ze=re.filters.includes(m)?m:re.filters[0]??"";d(De),g(Ze),await xn(P,{directory:H,extension:De,filter_text:Ze,recursive:b})}catch(re){Vt(P)&&xe(`Directory change failed: ${re.message}`,"error")}finally{ei(P)}},zt=async()=>{if(!a)return;const H=Lt();try{await xn(H,{directory:a,extension:f,filter_text:m,recursive:b})}catch(P){Vt(H)&&xe(`Scan failed: ${(P==null?void 0:P.message)??P}`,"error")}finally{ei(H)}},Kt=D.useRef(zt);D.useEffect(()=>{Kt.current=zt});const ml=H=>{g(H),oe.current&&clearTimeout(oe.current),oe.current=setTimeout(()=>{oe.current=null,Kt.current()},VC)},Iu=H=>{v(H),oe.current&&clearTimeout(oe.current),oe.current=setTimeout(()=>{oe.current=null,Kt.current()},VC)},ym=async()=>{if(g(""),!a)return;const H=Lt();try{await xn(H,{directory:a,extension:f,filter_text:"",recursive:b})}catch(P){Vt(H)&&xe(`Scan failed: ${(P==null?void 0:P.message)??P}`,"error")}finally{ei(H)}},bm=async()=>{if(v(!1),!a)return;const H=Lt();try{await xn(H,{directory:a,extension:f,filter_text:m,recursive:!1})}catch(P){Vt(H)&&xe(`Scan failed: ${P.message}`,"error")}finally{ei(H)}},Hr=async(H,P)=>{if(H.has_hook){ot({file:H,args:P});return}try{await MM({directory:a,filename:H.rel_path,release:l==null?void 0:l.release,args:P}),xe(`Launched ${H.filename}`)}catch(re){xe(`Launch error: ${re.message}`,"error")}},pl=()=>{Nt.length>0&&Nt[F]&&Hr(Nt[F])},mo=H=>{var P;ti.current=((P=Nt[H])==null?void 0:P.path)??null,se(H)},po=async(H,P)=>{Hr(H,P)},Ir=async H=>{try{await KC(H.path),xe("Revealed in file manager.")}catch(P){xe(`Error: ${P.message}`,"error")}},gl=async H=>{try{await Y0(H.path),xe("Folder opened in file manager.")}catch(P){xe(`Error: ${P.message}`,"error")}},bs=async H=>{try{const P=await Hk(H.path);xe(P.message||"Terminal opened.")}catch(P){xe(`Error: ${P.message}`,"error")}},xl=async H=>{try{await ni(H),xe(`Scanned directory: ${H}`)}catch(P){xe(`Error: ${P.message}`,"error")}},nn=H=>{g(H);const P=Lt();xn(P,{directory:a,extension:f,filter_text:H,recursive:b}).catch(re=>{Vt(P)&&xe(`Scan failed: ${(re==null?void 0:re.message)??re}`,"error")}).finally(()=>ei(P))},Uu=H=>{d(H);const P=Lt();xn(P,{directory:a,extension:H,filter_text:m,recursive:b}).catch(re=>{Vt(P)&&xe(`Scan failed: ${(re==null?void 0:re.message)??re}`,"error")}).finally(()=>ei(P))},Fu=async(H,P)=>{const re=P?H.path.replace(/\\/g,"/"):H.path;try{await navigator.clipboard.writeText(re),xe("Path copied to clipboard.")}catch(De){xe(`Copy failed: ${(De==null?void 0:De.message)??De}`,"error")}},qu=async(H,P)=>{let re=H.filename;if(P){const De=re.lastIndexOf(".");De!==-1&&(re=re.slice(0,De))}try{await navigator.clipboard.writeText(re),xe("Filename copied to clipboard.")}catch(De){xe(`Copy failed: ${(De==null?void 0:De.message)??De}`,"error")}},Ur=async(H,P)=>{try{xe(`Computing ${P.toUpperCase()}...`);const re=await Ik(H.path,P);await navigator.clipboard.writeText(re.hash),xe(`${P.toUpperCase()} hash copied: ${re.hash.slice(0,12)}...`)}catch(re){xe(`Hash computation failed: ${re.message}`,"error")}},yl=async H=>{try{const P=new URL("file:///").href+H.path.replace(/\\/g,"/");await navigator.clipboard.writeText(P),xe("File URI copied to clipboard.")}catch(P){xe(`URI copy failed: ${P.message}`,"error")}},vm=async(H,P)=>{try{const re=await navigator.clipboard.readText();if(!re.trim()){xe("Clipboard is empty — copy a hash first, then try again.");return}xe(`Computing ${P.toUpperCase()}...`);const Ze=(await Ik(H.path,P)).hash.toLowerCase()===re.trim().toLowerCase();xe(Ze?`✅ ${P.toUpperCase()} matches!`:`❌ ${P.toUpperCase()} mismatch`)}catch(re){xe(`Verification failed: ${re.message}`,"error")}},qa=H=>{qe(H),zn(!0)},Vu=H=>{en(H)},wm=async()=>{const H=Ft;if(en(null),!!H)try{if(xe("Deleting file..."),!(await fetch("/api/actions/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:H.path})})).ok)throw new Error("Failed to delete file");xe("File deleted successfully."),zt()}catch(P){xe(`Delete failed: ${P.message}`,"error")}},ct=H=>{tn(H.path),or(!0)},Va=async()=>{if(a)try{await Y0(a),xe("Directory opened in file manager.")}catch(H){xe(`Error: ${H.message}`,"error")}},go=async H=>{if(H)try{await Hk(H),xe("Terminal opened in directory.")}catch(P){xe(`Error: ${P.message}`,"error")}},vs=async()=>{try{await ni("~"),xe("Directory set to home folder.")}catch(H){xe(`Error: ${H.message}`,"error")}},Qi=async()=>{if(a)try{const H=await GC(a);H.parent_path?(await ni(H.parent_path),xe("Moved to parent directory.")):xe("Already at root directory.")}catch(H){xe(`Error: ${H.message}`,"error")}},Vn=async()=>{if(w.length===0){xe("No files to export.");return}try{const H=gq(w,(l==null?void 0:l.column_names)||[],l??void 0,m),P=`profiles-export-${new Date().toISOString().slice(0,19).replace(/[:.]/g,"-")}.csv`,re=await _M(H,P);xe(`Exported ${w.length} loaded row${w.length===1?"":"s"}${m?` matching "${m}"`:""} — ${re.message}`)}catch(H){xe(`Export failed: ${H.message}`,"error")}},Qu=async H=>{var Ve,ht;Jn(!1),xe("Barcode detected!");const re=FC(H).values,De=re.dir!==void 0?re.dir:a,Ze=re.ext!==void 0?re.ext:f,et=re.filter!==void 0?re.filter:m,yn=re.recursive!==void 0?re.recursive:b;if(re.dir!==void 0&&u(re.dir),re.ext!==void 0&&d(re.ext),re.filter!==void 0&&g(re.filter),re.recursive!==void 0&&v(re.recursive),De){const bt=Lt();try{await Pk({directory:De,extension:Ze,filter_text:et,recursive:yn},(Ve=ee.current)==null?void 0:Ve.signal);const ur=await Kg({offset:0,limit:M0,sort_by:q==null?void 0:q.column,sort_dir:q==null?void 0:q.direction,signal:(ht=ee.current)==null?void 0:ht.signal});if(!Vt(bt))return;S(ur.items),N(ur.count),M(!0),ti.current=null,se(0),ur.count===1&&ur.items.length===1&&hl(ur.items[0])}catch(ur){Vt(bt)&&xe(`Scan error: ${ur.message}`,"error")}finally{ei(bt)}}},km=()=>{qt(H=>{const P=!H;return P?(mn.current="",xe("Barcode mode ON — scan a barcode now.")):(mn.current="",xe("Barcode mode OFF.")),P})},Qa=H=>{H.filter!==void 0&&g(H.filter),H.ext!==void 0&&d(H.ext),H.recursive!==void 0&&v(H.recursive),H.dir!==void 0&&u(H.dir),(H.scan===!0||H.filter!==void 0||H.ext!==void 0||H.recursive!==void 0||H.dir!==void 0)&&(qt(!1),mn.current="",setTimeout(()=>{Kt.current()},50))};D.useEffect(()=>{if(!gt)return;const H=P=>{const re=P.target;if(!(re instanceof HTMLElement&&(re.isContentEditable||re instanceof HTMLInputElement||re instanceof HTMLTextAreaElement||re instanceof HTMLSelectElement)))if(P.key==="Enter"){const Ze=mn.current;if(!Ze){mn.current="";return}P.preventDefault(),mn.current="";const et=FC(Ze);if(et.isPlainFilter)xe(`Barcode filter: ${et.values.filter}`),g(et.values.filter||""),qt(!1),setTimeout(()=>void Kt.current(),50);else{const yn=et.values,Ve=Object.entries(yn).map(([ht,bt])=>`${ht}=${bt}`).join(", ");xe(`Barcode applied: ${Ve}`),Qa(yn)}}else P.key==="Escape"?(qt(!1),mn.current="",xe("Barcode mode cancelled.")):P.key.length===1&&!P.ctrlKey&&!P.metaKey&&!P.altKey&&(mn.current+=P.key)};return document.addEventListener("keydown",H,!0),()=>document.removeEventListener("keydown",H,!0)},[gt]),D.useEffect(()=>(ms>0&&(co.current=setInterval(()=>{Kt.current()},ms*1e3)),()=>{co.current&&(clearInterval(co.current),co.current=null)}),[ms]);const Xu=H=>{zu(H),H>0?xe(`Auto-rescan every ${H}s.`):xe("Auto-rescan disabled.")},$u=!!(Le||B||ve||It||Ut||Ie||V||Mi||pn||gn||We||Ft);return D.useEffect(()=>{const H=P=>{var De,Ze,et,yn;if(P.key==="Escape"){_e(null),j(!1),at(!1),K(!1),cr(Kh());return}if($u)return;if(P.ctrlKey&&!P.shiftKey&&P.key.toLowerCase()==="l"){P.preventDefault(),(De=document.querySelector("[data-testid='file-list']"))==null||De.focus();return}const re=P.target;if(!(re instanceof HTMLElement&&re.closest("button, a, [role='menuitem'], [role='option'], [role='columnheader'], [role='separator']"))){if(re instanceof HTMLInputElement||re instanceof HTMLSelectElement){P.key==="Enter"&&zt();return}if(P.key==="ContextMenu"||P.shiftKey&&P.key==="F10"){const Ve=Nt[F];if(!Ve)return;P.preventDefault();const ht=document.querySelector(`[data-row-index="${F}"]`),bt=ht==null?void 0:ht.getBoundingClientRect();_e({x:bt?bt.left+24:24,y:bt?bt.top+bt.height/2:24,file:Ve});return}if(P.key==="F5"){P.preventDefault(),zt();return}if(P.ctrlKey&&P.key.toLowerCase()==="r"){P.preventDefault(),dl();return}if(P.ctrlKey&&P.key.toLowerCase()==="d"){P.preventDefault(),(Ze=document.querySelector("#directory-combobox"))==null||Ze.focus();return}if(P.ctrlKey&&P.key.toLowerCase()==="e"){P.preventDefault(),(et=document.querySelector("#extension-combobox"))==null||et.focus();return}if(P.ctrlKey&&P.key.toLowerCase()==="f"){P.preventDefault(),(yn=document.querySelector("#filter-combobox"))==null||yn.focus();return}if(P.ctrlKey&&P.shiftKey&&P.key.toLowerCase()==="l"){P.preventDefault(),at(Ve=>!Ve);return}if(P.ctrlKey&&P.key===","){P.preventDefault(),_t(!0);return}if(P.ctrlKey&&P.shiftKey&&P.key.toLowerCase()==="t"){P.preventDefault(),e(Ve=>Ve==="dark"?"light":"dark");return}if(P.ctrlKey&&!P.shiftKey&&P.key.toLowerCase()==="b"){P.preventDefault(),qt(Ve=>!Ve);return}if(P.ctrlKey&&P.shiftKey&&P.key.toLowerCase()==="b"){P.preventDefault(),Jn(Ve=>!Ve);return}if(P.ctrlKey&&!P.shiftKey&&P.key.toLowerCase()==="t"){P.preventDefault(),K(!0);return}if(P.ctrlKey&&!P.shiftKey&&P.key.toLowerCase()==="h"){P.preventDefault(),vs();return}if(P.key==="?"||P.ctrlKey&&P.key==="/"){P.preventDefault(),j(Ve=>!Ve);return}if(P.key.toLowerCase()==="p"&&!P.ctrlKey&&!P.shiftKey&&!P.altKey){const Ve=Nt[F];Ve&&(P.preventDefault(),qa(Ve));return}P.key==="ArrowDown"?(P.preventDefault(),se(Ve=>{var bt;const ht=Math.min(Ve+1,Math.max(0,Nt.length-1));return ti.current=((bt=Nt[ht])==null?void 0:bt.path)??null,ht})):P.key==="ArrowUp"?(P.preventDefault(),se(Ve=>{var bt;const ht=Math.max(Ve-1,0);return ti.current=((bt=Nt[ht])==null?void 0:bt.path)??null,ht})):P.key==="Home"?(P.preventDefault(),se(Ve=>{var ht;return ti.current=((ht=Nt[0])==null?void 0:ht.path)??null,Ve===0?Ve:0})):P.key==="End"?(P.preventDefault(),se(Ve=>{var bt;const ht=Math.max(0,Nt.length-1);return ti.current=((bt=Nt[ht])==null?void 0:bt.path)??null,Ve===ht?Ve:ht})):P.key==="PageUp"?(P.preventDefault(),se(Ve=>{var bt;const ht=Math.max(Ve-QC,0);return ti.current=((bt=Nt[ht])==null?void 0:bt.path)??null,ht})):P.key==="PageDown"?(P.preventDefault(),se(Ve=>{var bt;const ht=Math.min(Ve+QC,Math.max(0,Nt.length-1));return ti.current=((bt=Nt[ht])==null?void 0:bt.path)??null,ht})):P.key==="Enter"&&(P.preventDefault(),pl())}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[$u,Nt,F,a,f,m,b,gt]),D.useEffect(()=>{document.documentElement.setAttribute("data-theme",n);try{localStorage.setItem("profiles-theme",n)}catch{}},[n]),y.jsxs("div",{className:"flex h-dvh flex-col bg-elevated/30 p-1 font-sans text-ink transition-colors duration-200 sm:p-1.5",children:[y.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-frame-line bg-app shadow-[0_2px_6px_rgb(0_0_0/0.35)] transition-colors duration-200 sm:rounded-xl",children:[y.jsx($9,{title:(l==null?void 0:l.title)||"",release:(l==null?void 0:l.release)||"",directories:(l==null?void 0:l.directories)||[],activeDirectory:a,onDirectoryChange:ni,onBrowseDirectory:Ia,onGoToParentDirectory:Qi,onGoToHomeDirectory:vs,onOpenActiveDirectory:Va,onOpenTerminal:go}),y.jsx(n8,{extensions:(l==null?void 0:l.extensions)||[],activeExtension:f,onExtensionChange:d,filterOptions:(l==null?void 0:l.filters)||[],filterText:m,onFilterTextChange:ml,recursive:b,onRecursiveChange:Iu,onScan:zt,scanning:he,barcodeMode:gt,onBarcodeToggle:km,onCameraBarcodeClick:()=>Jn(!0),autoRescanActive:ms>0,onTimerClick:()=>K(!0)}),E?y.jsx(Y9,{message:E,onRetry:()=>void Fa(),retrying:z}):y.jsx(X9,{files:Nt,totalCount:C,rawLoadedCount:w.length,onLoadMore:fo,loadingMore:I,scanning:he,hasScanned:R,activeDirectory:a,recursive:b,onDisableRecursive:bm,onOpenDirectory:Va,onLoadConfig:()=>Gt(!0),filterText:m,onClearFilter:ym,columnHeaders:(l==null?void 0:l.column_headers)||[],columnNames:(l==null?void 0:l.column_names)||[],selectedIndex:F,onSelectIndex:mo,prefilterNote:uo,onLaunch:Hr,onContextMenu:(H,P,re)=>{H.preventDefault(),ti.current=P.path,se(re),_e({x:H.clientX,y:H.clientY,file:P})},rowColors:(l==null?void 0:l.row_colors)||[],sort:q,onSortChange:H=>{J(H),ti.current=null,se(0);const P=Lt();gs(P,H).catch(re=>{Vt(P)&&xe(`Sort failed: ${re.message}`,"error")}).finally(()=>ei(P))}}),y.jsx(_D,{onExecute:pl,scanning:he,scanningDirectory:a,hasSelection:Nt.length>0,fileCount:Nt.length,totalCount:C,toastMessage:$,onToastDismiss:qn}),y.jsx(S8,{systemInfo:t,fileCount:C,theme:n,onToggleTheme:()=>e(H=>H==="dark"?"light":"dark"),onOpenLog:()=>at(!0),onOpenConfig:()=>_t(!0),onShowShortcuts:()=>j(!0),onReloadConfig:dl,onExport:Vn,exportDisabled:w.length===0||he,language:Te,onLanguageChange:ze,lanEnabled:(t==null?void 0:t.lan_enabled)??null,onToggleLan:ar})]}),y.jsx(U9,{open:un,onClose:()=>_t(!1),onApplied:xs,onLoadConfig:()=>Gt(!0),reloadKey:yt}),y.jsx(a8,{isOpen:It,activeConfigPath:l==null?void 0:l.config_path,configExists:l==null?void 0:l.config_exists,onClose:()=>Gt(!1),onLoaded:H=>{xs(H),rt(P=>P+1)}}),y.jsx(V9,{visible:xm,onFileSelected:H=>Pa.current(H)}),y.jsx(q9,{isOpen:ve,initialPath:a,onClose:()=>je(!1),onSelect:Ua}),y.jsx(F9,{position:Le,onClose:()=>_e(null),onLaunch:Hr,onLaunchWithArgs:po,onReveal:Ir,onOpenFolder:gl,onOpenTerminal:bs,onScanDirectory:xl,onFilterFolder:nn,onFilterExtension:Uu,onCopyPath:Fu,onCopyFilename:qu,onCopyUri:yl,onComputeHash:Ur,onVerifyHash:vm,onProperties:qa,onClearFile:Vu,onGenerateBarcode:ct,showToast:xe}),y.jsx(o8,{isOpen:B,onClose:()=>j(!1)}),y.jsx(d8,{isOpen:Ut,file:ke,onLaunch:Hr,onClose:()=>{zn(!1),qe(null)}}),y.jsx(O8,{isOpen:V,currentInterval:ms,onClose:()=>K(!1),onSetInterval:Xu}),y.jsx(s8,{isOpen:Ie,onClose:()=>at(!1),onOpenExternally:()=>{bM().then(H=>xe(H.message))}}),y.jsx(dq,{isOpen:!!We,onClose:()=>ot(null),directory:a,filename:(We==null?void 0:We.file.rel_path)||"",release:l==null?void 0:l.release,args:We==null?void 0:We.args,onFinished:(H,P)=>{H==="completed"?xe(P||"Workflow launched successfully."):(H==="aborted"||H==="failed")&&xe(`Workflow stopped: ${P}`,"error")}}),y.jsx(gA,{isOpen:Mi,onClose:()=>{or(!1),tn(void 0)},initialFilePath:ao}),y.jsx(w8,{isOpen:pn,onClose:()=>Jn(!1),onDetected:Qu}),y.jsx(va,{isOpen:!!Ft,title:"Delete file",message:`Delete this file? - -${(Ft==null?void 0:Ft.path)??""} - -This action cannot be undone.`,confirmLabel:"Delete",danger:!0,onConfirm:wm,onCancel:()=>en(null)}),y.jsx(va,{isOpen:de!==null,title:de?"Enable LAN access?":"Restrict to this machine?",message:de?y.jsxs("span",{className:"block",children:["ProFiles will be reachable by anyone on this network:",y.jsx(IC,{url:`http://${t==null?void 0:t.hostname}:${window.location.port}`,label:"Copy hostname URL",className:"mt-1.5",onCopied:()=>xe("URL copied to clipboard."),onCopyError:()=>xe("Failed to copy URL.","error")}),y.jsx(IC,{url:`http://${t==null?void 0:t.ip}:${window.location.port}`,label:"Copy IP URL",className:"mt-1.5",onCopied:()=>xe("URL copied to clipboard."),onCopyError:()=>xe("Failed to copy URL.","error")})]}):"ProFiles will be reachable only on this machine.",confirmLabel:de?"Enable LAN":"Restrict",onConfirm:async()=>{const H=de;Se(null);try{await wM(H),xe(H?"Updating LAN binding…":"Restricting ProFiles to this machine…","info");const P=await kM(H);P&&i(P),(P==null?void 0:P.lan_enabled)===H?xe(H?"ProFiles is now reachable on the local network.":"ProFiles is restricted to this machine.","info"):xe("Failed to update LAN binding — the previous address is still active.","error")}catch(P){const re=P instanceof Error?P.message:"Failed to update LAN binding";xe(`Failed to update LAN binding: ${re}`,"error");const De=await Gh();i(De)}},onCancel:()=>Se(null)}),y.jsx(k8,{isOpen:!!gn,file:gn,onConfirm:()=>{if(gn){const H=gn;hl(null),Hr(H)}},onDismiss:()=>hl(null)})]})}class vq extends D.Component{constructor(){super(...arguments);dh(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,i){console.error("Application render error:",t,i.componentStack)}render(){return this.state.error?y.jsx("main",{className:"flex min-h-screen items-center justify-center bg-app p-6 text-ink",children:y.jsxs("section",{className:"w-full max-w-lg rounded-lg border border-line bg-surface p-6",children:[y.jsx("h1",{className:"text-base font-semibold",children:"ProFiles encountered an error"}),y.jsx("p",{className:"mt-2 text-sm text-ink-secondary",children:"The interface could not continue. Reload the application to try again."}),y.jsxs("details",{className:"mt-4 text-xs text-ink-muted",children:[y.jsx("summary",{className:"cursor-pointer",children:"Error details"}),y.jsx("pre",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap",children:this.state.error.message})]}),y.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"btn btn-primary mt-5 px-4 py-2 text-sm font-semibold",children:"Reload application"})]})}):this.props.children}}xM.createRoot(document.getElementById("root")).render(y.jsx(uM.StrictMode,{children:y.jsx(vq,{children:y.jsx(bq,{})})})); diff --git a/src/profiles/web/dist/index.html b/src/profiles/web/dist/index.html index fb30f81..3688c25 100644 --- a/src/profiles/web/dist/index.html +++ b/src/profiles/web/dist/index.html @@ -1,14 +1,14 @@ - - - - - - ProFiles - - + + + + + + ProFiles + + - - -
- - + + +
+ + diff --git a/src/profiles/web/dist/sw.js b/src/profiles/web/dist/sw.js index c0e00d4..02bbd73 100644 --- a/src/profiles/web/dist/sw.js +++ b/src/profiles/web/dist/sw.js @@ -1 +1 @@ -if(!self.define){let e,i={};const s=(s,n)=>(s=new URL(s+".js",n).href,i[s]||new Promise(i=>{if("document"in self){const e=document.createElement("script");e.src=s,e.onload=i,document.head.appendChild(e)}else e=s,importScripts(s),i()}).then(()=>{let e=i[s];if(!e)throw new Error(`Module ${s} didn’t register its module`);return e}));self.define=(n,r)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(i[t])return;let o={};const l=e=>s(e,t),d={module:{uri:t},exports:o,require:l};i[t]=Promise.all(n.map(e=>d[e]||l(e))).then(e=>(r(...e),o))}}define(["./workbox-9c191d2f"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"d8242e2c833950915a4eaa382f82a145"},{url:"assets/index-Di9rzBmt.js",revision:null},{url:"assets/index-BPqTLQSc.css",revision:null},{url:"manifest.webmanifest",revision:"5a42ebe8b55b07b5831cbbddda834829"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))}); +if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(n,r)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let o={};const d=e=>i(e,t),l={module:{uri:t},exports:o,require:d};s[t]=Promise.all(n.map(e=>l[e]||d(e))).then(e=>(r(...e),o))}}define(["./workbox-9c191d2f"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"f418486ad0d311a652f7776b453dcd9f"},{url:"assets/index-CY2LGDSY.js",revision:null},{url:"assets/index-BPqTLQSc.css",revision:null},{url:"manifest.webmanifest",revision:"5a42ebe8b55b07b5831cbbddda834829"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))}); diff --git a/src/profiles/web/src/api/client.test.ts b/src/profiles/web/src/api/client.test.ts index 867d40a..3c9a753 100644 --- a/src/profiles/web/src/api/client.test.ts +++ b/src/profiles/web/src/api/client.test.ts @@ -273,21 +273,58 @@ describe("saveConfigFile", () => { it("POSTs the content and force flag to /api/config/save and returns the applied config", async () => { const fetchMock = vi.fn(async () => new Response( - JSON.stringify({ status: "SAVED", path: "/tmp/.profiles", config: SAMPLE_CONFIG }), + JSON.stringify({ + status: "SAVED", + path: "/tmp/.profiles", + config: SAMPLE_CONFIG, + content_hash: "abc123", + }), { status: 200 }, ), ); vi.stubGlobal("fetch", fetchMock); - const cfg = await saveConfigFile("title: Fresh From Disk\n", true); + const { config: cfg, contentHash } = await saveConfigFile("title: Fresh From Disk\n", true); expect(fetchMock).toHaveBeenCalledWith("/api/config/save", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ content: "title: Fresh From Disk\n", force: true }), + body: JSON.stringify({ + content: "title: Fresh From Disk\n", + force: true, + baseline_hash: null, + overwrite_changes: false, + }), }); expect(cfg.title).toBe("Fresh From Disk"); expect(cfg.config_path).toBe("C:/tmp/.profiles"); + expect(contentHash).toBe("abc123"); + }); + + it("sends the staleness baseline and overwrite decision when provided (issue #116)", async () => { + const fetchMock = vi.fn(async () => + new Response( + JSON.stringify({ status: "SAVED", path: "/tmp/.profiles", config: SAMPLE_CONFIG }), + { status: 200 }, + ), + ); + vi.stubGlobal("fetch", fetchMock); + + await saveConfigFile("title: Fresh From Disk\n", false, { + baselineHash: "deadbeef", + overwriteChanges: true, + }); + + expect(fetchMock).toHaveBeenCalledWith("/api/config/save", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + content: "title: Fresh From Disk\n", + force: false, + baseline_hash: "deadbeef", + overwrite_changes: true, + }), + }); }); it("surfaces the plain-string detail for a session-trial refusal", async () => { @@ -346,13 +383,15 @@ describe("saveConfigFileAs", () => { ); vi.stubGlobal("fetch", fetchMock); - const cfg = await saveConfigFileAs({ - content: "title: Fresh From Disk\n", - filename: ".profiles", - directory: "/tmp/copy", - force: false, - overwrite: true, - }); + const cfg = ( + await saveConfigFileAs({ + content: "title: Fresh From Disk\n", + filename: ".profiles", + directory: "/tmp/copy", + force: false, + overwrite: true, + }) + ).config; expect(fetchMock).toHaveBeenCalledWith("/api/config/save-as", { method: "POST", diff --git a/src/profiles/web/src/api/client.ts b/src/profiles/web/src/api/client.ts index 8e7f39e..9dfe348 100644 --- a/src/profiles/web/src/api/client.ts +++ b/src/profiles/web/src/api/client.ts @@ -242,21 +242,49 @@ export async function fetchConfigTemplate(): Promise<{ content: string; filename return res.json(); } +/** + * Result of a successful save/save-as: the applied config plus the hash + * of what was written — the next save's staleness baseline (issue #116). + */ +export interface ConfigSaveResult { + config: AppConfigData; + contentHash: string | null; +} + +/** Options of `saveConfigFile` — the staleness-guard contract (issue #116). */ +export interface SaveBaselineOptions { + /** Baseline hash from the content/save response the editor loaded. */ + baselineHash?: string | null; + /** True after the user answers the 409 conflict with "overwrite anyway". */ + overwriteChanges?: boolean; +} + /** * Write editor content to the active configuration file and apply it. * Rejects with an ApiError whose `detail` is either a plain message - * (e.g. a session-trial refusal) or a `ValidationIssue[]` gate list — - * callers rendering the compliance gate should inspect `detail`. + * (e.g. a session-trial refusal), a `ValidationIssue[]` gate list, or a + * 409 staleness conflict when the file changed on disk since the + * baseline hash was taken (issue #116) — callers rendering the + * compliance gate / conflict dialog should inspect `detail` and `status`. */ -export async function saveConfigFile(content: string, force: boolean): Promise { +export async function saveConfigFile( + content: string, + force: boolean, + options: SaveBaselineOptions = {}, +): Promise { const res = await fetch("/api/config/save", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ content, force }), + body: JSON.stringify({ + content, + force, + baseline_hash: options.baselineHash ?? null, + overwrite_changes: options.overwriteChanges ?? false, + }), }); if (!res.ok) throw await apiError(res, "Failed to save configuration"); - const payload: { config: AppConfigData } = await res.json(); - return payload.config; + const payload: { config: AppConfigData; content_hash?: string | null } = await res.json(); + return { config: payload.config, contentHash: payload.content_hash ?? null }; } /** @@ -271,15 +299,15 @@ export async function saveConfigFileAs(params: { directory: string; force: boolean; overwrite: boolean; -}): Promise { +}): Promise { const res = await fetch("/api/config/save-as", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(params), }); if (!res.ok) throw await apiError(res, "Failed to save configuration as"); - const payload: { config: AppConfigData } = await res.json(); - return payload.config; + const payload: { config: AppConfigData; content_hash?: string | null } = await res.json(); + return { config: payload.config, contentHash: payload.content_hash ?? null }; } export async function browseForConfigFiles(path: string): Promise { diff --git a/src/profiles/web/src/api/types.ts b/src/profiles/web/src/api/types.ts index 2f70e96..808c342 100644 --- a/src/profiles/web/src/api/types.ts +++ b/src/profiles/web/src/api/types.ts @@ -46,6 +46,13 @@ export interface ConfigContentData { config_path: string | null; /** True when the active config came from a dropped file — Save is refused, use Save As. */ session_trial: boolean; + /** + * SHA-256 hex of the served text (issue #116): echoed back on save as + * the baseline so an external edit between load and Save 409s instead + * of clobbering. Never null from the server; optional keeps older + * mocks/servers compatible. + */ + content_hash?: string | null; } export interface BrowseEntry { diff --git a/src/profiles/web/src/components/ConfigEditorModal.test.tsx b/src/profiles/web/src/components/ConfigEditorModal.test.tsx index 1a51b1d..fc09af2 100644 --- a/src/profiles/web/src/components/ConfigEditorModal.test.tsx +++ b/src/profiles/web/src/components/ConfigEditorModal.test.tsx @@ -7,6 +7,7 @@ import { join } from "node:path"; import { EditorView } from "codemirror"; import { ConfigEditorModal } from "./ConfigEditorModal"; import { + ApiError, browseDirectory, fetchConfigContent, fetchConfigTemplate, @@ -16,18 +17,30 @@ import { saveConfigFileAs, validateConfigContent, } from "../api/client"; -import type { AppConfigData, BrowseResult, ConfigContentData, ValidationIssue } from "../api/types"; - -vi.mock("../api/client", () => ({ - fetchConfigContent: vi.fn(), - openConfigFile: vi.fn(), - fetchConfigTemplate: vi.fn(), - validateConfigContent: vi.fn(), - loadConfigContent: vi.fn(), - saveConfigFile: vi.fn(), - saveConfigFileAs: vi.fn(), - browseDirectory: vi.fn(), -})); +import type { + AppConfigData, + BrowseResult, + ConfigContentData, + ValidationIssue, +} from "../api/types"; +import type { ConfigSaveResult } from "../api/client"; + +vi.mock("../api/client", async (importOriginal) => { + // Keep the real ApiError: the staleness-conflict flow (issue #116) + // branches on `err instanceof ApiError && err.status === 409`. + const actual = await importOriginal(); + return { + ...actual, + fetchConfigContent: vi.fn(), + openConfigFile: vi.fn(), + fetchConfigTemplate: vi.fn(), + validateConfigContent: vi.fn(), + loadConfigContent: vi.fn(), + saveConfigFile: vi.fn(), + saveConfigFileAs: vi.fn(), + browseDirectory: vi.fn(), + }; +}); // jsdom gap (not a CodeMirror mock): the view's measurement code calls // Range geometry APIs that jsdom does not implement. Empty geometry is @@ -83,6 +96,11 @@ function makeAppConfig(): AppConfigData { }; } +/** Successful save/save-as payload: applied config + written-text hash. */ +function makeSaveResult(config: AppConfigData = makeAppConfig(), contentHash = "written-hash"): ConfigSaveResult { + return { config, contentHash }; +} + /** Listing served by /api/fs/browse for the Save As dialog. */ function makeBrowseResult(overrides: Partial = {}): BrowseResult { return { @@ -525,7 +543,7 @@ describe("ConfigEditorModal", () => { fetchContentSpy.mockResolvedValue(makeContent()); validateSpy.mockResolvedValue({ valid: true, issues: [] }); const savedConfig = makeAppConfig(); - saveSpy.mockResolvedValue(savedConfig); + saveSpy.mockResolvedValue(makeSaveResult(savedConfig)); const user = userEvent.setup(); const { onApplied } = renderModal(); @@ -535,8 +553,9 @@ describe("ConfigEditorModal", () => { // The client-side gate validation runs first, on the current doc text… await waitFor(() => expect(validateSpy).toHaveBeenCalledWith("machine.profiles", edited)); - // …then the save endpoint writes it, unforced. - await waitFor(() => expect(saveSpy).toHaveBeenCalledWith(edited, false)); + // …then the save endpoint writes it, unforced, with the staleness + // baseline from the load (no content_hash served → null). + await waitFor(() => expect(saveSpy).toHaveBeenCalledWith(edited, false, { baselineHash: null })); expect(saveAsSpy).not.toHaveBeenCalled(); // Success surface: ok banner, dirty cleared (baseline = saved text), @@ -552,7 +571,7 @@ describe("ConfigEditorModal", () => { await user.keyboard("{Control>}s"); await waitFor(() => expect(validateSpy).toHaveBeenCalledTimes(2)); await waitFor(() => expect(saveSpy).toHaveBeenCalledTimes(2)); - expect(saveSpy.mock.calls[1]).toEqual([edited, false]); + expect(saveSpy.mock.calls[1]).toEqual([edited, false, { baselineHash: "written-hash" }]); expect(onApplied).toHaveBeenCalledTimes(2); }); @@ -605,7 +624,7 @@ describe("ConfigEditorModal", () => { valid: false, issues: [{ severity: "error", message: "unknown key 'foo' at line 3" }], }); - saveSpy.mockResolvedValue(makeAppConfig()); + saveSpy.mockResolvedValue(makeSaveResult()); const user = userEvent.setup(); const { onApplied } = renderModal(); @@ -616,8 +635,8 @@ describe("ConfigEditorModal", () => { // Force is the escape hatch: exactly one save call, with force=true. await user.click(screen.getByRole("button", { name: /force save anyway/i })); await waitFor(() => expect(saveSpy).toHaveBeenCalledTimes(1)); - expect(saveSpy).toHaveBeenCalledWith(edited, true); - expect(saveSpy.mock.calls[0]).toEqual([edited, true]); + expect(saveSpy).toHaveBeenCalledWith(edited, true, { baselineHash: null }); + expect(saveSpy.mock.calls[0]).toEqual([edited, true, { baselineHash: null }]); // Gate cleared, ok banner, dirty cleared, onApplied fired. expect(screen.queryByRole("dialog", { name: /validation issues/i })).toBeNull(); @@ -635,7 +654,7 @@ describe("ConfigEditorModal", () => { makeContent({ filename: "session-trial", config_path: null, session_trial: true }), ); validateSpy.mockResolvedValue({ valid: true, issues: [] }); - saveSpy.mockResolvedValue(makeAppConfig()); + saveSpy.mockResolvedValue(makeSaveResult()); const user = userEvent.setup(); const { onApplied } = renderModal(); @@ -658,9 +677,9 @@ describe("ConfigEditorModal", () => { fetchContentSpy.mockResolvedValue(makeContent()); validateSpy.mockResolvedValue({ valid: true, issues: [] }); // Deferred save: the first request stays pending across both clicks. - let resolveSave!: (value: AppConfigData) => void; + let resolveSave!: (value: ConfigSaveResult) => void; saveSpy.mockReturnValue( - new Promise((resolve) => { + new Promise((resolve) => { resolveSave = resolve; }), ); @@ -675,14 +694,14 @@ describe("ConfigEditorModal", () => { expect(validateSpy).toHaveBeenCalledTimes(1); // The in-flight save still completes exactly once. - resolveSave(makeAppConfig()); + resolveSave(makeSaveResult()); await waitFor(() => expect(onApplied).toHaveBeenCalledTimes(1)); expect(saveSpy).toHaveBeenCalledTimes(1); expect(screen.getByTestId("editor-status").textContent).toMatch(/saved/i); // The gate is released once the action settles — a follow-up works. validateSpy.mockResolvedValue({ valid: true, issues: [] }); - saveSpy.mockResolvedValue(makeAppConfig()); + saveSpy.mockResolvedValue(makeSaveResult()); await user.click(saveButton); await waitFor(() => expect(saveSpy).toHaveBeenCalledTimes(2)); expect(onApplied).toHaveBeenCalledTimes(2); @@ -693,9 +712,9 @@ describe("ConfigEditorModal", () => { templateSpy.mockResolvedValue({ content: TEMPLATE_YAML_LF, filename: "starter.profiles" }); validateSpy.mockResolvedValue({ valid: true, issues: [] }); // Deferred save: the save round-trip stays pending on purpose. - let resolveSave!: (value: AppConfigData) => void; + let resolveSave!: (value: ConfigSaveResult) => void; saveSpy.mockReturnValue( - new Promise((resolve) => { + new Promise((resolve) => { resolveSave = resolve; }), ); @@ -717,7 +736,7 @@ describe("ConfigEditorModal", () => { // The stale save resolution lands after New completed: it belongs to the // discarded document and must not mark it saved or fire onApplied. await act(async () => { - resolveSave(makeAppConfig()); + resolveSave(makeSaveResult()); }); expect(onApplied).not.toHaveBeenCalled(); const view = EditorView.findFromDOM(document.querySelector(".cm-editor") as HTMLElement); @@ -733,7 +752,7 @@ describe("ConfigEditorModal", () => { valid: false, issues: [{ severity: "error", message: "unknown key 'foo' at line 3" }], }); - saveAsSpy.mockResolvedValue(makeAppConfig()); + saveAsSpy.mockResolvedValue(makeSaveResult()); browseSpy.mockResolvedValue(makeBrowseResult()); const user = userEvent.setup(); const { onApplied } = renderModal(); @@ -773,6 +792,99 @@ describe("ConfigEditorModal", () => { await waitFor(() => expect(onApplied).toHaveBeenCalledTimes(1)); expect(saveSpy).not.toHaveBeenCalled(); }); + it("test_save_409_offers_reload_or_overwrite_and_overwrite_wins", async () => { + // The load serves a baseline hash; the file changes on disk before Save. + fetchContentSpy.mockResolvedValue(makeContent({ content_hash: "baseline-hash" })); + validateSpy.mockResolvedValue({ valid: true, issues: [] }); + const conflict = new ApiError( + "The configuration file changed on disk since it was loaded (edited externally?).", + 409, + ); + saveSpy.mockRejectedValueOnce(conflict).mockResolvedValueOnce(makeSaveResult()); + const user = userEvent.setup(); + const { onApplied } = renderModal(); + + const edited = await editDoc("# edited\n"); + await user.click(screen.getByRole("button", { name: /^save$/i })); + + // First save carries the load's baseline; the 409 parks the conflict + // dialog instead of clobbering (issue #116). + await waitFor(() => + expect(saveSpy).toHaveBeenCalledWith(edited, false, { baselineHash: "baseline-hash" }), + ); + const conflictDialog = await screen.findByRole("dialog", { name: /file changed on disk/i }); + expect(conflictDialog.textContent).toContain("Overwrite anyway"); + expect(conflictDialog.textContent).toContain("Reload disk version"); + + // "Overwrite anyway" retries the SAME text with overwrite_changes. + await user.click(within(conflictDialog).getByRole("button", { name: /overwrite anyway/i })); + await waitFor(() => expect(saveSpy).toHaveBeenCalledTimes(2)); + expect(saveSpy.mock.calls[1]).toEqual([ + edited, + false, + { baselineHash: "baseline-hash", overwriteChanges: true }, + ]); + + // Success surface: saved banner, onApplied once (the retry is not a + // second Apply), conflict dialog gone. + const banner = screen.getByTestId("editor-status"); + expect(banner.textContent).toMatch(/saved/i); + expect(onApplied).toHaveBeenCalledTimes(1); + expect(screen.queryByRole("dialog", { name: /file changed on disk/i })).toBeNull(); + }); + + it("test_save_409_reload_adopts_disk_version", async () => { + // First /content serves the editor's baseline; the second (after the + // user picks "Reload disk version") serves the external edits. + fetchContentSpy.mockReset(); + fetchContentSpy + .mockResolvedValueOnce(makeContent({ content_hash: "baseline-hash" })) + .mockResolvedValueOnce( + makeContent({ content: 'defaults:\n title: "External"\n', content_hash: "external-hash" }), + ); + validateSpy.mockResolvedValue({ valid: true, issues: [] }); + saveSpy.mockRejectedValueOnce( + new ApiError("The configuration file changed on disk since it was loaded.", 409), + ); + const user = userEvent.setup(); + const { onApplied } = renderModal(); + + await editDoc("# edited\n"); + await user.click(screen.getByRole("button", { name: /^save$/i })); + const conflictDialog = await screen.findByRole("dialog", { name: /file changed on disk/i }); + + // "Reload disk version" re-fetches and the disk text replaces the + // editor's document — the external edits are adopted, nothing written. + await user.click(within(conflictDialog).getByRole("button", { name: /reload disk version/i })); + await waitFor(() => expect(fetchContentSpy).toHaveBeenCalledTimes(2)); + await waitFor(() => { + const view = EditorView.findFromDOM(document.querySelector(".cm-editor") as HTMLElement); + expect(view?.state.doc.toString()).toBe('defaults:\n title: "External"\n'); + }); + expect(saveSpy).toHaveBeenCalledTimes(1); + expect(onApplied).not.toHaveBeenCalled(); + expect(screen.getByTestId("editor-status").textContent).toMatch(/reloaded from disk/i); + expect(screen.queryByRole("dialog", { name: /file changed on disk/i })).toBeNull(); + }); + + it("test_save_refreshes_the_staleness_baseline_after_each_save", async () => { + // The load's hash guards the first save; the written hash returned by + // the first save guards the second (issue #116). + fetchContentSpy.mockResolvedValue(makeContent({ content_hash: "baseline-hash" })); + validateSpy.mockResolvedValue({ valid: true, issues: [] }); + saveSpy.mockResolvedValue(makeSaveResult(undefined, "written-hash")); + const user = userEvent.setup(); + const { onApplied } = renderModal(); + + const edited = await editDoc("# edited\n"); + await user.click(screen.getByRole("button", { name: /^save$/i })); + await waitFor(() => expect(saveSpy).toHaveBeenCalledWith(edited, false, { baselineHash: "baseline-hash" })); + + await user.keyboard("{Control>}s"); + await waitFor(() => expect(saveSpy).toHaveBeenCalledTimes(2)); + expect(saveSpy.mock.calls[1]).toEqual([edited, false, { baselineHash: "written-hash" }]); + expect(onApplied).toHaveBeenCalledTimes(2); + }); }); /** @@ -1288,4 +1400,5 @@ describe("ConfigEditorModal status bar and problems panel (issue #105)", () => { await readyEditorView(); expect(screen.queryByTestId("problems-panel")).toBeNull(); }); + }); diff --git a/src/profiles/web/src/components/ConfigEditorModal.tsx b/src/profiles/web/src/components/ConfigEditorModal.tsx index 16e3f50..7f9d889 100644 --- a/src/profiles/web/src/components/ConfigEditorModal.tsx +++ b/src/profiles/web/src/components/ConfigEditorModal.tsx @@ -33,6 +33,7 @@ import { saveConfigFileAs, validateConfigContent, } from "../api/client"; +import type { ConfigSaveResult } from "../api/client"; import type { AppConfigData, ConfigContentData, ValidationIssue } from "../api/types"; import { ConfirmDialog } from "./ConfirmDialog"; import { SaveAsDialog } from "./SaveAsDialog"; @@ -100,6 +101,14 @@ type SaveGate = { issues: ValidationIssue[]; resolve: (force: boolean) => void } /** Save As dialog parked on an in-flight save-as action. */ type SaveAsPrompt = { resolve: (target: SaveAsTarget | null) => void }; +/** + * Conflict dialog parked on an in-flight save action (issue #116): the + * server answered 409 — the file changed on disk since it was loaded — + * and the user must choose between adopting the disk version (resolve(false)) + * or overwriting it with the editor's text (resolve(true)). + */ +type StaleGate = { resolve: (overwrite: boolean) => void }; + /** * Editor theme built from the app's `data-theme` CSS tokens (index.css * `--app-editor-*` surface tokens, issue #98). A solid VSCode-style canvas: @@ -228,7 +237,11 @@ function describeSaveError(err: unknown): { text: string; issues: ValidationIssu * the "Load config file…" entry point that raises the config picker above * this modal. Save and Save As run the compliance gate first: the text is * validated client-side, and issues block the write behind a "Go back and - * fix / Force save anyway" prompt. Feedback lives in the footer status bar + * fix / Force save anyway" prompt. Save also carries the staleness + * baseline (issue #116): a 409 — the file changed on disk since it was + * loaded, e.g. via "Open in OS" — parks a "Reload disk version / + * Overwrite anyway" conflict dialog before anything is written. + * Feedback lives in the footer status bar * (validity chip, unsaved dot, action outcome, cursor position) with the * collapsible right-hand Problems panel listing validation issues (#105). */ @@ -258,12 +271,20 @@ export function ConfigEditorModal({ const [gate, setGate] = useState(null); /** Save As dialog parked on an in-flight save-as action. */ const [saveAsPrompt, setSaveAsPrompt] = useState(null); + /** Conflict dialog parked on an in-flight save action (issue #116). */ + const [staleGate, setStaleGate] = useState(null); const dialogRef = useRef(null); const editorHostRef = useRef(null); const editorViewRef = useRef(null); /** Text the editor was seeded with — the baseline for the dirty check. */ const loadedTextRef = useRef(""); + /** + * Hash of the disk text the editor loaded (issue #116) — sent as the + * save's baseline so an external edit between load and Save is refused + * with 409 instead of clobbered. Refreshed on every load/revert/save. + */ + const baselineHashRef = useRef(null); /** * Monotonic id of the most recent toolbar-action dispatch. Each dispatch * tags its round trip with the id current at dispatch time; a resolution @@ -292,7 +313,7 @@ export function ConfigEditorModal({ const runValidationRef = useRef<() => void>(() => {}); /** Latest ref for the scheduling helper itself (see updateListener). */ const scheduleValidationRef = useRef<(text: string) => void>(() => {}); - parkedRef.current = gate !== null || saveAsPrompt !== null; + parkedRef.current = gate !== null || saveAsPrompt !== null || staleGate !== null; const handleDialogKeyDown = useModalA11y({ isOpen: open, @@ -307,6 +328,7 @@ export function ConfigEditorModal({ useEffect(() => { if (!open) { loadedTextRef.current = ""; + baselineHashRef.current = null; editorViewRef.current = null; setLoad({ status: "loading" }); setDirty(false); @@ -319,6 +341,7 @@ export function ConfigEditorModal({ setPendingAction(null); setGate(null); setSaveAsPrompt(null); + setStaleGate(null); // Drop any pending live-validation cycle (issue #100): a stale timer // must not fire into a closed session. if (validationTimerRef.current !== null) { @@ -338,6 +361,7 @@ export function ConfigEditorModal({ if (cancelled) return; const content = toEditorText(data.content); loadedTextRef.current = content; + baselineHashRef.current = data.content_hash ?? null; lastValidatedTextRef.current = content; setLoad({ status: "ready", data: { ...data, content } }); }) @@ -502,6 +526,9 @@ export function ConfigEditorModal({ if (seq !== actionSeqRef.current) return; // superseded — drop stale results const content = toEditorText(template.content); loadedTextRef.current = content; + // A template is not anchored to disk yet — Save stays hidden and + // there is no baseline to defend until the first Save As lands. + baselineHashRef.current = null; setDirty(false); setLoad( (prev): LoadState => @@ -532,6 +559,8 @@ export function ConfigEditorModal({ if (seq !== actionSeqRef.current) return; const content = toEditorText(data.content); loadedTextRef.current = content; + // The reloaded disk text is the new staleness baseline too. + baselineHashRef.current = data.content_hash ?? null; setDirty(false); setLoad({ status: "ready", data: { ...data, content } }); setStatus({ kind: "ok", text: "Configuration reloaded from disk." }); @@ -664,15 +693,37 @@ export function ConfigEditorModal({ [], ); + /** + * Park the staleness conflict dialog on the in-flight save action + * (issue #116): resolve(true) = "Overwrite anyway" (keep the editor's + * text), resolve(false) = "Reload disk version" (adopt the external + * edits, discarding the editor's text). + */ + const awaitStaleDecision = useCallback( + () => + new Promise((resolve) => { + setStaleGate({ + resolve: (overwrite: boolean) => { + setStaleGate(null); + resolve(overwrite); + }, + }); + }), + [], + ); + /** * Shared success surface for Save and Save As: the saved text becomes * the new dirty baseline, the response's fresh AppConfigData refreshes * the header (a Save As re-anchors the file, re-enabling Save) and - * drives the same `onApplied` path as Apply. + * drives the same `onApplied` path as Apply. `contentHash` — the hash + * of what was just written — becomes the next save's staleness + * baseline (issue #116). */ const markSaved = useCallback( - (data: AppConfigData, savedText: string) => { + (data: AppConfigData, savedText: string, contentHash: string | null) => { loadedTextRef.current = savedText; + baselineHashRef.current = contentHash; setDirty(false); setIssues([]); // The document just became the saved baseline — the previous @@ -773,7 +824,7 @@ export function ConfigEditorModal({ const target = await awaitSaveAsTarget(); if (seq !== actionSeqRef.current) return; // superseded while parked if (target === null) return; // cancelled — no save call - const data = await saveConfigFileAs({ + const saved = await saveConfigFileAs({ content: text, filename: target.filename, directory: target.directory, @@ -781,12 +832,37 @@ export function ConfigEditorModal({ overwrite: target.overwrite, }); if (seq !== actionSeqRef.current) return; - markSaved(data, text); + markSaved(saved.config, text, saved.contentHash); setStatus({ kind: "ok", text: `Configuration saved as ${target.filename}.` }); } else { - const data = await saveConfigFile(text, force); + // Staleness guard (issue #116): the save carries the hash of + // the disk text the editor loaded; a 409 means the file + // changed on disk underneath the editor, and the user picks + // between overwriting the external edits and adopting them. + let saved: ConfigSaveResult; + try { + saved = await saveConfigFile(text, force, { + baselineHash: baselineHashRef.current, + }); + } catch (err) { + if (!(err instanceof ApiError) || err.status !== 409) throw err; + const overwrite = await awaitStaleDecision(); + if (seq !== actionSeqRef.current) return; // superseded while parked + if (!overwrite) { + // "Reload disk version": adopt the external edits, the + // editor's text is discarded by the revert. + void reloadFromServer(); + return; + } + // "Overwrite anyway": the second request lifts the guard; + // a second 409 would mean the file changed AGAIN mid-decision. + saved = await saveConfigFile(text, force, { + baselineHash: baselineHashRef.current, + overwriteChanges: true, + }); + } if (seq !== actionSeqRef.current) return; - markSaved(data, text); + markSaved(saved.config, text, saved.contentHash); setStatus({ kind: "ok", text: `Configuration saved to ${filename}.` }); } } catch (err: unknown) { @@ -794,7 +870,16 @@ export function ConfigEditorModal({ reportSaveError(err); } }), - [awaitGateDecision, awaitSaveAsTarget, load, markSaved, reportSaveError, runToolbarAction], + [ + awaitGateDecision, + awaitSaveAsTarget, + awaitStaleDecision, + load, + markSaved, + reportSaveError, + reloadFromServer, + runToolbarAction, + ], ); const runSave = useCallback( @@ -818,7 +903,13 @@ export function ConfigEditorModal({ const modSHandlerRef = useRef<() => void>(() => {}); modSHandlerRef.current = () => { if (load.status !== "ready") return; - if (gate !== null || saveAsPrompt !== null || confirmDiscardOpen || pendingAction !== null) { + if ( + gate !== null || + saveAsPrompt !== null || + staleGate !== null || + confirmDiscardOpen || + pendingAction !== null + ) { return; } if (load.data.config_path !== null) void runSave(); @@ -1221,6 +1312,27 @@ export function ConfigEditorModal({ onCancel={() => gate?.resolve(false)} /> + {/* Staleness conflict (issue #116): the server answered 409 — the + file changed on disk since the editor loaded it. The user picks + between overwriting the external edits and adopting them. */} + staleGate?.resolve(true)} + onCancel={() => staleGate?.resolve(false)} + /> + {/* Target selection for Save As; overwrite is confirmed inside. */} None: assert "theme: dark" in content +class TestWriteTextAtomic: + def test_writes_content(self, tmp_path: Path) -> None: + conf = tmp_path / ".profiles" + write_text_atomic(conf, "version: 1\n") + assert conf.read_text(encoding="utf-8") == "version: 1\n" + + def test_overwrites_existing_file(self, tmp_path: Path) -> None: + conf = tmp_path / ".profiles" + conf.write_text("old\n", encoding="utf-8") + write_text_atomic(conf, "new\n") + assert conf.read_text(encoding="utf-8") == "new\n" + + def test_leaves_no_temp_files_behind(self, tmp_path: Path) -> None: + conf = tmp_path / ".profiles" + write_text_atomic(conf, "version: 1\n") + assert [p.name for p in tmp_path.iterdir()] == [conf.name] + + def test_no_temp_left_behind_when_replace_fails( + self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch + ) -> None: + conf = tmp_path / ".profiles" + conf.write_text("original\n", encoding="utf-8") + + def failing_replace(src: object, dst: object) -> None: + raise OSError("boom") + + monkeypatch.setattr("profiles.core.config.io.yaml_io.os.replace", failing_replace) + with pytest.raises(OSError, match="boom"): + write_text_atomic(conf, "new\n") + # The target is untouched and no .tmp litter remains. + assert conf.read_text(encoding="utf-8") == "original\n" + assert [p.name for p in tmp_path.iterdir()] == [conf.name] + + def test_replaces_not_appends(self, tmp_path: Path) -> None: + """The write is a replacement: shorter content shrinks the file.""" + conf = tmp_path / ".profiles" + write_text_atomic(conf, "version: 1\nversion: 2\nversion: 3\n") + write_text_atomic(conf, "version: 9\n") + assert conf.read_text(encoding="utf-8") == "version: 9\n" + + +class TestContentHash: + def test_is_sha256_hex_digest(self) -> None: + import hashlib + + assert content_hash("version: 1\n") == hashlib.sha256(b"version: 1\n").hexdigest() + + def test_deterministic_and_sensitive(self) -> None: + assert content_hash("a\n") == content_hash("a\n") + assert content_hash("a\n") != content_hash("b\n") + assert content_hash("a\n") != content_hash("a\r\n") + + class TestFindConfigFile: def test_found_in_start_dir(self, tmp_path: Path) -> None: conf = tmp_path / ".profiles" diff --git a/tests/server/routes/test_config_editor.py b/tests/server/routes/test_config_editor.py index acb22f2..31ed258 100644 --- a/tests/server/routes/test_config_editor.py +++ b/tests/server/routes/test_config_editor.py @@ -7,6 +7,7 @@ import pytest from httpx import ASGITransport, AsyncClient +from profiles.core.config.io.yaml_io import content_hash from profiles.core.config.models import AppConfig from profiles.core.config.reader import ConfigReader from profiles.core.config.template import STARTER_CONFIG_TEMPLATE @@ -715,3 +716,250 @@ async def test_template_does_not_change_state(config_state: ServerState) -> None assert response.status_code == 200 assert config_state.config is original + + +# --------------------------------------------------------------------------- +# Staleness guard + content hash (issue #116) +# --------------------------------------------------------------------------- + + +@pytest.mark.anyio +async def test_content_returns_content_hash_of_disk_text(tmp_path: Path) -> None: + """Verify GET /content answers the SHA-256 of the served text (issue #116). + + Given: A disk-anchored session with an on-disk config file + When: GET /api/config/content + Then: content_hash equals the SHA-256 hex digest of the served text + """ + config_path = tmp_path / ".profiles" + file_text = 'defaults:\n title: "On Disk"\n' + config_path.write_text(file_text, encoding="utf-8") + loaded = ConfigReader(config_path).load() + state = ServerState(config=loaded, active_directory=tmp_path) + + app = create_app(state) + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.get("/api/config/content") + + assert response.status_code == 200 + payload = response.json() + assert payload["content_hash"] == content_hash(file_text) + + +@pytest.mark.anyio +async def test_content_returns_content_hash_for_session_trial( + config_state: ServerState, +) -> None: + """The session-trial branch hashes the trial text it serves.""" + trial_text = "defaults:\n title: Dropped\n" + app = create_app(config_state) + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + drop = await client.post( + "/api/config/load-content", + json={"filename": "my.profiles", "content": trial_text}, + ) + assert drop.status_code == 200 + + response = await client.get("/api/config/content") + + assert response.status_code == 200 + payload = response.json() + assert payload["session_trial"] is True + assert payload["content_hash"] == content_hash(trial_text) + + +@pytest.mark.anyio +async def test_save_with_stale_baseline_returns_409_and_writes_nothing( + tmp_path: Path, +) -> None: + """Verify the staleness guard refuses to clobber an external edit (issue #116). + + Given: A disk-anchored session whose file changed on disk after the + editor loaded it (external edit), and a save carrying the stale + baseline hash + When: POST /api/config/save + Then: 409 with an explanatory detail, and the on-disk bytes are the + external edit — not the editor's text + """ + config_path = tmp_path / ".profiles" + config_path.write_text('defaults:\n title: "On Disk"\n', encoding="utf-8") + loaded = ConfigReader(config_path).load() + state = ServerState(config=loaded, active_directory=tmp_path) + stale_baseline = content_hash('defaults:\n title: "On Disk"\n') + + # The external edit lands between the editor's load and its Save. + config_path.write_text('defaults:\n title: "External Edit"\n', encoding="utf-8") + + app = create_app(state) + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.post( + "/api/config/save", + json={ + "content": 'defaults:\n title: "Editor Edit"\n', + "baseline_hash": stale_baseline, + }, + ) + + assert response.status_code == 409 + assert "changed on disk" in response.json()["detail"] + assert config_path.read_text(encoding="utf-8") == 'defaults:\n title: "External Edit"\n' + + +@pytest.mark.anyio +async def test_save_with_matching_baseline_saves_and_returns_new_hash( + tmp_path: Path, +) -> None: + """A save whose baseline still matches the disk file goes through. + + Given: A disk-anchored session and a save carrying the current file's + hash as baseline + When: POST /api/config/save + Then: 200 SAVED, the file is written, and the response's + content_hash is the hash of the newly written text — the next + save's baseline + """ + config_path = tmp_path / ".profiles" + current_text = 'defaults:\n title: "On Disk"\n' + config_path.write_text(current_text, encoding="utf-8") + loaded = ConfigReader(config_path).load() + state = ServerState(config=loaded, active_directory=tmp_path) + new_text = f"defaults:\n title: Fresh Title\n search_dir: '{tmp_path}'\n" + + app = create_app(state) + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.post( + "/api/config/save", + json={ + "content": new_text, + "baseline_hash": content_hash(current_text), + }, + ) + + assert response.status_code == 200 + payload = response.json() + assert payload["status"] == "SAVED" + assert config_path.read_text(encoding="utf-8") == new_text + assert payload["content_hash"] == content_hash(new_text) + + +@pytest.mark.anyio +async def test_save_stale_baseline_with_overwrite_changes_writes_anyway( + tmp_path: Path, +) -> None: + """``overwrite_changes=True`` is the 409's "overwrite anyway" answer. + + Given: A stale baseline (the file was edited externally) and a save + carrying ``overwrite_changes=True`` + When: POST /api/config/save + Then: 200 SAVED and the editor's text wins on disk + """ + config_path = tmp_path / ".profiles" + config_path.write_text('defaults:\n title: "On Disk"\n', encoding="utf-8") + loaded = ConfigReader(config_path).load() + state = ServerState(config=loaded, active_directory=tmp_path) + stale_baseline = content_hash('defaults:\n title: "On Disk"\n') + config_path.write_text('defaults:\n title: "External Edit"\n', encoding="utf-8") + + editor_text = 'defaults:\n title: "Editor Edit"\n' + app = create_app(state) + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.post( + "/api/config/save", + json={ + "content": editor_text, + "baseline_hash": stale_baseline, + "overwrite_changes": True, + }, + ) + + assert response.status_code == 200 + assert response.json()["status"] == "SAVED" + assert config_path.read_text(encoding="utf-8") == editor_text + + +@pytest.mark.anyio +async def test_save_without_baseline_keeps_legacy_no_check_behavior( + tmp_path: Path, +) -> None: + """Older callers that send no baseline are never 409'd (issue #116). + + Given: A disk-anchored session whose file changed on disk, and a save + with no ``baseline_hash`` field at all + When: POST /api/config/save + Then: 200 SAVED — the optional field keeps the endpoint backwards + compatible + """ + config_path = tmp_path / ".profiles" + config_path.write_text('defaults:\n title: "On Disk"\n', encoding="utf-8") + loaded = ConfigReader(config_path).load() + state = ServerState(config=loaded, active_directory=tmp_path) + config_path.write_text('defaults:\n title: "External Edit"\n', encoding="utf-8") + + editor_text = 'defaults:\n title: "Editor Edit"\n' + app = create_app(state) + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.post( + "/api/config/save", + json={"content": editor_text}, + ) + + assert response.status_code == 200 + assert response.json()["status"] == "SAVED" + assert config_path.read_text(encoding="utf-8") == editor_text + + +@pytest.mark.anyio +async def test_save_with_baseline_on_missing_file_returns_409(tmp_path: Path) -> None: + """A baseline-guarded save on a vanished file is refused, not recreated. + + Given: A session whose recorded config file was deleted on disk, and + a save carrying a baseline hash + When: POST /api/config/save + Then: 409 and the file is still absent afterwards + """ + config_path = tmp_path / ".profiles" + config_path.write_text('defaults:\n title: "On Disk"\n', encoding="utf-8") + loaded = ConfigReader(config_path).load() + state = ServerState(config=loaded, active_directory=tmp_path) + baseline = content_hash('defaults:\n title: "On Disk"\n') + config_path.unlink() + + app = create_app(state) + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.post( + "/api/config/save", + json={ + "content": 'defaults:\n title: "Editor Edit"\n', + "baseline_hash": baseline, + }, + ) + + assert response.status_code == 409 + assert "not found on disk" in response.json()["detail"] + assert not config_path.exists() + + +@pytest.mark.anyio +async def test_save_as_response_carries_content_hash(tmp_path: Path) -> None: + """save-as answers the hash of the newly written file (issue #116).""" + config_path = tmp_path / ".profiles" + config_path.write_text('defaults:\n title: "On Disk"\n', encoding="utf-8") + loaded = ConfigReader(config_path).load() + state = ServerState(config=loaded, active_directory=tmp_path) + new_text = f"defaults:\n title: Copied\n search_dir: '{tmp_path}'\n" + + app = create_app(state) + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.post( + "/api/config/save-as", + json={ + "content": new_text, + "filename": ".profiles.yaml", + "directory": str(tmp_path), + }, + ) + + assert response.status_code == 200 + payload = response.json() + assert payload["status"] == "SAVED" + assert payload["content_hash"] == content_hash(new_text)