qodalis-cli-server-plugin-databases 1.0.0b30__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,307 @@
1
+ """Database connections the databases plugin runs on: a session holds one connection for a while (a lock, a
2
+ transaction) and runs every statement on it, in order. Adapters wrap the usual drivers; the plugin needs none
3
+ of them installed."""
4
+
5
+ from __future__ import annotations
6
+
7
+ import asyncio
8
+ import sqlite3
9
+ from concurrent.futures import ThreadPoolExecutor
10
+ from contextlib import asynccontextmanager
11
+ from datetime import datetime, timezone
12
+ from typing import Any, AsyncIterator, Callable, Literal, Protocol, Sequence
13
+
14
+ CliSqlDialect = Literal["postgres", "mysql", "mssql", "sqlite"]
15
+
16
+ SQL_DIALECTS: tuple[str, ...] = ("postgres", "mysql", "mssql", "sqlite")
17
+
18
+ Row = dict[str, Any]
19
+
20
+
21
+ class CliSqlSession(Protocol):
22
+ """One connection held for a while: every statement runs on it, in order."""
23
+
24
+ dialect: str
25
+
26
+ async def query(self, sql: str, params: Sequence[Any] = ()) -> list[Row]:
27
+ """One statement with positional parameters written ``?`` (converted to the driver's style); its
28
+ rows as dicts."""
29
+ ...
30
+
31
+ async def exec(self, script: str) -> None:
32
+ """A script of one or more statements, without parameters (a migration's SQL)."""
33
+ ...
34
+
35
+
36
+ class CliSqlConnection(Protocol):
37
+ """A database the plugin migrates: ``async with connection.session() as db``."""
38
+
39
+ dialect: str
40
+
41
+ def session(self) -> Any:
42
+ """An async context manager giving a :class:`CliSqlSession` on a dedicated connection."""
43
+ ...
44
+
45
+
46
+ def number_placeholders(sql: str, style: Callable[[int], str]) -> str:
47
+ """``?`` placeholders (outside quotes) as ``$1, $2`` (PostgreSQL) or ``%s`` (MySQL, SQL Server)."""
48
+ n = 0
49
+ quote: str | None = None
50
+ out: list[str] = []
51
+ for ch in sql:
52
+ if quote:
53
+ if ch == quote:
54
+ quote = None
55
+ out.append(ch)
56
+ elif ch in ("'", '"', "`", "["):
57
+ quote = "]" if ch == "[" else ch
58
+ out.append(ch)
59
+ elif ch == "?":
60
+ n += 1
61
+ out.append(style(n))
62
+ else:
63
+ out.append(ch)
64
+ return "".join(out)
65
+
66
+
67
+ def _percent_style(sql: str) -> str:
68
+ """``?`` as ``%s``, a literal ``%`` doubled (the drivers format parameters with ``%``)."""
69
+ return number_placeholders(sql.replace("%", "%%"), lambda _: "%s")
70
+
71
+
72
+ def _naive_utc(value: Any) -> Any:
73
+ """Aware datetimes as naive UTC (MySQL ``datetime``, SQL Server ``datetime2``)."""
74
+ if isinstance(value, datetime) and value.tzinfo is not None:
75
+ return value.astimezone(timezone.utc).replace(tzinfo=None)
76
+ return value
77
+
78
+
79
+ def split_sqlite_script(script: str) -> list[str]:
80
+ """A script as its complete statements (``sqlite3.complete_statement``), so each runs with ``execute``
81
+ (``executescript`` would commit an open transaction first)."""
82
+ statements: list[str] = []
83
+ buf = ""
84
+ for ch in script:
85
+ buf += ch
86
+ if ch == ";" and sqlite3.complete_statement(buf):
87
+ if buf.strip().strip(";").strip():
88
+ statements.append(buf.strip())
89
+ buf = ""
90
+ if buf.strip() and not all(line.strip().startswith("--") or not line.strip() for line in buf.splitlines()):
91
+ statements.append(buf.strip())
92
+ return statements
93
+
94
+
95
+ # ---------------------------------------------------------------------------
96
+ # SQLite (sqlite3)
97
+ # ---------------------------------------------------------------------------
98
+
99
+
100
+ class _SqliteSession:
101
+ dialect = "sqlite"
102
+
103
+ def __init__(self, conn: sqlite3.Connection) -> None:
104
+ self._conn = conn
105
+
106
+ async def query(self, sql: str, params: Sequence[Any] = ()) -> list[Row]:
107
+ values = [
108
+ v.isoformat() if isinstance(v, datetime) else int(v) if isinstance(v, bool) else v for v in params
109
+ ]
110
+ cursor = self._conn.execute(sql, values)
111
+ if cursor.description is None:
112
+ return []
113
+ names = [d[0] for d in cursor.description]
114
+ return [dict(zip(names, row)) for row in cursor.fetchall()]
115
+
116
+ async def exec(self, script: str) -> None:
117
+ for statement in split_sqlite_script(script):
118
+ self._conn.execute(statement)
119
+
120
+
121
+ class _SqliteConnection:
122
+ dialect = "sqlite"
123
+
124
+ def __init__(self, conn: sqlite3.Connection) -> None:
125
+ # Explicit transactions (BEGIN IMMEDIATE ... COMMIT): no implicit ones around statements
126
+ conn.isolation_level = None
127
+ self._conn = conn
128
+ self._lock = asyncio.Lock()
129
+
130
+ @asynccontextmanager
131
+ async def session(self) -> AsyncIterator[_SqliteSession]:
132
+ async with self._lock:
133
+ yield _SqliteSession(self._conn)
134
+
135
+
136
+ def sqlite_connection(conn: sqlite3.Connection) -> CliSqlConnection:
137
+ """A SQLite database from a ``sqlite3`` connection (one connection: sessions run one after another).
138
+ The connection is switched to autocommit (``isolation_level = None``): migrations open their own
139
+ transactions."""
140
+ return _SqliteConnection(conn)
141
+
142
+
143
+ # ---------------------------------------------------------------------------
144
+ # PostgreSQL (asyncpg)
145
+ # ---------------------------------------------------------------------------
146
+
147
+
148
+ class _PostgresSession:
149
+ dialect = "postgres"
150
+
151
+ def __init__(self, conn: Any) -> None:
152
+ self._conn = conn
153
+
154
+ async def query(self, sql: str, params: Sequence[Any] = ()) -> list[Row]:
155
+ rows = await self._conn.fetch(number_placeholders(sql, lambda n: f"${n}"), *params)
156
+ return [dict(r) for r in rows]
157
+
158
+ async def exec(self, script: str) -> None:
159
+ await self._conn.execute(script)
160
+
161
+
162
+ class _PostgresConnection:
163
+ dialect = "postgres"
164
+
165
+ def __init__(self, pool: Any) -> None:
166
+ self._pool = pool
167
+
168
+ @asynccontextmanager
169
+ async def session(self) -> AsyncIterator[_PostgresSession]:
170
+ async with self._pool.acquire() as conn:
171
+ yield _PostgresSession(conn)
172
+
173
+
174
+ def postgres_connection(pool: Any) -> CliSqlConnection:
175
+ """A PostgreSQL database from an ``asyncpg`` pool (``await asyncpg.create_pool(dsn)``)."""
176
+ return _PostgresConnection(pool)
177
+
178
+
179
+ # ---------------------------------------------------------------------------
180
+ # MySQL / MariaDB (aiomysql)
181
+ # ---------------------------------------------------------------------------
182
+
183
+
184
+ class _MysqlSession:
185
+ dialect = "mysql"
186
+
187
+ def __init__(self, conn: Any) -> None:
188
+ self._conn = conn
189
+
190
+ async def query(self, sql: str, params: Sequence[Any] = ()) -> list[Row]:
191
+ async with self._conn.cursor() as cursor:
192
+ await cursor.execute(_percent_style(sql), [_naive_utc(p) for p in params] if params else None)
193
+ if cursor.description is None:
194
+ return []
195
+ names = [d[0] for d in cursor.description]
196
+ return [dict(zip(names, row)) for row in await cursor.fetchall()]
197
+
198
+ async def exec(self, script: str) -> None:
199
+ async with self._conn.cursor() as cursor:
200
+ await cursor.execute(script)
201
+ while await cursor.nextset():
202
+ pass
203
+
204
+
205
+ class _MysqlConnection:
206
+ dialect = "mysql"
207
+
208
+ def __init__(self, pool: Any) -> None:
209
+ self._pool = pool
210
+
211
+ @asynccontextmanager
212
+ async def session(self) -> AsyncIterator[_MysqlSession]:
213
+ async with self._pool.acquire() as conn:
214
+ await conn.autocommit(True)
215
+ yield _MysqlSession(conn)
216
+
217
+
218
+ def mysql_connection(pool: Any) -> CliSqlConnection:
219
+ """A MySQL / MariaDB database from an ``aiomysql`` pool. Migration scripts with several statements need
220
+ the pool created with ``client_flag=pymysql.constants.CLIENT.MULTI_STATEMENTS``. MySQL commits DDL
221
+ statements on its own: a failing migration that created a table leaves it behind."""
222
+ return _MysqlConnection(pool)
223
+
224
+
225
+ # ---------------------------------------------------------------------------
226
+ # SQL Server (pymssql, run on a thread of its own per session)
227
+ # ---------------------------------------------------------------------------
228
+
229
+
230
+ def _split_batches(script: str) -> list[str]:
231
+ import re
232
+
233
+ return [b for b in re.split(r"^\s*GO\s*;?\s*$", script, flags=re.IGNORECASE | re.MULTILINE) if b.strip()]
234
+
235
+
236
+ class _MssqlSession:
237
+ dialect = "mssql"
238
+
239
+ def __init__(self, conn: Any, executor: ThreadPoolExecutor) -> None:
240
+ self._conn = conn
241
+ self._executor = executor
242
+
243
+ async def _run(self, fn: Callable[[], Any]) -> Any:
244
+ return await asyncio.get_running_loop().run_in_executor(self._executor, fn)
245
+
246
+ async def query(self, sql: str, params: Sequence[Any] = ()) -> list[Row]:
247
+ def run() -> list[Row]:
248
+ cursor = self._conn.cursor()
249
+ try:
250
+ if params:
251
+ cursor.execute(_percent_style(sql), tuple(_naive_utc(p) for p in params))
252
+ else:
253
+ cursor.execute(sql)
254
+ # The first result set with rows (a batch may run statements without one first)
255
+ while cursor.description is None:
256
+ if not cursor.nextset():
257
+ return []
258
+ names = [d[0] for d in cursor.description]
259
+ rows = [dict(zip(names, row)) for row in cursor.fetchall()]
260
+ while cursor.nextset():
261
+ pass
262
+ return rows
263
+ finally:
264
+ cursor.close()
265
+
266
+ return await self._run(run)
267
+
268
+ async def exec(self, script: str) -> None:
269
+ def run() -> None:
270
+ cursor = self._conn.cursor()
271
+ try:
272
+ for batch in _split_batches(script):
273
+ cursor.execute(batch)
274
+ while cursor.nextset():
275
+ pass
276
+ finally:
277
+ cursor.close()
278
+
279
+ await self._run(run)
280
+
281
+
282
+ class _MssqlConnection:
283
+ dialect = "mssql"
284
+
285
+ def __init__(self, connect: Callable[[], Any]) -> None:
286
+ self._connect = connect
287
+
288
+ @asynccontextmanager
289
+ async def session(self) -> AsyncIterator[_MssqlSession]:
290
+ executor = ThreadPoolExecutor(max_workers=1, thread_name_prefix="qcli-mssql")
291
+ loop = asyncio.get_running_loop()
292
+ try:
293
+ conn = await loop.run_in_executor(executor, self._connect)
294
+ try:
295
+ await loop.run_in_executor(executor, lambda: conn.autocommit(True))
296
+ yield _MssqlSession(conn, executor)
297
+ finally:
298
+ await loop.run_in_executor(executor, conn.close)
299
+ finally:
300
+ executor.shutdown(wait=False)
301
+
302
+
303
+ def mssql_connection(connect: Callable[[], Any]) -> CliSqlConnection:
304
+ """A SQL Server database from a function opening a ``pymssql`` connection
305
+ (``lambda: pymssql.connect(server, user, password, database)``). Each session opens its own connection,
306
+ so locks and transactions stay on it; ``GO`` lines split a script into batches."""
307
+ return _MssqlConnection(connect)
@@ -0,0 +1,149 @@
1
+ """The databases API — ``/api/v1/qcli/databases``.
2
+
3
+ ``GET /`` databases, ``GET /{db}`` one, ``GET /{db}/stats``, ``GET /{db}/migrations``,
4
+ ``GET /{db}/migrations/runs``, ``GET /{db}/migrations/sql`` (dry run), ``POST /{db}/migrations/up``,
5
+ ``POST /{db}/migrations/down``. Errors answer ``{"error": "..."}``: 404 unknown database or migration, 400 bad
6
+ input, 409 busy or blocked. On a protected server reading needs ``databases:read`` and running migrations
7
+ ``databases:migrate`` (declared as route permissions).
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import functools
13
+ import json
14
+ from typing import Any, Awaitable, Callable
15
+
16
+ from fastapi import APIRouter, Request
17
+ from fastapi.responses import JSONResponse
18
+
19
+ from .databases import CliDatabases
20
+ from .runner import CliMigrationError, CliMigrationRunOptions
21
+
22
+ #: Key under ``scope["state"]`` where an auth plugin stores the caller (shared with ``qodalis_cli.security``).
23
+ AUTH_STATE_KEY = "qcli_auth"
24
+
25
+ TO_REQUIRED = "to is required to roll back (an id, or base for everything)"
26
+
27
+
28
+ def caller_name(ctx: Any) -> str | None:
29
+ """The signed-in user's name from an auth context, if any."""
30
+ if ctx is None:
31
+ return None
32
+ user = getattr(ctx, "user", None)
33
+ name = getattr(user, "name", None) if user is not None else getattr(ctx, "user_name", None)
34
+ return name if isinstance(name, str) and name else None
35
+
36
+
37
+ def _scope_caller(request: Request) -> Any:
38
+ state = request.scope.get("state")
39
+ if isinstance(state, dict):
40
+ return state.get(AUTH_STATE_KEY)
41
+ return getattr(state, AUTH_STATE_KEY, None) if state is not None else None
42
+
43
+
44
+ def _text(value: Any, name: str) -> str | None:
45
+ if value is None or value == "":
46
+ return None
47
+ if not isinstance(value, str) or len(value) > 200:
48
+ raise CliMigrationError(f"{name} must be a migration id", 400)
49
+ return value
50
+
51
+
52
+ def _guarded(fn: Callable[..., Awaitable[Any]]) -> Callable[..., Awaitable[Any]]:
53
+ """Answers a refused request (:class:`CliMigrationError`) with its status and ``{"error"}``."""
54
+
55
+ @functools.wraps(fn)
56
+ async def wrapper(*args: Any, **kwargs: Any) -> Any:
57
+ try:
58
+ return await fn(*args, **kwargs)
59
+ except CliMigrationError as exc:
60
+ return JSONResponse({"error": exc.message}, status_code=exc.status)
61
+
62
+ return wrapper
63
+
64
+
65
+ def create_databases_router(databases: CliDatabases) -> APIRouter:
66
+ router = APIRouter()
67
+
68
+ @router.get("")
69
+ @router.get("/")
70
+ @_guarded
71
+ async def overview() -> Any:
72
+ return {"databases": await databases.overview()}
73
+
74
+ @router.get("/{db}")
75
+ @_guarded
76
+ async def database(db: str) -> Any:
77
+ return await databases.summary(db)
78
+
79
+ @router.get("/{db}/stats")
80
+ @_guarded
81
+ async def stats(db: str) -> Any:
82
+ return await databases.stats(db)
83
+
84
+ @router.get("/{db}/migrations")
85
+ @_guarded
86
+ async def database_migrations(db: str) -> Any:
87
+ runner = databases.require(db)
88
+ states = await runner.status()
89
+ return {
90
+ "name": runner.name,
91
+ "dialect": runner.dialect,
92
+ "sources": runner.source_names,
93
+ "migrations": [s.to_dict() for s in states],
94
+ }
95
+
96
+ @router.get("/{db}/migrations/runs")
97
+ @_guarded
98
+ async def runs(db: str, request: Request) -> Any:
99
+ def number(name: str, default: int) -> int:
100
+ try:
101
+ return int(request.query_params.get(name) or default)
102
+ except ValueError:
103
+ return default
104
+
105
+ size = min(100, max(1, number("size", 20)))
106
+ page = max(1, number("page", 1))
107
+ items, total = await databases.require(db).runs(size, (page - 1) * size)
108
+ return {"items": [r.to_dict() for r in items], "total": total}
109
+
110
+ @router.get("/{db}/migrations/sql")
111
+ @_guarded
112
+ async def sql(db: str, request: Request) -> Any:
113
+ runner = databases.require(db)
114
+ direction = "down" if request.query_params.get("direction") == "down" else "up"
115
+ to = _text(request.query_params.get("to"), "to")
116
+ if direction == "down" and not to:
117
+ raise CliMigrationError(TO_REQUIRED, 400)
118
+ options = CliMigrationRunOptions(to=to, dry_run=True)
119
+ return await (runner.up(options) if direction == "up" else runner.down(options))
120
+
121
+ async def run(db: str, request: Request, direction: str) -> Any:
122
+ try:
123
+ body = await request.json() if await request.body() else {}
124
+ except (json.JSONDecodeError, UnicodeDecodeError):
125
+ raise CliMigrationError("invalid JSON body", 400) from None
126
+ if not isinstance(body, dict):
127
+ body = {}
128
+ options = CliMigrationRunOptions(
129
+ to=_text(body.get("to"), "to"),
130
+ force=body.get("force") is True,
131
+ actor=caller_name(_scope_caller(request)),
132
+ trigger="api",
133
+ )
134
+ if direction == "down" and not options.to:
135
+ raise CliMigrationError(TO_REQUIRED, 400)
136
+ result = await databases.run(db, direction, options) # type: ignore[arg-type]
137
+ return result.to_dict()
138
+
139
+ @router.post("/{db}/migrations/up")
140
+ @_guarded
141
+ async def up(db: str, request: Request) -> Any:
142
+ return await run(db, request, "up")
143
+
144
+ @router.post("/{db}/migrations/down")
145
+ @_guarded
146
+ async def down(db: str, request: Request) -> Any:
147
+ return await run(db, request, "down")
148
+
149
+ return router
@@ -0,0 +1 @@
1
+ .container{width:100%}@media(min-width:640px){.container{max-width:640px}}@media(min-width:768px){.container{max-width:768px}}@media(min-width:1024px){.container{max-width:1024px}}@media(min-width:1280px){.container{max-width:1280px}}@media(min-width:1536px){.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.right-2\.5{right:.625rem}.right-6{right:1.5rem}.top-1\/2{top:50%}.z-10{z-index:10}.z-50{z-index:50}.z-\[60\]{z-index:60}.m-6{margin:1.5rem}.-my-1{margin-top:-.25rem;margin-bottom:-.25rem}.mx-auto{margin-left:auto;margin-right:auto}.my-1{margin-top:.25rem;margin-bottom:.25rem}.-mb-px{margin-bottom:-1px}.-mr-2{margin-right:-.5rem}.-mt-\[5px\]{margin-top:-5px}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-0\.5{height:.125rem}.h-1{height:.25rem}.h-1\.5{height:.375rem}.h-11{height:2.75rem}.h-2\.5{height:.625rem}.h-4{height:1rem}.h-8{height:2rem}.h-\[100dvh\]{height:100dvh}.h-px{height:1px}.max-h-80{max-height:20rem}.max-h-\[50vh\]{max-height:50vh}.max-h-\[92dvh\]{max-height:92dvh}.min-h-0{min-height:0px}.min-h-11{min-height:2.75rem}.w-1\.5{width:.375rem}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-2\.5{width:.625rem}.w-3{width:.75rem}.w-4{width:1rem}.w-8{width:2rem}.w-auto{width:auto}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-11{min-width:2.75rem}.min-w-\[11rem\]{min-width:11rem}.min-w-\[120px\]{min-width:120px}.min-w-\[140px\]{min-width:140px}.max-w-\[8rem\]{max-width:8rem}.max-w-\[min\(20rem\,calc\(100vw-1rem\)\)\]{max-width:min(20rem,calc(100vw - 1rem))}.max-w-\[min\(24rem\,calc\(100vw-1rem\)\)\]{max-width:min(24rem,calc(100vw - 1rem))}.max-w-full{max-width:100%}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize{resize:both}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-\[auto_1fr\]{grid-template-columns:auto 1fr}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.items-stretch{align-items:stretch}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-1{row-gap:.25rem}.gap-y-2{row-gap:.5rem}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.divide-x>:not([hidden])~:not([hidden]){--tw-divide-x-reverse: 0;border-right-width:calc(1px * var(--tw-divide-x-reverse));border-left-width:calc(1px * calc(1 - var(--tw-divide-x-reverse)))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-border>:not([hidden])~:not([hidden]){--tw-divide-opacity: 1;border-color:color-mix(in srgb,var(--qcli-border) calc(var(--tw-divide-opacity, 1) * 100%),transparent)}.divide-border\/75>:not([hidden])~:not([hidden]){border-color:color-mix(in srgb,var(--qcli-border) 75%,transparent)}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overscroll-contain{overscroll-behavior:contain}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-sm{border-radius:.125rem}.rounded-xl{border-radius:.75rem}.rounded-t-2xl{border-top-left-radius:1rem;border-top-right-radius:1rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-t{border-top-width:1px}.border-border{--tw-border-opacity: 1;border-color:color-mix(in srgb,var(--qcli-border) calc(var(--tw-border-opacity, 1) * 100%),transparent)}.border-border\/50{border-color:color-mix(in srgb,var(--qcli-border) 50%,transparent)}.border-border\/75{border-color:color-mix(in srgb,var(--qcli-border) 75%,transparent)}.border-error\/30{border-color:color-mix(in srgb,var(--qcli-error) 30%,transparent)}.border-info\/30{border-color:color-mix(in srgb,var(--qcli-info) 30%,transparent)}.border-primary{--tw-border-opacity: 1;border-color:color-mix(in srgb,var(--qcli-primary) calc(var(--tw-border-opacity, 1) * 100%),transparent)}.border-subtle\/30{border-color:color-mix(in srgb,var(--qcli-subtle) 30%,transparent)}.border-success\/30{border-color:color-mix(in srgb,var(--qcli-success) 30%,transparent)}.border-transparent{border-color:transparent}.border-warning\/30{border-color:color-mix(in srgb,var(--qcli-warning) 30%,transparent)}.bg-border{--tw-bg-opacity: 1;background-color:color-mix(in srgb,var(--qcli-border) calc(var(--tw-bg-opacity, 1) * 100%),transparent)}.bg-border\/75{background-color:color-mix(in srgb,var(--qcli-border) 75%,transparent)}.bg-control{--tw-bg-opacity: 1;background-color:color-mix(in srgb,var(--qcli-control) calc(var(--tw-bg-opacity, 1) * 100%),transparent)}.bg-control-hover{--tw-bg-opacity: 1;background-color:color-mix(in srgb,var(--qcli-control-hover) calc(var(--tw-bg-opacity, 1) * 100%),transparent)}.bg-current{background-color:currentColor}.bg-error\/10{background-color:color-mix(in srgb,var(--qcli-error) 10%,transparent)}.bg-error\/15{background-color:color-mix(in srgb,var(--qcli-error) 15%,transparent)}.bg-error\/20{background-color:color-mix(in srgb,var(--qcli-error) 20%,transparent)}.bg-error\/\[0\.06\]{background-color:color-mix(in srgb,var(--qcli-error) 6%,transparent)}.bg-info\/15{background-color:color-mix(in srgb,var(--qcli-info) 15%,transparent)}.bg-overlay{--tw-bg-opacity: 1;background-color:color-mix(in srgb,var(--qcli-overlay) calc(var(--tw-bg-opacity, 1) * 100%),transparent)}.bg-popover{--tw-bg-opacity: 1;background-color:color-mix(in srgb,var(--qcli-popover) calc(var(--tw-bg-opacity, 1) * 100%),transparent)}.bg-primary{--tw-bg-opacity: 1;background-color:color-mix(in srgb,var(--qcli-primary) calc(var(--tw-bg-opacity, 1) * 100%),transparent)}.bg-primary\/15{background-color:color-mix(in srgb,var(--qcli-primary) 15%,transparent)}.bg-primary\/20{background-color:color-mix(in srgb,var(--qcli-primary) 20%,transparent)}.bg-subtle\/15{background-color:color-mix(in srgb,var(--qcli-subtle) 15%,transparent)}.bg-success\/15{background-color:color-mix(in srgb,var(--qcli-success) 15%,transparent)}.bg-surface{--tw-bg-opacity: 1;background-color:color-mix(in srgb,var(--qcli-surface) calc(var(--tw-bg-opacity, 1) * 100%),transparent)}.bg-warning\/10{background-color:color-mix(in srgb,var(--qcli-warning) 10%,transparent)}.bg-warning\/15{background-color:color-mix(in srgb,var(--qcli-warning) 15%,transparent)}.fill-subtle{fill:color-mix(in srgb,var(--qcli-subtle) 100%,transparent)}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.py-px{padding-top:1px;padding-bottom:1px}.pb-\[env\(safe-area-inset-bottom\)\]{padding-bottom:env(safe-area-inset-bottom)}.pl-\[env\(safe-area-inset-left\)\]{padding-left:env(safe-area-inset-left)}.pr-16{padding-right:4rem}.pr-7{padding-right:1.75rem}.pr-\[env\(safe-area-inset-right\)\]{padding-right:env(safe-area-inset-right)}.pt-\[env\(safe-area-inset-top\)\]{padding-top:env(safe-area-inset-top)}.text-left{text-align:left}.text-center{text-align:center}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[9px\]{font-size:9px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.leading-4{line-height:1rem}.leading-5{line-height:1.25rem}.leading-relaxed{line-height:1.625}.tracking-wide{letter-spacing:.025em}.text-accent{--tw-text-opacity: 1;color:color-mix(in srgb,var(--qcli-accent) calc(var(--tw-text-opacity, 1) * 100%),transparent)}.text-error{--tw-text-opacity: 1;color:color-mix(in srgb,var(--qcli-error) calc(var(--tw-text-opacity, 1) * 100%),transparent)}.text-error\/70{color:color-mix(in srgb,var(--qcli-error) 70%,transparent)}.text-heading{--tw-text-opacity: 1;color:color-mix(in srgb,var(--qcli-heading) calc(var(--tw-text-opacity, 1) * 100%),transparent)}.text-info{--tw-text-opacity: 1;color:color-mix(in srgb,var(--qcli-info) calc(var(--tw-text-opacity, 1) * 100%),transparent)}.text-muted{--tw-text-opacity: 1;color:color-mix(in srgb,var(--qcli-muted) calc(var(--tw-text-opacity, 1) * 100%),transparent)}.text-on-primary{--tw-text-opacity: 1;color:color-mix(in srgb,var(--qcli-on-primary) calc(var(--tw-text-opacity, 1) * 100%),transparent)}.text-primary{--tw-text-opacity: 1;color:color-mix(in srgb,var(--qcli-primary) calc(var(--tw-text-opacity, 1) * 100%),transparent)}.text-subtle{--tw-text-opacity: 1;color:color-mix(in srgb,var(--qcli-subtle) calc(var(--tw-text-opacity, 1) * 100%),transparent)}.text-success{--tw-text-opacity: 1;color:color-mix(in srgb,var(--qcli-success) calc(var(--tw-text-opacity, 1) * 100%),transparent)}.text-text{--tw-text-opacity: 1;color:color-mix(in srgb,var(--qcli-text) calc(var(--tw-text-opacity, 1) * 100%),transparent)}.text-warning{--tw-text-opacity: 1;color:color-mix(in srgb,var(--qcli-warning) calc(var(--tw-text-opacity, 1) * 100%),transparent)}.opacity-30{opacity:.3}.opacity-40{opacity:.4}.opacity-50{opacity:.5}.shadow-2xl{--tw-shadow: 0 25px 50px -12px rgb(0 0 0 / .25);--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.placeholder\:text-subtle::-moz-placeholder{--tw-text-opacity: 1;color:color-mix(in srgb,var(--qcli-subtle) calc(var(--tw-text-opacity, 1) * 100%),transparent)}.placeholder\:text-subtle::placeholder{--tw-text-opacity: 1;color:color-mix(in srgb,var(--qcli-subtle) calc(var(--tw-text-opacity, 1) * 100%),transparent)}.last\:border-0:last-child{border-width:0px}.hover\:bg-control:hover{--tw-bg-opacity: 1;background-color:color-mix(in srgb,var(--qcli-control) calc(var(--tw-bg-opacity, 1) * 100%),transparent)}.hover\:bg-control-hover:hover{--tw-bg-opacity: 1;background-color:color-mix(in srgb,var(--qcli-control-hover) calc(var(--tw-bg-opacity, 1) * 100%),transparent)}.hover\:bg-error\/15:hover{background-color:color-mix(in srgb,var(--qcli-error) 15%,transparent)}.hover\:bg-error\/30:hover{background-color:color-mix(in srgb,var(--qcli-error) 30%,transparent)}.hover\:bg-primary-hover:hover{--tw-bg-opacity: 1;background-color:color-mix(in srgb,var(--qcli-primary-hover) calc(var(--tw-bg-opacity, 1) * 100%),transparent)}.hover\:bg-primary\/15:hover{background-color:color-mix(in srgb,var(--qcli-primary) 15%,transparent)}.hover\:bg-success\/15:hover{background-color:color-mix(in srgb,var(--qcli-success) 15%,transparent)}.hover\:bg-surface:hover{--tw-bg-opacity: 1;background-color:color-mix(in srgb,var(--qcli-surface) calc(var(--tw-bg-opacity, 1) * 100%),transparent)}.hover\:bg-warning\/15:hover{background-color:color-mix(in srgb,var(--qcli-warning) 15%,transparent)}.hover\:text-text:hover{--tw-text-opacity: 1;color:color-mix(in srgb,var(--qcli-text) calc(var(--tw-text-opacity, 1) * 100%),transparent)}.hover\:underline:hover{text-decoration-line:underline}.focus\:border-primary:focus{--tw-border-opacity: 1;border-color:color-mix(in srgb,var(--qcli-primary) calc(var(--tw-border-opacity, 1) * 100%),transparent)}.focus\:bg-control-hover:focus{--tw-bg-opacity: 1;background-color:color-mix(in srgb,var(--qcli-control-hover) calc(var(--tw-bg-opacity, 1) * 100%),transparent)}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus-visible\:border-primary:focus-visible{--tw-border-opacity: 1;border-color:color-mix(in srgb,var(--qcli-primary) calc(var(--tw-border-opacity, 1) * 100%),transparent)}.focus-visible\:ring-2:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-inset:focus-visible{--tw-ring-inset: inset }.focus-visible\:ring-primary:focus-visible{--tw-ring-opacity: 1;--tw-ring-color: color-mix(in srgb, var(--qcli-primary) calc(var(--tw-ring-opacity, 1) * 100%), transparent) }.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:no-underline:disabled{text-decoration-line:none}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media(prefers-reduced-motion:no-preference){@keyframes fade-in{0%{opacity:0}to{opacity:1}}.motion-safe\:animate-fade-in{animation:fade-in .15s ease-out}@keyframes pop-in{0%{opacity:0;transform:scale(.97)}to{opacity:1;transform:none}}.motion-safe\:animate-pop-in{animation:pop-in .12s ease-out}@keyframes sheet-in{0%{transform:translateY(100%)}to{transform:none}}.motion-safe\:animate-sheet-in{animation:sheet-in .2s ease-out}.motion-safe\:transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}}@media(prefers-reduced-motion:reduce){.motion-reduce\:animate-none{animation:none}}@media(min-width:640px){.sm\:not-sr-only{position:static;width:auto;height:auto;padding:0;margin:0;overflow:visible;clip:auto;white-space:normal}.sm\:right-5{right:1.25rem}.sm\:hidden{display:none}.sm\:h-5{height:1.25rem}.sm\:h-8{height:2rem}.sm\:h-\[90vh\]{height:90vh}.sm\:max-h-\[90vh\]{max-height:90vh}.sm\:min-h-0{min-height:0px}.sm\:min-h-8{min-height:2rem}.sm\:w-5{width:1.25rem}.sm\:w-8{width:2rem}.sm\:w-auto{width:auto}.sm\:min-w-8{min-width:2rem}.sm\:max-w-3xl{max-width:48rem}.sm\:max-w-6xl{max-width:72rem}.sm\:max-w-md{max-width:28rem}.sm\:max-w-sm{max-width:24rem}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:items-center{align-items:center}.sm\:rounded-xl{border-radius:.75rem}.sm\:border{border-width:1px}.sm\:p-4{padding:1rem}.sm\:p-6{padding:1.5rem}.sm\:px-0{padding-left:0;padding-right:0}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}.sm\:pb-0{padding-bottom:0}.sm\:pr-12{padding-right:3rem}.sm\:pt-0{padding-top:0}.sm\:text-xs{font-size:.75rem;line-height:1rem}@media(prefers-reduced-motion:no-preference){@keyframes pop-in{0%{opacity:0;transform:scale(.97)}to{opacity:1;transform:none}}.sm\:motion-safe\:animate-pop-in{animation:pop-in .12s ease-out}}}@media(min-width:1280px){.xl\:not-sr-only{position:static;width:auto;height:auto;padding:0;margin:0;overflow:visible;clip:auto;white-space:normal}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}.\[\&\>button\]\:min-h-11>button{min-height:2.75rem}@media(min-width:640px){.sm\:\[\&\>button\]\:min-h-0>button{min-height:0px}}.focus-visible\:\[\&\>rect\.hit\]\:stroke-\[var\(--qcli-primary\)\]>rect.hit:focus-visible{stroke:var(--qcli-primary)}