From 53fdcab5d646a42a51c5a971b4e0513fc0c6a73f Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Fri, 12 Jun 2026 00:03:11 -0700 Subject: [PATCH 1/5] feat(tables): background jobs (delete/export/backfill on trigger.dev) + tenant-scoped query performance (#4915) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(tables): paginated background row-delete jobs via table_jobs * fix(tables): address review on async row-delete (filtered count, scoped optimistic clear, Cmd+A select-all, hide delete from tray) * improvement(tables): filter-aware select-all runs, delete-job read mask, keyset index + autovacuum tuning * feat(tables): run import/delete/export/backfill jobs on trigger.dev with in-process fallback * improvement(tables): raise delete page to 10k and export batch to 5k * improvement(tables): raise CSV import batch to 5k rows (param-cap bounded) * feat(tables): surface export jobs in the header tray with progress, cancel, and download * improvement(tables): surface exports as derived tables-scoped toasts instead of the import tray * Revert "improvement(tables): surface exports as derived tables-scoped toasts instead of the import tray" This reverts commit 1ea587161044850ef2b9df6467afa099d2097f8d. * fix(tables): preserve export storage key (NoSuchKey) and unify jobs in one spinner tray * improvement(tables): jobs tray icon reflects aggregate state (spinner/check/alert) * fix(tables): restore jobs tray on the tables list (dropped in staging merge) * improvement(tables): keyset-paginate export row reads (offset paging was O(n^2) over large tables) * perf(tables): keyset pagination for grid infinite scroll Default-order row pages now cursor on (order_key, id) instead of OFFSET — each page is an index seek on tableOrderKeyIdx, where OFFSET re-scans and discards every prior row (O(N²) across deep scrolls and full drains like select-all/export-to-clipboard). Sorted views keep offset paging; the contract refines after+sort as mutually exclusive. v1 public rows API is unchanged (extends the unrefined base, omits after). Co-Authored-By: Claude Opus 4.8 * fix(tables): show export in job tray immediately on kickoff The export-jobs query's poll only self-sustains once a running job is already in the cache, so a freshly kicked export stayed invisible until an SSE event or page refresh. Invalidate the tray query on kickoff success so the icon appears right away. Co-Authored-By: Claude Opus 4.8 * fix(tables): surface real row/column write errors in toasts Drizzle wraps DB errors in DrizzleQueryError whose message is the failed SQL — the real cause (e.g. the row-limit trigger's RAISE) sits on .cause, so the routes' substring classification never matched and everything fell through to generic 500s ("Failed to insert row"). Add rootErrorMessage (cause-chain unwrap) and a shared rowWriteErrorResponse classifier that consolidates the per-route pattern lists and rewrites the trigger message into a friendly "Row limit exceeded — capped at N rows". Applied across the app and v1 row-write routes and the columns route. Co-Authored-By: Claude Opus 4.8 * perf(tables): tenant-bound filtered row counts (12.7s -> 0.6s) JSONB filter predicates (->> ILIKE / range casts) are opaque to the planner: it estimates a handful of matches and picks a parallel seq scan over the entire shared user_table_rows relation — every tenant's rows — for the page-0 COUNT(*), so any non-equality filter on a large table cost 10s+ regardless of how few rows matched. Run filtered counts in a transaction with SET LOCAL enable_seqscan = off, forcing the tenant-bounded bitmap plan. Unfiltered counts keep their index-only scan. Co-Authored-By: Claude Opus 4.8 * perf(tables): tenant-bound Cmd+F search and stream its window (75s -> 2s) Same planner trap as the filtered count, compounded: the lateral jsonb_each_text ILIKE is unestimatable, so findRowMatches on a 1M-row table seq-scanned the whole 12M-row shared relation and disk-sorted ~120MB of window input (75s measured). SET LOCAL enable_seqscan=off bounds the scan to the tenant; on the default order, additionally penalizing bitmap/sort/parallel steers the planner onto the already- sorted (table_id, order_key, id) index walk so row_number() streams with no sort at all (2s measured). Flags only penalize plan shapes — a custom sort still sorts. Co-Authored-By: Claude Opus 4.8 * perf(tables): tenant-bound sorted pages and filtered write selections Extends the seqscan fix to every remaining jsonb-predicate path, all measured on a 1M-row table in a 12M-row shared relation: - sorted page query (ORDER BY data->>'col'): 9.7s/page -> 0.76s, and deep pages stop spilling ~130MB sorts to disk - updateRowsByFilter / deleteRowsByFilter row selection: 14.4s -> bounded - delete-job worker selectRowIdPage with a filter: 12.6s/page -> bounded - dispatcher filtered-scope window walk: same shape, same fix Shared withSeqscanOff helper moves to lib/table/planner.ts (service + dispatcher both consume it; dispatcher can't import service). Co-Authored-By: Claude Opus 4.8 * perf(tables): tenant-scoped containment index (migration 0232) The plain GIN on user_table_rows.data matched @> candidates across every tenant sharing the relation — a hot value in someone else's table inflated everyone's equality filters (1.07M candidates fetched for a 33k-row match, lossy bitmap, 1.1s). Replace it with btree_gin (table_id, data jsonb_path_ops): the tenant intersection happens inside the index and paths are single hashed entries. Rare-equality probe 326ms -> 17ms with zero wasted candidates; unique-constraint checks and upsert conflict lookups ride the same index. The new index is smaller than the one it replaces (529MB vs 694MB on the 12M-row dev relation). Co-Authored-By: Claude Opus 4.8 * perf(tables): tenant-bound unique-constraint checks (3.5s -> <1s per write) The unique check runs lower(data->>'col') = $1 LIMIT 1 on every insert and cell edit touching a unique column. The predicate is unestimatable and a unique (non-conflicting) value never exits early, so the planner seq-scanned all 12.3M shared-relation rows per check — 3.5s measured. Tenant-bound both the single and batch variants; the batch path sets the flag on the caller's transaction when one is supplied (SET LOCAL dies at its commit, and the statements that follow are tenant-scoped writes). Co-Authored-By: Claude Opus 4.8 * perf(tables): tenant-bound upsert conflict lookup Same unestimatable data->>key predicate as the unique checks; an insert-path upsert has no existing match so the lookup can't exit early and seq-scans the whole shared relation. The upsert already runs in a transaction — set the planner flag on it. Co-Authored-By: Claude Opus 4.8 * refactor(tables): consolidate executor types onto planner exports service.ts kept a private DbTransaction alias and two inline typeof db | DbTransaction unions after planner.ts began exporting the canonical DbTransaction/DbExecutor — import those instead. From the /simplify review of the perf series; no behavior change. Co-Authored-By: Claude Opus 4.8 * fix(tests): drop narrow schema mock override in process-contents test The local vi.mock('@sim/db/schema') stubbed only document/knowledgeBase, but the file's import graph reaches lib/table/service whose module scope now references tableJobs. The global schema mock already covers all of it — rely on it per the testing rules instead of re-mocking. Co-Authored-By: Claude Opus 4.8 * fix(tables): scope cancels and counts to the filtered selection (review) Addresses the open Bugbot/Greptile findings on filtered select-all: - Filtered runs no longer cancel the whole table: cancelWorkflowGroupRuns takes a filter — it stops only dispatches with that exact filter scope and only in-flight cells on matching rows (semi-join); whole-table and differently-scoped dispatches keep running, their cancelled cells skipped via cancelledAt > requestedAt. - Stop on a filtered select-all sends the filter through cancel-runs (contract + route + mutation) instead of a table-wide cancel. - runColumnBodySchema rejects rowIds + filter together (mirrors deleteTableRowsBodySchema). - Select-all delete clears the selection in onSuccess, not at click, so a failed kickoff restores both rows and selection. - Clipboard copy/cut estimates use the filter-aware total (rowTotal) instead of the whole-table rowCount. Co-Authored-By: Claude Opus 4.8 * chore: retrigger CI (Actions dropped the previous push events) Co-Authored-By: Claude Opus 4.8 * chore: bump api-validation route baseline to 807 (staging route + merge) Co-Authored-By: Claude Opus 4.8 * fix(tables): release job claim when trigger.dev dispatch fails If tasks.trigger (or its dynamic imports) throws after markTableJobRunning, the ghost running row held the table's one-write-job slot until the stale-job janitor fired (~15-20 min of 409s). All four kickoff routes now release the claim and rethrow; the backfill runner releases and warns (a failed backfill never fails the schema change). Greptile P1. Co-Authored-By: Claude Opus 4.8 * chore(db): squash 0232 into 0231 (one migration for the PR) Both are branch-only — no environment has applied them through the migration ledger yet — so the tenant-scoped GIN (btree_gin extension, index swap) folds into 0231_table_jobs_and_keyset. Snapshot chain re-pointed; drizzle-kit generate confirms zero drift. Co-Authored-By: Claude Opus 4.8 * fix(tables): context-menu delete label shows the true select-all count Under select-all the context menu counted only the loaded page ("Delete 1000 rows" on a 999k-row table) while the action correctly deletes every matching row via the background job. Delete now gets its own count from the filter-aware total minus deselections; the run-action labels keep the loaded-row count since those actions act on loaded rows only. Co-Authored-By: Claude Opus 4.8 * fix(tables): context-menu bulk actions act on the full select-all scope Follow-up to the label fix: under select-all the context menu's Run / Re-run / Stop only acted on the loaded page of rows. They now route through the same scopes as the action bar — runs dispatch by filter (whole table when unfiltered), Stop uses the filter-scoped cancel — and all labels share one true count (filter-aware total minus deselections, locale-formatted). Like the action bar, filter-scoped runs ignore deselections (the run API has no exclusion set). Co-Authored-By: Claude Opus 4.8 * feat(tables): exclusion set for select-all runs and stops Select-all minus deselected rows now means exactly that for every bulk action, not just delete. runColumnBodySchema and cancelTableRunsBodySchema accept excludeRowIds (bounded by MAX_EXCLUDE_ROW_IDS, select-all scope only); the dispatch scope persists it and the dispatcher window walk, eager bulk-clear, pre-run cancel, and filter/table-scoped cancel all skip excluded rows. Client threads exclusions from the selection through the action bar and the grid context menu, including the optimistic stamps. Co-Authored-By: Claude Opus 4.8 * fix(tables): spare excluded-row dispatches on Stop; no orphan placeholder table Two Bugbot findings on the exclusion work: - Select-all-minus-deselections Stop (no filter) cancelled every active dispatch table-wide, killing row-scoped runs on deselected rows. markActiveDispatchesCancelled now spares dispatches whose scope.rowIds are fully contained in the exclusion set (coalesce(false) keeps table-wide dispatches cancellable). - Create-mode import: a failed trigger.dev dispatch released the job claim but left the just-created placeholder table in the workspace. Archive it on the failure path (no hard-delete surface exists). Co-Authored-By: Claude Opus 4.8 * fix(tables): row counts reflect a running delete everywhere A mid-delete refresh resurrected the old counts: the optimistic update stripped cached rows but left page-0 totalCount (footer / select-all label) at the old total, and list/detail counts reported raw row_count including doomed-but-not-yet-deleted rows. - onMutate now sets the active view's totalCount to the kept rows and decrements the cached detail rowCount by the doomed estimate - the kickoff persists that estimate on the job (payload.doomedCount, clamped server-side); getTableById/listTables subtract the not-yet-deleted remainder (doomedCount - rows_processed) while the delete runs, so refetched counts match the read path's delete mask Co-Authored-By: Claude Opus 4.8 * copy(tables): drop background mention from delete confirm Co-Authored-By: Claude Opus 4.8 * fix(tables): clear select-all immediately when a delete kicks off The header checkbox lingered as a minus over the optimistically-emptied grid: rowSelectionCoversAll treats zero rows as not-covered, and the selection clear waited for the kickoff's onSuccess. Clear at click (failed kickoffs visibly restore rows + toast; re-selecting is cheap) and render an empty grid's header checkbox unchecked regardless — a selection over zero rows is vacuous. Co-Authored-By: Claude Opus 4.8 * fix(tables): export takes the async path while a delete job runs The sync/async export choice reads rowCount, which is a doomed-estimate- adjusted number during a running delete (and the estimate is client- supplied) — an overstated estimate could route a still-large masked set through the synchronous stream. Mid-delete exports now always run as a job: safe at any size, and exports bypass the one-job-per-table gate. Co-Authored-By: Claude Opus 4.8 * fix(build): stop uploads setup from sweeping the project into route graphs next build (Turbopack) failed with "Two or more assets with different content were emitted to the same output path" on the server-root chunk. Root cause: setup.server.ts's unscoped path.resolve(process.cwd()) made node-file-tracing sweep the entire project — next.config.ts included — into every route graph reaching lib/uploads (the files/upload route and, since the export job, the export-async path). Two producers emitted the swept config into same-named chunks; staging's latest commits made their contents diverge and the names collided. Annotate the path derivation with turbopackIgnore per the NFT warning's own remediation — the build passes and all ~390 "unexpected file in NFT list" warnings disappear. Also inline the releaseJobClaim dynamic imports in the kickoff routes to plain static imports — service is already statically imported there. Co-Authored-By: Claude Opus 4.8 --------- Co-authored-by: Claude Opus 4.8 --- .../cron/cleanup-stale-executions/route.ts | 60 +- .../api/table/[tableId]/cancel-runs/route.ts | 12 +- .../app/api/table/[tableId]/columns/route.ts | 64 +- .../api/table/[tableId]/columns/run/route.ts | 11 +- .../[tableId]/delete-async/route.test.ts | 213 + .../api/table/[tableId]/delete-async/route.ts | 124 + .../[tableId]/export-async/route.test.ts | 128 + .../api/table/[tableId]/export-async/route.ts | 83 + .../[tableId]/export/download/route.test.ts | 124 + .../table/[tableId]/export/download/route.ts | 64 + .../[tableId]/import-async/route.test.ts | 4 +- .../api/table/[tableId]/import-async/route.ts | 58 +- .../api/table/[tableId]/import/route.test.ts | 6 +- .../app/api/table/[tableId]/import/route.ts | 18 +- .../{import => job}/cancel/route.test.ts | 61 +- .../[tableId]/{import => job}/cancel/route.ts | 30 +- apps/sim/app/api/table/[tableId]/route.ts | 9 +- .../api/table/[tableId]/rows/[rowId]/route.ts | 24 +- .../sim/app/api/table/[tableId]/rows/route.ts | 80 +- .../api/table/[tableId]/rows/upsert/route.ts | 18 +- .../app/api/table/import-async/route.test.ts | 2 +- apps/sim/app/api/table/import-async/route.ts | 54 +- apps/sim/app/api/table/jobs/route.ts | 42 + apps/sim/app/api/table/route.ts | 9 +- apps/sim/app/api/table/utils.test.ts | 55 + apps/sim/app/api/table/utils.ts | 90 +- .../app/api/v1/tables/[tableId]/rows/route.ts | 51 +- .../components/context-menu/context-menu.tsx | 11 +- .../components/table-grid/table-grid.tsx | 204 +- .../[tableId]/components/table-grid/utils.ts | 17 +- .../[tableId]/hooks/use-table-event-stream.ts | 76 +- .../tables/[tableId]/hooks/use-table.ts | 11 + .../[workspaceId]/tables/[tableId]/table.tsx | 131 +- .../import-csv-dialog/import-csv-dialog.tsx | 4 +- .../import-progress-menu.tsx | 63 +- .../import-progress-menu/import-stage.ts | 26 + .../use-workspace-imports.ts | 116 +- .../workspace/[workspaceId]/tables/tables.tsx | 4 +- apps/sim/background/table-backfill.ts | 21 + apps/sim/background/table-delete.ts | 29 + apps/sim/background/table-export.ts | 21 + apps/sim/background/table-import.ts | 24 + apps/sim/hooks/queries/tables.test.ts | 26 +- apps/sim/hooks/queries/tables.ts | 293 +- apps/sim/lib/api/contracts/tables.ts | 199 +- apps/sim/lib/api/contracts/v1/tables/index.ts | 4 +- .../lib/copilot/chat/process-contents.test.ts | 2 - .../lib/execution/sandbox/bundles/docx.cjs | 63 +- .../lib/execution/sandbox/bundles/pdf-lib.cjs | 26 +- .../table/__tests__/find-row-matches.test.ts | 6 +- apps/sim/lib/table/backfill-runner.ts | 343 + apps/sim/lib/table/constants.ts | 9 + apps/sim/lib/table/delete-runner.test.ts | 131 + apps/sim/lib/table/delete-runner.ts | 146 + apps/sim/lib/table/dispatcher.ts | 93 +- apps/sim/lib/table/events.ts | 18 +- apps/sim/lib/table/export-format.ts | 41 + apps/sim/lib/table/export-runner.test.ts | 131 + apps/sim/lib/table/export-runner.ts | 150 + apps/sim/lib/table/import-runner.ts | 44 +- apps/sim/lib/table/import.ts | 9 +- apps/sim/lib/table/planner.ts | 23 + apps/sim/lib/table/service.ts | 921 +- apps/sim/lib/table/types.ts | 84 +- apps/sim/lib/table/validation.ts | 178 +- apps/sim/lib/table/workflow-columns.ts | 86 +- apps/sim/lib/uploads/core/setup.server.ts | 8 +- apps/sim/stores/table/import-tray/store.ts | 12 + .../migrations/0233_table_jobs_and_keyset.sql | 68 + .../db/migrations/meta/0233_snapshot.json | 16429 ++++++++++++++++ packages/db/migrations/meta/_journal.json | 7 + packages/db/schema.ts | 75 +- packages/testing/src/mocks/schema.mock.ts | 13 + scripts/check-api-validation-contracts.ts | 4 +- 74 files changed, 20902 insertions(+), 992 deletions(-) create mode 100644 apps/sim/app/api/table/[tableId]/delete-async/route.test.ts create mode 100644 apps/sim/app/api/table/[tableId]/delete-async/route.ts create mode 100644 apps/sim/app/api/table/[tableId]/export-async/route.test.ts create mode 100644 apps/sim/app/api/table/[tableId]/export-async/route.ts create mode 100644 apps/sim/app/api/table/[tableId]/export/download/route.test.ts create mode 100644 apps/sim/app/api/table/[tableId]/export/download/route.ts rename apps/sim/app/api/table/[tableId]/{import => job}/cancel/route.test.ts (61%) rename apps/sim/app/api/table/[tableId]/{import => job}/cancel/route.ts (55%) create mode 100644 apps/sim/app/api/table/jobs/route.ts create mode 100644 apps/sim/app/api/table/utils.test.ts create mode 100644 apps/sim/background/table-backfill.ts create mode 100644 apps/sim/background/table-delete.ts create mode 100644 apps/sim/background/table-export.ts create mode 100644 apps/sim/background/table-import.ts create mode 100644 apps/sim/lib/table/backfill-runner.ts create mode 100644 apps/sim/lib/table/delete-runner.test.ts create mode 100644 apps/sim/lib/table/delete-runner.ts create mode 100644 apps/sim/lib/table/export-format.ts create mode 100644 apps/sim/lib/table/export-runner.test.ts create mode 100644 apps/sim/lib/table/export-runner.ts create mode 100644 apps/sim/lib/table/planner.ts create mode 100644 packages/db/migrations/0233_table_jobs_and_keyset.sql create mode 100644 packages/db/migrations/meta/0233_snapshot.json diff --git a/apps/sim/app/api/cron/cleanup-stale-executions/route.ts b/apps/sim/app/api/cron/cleanup-stale-executions/route.ts index 99c395d644b..9f5bb1b868e 100644 --- a/apps/sim/app/api/cron/cleanup-stale-executions/route.ts +++ b/apps/sim/app/api/cron/cleanup-stale-executions/route.ts @@ -1,5 +1,5 @@ import { asyncJobs, db } from '@sim/db' -import { userTableDefinitions, workflowExecutionLogs } from '@sim/db/schema' +import { tableJobs, workflowExecutionLogs } from '@sim/db/schema' import { createLogger } from '@sim/logger' import { toError } from '@sim/utils/errors' import { and, eq, inArray, lt, sql } from 'drizzle-orm' @@ -8,12 +8,15 @@ import { verifyCronAuth } from '@/lib/auth/internal' import { JOB_RETENTION_HOURS, JOB_STATUS } from '@/lib/core/async-jobs' import { getMaxExecutionTimeout } from '@/lib/core/execution-limits' import { withRouteHandler } from '@/lib/core/utils/with-route-handler' +import { deleteFile } from '@/lib/uploads/core/storage-service' const logger = createLogger('CleanupStaleExecutions') const STALE_THRESHOLD_MS = getMaxExecutionTimeout() + 5 * 60 * 1000 const STALE_THRESHOLD_MINUTES = Math.ceil(STALE_THRESHOLD_MS / 60000) const MAX_INT32 = 2_147_483_647 +/** Terminal table-jobs older than this are pruned; only the latest job per table is ever read. */ +const TABLE_JOB_RETENTION_HOURS = 24 export const GET = withRouteHandler(async (request: NextRequest) => { try { @@ -110,33 +113,56 @@ export const GET = withRouteHandler(async (request: NextRequest) => { }) } - // Mark stale table imports as failed. Imports run detached on the web container and - // are lost if the pod is killed mid-load. `updatedAt` is bumped by progress updates, so - // an `importing` table with no recent update has stalled (not merely slow). Rows are - // left in place (no rollback); the user re-imports. + // Mark stale table jobs (import or delete) as failed. Jobs run detached on the web container + // and are lost if the pod is killed mid-run. `updated_at` is bumped by progress updates, so a + // `running` job with no recent update has stalled (not merely slow). Committed work is left in + // place (no rollback); the user retries. Also prune long-settled terminal jobs so the table + // doesn't grow unbounded (the latest job per table is what list/detail reads surface). let staleImportsMarkedFailed = 0 try { + const now = new Date() const staleImports = await db - .update(userTableDefinitions) + .update(tableJobs) .set({ - importStatus: 'failed', - importError: `Import terminated: no progress for more than ${STALE_THRESHOLD_MINUTES} minutes (worker timeout or crash)`, - updatedAt: new Date(), + status: 'failed', + error: `Job terminated: no progress for more than ${STALE_THRESHOLD_MINUTES} minutes (worker timeout or crash)`, + completedAt: now, + updatedAt: now, }) + .where(and(eq(tableJobs.status, 'running'), lt(tableJobs.updatedAt, staleThreshold))) + .returning({ id: tableJobs.id }) + + staleImportsMarkedFailed = staleImports.length + if (staleImportsMarkedFailed > 0) { + logger.info(`Marked ${staleImportsMarkedFailed} stale table jobs as failed`) + } + + const terminalRetention = new Date(Date.now() - TABLE_JOB_RETENTION_HOURS * 60 * 60 * 1000) + const pruned = await db + .delete(tableJobs) .where( and( - eq(userTableDefinitions.importStatus, 'importing'), - lt(userTableDefinitions.updatedAt, staleThreshold) + inArray(tableJobs.status, ['ready', 'failed', 'canceled']), + lt(tableJobs.updatedAt, terminalRetention) ) ) - .returning({ id: userTableDefinitions.id }) - - staleImportsMarkedFailed = staleImports.length - if (staleImportsMarkedFailed > 0) { - logger.info(`Marked ${staleImportsMarkedFailed} stale table imports as failed`) + .returning({ type: tableJobs.type, payload: tableJobs.payload }) + + // Pruned export jobs carry the generated file's storage key — delete the file with the job + // so the exports prefix doesn't accumulate. Best-effort: a miss just orphans one object. + for (const job of pruned) { + if (job.type !== 'export') continue + const resultKey = (job.payload as { resultKey?: string } | null)?.resultKey + if (!resultKey) continue + await deleteFile({ key: resultKey, context: 'workspace' }).catch((err) => { + logger.warn('Failed to delete pruned export file', { + resultKey, + error: toError(err).message, + }) + }) } } catch (error) { - logger.error('Failed to clean up stale table imports:', { + logger.error('Failed to clean up stale table jobs:', { error: toError(error).message, }) } diff --git a/apps/sim/app/api/table/[tableId]/cancel-runs/route.ts b/apps/sim/app/api/table/[tableId]/cancel-runs/route.ts index be89633d7e9..ce656d6be50 100644 --- a/apps/sim/app/api/table/[tableId]/cancel-runs/route.ts +++ b/apps/sim/app/api/table/[tableId]/cancel-runs/route.ts @@ -6,7 +6,7 @@ import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid' import { generateRequestId } from '@/lib/core/utils/request' import { withRouteHandler } from '@/lib/core/utils/with-route-handler' import { cancelWorkflowGroupRuns } from '@/lib/table/workflow-columns' -import { accessError, checkAccess } from '@/app/api/table/utils' +import { accessError, checkAccess, tableFilterError } from '@/app/api/table/utils' const logger = createLogger('TableCancelRunsAPI') @@ -32,7 +32,7 @@ export const POST = withRouteHandler(async (request: NextRequest, { params }: Ro const parsed = await parseRequest(cancelTableRunsContract, request, { params }) if (!parsed.success) return parsed.response const { tableId } = parsed.data.params - const { workspaceId, scope, rowId } = parsed.data.body + const { workspaceId, scope, rowId, filter, excludeRowIds } = parsed.data.body const result = await checkAccess(tableId, authResult.userId, 'write') if (!result.ok) return accessError(result, requestId, tableId) @@ -42,7 +42,13 @@ export const POST = withRouteHandler(async (request: NextRequest, { params }: Ro return NextResponse.json({ error: 'Invalid workspace ID' }, { status: 400 }) } - const cancelled = await cancelWorkflowGroupRuns(tableId, scope === 'row' ? rowId : undefined) + const filterError = tableFilterError(filter, table.schema.columns) + if (filterError) return filterError + + const cancelled = await cancelWorkflowGroupRuns(tableId, scope === 'row' ? rowId : undefined, { + filter, + excludeRowIds, + }) logger.info( `[${requestId}] cancel-runs: tableId=${tableId} scope=${scope}${ rowId ? ` rowId=${rowId}` : '' diff --git a/apps/sim/app/api/table/[tableId]/columns/route.ts b/apps/sim/app/api/table/[tableId]/columns/route.ts index 6b87c84f644..7eecb5ee466 100644 --- a/apps/sim/app/api/table/[tableId]/columns/route.ts +++ b/apps/sim/app/api/table/[tableId]/columns/route.ts @@ -17,7 +17,7 @@ import { updateColumnConstraints, updateColumnType, } from '@/lib/table' -import { accessError, checkAccess, normalizeColumn } from '@/app/api/table/utils' +import { accessError, checkAccess, normalizeColumn, rootErrorMessage } from '@/app/api/table/utils' const logger = createLogger('TableColumnsAPI') @@ -63,13 +63,17 @@ export const POST = withRouteHandler(async (request: NextRequest, context: Colum return validationErrorResponse(error, 'Invalid request data') } - if (error instanceof Error) { - if (error.message.includes('already exists') || error.message.includes('maximum column')) { - return NextResponse.json({ error: error.message }, { status: 400 }) - } - if (error.message === 'Table not found') { - return NextResponse.json({ error: error.message }, { status: 404 }) - } + const msg = rootErrorMessage(error) + if ( + msg.includes('already exists') || + msg.includes('maximum column') || + msg.includes('Invalid column') || + msg.includes('exceeds maximum') + ) { + return NextResponse.json({ error: msg }, { status: 400 }) + } + if (msg === 'Table not found') { + return NextResponse.json({ error: msg }, { status: 404 }) } logger.error(`[${requestId}] Error adding column to table ${tableId}:`, error) @@ -146,22 +150,21 @@ export const PATCH = withRouteHandler(async (request: NextRequest, context: Colu return validationErrorResponse(error, 'Invalid request data') } - if (error instanceof Error) { - const msg = error.message - if (msg.includes('not found') || msg.includes('Table not found')) { - return NextResponse.json({ error: msg }, { status: 404 }) - } - if ( - msg.includes('already exists') || - msg.includes('Cannot delete the last column') || - msg.includes('Cannot set column') || - msg.includes('Invalid column') || - msg.includes('exceeds maximum') || - msg.includes('incompatible') || - msg.includes('duplicate') - ) { - return NextResponse.json({ error: msg }, { status: 400 }) - } + const msg = rootErrorMessage(error) + if (msg.includes('not found') || msg.includes('Table not found')) { + return NextResponse.json({ error: msg }, { status: 404 }) + } + if ( + msg.includes('already exists') || + msg.includes('Cannot delete the last column') || + msg.includes('Cannot set column') || + msg.includes('Cannot set unique column') || + msg.includes('Invalid column') || + msg.includes('exceeds maximum') || + msg.includes('incompatible') || + msg.includes('duplicate') + ) { + return NextResponse.json({ error: msg }, { status: 400 }) } logger.error(`[${requestId}] Error updating column in table ${tableId}:`, error) @@ -211,13 +214,12 @@ export const DELETE = withRouteHandler( return validationErrorResponse(error, 'Invalid request data') } - if (error instanceof Error) { - if (error.message.includes('not found') || error.message === 'Table not found') { - return NextResponse.json({ error: error.message }, { status: 404 }) - } - if (error.message.includes('Cannot delete') || error.message.includes('last column')) { - return NextResponse.json({ error: error.message }, { status: 400 }) - } + const msg = rootErrorMessage(error) + if (msg.includes('not found') || msg === 'Table not found') { + return NextResponse.json({ error: msg }, { status: 404 }) + } + if (msg.includes('Cannot delete') || msg.includes('last column')) { + return NextResponse.json({ error: msg }, { status: 400 }) } logger.error(`[${requestId}] Error deleting column from table ${tableId}:`, error) diff --git a/apps/sim/app/api/table/[tableId]/columns/run/route.ts b/apps/sim/app/api/table/[tableId]/columns/run/route.ts index 341f58662b0..00856ae4a1a 100644 --- a/apps/sim/app/api/table/[tableId]/columns/run/route.ts +++ b/apps/sim/app/api/table/[tableId]/columns/run/route.ts @@ -6,7 +6,7 @@ import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid' import { generateRequestId } from '@/lib/core/utils/request' import { withRouteHandler } from '@/lib/core/utils/with-route-handler' import { runWorkflowColumn } from '@/lib/table/workflow-columns' -import { accessError, checkAccess } from '@/app/api/table/utils' +import { accessError, checkAccess, tableFilterError } from '@/app/api/table/utils' const logger = createLogger('TableRunColumnAPI') @@ -25,16 +25,23 @@ export const POST = withRouteHandler(async (request: NextRequest, { params }: Ro const parsed = await parseRequest(runColumnContract, request, { params }) if (!parsed.success) return parsed.response const { tableId } = parsed.data.params - const { workspaceId, groupIds, runMode, rowIds, limit } = parsed.data.body + const { workspaceId, groupIds, runMode, rowIds, filter, excludeRowIds, limit } = + parsed.data.body const access = await checkAccess(tableId, auth.userId, 'write') if (!access.ok) return accessError(access, requestId, tableId) + // Validate the filter up front (the dispatcher reuses it) so a bad field fails fast. + const filterError = tableFilterError(filter, access.table.schema.columns) + if (filterError) return filterError + const { dispatchId } = await runWorkflowColumn({ tableId, workspaceId, groupIds, mode: runMode, rowIds, + filter, + excludeRowIds, limit, requestId, triggeredByUserId: auth.userId, diff --git a/apps/sim/app/api/table/[tableId]/delete-async/route.test.ts b/apps/sim/app/api/table/[tableId]/delete-async/route.test.ts new file mode 100644 index 00000000000..9565725c8a6 --- /dev/null +++ b/apps/sim/app/api/table/[tableId]/delete-async/route.test.ts @@ -0,0 +1,213 @@ +/** + * @vitest-environment node + */ +import { hybridAuthMockFns } from '@sim/testing' +import { NextRequest, NextResponse } from 'next/server' +import { beforeEach, describe, expect, it, vi } from 'vitest' +import type { TableDefinition } from '@/lib/table' + +const { + mockCheckAccess, + mockMarkTableJobRunning, + mockReleaseJobClaim, + mockRunTableDelete, + mockTableFilterError, + mockTasksTrigger, + flags, +} = vi.hoisted(() => ({ + mockCheckAccess: vi.fn(), + mockMarkTableJobRunning: vi.fn(), + mockReleaseJobClaim: vi.fn(), + mockRunTableDelete: vi.fn(), + mockTableFilterError: vi.fn(), + mockTasksTrigger: vi.fn(), + flags: { triggerDev: false }, +})) + +vi.mock('@sim/utils/id', () => ({ + generateId: vi.fn().mockReturnValue('job-id-xyz'), + generateShortId: vi.fn().mockReturnValue('short-id'), +})) +vi.mock('@/lib/table/service', () => ({ + markTableJobRunning: mockMarkTableJobRunning, + releaseJobClaim: mockReleaseJobClaim, +})) +vi.mock('@/lib/table/delete-runner', () => ({ runTableDelete: mockRunTableDelete })) +vi.mock('@/lib/core/config/feature-flags', () => ({ + get isTriggerDevEnabled() { + return flags.triggerDev + }, +})) +vi.mock('@/background/table-delete', () => ({ tableDeleteTask: { id: 'table-delete' } })) +vi.mock('@trigger.dev/sdk', () => ({ + tasks: { trigger: mockTasksTrigger }, + task: (config: unknown) => config, +})) +vi.mock('@/lib/core/utils/background', () => ({ + runDetached: (_label: string, work: () => Promise) => { + void work() + }, +})) +vi.mock('@/app/api/table/utils', async () => { + const { NextResponse } = await import('next/server') + return { + checkAccess: mockCheckAccess, + accessError: (result: { status: number }) => + NextResponse.json({ error: 'denied' }, { status: result.status }), + tableFilterError: mockTableFilterError, + } +}) + +import { POST } from '@/app/api/table/[tableId]/delete-async/route' + +function buildTable(overrides: Partial = {}): TableDefinition { + return { + id: 'tbl_1', + name: 'People', + description: null, + schema: { columns: [{ name: 'status', type: 'string' }] }, + metadata: null, + rowCount: 1000, + maxRows: 1_000_000, + workspaceId: 'workspace-1', + createdBy: 'user-1', + archivedAt: null, + createdAt: new Date(), + updatedAt: new Date(), + ...overrides, + } +} + +function makeRequest(body: unknown, tableId = 'tbl_1') { + const req = new NextRequest(`http://localhost:3000/api/table/${tableId}/delete-async`, { + method: 'POST', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify(body), + }) + return POST(req, { params: Promise.resolve({ tableId }) }) +} + +const validBody = { + workspaceId: 'workspace-1', + filter: { status: 'archived' }, + excludeRowIds: ['row_keep'], +} + +describe('POST /api/table/[tableId]/delete-async', () => { + beforeEach(() => { + vi.clearAllMocks() + hybridAuthMockFns.mockCheckSessionOrInternalAuth.mockResolvedValue({ + success: true, + userId: 'user-1', + authType: 'session', + }) + mockCheckAccess.mockResolvedValue({ ok: true, table: buildTable() }) + mockMarkTableJobRunning.mockResolvedValue(true) + mockRunTableDelete.mockResolvedValue(undefined) + mockTableFilterError.mockReturnValue(null) + mockTasksTrigger.mockResolvedValue({ id: 'run_1' }) + flags.triggerDev = false + }) + + it('claims the job slot and kicks off the delete worker with filter + exclusions', async () => { + const response = await makeRequest(validBody) + const data = await response.json() + + expect(response.status).toBe(200) + expect(data.data).toEqual({ tableId: 'tbl_1', jobId: 'job-id-xyz' }) + expect(mockMarkTableJobRunning).toHaveBeenCalledWith('tbl_1', 'job-id-xyz', 'delete', { + filter: { status: 'archived' }, + excludeRowIds: ['row_keep'], + cutoff: expect.any(String), + }) + expect(mockRunTableDelete).toHaveBeenCalledWith( + expect.objectContaining({ + jobId: 'job-id-xyz', + tableId: 'tbl_1', + workspaceId: 'workspace-1', + filter: { status: 'archived' }, + excludeRowIds: ['row_keep'], + cutoff: expect.any(Date), + }) + ) + }) + + it('allows a whole-table delete with no filter', async () => { + const response = await makeRequest({ workspaceId: 'workspace-1' }) + expect(response.status).toBe(200) + expect(mockRunTableDelete).toHaveBeenCalledWith( + expect.objectContaining({ filter: undefined, cutoff: expect.any(Date) }) + ) + }) + + it('returns 409 when a job is already in progress (claim lost)', async () => { + mockMarkTableJobRunning.mockResolvedValue(false) + const response = await makeRequest(validBody) + expect(response.status).toBe(409) + expect(mockRunTableDelete).not.toHaveBeenCalled() + }) + + it('returns 400 on an invalid filter without claiming the slot', async () => { + mockTableFilterError.mockReturnValue(NextResponse.json({ error: 'bad field' }, { status: 400 })) + const response = await makeRequest(validBody) + expect(response.status).toBe(400) + expect(mockMarkTableJobRunning).not.toHaveBeenCalled() + expect(mockRunTableDelete).not.toHaveBeenCalled() + }) + + it('returns 401 when unauthenticated', async () => { + hybridAuthMockFns.mockCheckSessionOrInternalAuth.mockResolvedValue({ success: false }) + const response = await makeRequest(validBody) + expect(response.status).toBe(401) + expect(mockMarkTableJobRunning).not.toHaveBeenCalled() + }) + + it('returns the access error status when access is denied', async () => { + mockCheckAccess.mockResolvedValue({ ok: false, status: 403 }) + const response = await makeRequest(validBody) + expect(response.status).toBe(403) + expect(mockRunTableDelete).not.toHaveBeenCalled() + }) + + it('returns 400 when the table is archived', async () => { + mockCheckAccess.mockResolvedValue({ ok: true, table: buildTable({ archivedAt: new Date() }) }) + const response = await makeRequest(validBody) + expect(response.status).toBe(400) + expect(mockRunTableDelete).not.toHaveBeenCalled() + }) + + it('returns 400 on workspace mismatch', async () => { + const response = await makeRequest({ ...validBody, workspaceId: 'other-ws' }) + expect(response.status).toBe(400) + }) + + it('routes through trigger.dev (ISO cutoff, tagged) when the flag is on', async () => { + flags.triggerDev = true + const response = await makeRequest(validBody) + + expect(response.status).toBe(200) + expect(mockRunTableDelete).not.toHaveBeenCalled() + expect(mockTasksTrigger).toHaveBeenCalledWith( + 'table-delete', + expect.objectContaining({ + jobId: 'job-id-xyz', + tableId: 'tbl_1', + filter: { status: 'archived' }, + excludeRowIds: ['row_keep'], + cutoff: expect.any(String), + }), + { tags: ['tableId:tbl_1', 'jobId:job-id-xyz'] } + ) + }) + + it('releases the job claim when the trigger.dev dispatch fails (no ghost running job)', async () => { + flags.triggerDev = true + mockTasksTrigger.mockRejectedValueOnce(new Error('trigger.dev unreachable')) + + const response = await makeRequest(validBody) + + expect(response.status).toBe(500) + expect(mockReleaseJobClaim).toHaveBeenCalledWith('tbl_1', 'job-id-xyz') + expect(mockRunTableDelete).not.toHaveBeenCalled() + }) +}) diff --git a/apps/sim/app/api/table/[tableId]/delete-async/route.ts b/apps/sim/app/api/table/[tableId]/delete-async/route.ts new file mode 100644 index 00000000000..a322167dc89 --- /dev/null +++ b/apps/sim/app/api/table/[tableId]/delete-async/route.ts @@ -0,0 +1,124 @@ +import { createLogger } from '@sim/logger' +import { generateId } from '@sim/utils/id' +import { type NextRequest, NextResponse } from 'next/server' +import { deleteTableRowsAsyncContract } from '@/lib/api/contracts/tables' +import { parseRequest } from '@/lib/api/server' +import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid' +import { isTriggerDevEnabled } from '@/lib/core/config/feature-flags' +import { runDetached } from '@/lib/core/utils/background' +import { generateRequestId } from '@/lib/core/utils/request' +import { withRouteHandler } from '@/lib/core/utils/with-route-handler' +import { runTableDelete } from '@/lib/table/delete-runner' +import { markTableJobRunning, releaseJobClaim } from '@/lib/table/service' +import type { TableDeleteJobPayload } from '@/lib/table/types' +import { accessError, checkAccess, tableFilterError } from '@/app/api/table/utils' + +const logger = createLogger('TableDeleteAsync') + +export const runtime = 'nodejs' +export const dynamic = 'force-dynamic' + +interface RouteParams { + params: Promise<{ tableId: string }> +} + +/** + * POST /api/table/[tableId]/delete-async + * + * Kicks off a background "select all" delete: the client sends the active filter (and an optional + * exclusion set) instead of every row id. Claims the table's single job slot (mutually exclusive + * with imports), captures a `created_at` cutoff so rows inserted while the job runs survive, then + * runs the paginated delete worker detached. + */ +export const POST = withRouteHandler(async (request: NextRequest, { params }: RouteParams) => { + const requestId = generateRequestId() + + const authResult = await checkSessionOrInternalAuth(request, { requireWorkflowId: false }) + if (!authResult.success || !authResult.userId) { + return NextResponse.json({ error: 'Authentication required' }, { status: 401 }) + } + const userId = authResult.userId + + const parsed = await parseRequest(deleteTableRowsAsyncContract, request, { params }) + if (!parsed.success) return parsed.response + const { tableId } = parsed.data.params + const { workspaceId, filter, excludeRowIds, estimatedCount } = parsed.data.body + + const access = await checkAccess(tableId, userId, 'write') + if (!access.ok) return accessError(access, requestId, tableId) + const { table } = access + + if (table.workspaceId !== workspaceId) { + return NextResponse.json({ error: 'Invalid workspace ID' }, { status: 400 }) + } + if (table.archivedAt) { + return NextResponse.json({ error: 'Cannot delete from an archived table' }, { status: 400 }) + } + + // Validate the filter up front so the caller gets immediate feedback (the worker reuses it). + const filterError = tableFilterError(filter, table.schema.columns) + if (filterError) return filterError + + // Rows inserted after this instant are spared (created_at <= cutoff in the worker). + const cutoff = new Date() + + // Atomically claim the job slot — one background job per table, so this also blocks while an + // import is in flight (and vice versa). The scope is persisted to the job's payload so read + // paths can mask the doomed rows while the job runs (see `pendingDeleteMask`). + const jobId = generateId() + const payload: TableDeleteJobPayload = { + filter, + excludeRowIds, + cutoff: cutoff.toISOString(), + // Clamp the client's display estimate to reality so a stale/bogus value + // can't drive counts negative or hide more than the table holds. + ...(estimatedCount != null ? { doomedCount: Math.min(estimatedCount, table.rowCount) } : {}), + } + const claimed = await markTableJobRunning(tableId, jobId, 'delete', payload) + if (!claimed) { + return NextResponse.json( + { error: 'A job is already in progress for this table' }, + { status: 409 } + ) + } + + if (isTriggerDevEnabled) { + // Trigger.dev runs the delete outside the web container (survives deploys) and retries — + // safe: the keyset + cutoff walk just deletes whatever remains. + try { + const [{ tableDeleteTask }, { tasks }] = await Promise.all([ + import('@/background/table-delete'), + import('@trigger.dev/sdk'), + ]) + await tasks.trigger( + 'table-delete', + { jobId, tableId, workspaceId, filter, excludeRowIds, cutoff: cutoff.toISOString() }, + { tags: [`tableId:${tableId}`, `jobId:${jobId}`] } + ) + } catch (error) { + // A failed dispatch must not leave a ghost `running` job holding the + // table's one-write-job slot until the stale-job janitor fires. + await releaseJobClaim(tableId, jobId).catch(() => {}) + throw error + } + } else { + runDetached('table-delete', () => + runTableDelete({ + jobId, + tableId, + workspaceId, + filter, + excludeRowIds, + cutoff, + }) + ) + } + + logger.info(`[${requestId}] Async row delete started`, { + tableId, + jobId, + hasFilter: Boolean(filter), + excluded: excludeRowIds?.length ?? 0, + }) + return NextResponse.json({ success: true, data: { tableId, jobId } }) +}) diff --git a/apps/sim/app/api/table/[tableId]/export-async/route.test.ts b/apps/sim/app/api/table/[tableId]/export-async/route.test.ts new file mode 100644 index 00000000000..177e02abf37 --- /dev/null +++ b/apps/sim/app/api/table/[tableId]/export-async/route.test.ts @@ -0,0 +1,128 @@ +/** + * @vitest-environment node + */ +import { hybridAuthMockFns } from '@sim/testing' +import { NextRequest } from 'next/server' +import { beforeEach, describe, expect, it, vi } from 'vitest' +import type { TableDefinition } from '@/lib/table' + +const { mockCheckAccess, mockMarkTableJobRunning, mockRunTableExport } = vi.hoisted(() => ({ + mockCheckAccess: vi.fn(), + mockMarkTableJobRunning: vi.fn(), + mockRunTableExport: vi.fn(), +})) + +vi.mock('@sim/utils/id', () => ({ + generateId: vi.fn().mockReturnValue('job-id-xyz'), + generateShortId: vi.fn().mockReturnValue('short-id'), +})) +vi.mock('@/lib/table/service', () => ({ markTableJobRunning: mockMarkTableJobRunning })) +vi.mock('@/lib/table/export-runner', () => ({ runTableExport: mockRunTableExport })) +vi.mock('@/lib/core/utils/background', () => ({ + runDetached: (_label: string, work: () => Promise) => { + void work() + }, +})) +vi.mock('@/app/api/table/utils', async () => { + const { NextResponse } = await import('next/server') + return { + checkAccess: mockCheckAccess, + accessError: (result: { status: number }) => + NextResponse.json({ error: 'denied' }, { status: result.status }), + } +}) + +import { POST } from '@/app/api/table/[tableId]/export-async/route' + +function buildTable(overrides: Partial = {}): TableDefinition { + return { + id: 'tbl_1', + name: 'People', + description: null, + schema: { columns: [{ name: 'name', type: 'string' }] }, + metadata: null, + rowCount: 50000, + maxRows: 1_000_000, + workspaceId: 'workspace-1', + createdBy: 'user-1', + archivedAt: null, + createdAt: new Date(), + updatedAt: new Date(), + ...overrides, + } +} + +function makeRequest(body: unknown, tableId = 'tbl_1') { + const req = new NextRequest(`http://localhost:3000/api/table/${tableId}/export-async`, { + method: 'POST', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify(body), + }) + return POST(req, { params: Promise.resolve({ tableId }) }) +} + +const validBody = { workspaceId: 'workspace-1', format: 'csv' } + +describe('POST /api/table/[tableId]/export-async', () => { + beforeEach(() => { + vi.clearAllMocks() + hybridAuthMockFns.mockCheckSessionOrInternalAuth.mockResolvedValue({ + success: true, + userId: 'user-1', + authType: 'session', + }) + mockCheckAccess.mockResolvedValue({ ok: true, table: buildTable() }) + mockMarkTableJobRunning.mockResolvedValue(true) + mockRunTableExport.mockResolvedValue(undefined) + }) + + it('claims an export job and kicks off the worker', async () => { + const response = await makeRequest(validBody) + const data = await response.json() + + expect(response.status).toBe(200) + expect(data.data).toEqual({ tableId: 'tbl_1', jobId: 'job-id-xyz' }) + expect(mockMarkTableJobRunning).toHaveBeenCalledWith('tbl_1', 'job-id-xyz', 'export', { + format: 'csv', + }) + expect(mockRunTableExport).toHaveBeenCalledWith({ + jobId: 'job-id-xyz', + tableId: 'tbl_1', + workspaceId: 'workspace-1', + format: 'csv', + }) + }) + + it('defaults the format to csv', async () => { + const response = await makeRequest({ workspaceId: 'workspace-1' }) + expect(response.status).toBe(200) + expect(mockRunTableExport).toHaveBeenCalledWith(expect.objectContaining({ format: 'csv' })) + }) + + it('returns 409 when the claim fails', async () => { + mockMarkTableJobRunning.mockResolvedValue(false) + const response = await makeRequest(validBody) + expect(response.status).toBe(409) + expect(mockRunTableExport).not.toHaveBeenCalled() + }) + + it('returns 401 when unauthenticated', async () => { + hybridAuthMockFns.mockCheckSessionOrInternalAuth.mockResolvedValue({ success: false }) + const response = await makeRequest(validBody) + expect(response.status).toBe(401) + expect(mockMarkTableJobRunning).not.toHaveBeenCalled() + }) + + it('returns the access error status when access is denied', async () => { + mockCheckAccess.mockResolvedValue({ ok: false, status: 403 }) + const response = await makeRequest(validBody) + expect(response.status).toBe(403) + expect(mockRunTableExport).not.toHaveBeenCalled() + }) + + it('returns 400 on workspace mismatch', async () => { + const response = await makeRequest({ ...validBody, workspaceId: 'other-ws' }) + expect(response.status).toBe(400) + expect(mockMarkTableJobRunning).not.toHaveBeenCalled() + }) +}) diff --git a/apps/sim/app/api/table/[tableId]/export-async/route.ts b/apps/sim/app/api/table/[tableId]/export-async/route.ts new file mode 100644 index 00000000000..26ded9b6e1d --- /dev/null +++ b/apps/sim/app/api/table/[tableId]/export-async/route.ts @@ -0,0 +1,83 @@ +import { createLogger } from '@sim/logger' +import { generateId } from '@sim/utils/id' +import { type NextRequest, NextResponse } from 'next/server' +import { exportTableAsyncContract } from '@/lib/api/contracts/tables' +import { parseRequest } from '@/lib/api/server' +import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid' +import { isTriggerDevEnabled } from '@/lib/core/config/feature-flags' +import { runDetached } from '@/lib/core/utils/background' +import { generateRequestId } from '@/lib/core/utils/request' +import { withRouteHandler } from '@/lib/core/utils/with-route-handler' +import { runTableExport, type TableExportPayload } from '@/lib/table/export-runner' +import { markTableJobRunning, releaseJobClaim } from '@/lib/table/service' +import type { TableExportJobPayload } from '@/lib/table/types' +import { accessError, checkAccess } from '@/app/api/table/utils' + +const logger = createLogger('TableExportAsync') + +export const runtime = 'nodejs' +export const dynamic = 'force-dynamic' + +interface RouteParams { + params: Promise<{ tableId: string }> +} + +/** + * POST /api/table/[tableId]/export-async + * + * Kicks off a background export for large tables (small ones stream synchronously via `/export`). + * Export jobs are read-only, so they bypass the one-running-job-per-table gate (the partial-unique + * index excludes `type = 'export'`) — an export can run alongside an import or delete, and the + * delete-mask keeps a mid-delete export consistent with the delete's outcome. + */ +export const POST = withRouteHandler(async (request: NextRequest, { params }: RouteParams) => { + const requestId = generateRequestId() + + const authResult = await checkSessionOrInternalAuth(request, { requireWorkflowId: false }) + if (!authResult.success || !authResult.userId) { + return NextResponse.json({ error: 'Authentication required' }, { status: 401 }) + } + + const parsed = await parseRequest(exportTableAsyncContract, request, { params }) + if (!parsed.success) return parsed.response + const { tableId } = parsed.data.params + const { workspaceId, format } = parsed.data.body + + const access = await checkAccess(tableId, authResult.userId, 'read') + if (!access.ok) return accessError(access, requestId, tableId) + if (access.table.workspaceId !== workspaceId) { + return NextResponse.json({ error: 'Invalid workspace ID' }, { status: 400 }) + } + + const jobId = generateId() + const jobPayload: TableExportJobPayload = { format } + const claimed = await markTableJobRunning(tableId, jobId, 'export', jobPayload) + if (!claimed) { + // Only possible against another running *export*-typed insert race losing on the pkey, or a + // missing table — the active-job index excludes exports. + return NextResponse.json({ error: 'Failed to start export' }, { status: 409 }) + } + + const payload: TableExportPayload = { jobId, tableId, workspaceId, format } + if (isTriggerDevEnabled) { + try { + const [{ tableExportTask }, { tasks }] = await Promise.all([ + import('@/background/table-export'), + import('@trigger.dev/sdk'), + ]) + await tasks.trigger('table-export', payload, { + tags: [`tableId:${tableId}`, `jobId:${jobId}`], + }) + } catch (error) { + // A failed dispatch must not leave a ghost `running` job holding the + // table's one-write-job slot until the stale-job janitor fires. + await releaseJobClaim(tableId, jobId).catch(() => {}) + throw error + } + } else { + runDetached('table-export', () => runTableExport(payload)) + } + + logger.info(`[${requestId}] Async export started`, { tableId, jobId, format }) + return NextResponse.json({ success: true, data: { tableId, jobId } }) +}) diff --git a/apps/sim/app/api/table/[tableId]/export/download/route.test.ts b/apps/sim/app/api/table/[tableId]/export/download/route.test.ts new file mode 100644 index 00000000000..c3458093e68 --- /dev/null +++ b/apps/sim/app/api/table/[tableId]/export/download/route.test.ts @@ -0,0 +1,124 @@ +/** + * @vitest-environment node + */ +import { hybridAuthMockFns } from '@sim/testing' +import { NextRequest } from 'next/server' +import { beforeEach, describe, expect, it, vi } from 'vitest' +import type { TableDefinition } from '@/lib/table' + +const { mockCheckAccess, mockGetTableJob, mockGeneratePresignedDownloadUrl } = vi.hoisted(() => ({ + mockCheckAccess: vi.fn(), + mockGetTableJob: vi.fn(), + mockGeneratePresignedDownloadUrl: vi.fn(), +})) + +vi.mock('@/lib/table/service', () => ({ getTableJob: mockGetTableJob })) +vi.mock('@/lib/uploads/core/storage-service', () => ({ + generatePresignedDownloadUrl: mockGeneratePresignedDownloadUrl, +})) +vi.mock('@/app/api/table/utils', async () => { + const { NextResponse } = await import('next/server') + return { + checkAccess: mockCheckAccess, + accessError: (result: { status: number }) => + NextResponse.json({ error: 'denied' }, { status: result.status }), + } +}) + +import { GET } from '@/app/api/table/[tableId]/export/download/route' + +function buildTable(overrides: Partial = {}): TableDefinition { + return { + id: 'tbl_1', + name: 'People', + description: null, + schema: { columns: [] }, + metadata: null, + rowCount: 0, + maxRows: 1_000_000, + workspaceId: 'workspace-1', + createdBy: 'user-1', + archivedAt: null, + createdAt: new Date(), + updatedAt: new Date(), + ...overrides, + } +} + +function makeRequest(query: Record, tableId = 'tbl_1') { + const qs = new URLSearchParams(query).toString() + const req = new NextRequest(`http://localhost:3000/api/table/${tableId}/export/download?${qs}`) + return GET(req, { params: Promise.resolve({ tableId }) }) +} + +const validQuery = { workspaceId: 'workspace-1', jobId: 'job_1' } + +describe('GET /api/table/[tableId]/export/download', () => { + beforeEach(() => { + vi.clearAllMocks() + hybridAuthMockFns.mockCheckSessionOrInternalAuth.mockResolvedValue({ + success: true, + userId: 'user-1', + authType: 'session', + }) + mockCheckAccess.mockResolvedValue({ ok: true, table: buildTable() }) + mockGetTableJob.mockResolvedValue({ + id: 'job_1', + type: 'export', + status: 'ready', + payload: { format: 'csv', resultKey: 'workspace/workspace-1/exports/tbl_1/job_1/people.csv' }, + }) + mockGeneratePresignedDownloadUrl.mockResolvedValue('https://storage.example/signed-url') + }) + + it('resolves a ready export to a presigned URL', async () => { + const response = await makeRequest(validQuery) + const data = await response.json() + + expect(response.status).toBe(200) + expect(data.data).toEqual({ url: 'https://storage.example/signed-url', fileName: 'people.csv' }) + expect(mockGeneratePresignedDownloadUrl).toHaveBeenCalledWith( + 'workspace/workspace-1/exports/tbl_1/job_1/people.csv', + 'workspace' + ) + }) + + it('404s when the job is missing or not an export', async () => { + mockGetTableJob.mockResolvedValue({ id: 'job_1', type: 'delete', status: 'ready', payload: {} }) + const response = await makeRequest(validQuery) + expect(response.status).toBe(404) + }) + + it('409s when the export is not ready yet', async () => { + mockGetTableJob.mockResolvedValue({ + id: 'job_1', + type: 'export', + status: 'running', + payload: { format: 'csv' }, + }) + const response = await makeRequest(validQuery) + expect(response.status).toBe(409) + }) + + it('410s when the result file is gone from the payload', async () => { + mockGetTableJob.mockResolvedValue({ + id: 'job_1', + type: 'export', + status: 'ready', + payload: { format: 'csv' }, + }) + const response = await makeRequest(validQuery) + expect(response.status).toBe(410) + }) + + it('returns 401 when unauthenticated', async () => { + hybridAuthMockFns.mockCheckSessionOrInternalAuth.mockResolvedValue({ success: false }) + const response = await makeRequest(validQuery) + expect(response.status).toBe(401) + }) + + it('returns 400 on workspace mismatch', async () => { + const response = await makeRequest({ ...validQuery, workspaceId: 'other-ws' }) + expect(response.status).toBe(400) + }) +}) diff --git a/apps/sim/app/api/table/[tableId]/export/download/route.ts b/apps/sim/app/api/table/[tableId]/export/download/route.ts new file mode 100644 index 00000000000..577c2747b8c --- /dev/null +++ b/apps/sim/app/api/table/[tableId]/export/download/route.ts @@ -0,0 +1,64 @@ +import { createLogger } from '@sim/logger' +import { type NextRequest, NextResponse } from 'next/server' +import { exportDownloadContract } from '@/lib/api/contracts/tables' +import { parseRequest } from '@/lib/api/server' +import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid' +import { generateRequestId } from '@/lib/core/utils/request' +import { withRouteHandler } from '@/lib/core/utils/with-route-handler' +import { getTableJob } from '@/lib/table/service' +import type { TableExportJobPayload } from '@/lib/table/types' +import { generatePresignedDownloadUrl } from '@/lib/uploads/core/storage-service' +import { accessError, checkAccess } from '@/app/api/table/utils' + +const logger = createLogger('TableExportDownload') + +export const runtime = 'nodejs' +export const dynamic = 'force-dynamic' + +interface RouteParams { + params: Promise<{ tableId: string }> +} + +/** + * GET /api/table/[tableId]/export/download?jobId=… + * + * Resolves a completed export job to a short-lived presigned URL for the generated file. The job + * must belong to the table, be an export, and be `ready` — the worker stamps `resultKey` onto the + * job payload when the upload lands. + */ +export const GET = withRouteHandler(async (request: NextRequest, { params }: RouteParams) => { + const requestId = generateRequestId() + + const authResult = await checkSessionOrInternalAuth(request, { requireWorkflowId: false }) + if (!authResult.success || !authResult.userId) { + return NextResponse.json({ error: 'Authentication required' }, { status: 401 }) + } + + const parsed = await parseRequest(exportDownloadContract, request, { params }) + if (!parsed.success) return parsed.response + const { tableId } = parsed.data.params + const { workspaceId, jobId } = parsed.data.query + + const access = await checkAccess(tableId, authResult.userId, 'read') + if (!access.ok) return accessError(access, requestId, tableId) + if (access.table.workspaceId !== workspaceId) { + return NextResponse.json({ error: 'Invalid workspace ID' }, { status: 400 }) + } + + const job = await getTableJob(tableId, jobId) + if (!job || job.type !== 'export') { + return NextResponse.json({ error: 'Export job not found' }, { status: 404 }) + } + if (job.status !== 'ready') { + return NextResponse.json({ error: 'Export is not ready' }, { status: 409 }) + } + const payload = job.payload as TableExportJobPayload | null + if (!payload?.resultKey) { + return NextResponse.json({ error: 'Export file is no longer available' }, { status: 410 }) + } + + const url = await generatePresignedDownloadUrl(payload.resultKey, 'workspace') + const fileName = payload.resultKey.split('/').pop() ?? `export.${payload.format}` + logger.info(`[${requestId}] Export download URL issued`, { tableId, jobId }) + return NextResponse.json({ success: true, data: { url, fileName } }) +}) diff --git a/apps/sim/app/api/table/[tableId]/import-async/route.test.ts b/apps/sim/app/api/table/[tableId]/import-async/route.test.ts index 18fa93aca80..7ed47fa66e3 100644 --- a/apps/sim/app/api/table/[tableId]/import-async/route.test.ts +++ b/apps/sim/app/api/table/[tableId]/import-async/route.test.ts @@ -16,7 +16,7 @@ vi.mock('@sim/utils/id', () => ({ generateId: vi.fn().mockReturnValue('import-id-xyz'), generateShortId: vi.fn().mockReturnValue('short-id'), })) -vi.mock('@/lib/table/service', () => ({ markTableImporting: mockMarkTableImporting })) +vi.mock('@/lib/table/service', () => ({ markTableJobRunning: mockMarkTableImporting })) vi.mock('@/lib/table/import-runner', () => ({ runTableImport: mockRunTableImport })) vi.mock('@/lib/core/utils/background', () => ({ runDetached: (_label: string, work: () => Promise) => { @@ -92,7 +92,7 @@ describe('POST /api/table/[tableId]/import-async', () => { expect(response.status).toBe(200) expect(data.data).toEqual({ tableId: 'tbl_1', importId: 'import-id-xyz' }) - expect(mockMarkTableImporting).toHaveBeenCalledWith('tbl_1', 'import-id-xyz') + expect(mockMarkTableImporting).toHaveBeenCalledWith('tbl_1', 'import-id-xyz', 'import') expect(mockRunTableImport).toHaveBeenCalledWith( expect.objectContaining({ tableId: 'tbl_1', diff --git a/apps/sim/app/api/table/[tableId]/import-async/route.ts b/apps/sim/app/api/table/[tableId]/import-async/route.ts index 46190cbfb06..f256bf5f35a 100644 --- a/apps/sim/app/api/table/[tableId]/import-async/route.ts +++ b/apps/sim/app/api/table/[tableId]/import-async/route.ts @@ -4,11 +4,12 @@ import { type NextRequest, NextResponse } from 'next/server' import { importIntoTableAsyncContract } from '@/lib/api/contracts/tables' import { parseRequest } from '@/lib/api/server' import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid' +import { isTriggerDevEnabled } from '@/lib/core/config/feature-flags' import { runDetached } from '@/lib/core/utils/background' import { generateRequestId } from '@/lib/core/utils/request' import { withRouteHandler } from '@/lib/core/utils/with-route-handler' -import { runTableImport } from '@/lib/table/import-runner' -import { markTableImporting } from '@/lib/table/service' +import { runTableImport, type TableImportPayload } from '@/lib/table/import-runner' +import { markTableJobRunning, releaseJobClaim } from '@/lib/table/service' import { accessError, checkAccess } from '@/app/api/table/utils' const logger = createLogger('TableImportIntoAsync') @@ -56,31 +57,48 @@ export const POST = withRouteHandler(async (request: NextRequest, { params }: Ro } const delimiter = ext === 'tsv' ? '\t' : ',' - // Atomically claim the table — the single concurrency gate. If another import already holds it, - // this returns false (no overlapping workers writing colliding row positions). + // Atomically claim the table's job slot — the single concurrency gate. If another job (import + // or delete) already holds it, this returns false (no overlapping workers). const importId = generateId() - const claimed = await markTableImporting(tableId, importId) + const claimed = await markTableJobRunning(tableId, importId, 'import') if (!claimed) { return NextResponse.json( - { error: 'An import is already in progress for this table' }, + { error: 'A job is already in progress for this table' }, { status: 409 } ) } - runDetached('table-import', () => - runTableImport({ - importId, - tableId, - workspaceId, - userId, - fileKey, - fileName, - delimiter, - mode, - mapping, - createColumns, - }) - ) + const importPayload: TableImportPayload = { + importId, + tableId, + workspaceId, + userId, + fileKey, + fileName, + delimiter, + mode, + mapping, + createColumns, + } + if (isTriggerDevEnabled) { + // Trigger.dev runs the import outside the web container, so it survives app deploys. + try { + const [{ tableImportTask }, { tasks }] = await Promise.all([ + import('@/background/table-import'), + import('@trigger.dev/sdk'), + ]) + await tasks.trigger('table-import', importPayload, { + tags: [`tableId:${tableId}`, `jobId:${importId}`], + }) + } catch (error) { + // A failed dispatch must not leave a ghost `running` job holding the + // table's one-write-job slot until the stale-job janitor fires. + await releaseJobClaim(tableId, importId).catch(() => {}) + throw error + } + } else { + runDetached('table-import', () => runTableImport(importPayload)) + } logger.info(`[${requestId}] Async CSV import into existing table started`, { tableId, diff --git a/apps/sim/app/api/table/[tableId]/import/route.test.ts b/apps/sim/app/api/table/[tableId]/import/route.test.ts index ac3e1221924..76650baf4c1 100644 --- a/apps/sim/app/api/table/[tableId]/import/route.test.ts +++ b/apps/sim/app/api/table/[tableId]/import/route.test.ts @@ -55,8 +55,8 @@ vi.mock('@/lib/table/service', () => ({ importAppendRows: mockImportAppendRows, importReplaceRows: mockImportReplaceRows, dispatchAfterBatchInsert: mockDispatchAfterBatchInsert, - markTableImporting: mockMarkTableImporting, - releaseImportClaim: mockReleaseImportClaim, + markTableJobRunning: mockMarkTableImporting, + releaseJobClaim: mockReleaseImportClaim, })) import { POST } from '@/app/api/table/[tableId]/import/route' @@ -184,7 +184,7 @@ describe('POST /api/table/[tableId]/import', () => { it('releases the import claim after a successful write', async () => { const response = await callPost(createFormData(createCsvFile('name,age\nAlice,30'))) expect(response.status).toBe(200) - expect(mockMarkTableImporting).toHaveBeenCalledWith('tbl_1', 'deadbeefcafef00d') + expect(mockMarkTableImporting).toHaveBeenCalledWith('tbl_1', 'deadbeefcafef00d', 'import') expect(mockReleaseImportClaim).toHaveBeenCalledWith('tbl_1', 'deadbeefcafef00d') }) diff --git a/apps/sim/app/api/table/[tableId]/import/route.ts b/apps/sim/app/api/table/[tableId]/import/route.ts index f04827d1ab1..ef57b09aced 100644 --- a/apps/sim/app/api/table/[tableId]/import/route.ts +++ b/apps/sim/app/api/table/[tableId]/import/route.ts @@ -28,8 +28,8 @@ import { importAppendRows, importReplaceRows, inferColumnType, - markTableImporting, - releaseImportClaim, + markTableJobRunning, + releaseJobClaim, sanitizeName, type TableDefinition, type TableSchema, @@ -128,11 +128,11 @@ export const POST = withRouteHandler(async (request: NextRequest, { params }: Ro if (table.archivedAt) { return NextResponse.json({ error: 'Cannot import into an archived table' }, { status: 400 }) } - // Don't run a sync import on top of an in-flight background import — concurrent writers + // Don't run a sync import on top of an in-flight background job — concurrent writers // would insert at colliding row positions. - if (table.importStatus === 'importing') { + if (table.jobStatus === 'running') { return NextResponse.json( - { error: 'An import is already in progress for this table' }, + { error: 'A job is already in progress for this table' }, { status: 409 } ) } @@ -253,12 +253,12 @@ export const POST = withRouteHandler(async (request: NextRequest, { params }: Ro // Atomically claim the table before writing. The pre-check above reads a checkAccess snapshot // taken before the parse/validation; a background import could claim the table in that window. - // markTableImporting is the single atomic gate (same one the async kickoff uses) — released in + // markTableJobRunning is the single atomic gate (same one the async kickoff uses) — released in // the finally so a sync import can't write concurrently with a background one (corrupts replace). const syncImportId = generateId() - if (!(await markTableImporting(tableId, syncImportId))) { + if (!(await markTableJobRunning(tableId, syncImportId, 'import'))) { return NextResponse.json( - { error: 'An import is already in progress for this table' }, + { error: 'A job is already in progress for this table' }, { status: 409 } ) } @@ -399,6 +399,6 @@ export const POST = withRouteHandler(async (request: NextRequest, { params }: Ro } finally { fileStream?.destroy() // Release before the response returns, so a client refetch never observes the transient claim. - if (claimedImportId) await releaseImportClaim(tableId, claimedImportId).catch(() => {}) + if (claimedImportId) await releaseJobClaim(tableId, claimedImportId).catch(() => {}) } }) diff --git a/apps/sim/app/api/table/[tableId]/import/cancel/route.test.ts b/apps/sim/app/api/table/[tableId]/job/cancel/route.test.ts similarity index 61% rename from apps/sim/app/api/table/[tableId]/import/cancel/route.test.ts rename to apps/sim/app/api/table/[tableId]/job/cancel/route.test.ts index d45baae77e2..f1837b42dc7 100644 --- a/apps/sim/app/api/table/[tableId]/import/cancel/route.test.ts +++ b/apps/sim/app/api/table/[tableId]/job/cancel/route.test.ts @@ -6,13 +6,19 @@ import { NextRequest } from 'next/server' import { beforeEach, describe, expect, it, vi } from 'vitest' import type { TableDefinition } from '@/lib/table' -const { mockCheckAccess, mockMarkImportCanceled, mockAppendTableEvent } = vi.hoisted(() => ({ - mockCheckAccess: vi.fn(), - mockMarkImportCanceled: vi.fn(), - mockAppendTableEvent: vi.fn(), -})) +const { mockCheckAccess, mockMarkJobCanceled, mockGetTableJob, mockAppendTableEvent } = vi.hoisted( + () => ({ + mockCheckAccess: vi.fn(), + mockMarkJobCanceled: vi.fn(), + mockGetTableJob: vi.fn(), + mockAppendTableEvent: vi.fn(), + }) +) -vi.mock('@/lib/table/service', () => ({ markImportCanceled: mockMarkImportCanceled })) +vi.mock('@/lib/table/service', () => ({ + markJobCanceled: mockMarkJobCanceled, + getTableJob: mockGetTableJob, +})) vi.mock('@/lib/table/events', () => ({ appendTableEvent: mockAppendTableEvent })) vi.mock('@/app/api/table/utils', async () => { const { NextResponse } = await import('next/server') @@ -23,14 +29,14 @@ vi.mock('@/app/api/table/utils', async () => { } }) -import { POST } from '@/app/api/table/[tableId]/import/cancel/route' +import { POST } from '@/app/api/table/[tableId]/job/cancel/route' function buildTable(overrides: Partial = {}): TableDefinition { return { id: 'tbl_1', name: 'People', description: null, - schema: { columns: [{ name: 'name', type: 'string' }] }, + schema: { columns: [] }, metadata: null, rowCount: 0, maxRows: 1_000_000, @@ -44,7 +50,7 @@ function buildTable(overrides: Partial = {}): TableDefinition { } function makeRequest(body: unknown, tableId = 'tbl_1') { - const req = new NextRequest(`http://localhost:3000/api/table/${tableId}/import/cancel`, { + const req = new NextRequest(`http://localhost:3000/api/table/${tableId}/job/cancel`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body), @@ -52,9 +58,9 @@ function makeRequest(body: unknown, tableId = 'tbl_1') { return POST(req, { params: Promise.resolve({ tableId }) }) } -const validBody = { workspaceId: 'workspace-1', importId: 'import-id-xyz' } +const validBody = { workspaceId: 'workspace-1', jobId: 'job_1' } -describe('POST /api/table/[tableId]/import/cancel', () => { +describe('POST /api/table/[tableId]/job/cancel', () => { beforeEach(() => { vi.clearAllMocks() hybridAuthMockFns.mockCheckSessionOrInternalAuth.mockResolvedValue({ @@ -63,27 +69,31 @@ describe('POST /api/table/[tableId]/import/cancel', () => { authType: 'session', }) mockCheckAccess.mockResolvedValue({ ok: true, table: buildTable() }) - mockMarkImportCanceled.mockResolvedValue(true) + mockMarkJobCanceled.mockResolvedValue(true) + mockGetTableJob.mockResolvedValue({ + id: 'job_1', + type: 'delete', + status: 'running', + payload: null, + }) }) - it('cancels the import and emits a canceled event', async () => { + it('cancels the job and emits a typed cancel event', async () => { const response = await makeRequest(validBody) const data = await response.json() expect(response.status).toBe(200) expect(data.data).toEqual({ canceled: true }) - expect(mockMarkImportCanceled).toHaveBeenCalledWith('tbl_1', 'import-id-xyz') + expect(mockMarkJobCanceled).toHaveBeenCalledWith('tbl_1', 'job_1') expect(mockAppendTableEvent).toHaveBeenCalledWith( - expect.objectContaining({ kind: 'import', status: 'canceled', importId: 'import-id-xyz' }) + expect.objectContaining({ kind: 'job', type: 'delete', status: 'canceled', jobId: 'job_1' }) ) }) - it('does not emit an event when nothing was importing', async () => { - mockMarkImportCanceled.mockResolvedValue(false) + it('does not emit an event when nothing was running', async () => { + mockMarkJobCanceled.mockResolvedValue(false) const response = await makeRequest(validBody) const data = await response.json() - - expect(response.status).toBe(200) expect(data.data).toEqual({ canceled: false }) expect(mockAppendTableEvent).not.toHaveBeenCalled() }) @@ -92,19 +102,12 @@ describe('POST /api/table/[tableId]/import/cancel', () => { hybridAuthMockFns.mockCheckSessionOrInternalAuth.mockResolvedValue({ success: false }) const response = await makeRequest(validBody) expect(response.status).toBe(401) - expect(mockMarkImportCanceled).not.toHaveBeenCalled() - }) - - it('returns the access error status when access is denied', async () => { - mockCheckAccess.mockResolvedValue({ ok: false, status: 403 }) - const response = await makeRequest(validBody) - expect(response.status).toBe(403) + expect(mockMarkJobCanceled).not.toHaveBeenCalled() }) it('returns 400 on workspace mismatch', async () => { - mockCheckAccess.mockResolvedValue({ ok: true, table: buildTable({ workspaceId: 'other-ws' }) }) - const response = await makeRequest(validBody) + const response = await makeRequest({ ...validBody, workspaceId: 'other' }) expect(response.status).toBe(400) - expect(mockMarkImportCanceled).not.toHaveBeenCalled() + expect(mockMarkJobCanceled).not.toHaveBeenCalled() }) }) diff --git a/apps/sim/app/api/table/[tableId]/import/cancel/route.ts b/apps/sim/app/api/table/[tableId]/job/cancel/route.ts similarity index 55% rename from apps/sim/app/api/table/[tableId]/import/cancel/route.ts rename to apps/sim/app/api/table/[tableId]/job/cancel/route.ts index 62ab7310f47..b4ee3d98346 100644 --- a/apps/sim/app/api/table/[tableId]/import/cancel/route.ts +++ b/apps/sim/app/api/table/[tableId]/job/cancel/route.ts @@ -1,15 +1,16 @@ import { createLogger } from '@sim/logger' import { type NextRequest, NextResponse } from 'next/server' -import { cancelTableImportContract } from '@/lib/api/contracts/tables' +import { cancelTableJobContract } from '@/lib/api/contracts/tables' import { parseRequest } from '@/lib/api/server' import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid' import { generateRequestId } from '@/lib/core/utils/request' import { withRouteHandler } from '@/lib/core/utils/with-route-handler' import { appendTableEvent } from '@/lib/table/events' -import { markImportCanceled } from '@/lib/table/service' +import { getTableJob, markJobCanceled } from '@/lib/table/service' +import type { TableJobType } from '@/lib/table/types' import { accessError, checkAccess } from '@/app/api/table/utils' -const logger = createLogger('TableImportCancelAPI') +const logger = createLogger('TableJobCancelAPI') export const runtime = 'nodejs' export const dynamic = 'force-dynamic' @@ -19,11 +20,11 @@ interface RouteParams { } /** - * POST /api/table/[tableId]/import/cancel + * POST /api/table/[tableId]/job/cancel * - * Cancels an in-flight async CSV import. Flips the table's import status to `canceled`, which makes - * the detached worker's next ownership check fail so it stops inserting. Committed rows are left in - * place (no rollback) — the user can delete the table. No-op if the import already finished. + * Cancels an in-flight async table job (import or delete). Flips the table's job status to + * `canceled`, which makes the detached worker's next ownership check fail so it stops. Committed + * work (inserted/deleted rows) is left in place (no rollback). No-op if the job already finished. */ export const POST = withRouteHandler(async (request: NextRequest, { params }: RouteParams) => { const requestId = generateRequestId() @@ -33,10 +34,10 @@ export const POST = withRouteHandler(async (request: NextRequest, { params }: Ro return NextResponse.json({ error: 'Authentication required' }, { status: 401 }) } - const parsed = await parseRequest(cancelTableImportContract, request, { params }) + const parsed = await parseRequest(cancelTableJobContract, request, { params }) if (!parsed.success) return parsed.response const { tableId } = parsed.data.params - const { workspaceId, importId } = parsed.data.body + const { workspaceId, jobId } = parsed.data.body const access = await checkAccess(tableId, authResult.userId, 'write') if (!access.ok) return accessError(access, requestId, tableId) @@ -44,11 +45,16 @@ export const POST = withRouteHandler(async (request: NextRequest, { params }: Ro return NextResponse.json({ error: 'Invalid workspace ID' }, { status: 400 }) } - const canceled = await markImportCanceled(tableId, importId) + // Resolve the job's actual type (from its own row — the table-level derivation excludes + // exports) so the cancel event carries the right `type`. + const job = await getTableJob(tableId, jobId) + const type = (job?.type ?? 'import') as TableJobType + + const canceled = await markJobCanceled(tableId, jobId) if (canceled) { - void appendTableEvent({ kind: 'import', tableId, importId, status: 'canceled' }) + void appendTableEvent({ kind: 'job', type, tableId, jobId, status: 'canceled' }) } - logger.info(`[${requestId}] Import cancel requested`, { tableId, importId, canceled }) + logger.info(`[${requestId}] Job cancel requested`, { tableId, jobId, type, canceled }) return NextResponse.json({ success: true, data: { canceled } }) }) diff --git a/apps/sim/app/api/table/[tableId]/route.ts b/apps/sim/app/api/table/[tableId]/route.ts index c0b018f854e..0d185a74784 100644 --- a/apps/sim/app/api/table/[tableId]/route.ts +++ b/apps/sim/app/api/table/[tableId]/route.ts @@ -68,10 +68,11 @@ export const GET = withRouteHandler(async (request: NextRequest, { params }: Tab table.updatedAt instanceof Date ? table.updatedAt.toISOString() : String(table.updatedAt), - importStatus: table.importStatus ?? null, - importId: table.importId ?? null, - importError: table.importError ?? null, - importRowsProcessed: table.importRowsProcessed ?? 0, + jobStatus: table.jobStatus ?? null, + jobId: table.jobId ?? null, + jobType: table.jobType ?? null, + jobError: table.jobError ?? null, + jobRowsProcessed: table.jobRowsProcessed ?? 0, }, }, }) diff --git a/apps/sim/app/api/table/[tableId]/rows/[rowId]/route.ts b/apps/sim/app/api/table/[tableId]/rows/[rowId]/route.ts index 18486c370f6..b1865223f83 100644 --- a/apps/sim/app/api/table/[tableId]/rows/[rowId]/route.ts +++ b/apps/sim/app/api/table/[tableId]/rows/[rowId]/route.ts @@ -16,7 +16,12 @@ import { withRouteHandler } from '@/lib/core/utils/with-route-handler' import type { RowData, TableSchema } from '@/lib/table' import { deleteRow, updateRow } from '@/lib/table' import { rowWireTranslators } from '@/app/api/table/row-wire' -import { accessError, checkAccess } from '@/app/api/table/utils' +import { + accessError, + checkAccess, + rootErrorMessage, + rowWriteErrorResponse, +} from '@/app/api/table/utils' const logger = createLogger('TableRowAPI') @@ -167,21 +172,12 @@ export const PATCH = withRouteHandler(async (request: NextRequest, context: RowR }, }) } catch (error) { - const errorMessage = toError(error).message - - if (errorMessage === 'Row not found') { - return NextResponse.json({ error: errorMessage }, { status: 404 }) + if (rootErrorMessage(error) === 'Row not found') { + return NextResponse.json({ error: 'Row not found' }, { status: 404 }) } - if ( - errorMessage.includes('Row size exceeds') || - errorMessage.includes('Schema validation') || - errorMessage.includes('must be unique') || - errorMessage.includes('Unique constraint violation') || - errorMessage.includes('Cannot set unique column') - ) { - return NextResponse.json({ error: errorMessage }, { status: 400 }) - } + const response = rowWriteErrorResponse(error) + if (response) return response logger.error(`[${requestId}] Error updating row:`, error) return NextResponse.json({ error: 'Failed to update row' }, { status: 500 }) diff --git a/apps/sim/app/api/table/[tableId]/rows/route.ts b/apps/sim/app/api/table/[tableId]/rows/route.ts index 31708805ad2..372cd758041 100644 --- a/apps/sim/app/api/table/[tableId]/rows/route.ts +++ b/apps/sim/app/api/table/[tableId]/rows/route.ts @@ -1,5 +1,4 @@ import { createLogger } from '@sim/logger' -import { toError } from '@sim/utils/errors' import { type NextRequest, NextResponse } from 'next/server' import { type BatchInsertTableRowsBodyInput, @@ -14,7 +13,7 @@ import { isZodError, validationErrorResponse } from '@/lib/api/server/validation import { type AuthTypeValue, checkSessionOrInternalAuth } from '@/lib/auth/hybrid' import { generateRequestId } from '@/lib/core/utils/request' import { withRouteHandler } from '@/lib/core/utils/with-route-handler' -import type { Filter, RowData, Sort, TableSchema } from '@/lib/table' +import type { Filter, RowData, Sort, TableRowsCursor, TableSchema } from '@/lib/table' import { batchInsertRows, batchUpdateRows, @@ -29,7 +28,7 @@ import { import { queryRows } from '@/lib/table/service' import { TableQueryValidationError } from '@/lib/table/sql' import { rowWireTranslators } from '@/app/api/table/row-wire' -import { accessError, checkAccess } from '@/app/api/table/utils' +import { accessError, checkAccess, rowWriteErrorResponse } from '@/app/api/table/utils' const logger = createLogger('TableRowsAPI') @@ -98,18 +97,8 @@ async function handleBatchInsert( }, }) } catch (error) { - const errorMessage = toError(error).message - - if ( - errorMessage.includes('row limit') || - errorMessage.includes('Insufficient capacity') || - errorMessage.includes('Schema validation') || - errorMessage.includes('must be unique') || - errorMessage.includes('Row size exceeds') || - errorMessage.match(/^Row \d+:/) - ) { - return NextResponse.json({ error: errorMessage }, { status: 400 }) - } + const response = rowWriteErrorResponse(error) + if (response) return response logger.error(`[${requestId}] Error batch inserting rows:`, error) return NextResponse.json({ error: 'Failed to insert rows' }, { status: 500 }) @@ -197,17 +186,8 @@ export const POST = withRouteHandler( return validationErrorResponse(error) } - const errorMessage = toError(error).message - - if ( - errorMessage.includes('row limit') || - errorMessage.includes('Insufficient capacity') || - errorMessage.includes('Schema validation') || - errorMessage.includes('must be unique') || - errorMessage.includes('Row size exceeds') - ) { - return NextResponse.json({ error: errorMessage }, { status: 400 }) - } + const response = rowWriteErrorResponse(error) + if (response) return response logger.error(`[${requestId}] Error inserting row:`, error) return NextResponse.json({ error: 'Failed to insert row' }, { status: 500 }) @@ -231,12 +211,14 @@ export const GET = withRouteHandler( const workspaceId = searchParams.get('workspaceId') const filterParam = searchParams.get('filter') const sortParam = searchParams.get('sort') + const afterParam = searchParams.get('after') const limit = searchParams.get('limit') const offset = searchParams.get('offset') const includeTotalParam = searchParams.get('includeTotal') let filter: Record | undefined let sort: Sort | undefined + let after: TableRowsCursor | undefined try { if (filterParam) { @@ -245,14 +227,18 @@ export const GET = withRouteHandler( if (sortParam) { sort = JSON.parse(sortParam) as Sort } + if (afterParam) { + after = JSON.parse(afterParam) as TableRowsCursor + } } catch { - return NextResponse.json({ error: 'Invalid filter or sort JSON' }, { status: 400 }) + return NextResponse.json({ error: 'Invalid filter, sort, or after JSON' }, { status: 400 }) } const validated = tableRowsQuerySchema.parse({ workspaceId, filter, sort, + after, limit, offset, includeTotal: includeTotalParam, @@ -278,6 +264,7 @@ export const GET = withRouteHandler( sort: validated.sort ? wire.sortIn(validated.sort) : undefined, limit: validated.limit, offset: validated.offset, + after: validated.after, includeTotal: validated.includeTotal, }, requestId @@ -403,18 +390,8 @@ export const PUT = withRouteHandler( return NextResponse.json({ error: error.message }, { status: 400 }) } - const errorMessage = toError(error).message - - if ( - errorMessage.includes('Row size exceeds') || - errorMessage.includes('Schema validation') || - errorMessage.includes('must be unique') || - errorMessage.includes('Unique constraint violation') || - errorMessage.includes('Cannot set unique column') || - errorMessage.includes('Filter is required') - ) { - return NextResponse.json({ error: errorMessage }, { status: 400 }) - } + const response = rowWriteErrorResponse(error) + if (response) return response logger.error(`[${requestId}] Error updating rows by filter:`, error) return NextResponse.json({ error: 'Failed to update rows' }, { status: 500 }) @@ -506,11 +483,8 @@ export const DELETE = withRouteHandler( return NextResponse.json({ error: error.message }, { status: 400 }) } - const errorMessage = toError(error).message - - if (errorMessage.includes('Filter is required')) { - return NextResponse.json({ error: errorMessage }, { status: 400 }) - } + const response = rowWriteErrorResponse(error) + if (response) return response logger.error(`[${requestId}] Error deleting rows:`, error) return NextResponse.json({ error: 'Failed to delete rows' }, { status: 500 }) @@ -575,22 +549,8 @@ export const PATCH = withRouteHandler( return validationErrorResponse(error) } - const errorMessage = toError(error).message - - if ( - errorMessage.includes('Row size exceeds') || - errorMessage.includes('Schema validation') || - errorMessage.includes('must be valid') || - errorMessage.includes('must be string') || - errorMessage.includes('must be number') || - errorMessage.includes('must be boolean') || - errorMessage.includes('must be unique') || - errorMessage.includes('Unique constraint violation') || - errorMessage.includes('Cannot set unique column') || - errorMessage.includes('Rows not found') - ) { - return NextResponse.json({ error: errorMessage }, { status: 400 }) - } + const response = rowWriteErrorResponse(error) + if (response) return response logger.error(`[${requestId}] Error batch updating rows:`, error) return NextResponse.json({ error: 'Failed to update rows' }, { status: 500 }) diff --git a/apps/sim/app/api/table/[tableId]/rows/upsert/route.ts b/apps/sim/app/api/table/[tableId]/rows/upsert/route.ts index c8d9184e8c3..bc97623ef9a 100644 --- a/apps/sim/app/api/table/[tableId]/rows/upsert/route.ts +++ b/apps/sim/app/api/table/[tableId]/rows/upsert/route.ts @@ -1,5 +1,4 @@ import { createLogger } from '@sim/logger' -import { toError } from '@sim/utils/errors' import { type NextRequest, NextResponse } from 'next/server' import { upsertTableRowContract } from '@/lib/api/contracts/tables' import { parseRequest } from '@/lib/api/server' @@ -10,7 +9,7 @@ import { withRouteHandler } from '@/lib/core/utils/with-route-handler' import type { RowData, TableSchema } from '@/lib/table' import { upsertRow } from '@/lib/table' import { rowWireTranslators } from '@/app/api/table/row-wire' -import { accessError, checkAccess } from '@/app/api/table/utils' +import { accessError, checkAccess, rowWriteErrorResponse } from '@/app/api/table/utils' const logger = createLogger('TableUpsertAPI') @@ -80,19 +79,8 @@ export const POST = withRouteHandler(async (request: NextRequest, context: Upser return validationErrorResponse(error) } - const errorMessage = toError(error).message - - if ( - errorMessage.includes('unique column') || - errorMessage.includes('Unique constraint violation') || - errorMessage.includes('conflictTarget') || - errorMessage.includes('row limit') || - errorMessage.includes('Schema validation') || - errorMessage.includes('Upsert requires') || - errorMessage.includes('Row size exceeds') - ) { - return NextResponse.json({ error: errorMessage }, { status: 400 }) - } + const response = rowWriteErrorResponse(error) + if (response) return response logger.error(`[${requestId}] Error upserting row:`, error) return NextResponse.json({ error: 'Failed to upsert row' }, { status: 500 }) diff --git a/apps/sim/app/api/table/import-async/route.test.ts b/apps/sim/app/api/table/import-async/route.test.ts index 8ecdd2a923a..eaaf90597cc 100644 --- a/apps/sim/app/api/table/import-async/route.test.ts +++ b/apps/sim/app/api/table/import-async/route.test.ts @@ -84,7 +84,7 @@ describe('POST /api/table/import-async', () => { expect(response.status).toBe(200) expect(data.data).toEqual({ tableId: 'tbl_async', importId: 'import-id-123' }) expect(mockCreateTable).toHaveBeenCalledWith( - expect.objectContaining({ importStatus: 'importing', importId: 'import-id-123' }), + expect.objectContaining({ jobStatus: 'running', jobType: 'import', jobId: 'import-id-123' }), expect.any(String) ) expect(mockRunTableImport).toHaveBeenCalledWith( diff --git a/apps/sim/app/api/table/import-async/route.ts b/apps/sim/app/api/table/import-async/route.ts index 239268053e7..f10b822b6e3 100644 --- a/apps/sim/app/api/table/import-async/route.ts +++ b/apps/sim/app/api/table/import-async/route.ts @@ -4,19 +4,22 @@ import { type NextRequest, NextResponse } from 'next/server' import { importTableAsyncContract } from '@/lib/api/contracts/tables' import { parseRequest } from '@/lib/api/server' import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid' +import { isTriggerDevEnabled } from '@/lib/core/config/feature-flags' import { runDetached } from '@/lib/core/utils/background' import { generateRequestId } from '@/lib/core/utils/request' import { withRouteHandler } from '@/lib/core/utils/with-route-handler' import { captureServerEvent } from '@/lib/posthog/server' import { createTable, + deleteTable, getWorkspaceTableLimits, listTables, + releaseJobClaim, sanitizeName, TABLE_LIMITS, TableConflictError, } from '@/lib/table' -import { runTableImport } from '@/lib/table/import-runner' +import { runTableImport, type TableImportPayload } from '@/lib/table/import-runner' import { getUserEntityPermissions } from '@/lib/workspaces/permissions/utils' const logger = createLogger('TableImportAsync') @@ -83,8 +86,9 @@ export const POST = withRouteHandler(async (request: NextRequest) => { userId, maxRows: planLimits.maxRowsPerTable, maxTables: planLimits.maxTables, - importStatus: 'importing', - importId, + jobStatus: 'running', + jobType: 'import', + jobId: importId, }, requestId ) @@ -98,18 +102,38 @@ export const POST = withRouteHandler(async (request: NextRequest) => { throw error } - runDetached('table-import', () => - runTableImport({ - importId, - tableId: table.id, - workspaceId, - userId, - fileKey, - fileName, - delimiter, - mode: 'create', - }) - ) + const importPayload: TableImportPayload = { + importId, + tableId: table.id, + workspaceId, + userId, + fileKey, + fileName, + delimiter, + mode: 'create', + } + if (isTriggerDevEnabled) { + // Trigger.dev runs the import outside the web container, so it survives app deploys. + try { + const [{ tableImportTask }, { tasks }] = await Promise.all([ + import('@/background/table-import'), + import('@trigger.dev/sdk'), + ]) + await tasks.trigger('table-import', importPayload, { + tags: [`tableId:${table.id}`, `jobId:${importId}`], + }) + } catch (error) { + // A failed dispatch must not leave a ghost `running` job holding the + // table's one-write-job slot — nor, in create mode, the placeholder + // table itself: the user never saw it, so archive it back out of the + // workspace (no hard-delete surface exists; archived is invisible). + await releaseJobClaim(table.id, importId).catch(() => {}) + await deleteTable(table.id, requestId).catch(() => {}) + throw error + } + } else { + runDetached('table-import', () => runTableImport(importPayload)) + } captureServerEvent( userId, diff --git a/apps/sim/app/api/table/jobs/route.ts b/apps/sim/app/api/table/jobs/route.ts new file mode 100644 index 00000000000..912d769c39f --- /dev/null +++ b/apps/sim/app/api/table/jobs/route.ts @@ -0,0 +1,42 @@ +import { createLogger } from '@sim/logger' +import { type NextRequest, NextResponse } from 'next/server' +import { listTableJobsContract } from '@/lib/api/contracts/tables' +import { parseRequest } from '@/lib/api/server' +import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid' +import { generateRequestId } from '@/lib/core/utils/request' +import { withRouteHandler } from '@/lib/core/utils/with-route-handler' +import { listWorkspaceExportJobs } from '@/lib/table/service' +import { checkWorkspaceAccess } from '@/lib/workspaces/permissions/utils' + +const logger = createLogger('TableJobsAPI') + +export const runtime = 'nodejs' +export const dynamic = 'force-dynamic' + +/** + * GET /api/table/jobs?workspaceId=…&type=export + * + * Lists a workspace's export jobs (running + recently finished) for the header tray. Exports are + * excluded from the table-level job derivation, so the tray reads them here. + */ +export const GET = withRouteHandler(async (request: NextRequest) => { + const requestId = generateRequestId() + + const authResult = await checkSessionOrInternalAuth(request, { requireWorkflowId: false }) + if (!authResult.success || !authResult.userId) { + return NextResponse.json({ error: 'Authentication required' }, { status: 401 }) + } + + const parsed = await parseRequest(listTableJobsContract, request, {}) + if (!parsed.success) return parsed.response + const { workspaceId } = parsed.data.query + + const { hasAccess } = await checkWorkspaceAccess(workspaceId, authResult.userId) + if (!hasAccess) { + return NextResponse.json({ error: 'Access denied' }, { status: 403 }) + } + + const jobs = await listWorkspaceExportJobs(workspaceId) + logger.info(`[${requestId}] Listed ${jobs.length} export jobs`, { workspaceId }) + return NextResponse.json({ success: true, data: { jobs } }) +}) diff --git a/apps/sim/app/api/table/route.ts b/apps/sim/app/api/table/route.ts index ed41a7813d6..94aa8c45b4c 100644 --- a/apps/sim/app/api/table/route.ts +++ b/apps/sim/app/api/table/route.ts @@ -217,10 +217,11 @@ export const GET = withRouteHandler(async (request: NextRequest) => { : t.archivedAt ? String(t.archivedAt) : null, - importStatus: t.importStatus ?? null, - importId: t.importId ?? null, - importError: t.importError ?? null, - importRowsProcessed: t.importRowsProcessed ?? 0, + jobStatus: t.jobStatus ?? null, + jobId: t.jobId ?? null, + jobType: t.jobType ?? null, + jobError: t.jobError ?? null, + jobRowsProcessed: t.jobRowsProcessed ?? 0, } }) diff --git a/apps/sim/app/api/table/utils.test.ts b/apps/sim/app/api/table/utils.test.ts new file mode 100644 index 00000000000..df1a05e7c73 --- /dev/null +++ b/apps/sim/app/api/table/utils.test.ts @@ -0,0 +1,55 @@ +/** + * @vitest-environment node + */ +import { describe, expect, it } from 'vitest' +import { rootErrorMessage, rowWriteErrorResponse } from '@/app/api/table/utils' + +/** Mimics drizzle's DrizzleQueryError: message is the failed SQL, real error on `cause`. */ +function wrapLikeDrizzle(cause: Error): Error { + return new Error('Failed query: insert into "user_table_rows" ...', { cause }) +} + +describe('rootErrorMessage', () => { + it('returns the message of a plain error', () => { + expect(rootErrorMessage(new Error('Schema validation failed: bad'))).toBe( + 'Schema validation failed: bad' + ) + }) + + it('unwraps the cause chain to the deepest error', () => { + const root = new Error('Maximum row limit (10000) reached for table tbl_abc') + expect(rootErrorMessage(wrapLikeDrizzle(root))).toBe(root.message) + }) + + it('stringifies non-Error values', () => { + expect(rootErrorMessage('boom')).toBe('boom') + }) +}) + +describe('rowWriteErrorResponse', () => { + it('rewrites the DB row-limit trigger error into a friendly 400', async () => { + const error = wrapLikeDrizzle( + new Error('Maximum row limit (10000) reached for table tbl_2b15ec29647040e7b8eb5d2949f556cf') + ) + const response = rowWriteErrorResponse(error) + expect(response?.status).toBe(400) + const body = await response?.json() + expect(body.error).toBe('Row limit exceeded — this table is capped at 10,000 rows') + }) + + it('passes known validation messages through as 400', async () => { + const response = rowWriteErrorResponse(new Error('Value for column "email" must be unique')) + expect(response?.status).toBe(400) + const body = await response?.json() + expect(body.error).toBe('Value for column "email" must be unique') + }) + + it('matches per-row batch validation messages', () => { + expect(rowWriteErrorResponse(new Error('Row 3: name is required'))?.status).toBe(400) + }) + + it('returns null for unknown errors so callers keep their generic 500', () => { + expect(rowWriteErrorResponse(new Error('connection refused'))).toBeNull() + expect(rowWriteErrorResponse(wrapLikeDrizzle(new Error('deadlock detected')))).toBeNull() + }) +}) diff --git a/apps/sim/app/api/table/utils.ts b/apps/sim/app/api/table/utils.ts index 41a66e85bb3..c8dde913132 100644 --- a/apps/sim/app/api/table/utils.ts +++ b/apps/sim/app/api/table/utils.ts @@ -1,4 +1,5 @@ import { createLogger } from '@sim/logger' +import { toError } from '@sim/utils/errors' import { NextResponse } from 'next/server' import { createTableColumnBodySchema, @@ -6,12 +7,97 @@ import { updateTableColumnBodySchema, } from '@/lib/api/contracts/tables' import type { MultipartError } from '@/lib/core/utils/multipart' -import type { ColumnDefinition, TableDefinition } from '@/lib/table' -import { getTableById } from '@/lib/table' +import type { ColumnDefinition, Filter, TableDefinition } from '@/lib/table' +import { buildFilterClause, getTableById, TableQueryValidationError } from '@/lib/table' +import { USER_TABLE_ROWS_SQL_NAME } from '@/lib/table/constants' import { getUserEntityPermissions } from '@/lib/workspaces/permissions/utils' +/** + * Validates a `filter` against the table's column schema, returning a 400 response on a bad field + * (or `null` when the filter is valid or absent). Shared by the routes that accept a filter + * (`delete-async`, `columns/run`) so a bad field fails fast with a clear message. + */ +export function tableFilterError( + filter: Filter | undefined, + columns: ColumnDefinition[] +): NextResponse | null { + if (!filter) return null + try { + buildFilterClause(filter, USER_TABLE_ROWS_SQL_NAME, columns) + return null + } catch (error) { + if (error instanceof TableQueryValidationError) { + return NextResponse.json({ error: error.message }, { status: 400 }) + } + throw error + } +} + const logger = createLogger('TableUtils') +/** + * Deepest `Error` message in the cause chain. Drizzle wraps DB errors (e.g. the + * row-limit trigger's RAISE) in a `DrizzleQueryError` whose own message is just + * the failed SQL — substring classification must look at the root cause. + */ +export function rootErrorMessage(error: unknown): string { + let current: unknown = error + while (current instanceof Error && current.cause instanceof Error) { + current = current.cause + } + return toError(current).message +} + +/** + * Known user-facing row-write failures (service validation + the DB row-limit + * trigger). Anything outside this list stays a generic 500 — unknown errors can + * carry SQL/internals that don't belong in a toast. + */ +const ROW_WRITE_ERROR_PATTERNS = [ + 'row limit', + 'Insufficient capacity', + 'Schema validation', + 'must be unique', + 'must be valid', + 'must be string', + 'must be number', + 'must be boolean', + 'unique column', + 'Unique constraint violation', + 'Row size exceeds', + 'conflictTarget', + 'Upsert requires', + 'Rows not found', + 'Filter is required', +] as const + +/** + * Maps a known user-facing row-write failure to a 400 carrying the real message + * (so client toasts can show the actual reason); `null` when the error is + * unrecognized and the caller should log it and return its generic 500. + */ +export function rowWriteErrorResponse(error: unknown): NextResponse | null { + const message = rootErrorMessage(error) + + // Trigger message reads `Maximum row limit (N) reached for table tbl_...` — + // rewrite it for the toast instead of leaking the internal table id. + const limitMatch = message.match(/Maximum row limit \((\d+)\) reached/) + if (limitMatch) { + return NextResponse.json( + { + error: `Row limit exceeded — this table is capped at ${Number(limitMatch[1]).toLocaleString('en-US')} rows`, + }, + { status: 400 } + ) + } + + if (ROW_WRITE_ERROR_PATTERNS.some((p) => message.includes(p)) || /^Row .+?:/.test(message)) { + return NextResponse.json({ error: message }, { status: 400 }) + } + + return null +} + /** * Next.js buffers the request body for the proxy and silently truncates it past this * size (`experimental.proxyClientMaxBodySize`, default 10MB). The synchronous CSV diff --git a/apps/sim/app/api/v1/tables/[tableId]/rows/route.ts b/apps/sim/app/api/v1/tables/[tableId]/rows/route.ts index ecceb41b1e2..bce536fc9fb 100644 --- a/apps/sim/app/api/v1/tables/[tableId]/rows/route.ts +++ b/apps/sim/app/api/v1/tables/[tableId]/rows/route.ts @@ -1,5 +1,4 @@ import { createLogger } from '@sim/logger' -import { toError } from '@sim/utils/errors' import { type NextRequest, NextResponse } from 'next/server' import { type V1BatchInsertTableRowsBody, @@ -34,7 +33,7 @@ import { } from '@/lib/table' import { queryRows } from '@/lib/table/service' import { TableQueryValidationError } from '@/lib/table/sql' -import { accessError, checkAccess } from '@/app/api/table/utils' +import { accessError, checkAccess, rowWriteErrorResponse } from '@/app/api/table/utils' import { checkRateLimit, checkWorkspaceScope, @@ -104,18 +103,8 @@ async function handleBatchInsert( }, }) } catch (error) { - const errorMessage = toError(error).message - - if ( - errorMessage.includes('row limit') || - errorMessage.includes('Insufficient capacity') || - errorMessage.includes('Schema validation') || - errorMessage.includes('must be unique') || - errorMessage.includes('Row size exceeds') || - errorMessage.match(/^Row \d+:/) - ) { - return NextResponse.json({ error: errorMessage }, { status: 400 }) - } + const response = rowWriteErrorResponse(error) + if (response) return response logger.error(`[${requestId}] Error batch inserting rows:`, error) return NextResponse.json({ error: 'Failed to insert rows' }, { status: 500 }) @@ -287,17 +276,8 @@ export const POST = withRouteHandler( const validationResponse = validationErrorResponseFromError(error) if (validationResponse) return validationResponse - const errorMessage = toError(error).message - - if ( - errorMessage.includes('row limit') || - errorMessage.includes('Insufficient capacity') || - errorMessage.includes('Schema validation') || - errorMessage.includes('must be unique') || - errorMessage.includes('Row size exceeds') - ) { - return NextResponse.json({ error: errorMessage }, { status: 400 }) - } + const response = rowWriteErrorResponse(error) + if (response) return response logger.error(`[${requestId}] Error inserting row:`, error) return NextResponse.json({ error: 'Failed to insert row' }, { status: 500 }) @@ -381,18 +361,8 @@ export const PUT = withRouteHandler(async (request: NextRequest, context: TableR return NextResponse.json({ error: error.message }, { status: 400 }) } - const errorMessage = toError(error).message - - if ( - errorMessage.includes('Row size exceeds') || - errorMessage.includes('Schema validation') || - errorMessage.includes('must be unique') || - errorMessage.includes('Unique constraint violation') || - errorMessage.includes('Cannot set unique column') || - errorMessage.includes('Filter is required') - ) { - return NextResponse.json({ error: errorMessage }, { status: 400 }) - } + const response = rowWriteErrorResponse(error) + if (response) return response logger.error(`[${requestId}] Error updating rows by filter:`, error) return NextResponse.json({ error: 'Failed to update rows' }, { status: 500 }) @@ -478,11 +448,8 @@ export const DELETE = withRouteHandler( return NextResponse.json({ error: error.message }, { status: 400 }) } - const errorMessage = toError(error).message - - if (errorMessage.includes('Filter is required')) { - return NextResponse.json({ error: errorMessage }, { status: 400 }) - } + const response = rowWriteErrorResponse(error) + if (response) return response logger.error(`[${requestId}] Error deleting rows:`, error) return NextResponse.json({ error: 'Failed to delete rows' }, { status: 500 }) diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/context-menu/context-menu.tsx b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/context-menu/context-menu.tsx index c6c069d6389..de00999f35d 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/context-menu/context-menu.tsx +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/context-menu/context-menu.tsx @@ -73,20 +73,21 @@ export function ContextMenu({ disableInsert = false, disableDelete = false, }: ContextMenuProps) { - const deleteLabel = selectedRowCount > 1 ? `Delete ${selectedRowCount} rows` : 'Delete row' + const count = selectedRowCount.toLocaleString() + const deleteLabel = selectedRowCount > 1 ? `Delete ${count} rows` : 'Delete row' const runLabel = workflowCellScoped ? selectedRowCount > 1 - ? `Run cell on ${selectedRowCount} rows` + ? `Run cell on ${count} rows` : 'Run cell' : selectedRowCount > 1 - ? `Run empty or failed cells on ${selectedRowCount} rows` + ? `Run empty or failed cells on ${count} rows` : 'Run empty or failed cells' const refreshLabel = workflowCellScoped ? selectedRowCount > 1 - ? `Re-run cell on ${selectedRowCount} rows` + ? `Re-run cell on ${count} rows` : 'Re-run cell' : selectedRowCount > 1 - ? `Re-run all cells on ${selectedRowCount} rows` + ? `Re-run all cells on ${count} rows` : 'Re-run all cells' const stopLabel = runningInSelectionCount === 1 diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/table-grid.tsx b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/table-grid.tsx index c95c2e66090..87786d07984 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/table-grid.tsx +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/table-grid.tsx @@ -11,7 +11,7 @@ import { Loader, TableX } from '@/components/emcn/icons' import type { RunLimit, RunMode, TableFindMatch } from '@/lib/api/contracts/tables' import { cn } from '@/lib/core/utils/cn' import { captureEvent } from '@/lib/posthog/client' -import type { ColumnDefinition, TableRow as TableRowType, WorkflowGroup } from '@/lib/table' +import type { ColumnDefinition, Filter, TableRow as TableRowType, WorkflowGroup } from '@/lib/table' import { getColumnId } from '@/lib/table/column-keys' import { TABLE_LIMITS } from '@/lib/table/constants' import { useUserPermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider' @@ -97,8 +97,19 @@ export interface SelectionSnapshot { /** Whether the table has any workflow-output columns (drives the Run/Stop visibility). */ hasWorkflowColumns: boolean /** Cells the Play / Refresh / Stop buttons act on. Null when the selection - * contains no workflow output cells. */ - selectedRunScope: { groupIds: string[]; rowIds: string[]; allRows: boolean } | null + * contains no workflow output cells. `rowCount` is the true selected-row total for the + * action-bar label — equal to `rowIds.length` except under select-all, where `rowIds` holds + * only the loaded (virtualized) window but `rowCount` is the table's full row count. */ + selectedRunScope: { + groupIds: string[] + rowIds: string[] + allRows: boolean + rowCount: number + /** Active filter when `allRows` is set — lets a filtered "select all" run only matching rows. */ + filter?: Filter + /** Deselected rows when `allRows` is set — runs/stops skip them. */ + excludeRowIds?: string[] + } | null /** Drives Play (`hasIncompleteOrFailed`) / Refresh (`hasCompleted`) / * Stop (`hasInFlight`) visibility on the action bar. */ selectionStats: ExecStatusMix @@ -146,16 +157,38 @@ interface TableGridProps { onOpenRowModal: (row: TableRowType) => void /** Open the row-delete modal for `snapshots`. Wrapper renders the modal. */ onRequestDeleteRows: (snapshots: DeletedRowSnapshot[]) => void + /** + * Request a background "select all" delete: the active filter (held by the wrapper) plus the + * deselected `excludeRowIds`. The wrapper confirms and kicks off the async delete job. + */ + onRequestDeleteAllByFilter: (params: { excludeRowIds: string[]; estimatedCount: number }) => void /** Open the delete-columns confirmation modal for `names`. Wrapper renders the modal. */ onRequestDeleteColumns: (names: string[]) => void - /** Fire run for a single column (meta-cell Run menu). */ - onRunColumn: (groupId: string, runMode: RunMode, rowIds?: string[], limit?: RunLimit) => void + /** Fire run for a single column (meta-cell Run menu). `filter` (mutually + * exclusive with `rowIds`) scopes a select-all run to the active filter. */ + onRunColumn: ( + groupId: string, + runMode: RunMode, + rowIds?: string[], + limit?: RunLimit, + filter?: Filter, + excludeRowIds?: string[] + ) => void /** Fire every runnable column on a single row (per-row gutter Play). */ onRunRow: (rowId: string) => void - /** Fan out a run across every workflow group on `rowIds`. Used by context menu. */ - onRunRows: (rowIds: string[], runMode: RunMode) => void + /** Fan out a run across every workflow group on `rowIds` — or, with `rowIds` + * undefined, across the whole table / the active filter. Used by context menu. */ + onRunRows: ( + rowIds: string[] | undefined, + runMode: RunMode, + filter?: Filter, + excludeRowIds?: string[] + ) => void /** Stop running workflows on `rowIds`. Per-row gutter Stop also funnels through here. */ onStopRows: (rowIds: string[]) => void + /** Select-all Stop: table-wide, or scoped to the active filter when one is set. + * `excludeRowIds` (deselected rows) keep running. */ + onStopAllRows: (filter?: Filter, excludeRowIds?: string[]) => void /** Single-row stop for the per-row gutter button. */ onStopRow: (rowId: string) => void /** @@ -177,6 +210,12 @@ interface TableGridProps { * mutation succeeds. */ afterDeleteRowsSinkRef: React.MutableRefObject<((snapshots: DeletedRowSnapshot[]) => void) | null> + /** + * Ref the grid populates with its post-select-all-delete cleanup (clear selection). The wrapper + * invokes it after the async delete job is kicked off. No undo — the deleted set isn't + * materialized client-side. + */ + afterDeleteAllSinkRef: React.MutableRefObject<(() => void) | null> /** * Ref the grid populates with its full delete-columns cascade (per-column * mutation, undo push, columnOrder + columnWidths cleanup). The wrapper's @@ -246,16 +285,19 @@ export function TableGrid({ onOpenExecutionDetails, onOpenRowModal, onRequestDeleteRows, + onRequestDeleteAllByFilter, onRequestDeleteColumns, onRunColumn, onRunRow, onRunRows, onStopRows, + onStopAllRows, onStopRow, onSelectionChange, queryOptions, columnRenameSinkRef, afterDeleteRowsSinkRef, + afterDeleteAllSinkRef, confirmDeleteColumnsSinkRef, pushTableRenameUndoSinkRef, }: TableGridProps) { @@ -331,6 +373,7 @@ export function TableGrid({ tableData, isLoadingTable, rows, + rowTotal, isLoadingRows, fetchNextPage, hasNextPage, @@ -356,8 +399,10 @@ export function TableGrid({ const totalRunning = Object.values(runningByRowId).reduce((sum, n) => sum + n, 0) const hasActiveDispatch = (activeDispatches?.length ?? 0) > 0 - const tableRowCountRef = useRef(tableData?.rowCount ?? 0) - tableRowCountRef.current = tableData?.rowCount ?? 0 + // True "select all" total: the filter-scoped COUNT(*) when a filter is active, else the whole + // table. Drives the delete-confirm count and the action-bar cell count. + const selectAllTotalRef = useRef(0) + selectAllTotalRef.current = rowTotal ?? tableData?.rowCount ?? 0 const fetchNextPageRef = useRef(fetchNextPage) fetchNextPageRef.current = fetchNextPage @@ -704,11 +749,16 @@ export function TableGrid({ // Header select-all: filled check when all rows are selected, filled minus when // some are, empty when none. Any non-empty selection turns it into a "clear" affordance. - const selectAllState: boolean | 'indeterminate' = isAllRowsSelected - ? true - : rowSelectionIsEmpty(rowSelection) + // An empty grid renders unchecked regardless — a selection over zero rows is vacuous + // (e.g. the optimistic strip right after a select-all delete kicks off). + const selectAllState: boolean | 'indeterminate' = + rows.length === 0 ? false - : 'indeterminate' + : isAllRowsSelected + ? true + : rowSelectionIsEmpty(rowSelection) + ? false + : 'indeterminate' const columnsRef = useRef(displayColumns) const schemaColumnsRef = useRef(columns) @@ -893,19 +943,14 @@ export function TableGrid({ const contextRowInRows = currentRows.some((r) => r.id === contextRow.id) - // Select-all delete covers every row matching the active filter, which may - // not all be loaded — drain pages first so the (chunked) delete spans the - // full set rather than only the loaded window. + // Select-all delete covers every row matching the active filter — including rows not loaded by + // the virtualized grid. Send the filter + exclusion set to a background job instead of draining + // and materializing every id; the wrapper confirms and kicks it off. if (rowSel.kind === 'all' && contextRowInRows) { closeContextMenu() - void (async () => { - const allRows = await ensureAllRowsLoadedRef.current() - const snapshots = collectRowSnapshots(allRows) - if (snapshots.length > 0) onRequestDeleteRows(snapshots) - })().catch((error) => { - logger.error('Failed to load rows for delete', { error }) - toast.error('Failed to delete rows — please try again') - }) + const excludeRowIds = rowSel.excluded ? [...rowSel.excluded] : [] + const estimatedCount = Math.max(0, selectAllTotalRef.current - excludeRowIds.length) + onRequestDeleteAllByFilter({ excludeRowIds, estimatedCount }) return } @@ -1138,6 +1183,15 @@ export function TableGrid({ : -1 setRowSelection((prev) => { + // Deselecting a single row out of a select-all keeps the "all matching the filter" semantics + // by tracking an exclusion set — collapsing to the loaded ids would silently drop every + // unloaded matching row from the selection (and from a subsequent delete). + if (prev.kind === 'all' && lastIdx === -1) { + const excluded = new Set(prev.excluded ?? []) + if (excluded.has(targetId)) excluded.delete(targetId) + else excluded.add(targetId) + return { kind: 'all', excluded: excluded.size === 0 ? undefined : excluded } + } const next = rowSelectionMaterialize(prev, currentRows) if (lastIdx !== -1) { const from = Math.min(lastIdx, rowIndex) @@ -1210,6 +1264,12 @@ export function TableGrid({ handleClearSelection() } + // Select-all delete runs as a background job (no client-side snapshots), so the only cleanup is + // clearing the now-stale selection once the wrapper has kicked it off. + afterDeleteAllSinkRef.current = () => { + handleClearSelection() + } + // Populate the wrapper's table-rename undo sink. The wrapper's // breadcrumb rename calls back here so the rename is part of the grid's undo // stack (Cmd-Z restores the previous name). @@ -2467,7 +2527,7 @@ export function TableGrid({ selectRow: (row) => rowSelectionIncludes(rowSel, row.id), buildCells: (row) => cols.map((col) => cellToText(row.data[col.key])), verb: 'Copied', - estimatedCount: rowSel.kind === 'some' ? rowSel.ids.size : tableRowCountRef.current, + estimatedCount: rowSel.kind === 'some' ? rowSel.ids.size : selectAllTotalRef.current, }) return } @@ -2491,7 +2551,7 @@ export function TableGrid({ selectRow: () => true, buildCells: (row) => colNames.map((name) => cellToText(row.data[name])), verb: 'Copied', - estimatedCount: tableRowCountRef.current, + estimatedCount: selectAllTotalRef.current, }) return } @@ -2529,7 +2589,7 @@ export function TableGrid({ selectRow: (row) => rowSelectionIncludes(rowSel, row.id), buildCells: (row) => cols.map((col) => cellToText(row.data[col.key])), verb: 'Cut', - estimatedCount: rowSel.kind === 'some' ? rowSel.ids.size : tableRowCountRef.current, + estimatedCount: rowSel.kind === 'some' ? rowSel.ids.size : selectAllTotalRef.current, afterCopy: (copied) => clearCutRows( copied, @@ -2558,7 +2618,7 @@ export function TableGrid({ selectRow: () => true, buildCells: (row) => colNames.map((name) => cellToText(row.data[name])), verb: 'Cut', - estimatedCount: tableRowCountRef.current, + estimatedCount: selectAllTotalRef.current, afterCopy: (copied) => clearCutRows(copied, colNames), }) return @@ -2731,18 +2791,15 @@ export function TableGrid({ const currentCols = columnsRef.current if (rws.length > 0 && currentCols.length > 0) { e.preventDefault() - suppressFocusScrollRef.current = true - setEditingCell(null) - setRowSelection((prev) => (prev.kind === 'none' ? prev : ROW_SELECTION_NONE)) - lastCheckboxRowRef.current = null - setSelectionAnchor({ rowIndex: 0, colIndex: 0 }) - setSelectionFocus({ rowIndex: rws.length - 1, colIndex: currentCols.length - 1 }) - setIsColumnSelection(false) + // Cmd/Ctrl+A toggles the whole-table row selection (same as the gutter checkbox), so it + // reflects the true row count and feeds the filter-based delete — not a loaded-window cell + // rectangle. Pressing again clears. + handleSelectAllToggle() } } document.addEventListener('keydown', handleSelectAll) return () => document.removeEventListener('keydown', handleSelectAll) - }, [embedded]) + }, [embedded, handleSelectAllToggle]) /** Override the browser's Cmd/Ctrl+F with the in-table find while mounted. */ useEffect(() => { @@ -3162,7 +3219,26 @@ export function TableGrid({ return [contextMenu.row.id] }, [contextMenu.isOpen, contextMenu.row, rowSelection, normalizedSelection, rows]) - const selectedRowCount = contextMenuRowIds.length || 1 + /** + * Select-all detection for the context-menu bulk actions: delete, run, + * refresh, and stop all act on EVERY row in the (filtered) selection — not + * just the loaded page `contextMenuRowIds` reflects — via the filter-scoped + * delete job / dispatch / cancel paths. + */ + const contextMenuIsSelectAll = Boolean( + contextMenu.isOpen && + contextMenu.row && + rowSelection.kind === 'all' && + rowSelectionIncludes(rowSelection, contextMenu.row.id) + ) + + const selectedRowCount = contextMenuIsSelectAll + ? Math.max( + 1, + selectAllTotalRef.current - + (rowSelection.kind === 'all' ? (rowSelection.excluded?.size ?? 0) : 0) + ) + : contextMenuRowIds.length || 1 const pendingUpdate = updateRowMutation.isPending ? updateRowMutation.variables : null @@ -3192,18 +3268,37 @@ export function TableGrid({ // opened on a workflow-output cell, scope to just that cell's group — the // server cascade re-runs dependent groups whose deps it fills. Right-clicking // a plain cell has no group, so fall back to every group on the row(s). - const handleRunWorkflowsOnSelection = () => { - if (contextMenuGroupId) onRunColumn(contextMenuGroupId, 'incomplete', contextMenuRowIds) - else onRunRows(contextMenuRowIds, 'incomplete') - closeContextMenu() - } - const handleRefreshWorkflowsOnSelection = () => { - if (contextMenuGroupId) onRunColumn(contextMenuGroupId, 'all', contextMenuRowIds) - else onRunRows(contextMenuRowIds, 'all') + /** Select-all runs dispatch by filter scope (whole table when unfiltered), + * mirroring the action bar's Play/Refresh; deselected rows are excluded. */ + const runSelection = (runMode: RunMode) => { + if (contextMenuIsSelectAll) { + const filter = queryOptions.filter ?? undefined + const excluded = + rowSelection.kind === 'all' && rowSelection.excluded + ? [...rowSelection.excluded] + : undefined + if (contextMenuGroupId) + onRunColumn(contextMenuGroupId, runMode, undefined, undefined, filter, excluded) + else onRunRows(undefined, runMode, filter, excluded) + } else if (contextMenuGroupId) { + onRunColumn(contextMenuGroupId, runMode, contextMenuRowIds) + } else { + onRunRows(contextMenuRowIds, runMode) + } closeContextMenu() } + const handleRunWorkflowsOnSelection = () => runSelection('incomplete') + const handleRefreshWorkflowsOnSelection = () => runSelection('all') const handleStopWorkflowsOnSelection = () => { - onStopRows(contextMenuRowIds) + if (contextMenuIsSelectAll) { + const excluded = + rowSelection.kind === 'all' && rowSelection.excluded + ? [...rowSelection.excluded] + : undefined + onStopAllRows(queryOptions.filter ?? undefined, excluded) + } else { + onStopRows(contextMenuRowIds) + } closeContextMenu() } @@ -3318,11 +3413,22 @@ export function TableGrid({ if (tableWorkflowGroupIds.length === 0) return null if (!rowSelectionIsEmpty(rowSelection)) { if (rowSelection.kind === 'all') { - return { groupIds: tableWorkflowGroupIds, rowIds: rows.map((r) => r.id), allRows: true } + // `rowIds` is the loaded window (virtualized); the label total comes from the filter-scoped + // row count minus any deselected rows. `filter` lets the run target the matching rows + // server-side (the dispatcher walks them) rather than the loaded window. + const excluded = rowSelection.excluded?.size ?? 0 + return { + groupIds: tableWorkflowGroupIds, + rowIds: rows.map((r) => r.id), + allRows: true, + rowCount: Math.max(0, selectAllTotalRef.current - excluded), + filter: queryOptions.filter ?? undefined, + excludeRowIds: rowSelection.excluded ? [...rowSelection.excluded] : undefined, + } } const rowIds = rows.filter((r) => rowSelectionIncludes(rowSelection, r.id)).map((r) => r.id) if (rowIds.length === 0) return null - return { groupIds: tableWorkflowGroupIds, rowIds, allRows: false } + return { groupIds: tableWorkflowGroupIds, rowIds, allRows: false, rowCount: rowIds.length } } const sel = normalizedSelection if (!sel) return null @@ -3340,7 +3446,7 @@ export function TableGrid({ if (row) rowIds.push(row.id) } if (rowIds.length === 0) return null - return { groupIds: [...groupIdsInRect], rowIds, allRows: false } + return { groupIds: [...groupIdsInRect], rowIds, allRows: false, rowCount: rowIds.length } }, [rowSelection, normalizedSelection, rows, displayColumns, tableWorkflowGroupIds]) const selectionStats = useMemo(() => { diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/utils.ts b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/utils.ts index 7b263d4e1cf..39de6fb07dd 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/utils.ts +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/utils.ts @@ -11,13 +11,21 @@ import { areGroupDepsSatisfied, areOutputsFilled } from '@/lib/table/deps' import type { DeletedRowSnapshot } from '@/stores/table/types' import type { DisplayColumn } from './types' -export type RowSelection = { kind: 'none' } | { kind: 'some'; ids: Set } | { kind: 'all' } +/** + * `all` means "every row matching the active filter" — including rows not yet loaded by the + * virtualized grid. `excluded` holds rows deselected after a select-all, so the pair maps directly + * onto the async delete job's `{ filter, excludeRowIds }`. + */ +export type RowSelection = + | { kind: 'none' } + | { kind: 'some'; ids: Set } + | { kind: 'all'; excluded?: Set } export const ROW_SELECTION_NONE: RowSelection = { kind: 'none' } export const ROW_SELECTION_ALL: RowSelection = { kind: 'all' } export function rowSelectionIncludes(sel: RowSelection, id: string): boolean { - if (sel.kind === 'all') return true + if (sel.kind === 'all') return !sel.excluded?.has(id) if (sel.kind === 'some') return sel.ids.has(id) return false } @@ -29,14 +37,15 @@ export function rowSelectionIsEmpty(sel: RowSelection): boolean { } export function rowSelectionMaterialize(sel: RowSelection, rows: TableRowType[]): Set { - if (sel.kind === 'all') return new Set(rows.map((r) => r.id)) + if (sel.kind === 'all') + return new Set(rows.filter((r) => !sel.excluded?.has(r.id)).map((r) => r.id)) if (sel.kind === 'some') return new Set(sel.ids) return new Set() } export function rowSelectionCoversAll(sel: RowSelection, rows: TableRowType[]): boolean { if (rows.length === 0) return false - if (sel.kind === 'all') return true + if (sel.kind === 'all') return !rows.some((r) => sel.excluded?.has(r.id)) if (sel.kind === 'none') return false if (sel.ids.size < rows.length) return false for (const r of rows) if (!sel.ids.has(r.id)) return false diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/hooks/use-table-event-stream.ts b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/hooks/use-table-event-stream.ts index 29cfbfd9478..34789dff546 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/hooks/use-table-event-stream.ts +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/hooks/use-table-event-stream.ts @@ -3,11 +3,18 @@ import { useEffect, useRef } from 'react' import { createLogger } from '@sim/logger' import { useQueryClient } from '@tanstack/react-query' +import { toast } from '@/components/emcn' import type { ActiveDispatch } from '@/lib/api/contracts/tables' import type { RowData, RowExecutionMetadata, RowExecutions, TableDefinition } from '@/lib/table' import { isExecInFlight } from '@/lib/table/deps' import type { TableEvent, TableEventEntry } from '@/lib/table/events' -import { snapshotAndMutateRows, type TableRunState, tableKeys } from '@/hooks/queries/tables' +import { + consumeInitiatedExport, + downloadExportResult, + snapshotAndMutateRows, + type TableRunState, + tableKeys, +} from '@/hooks/queries/tables' const logger = createLogger('useTableEventStream') @@ -94,11 +101,11 @@ export function useTableEventStream({ // Live-fill: import progress ticks arrive every N rows; coalesce the row // refetches into one per debounce window instead of refetching per tick. - let importInvalidateTimer: ReturnType | null = null + let jobInvalidateTimer: ReturnType | null = null const scheduleRowsInvalidate = (): void => { - if (importInvalidateTimer !== null) clearTimeout(importInvalidateTimer) - importInvalidateTimer = setTimeout(() => { - importInvalidateTimer = null + if (jobInvalidateTimer !== null) clearTimeout(jobInvalidateTimer) + jobInvalidateTimer = setTimeout(() => { + jobInvalidateTimer = null void queryClient.invalidateQueries({ queryKey: tableKeys.rowsRoot(tableId) }) }, DISPATCH_INVALIDATE_DEBOUNCE_MS) } @@ -224,37 +231,60 @@ export function useTableEventStream({ scheduleDispatchInvalidate() } - const applyImport = (event: Extract): void => { - const { status, progress, error, importId } = event + const applyJob = (event: Extract): void => { + const { type, status, progress, error, jobId } = event const isTerminal = status === 'ready' || status === 'failed' || status === 'canceled' - // The SSE buffer replays on (re)connect and can hold a *prior* import's events for this - // table. Ignore anything from a superseded run, and don't trust a replayed terminal before - // we know the active run's id. + // Exports run concurrently with other jobs and never touch the detail-cache job fields + // (those derive from the latest *non-export* job). Their only client effect: download the + // file when an export this session kicked off completes. The initiated-set guard is what + // keeps replayed `ready` events (SSE re-delivers up to 1h on reconnect) from re-downloading. + if (type === 'export') { + // Keep the tray's export list fresh between its polls. + void queryClient.invalidateQueries({ queryKey: tableKeys.exportJobs(workspaceId) }) + if (status === 'ready' && jobId && consumeInitiatedExport(jobId)) { + void downloadExportResult(workspaceId, tableId, jobId) + .then(() => toast.success('Export ready — downloading')) + .catch((err) => { + logger.error('Export download failed', { tableId, jobId, err }) + toast.error('Export finished but the download failed — try again from the table menu') + }) + } else if (status === 'failed' && jobId && consumeInitiatedExport(jobId)) { + toast.error(error || 'Export failed') + } + return + } + + // The SSE buffer replays on (re)connect and can hold a *prior* job's events for this table. + // Ignore anything from a superseded run, and don't trust a replayed terminal before we know + // the active run's id. const prev = queryClient.getQueryData(tableKeys.detail(tableId)) - const lockedId = prev?.importId - if (lockedId && importId && importId !== lockedId) return + const lockedId = prev?.jobId + if (lockedId && jobId && jobId !== lockedId) return if (!lockedId && isTerminal) return queryClient.setQueryData(tableKeys.detail(tableId), (p) => p ? { ...p, - importStatus: status, - importId: importId ?? p.importId, - importRowsProcessed: progress ?? p.importRowsProcessed, - importError: error ?? null, + jobStatus: status, + jobId: jobId ?? p.jobId, + jobType: type, + jobRowsProcessed: progress ?? p.jobRowsProcessed, + jobError: error ?? null, } : p ) - // The header tray + completion toast are owned by `useImportTrayPoll`. Here we only keep the - // detail cache + grid in sync: live-fill rows per batch (debounced), and on the terminal - // event refetch rows + the definition (the worker may have rewritten the schema). + // The header tray + completion toast are owned by the tray poll. Here we keep the detail + // cache + grid in sync. On terminal, refetch rows + the definition (import may have rewritten + // the schema; delete failure/cancel restores optimistically-hidden rows). While running, + // imports and backfills live-fill rows per batch; a delete has already optimistically removed + // its rows, so we don't refetch mid-run (that would flicker not-yet-deleted rows back in). if (isTerminal) { - if (importInvalidateTimer !== null) clearTimeout(importInvalidateTimer) + if (jobInvalidateTimer !== null) clearTimeout(jobInvalidateTimer) void queryClient.invalidateQueries({ queryKey: tableKeys.rowsRoot(tableId) }) void queryClient.invalidateQueries({ queryKey: tableKeys.detail(tableId) }) - } else { + } else if (type === 'import' || type === 'backfill') { scheduleRowsInvalidate() } } @@ -329,7 +359,7 @@ export function useTableEventStream({ savePointer(tableId, lastEventId) if (entry.event?.kind === 'cell') applyCell(entry.event) else if (entry.event?.kind === 'dispatch') applyDispatch(entry.event) - else if (entry.event?.kind === 'import') applyImport(entry.event) + else if (entry.event?.kind === 'job') applyJob(entry.event) else if (entry.event?.kind === 'usageLimitReached') applyUsageLimit(entry.event) } catch (err) { logger.warn('Failed to parse table event', { tableId, err }) @@ -364,7 +394,7 @@ export function useTableEventStream({ cancelled = true if (reconnectTimer !== null) clearTimeout(reconnectTimer) if (dispatchInvalidateTimer !== null) clearTimeout(dispatchInvalidateTimer) - if (importInvalidateTimer !== null) clearTimeout(importInvalidateTimer) + if (jobInvalidateTimer !== null) clearTimeout(jobInvalidateTimer) eventSource?.close() eventSource = null } diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/hooks/use-table.ts b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/hooks/use-table.ts index 844c87a7c3c..818cdf43d20 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/hooks/use-table.ts +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/hooks/use-table.ts @@ -35,6 +35,8 @@ export interface UseTableReturn { isLoadingTable: boolean /** Flattened across every fetched infinite-query page. */ rows: TableRow[] + /** Filter-scoped total row count (server COUNT(*) for the active filter); null until loaded. */ + rowTotal: number | null isLoadingRows: boolean refetchRows: () => void /** @@ -96,6 +98,14 @@ export function useTable({ workspaceId, tableId, queryOptions }: UseTableParams) [rowsData?.pages] ) + // Server-side COUNT(*) for the active filter (page 0 only). Null until the first page lands; + // callers fall back to the table's unfiltered `rowCount`. This is the true "select all" total — + // it reflects the filter, unlike `tableData.rowCount`. + const rowTotal = useMemo( + () => rowsData?.pages[0]?.totalCount ?? null, + [rowsData?.pages] + ) + const refetchRows = useCallback(() => { void refetch() }, [refetch]) @@ -219,6 +229,7 @@ export function useTable({ workspaceId, tableId, queryOptions }: UseTableParams) tableData, isLoadingTable, rows, + rowTotal, isLoadingRows, refetchRows, fetchNextPage: fetchNextPageWrapped, diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx index 57a68a8485f..246a7ddbfe8 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx @@ -10,6 +10,7 @@ import type { RunLimit, RunMode } from '@/lib/api/contracts/tables' import { captureEvent } from '@/lib/posthog/client' import type { ColumnDefinition, Filter, TableRow as TableRowType, WorkflowGroup } from '@/lib/table' import { getColumnId } from '@/lib/table/column-keys' +import { TABLE_LIMITS } from '@/lib/table/constants' import { type ColumnOption, Resource, @@ -24,6 +25,8 @@ import { downloadTableExport, useCancelTableRuns, useDeleteTable, + useDeleteTableRowsAsync, + useExportTableAsync, useRenameTable, useRunColumn, } from '@/hooks/queries/tables' @@ -137,6 +140,10 @@ export function Table({ const [isImportCsvOpen, setIsImportCsvOpen] = useState(false) const [editingRow, setEditingRow] = useState(null) const [deletingRows, setDeletingRows] = useState([]) + const [deletingAll, setDeletingAll] = useState<{ + excludeRowIds: string[] + estimatedCount: number + } | null>(null) const [deletingColumns, setDeletingColumns] = useState(null) const [selection, setSelection] = useState({ actionBarRowIds: [], @@ -179,6 +186,12 @@ export function Table({ const onRequestDeleteRows = useCallback((snapshots: DeletedRowSnapshot[]) => { setDeletingRows(snapshots) }, []) + const onRequestDeleteAllByFilter = useCallback( + (params: { excludeRowIds: string[]; estimatedCount: number }) => { + setDeletingAll(params) + }, + [] + ) const onRequestDeleteColumns = useCallback((names: string[]) => { setDeletingColumns(names) }, []) @@ -200,6 +213,9 @@ export function Table({ */ const afterDeleteRowsSinkRef = useRef<((snapshots: DeletedRowSnapshot[]) => void) | null>(null) + /** Sink the grid populates with its post-select-all-delete cleanup (clear selection). */ + const afterDeleteAllSinkRef = useRef<(() => void) | null>(null) + /** * Sink the grid populates with its full delete-columns cascade (per-column * mutation, undo push, columnOrder + columnWidths cleanup). The wrapper's @@ -236,6 +252,8 @@ export function Table({ (args: { groupIds: string[] rowIds?: string[] + filter?: Filter + excludeRowIds?: string[] runMode: RunMode limit?: RunLimit source: 'row' | 'rows' | 'column' @@ -268,15 +286,37 @@ export function Table({ ) const onRunColumn = useCallback( - (groupId: string, runMode: RunMode, rowIds?: string[], limit?: RunLimit) => { - runScope({ groupIds: [groupId], rowIds, runMode, limit, source: 'column' }) + ( + groupId: string, + runMode: RunMode, + rowIds?: string[], + limit?: RunLimit, + filter?: Filter, + excludeRowIds?: string[] + ) => { + runScope({ + groupIds: [groupId], + rowIds, + filter, + excludeRowIds, + runMode, + limit, + source: 'column', + }) }, [runScope] ) const onRunRows = useCallback( - (rowIds: string[], runMode: RunMode) => { - runScope({ groupIds: tableWorkflowGroups.map((g) => g.id), rowIds, runMode, source: 'rows' }) + (rowIds: string[] | undefined, runMode: RunMode, filter?: Filter, excludeRowIds?: string[]) => { + runScope({ + groupIds: tableWorkflowGroups.map((g) => g.id), + rowIds, + filter, + excludeRowIds, + runMode, + source: 'rows', + }) }, [runScope, tableWorkflowGroups] ) @@ -321,7 +361,9 @@ export function Table({ }) } - // useCallback because is memo-wrapped. + // useCallback because is memo-wrapped. Zero-arg on + // purpose — RunStatusControl passes it straight to onClick, which would + // otherwise leak the MouseEvent into `filter`. const onStopAll = useCallback(() => { cancelRunsMutate({ scope: 'all' }) captureEvent(posthogRef.current, 'table_workflow_stopped', { @@ -332,6 +374,20 @@ export function Table({ }) }, [cancelRunsMutate, tableId, workspaceId]) + /** Select-all Stop — filter-scoped when a filter is active; deselected rows keep running. */ + const onStopAllRows = useCallback( + (filter?: Filter, excludeRowIds?: string[]) => { + cancelRunsMutate({ scope: 'all', filter, excludeRowIds }) + captureEvent(posthogRef.current, 'table_workflow_stopped', { + table_id: tableId, + workspace_id: workspaceId, + scope: 'all', + row_count: null, + }) + }, + [cancelRunsMutate, tableId, workspaceId] + ) + const onSelectionChange = (next: SelectionSnapshot) => { setSelection(next) } @@ -371,7 +427,17 @@ export function Table({ const handleExportCsv = useCallback(async () => { if (!tableData) return try { - await downloadTableExport(tableData.id, tableData.name) + // Big tables export as a background job (the file downloads when the job completes via the + // SSE stream); small ones keep the instant synchronous stream. While a delete job runs, + // rowCount is a doomed-estimate-adjusted number — not ground truth — so always take the + // async path (safe at any size; exports bypass the one-job-per-table gate). + const deleteRunning = tableData.jobType === 'delete' && tableData.jobStatus === 'running' + if (deleteRunning || tableData.rowCount > TABLE_LIMITS.EXPORT_ASYNC_THRESHOLD_ROWS) { + await exportTableAsync.mutateAsync({ format: 'csv' }) + toast.success('Export started — the download will begin when it finishes') + } else { + await downloadTableExport(tableData.id, tableData.name) + } captureEvent(posthogRef.current, 'table_exported', { table_id: tableData.id, workspace_id: workspaceId, @@ -499,6 +565,8 @@ export function Table({ : 0 const deleteTableMutation = useDeleteTable(workspaceId) + const deleteRowsAsyncMutation = useDeleteTableRowsAsync({ workspaceId, tableId }) + const exportTableAsync = useExportTableAsync({ workspaceId, tableId }) const handleDeleteTable = async () => { try { await deleteTableMutation.mutateAsync(tableId) @@ -595,16 +663,19 @@ export function Table({ onOpenExecutionDetails={onOpenExecutionDetails} onOpenRowModal={onOpenRowModal} onRequestDeleteRows={onRequestDeleteRows} + onRequestDeleteAllByFilter={onRequestDeleteAllByFilter} onRequestDeleteColumns={onRequestDeleteColumns} onRunColumn={onRunColumn} onRunRow={onRunRow} onRunRows={onRunRows} onStopRows={onStopRows} + onStopAllRows={onStopAllRows} onStopRow={onStopRow} onSelectionChange={onSelectionChange} queryOptions={queryOptions} columnRenameSinkRef={columnRenameSinkRef} afterDeleteRowsSinkRef={afterDeleteRowsSinkRef} + afterDeleteAllSinkRef={afterDeleteAllSinkRef} confirmDeleteColumnsSinkRef={confirmDeleteColumnsSinkRef} pushTableRenameUndoSinkRef={pushTableRenameUndoSinkRef} /> @@ -612,8 +683,7 @@ export function Table({ { const scope = selection.selectedRunScope if (!scope) return - scope.allRows ? onStopAll() : onStopRows(scope.rowIds) + if (scope.allRows) { + scope.filter || scope.excludeRowIds?.length + ? onStopAllRows(scope.filter, scope.excludeRowIds) + : onStopAll() + } else { + onStopRows(scope.rowIds) + } }} onViewExecution={ selection.singleWorkflowCell?.canViewExecution && @@ -722,6 +803,38 @@ export function Table({ }} /> )} + { + if (!open) setDeletingAll(null) + }} + srTitle='Delete rows' + title='Delete rows' + description={`Delete ${deletingAll ? deletingAll.estimatedCount.toLocaleString() : 0} ${ + deletingAll?.estimatedCount === 1 ? 'row' : 'rows' + }${queryOptions.filter ? ' matching the current filter' : ''}? This can't be undone.`} + confirm={{ + label: 'Delete', + pending: deleteRowsAsyncMutation.isPending, + pendingLabel: 'Deleting...', + onClick: () => { + if (!deletingAll) return + const { excludeRowIds, estimatedCount } = deletingAll + deleteRowsAsyncMutation.mutate({ + filter: queryOptions.filter ?? undefined, + sort: queryOptions.sort, + excludeRowIds: excludeRowIds.length > 0 ? excludeRowIds : undefined, + estimatedCount, + }) + // Clear at click so the header checkbox doesn't linger in its + // select-all state over the optimistically-emptied grid. If the + // kickoff fails the rows visibly return with an error toast — + // re-selecting is cheaper than a stale-looking selection. + afterDeleteAllSinkRef.current?.() + setDeletingAll(null) + }, + }} + /> { diff --git a/apps/sim/app/workspace/[workspaceId]/tables/components/import-csv-dialog/import-csv-dialog.tsx b/apps/sim/app/workspace/[workspaceId]/tables/components/import-csv-dialog/import-csv-dialog.tsx index a718f010cc7..f042447a7a8 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/components/import-csv-dialog/import-csv-dialog.tsx +++ b/apps/sim/app/workspace/[workspaceId]/tables/components/import-csv-dialog/import-csv-dialog.tsx @@ -28,7 +28,7 @@ import { buildAutoMapping, parseCsvBuffer } from '@/lib/table/import' import type { TableDefinition } from '@/lib/table/types' import { type CsvImportMode, - cancelTableImport, + cancelTableJob, useImportCsvIntoTable, useImportCsvIntoTableAsync, } from '@/hooks/queries/tables' @@ -322,7 +322,7 @@ export function ImportCsvDialog({ // the id so it's not shown and cancel the worker server-side. if (useImportTrayStore.getState().consumeCanceled(table.id) && data?.importId) { useImportTrayStore.getState().cancel(table.id) - void cancelTableImport(workspaceId, table.id, data.importId).catch(() => {}) + void cancelTableJob(workspaceId, table.id, data.importId).catch(() => {}) } }, onError: () => { diff --git a/apps/sim/app/workspace/[workspaceId]/tables/components/import-progress-menu/import-progress-menu.tsx b/apps/sim/app/workspace/[workspaceId]/tables/components/import-progress-menu/import-progress-menu.tsx index 1c1bf48fa48..238e3f0f7f4 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/components/import-progress-menu/import-progress-menu.tsx +++ b/apps/sim/app/workspace/[workspaceId]/tables/components/import-progress-menu/import-progress-menu.tsx @@ -1,18 +1,22 @@ 'use client' +import { createLogger } from '@sim/logger' import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuTrigger, ProgressItem, + toast, } from '@/components/emcn' -import { Upload } from '@/components/emcn/icons' -import { cancelTableImport } from '@/hooks/queries/tables' +import { CircleAlert, CircleCheck, Loader } from '@/components/emcn/icons' +import { cancelTableJob, downloadExportResult } from '@/hooks/queries/tables' import { useImportTrayStore } from '@/stores/table/import-tray/store' import { getImportStage } from './import-stage' import { type ImportRow, useWorkspaceImports } from './use-workspace-imports' +const logger = createLogger('ImportProgressMenu') + interface ImportProgressMenuProps { workspaceId: string | undefined /** When mounted inside a specific table's header, the indicator is scoped to that table. */ @@ -20,13 +24,15 @@ interface ImportProgressMenuProps { } /** - * Header affordance for background CSV imports: a clickable `{done}/{total}` count that opens a - * dropdown of per-import progress rows. Renders nothing when there are no imports. The single - * import-progress surface for both the tables list and the in-table view. + * Header affordance for background table jobs: a clickable `{done}/{total}` count that opens a + * dropdown of per-job progress rows — CSV imports and exports (a ready export row carries a + * Download action). Renders nothing when there are no jobs. The single job-progress surface for + * both the tables list and the in-table view. */ export function ImportProgressMenu({ workspaceId, tableId }: ImportProgressMenuProps) { const imports = useWorkspaceImports(workspaceId, tableId) const dismiss = useImportTrayStore((state) => state.dismiss) + const dismissJob = useImportTrayStore((state) => state.dismissJob) const cancelId = useImportTrayStore((state) => state.cancel) const menuOpen = useImportTrayStore((state) => state.menuOpen) const setMenuOpen = useImportTrayStore((state) => state.setMenuOpen) @@ -35,21 +41,39 @@ export function ImportProgressMenu({ workspaceId, tableId }: ImportProgressMenuP const total = imports.length const done = imports.filter((e) => e.phase === 'ready').length + const anyRunning = imports.some((e) => e.phase === 'importing') + const anyFailed = imports.some((e) => e.phase === 'failed') const cancel = (row: ImportRow) => { cancelId(row.id) // Worker already running — cancel it server-side now. (An upload still mid-flight is canceled by - // the kickoff handler once its importId is known; see the `consumeCanceled` branches.) - if (row.importId) { - void cancelTableImport(row.workspaceId, row.id, row.importId).catch(() => {}) + // the kickoff handler once its jobId is known; see the `consumeCanceled` branches.) + if (row.jobId) { + void cancelTableJob(row.workspaceId, row.tableId, row.jobId).catch(() => {}) } } + const download = (row: ImportRow) => { + if (!row.jobId) return + void downloadExportResult(row.workspaceId, row.tableId, row.jobId).catch((err) => { + logger.error('Export download failed', { jobId: row.jobId, err }) + toast.error('Download failed — the export may have expired') + }) + } + return ( + ) : ( + stage.detail + ) + } onCancel={row.phase === 'importing' ? () => cancel(row) : undefined} - onDismiss={stage.dismissible ? () => dismiss(row.id) : undefined} + onDismiss={ + stage.dismissible + ? () => (row.jobType === 'export' ? dismissJob(row.id) : dismiss(row.id)) + : undefined + } /> ) })} diff --git a/apps/sim/app/workspace/[workspaceId]/tables/components/import-progress-menu/import-stage.ts b/apps/sim/app/workspace/[workspaceId]/tables/components/import-progress-menu/import-stage.ts index 56e0fb77739..8d20cfc2132 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/components/import-progress-menu/import-stage.ts +++ b/apps/sim/app/workspace/[workspaceId]/tables/components/import-progress-menu/import-stage.ts @@ -27,6 +27,32 @@ export function getImportStage(entry: ImportRow): ImportStageView { const name = entry.title const meta = typeof entry.percent === 'number' ? `${entry.percent}%` : undefined + if (entry.jobType === 'export') { + if (entry.phase === 'failed') { + return { + status: 'error', + title: `Export failed for ${name}`, + detail: entry.error ?? 'Something went wrong', + dismissible: true, + } + } + if (entry.phase === 'ready') { + // The menu replaces `detail` with a Download action for ready exports. + return { + status: 'success', + title: `Exported ${name}`, + detail: `${rows} rows`, + dismissible: true, + } + } + return { + status: 'pending', + title: `Exporting ${name}`, + detail: `${rows} rows`, + dismissible: false, + } + } + if (entry.phase === 'failed') { return { status: 'error', diff --git a/apps/sim/app/workspace/[workspaceId]/tables/components/import-progress-menu/use-workspace-imports.ts b/apps/sim/app/workspace/[workspaceId]/tables/components/import-progress-menu/use-workspace-imports.ts index a4f1acb25e0..e5227ab2665 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/components/import-progress-menu/use-workspace-imports.ts +++ b/apps/sim/app/workspace/[workspaceId]/tables/components/import-progress-menu/use-workspace-imports.ts @@ -3,7 +3,7 @@ import { useEffect, useMemo, useRef } from 'react' import { useShallow } from 'zustand/react/shallow' import { toast } from '@/components/emcn' -import { useTablesList } from '@/hooks/queries/tables' +import { useTablesList, useWorkspaceExportJobs } from '@/hooks/queries/tables' import { useImportTrayStore } from '@/stores/table/import-tray/store' const READY_AUTO_CLEAR_MS = 6000 @@ -11,25 +11,33 @@ const POLL_INTERVAL_MS = 2000 export type ImportPhase = 'importing' | 'ready' | 'failed' -/** A row rendered in the import tray. Importing rows come live from the table list; uploads are - * client-only until their server row exists. */ +/** A row rendered in the job tray. Import rows come live from the table list (uploads are + * client-only until their server row exists); export rows come from the workspace export-jobs + * query. Delete/backfill jobs are intentionally excluded — the grid reflects them directly. */ export interface ImportRow { + /** Table id for imports/uploads; job id for exports (a table can have several exports). */ id: string + /** The table the job belongs to — cancel and download need it for export rows. */ + tableId: string workspaceId: string title: string phase: ImportPhase + jobType: 'import' | 'export' rowsProcessed: number /** Upload byte percent (upload phase only). */ percent?: number error?: string - importId?: string + jobId?: string + /** Export rows: whether the generated file is downloadable. */ + hasResult?: boolean } /** * Single source for the import tray. Importing rows are derived live from the table list (polled - * while any import is in flight) rather than mirrored into a store; the store only supplies + * while any job is in flight) rather than mirrored into a store; the store only supplies * optimistic uploads and which terminal completions to surface this session. Also fires the - * completion toasts on the importing → terminal transition. + * completion toasts on the importing → terminal transition. Delete jobs never render as tray rows + * and only surface a toast on failure (a failed delete restores the optimistically-removed rows). */ export function useWorkspaceImports( workspaceId: string | undefined, @@ -37,8 +45,11 @@ export function useWorkspaceImports( ): ImportRow[] { const { data: tables } = useTablesList(workspaceId, 'active', { refetchInterval: (list) => - list?.some((t) => t.importStatus === 'importing') ? POLL_INTERVAL_MS : false, + list?.some((t) => t.jobStatus === 'running') ? POLL_INTERVAL_MS : false, }) + // Exports are excluded from the table-level job derivation (they run concurrently with other + // jobs), so the tray reads them from their dedicated workspace listing. + const { data: exportJobs } = useWorkspaceExportJobs(workspaceId) const prevStatus = useRef>(new Map()) useEffect(() => { @@ -46,17 +57,29 @@ export function useWorkspaceImports( const store = useImportTrayStore.getState() for (const table of tables) { const before = prevStatus.current.get(table.id) - const now = table.importStatus ?? 'none' - if (before === 'importing' && now === 'ready') { - const rows = (table.importRowsProcessed ?? 0).toLocaleString() - toast.success(`Imported ${rows} rows into "${table.name}"`) - store.notify(table.id) - setTimeout(() => useImportTrayStore.getState().dismiss(table.id), READY_AUTO_CLEAR_MS) - } else if (before === 'importing' && now === 'failed') { - toast.error(table.importError || `Import failed for "${table.name}"`) - store.notify(table.id) + const now = table.jobStatus ?? 'none' + if (before === 'running' && now === 'ready') { + // Success toast only for imports — deletes reflect instantly in the grid and backfills + // live-fill cells; announcing them would be noise. + if (table.jobType === 'import') { + const rows = (table.jobRowsProcessed ?? 0).toLocaleString() + toast.success(`Imported ${rows} rows into "${table.name}"`) + store.notify(table.id) + setTimeout(() => useImportTrayStore.getState().dismiss(table.id), READY_AUTO_CLEAR_MS) + } + } else if (before === 'running' && now === 'failed') { + // Surface every failure — e.g. a failed delete restores the optimistically-removed rows, + // and a failed backfill leaves cells unfilled; the user should know why. + const fallback = + table.jobType === 'delete' + ? `Delete failed for "${table.name}"` + : table.jobType === 'backfill' + ? `Column backfill failed for "${table.name}"` + : `Import failed for "${table.name}"` + toast.error(table.jobError || fallback) + if (table.jobType === 'import') store.notify(table.id) } - if (now !== 'importing' && store.isCanceled(table.id)) store.consumeCanceled(table.id) + if (now !== 'running' && store.isCanceled(table.id)) store.consumeCanceled(table.id) prevStatus.current.set(table.id, now) } }, [tables]) @@ -64,6 +87,7 @@ export function useWorkspaceImports( const uploads = useImportTrayStore(useShallow((s) => Object.values(s.uploads))) const notified = useImportTrayStore((s) => s.notified) const canceledIds = useImportTrayStore((s) => s.canceledIds) + const dismissedIds = useImportTrayStore((s) => s.dismissedIds) return useMemo(() => { const rows: ImportRow[] = [] @@ -71,28 +95,35 @@ export function useWorkspaceImports( for (const table of tables ?? []) { if (scopeTableId && table.id !== scopeTableId) continue - if (table.importStatus === 'importing') { + // Of the table-derived jobs, only imports render here: deletes reflect optimistically in + // the grid and backfills live-fill cells via SSE. (Exports merge in below.) + if (table.jobType !== 'import') continue + if (table.jobStatus === 'running') { if (canceledIds[table.id]) continue rows.push({ id: table.id, + tableId: table.id, workspaceId: table.workspaceId, title: table.name, phase: 'importing', - rowsProcessed: table.importRowsProcessed ?? 0, - importId: table.importId ?? undefined, + jobType: 'import', + rowsProcessed: table.jobRowsProcessed ?? 0, + jobId: table.jobId ?? undefined, }) seen.add(table.id) } else if ( - (table.importStatus === 'ready' || table.importStatus === 'failed') && + (table.jobStatus === 'ready' || table.jobStatus === 'failed') && notified[table.id] ) { rows.push({ id: table.id, + tableId: table.id, workspaceId: table.workspaceId, title: table.name, - phase: table.importStatus, - rowsProcessed: table.importRowsProcessed ?? 0, - error: table.importError ?? undefined, + phase: table.jobStatus, + jobType: 'import', + rowsProcessed: table.jobRowsProcessed ?? 0, + error: table.jobError ?? undefined, }) seen.add(table.id) } @@ -104,15 +135,50 @@ export function useWorkspaceImports( if (canceledIds[upload.uploadId] || seen.has(upload.uploadId)) continue rows.push({ id: upload.uploadId, + tableId: upload.uploadId, workspaceId: upload.workspaceId, title: upload.title, phase: 'importing', + jobType: 'import', rowsProcessed: 0, percent: upload.percent, }) } + // Export rows: running ones always; terminal ready stays listed (re-downloadable) until the + // server's visibility window lapses or the user dismisses it. Keyed by jobId. + for (const job of exportJobs ?? []) { + if (!workspaceId) break + if (scopeTableId && job.tableId !== scopeTableId) continue + if (job.status === 'canceled' || canceledIds[job.jobId] || dismissedIds[job.jobId]) continue + if (job.status === 'running') { + rows.push({ + id: job.jobId, + tableId: job.tableId, + workspaceId, + title: job.tableName, + phase: 'importing', + jobType: 'export', + rowsProcessed: job.rowsProcessed, + jobId: job.jobId, + }) + } else { + rows.push({ + id: job.jobId, + tableId: job.tableId, + workspaceId, + title: job.tableName, + phase: job.status === 'ready' ? 'ready' : 'failed', + jobType: 'export', + rowsProcessed: job.rowsProcessed, + jobId: job.jobId, + hasResult: job.hasResult, + error: job.error ?? undefined, + }) + } + } + rows.sort((a, b) => (a.phase === b.phase ? 0 : a.phase === 'importing' ? -1 : 1)) return rows - }, [tables, uploads, notified, canceledIds, workspaceId, scopeTableId]) + }, [tables, exportJobs, uploads, notified, canceledIds, dismissedIds, workspaceId, scopeTableId]) } diff --git a/apps/sim/app/workspace/[workspaceId]/tables/tables.tsx b/apps/sim/app/workspace/[workspaceId]/tables/tables.tsx index 676fd3b6724..8a0cc6db062 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/tables.tsx +++ b/apps/sim/app/workspace/[workspaceId]/tables/tables.tsx @@ -27,7 +27,7 @@ import { import { TableContextMenu } from '@/app/workspace/[workspaceId]/tables/components/table-context-menu' import { useContextMenu } from '@/app/workspace/[workspaceId]/w/components/sidebar/hooks' import { - cancelTableImport, + cancelTableJob, downloadTableExport, useCreateTable, useDeleteTable, @@ -448,7 +448,7 @@ export function Tables() { useImportTrayStore.getState().consumeCanceled(pendingId) ) { useImportTrayStore.getState().cancel(result.tableId) - void cancelTableImport(workspaceId, result.tableId, result.importId).catch(() => {}) + void cancelTableJob(workspaceId, result.tableId, result.importId).catch(() => {}) } } catch { // The hook's onError surfaces the toast; just clear the tray indicator here. diff --git a/apps/sim/background/table-backfill.ts b/apps/sim/background/table-backfill.ts new file mode 100644 index 00000000000..3c210b17e53 --- /dev/null +++ b/apps/sim/background/table-backfill.ts @@ -0,0 +1,21 @@ +import { task } from '@trigger.dev/sdk' +import { runTableBackfill, type TableBackfillPayload } from '@/lib/table/backfill-runner' + +/** + * Trigger.dev wrapper around `runTableBackfill` (output-column backfill from saved execution + * logs). Retry-safe: re-plucking the same trace spans writes the same values, and + * `overwrite: false` passes skip already-filled cells. The `table_jobs` ownership gate stops a + * run that lost the job within one page. + */ +export const tableBackfillTask = task({ + id: 'table-backfill', + machine: 'small-1x', + retry: { maxAttempts: 3 }, + queue: { + name: 'table-backfill', + concurrencyLimit: 10, + }, + run: async (payload: TableBackfillPayload) => { + await runTableBackfill(payload) + }, +}) diff --git a/apps/sim/background/table-delete.ts b/apps/sim/background/table-delete.ts new file mode 100644 index 00000000000..464e963fd49 --- /dev/null +++ b/apps/sim/background/table-delete.ts @@ -0,0 +1,29 @@ +import { task } from '@trigger.dev/sdk' +import { runTableDelete, type TableDeletePayload } from '@/lib/table/delete-runner' + +/** + * `TableDeletePayload` with the cutoff as an ISO string — task payloads cross a JSON boundary, so + * the Date is rehydrated in `run` rather than trusting payload serialization. + */ +export interface TableDeleteTaskPayload extends Omit { + cutoff: string +} + +/** + * Trigger.dev wrapper around `runTableDelete`. Retry-safe: the worker keysets by id with a + * `created_at <= cutoff` floor and pages are committed independently, so a retried attempt simply + * re-walks and deletes whatever remains. The `table_jobs` ownership gate stops a retried run that + * lost the job (canceled / janitor-failed) within one page. + */ +export const tableDeleteTask = task({ + id: 'table-delete', + machine: 'small-1x', + retry: { maxAttempts: 3 }, + queue: { + name: 'table-delete', + concurrencyLimit: 10, + }, + run: async (payload: TableDeleteTaskPayload) => { + await runTableDelete({ ...payload, cutoff: new Date(payload.cutoff) }) + }, +}) diff --git a/apps/sim/background/table-export.ts b/apps/sim/background/table-export.ts new file mode 100644 index 00000000000..49a9c622c3c --- /dev/null +++ b/apps/sim/background/table-export.ts @@ -0,0 +1,21 @@ +import { task } from '@trigger.dev/sdk' +import { runTableExport, type TableExportPayload } from '@/lib/table/export-runner' + +/** + * Trigger.dev wrapper around `runTableExport`. Retry-safe: a retried attempt regenerates the file + * from scratch (failures clean up their partial upload), and the `table_jobs` ownership gate + * stops a run that lost the job. `medium-1x` — the serialized file is buffered in memory before + * the single-shot storage upload (~hundreds of MB worst case for enterprise 1M-row tables). + */ +export const tableExportTask = task({ + id: 'table-export', + machine: 'medium-1x', + retry: { maxAttempts: 3 }, + queue: { + name: 'table-export', + concurrencyLimit: 10, + }, + run: async (payload: TableExportPayload) => { + await runTableExport(payload) + }, +}) diff --git a/apps/sim/background/table-import.ts b/apps/sim/background/table-import.ts new file mode 100644 index 00000000000..65f8fbb82f2 --- /dev/null +++ b/apps/sim/background/table-import.ts @@ -0,0 +1,24 @@ +import { task } from '@trigger.dev/sdk' +import { runTableImport, type TableImportPayload } from '@/lib/table/import-runner' + +/** + * Trigger.dev wrapper around `runTableImport`. The job's lifecycle (claim, progress heartbeat, + * cancel, terminal state) lives in the `table_jobs` state machine, so the task is a thin shell: + * the worker's per-batch ownership gate stops it on cancel/supersede regardless of where it runs. + * + * `maxAttempts: 1` — a blind re-run would re-insert batches the failed attempt already committed + * (imports commit per batch with no rollback). A crashed import marks failed via the worker's own + * catch, or the stale-job janitor if the process died; the user retries the upload. + */ +export const tableImportTask = task({ + id: 'table-import', + machine: 'small-1x', + retry: { maxAttempts: 1 }, + queue: { + name: 'table-import', + concurrencyLimit: 10, + }, + run: async (payload: TableImportPayload) => { + await runTableImport(payload) + }, +}) diff --git a/apps/sim/hooks/queries/tables.test.ts b/apps/sim/hooks/queries/tables.test.ts index 473c29fa4d9..da4c8c1cc04 100644 --- a/apps/sim/hooks/queries/tables.test.ts +++ b/apps/sim/hooks/queries/tables.test.ts @@ -348,20 +348,20 @@ describe('tableRowsParamsKey', () => { describe('tableRowsInfiniteOptions', () => { const PAGE_SIZE = 1000 - function makeOpts(pageSize = PAGE_SIZE) { + function makeOpts(pageSize = PAGE_SIZE, sort: unknown = null) { return tableRowsInfiniteOptions({ workspaceId: WORKSPACE_ID, tableId: TABLE_ID, pageSize, filter: null, - sort: null, + sort: sort as never, }) as { queryKey: readonly unknown[] getNextPageParam: ( lastPage: { rows: unknown[] }, allPages: unknown[], lastPageParam: unknown - ) => number | undefined + ) => number | { orderKey: string; id: string } | undefined } } @@ -393,6 +393,26 @@ describe('tableRowsInfiniteOptions', () => { expect(opts.getNextPageParam(lastPartialPage, [], 2000)).toBeUndefined() }) + it('getNextPageParam returns a keyset cursor when rows carry orderKey and there is no sort', () => { + const opts = makeOpts() + const fullPage = { + rows: Array.from({ length: PAGE_SIZE }, (_, i) => ({ id: `r${i}`, orderKey: `a${i}` })), + } + expect(opts.getNextPageParam(fullPage, [], 0)).toEqual({ + orderKey: `a${PAGE_SIZE - 1}`, + id: `r${PAGE_SIZE - 1}`, + }) + }) + + it('getNextPageParam falls back to offset for sorted views even with orderKey present', () => { + const opts = makeOpts(PAGE_SIZE, { column: 'name', direction: 'asc' }) + const fullPage = { + rows: Array.from({ length: PAGE_SIZE }, (_, i) => ({ id: `r${i}`, orderKey: `a${i}` })), + } + expect(opts.getNextPageParam(fullPage, [], 0)).toBe(PAGE_SIZE) + expect(opts.getNextPageParam(fullPage, [], PAGE_SIZE)).toBe(PAGE_SIZE * 2) + }) + it('queryKey includes the result of tableRowsParamsKey', () => { const paramsKey = tableRowsParamsKey({ pageSize: PAGE_SIZE, filter: null, sort: null }) const opts = makeOpts(PAGE_SIZE) diff --git a/apps/sim/hooks/queries/tables.ts b/apps/sim/hooks/queries/tables.ts index f854284e648..ccb6a07232c 100644 --- a/apps/sim/hooks/queries/tables.ts +++ b/apps/sim/hooks/queries/tables.ts @@ -29,21 +29,26 @@ import { batchUpdateTableRowsContract, type CreateTableBodyInput, type CreateTableColumnBodyInput, - cancelTableImportContract, + cancelTableJobContract, cancelTableRunsContract, createTableContract, createTableRowContract, + type DeleteTableRowsAsyncBody, deleteTableColumnContract, deleteTableContract, deleteTableRowContract, + deleteTableRowsAsyncContract, deleteTableRowsContract, deleteWorkflowGroupContract, + exportDownloadContract, + exportTableAsyncContract, findTableRowsContract, getTableContract, type InsertTableRowBodyInput, importIntoTableAsyncContract, importTableAsyncContract, listActiveDispatchesContract, + listTableJobsContract, listTableRowsContract, listTablesContract, type RunLimit, @@ -53,6 +58,7 @@ import { runColumnContract, type TableFindMatch, type TableIdParamsInput, + type TableJobSummary, type TableRowParamsInput, type TableRowsQueryInput, type UpdateTableColumnBodyInput, @@ -73,6 +79,7 @@ import type { TableDefinition, TableMetadata, TableRow, + TableRowsCursor, WorkflowGroup, WorkflowGroupDependencies, WorkflowGroupOutput, @@ -97,6 +104,8 @@ export const tableKeys = { [...tableKeys.lists(), workspaceId ?? '', scope] as const, details: () => [...tableKeys.all, 'detail'] as const, detail: (tableId: string) => [...tableKeys.details(), tableId] as const, + exportJobs: (workspaceId?: string) => + [...tableKeys.all, 'export-jobs', workspaceId ?? ''] as const, rowsRoot: (tableId: string) => [...tableKeys.detail(tableId), 'rows'] as const, infiniteRows: (tableId: string, paramsKey: string) => [...tableKeys.rowsRoot(tableId), 'infinite', paramsKey] as const, @@ -113,6 +122,12 @@ type TableRowsParams = Omit & sort?: Sort | null } +/** + * Infinite-rows page param: a keyset cursor on the default `(order_key, id)` order, or a numeric + * offset for sorted views / legacy rows without an order key. `0` doubles as the first page. + */ +export type TableRowsPageParam = number | TableRowsCursor + export type TableRowsResponse = Pick< ContractJsonResponse['data'], 'rows' | 'totalCount' @@ -151,6 +166,7 @@ async function fetchTableRows({ tableId, limit, offset, + after, filter, sort, includeTotal, @@ -162,6 +178,7 @@ async function fetchTableRows({ workspaceId, limit, offset, + after, filter: filter ?? undefined, sort: sort ?? undefined, includeTotal, @@ -438,21 +455,31 @@ export function tableRowsInfiniteOptions({ const paramsKey = tableRowsParamsKey({ pageSize, filter, sort }) return infiniteQueryOptions({ queryKey: tableKeys.infiniteRows(tableId, paramsKey), - queryFn: ({ pageParam, signal }) => - fetchTableRows({ + queryFn: ({ pageParam, signal }) => { + const param = pageParam as TableRowsPageParam + return fetchTableRows({ workspaceId, tableId, limit: pageSize, - offset: pageParam as number, + ...(typeof param === 'number' ? { offset: param } : { after: param }), filter, sort, - includeTotal: pageParam === 0, + includeTotal: param === 0, signal, - }), - initialPageParam: 0, - getNextPageParam: (lastPage, _allPages, lastPageParam) => { + }) + }, + initialPageParam: 0 as TableRowsPageParam, + getNextPageParam: (lastPage, _allPages, lastPageParam): TableRowsPageParam | undefined => { if (lastPage.rows.length < pageSize) return undefined - return (lastPageParam as number) + pageSize + // Default order pages by keyset cursor — each page is an index seek on (order_key, id), + // where OFFSET would re-scan every prior row (O(N²) across a deep scroll / full drain). + // Sorted views (and legacy rows without an order key) fall back to offset paging. + if (!sort) { + const last = lastPage.rows[lastPage.rows.length - 1] + if (last?.orderKey) return { orderKey: last.orderKey, id: last.id } + } + const param = lastPageParam as TableRowsPageParam + return (typeof param === 'number' ? param : 0) + lastPage.rows.length }, staleTime: 30 * 1000, }) @@ -653,7 +680,7 @@ function patchCachedRows( tableId: string, patchRow: (row: TableRow) => TableRow ) { - queryClient.setQueriesData>( + queryClient.setQueriesData>( { queryKey: tableKeys.rowsRoot(tableId), exact: false }, (old) => { if (!old) return old @@ -700,7 +727,7 @@ function reconcileCreatedRow( tableId: string, row: TableRow ) { - queryClient.setQueriesData>( + queryClient.setQueriesData>( { queryKey: tableKeys.rowsRoot(tableId), exact: false, @@ -827,7 +854,9 @@ export function useUpdateTableRow({ workspaceId, tableId }: RowMutationContext) onMutate: async ({ rowId, data }) => { await queryClient.cancelQueries({ queryKey: tableKeys.rowsRoot(tableId) }) - const previousQueries = queryClient.getQueriesData>({ + const previousQueries = queryClient.getQueriesData< + InfiniteData + >({ queryKey: tableKeys.rowsRoot(tableId), }) @@ -914,7 +943,9 @@ export function useBatchUpdateTableRows({ workspaceId, tableId }: RowMutationCon onMutate: async ({ updates }) => { await queryClient.cancelQueries({ queryKey: tableKeys.rowsRoot(tableId) }) - const previousQueries = queryClient.getQueriesData>({ + const previousQueries = queryClient.getQueriesData< + InfiniteData + >({ queryKey: tableKeys.rowsRoot(tableId), }) @@ -1032,6 +1063,98 @@ export function useDeleteTableRows({ workspaceId, tableId }: RowMutationContext) }) } +interface DeleteTableRowsAsyncVariables { + /** Active filter; omit for a whole-table "select all". */ + filter?: DeleteTableRowsAsyncBody['filter'] + /** Active sort — together with `filter` it identifies the exact rows query to optimistically + * strip, so we don't clear unrelated cached views (other filters/sorts). */ + sort?: Sort | null + /** Rows deselected after "select all" — spared by the job. */ + excludeRowIds?: string[] + /** Doomed-row estimate shown in the confirm — persisted on the job so server counts can + * subtract the not-yet-deleted remainder mid-job. */ + estimatedCount?: number +} + +/** + * Kicks off a background "select all" delete (filter + optional exclusion set) instead of sending + * every row id. Optimistically strips the rows from the *active* filter/sort view only (the one the + * user is looking at) so the table empties instantly while the worker deletes in the background; + * emptying that view's pages also drops `hasNextPage`, so scrolling won't reload not-yet-deleted + * rows. Other cached views are left intact. The SSE job stream reconciles on completion (and + * restores rows on failure/cancel). + */ +export function useDeleteTableRowsAsync({ workspaceId, tableId }: RowMutationContext) { + const queryClient = useQueryClient() + + return useMutation({ + mutationFn: async ({ + filter, + excludeRowIds, + estimatedCount, + }: DeleteTableRowsAsyncVariables) => { + return requestJson(deleteTableRowsAsyncContract, { + params: { tableId }, + body: { workspaceId, filter, excludeRowIds, estimatedCount }, + }) + }, + onMutate: async ({ filter, sort, excludeRowIds, estimatedCount }) => { + // Target the exact infinite-rows query for the view the user is on — not every cached view. + const activeKey = tableKeys.infiniteRows( + tableId, + tableRowsParamsKey({ pageSize: TABLE_LIMITS.MAX_QUERY_LIMIT, filter: filter ?? null, sort }) + ) + await queryClient.cancelQueries({ queryKey: activeKey }) + const previousRows = + queryClient.getQueryData>(activeKey) + const previousDetail = queryClient.getQueryData(tableKeys.detail(tableId)) + const keep = new Set(excludeRowIds ?? []) + // The active view's post-delete total is exactly the kept (deselected) rows — every other + // matching row is doomed. Without this the footer / select-all label stays at the old total + // until the job's terminal refetch. + queryClient.setQueryData>( + activeKey, + (old) => + old + ? { + ...old, + pages: old.pages.map((page) => ({ + ...page, + rows: page.rows.filter((r) => keep.has(r.id)), + ...(page.totalCount != null ? { totalCount: keep.size } : {}), + })), + } + : old + ) + if (estimatedCount != null) { + queryClient.setQueryData(tableKeys.detail(tableId), (p) => + p ? { ...p, rowCount: Math.max(0, p.rowCount - estimatedCount) } : p + ) + } + return { activeKey, previousRows, previousDetail } + }, + onSuccess: ({ data }) => { + // Lock the SSE job consumer onto this run so its running/terminal events are accepted, and + // flip the list-driven tray into "deleting" without waiting for a poll. + queryClient.setQueryData(tableKeys.detail(tableId), (p) => + p ? { ...p, jobStatus: 'running', jobId: data.jobId, jobType: 'delete' } : p + ) + queryClient.invalidateQueries({ queryKey: tableKeys.lists() }) + }, + onError: (error, _vars, context) => { + // Restore the optimistically-removed rows — the kickoff failed, nothing was deleted. + if (context?.activeKey && context.previousRows) { + queryClient.setQueryData(context.activeKey, context.previousRows) + } + if (context?.previousDetail) { + queryClient.setQueryData(tableKeys.detail(tableId), context.previousDetail) + } + if (isValidationError(error)) return + toast.error(error.message, { duration: 5000 }) + }, + }) +} + type UpdateColumnParams = Omit /** @@ -1127,6 +1250,10 @@ export function useUpdateTableMetadata({ workspaceId, tableId }: RowMutationCont interface CancelRunsParams { scope: 'all' | 'row' rowId?: string + /** Scope-`all` only: cancel just the cells on rows matching this filter (filtered select-all Stop). */ + filter?: Filter + /** Scope-`all` only: deselected rows whose cells keep running. */ + excludeRowIds?: string[] } /** @@ -1141,15 +1268,18 @@ export function useCancelTableRuns({ workspaceId, tableId }: RowMutationContext) const queryClient = useQueryClient() return useMutation({ - mutationFn: async ({ scope, rowId }: CancelRunsParams) => { + mutationFn: async ({ scope, rowId, filter, excludeRowIds }: CancelRunsParams) => { return requestJson(cancelTableRunsContract, { params: { tableId }, - body: { workspaceId, scope, rowId }, + body: { workspaceId, scope, rowId, filter, excludeRowIds }, }) }, - onMutate: async ({ scope, rowId }) => { + onMutate: async ({ scope, rowId, excludeRowIds }) => { + const excludedRowIds = + excludeRowIds && excludeRowIds.length > 0 ? new Set(excludeRowIds) : null const snapshots = await snapshotAndMutateRows(queryClient, tableId, (r) => { if (scope === 'row' && r.id !== rowId) return null + if (excludedRowIds?.has(r.id)) return null const executions = (r.executions ?? {}) as RowExecutions let rowTouched = false const nextExecutions: RowExecutions = { ...executions } @@ -1443,20 +1573,105 @@ export function useImportCsvIntoTable() { * `/api/table/[tableId]/export`. Defaults to CSV; pass `'json'` for JSON. */ /** - * Cancels an in-flight async import. Plain function (not a hook) because the import dropdown lists - * multiple tables and cancels a chosen one by id rather than binding to a single table. + * Cancels an in-flight async table job (import or delete). Plain function (not a hook) because the + * job tray lists multiple tables and cancels a chosen one by id rather than binding to a single + * table. */ -export async function cancelTableImport( +export async function cancelTableJob( workspaceId: string, tableId: string, - importId: string + jobId: string ): Promise { - await requestJson(cancelTableImportContract, { + await requestJson(cancelTableJobContract, { params: { tableId }, - body: { workspaceId, importId }, + body: { workspaceId, jobId }, }) } +async function fetchWorkspaceExportJobs( + workspaceId: string, + signal?: AbortSignal +): Promise { + const response = await requestJson(listTableJobsContract, { + query: { workspaceId, type: 'export' }, + signal, + }) + return response.data.jobs +} + +/** + * Export jobs for the header tray: running ones plus recent terminals (re-downloadable). Polls + * while any export is in flight; otherwise the SSE job stream invalidates this key on export + * events, so the list stays fresh without a steady poll. + */ +export function useWorkspaceExportJobs(workspaceId?: string) { + return useQuery({ + queryKey: tableKeys.exportJobs(workspaceId), + queryFn: ({ signal }) => fetchWorkspaceExportJobs(workspaceId as string, signal), + enabled: Boolean(workspaceId), + staleTime: 5 * 1000, + refetchInterval: (query) => + query.state.data?.some((j) => j.status === 'running') ? 2000 : false, + }) +} + +/** + * Export jobs this session kicked off. The SSE buffer replays up to an hour of events on every + * (re)connect, so the job stream consumer must only auto-download `ready` events for exports the + * user just initiated — not replayed ones from a previous visit. + */ +const initiatedExportJobIds = new Set() + +/** Consumes (one-shot) whether this session initiated the export job. */ +export function consumeInitiatedExport(jobId: string): boolean { + return initiatedExportJobIds.delete(jobId) +} + +/** + * Kicks off a background export job for large tables (small ones stream synchronously via + * {@link downloadTableExport}). The SSE job stream auto-downloads the file when the job is ready. + */ +export function useExportTableAsync({ workspaceId, tableId }: RowMutationContext) { + const queryClient = useQueryClient() + return useMutation({ + mutationFn: async ({ format }: { format: 'csv' | 'json' }) => { + const response = await requestJson(exportTableAsyncContract, { + params: { tableId }, + body: { workspaceId, format }, + }) + initiatedExportJobIds.add(response.data.jobId) + return response.data + }, + onSuccess: () => { + // Surface the new running job in the tray immediately — its poll only + // self-sustains once a running job is already in the cache. + void queryClient.invalidateQueries({ queryKey: tableKeys.exportJobs(workspaceId) }) + }, + onError: (error) => { + if (isValidationError(error)) return + toast.error(error.message, { duration: 5000 }) + }, + }) +} + +/** Resolves a ready export job to its presigned URL and triggers the browser download. */ +export async function downloadExportResult( + workspaceId: string, + tableId: string, + jobId: string +): Promise { + const response = await requestJson(exportDownloadContract, { + params: { tableId }, + query: { workspaceId, jobId }, + }) + const a = document.createElement('a') + a.href = response.data.url + a.download = response.data.fileName + document.body.appendChild(a) + a.click() + document.body.removeChild(a) +} + export async function downloadTableExport( tableId: string, fileName: string, @@ -1556,13 +1771,19 @@ interface RunColumnVariables { runMode?: RunMode /** Restrict to these rows. Server applies the same eligibility predicate. */ rowIds?: string[] + /** "Select all under a filter" — run every row matching this filter (mutually exclusive with + * `rowIds`). Optimistic stamping is skipped (like `limit`) since the matching set isn't known + * client-side; the dispatcher's real pending stamps drive the UI. */ + filter?: Filter + /** Select-all scope only: deselected rows — skipped by the dispatcher and the optimistic stamp. */ + excludeRowIds?: string[] /** Cap the run to the first `max` eligible rows. Omit for an unbounded run. * Optimistic stamping is skipped when set — the dispatcher's real pending * stamps drive the UI for the actual capped rows. */ limit?: RunLimit } -type InfiniteRowsCache = { pages: TableRowsResponse[]; pageParams: number[] } +type InfiniteRowsCache = { pages: TableRowsResponse[]; pageParams: TableRowsPageParam[] } /** * Cache shapes that hold table-row data. Single-page (`useTableRows`) and * infinite (`useInfiniteTableRows`) live under the same `rowsRoot(tableId)` @@ -1681,7 +1902,14 @@ export function useRunColumn({ workspaceId, tableId }: RowMutationContext) { const queryClient = useQueryClient() return useMutation({ - mutationFn: async ({ groupIds, runMode = 'all', rowIds, limit }: RunColumnVariables) => { + mutationFn: async ({ + groupIds, + runMode = 'all', + rowIds, + filter, + excludeRowIds, + limit, + }: RunColumnVariables) => { return requestJson(runColumnContract, { params: { tableId }, body: { @@ -1689,18 +1917,22 @@ export function useRunColumn({ workspaceId, tableId }: RowMutationContext) { groupIds, runMode, ...(rowIds && rowIds.length > 0 ? { rowIds } : {}), + ...(filter ? { filter } : {}), + ...(excludeRowIds && excludeRowIds.length > 0 ? { excludeRowIds } : {}), ...(limit ? { limit } : {}), }, }) }, - onMutate: async ({ groupIds, runMode = 'all', rowIds, limit }) => { - // Capped runs touch only the first N eligible rows, chosen server-side by - // position. We can't predict that set client-side, so optimistic stamping - // is skipped — the dispatcher's real pending stamps (cell SSE) drive the - // UI within the first window. - if (limit) + onMutate: async ({ groupIds, runMode = 'all', rowIds, filter, excludeRowIds, limit }) => { + // Capped and filtered runs target a set we can't predict client-side (capped picks the first + // N by position; filtered matches a server-evaluated predicate), so optimistic stamping is + // skipped — the dispatcher's real pending stamps (cell SSE) drive the UI within the first + // window. + if (limit || filter) return { snapshots: undefined, runStateSnapshot: undefined, didBumpRunState: false } const targetRowIds = rowIds && rowIds.length > 0 ? new Set(rowIds) : null + const excludedRowIds = + excludeRowIds && excludeRowIds.length > 0 ? new Set(excludeRowIds) : null const targetGroupIds = new Set(groupIds) const groups = queryClient.getQueryData(tableKeys.detail(tableId))?.schema @@ -1710,6 +1942,7 @@ export function useRunColumn({ workspaceId, tableId }: RowMutationContext) { const stampedByRow: Record = {} const snapshots = await snapshotAndMutateRows(queryClient, tableId, (r) => { if (targetRowIds && !targetRowIds.has(r.id)) return null + if (excludedRowIds?.has(r.id)) return null const executions = r.executions ?? {} let stamped = 0 const next: RowExecutions = { ...executions } diff --git a/apps/sim/lib/api/contracts/tables.ts b/apps/sim/lib/api/contracts/tables.ts index 0b277049000..a21c1502f3c 100644 --- a/apps/sim/lib/api/contracts/tables.ts +++ b/apps/sim/lib/api/contracts/tables.ts @@ -8,6 +8,7 @@ import type { TableDefinition, TableMetadata, TableRow, + TableRowsCursor, } from '@/lib/table' import { COLUMN_TYPES, NAME_PATTERN, TABLE_LIMITS } from '@/lib/table/constants' import { CSV_MAX_FILE_SIZE_BYTES } from '@/lib/table/import' @@ -293,10 +294,17 @@ export const deleteTableRowsBodySchema = z message: 'Provide either filter or rowIds, but not both', }) -export const tableRowsQuerySchema = z.object({ +/** Unrefined base so v1 contracts can `.extend()` — consumers use {@link tableRowsQuerySchema}. */ +export const tableRowsQueryBaseSchema = z.object({ workspaceId: z.string().min(1, 'Workspace ID is required'), filter: domainObjectSchema().optional(), sort: domainObjectSchema().optional(), + /** + * Keyset cursor `(orderKey, id)` for the default row order — each page is an index seek + * instead of OFFSET's scan-and-discard. Mutually exclusive with `sort` (cursors only make + * sense on the default order); takes precedence over `offset`. + */ + after: domainObjectSchema().optional(), limit: z .preprocess( (value) => @@ -329,6 +337,11 @@ export const tableRowsQuerySchema = z.object({ .default(true), }) +export const tableRowsQuerySchema = tableRowsQueryBaseSchema.refine( + (data) => !(data.after && data.sort), + { message: 'after cursor cannot be combined with sort — cursors paginate the default order' } +) + export const updateRowsByFilterBodySchema = z.object({ workspaceId: z.string().min(1, 'Workspace ID is required'), filter: nonEmptyFilterSchema, @@ -724,6 +737,79 @@ export const tableExportFormatSchema = z ) .default('csv') +export const exportTableAsyncBodySchema = z.object({ + workspaceId: z.string().min(1, 'Workspace ID is required'), + format: z.enum(['csv', 'json']).default('csv'), +}) + +export type ExportTableAsyncBody = z.input + +/** + * Kickoff for a background export (large tables — small ones use the synchronous streaming + * `/export` route). The worker generates the file, uploads it to workspace storage, and the + * client fetches a presigned URL from the download contract once the job is `ready`. + */ +export const exportTableAsyncContract = defineRouteContract({ + method: 'POST', + path: '/api/table/[tableId]/export-async', + params: tableIdParamsSchema, + body: exportTableAsyncBodySchema, + response: { + mode: 'json', + schema: successResponseSchema(z.object({ tableId: z.string(), jobId: z.string() })), + }, +}) + +export const tableJobSummarySchema = z.object({ + jobId: z.string(), + tableId: z.string(), + tableName: z.string(), + status: z.enum(['running', 'ready', 'failed', 'canceled']), + rowsProcessed: z.number(), + format: z.enum(['csv', 'json']), + hasResult: z.boolean(), + error: z.string().nullable(), +}) + +export type TableJobSummary = z.output + +export const listTableJobsQuerySchema = z.object({ + workspaceId: z.string().min(1, 'Workspace ID is required'), + type: z.literal('export'), +}) + +/** + * Workspace-scoped job listing the header tray polls. Export-only today: exports are excluded + * from the table-level job derivation (they run concurrently with other jobs), so this is their + * dedicated read path — running jobs plus recently-finished ones for re-download. + */ +export const listTableJobsContract = defineRouteContract({ + method: 'GET', + path: '/api/table/jobs', + query: listTableJobsQuerySchema, + response: { + mode: 'json', + schema: successResponseSchema(z.object({ jobs: z.array(tableJobSummarySchema) })), + }, +}) + +export const exportDownloadQuerySchema = z.object({ + workspaceId: z.string().min(1, 'Workspace ID is required'), + jobId: z.string().min(1, 'Job ID is required'), +}) + +/** Resolves a completed export job to a short-lived presigned download URL. */ +export const exportDownloadContract = defineRouteContract({ + method: 'GET', + path: '/api/table/[tableId]/export/download', + params: tableIdParamsSchema, + query: exportDownloadQuerySchema, + response: { + mode: 'json', + schema: successResponseSchema(z.object({ url: z.string().min(1), fileName: z.string() })), + }, +}) + /** * `mapping` form field — a JSON-encoded `CsvHeaderMapping` (CSV header → * column name, or `null` to skip the header). @@ -834,6 +920,40 @@ export const deleteTableRowsContract = defineRouteContract({ }, }) +/** + * Kickoff body for an asynchronous "select all" delete. Sends the active filter (and an optional + * exclusion set for "select all then deselect a few") instead of every row id, so the background + * worker deletes in paginated batches. Omitting `filter` deletes the whole table (at the cutoff). + */ +export const deleteTableRowsAsyncBodySchema = z.object({ + workspaceId: z.string().min(1, 'Workspace ID is required'), + filter: nonEmptyFilterSchema.optional(), + excludeRowIds: z + .array(z.string().min(1)) + .max( + TABLE_LIMITS.MAX_EXCLUDE_ROW_IDS, + `Cannot exclude more than ${TABLE_LIMITS.MAX_EXCLUDE_ROW_IDS} rows` + ) + .optional(), + /** Display-only doomed-row estimate (the filtered total minus deselections the client just + * showed). Persisted on the job so list/detail counts can subtract the not-yet-deleted + * remainder mid-job; clamped server-side, never used to scope the delete itself. */ + estimatedCount: z.number().int().min(0).optional(), +}) + +export type DeleteTableRowsAsyncBody = z.input + +export const deleteTableRowsAsyncContract = defineRouteContract({ + method: 'POST', + path: '/api/table/[tableId]/delete-async', + params: tableIdParamsSchema, + body: deleteTableRowsAsyncBodySchema, + response: { + mode: 'json', + schema: successResponseSchema(z.object({ tableId: z.string(), jobId: z.string() })), + }, +}) + // ============================================================================ // Workflow group contracts (`/api/table/[tableId]/groups`, `/cancel-runs`, // `/columns/run`, `/rows/run`, `/rows/[rowId]/cells/[groupId]/run`) @@ -993,7 +1113,8 @@ export const deleteWorkflowGroupContract = defineRouteContract({ /** * Cancel scopes: - * - `all` — every running/pending cell in the table + * - `all` — every running/pending cell in the table; with `filter`, only + * cells on rows matching it (filtered "select all" Stop) * - `row` — every running/pending cell for a specific row (`rowId` required) */ export const cancelTableRunsBodySchema = z @@ -1001,6 +1122,15 @@ export const cancelTableRunsBodySchema = z workspaceId: z.string().min(1, 'Workspace ID is required'), scope: z.enum(['all', 'row']), rowId: z.string().min(1).optional(), + filter: domainObjectSchema().optional(), + /** Scope-`all` only: rows deselected from the selection — their cells keep running. */ + excludeRowIds: z + .array(z.string().min(1)) + .max( + TABLE_LIMITS.MAX_EXCLUDE_ROW_IDS, + `Cannot exclude more than ${TABLE_LIMITS.MAX_EXCLUDE_ROW_IDS} rows` + ) + .optional(), }) .superRefine((value, ctx) => { if (value.scope === 'row' && !value.rowId) { @@ -1010,6 +1140,20 @@ export const cancelTableRunsBodySchema = z message: 'rowId is required when scope is "row"', }) } + if (value.scope === 'row' && value.filter) { + ctx.addIssue({ + code: 'custom', + path: ['filter'], + message: 'filter only applies to scope "all"', + }) + } + if (value.scope === 'row' && value.excludeRowIds) { + ctx.addIssue({ + code: 'custom', + path: ['excludeRowIds'], + message: 'excludeRowIds only applies to scope "all"', + }) + } }) export const cancelTableRunsContract = defineRouteContract({ @@ -1023,23 +1167,26 @@ export const cancelTableRunsContract = defineRouteContract({ }, }) -export const cancelTableImportBodySchema = z.object({ +export const cancelTableJobBodySchema = z.object({ workspaceId: z.string().min(1, 'Workspace ID is required'), - importId: z.string().min(1, 'Import ID is required'), + jobId: z.string().min(1, 'Job ID is required'), }) -/** Cancel an in-flight async CSV import. The worker stops; committed rows are left in place. */ -export const cancelTableImportContract = defineRouteContract({ +/** + * Cancel an in-flight async table job (import or delete). The worker stops at its next ownership + * check; committed work (inserted/deleted rows) is left in place. + */ +export const cancelTableJobContract = defineRouteContract({ method: 'POST', - path: '/api/table/[tableId]/import/cancel', + path: '/api/table/[tableId]/job/cancel', params: tableIdParamsSchema, - body: cancelTableImportBodySchema, + body: cancelTableJobBodySchema, response: { mode: 'json', schema: successResponseSchema(z.object({ canceled: z.boolean() })), }, }) -export type CancelTableImportBody = z.input +export type CancelTableJobBody = z.input /** * Run modes for `POST /api/table/[tableId]/columns/run`: @@ -1071,14 +1218,32 @@ export const runLimitSchema = z.object({ .max(1_000_000, 'max cannot exceed 1,000,000'), }) -export const runColumnBodySchema = z.object({ - workspaceId: z.string().min(1, 'Workspace ID is required'), - groupIds: z.array(z.string().min(1)).min(1), - runMode: z.enum(['all', 'incomplete']).default('all'), - rowIds: z.array(z.string().min(1)).min(1).optional(), - /** Cap the run to the first `max` eligible rows. Omit for an unbounded run. */ - limit: runLimitSchema.optional(), -}) +export const runColumnBodySchema = z + .object({ + workspaceId: z.string().min(1, 'Workspace ID is required'), + groupIds: z.array(z.string().min(1)).min(1), + runMode: z.enum(['all', 'incomplete']).default('all'), + rowIds: z.array(z.string().min(1)).min(1).optional(), + /** "Select all under a filter" — run every row matching this filter instead of `rowIds`. The + * dispatcher walks only matching rows (paginated), so no id list is materialized. */ + filter: nonEmptyFilterSchema.optional(), + /** Select-all scope only: rows deselected from the selection — the dispatcher skips them. */ + excludeRowIds: z + .array(z.string().min(1)) + .max( + TABLE_LIMITS.MAX_EXCLUDE_ROW_IDS, + `Cannot exclude more than ${TABLE_LIMITS.MAX_EXCLUDE_ROW_IDS} rows` + ) + .optional(), + /** Cap the run to the first `max` eligible rows. Omit for an unbounded run. */ + limit: runLimitSchema.optional(), + }) + .refine((data) => !(data.rowIds && data.filter), { + message: 'Provide either filter or rowIds, but not both', + }) + .refine((data) => !(data.rowIds && data.excludeRowIds), { + message: 'excludeRowIds only applies to select-all scope (no rowIds)', + }) export const runColumnContract = defineRouteContract({ method: 'POST', diff --git a/apps/sim/lib/api/contracts/v1/tables/index.ts b/apps/sim/lib/api/contracts/v1/tables/index.ts index 78b642e42dc..8beeec19a8a 100644 --- a/apps/sim/lib/api/contracts/v1/tables/index.ts +++ b/apps/sim/lib/api/contracts/v1/tables/index.ts @@ -9,7 +9,7 @@ import { rowDataSchema, tableIdParamsSchema, tableRowParamsSchema, - tableRowsQuerySchema, + tableRowsQueryBaseSchema, updateRowsByFilterBodySchema, updateTableColumnBodySchema, updateTableRowBodySchema, @@ -44,7 +44,7 @@ const optionalJsonObjectQuerySchema = (label: string) => return z.NEVER }) -export const v1TableRowsQuerySchema = tableRowsQuerySchema.extend({ +export const v1TableRowsQuerySchema = tableRowsQueryBaseSchema.omit({ after: true }).extend({ filter: optionalJsonObjectQuerySchema('filter'), sort: optionalJsonObjectQuerySchema('sort'), }) diff --git a/apps/sim/lib/copilot/chat/process-contents.test.ts b/apps/sim/lib/copilot/chat/process-contents.test.ts index 76033ef908d..37aeaa2735c 100644 --- a/apps/sim/lib/copilot/chat/process-contents.test.ts +++ b/apps/sim/lib/copilot/chat/process-contents.test.ts @@ -7,8 +7,6 @@ import type { ChatContext } from '@/stores/panel' const { getSkillById } = vi.hoisted(() => ({ getSkillById: vi.fn() })) -vi.mock('@sim/db', () => ({ db: {}, dbReplica: {} })) -vi.mock('@sim/db/schema', () => ({ document: {}, knowledgeBase: {} })) vi.mock('@/lib/workflows/skills/operations', () => ({ getSkillById })) import { processContextsServer } from './process-contents' diff --git a/apps/sim/lib/execution/sandbox/bundles/docx.cjs b/apps/sim/lib/execution/sandbox/bundles/docx.cjs index f94ae48b832..01697107612 100644 --- a/apps/sim/lib/execution/sandbox/bundles/docx.cjs +++ b/apps/sim/lib/execution/sandbox/bundles/docx.cjs @@ -1,27 +1,42 @@ // sandbox bundle: docx // generated by apps/sim/lib/execution/sandbox/bundles/build.ts // do not edit by hand. run `bun run build:sandbox-bundles` to regenerate. -(()=>{var F7=Object.create;var{getPrototypeOf:N7,defineProperty:F8,getOwnPropertyNames:R7}=Object;var D7=Object.prototype.hasOwnProperty;function A7($){return this[$]}var P7,T7,C7=($,U,Y)=>{var Z=$!=null&&typeof $==="object";if(Z){var J=U?P7??=new WeakMap:T7??=new WeakMap,G=J.get($);if(G)return G}Y=$!=null?F7(N7($)):{};let X=U||!$||!$.__esModule?F8(Y,"default",{value:$,enumerable:!0}):Y;for(let Q of R7($))if(!D7.call(X,Q))F8(X,Q,{get:A7.bind($,Q),enumerable:!0});if(Z)J.set($,X);return X};var O7=($,U)=>()=>(U||$((U={exports:{}}).exports,U),U.exports);var k7=($)=>$;function E7($,U){this[$]=k7.bind(null,U)}var S7=($,U)=>{for(var Y in U)F8($,Y,{get:U[Y],enumerable:!0,configurable:!0,set:E7.bind(U,Y)})};var iU=O7((hB,pU)=>{var A0=pU.exports={},i0,r0;function S8(){throw Error("setTimeout has not been defined")}function v8(){throw Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function")i0=setTimeout;else i0=S8}catch($){i0=S8}try{if(typeof clearTimeout==="function")r0=clearTimeout;else r0=v8}catch($){r0=v8}})();function mU($){if(i0===setTimeout)return setTimeout($,0);if((i0===S8||!i0)&&setTimeout)return i0=setTimeout,setTimeout($,0);try{return i0($,0)}catch(U){try{return i0.call(null,$,0)}catch(Y){return i0.call(this,$,0)}}}function Xq($){if(r0===clearTimeout)return clearTimeout($);if((r0===v8||!r0)&&clearTimeout)return r0=clearTimeout,clearTimeout($);try{return r0($)}catch(U){try{return r0.call(null,$)}catch(Y){return r0.call(this,$)}}}var X2=[],g2=!1,T2,O1=-1;function Vq(){if(!g2||!T2)return;if(g2=!1,T2.length)X2=T2.concat(X2);else O1=-1;if(X2.length)lU()}function lU(){if(g2)return;var $=mU(Vq);g2=!0;var U=X2.length;while(U){T2=X2,X2=[];while(++O11)for(var Y=1;Y"u")DU.global=globalThis;var a0=[],u0=[],N8="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(A2=0,AU=N8.length;A20)throw Error("Invalid string. Length must be a multiple of 4");var Y=$.indexOf("=");if(Y===-1)Y=U;var Z=Y===U?0:4-Y%4;return[Y,Z]}function _7($,U){return($+U)*3/4-U}function y7($){var U,Y=v7($),Z=Y[0],J=Y[1],G=new Uint8Array(_7(Z,J)),X=0,Q=J>0?Z-4:Z,B;for(B=0;B>16&255,G[X++]=U>>8&255,G[X++]=U&255;if(J===2)U=u0[$.charCodeAt(B)]<<2|u0[$.charCodeAt(B+1)]>>4,G[X++]=U&255;if(J===1)U=u0[$.charCodeAt(B)]<<10|u0[$.charCodeAt(B+1)]<<4|u0[$.charCodeAt(B+2)]>>2,G[X++]=U>>8&255,G[X++]=U&255;return G}function b7($){return a0[$>>18&63]+a0[$>>12&63]+a0[$>>6&63]+a0[$&63]}function g7($,U,Y){var Z,J=[];for(var G=U;GQ?Q:X+G));if(Z===1)U=$[Y-1],J.push(a0[U>>2]+a0[U<<4&63]+"==");else if(Z===2)U=($[Y-2]<<8)+$[Y-1],J.push(a0[U>>10]+a0[U>>4&63]+a0[U<<2&63]+"=");return J.join("")}function T1($,U,Y,Z,J){var G,X,Q=J*8-Z-1,B=(1<>1,z=-7,W=Y?J-1:0,k=Y?-1:1,D=$[U+W];W+=k,G=D&(1<<-z)-1,D>>=-z,z+=Q;for(;z>0;G=G*256+$[U+W],W+=k,z-=8);X=G&(1<<-z)-1,G>>=-z,z+=Z;for(;z>0;X=X*256+$[U+W],W+=k,z-=8);if(G===0)G=1-F;else if(G===B)return X?NaN:(D?-1:1)*(1/0);else X=X+Math.pow(2,Z),G=G-F;return(D?-1:1)*X*Math.pow(2,G-Z)}function EU($,U,Y,Z,J,G){var X,Q,B,F=G*8-J-1,z=(1<>1,k=J===23?Math.pow(2,-24)-Math.pow(2,-77):0,D=Z?0:G-1,C=Z?1:-1,H=U<0||U===0&&1/U<0?1:0;if(U=Math.abs(U),isNaN(U)||U===1/0)Q=isNaN(U)?1:0,X=z;else{if(X=Math.floor(Math.log(U)/Math.LN2),U*(B=Math.pow(2,-X))<1)X--,B*=2;if(X+W>=1)U+=k/B;else U+=k*Math.pow(2,1-W);if(U*B>=2)X++,B/=2;if(X+W>=z)Q=0,X=z;else if(X+W>=1)Q=(U*B-1)*Math.pow(2,J),X=X+W;else Q=U*Math.pow(2,W-1)*Math.pow(2,J),X=0}for(;J>=8;$[Y+D]=Q&255,D+=C,Q/=256,J-=8);X=X<0;$[Y+D]=X&255,D+=C,X/=256,F-=8);$[Y+D-C]|=H*128}var TU=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null,x7=50,R8=2147483647;var{btoa:EB,atob:SB,File:vB,Blob:_B}=globalThis;function q2($){if($>R8)throw RangeError('The value "'+$+'" is invalid for option "size"');let U=new Uint8Array($);return Object.setPrototypeOf(U,G0.prototype),U}function C8($,U,Y){return class extends Y{constructor(){super();Object.defineProperty(this,"message",{value:U.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${$}]`,this.stack,delete this.name}get code(){return $}set code(Z){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:Z,writable:!0})}toString(){return`${this.name} [${$}]: ${this.message}`}}}var f7=C8("ERR_BUFFER_OUT_OF_BOUNDS",function($){if($)return`${$} is outside of buffer bounds`;return"Attempt to access memory outside buffer bounds"},RangeError),h7=C8("ERR_INVALID_ARG_TYPE",function($,U){return`The "${$}" argument must be of type number. Received type ${typeof U}`},TypeError),D8=C8("ERR_OUT_OF_RANGE",function($,U,Y){let Z=`The value of "${$}" is out of range.`,J=Y;if(Number.isInteger(Y)&&Math.abs(Y)>4294967296)J=kU(String(Y));else if(typeof Y==="bigint"){if(J=String(Y),Y>BigInt(2)**BigInt(32)||Y<-(BigInt(2)**BigInt(32)))J=kU(J);J+="n"}return Z+=` It must be ${U}. Received ${J}`,Z},RangeError);function G0($,U,Y){if(typeof $==="number"){if(typeof U==="string")throw TypeError('The "string" argument must be of type string. Received type number');return O8($)}return SU($,U,Y)}Object.defineProperty(G0.prototype,"parent",{enumerable:!0,get:function(){if(!G0.isBuffer(this))return;return this.buffer}});Object.defineProperty(G0.prototype,"offset",{enumerable:!0,get:function(){if(!G0.isBuffer(this))return;return this.byteOffset}});G0.poolSize=8192;function SU($,U,Y){if(typeof $==="string")return d7($,U);if(ArrayBuffer.isView($))return c7($);if($==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof $);if(p0($,ArrayBuffer)||$&&p0($.buffer,ArrayBuffer))return P8($,U,Y);if(typeof SharedArrayBuffer<"u"&&(p0($,SharedArrayBuffer)||$&&p0($.buffer,SharedArrayBuffer)))return P8($,U,Y);if(typeof $==="number")throw TypeError('The "value" argument must not be of type number. Received type number');let Z=$.valueOf&&$.valueOf();if(Z!=null&&Z!==$)return G0.from(Z,U,Y);let J=m7($);if(J)return J;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof $[Symbol.toPrimitive]==="function")return G0.from($[Symbol.toPrimitive]("string"),U,Y);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof $)}G0.from=function($,U,Y){return SU($,U,Y)};Object.setPrototypeOf(G0.prototype,Uint8Array.prototype);Object.setPrototypeOf(G0,Uint8Array);function vU($){if(typeof $!=="number")throw TypeError('"size" argument must be of type number');else if($<0)throw RangeError('The value "'+$+'" is invalid for option "size"')}function u7($,U,Y){if(vU($),$<=0)return q2($);if(U!==void 0)return typeof Y==="string"?q2($).fill(U,Y):q2($).fill(U);return q2($)}G0.alloc=function($,U,Y){return u7($,U,Y)};function O8($){return vU($),q2($<0?0:k8($)|0)}G0.allocUnsafe=function($){return O8($)};G0.allocUnsafeSlow=function($){return O8($)};function d7($,U){if(typeof U!=="string"||U==="")U="utf8";if(!G0.isEncoding(U))throw TypeError("Unknown encoding: "+U);let Y=_U($,U)|0,Z=q2(Y),J=Z.write($,U);if(J!==Y)Z=Z.slice(0,J);return Z}function A8($){let U=$.length<0?0:k8($.length)|0,Y=q2(U);for(let Z=0;Z=R8)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+R8.toString(16)+" bytes");return $|0}G0.isBuffer=function($){return $!=null&&$._isBuffer===!0&&$!==G0.prototype};G0.compare=function($,U){if(p0($,Uint8Array))$=G0.from($,$.offset,$.byteLength);if(p0(U,Uint8Array))U=G0.from(U,U.offset,U.byteLength);if(!G0.isBuffer($)||!G0.isBuffer(U))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if($===U)return 0;let Y=$.length,Z=U.length;for(let J=0,G=Math.min(Y,Z);JZ.length){if(!G0.isBuffer(G))G=G0.from(G);G.copy(Z,J)}else Uint8Array.prototype.set.call(Z,G,J);else if(!G0.isBuffer(G))throw TypeError('"list" argument must be an Array of Buffers');else G.copy(Z,J);J+=G.length}return Z};function _U($,U){if(G0.isBuffer($))return $.length;if(ArrayBuffer.isView($)||p0($,ArrayBuffer))return $.byteLength;if(typeof $!=="string")throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof $);let Y=$.length,Z=arguments.length>2&&arguments[2]===!0;if(!Z&&Y===0)return 0;let J=!1;for(;;)switch(U){case"ascii":case"latin1":case"binary":return Y;case"utf8":case"utf-8":return T8($).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y*2;case"hex":return Y>>>1;case"base64":return cU($).length;default:if(J)return Z?-1:T8($).length;U=(""+U).toLowerCase(),J=!0}}G0.byteLength=_U;function l7($,U,Y){let Z=!1;if(U===void 0||U<0)U=0;if(U>this.length)return"";if(Y===void 0||Y>this.length)Y=this.length;if(Y<=0)return"";if(Y>>>=0,U>>>=0,Y<=U)return"";if(!$)$="utf8";while(!0)switch($){case"hex":return $q(this,U,Y);case"utf8":case"utf-8":return bU(this,U,Y);case"ascii":return t7(this,U,Y);case"latin1":case"binary":return e7(this,U,Y);case"base64":return n7(this,U,Y);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Uq(this,U,Y);default:if(Z)throw TypeError("Unknown encoding: "+$);$=($+"").toLowerCase(),Z=!0}}G0.prototype._isBuffer=!0;function P2($,U,Y){let Z=$[U];$[U]=$[Y],$[Y]=Z}G0.prototype.swap16=function(){let $=this.length;if($%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let U=0;U<$;U+=2)P2(this,U,U+1);return this};G0.prototype.swap32=function(){let $=this.length;if($%4!==0)throw RangeError("Buffer size must be a multiple of 32-bits");for(let U=0;U<$;U+=4)P2(this,U,U+3),P2(this,U+1,U+2);return this};G0.prototype.swap64=function(){let $=this.length;if($%8!==0)throw RangeError("Buffer size must be a multiple of 64-bits");for(let U=0;U<$;U+=8)P2(this,U,U+7),P2(this,U+1,U+6),P2(this,U+2,U+5),P2(this,U+3,U+4);return this};G0.prototype.toString=function(){let $=this.length;if($===0)return"";if(arguments.length===0)return bU(this,0,$);return l7.apply(this,arguments)};G0.prototype.toLocaleString=G0.prototype.toString;G0.prototype.equals=function($){if(!G0.isBuffer($))throw TypeError("Argument must be a Buffer");if(this===$)return!0;return G0.compare(this,$)===0};G0.prototype.inspect=function(){let $="",U=x7;if($=this.toString("hex",0,U).replace(/(.{2})/g,"$1 ").trim(),this.length>U)$+=" ... ";return""};if(TU)G0.prototype[TU]=G0.prototype.inspect;G0.prototype.compare=function($,U,Y,Z,J){if(p0($,Uint8Array))$=G0.from($,$.offset,$.byteLength);if(!G0.isBuffer($))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof $);if(U===void 0)U=0;if(Y===void 0)Y=$?$.length:0;if(Z===void 0)Z=0;if(J===void 0)J=this.length;if(U<0||Y>$.length||Z<0||J>this.length)throw RangeError("out of range index");if(Z>=J&&U>=Y)return 0;if(Z>=J)return-1;if(U>=Y)return 1;if(U>>>=0,Y>>>=0,Z>>>=0,J>>>=0,this===$)return 0;let G=J-Z,X=Y-U,Q=Math.min(G,X),B=this.slice(Z,J),F=$.slice(U,Y);for(let z=0;z2147483647)Y=2147483647;else if(Y<-2147483648)Y=-2147483648;if(Y=+Y,Number.isNaN(Y))Y=J?0:$.length-1;if(Y<0)Y=$.length+Y;if(Y>=$.length)if(J)return-1;else Y=$.length-1;else if(Y<0)if(J)Y=0;else return-1;if(typeof U==="string")U=G0.from(U,Z);if(G0.isBuffer(U)){if(U.length===0)return-1;return CU($,U,Y,Z,J)}else if(typeof U==="number"){if(U=U&255,typeof Uint8Array.prototype.indexOf==="function")if(J)return Uint8Array.prototype.indexOf.call($,U,Y);else return Uint8Array.prototype.lastIndexOf.call($,U,Y);return CU($,[U],Y,Z,J)}throw TypeError("val must be string, number or Buffer")}function CU($,U,Y,Z,J){let G=1,X=$.length,Q=U.length;if(Z!==void 0){if(Z=String(Z).toLowerCase(),Z==="ucs2"||Z==="ucs-2"||Z==="utf16le"||Z==="utf-16le"){if($.length<2||U.length<2)return-1;G=2,X/=2,Q/=2,Y/=2}}function B(z,W){if(G===1)return z[W];else return z.readUInt16BE(W*G)}let F;if(J){let z=-1;for(F=Y;FX)Y=X-Q;for(F=Y;F>=0;F--){let z=!0;for(let W=0;WJ)Z=J;let G=U.length;if(Z>G/2)Z=G/2;let X;for(X=0;X>>0,isFinite(Y)){if(Y=Y>>>0,Z===void 0)Z="utf8"}else Z=Y,Y=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let J=this.length-U;if(Y===void 0||Y>J)Y=J;if($.length>0&&(Y<0||U<0)||U>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!Z)Z="utf8";let G=!1;for(;;)switch(Z){case"hex":return a7(this,$,U,Y);case"utf8":case"utf-8":return p7(this,$,U,Y);case"ascii":case"latin1":case"binary":return i7(this,$,U,Y);case"base64":return r7(this,$,U,Y);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s7(this,$,U,Y);default:if(G)throw TypeError("Unknown encoding: "+Z);Z=(""+Z).toLowerCase(),G=!0}};G0.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function n7($,U,Y){if(U===0&&Y===$.length)return PU($);else return PU($.slice(U,Y))}function bU($,U,Y){Y=Math.min($.length,Y);let Z=[],J=U;while(J239?4:G>223?3:G>191?2:1;if(J+Q<=Y){let B,F,z,W;switch(Q){case 1:if(G<128)X=G;break;case 2:if(B=$[J+1],(B&192)===128){if(W=(G&31)<<6|B&63,W>127)X=W}break;case 3:if(B=$[J+1],F=$[J+2],(B&192)===128&&(F&192)===128){if(W=(G&15)<<12|(B&63)<<6|F&63,W>2047&&(W<55296||W>57343))X=W}break;case 4:if(B=$[J+1],F=$[J+2],z=$[J+3],(B&192)===128&&(F&192)===128&&(z&192)===128){if(W=(G&15)<<18|(B&63)<<12|(F&63)<<6|z&63,W>65535&&W<1114112)X=W}}}if(X===null)X=65533,Q=1;else if(X>65535)X-=65536,Z.push(X>>>10&1023|55296),X=56320|X&1023;Z.push(X),J+=Q}return o7(Z)}var OU=4096;function o7($){let U=$.length;if(U<=OU)return String.fromCharCode.apply(String,$);let Y="",Z=0;while(ZZ)Y=Z;let J="";for(let G=U;GY)$=Y;if(U<0){if(U+=Y,U<0)U=0}else if(U>Y)U=Y;if(U<$)U=$;let Z=this.subarray($,U);return Object.setPrototypeOf(Z,G0.prototype),Z};function E0($,U,Y){if($%1!==0||$<0)throw RangeError("offset is not uint");if($+U>Y)throw RangeError("Trying to access beyond buffer length")}G0.prototype.readUintLE=G0.prototype.readUIntLE=function($,U,Y){if($=$>>>0,U=U>>>0,!Y)E0($,U,this.length);let Z=this[$],J=1,G=0;while(++G>>0,U=U>>>0,!Y)E0($,U,this.length);let Z=this[$+--U],J=1;while(U>0&&(J*=256))Z+=this[$+--U]*J;return Z};G0.prototype.readUint8=G0.prototype.readUInt8=function($,U){if($=$>>>0,!U)E0($,1,this.length);return this[$]};G0.prototype.readUint16LE=G0.prototype.readUInt16LE=function($,U){if($=$>>>0,!U)E0($,2,this.length);return this[$]|this[$+1]<<8};G0.prototype.readUint16BE=G0.prototype.readUInt16BE=function($,U){if($=$>>>0,!U)E0($,2,this.length);return this[$]<<8|this[$+1]};G0.prototype.readUint32LE=G0.prototype.readUInt32LE=function($,U){if($=$>>>0,!U)E0($,4,this.length);return(this[$]|this[$+1]<<8|this[$+2]<<16)+this[$+3]*16777216};G0.prototype.readUint32BE=G0.prototype.readUInt32BE=function($,U){if($=$>>>0,!U)E0($,4,this.length);return this[$]*16777216+(this[$+1]<<16|this[$+2]<<8|this[$+3])};G0.prototype.readBigUInt64LE=z2(function($){$=$>>>0,b2($,"offset");let U=this[$],Y=this[$+7];if(U===void 0||Y===void 0)$1($,this.length-8);let Z=U+this[++$]*256+this[++$]*65536+this[++$]*16777216,J=this[++$]+this[++$]*256+this[++$]*65536+Y*16777216;return BigInt(Z)+(BigInt(J)<>>0,b2($,"offset");let U=this[$],Y=this[$+7];if(U===void 0||Y===void 0)$1($,this.length-8);let Z=U*16777216+this[++$]*65536+this[++$]*256+this[++$],J=this[++$]*16777216+this[++$]*65536+this[++$]*256+Y;return(BigInt(Z)<>>0,U=U>>>0,!Y)E0($,U,this.length);let Z=this[$],J=1,G=0;while(++G=J)Z-=Math.pow(2,8*U);return Z};G0.prototype.readIntBE=function($,U,Y){if($=$>>>0,U=U>>>0,!Y)E0($,U,this.length);let Z=U,J=1,G=this[$+--Z];while(Z>0&&(J*=256))G+=this[$+--Z]*J;if(J*=128,G>=J)G-=Math.pow(2,8*U);return G};G0.prototype.readInt8=function($,U){if($=$>>>0,!U)E0($,1,this.length);if(!(this[$]&128))return this[$];return(255-this[$]+1)*-1};G0.prototype.readInt16LE=function($,U){if($=$>>>0,!U)E0($,2,this.length);let Y=this[$]|this[$+1]<<8;return Y&32768?Y|4294901760:Y};G0.prototype.readInt16BE=function($,U){if($=$>>>0,!U)E0($,2,this.length);let Y=this[$+1]|this[$]<<8;return Y&32768?Y|4294901760:Y};G0.prototype.readInt32LE=function($,U){if($=$>>>0,!U)E0($,4,this.length);return this[$]|this[$+1]<<8|this[$+2]<<16|this[$+3]<<24};G0.prototype.readInt32BE=function($,U){if($=$>>>0,!U)E0($,4,this.length);return this[$]<<24|this[$+1]<<16|this[$+2]<<8|this[$+3]};G0.prototype.readBigInt64LE=z2(function($){$=$>>>0,b2($,"offset");let U=this[$],Y=this[$+7];if(U===void 0||Y===void 0)$1($,this.length-8);let Z=this[$+4]+this[$+5]*256+this[$+6]*65536+(Y<<24);return(BigInt(Z)<>>0,b2($,"offset");let U=this[$],Y=this[$+7];if(U===void 0||Y===void 0)$1($,this.length-8);let Z=(U<<24)+this[++$]*65536+this[++$]*256+this[++$];return(BigInt(Z)<>>0,!U)E0($,4,this.length);return T1(this,$,!0,23,4)};G0.prototype.readFloatBE=function($,U){if($=$>>>0,!U)E0($,4,this.length);return T1(this,$,!1,23,4)};G0.prototype.readDoubleLE=function($,U){if($=$>>>0,!U)E0($,8,this.length);return T1(this,$,!0,52,8)};G0.prototype.readDoubleBE=function($,U){if($=$>>>0,!U)E0($,8,this.length);return T1(this,$,!1,52,8)};function b0($,U,Y,Z,J,G){if(!G0.isBuffer($))throw TypeError('"buffer" argument must be a Buffer instance');if(U>J||U$.length)throw RangeError("Index out of range")}G0.prototype.writeUintLE=G0.prototype.writeUIntLE=function($,U,Y,Z){if($=+$,U=U>>>0,Y=Y>>>0,!Z){let X=Math.pow(2,8*Y)-1;b0(this,$,U,Y,X,0)}let J=1,G=0;this[U]=$&255;while(++G>>0,Y=Y>>>0,!Z){let X=Math.pow(2,8*Y)-1;b0(this,$,U,Y,X,0)}let J=Y-1,G=1;this[U+J]=$&255;while(--J>=0&&(G*=256))this[U+J]=$/G&255;return U+Y};G0.prototype.writeUint8=G0.prototype.writeUInt8=function($,U,Y){if($=+$,U=U>>>0,!Y)b0(this,$,U,1,255,0);return this[U]=$&255,U+1};G0.prototype.writeUint16LE=G0.prototype.writeUInt16LE=function($,U,Y){if($=+$,U=U>>>0,!Y)b0(this,$,U,2,65535,0);return this[U]=$&255,this[U+1]=$>>>8,U+2};G0.prototype.writeUint16BE=G0.prototype.writeUInt16BE=function($,U,Y){if($=+$,U=U>>>0,!Y)b0(this,$,U,2,65535,0);return this[U]=$>>>8,this[U+1]=$&255,U+2};G0.prototype.writeUint32LE=G0.prototype.writeUInt32LE=function($,U,Y){if($=+$,U=U>>>0,!Y)b0(this,$,U,4,4294967295,0);return this[U+3]=$>>>24,this[U+2]=$>>>16,this[U+1]=$>>>8,this[U]=$&255,U+4};G0.prototype.writeUint32BE=G0.prototype.writeUInt32BE=function($,U,Y){if($=+$,U=U>>>0,!Y)b0(this,$,U,4,4294967295,0);return this[U]=$>>>24,this[U+1]=$>>>16,this[U+2]=$>>>8,this[U+3]=$&255,U+4};function gU($,U,Y,Z,J){dU(U,Z,J,$,Y,7);let G=Number(U&BigInt(4294967295));$[Y++]=G,G=G>>8,$[Y++]=G,G=G>>8,$[Y++]=G,G=G>>8,$[Y++]=G;let X=Number(U>>BigInt(32)&BigInt(4294967295));return $[Y++]=X,X=X>>8,$[Y++]=X,X=X>>8,$[Y++]=X,X=X>>8,$[Y++]=X,Y}function xU($,U,Y,Z,J){dU(U,Z,J,$,Y,7);let G=Number(U&BigInt(4294967295));$[Y+7]=G,G=G>>8,$[Y+6]=G,G=G>>8,$[Y+5]=G,G=G>>8,$[Y+4]=G;let X=Number(U>>BigInt(32)&BigInt(4294967295));return $[Y+3]=X,X=X>>8,$[Y+2]=X,X=X>>8,$[Y+1]=X,X=X>>8,$[Y]=X,Y+8}G0.prototype.writeBigUInt64LE=z2(function($,U=0){return gU(this,$,U,BigInt(0),BigInt("0xffffffffffffffff"))});G0.prototype.writeBigUInt64BE=z2(function($,U=0){return xU(this,$,U,BigInt(0),BigInt("0xffffffffffffffff"))});G0.prototype.writeIntLE=function($,U,Y,Z){if($=+$,U=U>>>0,!Z){let Q=Math.pow(2,8*Y-1);b0(this,$,U,Y,Q-1,-Q)}let J=0,G=1,X=0;this[U]=$&255;while(++J>0)-X&255}return U+Y};G0.prototype.writeIntBE=function($,U,Y,Z){if($=+$,U=U>>>0,!Z){let Q=Math.pow(2,8*Y-1);b0(this,$,U,Y,Q-1,-Q)}let J=Y-1,G=1,X=0;this[U+J]=$&255;while(--J>=0&&(G*=256)){if($<0&&X===0&&this[U+J+1]!==0)X=1;this[U+J]=($/G>>0)-X&255}return U+Y};G0.prototype.writeInt8=function($,U,Y){if($=+$,U=U>>>0,!Y)b0(this,$,U,1,127,-128);if($<0)$=255+$+1;return this[U]=$&255,U+1};G0.prototype.writeInt16LE=function($,U,Y){if($=+$,U=U>>>0,!Y)b0(this,$,U,2,32767,-32768);return this[U]=$&255,this[U+1]=$>>>8,U+2};G0.prototype.writeInt16BE=function($,U,Y){if($=+$,U=U>>>0,!Y)b0(this,$,U,2,32767,-32768);return this[U]=$>>>8,this[U+1]=$&255,U+2};G0.prototype.writeInt32LE=function($,U,Y){if($=+$,U=U>>>0,!Y)b0(this,$,U,4,2147483647,-2147483648);return this[U]=$&255,this[U+1]=$>>>8,this[U+2]=$>>>16,this[U+3]=$>>>24,U+4};G0.prototype.writeInt32BE=function($,U,Y){if($=+$,U=U>>>0,!Y)b0(this,$,U,4,2147483647,-2147483648);if($<0)$=4294967295+$+1;return this[U]=$>>>24,this[U+1]=$>>>16,this[U+2]=$>>>8,this[U+3]=$&255,U+4};G0.prototype.writeBigInt64LE=z2(function($,U=0){return gU(this,$,U,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});G0.prototype.writeBigInt64BE=z2(function($,U=0){return xU(this,$,U,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function fU($,U,Y,Z,J,G){if(Y+Z>$.length)throw RangeError("Index out of range");if(Y<0)throw RangeError("Index out of range")}function hU($,U,Y,Z,J){if(U=+U,Y=Y>>>0,!J)fU($,U,Y,4,340282346638528860000000000000000000000,-340282346638528860000000000000000000000);return EU($,U,Y,Z,23,4),Y+4}G0.prototype.writeFloatLE=function($,U,Y){return hU(this,$,U,!0,Y)};G0.prototype.writeFloatBE=function($,U,Y){return hU(this,$,U,!1,Y)};function uU($,U,Y,Z,J){if(U=+U,Y=Y>>>0,!J)fU($,U,Y,8,179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);return EU($,U,Y,Z,52,8),Y+8}G0.prototype.writeDoubleLE=function($,U,Y){return uU(this,$,U,!0,Y)};G0.prototype.writeDoubleBE=function($,U,Y){return uU(this,$,U,!1,Y)};G0.prototype.copy=function($,U,Y,Z){if(!G0.isBuffer($))throw TypeError("argument should be a Buffer");if(!Y)Y=0;if(!Z&&Z!==0)Z=this.length;if(U>=$.length)U=$.length;if(!U)U=0;if(Z>0&&Z=this.length)throw RangeError("Index out of range");if(Z<0)throw RangeError("sourceEnd out of bounds");if(Z>this.length)Z=this.length;if($.length-U>>0,Y=Y===void 0?this.length:Y>>>0,!$)$=0;let J;if(typeof $==="number")for(J=U;J=Z+4;Y-=3)U=`_${$.slice(Y-3,Y)}${U}`;return`${$.slice(0,Y)}${U}`}function Yq($,U,Y){if(b2(U,"offset"),$[U]===void 0||$[U+Y]===void 0)$1(U,$.length-(Y+1))}function dU($,U,Y,Z,J,G){if($>Y||$3)if(U===0||U===BigInt(0))Q=`>= 0${X} and < 2${X} ** ${(G+1)*8}${X}`;else Q=`>= -(2${X} ** ${(G+1)*8-1}${X}) and < 2 ** ${(G+1)*8-1}${X}`;else Q=`>= ${U}${X} and <= ${Y}${X}`;throw new D8("value",Q,$)}Yq(Z,J,G)}function b2($,U){if(typeof $!=="number")throw new h7(U,"number",$)}function $1($,U,Y){if(Math.floor($)!==$)throw b2($,Y),new D8(Y||"offset","an integer",$);if(U<0)throw new f7;throw new D8(Y||"offset",`>= ${Y?1:0} and <= ${U}`,$)}var Zq=/[^+/0-9A-Za-z-_]/g;function Qq($){if($=$.split("=")[0],$=$.trim().replace(Zq,""),$.length<2)return"";while($.length%4!==0)$=$+"=";return $}function T8($,U){U=U||1/0;let Y,Z=$.length,J=null,G=[];for(let X=0;X55295&&Y<57344){if(!J){if(Y>56319){if((U-=3)>-1)G.push(239,191,189);continue}else if(X+1===Z){if((U-=3)>-1)G.push(239,191,189);continue}J=Y;continue}if(Y<56320){if((U-=3)>-1)G.push(239,191,189);J=Y;continue}Y=(J-55296<<10|Y-56320)+65536}else if(J){if((U-=3)>-1)G.push(239,191,189)}if(J=null,Y<128){if((U-=1)<0)break;G.push(Y)}else if(Y<2048){if((U-=2)<0)break;G.push(Y>>6|192,Y&63|128)}else if(Y<65536){if((U-=3)<0)break;G.push(Y>>12|224,Y>>6&63|128,Y&63|128)}else if(Y<1114112){if((U-=4)<0)break;G.push(Y>>18|240,Y>>12&63|128,Y>>6&63|128,Y&63|128)}else throw Error("Invalid code point")}return G}function Jq($){let U=[];for(let Y=0;Y<$.length;++Y)U.push($.charCodeAt(Y)&255);return U}function Gq($,U){let Y,Z,J,G=[];for(let X=0;X<$.length;++X){if((U-=2)<0)break;Y=$.charCodeAt(X),Z=Y>>8,J=Y%256,G.push(J),G.push(Z)}return G}function cU($){return y7(Qq($))}function C1($,U,Y,Z){let J;for(J=0;J=U.length||J>=$.length)break;U[J+Y]=$[J]}return J}function p0($,U){return $ instanceof U||$!=null&&$.constructor!=null&&$.constructor.name!=null&&$.constructor.name===U.name}var Kq=function(){let $=Array(256);for(let U=0;U<16;++U){let Y=U*16;for(let Z=0;Z<16;++Z)$[Y+Z]="0123456789abcdef"[U]+"0123456789abcdef"[Z]}return $}();function z2($){return typeof BigInt>"u"?qq:$}function qq(){throw Error("BigInt not supported")}function E8($){return()=>{throw Error($+" is not implemented for node:buffer browser polyfill")}}var yB=E8("resolveObjectURL"),bB=E8("isUtf8");var gB=E8("transcode");var OB=C7(iU(),1);var FU={};S7(FU,{unsignedDecimalNumber:()=>W1,universalMeasureValue:()=>H1,uniqueUuid:()=>tQ,uniqueNumericIdCreator:()=>N1,uniqueId:()=>R1,uCharHexNumber:()=>D9,twipsMeasureValue:()=>T0,standardizeData:()=>mJ,signedTwipsMeasureValue:()=>e0,signedHpsMeasureValue:()=>LX,shortHexNumber:()=>DQ,sectionPageSizeDefaults:()=>h1,sectionMarginDefaults:()=>F2,positiveUniversalMeasureValue:()=>r9,pointMeasureValue:()=>CQ,percentageValue:()=>PQ,patchDocument:()=>AB,patchDetector:()=>TB,measurementOrPercentValue:()=>s9,longHexNumber:()=>BX,hpsMeasureValue:()=>AQ,hexColorValue:()=>S2,hashedId:()=>A9,encodeUtf8:()=>X1,eighthPointMeasureValue:()=>TQ,docPropertiesUniqueNumericIdGen:()=>nQ,decimalNumber:()=>S0,dateTimeValue:()=>OQ,createWrapTopAndBottom:()=>bJ,createWrapTight:()=>yJ,createWrapSquare:()=>_J,createWrapNone:()=>C9,createVerticalPosition:()=>JJ,createVerticalAlign:()=>f$,createUnderline:()=>mQ,createTransformation:()=>B$,createTableWidthElement:()=>M1,createTableRowHeight:()=>EK,createTableLook:()=>CK,createTableLayout:()=>PK,createTableFloatProperties:()=>AK,createTabStopItem:()=>PG,createTabStop:()=>TG,createStringElement:()=>u2,createSpacing:()=>AG,createSimplePos:()=>UJ,createShading:()=>j1,createSectionType:()=>nK,createRunFonts:()=>g1,createParagraphStyle:()=>K1,createPageSize:()=>rK,createPageNumberType:()=>iK,createPageMargin:()=>pK,createOutlineLevel:()=>yG,createMathSuperScriptProperties:()=>iG,createMathSuperScriptElement:()=>n2,createMathSubSuperScriptProperties:()=>oG,createMathSubScriptProperties:()=>sG,createMathSubScriptElement:()=>s2,createMathPreSubSuperScriptProperties:()=>eG,createMathNAryProperties:()=>T$,createMathLimitLocation:()=>cG,createMathBase:()=>y0,createMathAccentCharacter:()=>dG,createLineNumberType:()=>aK,createIndent:()=>EQ,createHorizontalPosition:()=>QJ,createHeaderFooterReference:()=>f1,createFrameProperties:()=>xG,createEmphasisMark:()=>Y$,createDotEmphasisMark:()=>HX,createDocumentGrid:()=>lK,createColumns:()=>mK,createBorderElement:()=>N0,createBodyProperties:()=>KJ,createAlignment:()=>n9,convertToXmlComponent:()=>U8,convertMillimetersToTwip:()=>bX,convertInchesToTwip:()=>d0,concreteNumUniqueNumericIdGen:()=>sQ,bookmarkUniqueNumericIdGen:()=>oQ,abstractNumUniqueNumericIdGen:()=>rQ,YearShort:()=>qG,YearLong:()=>BG,XmlComponent:()=>o,XmlAttributeComponent:()=>I0,WpsShapeRun:()=>aJ,WpgGroupRun:()=>pJ,WidthType:()=>l1,WORKAROUND4:()=>HV,WORKAROUND3:()=>VX,WORKAROUND2:()=>lV,VerticalPositionRelativeFrom:()=>$J,VerticalPositionAlign:()=>IX,VerticalMergeType:()=>d$,VerticalMergeRevisionType:()=>NV,VerticalMerge:()=>a1,VerticalAnchor:()=>GJ,VerticalAlignTable:()=>HK,VerticalAlignSection:()=>jK,VerticalAlign:()=>RV,UnderlineType:()=>Z$,ThematicBreak:()=>t9,Textbox:()=>G7,TextWrappingType:()=>G1,TextWrappingSide:()=>vJ,TextRun:()=>p2,TextEffect:()=>NX,TextDirection:()=>PV,TableRowPropertiesChange:()=>l$,TableRowProperties:()=>M8,TableRow:()=>SK,TableProperties:()=>L8,TableOfContents:()=>e5,TableLayoutType:()=>SV,TableCellBorders:()=>h$,TableCell:()=>V8,TableBorders:()=>B8,TableAnchorType:()=>TV,Table:()=>kK,TabStopType:()=>O9,TabStopPosition:()=>ZV,Tab:()=>w$,TDirection:()=>c$,SymbolRun:()=>G$,Styles:()=>B1,StyleLevel:()=>$7,StyleForParagraph:()=>y2,StyleForCharacter:()=>D2,StringValueElement:()=>Y2,StringEnumValueElement:()=>kQ,StringContainer:()=>L2,SpaceType:()=>g0,SoftHyphen:()=>JG,SimpleMailMergeField:()=>nJ,SimpleField:()=>J8,ShadingType:()=>WX,SequentialIdentifier:()=>rJ,Separator:()=>IG,SectionType:()=>dV,SectionPropertiesChange:()=>i$,SectionProperties:()=>I8,RunPropertiesDefaults:()=>XU,RunPropertiesChange:()=>J$,RunProperties:()=>J2,Run:()=>C0,RelativeVerticalPosition:()=>OV,RelativeHorizontalPosition:()=>CV,PrettifyType:()=>X7,PositionalTabRelativeTo:()=>eX,PositionalTabLeader:()=>$V,PositionalTabAlignment:()=>tX,PositionalTab:()=>FG,PatchType:()=>y9,ParagraphRunProperties:()=>Q$,ParagraphPropertiesDefaults:()=>qU,ParagraphPropertiesChange:()=>D$,ParagraphProperties:()=>Z2,Paragraph:()=>h0,PageTextDirectionType:()=>uV,PageTextDirection:()=>p$,PageReference:()=>gG,PageOrientation:()=>i1,PageNumberSeparator:()=>hV,PageNumberElement:()=>WG,PageNumber:()=>N2,PageBreakBefore:()=>H$,PageBreak:()=>RG,PageBorders:()=>a$,PageBorderZOrder:()=>fV,PageBorderOffsetFrom:()=>xV,PageBorderDisplay:()=>gV,Packer:()=>qB,OverlapType:()=>kV,OnOffElement:()=>X0,Numbering:()=>JU,NumberedItemReferenceFormat:()=>vG,NumberedItemReference:()=>_G,NumberValueElement:()=>k2,NumberProperties:()=>V1,NumberFormat:()=>wX,NoBreakHyphen:()=>QG,NextAttributeComponent:()=>n1,MonthShort:()=>KG,MonthLong:()=>VG,Media:()=>w8,MathSuperScript:()=>rG,MathSum:()=>mG,MathSubSuperScript:()=>tG,MathSubScript:()=>nG,MathSquareBrackets:()=>GK,MathRun:()=>hG,MathRoundBrackets:()=>JK,MathRadicalProperties:()=>O$,MathRadical:()=>ZK,MathPreSubSuperScript:()=>$K,MathNumerator:()=>P$,MathLimitUpper:()=>aG,MathLimitLower:()=>pG,MathLimit:()=>q8,MathIntegral:()=>lG,MathFunctionProperties:()=>E$,MathFunctionName:()=>k$,MathFunction:()=>QK,MathFraction:()=>uG,MathDenominator:()=>A$,MathDegree:()=>C$,MathCurlyBrackets:()=>KK,MathAngledBrackets:()=>qK,Math:()=>IV,LineRuleType:()=>v2,LineNumberRestartFormat:()=>bV,LevelSuffix:()=>aV,LevelOverride:()=>QU,LevelFormat:()=>n0,LevelForOverride:()=>F5,LevelBase:()=>W8,Level:()=>ZU,LeaderType:()=>YV,LastRenderedPageBreak:()=>jG,InternalHyperlink:()=>j$,InsertedTextRun:()=>BK,InsertedTableRow:()=>v$,InsertedTableCell:()=>y$,InitializableXmlComponent:()=>Y8,ImportedXmlComponent:()=>p9,ImportedRootElementAttributes:()=>i9,ImageRun:()=>lJ,IgnoreIfEmptyXmlComponent:()=>Q2,HyperlinkType:()=>QV,HpsMeasureElement:()=>q1,HorizontalPositionRelativeFrom:()=>eQ,HorizontalPositionAlign:()=>MX,HighlightColor:()=>RX,HeightRule:()=>_V,HeadingLevel:()=>UV,HeaderWrapper:()=>YU,HeaderFooterType:()=>S9,HeaderFooterReferenceType:()=>E2,Header:()=>U7,GridSpan:()=>u$,FrameWrap:()=>MV,FrameAnchorType:()=>LV,FootnoteReferenceRun:()=>Z7,FootnoteReferenceElement:()=>MG,FootnoteReference:()=>IU,FooterWrapper:()=>$U,Footer:()=>Y7,FootNotes:()=>UU,FootNoteReferenceRunAttributes:()=>MU,FileChild:()=>r2,File:()=>o5,ExternalHyperlink:()=>K8,Endnotes:()=>e$,EndnoteReferenceRunAttributes:()=>wU,EndnoteReferenceRun:()=>Q7,EndnoteReference:()=>I$,EndnoteIdReference:()=>WU,EmptyElement:()=>k0,EmphasisMarkType:()=>U$,EMPTY_OBJECT:()=>tZ,DropCapType:()=>BV,Drawing:()=>D1,DocumentGridType:()=>yV,DocumentDefaults:()=>VU,DocumentBackgroundAttributes:()=>s$,DocumentBackground:()=>n$,DocumentAttributes:()=>o2,DocumentAttributeNamespaces:()=>p1,Document:()=>o5,DeletedTextRun:()=>wK,DeletedTableRow:()=>_$,DeletedTableCell:()=>b$,DayShort:()=>GG,DayLong:()=>XG,ContinuationSeparator:()=>wG,ConcreteNumbering:()=>s1,ConcreteHyperlink:()=>_2,Comments:()=>M$,CommentReference:()=>ZG,CommentRangeStart:()=>UG,CommentRangeEnd:()=>YG,Comment:()=>L$,ColumnBreak:()=>DG,Column:()=>tK,CheckBoxUtil:()=>HU,CheckBoxSymbolElement:()=>L1,CheckBox:()=>J7,CharacterSet:()=>GV,CellMergeAttributes:()=>g$,CellMerge:()=>x$,CarriageReturn:()=>HG,BuilderElement:()=>B0,BorderStyle:()=>Q8,Border:()=>o9,BookmarkStart:()=>F$,BookmarkEnd:()=>N$,Bookmark:()=>z$,Body:()=>r$,BaseXmlComponent:()=>m2,Attributes:()=>O0,AnnotationReference:()=>LG,AlignmentType:()=>m0,AbstractNumbering:()=>r1});var{defineProperty:Bq,defineProperties:Lq,getOwnPropertyDescriptors:Mq,getOwnPropertySymbols:m1}=Object,sZ=Object.prototype.hasOwnProperty,nZ=Object.prototype.propertyIsEnumerable,z9=($,U,Y)=>(U in $)?Bq($,U,{enumerable:!0,configurable:!0,writable:!0,value:Y}):$[U]=Y,W0=($,U)=>{for(var Y in U||(U={}))if(sZ.call(U,Y))z9($,Y,U[Y]);if(m1){for(var Y of m1(U))if(nZ.call(U,Y))z9($,Y,U[Y])}return $},R0=($,U)=>Lq($,Mq(U)),oZ=($,U)=>{var Y={};for(var Z in $)if(sZ.call($,Z)&&U.indexOf(Z)<0)Y[Z]=$[Z];if($!=null&&m1){for(var Z of m1($))if(U.indexOf(Z)<0&&nZ.call($,Z))Y[Z]=$[Z]}return Y},Y0=($,U,Y)=>z9($,typeof U!=="symbol"?U+"":U,Y),b9=($,U,Y)=>{return new Promise((Z,J)=>{var G=(B)=>{try{Q(Y.next(B))}catch(F){J(F)}},X=(B)=>{try{Q(Y.throw(B))}catch(F){J(F)}},Q=(B)=>B.done?Z(B.value):Promise.resolve(B.value).then(G,X);Q((Y=Y.apply($,U)).next())})};class m2{constructor($){Y0(this,"rootKey"),this.rootKey=$}}var tZ=Object.seal({});class o extends m2{constructor($){super($);Y0(this,"root"),this.root=[]}prepForXml($){var U;$.stack.push(this);let Y=this.root.map((Z)=>{if(Z instanceof m2)return Z.prepForXml($);return Z}).filter((Z)=>Z!==void 0);return $.stack.pop(),{[this.rootKey]:Y.length?Y.length===1&&((U=Y[0])==null?void 0:U._attr)?Y[0]:Y:tZ}}addChildElement($){return this.root.push($),this}}class Q2 extends o{constructor($,U){super($);Y0(this,"includeIfEmpty"),this.includeIfEmpty=U}prepForXml($){let U=super.prepForXml($);if(this.includeIfEmpty)return U;if(U&&(typeof U[this.rootKey]!=="object"||Object.keys(U[this.rootKey]).length))return U;return}}class I0 extends m2{constructor($){super("_attr");Y0(this,"xmlKeys"),this.root=$}prepForXml($){let U={};return Object.entries(this.root).forEach(([Y,Z])=>{if(Z!==void 0){let J=this.xmlKeys&&this.xmlKeys[Y]||Y;U[J]=Z}}),{_attr:U}}}class n1 extends m2{constructor($){super("_attr");this.root=$}prepForXml($){return{_attr:Object.values(this.root).filter(({value:Y})=>Y!==void 0).reduce((Y,{key:Z,value:J})=>R0(W0({},Y),{[Z]:J}),{})}}}class O0 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{val:"w:val",color:"w:color",fill:"w:fill",space:"w:space",sz:"w:sz",type:"w:type",rsidR:"w:rsidR",rsidRPr:"w:rsidRPr",rsidSect:"w:rsidSect",w:"w:w",h:"w:h",top:"w:top",right:"w:right",bottom:"w:bottom",left:"w:left",header:"w:header",footer:"w:footer",gutter:"w:gutter",linePitch:"w:linePitch",pos:"w:pos"})}}var c0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function g9($){return $&&$.__esModule&&Object.prototype.hasOwnProperty.call($,"default")?$.default:$}var _8={},k1={exports:{}},rU;function x9(){if(rU)return k1.exports;rU=1;var $=typeof Reflect==="object"?Reflect:null,U=$&&typeof $.apply==="function"?$.apply:function(A,y,g){return Function.prototype.apply.call(A,y,g)},Y;if($&&typeof $.ownKeys==="function")Y=$.ownKeys;else if(Object.getOwnPropertySymbols)Y=function(A){return Object.getOwnPropertyNames(A).concat(Object.getOwnPropertySymbols(A))};else Y=function(A){return Object.getOwnPropertyNames(A)};function Z(L){if(console&&console.warn)console.warn(L)}var J=Number.isNaN||function(A){return A!==A};function G(){G.init.call(this)}k1.exports=G,k1.exports.once=V,G.EventEmitter=G,G.prototype._events=void 0,G.prototype._eventsCount=0,G.prototype._maxListeners=void 0;var X=10;function Q(L){if(typeof L!=="function")throw TypeError('The "listener" argument must be of type Function. Received type '+typeof L)}Object.defineProperty(G,"defaultMaxListeners",{enumerable:!0,get:function(){return X},set:function(L){if(typeof L!=="number"||L<0||J(L))throw RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+L+".");X=L}}),G.init=function(){if(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)this._events=Object.create(null),this._eventsCount=0;this._maxListeners=this._maxListeners||void 0},G.prototype.setMaxListeners=function(A){if(typeof A!=="number"||A<0||J(A))throw RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+A+".");return this._maxListeners=A,this};function B(L){if(L._maxListeners===void 0)return G.defaultMaxListeners;return L._maxListeners}G.prototype.getMaxListeners=function(){return B(this)},G.prototype.emit=function(A){var y=[];for(var g=1;g0)s=y[0];if(s instanceof Error)throw s;var V0=Error("Unhandled error."+(s?" ("+s.message+")":""));throw V0.context=s,V0}var S=E[A];if(S===void 0)return!1;if(typeof S==="function")U(S,this,y);else{var h=S.length,N=C(S,h);for(var g=0;g0&&s.length>d&&!s.warned){s.warned=!0;var V0=Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(A)+" listeners added. Use emitter.setMaxListeners() to increase limit");V0.name="MaxListenersExceededWarning",V0.emitter=L,V0.type=A,V0.count=s.length,Z(V0)}}return L}G.prototype.addListener=function(A,y){return F(this,A,y,!1)},G.prototype.on=G.prototype.addListener,G.prototype.prependListener=function(A,y){return F(this,A,y,!0)};function z(){if(!this.fired){if(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0)return this.listener.call(this.target);return this.listener.apply(this.target,arguments)}}function W(L,A,y){var g={fired:!1,wrapFn:void 0,target:L,type:A,listener:y},d=z.bind(g);return d.listener=y,g.wrapFn=d,d}G.prototype.once=function(A,y){return Q(y),this.on(A,W(this,A,y)),this},G.prototype.prependOnceListener=function(A,y){return Q(y),this.prependListener(A,W(this,A,y)),this},G.prototype.removeListener=function(A,y){var g,d,E,s,V0;if(Q(y),d=this._events,d===void 0)return this;if(g=d[A],g===void 0)return this;if(g===y||g.listener===y){if(--this._eventsCount===0)this._events=Object.create(null);else if(delete d[A],d.removeListener)this.emit("removeListener",A,g.listener||y)}else if(typeof g!=="function"){E=-1;for(s=g.length-1;s>=0;s--)if(g[s]===y||g[s].listener===y){V0=g[s].listener,E=s;break}if(E<0)return this;if(E===0)g.shift();else H(g,E);if(g.length===1)d[A]=g[0];if(d.removeListener!==void 0)this.emit("removeListener",A,V0||y)}return this},G.prototype.off=G.prototype.removeListener,G.prototype.removeAllListeners=function(A){var y,g,d;if(g=this._events,g===void 0)return this;if(g.removeListener===void 0){if(arguments.length===0)this._events=Object.create(null),this._eventsCount=0;else if(g[A]!==void 0)if(--this._eventsCount===0)this._events=Object.create(null);else delete g[A];return this}if(arguments.length===0){var E=Object.keys(g),s;for(d=0;d=0;d--)this.removeListener(A,y[d]);return this};function k(L,A,y){var g=L._events;if(g===void 0)return[];var d=g[A];if(d===void 0)return[];if(typeof d==="function")return y?[d.listener||d]:[d];return y?O(d):C(d,d.length)}G.prototype.listeners=function(A){return k(this,A,!0)},G.prototype.rawListeners=function(A){return k(this,A,!1)},G.listenerCount=function(L,A){if(typeof L.listenerCount==="function")return L.listenerCount(A);else return D.call(L,A)},G.prototype.listenerCount=D;function D(L){var A=this._events;if(A!==void 0){var y=A[L];if(typeof y==="function")return 1;else if(y!==void 0)return y.length}return 0}G.prototype.eventNames=function(){return this._eventsCount>0?Y(this._events):[]};function C(L,A){var y=Array(A);for(var g=0;g1)for(var Y=1;Y0)throw Error("Invalid string. Length must be a multiple of 4");var H=D.indexOf("=");if(H===-1)H=C;var O=H===C?0:4-H%4;return[H,O]}function Q(D){var C=X(D),H=C[0],O=C[1];return(H+O)*3/4-O}function B(D,C,H){return(C+H)*3/4-H}function F(D){var C,H=X(D),O=H[0],V=H[1],j=new Y(B(D,O,V)),M=0,L=V>0?O-4:O,A;for(A=0;A>16&255,j[M++]=C>>8&255,j[M++]=C&255;if(V===2)C=U[D.charCodeAt(A)]<<2|U[D.charCodeAt(A+1)]>>4,j[M++]=C&255;if(V===1)C=U[D.charCodeAt(A)]<<10|U[D.charCodeAt(A+1)]<<4|U[D.charCodeAt(A+2)]>>2,j[M++]=C>>8&255,j[M++]=C&255;return j}function z(D){return $[D>>18&63]+$[D>>12&63]+$[D>>6&63]+$[D&63]}function W(D,C,H){var O,V=[];for(var j=C;jL?L:M+j));if(O===1)C=D[H-1],V.push($[C>>2]+$[C<<4&63]+"==");else if(O===2)C=(D[H-2]<<8)+D[H-1],V.push($[C>>10]+$[C>>4&63]+$[C<<2&63]+"=");return V.join("")}return U1}var S1={},tU;function zq(){if(tU)return S1;return tU=1,S1.read=function($,U,Y,Z,J){var G,X,Q=J*8-Z-1,B=(1<>1,z=-7,W=Y?J-1:0,k=Y?-1:1,D=$[U+W];W+=k,G=D&(1<<-z)-1,D>>=-z,z+=Q;for(;z>0;G=G*256+$[U+W],W+=k,z-=8);X=G&(1<<-z)-1,G>>=-z,z+=Z;for(;z>0;X=X*256+$[U+W],W+=k,z-=8);if(G===0)G=1-F;else if(G===B)return X?NaN:(D?-1:1)*(1/0);else X=X+Math.pow(2,Z),G=G-F;return(D?-1:1)*X*Math.pow(2,G-Z)},S1.write=function($,U,Y,Z,J,G){var X,Q,B,F=G*8-J-1,z=(1<>1,k=J===23?Math.pow(2,-24)-Math.pow(2,-77):0,D=Z?0:G-1,C=Z?1:-1,H=U<0||U===0&&1/U<0?1:0;if(U=Math.abs(U),isNaN(U)||U===1/0)Q=isNaN(U)?1:0,X=z;else{if(X=Math.floor(Math.log(U)/Math.LN2),U*(B=Math.pow(2,-X))<1)X--,B*=2;if(X+W>=1)U+=k/B;else U+=k*Math.pow(2,1-W);if(U*B>=2)X++,B/=2;if(X+W>=z)Q=0,X=z;else if(X+W>=1)Q=(U*B-1)*Math.pow(2,J),X=X+W;else Q=U*Math.pow(2,W-1)*Math.pow(2,J),X=0}for(;J>=8;$[Y+D]=Q&255,D+=C,Q/=256,J-=8);X=X<0;$[Y+D]=X&255,D+=C,X/=256,F-=8);$[Y+D-C]|=H*128},S1}var eU;function o1(){if(eU)return b8;return eU=1,function($){var U=jq(),Y=zq(),Z=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null;$.Buffer=Q,$.SlowBuffer=j,$.INSPECT_MAX_BYTES=50;var J=2147483647;if($.kMaxLength=J,Q.TYPED_ARRAY_SUPPORT=G(),!Q.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error==="function")console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function G(){try{var T=new Uint8Array(1),K={foo:function(){return 42}};return Object.setPrototypeOf(K,Uint8Array.prototype),Object.setPrototypeOf(T,K),T.foo()===42}catch(q){return!1}}Object.defineProperty(Q.prototype,"parent",{enumerable:!0,get:function(){if(!Q.isBuffer(this))return;return this.buffer}}),Object.defineProperty(Q.prototype,"offset",{enumerable:!0,get:function(){if(!Q.isBuffer(this))return;return this.byteOffset}});function X(T){if(T>J)throw RangeError('The value "'+T+'" is invalid for option "size"');var K=new Uint8Array(T);return Object.setPrototypeOf(K,Q.prototype),K}function Q(T,K,q){if(typeof T==="number"){if(typeof K==="string")throw TypeError('The "string" argument must be of type string. Received type number');return W(T)}return B(T,K,q)}Q.poolSize=8192;function B(T,K,q){if(typeof T==="string")return k(T,K);if(ArrayBuffer.isView(T))return C(T);if(T==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T);if(e(T,ArrayBuffer)||T&&e(T.buffer,ArrayBuffer))return H(T,K,q);if(typeof SharedArrayBuffer<"u"&&(e(T,SharedArrayBuffer)||T&&e(T.buffer,SharedArrayBuffer)))return H(T,K,q);if(typeof T==="number")throw TypeError('The "value" argument must not be of type number. Received type number');var w=T.valueOf&&T.valueOf();if(w!=null&&w!==T)return Q.from(w,K,q);var x=O(T);if(x)return x;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof T[Symbol.toPrimitive]==="function")return Q.from(T[Symbol.toPrimitive]("string"),K,q);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T)}Q.from=function(T,K,q){return B(T,K,q)},Object.setPrototypeOf(Q.prototype,Uint8Array.prototype),Object.setPrototypeOf(Q,Uint8Array);function F(T){if(typeof T!=="number")throw TypeError('"size" argument must be of type number');else if(T<0)throw RangeError('The value "'+T+'" is invalid for option "size"')}function z(T,K,q){if(F(T),T<=0)return X(T);if(K!==void 0)return typeof q==="string"?X(T).fill(K,q):X(T).fill(K);return X(T)}Q.alloc=function(T,K,q){return z(T,K,q)};function W(T){return F(T),X(T<0?0:V(T)|0)}Q.allocUnsafe=function(T){return W(T)},Q.allocUnsafeSlow=function(T){return W(T)};function k(T,K){if(typeof K!=="string"||K==="")K="utf8";if(!Q.isEncoding(K))throw TypeError("Unknown encoding: "+K);var q=M(T,K)|0,w=X(q),x=w.write(T,K);if(x!==q)w=w.slice(0,x);return w}function D(T){var K=T.length<0?0:V(T.length)|0,q=X(K);for(var w=0;w=J)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+J.toString(16)+" bytes");return T|0}function j(T){if(+T!=T)T=0;return Q.alloc(+T)}Q.isBuffer=function(K){return K!=null&&K._isBuffer===!0&&K!==Q.prototype},Q.compare=function(K,q){if(e(K,Uint8Array))K=Q.from(K,K.offset,K.byteLength);if(e(q,Uint8Array))q=Q.from(q,q.offset,q.byteLength);if(!Q.isBuffer(K)||!Q.isBuffer(q))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(K===q)return 0;var w=K.length,x=q.length;for(var l=0,u=Math.min(w,x);lx.length)Q.from(u).copy(x,l);else Uint8Array.prototype.set.call(x,u,l);else if(!Q.isBuffer(u))throw TypeError('"list" argument must be an Array of Buffers');else u.copy(x,l);l+=u.length}return x};function M(T,K){if(Q.isBuffer(T))return T.length;if(ArrayBuffer.isView(T)||e(T,ArrayBuffer))return T.byteLength;if(typeof T!=="string")throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof T);var q=T.length,w=arguments.length>2&&arguments[2]===!0;if(!w&&q===0)return 0;var x=!1;for(;;)switch(K){case"ascii":case"latin1":case"binary":return q;case"utf8":case"utf-8":return R(T).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q*2;case"hex":return q>>>1;case"base64":return v(T).length;default:if(x)return w?-1:R(T).length;K=(""+K).toLowerCase(),x=!0}}Q.byteLength=M;function L(T,K,q){var w=!1;if(K===void 0||K<0)K=0;if(K>this.length)return"";if(q===void 0||q>this.length)q=this.length;if(q<=0)return"";if(q>>>=0,K>>>=0,q<=K)return"";if(!T)T="utf8";while(!0)switch(T){case"hex":return U0(this,K,q);case"utf8":case"utf-8":return N(this,K,q);case"ascii":return m(this,K,q);case"latin1":case"binary":return J0(this,K,q);case"base64":return h(this,K,q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L0(this,K,q);default:if(w)throw TypeError("Unknown encoding: "+T);T=(T+"").toLowerCase(),w=!0}}Q.prototype._isBuffer=!0;function A(T,K,q){var w=T[K];T[K]=T[q],T[q]=w}if(Q.prototype.swap16=function(){var K=this.length;if(K%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var q=0;qq)K+=" ... ";return""},Z)Q.prototype[Z]=Q.prototype.inspect;Q.prototype.compare=function(K,q,w,x,l){if(e(K,Uint8Array))K=Q.from(K,K.offset,K.byteLength);if(!Q.isBuffer(K))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof K);if(q===void 0)q=0;if(w===void 0)w=K?K.length:0;if(x===void 0)x=0;if(l===void 0)l=this.length;if(q<0||w>K.length||x<0||l>this.length)throw RangeError("out of range index");if(x>=l&&q>=w)return 0;if(x>=l)return-1;if(q>=w)return 1;if(q>>>=0,w>>>=0,x>>>=0,l>>>=0,this===K)return 0;var u=l-x,Q0=w-q,q0=Math.min(u,Q0),K0=this.slice(x,l),M0=K.slice(q,w);for(var w0=0;w02147483647)q=2147483647;else if(q<-2147483648)q=-2147483648;if(q=+q,I(q))q=x?0:T.length-1;if(q<0)q=T.length+q;if(q>=T.length)if(x)return-1;else q=T.length-1;else if(q<0)if(x)q=0;else return-1;if(typeof K==="string")K=Q.from(K,w);if(Q.isBuffer(K)){if(K.length===0)return-1;return g(T,K,q,w,x)}else if(typeof K==="number"){if(K=K&255,typeof Uint8Array.prototype.indexOf==="function")if(x)return Uint8Array.prototype.indexOf.call(T,K,q);else return Uint8Array.prototype.lastIndexOf.call(T,K,q);return g(T,[K],q,w,x)}throw TypeError("val must be string, number or Buffer")}function g(T,K,q,w,x){var l=1,u=T.length,Q0=K.length;if(w!==void 0){if(w=String(w).toLowerCase(),w==="ucs2"||w==="ucs-2"||w==="utf16le"||w==="utf-16le"){if(T.length<2||K.length<2)return-1;l=2,u/=2,Q0/=2,q/=2}}function q0(v0,j2){if(l===1)return v0[j2];else return v0.readUInt16BE(j2*l)}var K0;if(x){var M0=-1;for(K0=q;K0u)q=u-Q0;for(K0=q;K0>=0;K0--){var w0=!0;for(var H0=0;H0x)w=x;var l=K.length;if(w>l/2)w=l/2;for(var u=0;u>>0,isFinite(w)){if(w=w>>>0,x===void 0)x="utf8"}else x=w,w=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var l=this.length-q;if(w===void 0||w>l)w=l;if(K.length>0&&(w<0||q<0)||q>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!x)x="utf8";var u=!1;for(;;)switch(x){case"hex":return d(this,K,q,w);case"utf8":case"utf-8":return E(this,K,q,w);case"ascii":case"latin1":case"binary":return s(this,K,q,w);case"base64":return V0(this,K,q,w);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,K,q,w);default:if(u)throw TypeError("Unknown encoding: "+x);x=(""+x).toLowerCase(),u=!0}},Q.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function h(T,K,q){if(K===0&&q===T.length)return U.fromByteArray(T);else return U.fromByteArray(T.slice(K,q))}function N(T,K,q){q=Math.min(T.length,q);var w=[],x=K;while(x239?4:l>223?3:l>191?2:1;if(x+Q0<=q){var q0,K0,M0,w0;switch(Q0){case 1:if(l<128)u=l;break;case 2:if(q0=T[x+1],(q0&192)===128){if(w0=(l&31)<<6|q0&63,w0>127)u=w0}break;case 3:if(q0=T[x+1],K0=T[x+2],(q0&192)===128&&(K0&192)===128){if(w0=(l&15)<<12|(q0&63)<<6|K0&63,w0>2047&&(w0<55296||w0>57343))u=w0}break;case 4:if(q0=T[x+1],K0=T[x+2],M0=T[x+3],(q0&192)===128&&(K0&192)===128&&(M0&192)===128){if(w0=(l&15)<<18|(q0&63)<<12|(K0&63)<<6|M0&63,w0>65535&&w0<1114112)u=w0}}}if(u===null)u=65533,Q0=1;else if(u>65535)u-=65536,w.push(u>>>10&1023|55296),u=56320|u&1023;w.push(u),x+=Q0}return $0(w)}var a=4096;function $0(T){var K=T.length;if(K<=a)return String.fromCharCode.apply(String,T);var q="",w=0;while(ww)q=w;var x="";for(var l=K;lw)K=w;if(q<0){if(q+=w,q<0)q=0}else if(q>w)q=w;if(qq)throw RangeError("Trying to access beyond buffer length")}Q.prototype.readUintLE=Q.prototype.readUIntLE=function(K,q,w){if(K=K>>>0,q=q>>>0,!w)i(K,q,this.length);var x=this[K],l=1,u=0;while(++u>>0,q=q>>>0,!w)i(K,q,this.length);var x=this[K+--q],l=1;while(q>0&&(l*=256))x+=this[K+--q]*l;return x},Q.prototype.readUint8=Q.prototype.readUInt8=function(K,q){if(K=K>>>0,!q)i(K,1,this.length);return this[K]},Q.prototype.readUint16LE=Q.prototype.readUInt16LE=function(K,q){if(K=K>>>0,!q)i(K,2,this.length);return this[K]|this[K+1]<<8},Q.prototype.readUint16BE=Q.prototype.readUInt16BE=function(K,q){if(K=K>>>0,!q)i(K,2,this.length);return this[K]<<8|this[K+1]},Q.prototype.readUint32LE=Q.prototype.readUInt32LE=function(K,q){if(K=K>>>0,!q)i(K,4,this.length);return(this[K]|this[K+1]<<8|this[K+2]<<16)+this[K+3]*16777216},Q.prototype.readUint32BE=Q.prototype.readUInt32BE=function(K,q){if(K=K>>>0,!q)i(K,4,this.length);return this[K]*16777216+(this[K+1]<<16|this[K+2]<<8|this[K+3])},Q.prototype.readIntLE=function(K,q,w){if(K=K>>>0,q=q>>>0,!w)i(K,q,this.length);var x=this[K],l=1,u=0;while(++u=l)x-=Math.pow(2,8*q);return x},Q.prototype.readIntBE=function(K,q,w){if(K=K>>>0,q=q>>>0,!w)i(K,q,this.length);var x=q,l=1,u=this[K+--x];while(x>0&&(l*=256))u+=this[K+--x]*l;if(l*=128,u>=l)u-=Math.pow(2,8*q);return u},Q.prototype.readInt8=function(K,q){if(K=K>>>0,!q)i(K,1,this.length);if(!(this[K]&128))return this[K];return(255-this[K]+1)*-1},Q.prototype.readInt16LE=function(K,q){if(K=K>>>0,!q)i(K,2,this.length);var w=this[K]|this[K+1]<<8;return w&32768?w|4294901760:w},Q.prototype.readInt16BE=function(K,q){if(K=K>>>0,!q)i(K,2,this.length);var w=this[K+1]|this[K]<<8;return w&32768?w|4294901760:w},Q.prototype.readInt32LE=function(K,q){if(K=K>>>0,!q)i(K,4,this.length);return this[K]|this[K+1]<<8|this[K+2]<<16|this[K+3]<<24},Q.prototype.readInt32BE=function(K,q){if(K=K>>>0,!q)i(K,4,this.length);return this[K]<<24|this[K+1]<<16|this[K+2]<<8|this[K+3]},Q.prototype.readFloatLE=function(K,q){if(K=K>>>0,!q)i(K,4,this.length);return Y.read(this,K,!0,23,4)},Q.prototype.readFloatBE=function(K,q){if(K=K>>>0,!q)i(K,4,this.length);return Y.read(this,K,!1,23,4)},Q.prototype.readDoubleLE=function(K,q){if(K=K>>>0,!q)i(K,8,this.length);return Y.read(this,K,!0,52,8)},Q.prototype.readDoubleBE=function(K,q){if(K=K>>>0,!q)i(K,8,this.length);return Y.read(this,K,!1,52,8)};function _(T,K,q,w,x,l){if(!Q.isBuffer(T))throw TypeError('"buffer" argument must be a Buffer instance');if(K>x||KT.length)throw RangeError("Index out of range")}Q.prototype.writeUintLE=Q.prototype.writeUIntLE=function(K,q,w,x){if(K=+K,q=q>>>0,w=w>>>0,!x){var l=Math.pow(2,8*w)-1;_(this,K,q,w,l,0)}var u=1,Q0=0;this[q]=K&255;while(++Q0>>0,w=w>>>0,!x){var l=Math.pow(2,8*w)-1;_(this,K,q,w,l,0)}var u=w-1,Q0=1;this[q+u]=K&255;while(--u>=0&&(Q0*=256))this[q+u]=K/Q0&255;return q+w},Q.prototype.writeUint8=Q.prototype.writeUInt8=function(K,q,w){if(K=+K,q=q>>>0,!w)_(this,K,q,1,255,0);return this[q]=K&255,q+1},Q.prototype.writeUint16LE=Q.prototype.writeUInt16LE=function(K,q,w){if(K=+K,q=q>>>0,!w)_(this,K,q,2,65535,0);return this[q]=K&255,this[q+1]=K>>>8,q+2},Q.prototype.writeUint16BE=Q.prototype.writeUInt16BE=function(K,q,w){if(K=+K,q=q>>>0,!w)_(this,K,q,2,65535,0);return this[q]=K>>>8,this[q+1]=K&255,q+2},Q.prototype.writeUint32LE=Q.prototype.writeUInt32LE=function(K,q,w){if(K=+K,q=q>>>0,!w)_(this,K,q,4,4294967295,0);return this[q+3]=K>>>24,this[q+2]=K>>>16,this[q+1]=K>>>8,this[q]=K&255,q+4},Q.prototype.writeUint32BE=Q.prototype.writeUInt32BE=function(K,q,w){if(K=+K,q=q>>>0,!w)_(this,K,q,4,4294967295,0);return this[q]=K>>>24,this[q+1]=K>>>16,this[q+2]=K>>>8,this[q+3]=K&255,q+4},Q.prototype.writeIntLE=function(K,q,w,x){if(K=+K,q=q>>>0,!x){var l=Math.pow(2,8*w-1);_(this,K,q,w,l-1,-l)}var u=0,Q0=1,q0=0;this[q]=K&255;while(++u>0)-q0&255}return q+w},Q.prototype.writeIntBE=function(K,q,w,x){if(K=+K,q=q>>>0,!x){var l=Math.pow(2,8*w-1);_(this,K,q,w,l-1,-l)}var u=w-1,Q0=1,q0=0;this[q+u]=K&255;while(--u>=0&&(Q0*=256)){if(K<0&&q0===0&&this[q+u+1]!==0)q0=1;this[q+u]=(K/Q0>>0)-q0&255}return q+w},Q.prototype.writeInt8=function(K,q,w){if(K=+K,q=q>>>0,!w)_(this,K,q,1,127,-128);if(K<0)K=255+K+1;return this[q]=K&255,q+1},Q.prototype.writeInt16LE=function(K,q,w){if(K=+K,q=q>>>0,!w)_(this,K,q,2,32767,-32768);return this[q]=K&255,this[q+1]=K>>>8,q+2},Q.prototype.writeInt16BE=function(K,q,w){if(K=+K,q=q>>>0,!w)_(this,K,q,2,32767,-32768);return this[q]=K>>>8,this[q+1]=K&255,q+2},Q.prototype.writeInt32LE=function(K,q,w){if(K=+K,q=q>>>0,!w)_(this,K,q,4,2147483647,-2147483648);return this[q]=K&255,this[q+1]=K>>>8,this[q+2]=K>>>16,this[q+3]=K>>>24,q+4},Q.prototype.writeInt32BE=function(K,q,w){if(K=+K,q=q>>>0,!w)_(this,K,q,4,2147483647,-2147483648);if(K<0)K=4294967295+K+1;return this[q]=K>>>24,this[q+1]=K>>>16,this[q+2]=K>>>8,this[q+3]=K&255,q+4};function r(T,K,q,w,x,l){if(q+w>T.length)throw RangeError("Index out of range");if(q<0)throw RangeError("Index out of range")}function n(T,K,q,w,x){if(K=+K,q=q>>>0,!x)r(T,K,q,4);return Y.write(T,K,q,w,23,4),q+4}Q.prototype.writeFloatLE=function(K,q,w){return n(this,K,q,!0,w)},Q.prototype.writeFloatBE=function(K,q,w){return n(this,K,q,!1,w)};function Z0(T,K,q,w,x){if(K=+K,q=q>>>0,!x)r(T,K,q,8);return Y.write(T,K,q,w,52,8),q+8}Q.prototype.writeDoubleLE=function(K,q,w){return Z0(this,K,q,!0,w)},Q.prototype.writeDoubleBE=function(K,q,w){return Z0(this,K,q,!1,w)},Q.prototype.copy=function(K,q,w,x){if(!Q.isBuffer(K))throw TypeError("argument should be a Buffer");if(!w)w=0;if(!x&&x!==0)x=this.length;if(q>=K.length)q=K.length;if(!q)q=0;if(x>0&&x=this.length)throw RangeError("Index out of range");if(x<0)throw RangeError("sourceEnd out of bounds");if(x>this.length)x=this.length;if(K.length-q>>0,w=w===void 0?this.length:w>>>0,!K)K=0;var u;if(typeof K==="number")for(u=q;u55295&&q<57344){if(!x){if(q>56319){if((K-=3)>-1)l.push(239,191,189);continue}else if(u+1===w){if((K-=3)>-1)l.push(239,191,189);continue}x=q;continue}if(q<56320){if((K-=3)>-1)l.push(239,191,189);x=q;continue}q=(x-55296<<10|q-56320)+65536}else if(x){if((K-=3)>-1)l.push(239,191,189)}if(x=null,q<128){if((K-=1)<0)break;l.push(q)}else if(q<2048){if((K-=2)<0)break;l.push(q>>6|192,q&63|128)}else if(q<65536){if((K-=3)<0)break;l.push(q>>12|224,q>>6&63|128,q&63|128)}else if(q<1114112){if((K-=4)<0)break;l.push(q>>18|240,q>>12&63|128,q>>6&63|128,q&63|128)}else throw Error("Invalid code point")}return l}function c(T){var K=[];for(var q=0;q>8,x=q%256,l.push(x),l.push(w)}return l}function v(T){return U.toByteArray(P(T))}function b(T,K,q,w){for(var x=0;x=K.length||x>=T.length)break;K[x+q]=T[x]}return x}function e(T,K){return T instanceof K||T!=null&&T.constructor!=null&&T.constructor.name!=null&&T.constructor.name===K.name}function I(T){return T!==T}var t=function(){var T="0123456789abcdef",K=Array(256);for(var q=0;q<16;++q){var w=q*16;for(var x=0;x<16;++x)K[w+x]=T[q]+T[x]}return K}()}(b8),b8}var g8={},x8={},f8,$Y;function QQ(){if($Y)return f8;return $Y=1,f8=function(){if(typeof Symbol!=="function"||typeof Object.getOwnPropertySymbols!=="function")return!1;if(typeof Symbol.iterator==="symbol")return!0;var U={},Y=Symbol("test"),Z=Object(Y);if(typeof Y==="string")return!1;if(Object.prototype.toString.call(Y)!=="[object Symbol]")return!1;if(Object.prototype.toString.call(Z)!=="[object Symbol]")return!1;var J=42;U[Y]=J;for(var G in U)return!1;if(typeof Object.keys==="function"&&Object.keys(U).length!==0)return!1;if(typeof Object.getOwnPropertyNames==="function"&&Object.getOwnPropertyNames(U).length!==0)return!1;var X=Object.getOwnPropertySymbols(U);if(X.length!==1||X[0]!==Y)return!1;if(!Object.prototype.propertyIsEnumerable.call(U,Y))return!1;if(typeof Object.getOwnPropertyDescriptor==="function"){var Q=Object.getOwnPropertyDescriptor(U,Y);if(Q.value!==J||Q.enumerable!==!0)return!1}return!0},f8}var h8,UY;function f9(){if(UY)return h8;UY=1;var $=QQ();return h8=function(){return $()&&!!Symbol.toStringTag},h8}var u8,YY;function JQ(){if(YY)return u8;return YY=1,u8=Object,u8}var d8,ZY;function Fq(){if(ZY)return d8;return ZY=1,d8=Error,d8}var c8,QY;function Nq(){if(QY)return c8;return QY=1,c8=EvalError,c8}var m8,JY;function Rq(){if(JY)return m8;return JY=1,m8=RangeError,m8}var l8,GY;function Dq(){if(GY)return l8;return GY=1,l8=ReferenceError,l8}var a8,KY;function GQ(){if(KY)return a8;return KY=1,a8=SyntaxError,a8}var p8,qY;function t1(){if(qY)return p8;return qY=1,p8=TypeError,p8}var i8,XY;function Aq(){if(XY)return i8;return XY=1,i8=URIError,i8}var r8,VY;function Pq(){if(VY)return r8;return VY=1,r8=Math.abs,r8}var s8,BY;function Tq(){if(BY)return s8;return BY=1,s8=Math.floor,s8}var n8,LY;function Cq(){if(LY)return n8;return LY=1,n8=Math.max,n8}var o8,MY;function Oq(){if(MY)return o8;return MY=1,o8=Math.min,o8}var t8,IY;function kq(){if(IY)return t8;return IY=1,t8=Math.pow,t8}var e8,wY;function Eq(){if(wY)return e8;return wY=1,e8=Math.round,e8}var $6,WY;function Sq(){if(WY)return $6;return WY=1,$6=Number.isNaN||function(U){return U!==U},$6}var U6,HY;function vq(){if(HY)return U6;HY=1;var $=Sq();return U6=function(Y){if($(Y)||Y===0)return Y;return Y<0?-1:1},U6}var Y6,jY;function _q(){if(jY)return Y6;return jY=1,Y6=Object.getOwnPropertyDescriptor,Y6}var Z6,zY;function I1(){if(zY)return Z6;zY=1;var $=_q();if($)try{$([],"length")}catch(U){$=null}return Z6=$,Z6}var Q6,FY;function e1(){if(FY)return Q6;FY=1;var $=Object.defineProperty||!1;if($)try{$({},"a",{value:1})}catch(U){$=!1}return Q6=$,Q6}var J6,NY;function yq(){if(NY)return J6;NY=1;var $=typeof Symbol<"u"&&Symbol,U=QQ();return J6=function(){if(typeof $!=="function")return!1;if(typeof Symbol!=="function")return!1;if(typeof $("foo")!=="symbol")return!1;if(typeof Symbol("bar")!=="symbol")return!1;return U()},J6}var G6,RY;function KQ(){if(RY)return G6;return RY=1,G6=typeof Reflect<"u"&&Reflect.getPrototypeOf||null,G6}var K6,DY;function qQ(){if(DY)return K6;DY=1;var $=JQ();return K6=$.getPrototypeOf||null,K6}var q6,AY;function bq(){if(AY)return q6;AY=1;var $="Function.prototype.bind called on incompatible ",U=Object.prototype.toString,Y=Math.max,Z="[object Function]",J=function(B,F){var z=[];for(var W=0;W"u"||!g?$:g(Uint8Array),N={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?$:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?$:ArrayBuffer,"%ArrayIteratorPrototype%":y&&g?g([][Symbol.iterator]()):$,"%AsyncFromSyncIteratorPrototype%":$,"%AsyncFunction%":S,"%AsyncGenerator%":S,"%AsyncGeneratorFunction%":S,"%AsyncIteratorPrototype%":S,"%Atomics%":typeof Atomics>"u"?$:Atomics,"%BigInt%":typeof BigInt>"u"?$:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?$:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?$:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?$:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Y,"%eval%":eval,"%EvalError%":Z,"%Float16Array%":typeof Float16Array>"u"?$:Float16Array,"%Float32Array%":typeof Float32Array>"u"?$:Float32Array,"%Float64Array%":typeof Float64Array>"u"?$:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?$:FinalizationRegistry,"%Function%":O,"%GeneratorFunction%":S,"%Int8Array%":typeof Int8Array>"u"?$:Int8Array,"%Int16Array%":typeof Int16Array>"u"?$:Int16Array,"%Int32Array%":typeof Int32Array>"u"?$:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":y&&g?g(g([][Symbol.iterator]())):$,"%JSON%":typeof JSON==="object"?JSON:$,"%Map%":typeof Map>"u"?$:Map,"%MapIteratorPrototype%":typeof Map>"u"||!y||!g?$:g(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":U,"%Object.getOwnPropertyDescriptor%":j,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?$:Promise,"%Proxy%":typeof Proxy>"u"?$:Proxy,"%RangeError%":J,"%ReferenceError%":G,"%Reflect%":typeof Reflect>"u"?$:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?$:Set,"%SetIteratorPrototype%":typeof Set>"u"||!y||!g?$:g(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?$:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":y&&g?g(""[Symbol.iterator]()):$,"%Symbol%":y?Symbol:$,"%SyntaxError%":X,"%ThrowTypeError%":A,"%TypedArray%":h,"%TypeError%":Q,"%Uint8Array%":typeof Uint8Array>"u"?$:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?$:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?$:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?$:Uint32Array,"%URIError%":B,"%WeakMap%":typeof WeakMap>"u"?$:WeakMap,"%WeakRef%":typeof WeakRef>"u"?$:WeakRef,"%WeakSet%":typeof WeakSet>"u"?$:WeakSet,"%Function.prototype.call%":V0,"%Function.prototype.apply%":s,"%Object.defineProperty%":M,"%Object.getPrototypeOf%":d,"%Math.abs%":F,"%Math.floor%":z,"%Math.max%":W,"%Math.min%":k,"%Math.pow%":D,"%Math.round%":C,"%Math.sign%":H,"%Reflect.getPrototypeOf%":E};if(g)try{null.error}catch(c){var a=g(g(c));N["%Error.prototype%"]=a}var $0=function c(f){var v;if(f==="%AsyncFunction%")v=V("async function () {}");else if(f==="%GeneratorFunction%")v=V("function* () {}");else if(f==="%AsyncGeneratorFunction%")v=V("async function* () {}");else if(f==="%AsyncGenerator%"){var b=c("%AsyncGeneratorFunction%");if(b)v=b.prototype}else if(f==="%AsyncIteratorPrototype%"){var e=c("%AsyncGenerator%");if(e&&g)v=g(e.prototype)}return N[f]=v,v},m={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},J0=w1(),U0=fq(),L0=J0.call(V0,Array.prototype.concat),i=J0.call(s,Array.prototype.splice),_=J0.call(V0,String.prototype.replace),r=J0.call(V0,String.prototype.slice),n=J0.call(V0,RegExp.prototype.exec),Z0=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,p=/\\(\\)?/g,P=function(f){var v=r(f,0,1),b=r(f,-1);if(v==="%"&&b!=="%")throw new X("invalid intrinsic syntax, expected closing `%`");else if(b==="%"&&v!=="%")throw new X("invalid intrinsic syntax, expected opening `%`");var e=[];return _(f,Z0,function(I,t,T,K){e[e.length]=T?_(K,p,"$1"):t||I}),e},R=function(f,v){var b=f,e;if(U0(m,b))e=m[b],b="%"+e[0]+"%";if(U0(N,b)){var I=N[b];if(I===S)I=$0(b);if(typeof I>"u"&&!v)throw new Q("intrinsic "+f+" exists, but is not available. Please file an issue!");return{alias:e,name:b,value:I}}throw new X("intrinsic "+f+" does not exist!")};return j6=function(f,v){if(typeof f!=="string"||f.length===0)throw new Q("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof v!=="boolean")throw new Q('"allowMissing" argument must be a boolean');if(n(/^%?[^%]*%?$/,f)===null)throw new X("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var b=P(f),e=b.length>0?b[0]:"",I=R("%"+e+"%",v),t=I.name,T=I.value,K=!1,q=I.alias;if(q)e=q[0],i(b,L0([0,1],q));for(var w=1,x=!0;w=b.length){var q0=j(T,l);if(x=!!q0,x&&"get"in q0&&!("originalValue"in q0.get))T=q0.get;else T=T[l]}else x=U0(T,l),T=T[l];if(x&&!K)N[t]=T}}return T},j6}var z6,bY;function LQ(){if(bY)return z6;bY=1;var $=BQ(),U=d9(),Y=U([$("%String.prototype.indexOf%")]);return z6=function(J,G){var X=$(J,!!G);if(typeof X==="function"&&Y(J,".prototype.")>-1)return U([X]);return X},z6}var F6,gY;function hq(){if(gY)return F6;gY=1;var $=f9()(),U=LQ(),Y=U("Object.prototype.toString"),Z=function(Q){if($&&Q&&typeof Q==="object"&&Symbol.toStringTag in Q)return!1;return Y(Q)==="[object Arguments]"},J=function(Q){if(Z(Q))return!0;return Q!==null&&typeof Q==="object"&&"length"in Q&&typeof Q.length==="number"&&Q.length>=0&&Y(Q)!=="[object Array]"&&"callee"in Q&&Y(Q.callee)==="[object Function]"},G=function(){return Z(arguments)}();return Z.isLegacyArguments=J,F6=G?Z:J,F6}var N6,xY;function uq(){if(xY)return N6;xY=1;var $=Object.prototype.toString,U=Function.prototype.toString,Y=/^\s*(?:function)?\*/,Z=f9()(),J=Object.getPrototypeOf,G=function(){if(!Z)return!1;try{return Function("return function*() {}")()}catch(Q){}},X;return N6=function(B){if(typeof B!=="function")return!1;if(Y.test(U.call(B)))return!0;if(!Z){var F=$.call(B);return F==="[object GeneratorFunction]"}if(!J)return!1;if(typeof X>"u"){var z=G();X=z?J(z):!1}return J(B)===X},N6}var R6,fY;function dq(){if(fY)return R6;fY=1;var $=Function.prototype.toString,U=typeof Reflect==="object"&&Reflect!==null&&Reflect.apply,Y,Z;if(typeof U==="function"&&typeof Object.defineProperty==="function")try{Y=Object.defineProperty({},"length",{get:function(){throw Z}}),Z={},U(function(){throw 42},null,Y)}catch(j){if(j!==Z)U=null}else U=null;var J=/^\s*class\b/,G=function(M){try{var L=$.call(M);return J.test(L)}catch(A){return!1}},X=function(M){try{if(G(M))return!1;return $.call(M),!0}catch(L){return!1}},Q=Object.prototype.toString,B="[object Object]",F="[object Function]",z="[object GeneratorFunction]",W="[object HTMLAllCollection]",k="[object HTML document.all class]",D="[object HTMLCollection]",C=typeof Symbol==="function"&&!!Symbol.toStringTag,H=!(0 in[,]),O=function(){return!1};if(typeof document==="object"){var V=document.all;if(Q.call(V)===Q.call(document.all))O=function(M){if((H||!M)&&(typeof M>"u"||typeof M==="object"))try{var L=Q.call(M);return(L===W||L===k||L===D||L===B)&&M("")==null}catch(A){}return!1}}return R6=U?function(M){if(O(M))return!0;if(!M)return!1;if(typeof M!=="function"&&typeof M!=="object")return!1;try{U(M,null,Y)}catch(L){if(L!==Z)return!1}return!G(M)&&X(M)}:function(M){if(O(M))return!0;if(!M)return!1;if(typeof M!=="function"&&typeof M!=="object")return!1;if(C)return X(M);if(G(M))return!1;var L=Q.call(M);if(L!==F&&L!==z&&!/^\[object HTML/.test(L))return!1;return X(M)},R6}var D6,hY;function cq(){if(hY)return D6;hY=1;var $=dq(),U=Object.prototype.toString,Y=Object.prototype.hasOwnProperty,Z=function(B,F,z){for(var W=0,k=B.length;W=3)W=z;if(X(B))Z(B,F,W);else if(typeof B==="string")J(B,F,W);else G(B,F,W)},D6}var A6,uY;function mq(){if(uY)return A6;return uY=1,A6=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],A6}var P6,dY;function lq(){if(dY)return P6;dY=1;var $=mq(),U=typeof globalThis>"u"?c0:globalThis;return P6=function(){var Z=[];for(var J=0;J<$.length;J++)if(typeof U[$[J]]==="function")Z[Z.length]=$[J];return Z},P6}var T6={exports:{}},C6,cY;function aq(){if(cY)return C6;cY=1;var $=e1(),U=GQ(),Y=t1(),Z=I1();return C6=function(G,X,Q){if(!G||typeof G!=="object"&&typeof G!=="function")throw new Y("`obj` must be an object or a function`");if(typeof X!=="string"&&typeof X!=="symbol")throw new Y("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!=="boolean"&&arguments[3]!==null)throw new Y("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!=="boolean"&&arguments[4]!==null)throw new Y("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!=="boolean"&&arguments[5]!==null)throw new Y("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!=="boolean")throw new Y("`loose`, if provided, must be a boolean");var B=arguments.length>3?arguments[3]:null,F=arguments.length>4?arguments[4]:null,z=arguments.length>5?arguments[5]:null,W=arguments.length>6?arguments[6]:!1,k=!!Z&&Z(G,X);if($)$(G,X,{configurable:z===null&&k?k.configurable:!z,enumerable:B===null&&k?k.enumerable:!B,value:Q,writable:F===null&&k?k.writable:!F});else if(W||!B&&!F&&!z)G[X]=Q;else throw new U("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},C6}var O6,mY;function pq(){if(mY)return O6;mY=1;var $=e1(),U=function(){return!!$};return U.hasArrayLengthDefineBug=function(){if(!$)return null;try{return $([],"length",{value:1}).length!==1}catch(Z){return!0}},O6=U,O6}var k6,lY;function iq(){if(lY)return k6;lY=1;var $=BQ(),U=aq(),Y=pq()(),Z=I1(),J=t1(),G=$("%Math.floor%");return k6=function(Q,B){if(typeof Q!=="function")throw new J("`fn` is not a function");if(typeof B!=="number"||B<0||B>4294967295||G(B)!==B)throw new J("`length` must be a positive 32-bit integer");var F=arguments.length>2&&!!arguments[2],z=!0,W=!0;if("length"in Q&&Z){var k=Z(Q,"length");if(k&&!k.configurable)z=!1;if(k&&!k.writable)W=!1}if(z||W||!F)if(Y)U(Q,"length",B,!0,!0);else U(Q,"length",B);return Q},k6}var E6,aY;function rq(){if(aY)return E6;aY=1;var $=w1(),U=u9(),Y=XQ();return E6=function(){return Y($,U,arguments)},E6}var pY;function sq(){if(pY)return T6.exports;return pY=1,function($){var U=iq(),Y=e1(),Z=d9(),J=rq();if($.exports=function(X){var Q=Z(arguments),B=X.length-(arguments.length-1);return U(Q,1+(B>0?B:0),!0)},Y)Y($.exports,"apply",{value:J});else $.exports.apply=J}(T6),T6.exports}var S6,iY;function MQ(){if(iY)return S6;iY=1;var $=cq(),U=lq(),Y=sq(),Z=LQ(),J=I1(),G=VQ(),X=Z("Object.prototype.toString"),Q=f9()(),B=typeof globalThis>"u"?c0:globalThis,F=U(),z=Z("String.prototype.slice"),W=Z("Array.prototype.indexOf",!0)||function(O,V){for(var j=0;j-1)return V;if(V!=="Object")return!1;return C(O)}if(!J)return null;return D(O)},S6}var v6,rY;function nq(){if(rY)return v6;rY=1;var $=MQ();return v6=function(Y){return!!$(Y)},v6}var sY;function oq(){if(sY)return x8;return sY=1,function($){var U=hq(),Y=uq(),Z=MQ(),J=nq();function G(w){return w.call.bind(w)}var X=typeof BigInt<"u",Q=typeof Symbol<"u",B=G(Object.prototype.toString),F=G(Number.prototype.valueOf),z=G(String.prototype.valueOf),W=G(Boolean.prototype.valueOf);if(X)var k=G(BigInt.prototype.valueOf);if(Q)var D=G(Symbol.prototype.valueOf);function C(w,x){if(typeof w!=="object")return!1;try{return x(w),!0}catch(l){return!1}}$.isArgumentsObject=U,$.isGeneratorFunction=Y,$.isTypedArray=J;function H(w){return typeof Promise<"u"&&w instanceof Promise||w!==null&&typeof w==="object"&&typeof w.then==="function"&&typeof w.catch==="function"}$.isPromise=H;function O(w){if(typeof ArrayBuffer<"u"&&ArrayBuffer.isView)return ArrayBuffer.isView(w);return J(w)||r(w)}$.isArrayBufferView=O;function V(w){return Z(w)==="Uint8Array"}$.isUint8Array=V;function j(w){return Z(w)==="Uint8ClampedArray"}$.isUint8ClampedArray=j;function M(w){return Z(w)==="Uint16Array"}$.isUint16Array=M;function L(w){return Z(w)==="Uint32Array"}$.isUint32Array=L;function A(w){return Z(w)==="Int8Array"}$.isInt8Array=A;function y(w){return Z(w)==="Int16Array"}$.isInt16Array=y;function g(w){return Z(w)==="Int32Array"}$.isInt32Array=g;function d(w){return Z(w)==="Float32Array"}$.isFloat32Array=d;function E(w){return Z(w)==="Float64Array"}$.isFloat64Array=E;function s(w){return Z(w)==="BigInt64Array"}$.isBigInt64Array=s;function V0(w){return Z(w)==="BigUint64Array"}$.isBigUint64Array=V0;function S(w){return B(w)==="[object Map]"}S.working=typeof Map<"u"&&S(new Map);function h(w){if(typeof Map>"u")return!1;return S.working?S(w):w instanceof Map}$.isMap=h;function N(w){return B(w)==="[object Set]"}N.working=typeof Set<"u"&&N(new Set);function a(w){if(typeof Set>"u")return!1;return N.working?N(w):w instanceof Set}$.isSet=a;function $0(w){return B(w)==="[object WeakMap]"}$0.working=typeof WeakMap<"u"&&$0(new WeakMap);function m(w){if(typeof WeakMap>"u")return!1;return $0.working?$0(w):w instanceof WeakMap}$.isWeakMap=m;function J0(w){return B(w)==="[object WeakSet]"}J0.working=typeof WeakSet<"u"&&J0(new WeakSet);function U0(w){return J0(w)}$.isWeakSet=U0;function L0(w){return B(w)==="[object ArrayBuffer]"}L0.working=typeof ArrayBuffer<"u"&&L0(new ArrayBuffer);function i(w){if(typeof ArrayBuffer>"u")return!1;return L0.working?L0(w):w instanceof ArrayBuffer}$.isArrayBuffer=i;function _(w){return B(w)==="[object DataView]"}_.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&_(new DataView(new ArrayBuffer(1),0,1));function r(w){if(typeof DataView>"u")return!1;return _.working?_(w):w instanceof DataView}$.isDataView=r;var n=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function Z0(w){return B(w)==="[object SharedArrayBuffer]"}function p(w){if(typeof n>"u")return!1;if(typeof Z0.working>"u")Z0.working=Z0(new n);return Z0.working?Z0(w):w instanceof n}$.isSharedArrayBuffer=p;function P(w){return B(w)==="[object AsyncFunction]"}$.isAsyncFunction=P;function R(w){return B(w)==="[object Map Iterator]"}$.isMapIterator=R;function c(w){return B(w)==="[object Set Iterator]"}$.isSetIterator=c;function f(w){return B(w)==="[object Generator]"}$.isGeneratorObject=f;function v(w){return B(w)==="[object WebAssembly.Module]"}$.isWebAssemblyCompiledModule=v;function b(w){return C(w,F)}$.isNumberObject=b;function e(w){return C(w,z)}$.isStringObject=e;function I(w){return C(w,W)}$.isBooleanObject=I;function t(w){return X&&C(w,k)}$.isBigIntObject=t;function T(w){return Q&&C(w,D)}$.isSymbolObject=T;function K(w){return b(w)||e(w)||I(w)||t(w)||T(w)}$.isBoxedPrimitive=K;function q(w){return typeof Uint8Array<"u"&&(i(w)||p(w))}$.isAnyArrayBuffer=q,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(w){Object.defineProperty($,w,{enumerable:!1,value:function(){throw Error(w+" is not supported in userland")}})})}(x8),x8}var _6,nY;function tq(){if(nY)return _6;return nY=1,_6=function(U){return U&&typeof U==="object"&&typeof U.copy==="function"&&typeof U.fill==="function"&&typeof U.readUInt8==="function"},_6}var oY;function IQ(){if(oY)return g8;return oY=1,function($){var U=Object.getOwnPropertyDescriptors||function(r){var n=Object.keys(r),Z0={};for(var p=0;p=p)return c;switch(c){case"%s":return String(Z0[n++]);case"%d":return Number(Z0[n++]);case"%j":try{return JSON.stringify(Z0[n++])}catch(f){return"[Circular]"}default:return c}});for(var R=Z0[n];n"u")return function(){return $.deprecate(_,r).apply(this,arguments)};var n=!1;function Z0(){if(!n){if(j0.throwDeprecation)throw Error(r);else if(j0.traceDeprecation)console.trace(r);else console.error(r);n=!0}return _.apply(this,arguments)}return Z0};var Z={},J=/^$/;if(j0.env.NODE_DEBUG){var G=j0.env.NODE_DEBUG;G=G.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),J=new RegExp("^"+G+"$","i")}$.debuglog=function(_){if(_=_.toUpperCase(),!Z[_])if(J.test(_)){var r=j0.pid;Z[_]=function(){var n=$.format.apply($,arguments);console.error("%s %d: %s",_,r,n)}}else Z[_]=function(){};return Z[_]};function X(_,r){var n={seen:[],stylize:B};if(arguments.length>=3)n.depth=arguments[2];if(arguments.length>=4)n.colors=arguments[3];if(V(r))n.showHidden=r;else if(r)$._extend(n,r);if(g(n.showHidden))n.showHidden=!1;if(g(n.depth))n.depth=2;if(g(n.colors))n.colors=!1;if(g(n.customInspect))n.customInspect=!0;if(n.colors)n.stylize=Q;return z(n,_,n.depth)}$.inspect=X,X.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},X.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function Q(_,r){var n=X.styles[r];if(n)return"\x1B["+X.colors[n][0]+"m"+_+"\x1B["+X.colors[n][1]+"m";else return _}function B(_,r){return _}function F(_){var r={};return _.forEach(function(n,Z0){r[n]=!0}),r}function z(_,r,n){if(_.customInspect&&r&&S(r.inspect)&&r.inspect!==$.inspect&&!(r.constructor&&r.constructor.prototype===r)){var Z0=r.inspect(n,_);if(!A(Z0))Z0=z(_,Z0,n);return Z0}var p=W(_,r);if(p)return p;var P=Object.keys(r),R=F(P);if(_.showHidden)P=Object.getOwnPropertyNames(r);if(V0(r)&&(P.indexOf("message")>=0||P.indexOf("description")>=0))return k(r);if(P.length===0){if(S(r)){var c=r.name?": "+r.name:"";return _.stylize("[Function"+c+"]","special")}if(d(r))return _.stylize(RegExp.prototype.toString.call(r),"regexp");if(s(r))return _.stylize(Date.prototype.toString.call(r),"date");if(V0(r))return k(r)}var f="",v=!1,b=["{","}"];if(O(r))v=!0,b=["[","]"];if(S(r)){var e=r.name?": "+r.name:"";f=" [Function"+e+"]"}if(d(r))f=" "+RegExp.prototype.toString.call(r);if(s(r))f=" "+Date.prototype.toUTCString.call(r);if(V0(r))f=" "+k(r);if(P.length===0&&(!v||r.length==0))return b[0]+f+b[1];if(n<0)if(d(r))return _.stylize(RegExp.prototype.toString.call(r),"regexp");else return _.stylize("[Object]","special");_.seen.push(r);var I;if(v)I=D(_,r,n,R,P);else I=P.map(function(t){return C(_,r,n,R,t,v)});return _.seen.pop(),H(I,f,b)}function W(_,r){if(g(r))return _.stylize("undefined","undefined");if(A(r)){var n="'"+JSON.stringify(r).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return _.stylize(n,"string")}if(L(r))return _.stylize(""+r,"number");if(V(r))return _.stylize(""+r,"boolean");if(j(r))return _.stylize("null","null")}function k(_){return"["+Error.prototype.toString.call(_)+"]"}function D(_,r,n,Z0,p){var P=[];for(var R=0,c=r.length;R-1)if(P)c=c.split(` -`).map(function(v){return" "+v}).join(` -`).slice(2);else c=` -`+c.split(` -`).map(function(v){return" "+v}).join(` -`)}else c=_.stylize("[Circular]","special");if(g(R)){if(P&&p.match(/^\d+$/))return c;if(R=JSON.stringify(""+p),R.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/))R=R.slice(1,-1),R=_.stylize(R,"name");else R=R.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),R=_.stylize(R,"string")}return R+": "+c}function H(_,r,n){var Z0=_.reduce(function(p,P){if(P.indexOf(` -`)>=0);return p+P.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(Z0>60)return n[0]+(r===""?"":r+` - `)+" "+_.join(`, - `)+" "+n[1];return n[0]+r+" "+_.join(", ")+" "+n[1]}$.types=oq();function O(_){return Array.isArray(_)}$.isArray=O;function V(_){return typeof _==="boolean"}$.isBoolean=V;function j(_){return _===null}$.isNull=j;function M(_){return _==null}$.isNullOrUndefined=M;function L(_){return typeof _==="number"}$.isNumber=L;function A(_){return typeof _==="string"}$.isString=A;function y(_){return typeof _==="symbol"}$.isSymbol=y;function g(_){return _===void 0}$.isUndefined=g;function d(_){return E(_)&&N(_)==="[object RegExp]"}$.isRegExp=d,$.types.isRegExp=d;function E(_){return typeof _==="object"&&_!==null}$.isObject=E;function s(_){return E(_)&&N(_)==="[object Date]"}$.isDate=s,$.types.isDate=s;function V0(_){return E(_)&&(N(_)==="[object Error]"||_ instanceof Error)}$.isError=V0,$.types.isNativeError=V0;function S(_){return typeof _==="function"}$.isFunction=S;function h(_){return _===null||typeof _==="boolean"||typeof _==="number"||typeof _==="string"||typeof _==="symbol"||typeof _>"u"}$.isPrimitive=h,$.isBuffer=tq();function N(_){return Object.prototype.toString.call(_)}function a(_){return _<10?"0"+_.toString(10):_.toString(10)}var $0=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function m(){var _=new Date,r=[a(_.getHours()),a(_.getMinutes()),a(_.getSeconds())].join(":");return[_.getDate(),$0[_.getMonth()],r].join(" ")}$.log=function(){console.log("%s - %s",m(),$.format.apply($,arguments))},$.inherits=R2(),$._extend=function(_,r){if(!r||!E(r))return _;var n=Object.keys(r),Z0=n.length;while(Z0--)_[n[Z0]]=r[n[Z0]];return _};function J0(_,r){return Object.prototype.hasOwnProperty.call(_,r)}var U0=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;$.promisify=function(r){if(typeof r!=="function")throw TypeError('The "original" argument must be of type Function');if(U0&&r[U0]){var n=r[U0];if(typeof n!=="function")throw TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(n,U0,{value:n,enumerable:!1,writable:!1,configurable:!0}),n}function n(){var Z0,p,P=new Promise(function(f,v){Z0=f,p=v}),R=[];for(var c=0;c0)this.tail.next=V;else this.head=V;this.tail=V,++this.length}},{key:"unshift",value:function(O){var V={data:O,next:this.head};if(this.length===0)this.tail=V;this.head=V,++this.length}},{key:"shift",value:function(){if(this.length===0)return;var O=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;return--this.length,O}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(O){if(this.length===0)return"";var V=this.head,j=""+V.data;while(V=V.next)j+=O+V.data;return j}},{key:"concat",value:function(O){if(this.length===0)return F.alloc(0);var V=F.allocUnsafe(O>>>0),j=this.head,M=0;while(j)D(j.data,V,M),M+=j.data.length,j=j.next;return V}},{key:"consume",value:function(O,V){var j;if(OL.length?L.length:O;if(A===L.length)M+=L;else M+=L.slice(0,O);if(O-=A,O===0){if(A===L.length)if(++j,V.next)this.head=V.next;else this.head=this.tail=null;else this.head=V,V.data=L.slice(A);break}++j}return this.length-=j,M}},{key:"_getBuffer",value:function(O){var V=F.allocUnsafe(O),j=this.head,M=1;j.data.copy(V),O-=j.data.length;while(j=j.next){var L=j.data,A=O>L.length?L.length:O;if(L.copy(V,V.length-O,0,A),O-=A,O===0){if(A===L.length)if(++M,j.next)this.head=j.next;else this.head=this.tail=null;else this.head=j,j.data=L.slice(A);break}++M}return this.length-=M,V}},{key:k,value:function(O,V){return W(this,U(U({},V),{},{depth:0,customInspect:!1}))}}]),C}(),y6}var b6,eY;function wQ(){if(eY)return b6;eY=1;function $(X,Q){var B=this,F=this._readableState&&this._readableState.destroyed,z=this._writableState&&this._writableState.destroyed;if(F||z){if(Q)Q(X);else if(X){if(!this._writableState)j0.nextTick(J,this,X);else if(!this._writableState.errorEmitted)this._writableState.errorEmitted=!0,j0.nextTick(J,this,X)}return this}if(this._readableState)this._readableState.destroyed=!0;if(this._writableState)this._writableState.destroyed=!0;return this._destroy(X||null,function(W){if(!Q&&W)if(!B._writableState)j0.nextTick(U,B,W);else if(!B._writableState.errorEmitted)B._writableState.errorEmitted=!0,j0.nextTick(U,B,W);else j0.nextTick(Y,B);else if(Q)j0.nextTick(Y,B),Q(W);else j0.nextTick(Y,B)}),this}function U(X,Q){J(X,Q),Y(X)}function Y(X){if(X._writableState&&!X._writableState.emitClose)return;if(X._readableState&&!X._readableState.emitClose)return;X.emit("close")}function Z(){if(this._readableState)this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1;if(this._writableState)this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1}function J(X,Q){X.emit("error",Q)}function G(X,Q){var{_readableState:B,_writableState:F}=X;if(B&&B.autoDestroy||F&&F.autoDestroy)X.destroy(Q);else X.emit("error",Q)}return b6={destroy:$,undestroy:Z,errorOrDestroy:G},b6}var g6={},$Z;function i2(){if($Z)return g6;$Z=1;function $(Q,B){Q.prototype=Object.create(B.prototype),Q.prototype.constructor=Q,Q.__proto__=B}var U={};function Y(Q,B,F){if(!F)F=Error;function z(k,D,C){if(typeof B==="string")return B;else return B(k,D,C)}var W=function(k){$(D,k);function D(C,H,O){return k.call(this,z(C,H,O))||this}return D}(F);W.prototype.name=F.name,W.prototype.code=Q,U[Q]=W}function Z(Q,B){if(Array.isArray(Q)){var F=Q.length;if(Q=Q.map(function(z){return String(z)}),F>2)return"one of ".concat(B," ").concat(Q.slice(0,F-1).join(", "),", or ")+Q[F-1];else if(F===2)return"one of ".concat(B," ").concat(Q[0]," or ").concat(Q[1]);else return"of ".concat(B," ").concat(Q[0])}else return"of ".concat(B," ").concat(String(Q))}function J(Q,B,F){return Q.substr(0,B.length)===B}function G(Q,B,F){if(F===void 0||F>Q.length)F=Q.length;return Q.substring(F-B.length,F)===B}function X(Q,B,F){if(typeof F!=="number")F=0;if(F+B.length>Q.length)return!1;else return Q.indexOf(B,F)!==-1}return Y("ERR_INVALID_OPT_VALUE",function(Q,B){return'The value "'+B+'" is invalid for option "'+Q+'"'},TypeError),Y("ERR_INVALID_ARG_TYPE",function(Q,B,F){var z;if(typeof B==="string"&&J(B,"not "))z="must not be",B=B.replace(/^not /,"");else z="must be";var W;if(G(Q," argument"))W="The ".concat(Q," ").concat(z," ").concat(Z(B,"type"));else{var k=X(Q,".")?"property":"argument";W='The "'.concat(Q,'" ').concat(k," ").concat(z," ").concat(Z(B,"type"))}return W+=". Received type ".concat(typeof F),W},TypeError),Y("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),Y("ERR_METHOD_NOT_IMPLEMENTED",function(Q){return"The "+Q+" method is not implemented"}),Y("ERR_STREAM_PREMATURE_CLOSE","Premature close"),Y("ERR_STREAM_DESTROYED",function(Q){return"Cannot call "+Q+" after a stream was destroyed"}),Y("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),Y("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),Y("ERR_STREAM_WRITE_AFTER_END","write after end"),Y("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Y("ERR_UNKNOWN_ENCODING",function(Q){return"Unknown encoding: "+Q},TypeError),Y("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),g6.codes=U,g6}var x6,UZ;function WQ(){if(UZ)return x6;UZ=1;var $=i2().codes.ERR_INVALID_OPT_VALUE;function U(Z,J,G){return Z.highWaterMark!=null?Z.highWaterMark:J?Z[G]:null}function Y(Z,J,G,X){var Q=U(J,X,G);if(Q!=null){if(!(isFinite(Q)&&Math.floor(Q)===Q)||Q<0){var B=X?G:"highWaterMark";throw new $(B,Q)}return Math.floor(Q)}return Z.objectMode?16:16384}return x6={getHighWaterMark:Y},x6}var f6,YZ;function $X(){if(YZ)return f6;YZ=1,f6=$;function $(Y,Z){if(U("noDeprecation"))return Y;var J=!1;function G(){if(!J){if(U("throwDeprecation"))throw Error(Z);else if(U("traceDeprecation"))console.trace(Z);else console.warn(Z);J=!0}return Y.apply(this,arguments)}return G}function U(Y){try{if(!c0.localStorage)return!1}catch(J){return!1}var Z=c0.localStorage[Y];if(Z==null)return!1;return String(Z).toLowerCase()==="true"}return f6}var h6,ZZ;function HQ(){if(ZZ)return h6;ZZ=1,h6=d;function $(p){var P=this;this.next=null,this.entry=null,this.finish=function(){Z0(P,p)}}var U;d.WritableState=y;var Y={deprecate:$X()},Z=ZQ(),J=o1().Buffer,G=(typeof c0<"u"?c0:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function X(p){return J.from(p)}function Q(p){return J.isBuffer(p)||p instanceof G}var B=wQ(),F=WQ(),z=F.getHighWaterMark,W=i2().codes,k=W.ERR_INVALID_ARG_TYPE,D=W.ERR_METHOD_NOT_IMPLEMENTED,C=W.ERR_MULTIPLE_CALLBACK,H=W.ERR_STREAM_CANNOT_PIPE,O=W.ERR_STREAM_DESTROYED,V=W.ERR_STREAM_NULL_VALUES,j=W.ERR_STREAM_WRITE_AFTER_END,M=W.ERR_UNKNOWN_ENCODING,L=B.errorOrDestroy;R2()(d,Z);function A(){}function y(p,P,R){if(U=U||l2(),p=p||{},typeof R!=="boolean")R=P instanceof U;if(this.objectMode=!!p.objectMode,R)this.objectMode=this.objectMode||!!p.writableObjectMode;this.highWaterMark=z(this,p,"writableHighWaterMark",R),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var c=p.decodeStrings===!1;this.decodeStrings=!c,this.defaultEncoding=p.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(f){$0(P,f)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=p.emitClose!==!1,this.autoDestroy=!!p.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new $(this)}y.prototype.getBuffer=function(){var P=this.bufferedRequest,R=[];while(P)R.push(P),P=P.next;return R},function(){try{Object.defineProperty(y.prototype,"buffer",{get:Y.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(p){}}();var g;if(typeof Symbol==="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==="function")g=Function.prototype[Symbol.hasInstance],Object.defineProperty(d,Symbol.hasInstance,{value:function(P){if(g.call(this,P))return!0;if(this!==d)return!1;return P&&P._writableState instanceof y}});else g=function(P){return P instanceof this};function d(p){U=U||l2();var P=this instanceof U;if(!P&&!g.call(d,this))return new d(p);if(this._writableState=new y(p,this,P),this.writable=!0,p){if(typeof p.write==="function")this._write=p.write;if(typeof p.writev==="function")this._writev=p.writev;if(typeof p.destroy==="function")this._destroy=p.destroy;if(typeof p.final==="function")this._final=p.final}Z.call(this)}d.prototype.pipe=function(){L(this,new H)};function E(p,P){var R=new j;L(p,R),j0.nextTick(P,R)}function s(p,P,R,c){var f;if(R===null)f=new V;else if(typeof R!=="string"&&!P.objectMode)f=new k("chunk",["string","Buffer"],R);if(f)return L(p,f),j0.nextTick(c,f),!1;return!0}d.prototype.write=function(p,P,R){var c=this._writableState,f=!1,v=!c.objectMode&&Q(p);if(v&&!J.isBuffer(p))p=X(p);if(typeof P==="function")R=P,P=null;if(v)P="buffer";else if(!P)P=c.defaultEncoding;if(typeof R!=="function")R=A;if(c.ending)E(this,R);else if(v||s(this,c,p,R))c.pendingcb++,f=S(this,c,v,p,P,R);return f},d.prototype.cork=function(){this._writableState.corked++},d.prototype.uncork=function(){var p=this._writableState;if(p.corked){if(p.corked--,!p.writing&&!p.corked&&!p.bufferProcessing&&p.bufferedRequest)U0(this,p)}},d.prototype.setDefaultEncoding=function(P){if(typeof P==="string")P=P.toLowerCase();if(!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((P+"").toLowerCase())>-1))throw new M(P);return this._writableState.defaultEncoding=P,this},Object.defineProperty(d.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function V0(p,P,R){if(!p.objectMode&&p.decodeStrings!==!1&&typeof P==="string")P=J.from(P,R);return P}Object.defineProperty(d.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function S(p,P,R,c,f,v){if(!R){var b=V0(P,c,f);if(c!==b)R=!0,f="buffer",c=b}var e=P.objectMode?1:c.length;P.length+=e;var I=P.length>5===6)return 2;else if(V>>4===14)return 3;else if(V>>3===30)return 4;return V>>6===2?-1:-2}function X(V,j,M){var L=j.length-1;if(L=0){if(A>0)V.lastNeed=A-1;return A}if(--L=0){if(A>0)V.lastNeed=A-2;return A}if(--L=0){if(A>0)if(A===2)A=0;else V.lastNeed=A-3;return A}return 0}function Q(V,j,M){if((j[0]&192)!==128)return V.lastNeed=0,"�";if(V.lastNeed>1&&j.length>1){if((j[1]&192)!==128)return V.lastNeed=1,"�";if(V.lastNeed>2&&j.length>2){if((j[2]&192)!==128)return V.lastNeed=2,"�"}}}function B(V){var j=this.lastTotal-this.lastNeed,M=Q(this,V);if(M!==void 0)return M;if(this.lastNeed<=V.length)return V.copy(this.lastChar,j,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);V.copy(this.lastChar,j,0,V.length),this.lastNeed-=V.length}function F(V,j){var M=X(this,V,j);if(!this.lastNeed)return V.toString("utf8",j);this.lastTotal=M;var L=V.length-(M-this.lastNeed);return V.copy(this.lastChar,0,L),V.toString("utf8",j,L)}function z(V){var j=V&&V.length?this.write(V):"";if(this.lastNeed)return j+"�";return j}function W(V,j){if((V.length-j)%2===0){var M=V.toString("utf16le",j);if(M){var L=M.charCodeAt(M.length-1);if(L>=55296&&L<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=V[V.length-2],this.lastChar[1]=V[V.length-1],M.slice(0,-1)}return M}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=V[V.length-1],V.toString("utf16le",j,V.length-1)}function k(V){var j=V&&V.length?this.write(V):"";if(this.lastNeed){var M=this.lastTotal-this.lastNeed;return j+this.lastChar.toString("utf16le",0,M)}return j}function D(V,j){var M=(V.length-j)%3;if(M===0)return V.toString("base64",j);if(this.lastNeed=3-M,this.lastTotal=3,M===1)this.lastChar[0]=V[V.length-1];else this.lastChar[0]=V[V.length-2],this.lastChar[1]=V[V.length-1];return V.toString("base64",j,V.length-M)}function C(V){var j=V&&V.length?this.write(V):"";if(this.lastNeed)return j+this.lastChar.toString("base64",0,3-this.lastNeed);return j}function H(V){return V.toString(this.encoding)}function O(V){return V&&V.length?this.write(V):""}return d6}var c6,KZ;function c9(){if(KZ)return c6;KZ=1;var $=i2().codes.ERR_STREAM_PREMATURE_CLOSE;function U(G){var X=!1;return function(){if(X)return;X=!0;for(var Q=arguments.length,B=Array(Q),F=0;F0){if(typeof b!=="string"&&!T.objectMode&&Object.getPrototypeOf(b)!==Z.prototype)b=G(b);if(I)if(T.endEmitted)A(v,new V);else V0(v,T,b,!0);else if(T.ended)A(v,new H);else if(T.destroyed)return!1;else if(T.reading=!1,T.decoder&&!e)if(b=T.decoder.write(b),T.objectMode||b.length!==0)V0(v,T,b,!1);else U0(v,T);else V0(v,T,b,!1)}else if(!I)T.reading=!1,U0(v,T)}return!T.ended&&(T.length=h)v=h;else v--,v|=v>>>1,v|=v>>>2,v|=v>>>4,v|=v>>>8,v|=v>>>16,v++;return v}function a(v,b){if(v<=0||b.length===0&&b.ended)return 0;if(b.objectMode)return 1;if(v!==v)if(b.flowing&&b.length)return b.buffer.head.data.length;else return b.length;if(v>b.highWaterMark)b.highWaterMark=N(v);if(v<=b.length)return v;if(!b.ended)return b.needReadable=!0,0;return b.length}E.prototype.read=function(v){B("read",v),v=parseInt(v,10);var b=this._readableState,e=v;if(v!==0)b.emittedReadable=!1;if(v===0&&b.needReadable&&((b.highWaterMark!==0?b.length>=b.highWaterMark:b.length>0)||b.ended)){if(B("read: emitReadable",b.length,b.ended),b.length===0&&b.ended)R(this);else m(this);return null}if(v=a(v,b),v===0&&b.ended){if(b.length===0)R(this);return null}var I=b.needReadable;if(B("need readable",I),b.length===0||b.length-v0)t=P(v,b);else t=null;if(t===null)b.needReadable=b.length<=b.highWaterMark,v=0;else b.length-=v,b.awaitDrain=0;if(b.length===0){if(!b.ended)b.needReadable=!0;if(e!==v&&b.ended)R(this)}if(t!==null)this.emit("data",t);return t};function $0(v,b){if(B("onEofChunk"),b.ended)return;if(b.decoder){var e=b.decoder.end();if(e&&e.length)b.buffer.push(e),b.length+=b.objectMode?1:e.length}if(b.ended=!0,b.sync)m(v);else if(b.needReadable=!1,!b.emittedReadable)b.emittedReadable=!0,J0(v)}function m(v){var b=v._readableState;if(B("emitReadable",b.needReadable,b.emittedReadable),b.needReadable=!1,!b.emittedReadable)B("emitReadable",b.flowing),b.emittedReadable=!0,j0.nextTick(J0,v)}function J0(v){var b=v._readableState;if(B("emitReadable_",b.destroyed,b.length,b.ended),!b.destroyed&&(b.length||b.ended))v.emit("readable"),b.emittedReadable=!1;b.needReadable=!b.flowing&&!b.ended&&b.length<=b.highWaterMark,p(v)}function U0(v,b){if(!b.readingMore)b.readingMore=!0,j0.nextTick(L0,v,b)}function L0(v,b){while(!b.reading&&!b.ended&&(b.length1&&f(I.pipes,v)!==-1)&&!x)B("false write response, pause",I.awaitDrain),I.awaitDrain++;e.pause()}}function Q0(w0){if(B("onerror",w0),M0(),v.removeListener("error",Q0),U(v,"error")===0)A(v,w0)}g(v,"error",Q0);function q0(){v.removeListener("finish",K0),M0()}v.once("close",q0);function K0(){B("onfinish"),v.removeListener("close",q0),M0()}v.once("finish",K0);function M0(){B("unpipe"),e.unpipe(v)}if(v.emit("pipe",e),!I.flowing)B("pipe resume"),e.resume();return v};function i(v){return function(){var e=v._readableState;if(B("pipeOnDrain",e.awaitDrain),e.awaitDrain)e.awaitDrain--;if(e.awaitDrain===0&&U(v,"data"))e.flowing=!0,p(v)}}E.prototype.unpipe=function(v){var b=this._readableState,e={hasUnpiped:!1};if(b.pipesCount===0)return this;if(b.pipesCount===1){if(v&&v!==b.pipes)return this;if(!v)v=b.pipes;if(b.pipes=null,b.pipesCount=0,b.flowing=!1,v)v.emit("unpipe",this,e);return this}if(!v){var{pipes:I,pipesCount:t}=b;b.pipes=null,b.pipesCount=0,b.flowing=!1;for(var T=0;T0,I.flowing!==!1)this.resume()}else if(v==="readable"){if(!I.endEmitted&&!I.readableListening){if(I.readableListening=I.needReadable=!0,I.flowing=!1,I.emittedReadable=!1,B("on readable",I.length,I.reading),I.length)m(this);else if(!I.reading)j0.nextTick(r,this)}}return e},E.prototype.addListener=E.prototype.on,E.prototype.removeListener=function(v,b){var e=Y.prototype.removeListener.call(this,v,b);if(v==="readable")j0.nextTick(_,this);return e},E.prototype.removeAllListeners=function(v){var b=Y.prototype.removeAllListeners.apply(this,arguments);if(v==="readable"||v===void 0)j0.nextTick(_,this);return b};function _(v){var b=v._readableState;if(b.readableListening=v.listenerCount("readable")>0,b.resumeScheduled&&!b.paused)b.flowing=!0;else if(v.listenerCount("data")>0)v.resume()}function r(v){B("readable nexttick read 0"),v.read(0)}E.prototype.resume=function(){var v=this._readableState;if(!v.flowing)B("resume"),v.flowing=!v.readableListening,n(this,v);return v.paused=!1,this};function n(v,b){if(!b.resumeScheduled)b.resumeScheduled=!0,j0.nextTick(Z0,v,b)}function Z0(v,b){if(B("resume",b.reading),!b.reading)v.read(0);if(b.resumeScheduled=!1,v.emit("resume"),p(v),b.flowing&&!b.reading)v.read(0)}E.prototype.pause=function(){if(B("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1)B("pause"),this._readableState.flowing=!1,this.emit("pause");return this._readableState.paused=!0,this};function p(v){var b=v._readableState;B("flow",b.flowing);while(b.flowing&&v.read()!==null);}if(E.prototype.wrap=function(v){var b=this,e=this._readableState,I=!1;v.on("end",function(){if(B("wrapped end"),e.decoder&&!e.ended){var K=e.decoder.end();if(K&&K.length)b.push(K)}b.push(null)}),v.on("data",function(K){if(B("wrapped data"),e.decoder)K=e.decoder.write(K);if(e.objectMode&&(K===null||K===void 0))return;else if(!e.objectMode&&(!K||!K.length))return;var q=b.push(K);if(!q)I=!0,v.pause()});for(var t in v)if(this[t]===void 0&&typeof v[t]==="function")this[t]=function(q){return function(){return v[q].apply(v,arguments)}}(t);for(var T=0;T=b.length){if(b.decoder)e=b.buffer.join("");else if(b.buffer.length===1)e=b.buffer.first();else e=b.buffer.concat(b.length);b.buffer.clear()}else e=b.buffer.consume(v,b.decoder);return e}function R(v){var b=v._readableState;if(B("endReadable",b.endEmitted),!b.endEmitted)b.ended=!0,j0.nextTick(c,b,v)}function c(v,b){if(B("endReadableNT",v.endEmitted,v.length),!v.endEmitted&&v.length===0){if(v.endEmitted=!0,b.readable=!1,b.emit("end"),v.autoDestroy){var e=b._writableState;if(!e||e.autoDestroy&&e.finished)b.destroy()}}}if(typeof Symbol==="function")E.from=function(v,b){if(L===void 0)L=ZX();return L(E,v,b)};function f(v,b){for(var e=0,I=v.length;e0;return Q(j,L,A,function(y){if(!O)O=y;if(y)V.forEach(B);if(L)return;V.forEach(B),H(O)})});return D.reduce(F)}return r6=W,r6}var s6,IZ;function m9(){if(IZ)return s6;IZ=1,s6=Y;var $=x9().EventEmitter,U=R2();U(Y,$),Y.Readable=jQ(),Y.Writable=HQ(),Y.Duplex=l2(),Y.Transform=zQ(),Y.PassThrough=QX(),Y.finished=c9(),Y.pipeline=JX(),Y.Stream=Y;function Y(){$.call(this)}return Y.prototype.pipe=function(Z,J){var G=this;function X(D){if(Z.writable){if(Z.write(D)===!1&&G.pause)G.pause()}}G.on("data",X);function Q(){if(G.readable&&G.resume)G.resume()}if(Z.on("drain",Q),!Z._isStdio&&(!J||J.end!==!1))G.on("end",F),G.on("close",z);var B=!1;function F(){if(B)return;B=!0,Z.end()}function z(){if(B)return;if(B=!0,typeof Z.destroy==="function")Z.destroy()}function W(D){if(k(),$.listenerCount(this,"error")===0)throw D}G.on("error",W),Z.on("error",W);function k(){G.removeListener("data",X),Z.removeListener("drain",Q),G.removeListener("end",F),G.removeListener("close",z),G.removeListener("error",W),Z.removeListener("error",W),G.removeListener("end",k),G.removeListener("close",k),Z.removeListener("close",k)}return G.on("end",k),G.on("close",k),Z.on("close",k),Z.emit("pipe",G),Z},s6}var wZ;function GX(){if(wZ)return _8;return wZ=1,function($){(function(U){U.parser=function(P,R){return new Z(P,R)},U.SAXParser=Z,U.SAXStream=z,U.createStream=F,U.MAX_BUFFER_LENGTH=65536;var Y=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];U.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function Z(P,R){if(!(this instanceof Z))return new Z(P,R);var c=this;if(G(c),c.q=c.c="",c.bufferCheckPosition=U.MAX_BUFFER_LENGTH,c.opt=R||{},c.opt.lowercase=c.opt.lowercase||c.opt.lowercasetags,c.looseCase=c.opt.lowercase?"toLowerCase":"toUpperCase",c.tags=[],c.closed=c.closedRoot=c.sawRoot=!1,c.tag=c.error=null,c.strict=!!P,c.noscript=!!(P||c.opt.noscript),c.state=E.BEGIN,c.strictEntities=c.opt.strictEntities,c.ENTITIES=c.strictEntities?Object.create(U.XML_ENTITIES):Object.create(U.ENTITIES),c.attribList=[],c.opt.xmlns)c.ns=Object.create(H);if(c.trackPosition=c.opt.position!==!1,c.trackPosition)c.position=c.line=c.column=0;V0(c,"onready")}if(!Object.create)Object.create=function(P){function R(){}R.prototype=P;var c=new R;return c};if(!Object.keys)Object.keys=function(P){var R=[];for(var c in P)if(P.hasOwnProperty(c))R.push(c);return R};function J(P){var R=Math.max(U.MAX_BUFFER_LENGTH,10),c=0;for(var f=0,v=Y.length;fR)switch(Y[f]){case"textNode":h(P);break;case"cdata":S(P,"oncdata",P.cdata),P.cdata="";break;case"script":S(P,"onscript",P.script),P.script="";break;default:a(P,"Max buffer length exceeded: "+Y[f])}c=Math.max(c,b)}var e=U.MAX_BUFFER_LENGTH-c;P.bufferCheckPosition=e+P.position}function G(P){for(var R=0,c=Y.length;R"||L(P)}function g(P,R){return P.test(R)}function d(P,R){return!g(P,R)}var E=0;U.STATE={BEGIN:E++,BEGIN_WHITESPACE:E++,TEXT:E++,TEXT_ENTITY:E++,OPEN_WAKA:E++,SGML_DECL:E++,SGML_DECL_QUOTED:E++,DOCTYPE:E++,DOCTYPE_QUOTED:E++,DOCTYPE_DTD:E++,DOCTYPE_DTD_QUOTED:E++,COMMENT_STARTING:E++,COMMENT:E++,COMMENT_ENDING:E++,COMMENT_ENDED:E++,CDATA:E++,CDATA_ENDING:E++,CDATA_ENDING_2:E++,PROC_INST:E++,PROC_INST_BODY:E++,PROC_INST_ENDING:E++,OPEN_TAG:E++,OPEN_TAG_SLASH:E++,ATTRIB:E++,ATTRIB_NAME:E++,ATTRIB_NAME_SAW_WHITE:E++,ATTRIB_VALUE:E++,ATTRIB_VALUE_QUOTED:E++,ATTRIB_VALUE_CLOSED:E++,ATTRIB_VALUE_UNQUOTED:E++,ATTRIB_VALUE_ENTITY_Q:E++,ATTRIB_VALUE_ENTITY_U:E++,CLOSE_TAG:E++,CLOSE_TAG_SAW_WHITE:E++,SCRIPT:E++,SCRIPT_ENDING:E++},U.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},U.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(U.ENTITIES).forEach(function(P){var R=U.ENTITIES[P],c=typeof R==="number"?String.fromCharCode(R):R;U.ENTITIES[P]=c});for(var s in U.STATE)U.STATE[U.STATE[s]]=s;E=U.STATE;function V0(P,R,c){P[R]&&P[R](c)}function S(P,R,c){if(P.textNode)h(P);V0(P,R,c)}function h(P){if(P.textNode=N(P.opt,P.textNode),P.textNode)V0(P,"ontext",P.textNode);P.textNode=""}function N(P,R){if(P.trim)R=R.trim();if(P.normalize)R=R.replace(/\s+/g," ");return R}function a(P,R){if(h(P),P.trackPosition)R+=` -Line: `+P.line+` -Column: `+P.column+` -Char: `+P.c;return R=Error(R),P.error=R,V0(P,"onerror",R),P}function $0(P){if(P.sawRoot&&!P.closedRoot)m(P,"Unclosed root tag");if(P.state!==E.BEGIN&&P.state!==E.BEGIN_WHITESPACE&&P.state!==E.TEXT)a(P,"Unexpected end");return h(P),P.c="",P.closed=!0,V0(P,"onend"),Z.call(P,P.strict,P.opt),P}function m(P,R){if(typeof P!=="object"||!(P instanceof Z))throw Error("bad call to strictFail");if(P.strict)a(P,R)}function J0(P){if(!P.strict)P.tagName=P.tagName[P.looseCase]();var R=P.tags[P.tags.length-1]||P,c=P.tag={name:P.tagName,attributes:{}};if(P.opt.xmlns)c.ns=R.ns;P.attribList.length=0,S(P,"onopentagstart",c)}function U0(P,R){var c=P.indexOf(":"),f=c<0?["",P]:P.split(":"),v=f[0],b=f[1];if(R&&P==="xmlns")v="xmlns",b="";return{prefix:v,local:b}}function L0(P){if(!P.strict)P.attribName=P.attribName[P.looseCase]();if(P.attribList.indexOf(P.attribName)!==-1||P.tag.attributes.hasOwnProperty(P.attribName)){P.attribName=P.attribValue="";return}if(P.opt.xmlns){var R=U0(P.attribName,!0),c=R.prefix,f=R.local;if(c==="xmlns")if(f==="xml"&&P.attribValue!==D)m(P,"xml: prefix must be bound to "+D+` -Actual: `+P.attribValue);else if(f==="xmlns"&&P.attribValue!==C)m(P,"xmlns: prefix must be bound to "+C+` -Actual: `+P.attribValue);else{var v=P.tag,b=P.tags[P.tags.length-1]||P;if(v.ns===b.ns)v.ns=Object.create(b.ns);v.ns[f]=P.attribValue}P.attribList.push([P.attribName,P.attribValue])}else P.tag.attributes[P.attribName]=P.attribValue,S(P,"onattribute",{name:P.attribName,value:P.attribValue});P.attribName=P.attribValue=""}function i(P,R){if(P.opt.xmlns){var c=P.tag,f=U0(P.tagName);if(c.prefix=f.prefix,c.local=f.local,c.uri=c.ns[f.prefix]||"",c.prefix&&!c.uri)m(P,"Unbound namespace prefix: "+JSON.stringify(P.tagName)),c.uri=f.prefix;var v=P.tags[P.tags.length-1]||P;if(c.ns&&v.ns!==c.ns)Object.keys(c.ns).forEach(function(u){S(P,"onopennamespace",{prefix:u,uri:c.ns[u]})});for(var b=0,e=P.attribList.length;b",P.tagName="",P.state=E.SCRIPT;return}S(P,"onscript",P.script),P.script=""}var R=P.tags.length,c=P.tagName;if(!P.strict)c=c[P.looseCase]();var f=c;while(R--){var v=P.tags[R];if(v.name!==f)m(P,"Unexpected close tag");else break}if(R<0){m(P,"Unmatched closing tag: "+P.tagName),P.textNode+="",P.state=E.TEXT;return}P.tagName=c;var b=P.tags.length;while(b-- >R){var e=P.tag=P.tags.pop();P.tagName=P.tag.name,S(P,"onclosetag",P.tagName);var I={};for(var t in e.ns)I[t]=e.ns[t];var T=P.tags[P.tags.length-1]||P;if(P.opt.xmlns&&e.ns!==T.ns)Object.keys(e.ns).forEach(function(K){var q=e.ns[K];S(P,"onclosenamespace",{prefix:K,uri:q})})}if(R===0)P.closedRoot=!0;P.tagName=P.attribValue=P.attribName="",P.attribList.length=0,P.state=E.TEXT}function r(P){var R=P.entity,c=R.toLowerCase(),f,v="";if(P.ENTITIES[R])return P.ENTITIES[R];if(P.ENTITIES[c])return P.ENTITIES[c];if(R=c,R.charAt(0)==="#")if(R.charAt(1)==="x")R=R.slice(2),f=parseInt(R,16),v=f.toString(16);else R=R.slice(1),f=parseInt(R,10),v=f.toString(10);if(R=R.replace(/^0+/,""),isNaN(f)||v.toLowerCase()!==R)return m(P,"Invalid character entity"),"&"+P.entity+";";return String.fromCodePoint(f)}function n(P,R){if(R==="<")P.state=E.OPEN_WAKA,P.startTagPosition=P.position;else if(!L(R))m(P,"Non-whitespace before first tag."),P.textNode=R,P.state=E.TEXT}function Z0(P,R){var c="";if(R")S(R,"onsgmldeclaration",R.sgmlDecl),R.sgmlDecl="",R.state=E.TEXT;else if(A(f))R.state=E.SGML_DECL_QUOTED,R.sgmlDecl+=f;else R.sgmlDecl+=f;continue;case E.SGML_DECL_QUOTED:if(f===R.q)R.state=E.SGML_DECL,R.q="";R.sgmlDecl+=f;continue;case E.DOCTYPE:if(f===">")R.state=E.TEXT,S(R,"ondoctype",R.doctype),R.doctype=!0;else if(R.doctype+=f,f==="[")R.state=E.DOCTYPE_DTD;else if(A(f))R.state=E.DOCTYPE_QUOTED,R.q=f;continue;case E.DOCTYPE_QUOTED:if(R.doctype+=f,f===R.q)R.q="",R.state=E.DOCTYPE;continue;case E.DOCTYPE_DTD:if(R.doctype+=f,f==="]")R.state=E.DOCTYPE;else if(A(f))R.state=E.DOCTYPE_DTD_QUOTED,R.q=f;continue;case E.DOCTYPE_DTD_QUOTED:if(R.doctype+=f,f===R.q)R.state=E.DOCTYPE_DTD,R.q="";continue;case E.COMMENT:if(f==="-")R.state=E.COMMENT_ENDING;else R.comment+=f;continue;case E.COMMENT_ENDING:if(f==="-"){if(R.state=E.COMMENT_ENDED,R.comment=N(R.opt,R.comment),R.comment)S(R,"oncomment",R.comment);R.comment=""}else R.comment+="-"+f,R.state=E.COMMENT;continue;case E.COMMENT_ENDED:if(f!==">")m(R,"Malformed comment"),R.comment+="--"+f,R.state=E.COMMENT;else R.state=E.TEXT;continue;case E.CDATA:if(f==="]")R.state=E.CDATA_ENDING;else R.cdata+=f;continue;case E.CDATA_ENDING:if(f==="]")R.state=E.CDATA_ENDING_2;else R.cdata+="]"+f,R.state=E.CDATA;continue;case E.CDATA_ENDING_2:if(f===">"){if(R.cdata)S(R,"oncdata",R.cdata);S(R,"onclosecdata"),R.cdata="",R.state=E.TEXT}else if(f==="]")R.cdata+="]";else R.cdata+="]]"+f,R.state=E.CDATA;continue;case E.PROC_INST:if(f==="?")R.state=E.PROC_INST_ENDING;else if(L(f))R.state=E.PROC_INST_BODY;else R.procInstName+=f;continue;case E.PROC_INST_BODY:if(!R.procInstBody&&L(f))continue;else if(f==="?")R.state=E.PROC_INST_ENDING;else R.procInstBody+=f;continue;case E.PROC_INST_ENDING:if(f===">")S(R,"onprocessinginstruction",{name:R.procInstName,body:R.procInstBody}),R.procInstName=R.procInstBody="",R.state=E.TEXT;else R.procInstBody+="?"+f,R.state=E.PROC_INST_BODY;continue;case E.OPEN_TAG:if(g(V,f))R.tagName+=f;else if(J0(R),f===">")i(R);else if(f==="/")R.state=E.OPEN_TAG_SLASH;else{if(!L(f))m(R,"Invalid character in tag name");R.state=E.ATTRIB}continue;case E.OPEN_TAG_SLASH:if(f===">")i(R,!0),_(R);else m(R,"Forward-slash in opening tag not followed by >"),R.state=E.ATTRIB;continue;case E.ATTRIB:if(L(f))continue;else if(f===">")i(R);else if(f==="/")R.state=E.OPEN_TAG_SLASH;else if(g(O,f))R.attribName=f,R.attribValue="",R.state=E.ATTRIB_NAME;else m(R,"Invalid attribute name");continue;case E.ATTRIB_NAME:if(f==="=")R.state=E.ATTRIB_VALUE;else if(f===">")m(R,"Attribute without value"),R.attribValue=R.attribName,L0(R),i(R);else if(L(f))R.state=E.ATTRIB_NAME_SAW_WHITE;else if(g(V,f))R.attribName+=f;else m(R,"Invalid attribute name");continue;case E.ATTRIB_NAME_SAW_WHITE:if(f==="=")R.state=E.ATTRIB_VALUE;else if(L(f))continue;else if(m(R,"Attribute without value"),R.tag.attributes[R.attribName]="",R.attribValue="",S(R,"onattribute",{name:R.attribName,value:""}),R.attribName="",f===">")i(R);else if(g(O,f))R.attribName=f,R.state=E.ATTRIB_NAME;else m(R,"Invalid attribute name"),R.state=E.ATTRIB;continue;case E.ATTRIB_VALUE:if(L(f))continue;else if(A(f))R.q=f,R.state=E.ATTRIB_VALUE_QUOTED;else m(R,"Unquoted attribute value"),R.state=E.ATTRIB_VALUE_UNQUOTED,R.attribValue=f;continue;case E.ATTRIB_VALUE_QUOTED:if(f!==R.q){if(f==="&")R.state=E.ATTRIB_VALUE_ENTITY_Q;else R.attribValue+=f;continue}L0(R),R.q="",R.state=E.ATTRIB_VALUE_CLOSED;continue;case E.ATTRIB_VALUE_CLOSED:if(L(f))R.state=E.ATTRIB;else if(f===">")i(R);else if(f==="/")R.state=E.OPEN_TAG_SLASH;else if(g(O,f))m(R,"No whitespace between attributes"),R.attribName=f,R.attribValue="",R.state=E.ATTRIB_NAME;else m(R,"Invalid attribute name");continue;case E.ATTRIB_VALUE_UNQUOTED:if(!y(f)){if(f==="&")R.state=E.ATTRIB_VALUE_ENTITY_U;else R.attribValue+=f;continue}if(L0(R),f===">")i(R);else R.state=E.ATTRIB;continue;case E.CLOSE_TAG:if(!R.tagName)if(L(f))continue;else if(d(O,f))if(R.script)R.script+="")_(R);else if(g(V,f))R.tagName+=f;else if(R.script)R.script+="")_(R);else m(R,"Invalid characters in closing tag");continue;case E.TEXT_ENTITY:case E.ATTRIB_VALUE_ENTITY_Q:case E.ATTRIB_VALUE_ENTITY_U:var e,I;switch(R.state){case E.TEXT_ENTITY:e=E.TEXT,I="textNode";break;case E.ATTRIB_VALUE_ENTITY_Q:e=E.ATTRIB_VALUE_QUOTED,I="attribValue";break;case E.ATTRIB_VALUE_ENTITY_U:e=E.ATTRIB_VALUE_UNQUOTED,I="attribValue";break}if(f===";")R[I]+=r(R),R.entity="",R.state=e;else if(g(R.entity.length?M:j,f))R.entity+=f;else m(R,"Invalid character in entity name"),R[I]+="&"+R.entity+f,R.entity="",R.state=e;continue;default:throw Error(R,"Unknown state: "+R.state)}}if(R.position>=R.bufferCheckPosition)J(R);return R}if(!String.fromCodePoint)(function(){var P=String.fromCharCode,R=Math.floor,c=function(){var f=16384,v=[],b,e,I=-1,t=arguments.length;if(!t)return"";var T="";while(++I1114111||R(K)!==K)throw RangeError("Invalid code point: "+K);if(K<=65535)v.push(K);else K-=65536,b=(K>>10)+55296,e=K%1024+56320,v.push(b,e);if(I+1===t||v.length>f)T+=P.apply(null,v),v.length=0}return T};if(Object.defineProperty)Object.defineProperty(String,"fromCodePoint",{value:c,configurable:!0,writable:!0});else String.fromCodePoint=c})()})($)}(_8),_8}var n6,WZ;function l9(){if(WZ)return n6;return WZ=1,n6={isArray:function($){if(Array.isArray)return Array.isArray($);return Object.prototype.toString.call($)==="[object Array]"}},n6}var o6,HZ;function a9(){if(HZ)return o6;HZ=1;var $=l9().isArray;return o6={copyOptions:function(U){var Y,Z={};for(Y in U)if(U.hasOwnProperty(Y))Z[Y]=U[Y];return Z},ensureFlagExists:function(U,Y){if(!(U in Y)||typeof Y[U]!=="boolean")Y[U]=!1},ensureSpacesExists:function(U){if(!("spaces"in U)||typeof U.spaces!=="number"&&typeof U.spaces!=="string")U.spaces=0},ensureAlwaysArrayExists:function(U){if(!("alwaysArray"in U)||typeof U.alwaysArray!=="boolean"&&!$(U.alwaysArray))U.alwaysArray=!1},ensureKeyExists:function(U,Y){if(!(U+"Key"in Y)||typeof Y[U+"Key"]!=="string")Y[U+"Key"]=Y.compact?"_"+U:U},checkFnExists:function(U,Y){return U+"Fn"in Y}},o6}var t6,jZ;function FQ(){if(jZ)return t6;jZ=1;var $=GX(),U=a9(),Y=l9().isArray,Z,J;function G(V){return Z=U.copyOptions(V),U.ensureFlagExists("ignoreDeclaration",Z),U.ensureFlagExists("ignoreInstruction",Z),U.ensureFlagExists("ignoreAttributes",Z),U.ensureFlagExists("ignoreText",Z),U.ensureFlagExists("ignoreComment",Z),U.ensureFlagExists("ignoreCdata",Z),U.ensureFlagExists("ignoreDoctype",Z),U.ensureFlagExists("compact",Z),U.ensureFlagExists("alwaysChildren",Z),U.ensureFlagExists("addParent",Z),U.ensureFlagExists("trim",Z),U.ensureFlagExists("nativeType",Z),U.ensureFlagExists("nativeTypeAttributes",Z),U.ensureFlagExists("sanitize",Z),U.ensureFlagExists("instructionHasAttributes",Z),U.ensureFlagExists("captureSpacesBetweenElements",Z),U.ensureAlwaysArrayExists(Z),U.ensureKeyExists("declaration",Z),U.ensureKeyExists("instruction",Z),U.ensureKeyExists("attributes",Z),U.ensureKeyExists("text",Z),U.ensureKeyExists("comment",Z),U.ensureKeyExists("cdata",Z),U.ensureKeyExists("doctype",Z),U.ensureKeyExists("type",Z),U.ensureKeyExists("name",Z),U.ensureKeyExists("elements",Z),U.ensureKeyExists("parent",Z),U.checkFnExists("doctype",Z),U.checkFnExists("instruction",Z),U.checkFnExists("cdata",Z),U.checkFnExists("comment",Z),U.checkFnExists("text",Z),U.checkFnExists("instructionName",Z),U.checkFnExists("elementName",Z),U.checkFnExists("attributeName",Z),U.checkFnExists("attributeValue",Z),U.checkFnExists("attributes",Z),Z}function X(V){var j=Number(V);if(!isNaN(j))return j;var M=V.toLowerCase();if(M==="true")return!0;else if(M==="false")return!1;return V}function Q(V,j){var M;if(Z.compact){if(!J[Z[V+"Key"]]&&(Y(Z.alwaysArray)?Z.alwaysArray.indexOf(Z[V+"Key"])!==-1:Z.alwaysArray))J[Z[V+"Key"]]=[];if(J[Z[V+"Key"]]&&!Y(J[Z[V+"Key"]]))J[Z[V+"Key"]]=[J[Z[V+"Key"]]];if(V+"Fn"in Z&&typeof j==="string")j=Z[V+"Fn"](j,J);if(V==="instruction"&&(("instructionFn"in Z)||("instructionNameFn"in Z))){for(M in j)if(j.hasOwnProperty(M))if("instructionFn"in Z)j[M]=Z.instructionFn(j[M],M,J);else{var L=j[M];delete j[M],j[Z.instructionNameFn(M,L,J)]=L}}if(Y(J[Z[V+"Key"]]))J[Z[V+"Key"]].push(j);else J[Z[V+"Key"]]=j}else{if(!J[Z.elementsKey])J[Z.elementsKey]=[];var A={};if(A[Z.typeKey]=V,V==="instruction"){for(M in j)if(j.hasOwnProperty(M))break;if(A[Z.nameKey]="instructionNameFn"in Z?Z.instructionNameFn(M,j,J):M,Z.instructionHasAttributes){if(A[Z.attributesKey]=j[M][Z.attributesKey],"instructionFn"in Z)A[Z.attributesKey]=Z.instructionFn(A[Z.attributesKey],M,J)}else{if("instructionFn"in Z)j[M]=Z.instructionFn(j[M],M,J);A[Z.instructionKey]=j[M]}}else{if(V+"Fn"in Z)j=Z[V+"Fn"](j,J);A[Z[V+"Key"]]=j}if(Z.addParent)A[Z.parentKey]=J;J[Z.elementsKey].push(A)}}function B(V){if("attributesFn"in Z&&V)V=Z.attributesFn(V,J);if((Z.trim||("attributeValueFn"in Z)||("attributeNameFn"in Z)||Z.nativeTypeAttributes)&&V){var j;for(j in V)if(V.hasOwnProperty(j)){if(Z.trim)V[j]=V[j].trim();if(Z.nativeTypeAttributes)V[j]=X(V[j]);if("attributeValueFn"in Z)V[j]=Z.attributeValueFn(V[j],j,J);if("attributeNameFn"in Z){var M=V[j];delete V[j],V[Z.attributeNameFn(j,V[j],J)]=M}}}return V}function F(V){var j={};if(V.body&&(V.name.toLowerCase()==="xml"||Z.instructionHasAttributes)){var M=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,L;while((L=M.exec(V.body))!==null)j[L[1]]=L[2]||L[3]||L[4];j=B(j)}if(V.name.toLowerCase()==="xml"){if(Z.ignoreDeclaration)return;if(J[Z.declarationKey]={},Object.keys(j).length)J[Z.declarationKey][Z.attributesKey]=j;if(Z.addParent)J[Z.declarationKey][Z.parentKey]=J}else{if(Z.ignoreInstruction)return;if(Z.trim)V.body=V.body.trim();var A={};if(Z.instructionHasAttributes&&Object.keys(j).length)A[V.name]={},A[V.name][Z.attributesKey]=j;else A[V.name]=V.body;Q("instruction",A)}}function z(V,j){var M;if(typeof V==="object")j=V.attributes,V=V.name;if(j=B(j),"elementNameFn"in Z)V=Z.elementNameFn(V,J);if(Z.compact){if(M={},!Z.ignoreAttributes&&j&&Object.keys(j).length){M[Z.attributesKey]={};var L;for(L in j)if(j.hasOwnProperty(L))M[Z.attributesKey][L]=j[L]}if(!(V in J)&&(Y(Z.alwaysArray)?Z.alwaysArray.indexOf(V)!==-1:Z.alwaysArray))J[V]=[];if(J[V]&&!Y(J[V]))J[V]=[J[V]];if(Y(J[V]))J[V].push(M);else J[V]=M}else{if(!J[Z.elementsKey])J[Z.elementsKey]=[];if(M={},M[Z.typeKey]="element",M[Z.nameKey]=V,!Z.ignoreAttributes&&j&&Object.keys(j).length)M[Z.attributesKey]=j;if(Z.alwaysChildren)M[Z.elementsKey]=[];J[Z.elementsKey].push(M)}M[Z.parentKey]=J,J=M}function W(V){if(Z.ignoreText)return;if(!V.trim()&&!Z.captureSpacesBetweenElements)return;if(Z.trim)V=V.trim();if(Z.nativeType)V=X(V);if(Z.sanitize)V=V.replace(/&/g,"&").replace(//g,">");Q("text",V)}function k(V){if(Z.ignoreComment)return;if(Z.trim)V=V.trim();Q("comment",V)}function D(V){var j=J[Z.parentKey];if(!Z.addParent)delete J[Z.parentKey];J=j}function C(V){if(Z.ignoreCdata)return;if(Z.trim)V=V.trim();Q("cdata",V)}function H(V){if(Z.ignoreDoctype)return;if(V=V.replace(/^ /,""),Z.trim)V=V.trim();Q("doctype",V)}function O(V){V.note=V}return t6=function(V,j){var M=$.parser(!0,{}),L={};if(J=L,Z=G(j),M.opt={strictEntities:!0},M.onopentag=z,M.ontext=W,M.oncomment=k,M.onclosetag=D,M.onerror=O,M.oncdata=C,M.ondoctype=H,M.onprocessinginstruction=F,M.write(V).close(),L[Z.elementsKey]){var A=L[Z.elementsKey];delete L[Z.elementsKey],L[Z.elementsKey]=A,delete L.text}return L},t6}var e6,zZ;function KX(){if(zZ)return e6;zZ=1;var $=a9(),U=FQ();function Y(Z){var J=$.copyOptions(Z);return $.ensureSpacesExists(J),J}return e6=function(Z,J){var G,X,Q,B;if(G=Y(J),X=U(Z,G),B="compact"in G&&G.compact?"_parent":"parent","addParent"in G&&G.addParent)Q=JSON.stringify(X,function(F,z){return F===B?"_":z},G.spaces);else Q=JSON.stringify(X,null,G.spaces);return Q.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},e6}var $9,FZ;function NQ(){if(FZ)return $9;FZ=1;var $=a9(),U=l9().isArray,Y,Z;function J(M){var L=$.copyOptions(M);if($.ensureFlagExists("ignoreDeclaration",L),$.ensureFlagExists("ignoreInstruction",L),$.ensureFlagExists("ignoreAttributes",L),$.ensureFlagExists("ignoreText",L),$.ensureFlagExists("ignoreComment",L),$.ensureFlagExists("ignoreCdata",L),$.ensureFlagExists("ignoreDoctype",L),$.ensureFlagExists("compact",L),$.ensureFlagExists("indentText",L),$.ensureFlagExists("indentCdata",L),$.ensureFlagExists("indentAttributes",L),$.ensureFlagExists("indentInstruction",L),$.ensureFlagExists("fullTagEmptyElement",L),$.ensureFlagExists("noQuotesForNativeAttributes",L),$.ensureSpacesExists(L),typeof L.spaces==="number")L.spaces=Array(L.spaces+1).join(" ");return $.ensureKeyExists("declaration",L),$.ensureKeyExists("instruction",L),$.ensureKeyExists("attributes",L),$.ensureKeyExists("text",L),$.ensureKeyExists("comment",L),$.ensureKeyExists("cdata",L),$.ensureKeyExists("doctype",L),$.ensureKeyExists("type",L),$.ensureKeyExists("name",L),$.ensureKeyExists("elements",L),$.checkFnExists("doctype",L),$.checkFnExists("instruction",L),$.checkFnExists("cdata",L),$.checkFnExists("comment",L),$.checkFnExists("text",L),$.checkFnExists("instructionName",L),$.checkFnExists("elementName",L),$.checkFnExists("attributeName",L),$.checkFnExists("attributeValue",L),$.checkFnExists("attributes",L),$.checkFnExists("fullTagEmptyElement",L),L}function G(M,L,A){return(!A&&M.spaces?` -`:"")+Array(L+1).join(M.spaces)}function X(M,L,A){if(L.ignoreAttributes)return"";if("attributesFn"in L)M=L.attributesFn(M,Z,Y);var y,g,d,E,s=[];for(y in M)if(M.hasOwnProperty(y)&&M[y]!==null&&M[y]!==void 0)E=L.noQuotesForNativeAttributes&&typeof M[y]!=="string"?"":'"',g=""+M[y],g=g.replace(/"/g,"""),d="attributeNameFn"in L?L.attributeNameFn(y,g,Z,Y):y,s.push(L.spaces&&L.indentAttributes?G(L,A+1,!1):" "),s.push(d+"="+E+("attributeValueFn"in L?L.attributeValueFn(g,y,Z,Y):g)+E);if(M&&Object.keys(M).length&&L.spaces&&L.indentAttributes)s.push(G(L,A,!1));return s.join("")}function Q(M,L,A){return Y=M,Z="xml",L.ignoreDeclaration?"":""}function B(M,L,A){if(L.ignoreInstruction)return"";var y;for(y in M)if(M.hasOwnProperty(y))break;var g="instructionNameFn"in L?L.instructionNameFn(y,M[y],Z,Y):y;if(typeof M[y]==="object")return Y=M,Z=g,"";else{var d=M[y]?M[y]:"";if("instructionFn"in L)d=L.instructionFn(d,y,Z,Y);return""}}function F(M,L){return L.ignoreComment?"":""}function z(M,L){return L.ignoreCdata?"":"","]]]]>"))+"]]>"}function W(M,L){return L.ignoreDoctype?"":""}function k(M,L){if(L.ignoreText)return"";return M=""+M,M=M.replace(/&/g,"&"),M=M.replace(/&/g,"&").replace(//g,">"),"textFn"in L?L.textFn(M,Z,Y):M}function D(M,L){var A;if(M.elements&&M.elements.length)for(A=0;A"),M[L.elementsKey]&&M[L.elementsKey].length)y.push(H(M[L.elementsKey],L,A+1)),Y=M,Z=M.name;y.push(L.spaces&&D(M,L)?` -`+Array(A+1).join(L.spaces):""),y.push("")}else y.push("/>");return y.join("")}function H(M,L,A,y){return M.reduce(function(g,d){var E=G(L,A,y&&!g);switch(d.type){case"element":return g+E+C(d,L,A);case"comment":return g+E+F(d[L.commentKey],L);case"doctype":return g+E+W(d[L.doctypeKey],L);case"cdata":return g+(L.indentCdata?E:"")+z(d[L.cdataKey],L);case"text":return g+(L.indentText?E:"")+k(d[L.textKey],L);case"instruction":var s={};return s[d[L.nameKey]]=d[L.attributesKey]?d:d[L.instructionKey],g+(L.indentInstruction?E:"")+B(s,L,A)}},"")}function O(M,L,A){var y;for(y in M)if(M.hasOwnProperty(y))switch(y){case L.parentKey:case L.attributesKey:break;case L.textKey:if(L.indentText||A)return!0;break;case L.cdataKey:if(L.indentCdata||A)return!0;break;case L.instructionKey:if(L.indentInstruction||A)return!0;break;case L.doctypeKey:case L.commentKey:return!0;default:return!0}return!1}function V(M,L,A,y,g){Y=M,Z=L;var d="elementNameFn"in A?A.elementNameFn(L,M):L;if(typeof M>"u"||M===null||M==="")return"fullTagEmptyElementFn"in A&&A.fullTagEmptyElementFn(L,M)||A.fullTagEmptyElement?"<"+d+">":"<"+d+"/>";var E=[];if(L){if(E.push("<"+d),typeof M!=="object")return E.push(">"+k(M,A)+""),E.join("");if(M[A.attributesKey])E.push(X(M[A.attributesKey],A,y));var s=O(M,A,!0)||M[A.attributesKey]&&M[A.attributesKey]["xml:space"]==="preserve";if(!s)if("fullTagEmptyElementFn"in A)s=A.fullTagEmptyElementFn(L,M);else s=A.fullTagEmptyElement;if(s)E.push(">");else return E.push("/>"),E.join("")}if(E.push(j(M,A,y+1,!1)),Y=M,Z=L,L)E.push((g?G(A,y,!1):"")+"");return E.join("")}function j(M,L,A,y){var g,d,E,s=[];for(d in M)if(M.hasOwnProperty(d)){E=U(M[d])?M[d]:[M[d]];for(g=0;g{switch($.type){case void 0:case"element":let U=new p9($.name,$.attributes),Y=$.elements||[];for(let Z of Y){let J=U8(Z);if(J!==void 0)U.push(J)}return U;case"text":return $.text;default:return}};class RQ extends I0{}class p9 extends o{static fromXmlString($){let U=$8.xml2js($,{compact:!1});return U8(U)}constructor($,U){super($);if(U)this.root.push(new RQ(U))}push($){this.root.push($)}}class i9 extends o{constructor($){super("");this._attr=$}prepForXml($){return{_attr:this._attr}}}var VX="";class Y8 extends o{constructor($,U){super($);if(U)this.root=U.root}}var S0=($)=>{if(isNaN($))throw Error(`Invalid value '${$}' specified. Must be an integer.`);return Math.floor($)},W1=($)=>{let U=S0($);if(U<0)throw Error(`Invalid value '${$}' specified. Must be a positive integer.`);return U},Z8=($,U)=>{let Y=U*2;if($.length!==Y||isNaN(Number(`0x${$}`)))throw Error(`Invalid hex value '${$}'. Expected ${Y} digit hex value`);return $},BX=($)=>Z8($,4),DQ=($)=>Z8($,2),D9=($)=>Z8($,1),H1=($)=>{let U=$.slice(-2),Y=$.substring(0,$.length-2);return`${Number(Y)}${U}`},r9=($)=>{let U=H1($);if(parseFloat(U)<0)throw Error(`Invalid value '${U}' specified. Expected a positive number.`);return U},S2=($)=>{if($==="auto")return $;let U=$.charAt(0)==="#"?$.substring(1):$;return Z8(U,3)},e0=($)=>typeof $==="string"?H1($):S0($),AQ=($)=>typeof $==="string"?r9($):W1($),LX=($)=>typeof $==="string"?H1($):S0($),T0=($)=>typeof $==="string"?r9($):W1($),PQ=($)=>{let U=$.substring(0,$.length-1);return`${Number(U)}%`},s9=($)=>{if(typeof $==="number")return S0($);if($.slice(-1)==="%")return PQ($);return H1($)},TQ=W1,CQ=W1,OQ=($)=>$.toISOString();class X0 extends o{constructor($,U=!0){super($);if(U!==!0)this.root.push(new O0({val:U}))}}class q1 extends o{constructor($,U){super($);this.root.push(new O0({val:AQ(U)}))}}class k0 extends o{}class Y2 extends o{constructor($,U){super($);this.root.push(new O0({val:U}))}}var u2=($,U)=>new B0({name:$,attributes:{value:{key:"w:val",value:U}}});class k2 extends o{constructor($,U){super($);this.root.push(new O0({val:U}))}}class kQ extends o{constructor($,U){super($);this.root.push(new O0({val:U}))}}class L2 extends o{constructor($,U){super($);this.root.push(U)}}class B0 extends o{constructor({name:$,attributes:U,children:Y}){super($);if(U)this.root.push(new n1(U));if(Y)this.root.push(...Y)}}var m0={START:"start",CENTER:"center",END:"end",BOTH:"both",MEDIUM_KASHIDA:"mediumKashida",DISTRIBUTE:"distribute",NUM_TAB:"numTab",HIGH_KASHIDA:"highKashida",LOW_KASHIDA:"lowKashida",THAI_DISTRIBUTE:"thaiDistribute",LEFT:"left",RIGHT:"right",JUSTIFIED:"both"},n9=($)=>new B0({name:"w:jc",attributes:{val:{key:"w:val",value:$}}}),N0=($,{color:U,size:Y,space:Z,style:J})=>new B0({name:$,attributes:{style:{key:"w:val",value:J},color:{key:"w:color",value:U===void 0?void 0:S2(U)},size:{key:"w:sz",value:Y===void 0?void 0:TQ(Y)},space:{key:"w:space",value:Z===void 0?void 0:CQ(Z)}}}),Q8={SINGLE:"single",DASH_DOT_STROKED:"dashDotStroked",DASHED:"dashed",DASH_SMALL_GAP:"dashSmallGap",DOT_DASH:"dotDash",DOT_DOT_DASH:"dotDotDash",DOTTED:"dotted",DOUBLE:"double",DOUBLE_WAVE:"doubleWave",INSET:"inset",NIL:"nil",NONE:"none",OUTSET:"outset",THICK:"thick",THICK_THIN_LARGE_GAP:"thickThinLargeGap",THICK_THIN_MEDIUM_GAP:"thickThinMediumGap",THICK_THIN_SMALL_GAP:"thickThinSmallGap",THIN_THICK_LARGE_GAP:"thinThickLargeGap",THIN_THICK_MEDIUM_GAP:"thinThickMediumGap",THIN_THICK_SMALL_GAP:"thinThickSmallGap",THIN_THICK_THIN_LARGE_GAP:"thinThickThinLargeGap",THIN_THICK_THIN_MEDIUM_GAP:"thinThickThinMediumGap",THIN_THICK_THIN_SMALL_GAP:"thinThickThinSmallGap",THREE_D_EMBOSS:"threeDEmboss",THREE_D_ENGRAVE:"threeDEngrave",TRIPLE:"triple",WAVE:"wave"};class o9 extends Q2{constructor($){super("w:pBdr");if($.top)this.root.push(N0("w:top",$.top));if($.bottom)this.root.push(N0("w:bottom",$.bottom));if($.left)this.root.push(N0("w:left",$.left));if($.right)this.root.push(N0("w:right",$.right));if($.between)this.root.push(N0("w:between",$.between))}}class t9 extends o{constructor(){super("w:pBdr");let $=N0("w:bottom",{color:"auto",space:1,style:Q8.SINGLE,size:6});this.root.push($)}}var EQ=({start:$,end:U,left:Y,right:Z,hanging:J,firstLine:G})=>new B0({name:"w:ind",attributes:{start:{key:"w:start",value:$===void 0?void 0:e0($)},end:{key:"w:end",value:U===void 0?void 0:e0(U)},left:{key:"w:left",value:Y===void 0?void 0:e0(Y)},right:{key:"w:right",value:Z===void 0?void 0:e0(Z)},hanging:{key:"w:hanging",value:J===void 0?void 0:T0(J)},firstLine:{key:"w:firstLine",value:G===void 0?void 0:T0(G)}}}),SQ=()=>new B0({name:"w:br"}),e9={BEGIN:"begin",END:"end",SEPARATE:"separate"},$$=($,U)=>new B0({name:"w:fldChar",attributes:{type:{key:"w:fldCharType",value:$},dirty:{key:"w:dirty",value:U}}}),$2=($)=>$$(e9.BEGIN,$),I2=($)=>$$(e9.SEPARATE,$),U2=($)=>$$(e9.END,$),MX={CENTER:"center",INSIDE:"inside",LEFT:"left",OUTSIDE:"outside",RIGHT:"right"},IX={BOTTOM:"bottom",CENTER:"center",INSIDE:"inside",OUTSIDE:"outside",TOP:"top"},wX={DECIMAL:"decimal",UPPER_ROMAN:"upperRoman",LOWER_ROMAN:"lowerRoman",UPPER_LETTER:"upperLetter",LOWER_LETTER:"lowerLetter",ORDINAL:"ordinal",CARDINAL_TEXT:"cardinalText",ORDINAL_TEXT:"ordinalText",HEX:"hex",CHICAGO:"chicago",IDEOGRAPH_DIGITAL:"ideographDigital",JAPANESE_COUNTING:"japaneseCounting",AIUEO:"aiueo",IROHA:"iroha",DECIMAL_FULL_WIDTH:"decimalFullWidth",DECIMAL_HALF_WIDTH:"decimalHalfWidth",JAPANESE_LEGAL:"japaneseLegal",JAPANESE_DIGITAL_TEN_THOUSAND:"japaneseDigitalTenThousand",DECIMAL_ENCLOSED_CIRCLE:"decimalEnclosedCircle",DECIMAL_FULL_WIDTH_2:"decimalFullWidth2",AIUEO_FULL_WIDTH:"aiueoFullWidth",IROHA_FULL_WIDTH:"irohaFullWidth",DECIMAL_ZERO:"decimalZero",BULLET:"bullet",GANADA:"ganada",CHOSUNG:"chosung",DECIMAL_ENCLOSED_FULL_STOP:"decimalEnclosedFullstop",DECIMAL_ENCLOSED_PAREN:"decimalEnclosedParen",DECIMAL_ENCLOSED_CIRCLE_CHINESE:"decimalEnclosedCircleChinese",IDEOGRAPH_ENCLOSED_CIRCLE:"ideographEnclosedCircle",IDEOGRAPH_TRADITIONAL:"ideographTraditional",IDEOGRAPH_ZODIAC:"ideographZodiac",IDEOGRAPH_ZODIAC_TRADITIONAL:"ideographZodiacTraditional",TAIWANESE_COUNTING:"taiwaneseCounting",IDEOGRAPH_LEGAL_TRADITIONAL:"ideographLegalTraditional",TAIWANESE_COUNTING_THOUSAND:"taiwaneseCountingThousand",TAIWANESE_DIGITAL:"taiwaneseDigital",CHINESE_COUNTING:"chineseCounting",CHINESE_LEGAL_SIMPLIFIED:"chineseLegalSimplified",CHINESE_COUNTING_TEN_THOUSAND:"chineseCountingThousand",KOREAN_DIGITAL:"koreanDigital",KOREAN_COUNTING:"koreanCounting",KOREAN_LEGAL:"koreanLegal",KOREAN_DIGITAL_2:"koreanDigital2",VIETNAMESE_COUNTING:"vietnameseCounting",RUSSIAN_LOWER:"russianLower",RUSSIAN_UPPER:"russianUpper",NONE:"none",NUMBER_IN_DASH:"numberInDash",HEBREW_1:"hebrew1",HEBREW_2:"hebrew2",ARABIC_ALPHA:"arabicAlpha",ARABIC_ABJAD:"arabicAbjad",HINDI_VOWELS:"hindiVowels",HINDI_CONSONANTS:"hindiConsonants",HINDI_NUMBERS:"hindiNumbers",HINDI_COUNTING:"hindiCounting",THAI_LETTERS:"thaiLetters",THAI_NUMBERS:"thaiNumbers",THAI_COUNTING:"thaiCounting",BAHT_TEXT:"bahtText",DOLLAR_TEXT:"dollarText"},g0={DEFAULT:"default",PRESERVE:"preserve"};class x0 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{space:"xml:space"})}}class vQ extends o{constructor(){super("w:instrText");this.root.push(new x0({space:g0.PRESERVE})),this.root.push("PAGE")}}class _Q extends o{constructor(){super("w:instrText");this.root.push(new x0({space:g0.PRESERVE})),this.root.push("NUMPAGES")}}class yQ extends o{constructor(){super("w:instrText");this.root.push(new x0({space:g0.PRESERVE})),this.root.push("SECTIONPAGES")}}class bQ extends o{constructor(){super("w:instrText");this.root.push(new x0({space:g0.PRESERVE})),this.root.push("SECTION")}}var j1=({fill:$,color:U,type:Y})=>new B0({name:"w:shd",attributes:{fill:{key:"w:fill",value:$===void 0?void 0:S2($)},color:{key:"w:color",value:U===void 0?void 0:S2(U)},type:{key:"w:val",value:Y}}}),WX={CLEAR:"clear",DIAGONAL_CROSS:"diagCross",DIAGONAL_STRIPE:"diagStripe",HORIZONTAL_CROSS:"horzCross",HORIZONTAL_STRIPE:"horzStripe",NIL:"nil",PERCENT_5:"pct5",PERCENT_10:"pct10",PERCENT_12:"pct12",PERCENT_15:"pct15",PERCENT_20:"pct20",PERCENT_25:"pct25",PERCENT_30:"pct30",PERCENT_35:"pct35",PERCENT_37:"pct37",PERCENT_40:"pct40",PERCENT_45:"pct45",PERCENT_50:"pct50",PERCENT_55:"pct55",PERCENT_60:"pct60",PERCENT_62:"pct62",PERCENT_65:"pct65",PERCENT_70:"pct70",PERCENT_75:"pct75",PERCENT_80:"pct80",PERCENT_85:"pct85",PERCENT_87:"pct87",PERCENT_90:"pct90",PERCENT_95:"pct95",REVERSE_DIAGONAL_STRIPE:"reverseDiagStripe",SOLID:"solid",THIN_DIAGONAL_CROSS:"thinDiagCross",THIN_DIAGONAL_STRIPE:"thinDiagStripe",THIN_HORIZONTAL_CROSS:"thinHorzCross",THIN_REVERSE_DIAGONAL_STRIPE:"thinReverseDiagStripe",THIN_VERTICAL_STRIPE:"thinVertStripe",VERTICAL_STRIPE:"vertStripe"};class _0 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{id:"w:id",author:"w:author",date:"w:date"})}}class gQ extends o{constructor($){super("w:del");this.root.push(new _0({id:$.id,author:$.author,date:$.date}))}}class xQ extends o{constructor($){super("w:ins");this.root.push(new _0({id:$.id,author:$.author,date:$.date}))}}var U$={DOT:"dot"},Y$=($=U$.DOT)=>new B0({name:"w:em",attributes:{val:{key:"w:val",value:$}}}),HX=()=>Y$(U$.DOT);class fQ extends o{constructor($){super("w:spacing");this.root.push(new O0({val:e0($)}))}}class hQ extends o{constructor($){super("w:color");this.root.push(new O0({val:S2($)}))}}class uQ extends o{constructor($){super("w:highlight");this.root.push(new O0({val:$}))}}class dQ extends o{constructor($){super("w:highlightCs");this.root.push(new O0({val:$}))}}var jX=($)=>new B0({name:"w:lang",attributes:{value:{key:"w:val",value:$.value},eastAsia:{key:"w:eastAsia",value:$.eastAsia},bidirectional:{key:"w:bidi",value:$.bidirectional}}}),g1=($,U)=>{if(typeof $==="string"){let Z=$;return new B0({name:"w:rFonts",attributes:{ascii:{key:"w:ascii",value:Z},cs:{key:"w:cs",value:Z},eastAsia:{key:"w:eastAsia",value:Z},hAnsi:{key:"w:hAnsi",value:Z},hint:{key:"w:hint",value:U}}})}let Y=$;return new B0({name:"w:rFonts",attributes:{ascii:{key:"w:ascii",value:Y.ascii},cs:{key:"w:cs",value:Y.cs},eastAsia:{key:"w:eastAsia",value:Y.eastAsia},hAnsi:{key:"w:hAnsi",value:Y.hAnsi},hint:{key:"w:hint",value:Y.hint}}})},cQ=($)=>new B0({name:"w:vertAlign",attributes:{val:{key:"w:val",value:$}}}),zX=()=>cQ("superscript"),FX=()=>cQ("subscript"),Z$={SINGLE:"single",WORDS:"words",DOUBLE:"double",THICK:"thick",DOTTED:"dotted",DOTTEDHEAVY:"dottedHeavy",DASH:"dash",DASHEDHEAVY:"dashedHeavy",DASHLONG:"dashLong",DASHLONGHEAVY:"dashLongHeavy",DOTDASH:"dotDash",DASHDOTHEAVY:"dashDotHeavy",DOTDOTDASH:"dotDotDash",DASHDOTDOTHEAVY:"dashDotDotHeavy",WAVE:"wave",WAVYHEAVY:"wavyHeavy",WAVYDOUBLE:"wavyDouble",NONE:"none"},mQ=($=Z$.SINGLE,U)=>new B0({name:"w:u",attributes:{val:{key:"w:val",value:$},color:{key:"w:color",value:U===void 0?void 0:S2(U)}}}),NX={BLINK_BACKGROUND:"blinkBackground",LIGHTS:"lights",ANTS_BLACK:"antsBlack",ANTS_RED:"antsRed",SHIMMER:"shimmer",SPARKLE:"sparkle",NONE:"none"},RX={BLACK:"black",BLUE:"blue",CYAN:"cyan",DARK_BLUE:"darkBlue",DARK_CYAN:"darkCyan",DARK_GRAY:"darkGray",DARK_GREEN:"darkGreen",DARK_MAGENTA:"darkMagenta",DARK_RED:"darkRed",DARK_YELLOW:"darkYellow",GREEN:"green",LIGHT_GRAY:"lightGray",MAGENTA:"magenta",NONE:"none",RED:"red",WHITE:"white",YELLOW:"yellow"};class J2 extends Q2{constructor($){var U,Y;super("w:rPr");if(!$)return;if($.style)this.push(new Y2("w:rStyle",$.style));if($.font)if(typeof $.font==="string")this.push(g1($.font));else if("name"in $.font)this.push(g1($.font.name,$.font.hint));else this.push(g1($.font));if($.bold!==void 0)this.push(new X0("w:b",$.bold));if($.boldComplexScript===void 0&&$.bold!==void 0||$.boldComplexScript)this.push(new X0("w:bCs",(U=$.boldComplexScript)!=null?U:$.bold));if($.italics!==void 0)this.push(new X0("w:i",$.italics));if($.italicsComplexScript===void 0&&$.italics!==void 0||$.italicsComplexScript)this.push(new X0("w:iCs",(Y=$.italicsComplexScript)!=null?Y:$.italics));if($.smallCaps!==void 0)this.push(new X0("w:smallCaps",$.smallCaps));else if($.allCaps!==void 0)this.push(new X0("w:caps",$.allCaps));if($.strike!==void 0)this.push(new X0("w:strike",$.strike));if($.doubleStrike!==void 0)this.push(new X0("w:dstrike",$.doubleStrike));if($.emboss!==void 0)this.push(new X0("w:emboss",$.emboss));if($.imprint!==void 0)this.push(new X0("w:imprint",$.imprint));if($.noProof!==void 0)this.push(new X0("w:noProof",$.noProof));if($.snapToGrid!==void 0)this.push(new X0("w:snapToGrid",$.snapToGrid));if($.vanish)this.push(new X0("w:vanish",$.vanish));if($.color)this.push(new hQ($.color));if($.characterSpacing)this.push(new fQ($.characterSpacing));if($.scale!==void 0)this.push(new k2("w:w",$.scale));if($.kern)this.push(new q1("w:kern",$.kern));if($.position)this.push(new Y2("w:position",$.position));if($.size!==void 0)this.push(new q1("w:sz",$.size));let Z=$.sizeComplexScript===void 0||$.sizeComplexScript===!0?$.size:$.sizeComplexScript;if(Z)this.push(new q1("w:szCs",Z));if($.highlight)this.push(new uQ($.highlight));let J=$.highlightComplexScript===void 0||$.highlightComplexScript===!0?$.highlight:$.highlightComplexScript;if(J)this.push(new dQ(J));if($.underline)this.push(mQ($.underline.type,$.underline.color));if($.effect)this.push(new Y2("w:effect",$.effect));if($.border)this.push(N0("w:bdr",$.border));if($.shading)this.push(j1($.shading));if($.subScript)this.push(FX());if($.superScript)this.push(zX());if($.rightToLeft!==void 0)this.push(new X0("w:rtl",$.rightToLeft));if($.emphasisMark)this.push(Y$($.emphasisMark.type));if($.language)this.push(jX($.language));if($.specVanish)this.push(new X0("w:specVanish",$.vanish));if($.math)this.push(new X0("w:oMath",$.math));if($.revision)this.push(new J$($.revision))}push($){this.root.push($)}}class Q$ extends J2{constructor($){super($);if($==null?void 0:$.insertion)this.push(new xQ($.insertion));if($==null?void 0:$.deletion)this.push(new gQ($.deletion))}}class J$ extends o{constructor($){super("w:rPrChange");this.root.push(new _0({id:$.id,author:$.author,date:$.date})),this.addChildElement(new J2($))}}class a2 extends o{constructor($){var U;super("w:t");if(typeof $==="string")this.root.push(new x0({space:g0.PRESERVE})),this.root.push($);else this.root.push(new x0({space:(U=$.space)!=null?U:g0.DEFAULT})),this.root.push($.text)}}var N2={CURRENT:"CURRENT",TOTAL_PAGES:"TOTAL_PAGES",TOTAL_PAGES_IN_SECTION:"TOTAL_PAGES_IN_SECTION",CURRENT_SECTION:"SECTION"};class C0 extends o{constructor($){super("w:r");if(Y0(this,"properties"),this.properties=new J2($),this.root.push(this.properties),$.break)for(let U=0;U<$.break;U++)this.root.push(SQ());if($.children)for(let U of $.children){if(typeof U==="string"){switch(U){case N2.CURRENT:this.root.push($2()),this.root.push(new vQ),this.root.push(I2()),this.root.push(U2());break;case N2.TOTAL_PAGES:this.root.push($2()),this.root.push(new _Q),this.root.push(I2()),this.root.push(U2());break;case N2.TOTAL_PAGES_IN_SECTION:this.root.push($2()),this.root.push(new yQ),this.root.push(I2()),this.root.push(U2());break;case N2.CURRENT_SECTION:this.root.push($2()),this.root.push(new bQ),this.root.push(I2()),this.root.push(U2());break;default:this.root.push(new a2(U));break}continue}this.root.push(U)}else if($.text!==void 0)this.root.push(new a2($.text))}}class p2 extends C0{constructor($){super(typeof $==="string"?{text:$}:$)}}class lQ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{char:"w:char",symbolfont:"w:font"})}}var DZ=class extends o{constructor(U="",Y="Wingdings"){super("w:sym");this.root.push(new lQ({char:U,symbolfont:Y}))}};class G$ extends C0{constructor($){if(typeof $==="string"){super({});return this.root.push(new DZ($)),this}super($);this.root.push(new DZ($.char,$.symbolfont))}}var Z9={},z0={},Q9,AZ;function z1(){if(AZ)return Q9;AZ=1,Q9=$;function $(U,Y){if(!U)throw Error(Y||"Assertion failed")}return $.equal=function(Y,Z,J){if(Y!=Z)throw Error(J||"Assertion failed: "+Y+" != "+Z)},Q9}var PZ;function G2(){if(PZ)return z0;PZ=1;var $=z1(),U=R2();z0.inherits=U;function Y(S,h){if((S.charCodeAt(h)&64512)!==55296)return!1;if(h<0||h+1>=S.length)return!1;return(S.charCodeAt(h+1)&64512)===56320}function Z(S,h){if(Array.isArray(S))return S.slice();if(!S)return[];var N=[];if(typeof S==="string"){if(!h){var a=0;for(var $0=0;$0>6|192,N[a++]=m&63|128;else if(Y(S,$0))m=65536+((m&1023)<<10)+(S.charCodeAt(++$0)&1023),N[a++]=m>>18|240,N[a++]=m>>12&63|128,N[a++]=m>>6&63|128,N[a++]=m&63|128;else N[a++]=m>>12|224,N[a++]=m>>6&63|128,N[a++]=m&63|128}}else if(h==="hex"){if(S=S.replace(/[^a-z0-9]+/ig,""),S.length%2!==0)S="0"+S;for($0=0;$0>>24|S>>>8&65280|S<<8&16711680|(S&255)<<24;return h>>>0}z0.htonl=G;function X(S,h){var N="";for(var a=0;a>>0}return m}z0.join32=F;function z(S,h){var N=Array(S.length*4);for(var a=0,$0=0;a>>24,N[$0+1]=m>>>16&255,N[$0+2]=m>>>8&255,N[$0+3]=m&255;else N[$0+3]=m>>>24,N[$0+2]=m>>>16&255,N[$0+1]=m>>>8&255,N[$0]=m&255}return N}z0.split32=z;function W(S,h){return S>>>h|S<<32-h}z0.rotr32=W;function k(S,h){return S<>>32-h}z0.rotl32=k;function D(S,h){return S+h>>>0}z0.sum32=D;function C(S,h,N){return S+h+N>>>0}z0.sum32_3=C;function H(S,h,N,a){return S+h+N+a>>>0}z0.sum32_4=H;function O(S,h,N,a,$0){return S+h+N+a+$0>>>0}z0.sum32_5=O;function V(S,h,N,a){var $0=S[h],m=S[h+1],J0=a+m>>>0,U0=(J0>>0,S[h+1]=J0}z0.sum64=V;function j(S,h,N,a){var $0=h+a>>>0,m=($0>>0}z0.sum64_hi=j;function M(S,h,N,a){var $0=h+a;return $0>>>0}z0.sum64_lo=M;function L(S,h,N,a,$0,m,J0,U0){var L0=0,i=h;i=i+a>>>0,L0+=i>>0,L0+=i>>0,L0+=i>>0}z0.sum64_4_hi=L;function A(S,h,N,a,$0,m,J0,U0){var L0=h+a+m+U0;return L0>>>0}z0.sum64_4_lo=A;function y(S,h,N,a,$0,m,J0,U0,L0,i){var _=0,r=h;r=r+a>>>0,_+=r>>0,_+=r>>0,_+=r>>0,_+=r>>0}z0.sum64_5_hi=y;function g(S,h,N,a,$0,m,J0,U0,L0,i){var _=h+a+m+U0+i;return _>>>0}z0.sum64_5_lo=g;function d(S,h,N){var a=h<<32-N|S>>>N;return a>>>0}z0.rotr64_hi=d;function E(S,h,N){var a=S<<32-N|h>>>N;return a>>>0}z0.rotr64_lo=E;function s(S,h,N){return S>>>N}z0.shr64_hi=s;function V0(S,h,N){var a=S<<32-N|h>>>N;return a>>>0}return z0.shr64_lo=V0,z0}var J9={},TZ;function F1(){if(TZ)return J9;TZ=1;var $=G2(),U=z1();function Y(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}return J9.BlockHash=Y,Y.prototype.update=function(J,G){if(J=$.toArray(J,G),!this.pending)this.pending=J;else this.pending=this.pending.concat(J);if(this.pendingTotal+=J.length,this.pending.length>=this._delta8){J=this.pending;var X=J.length%this._delta8;if(this.pending=J.slice(J.length-X,J.length),this.pending.length===0)this.pending=null;J=$.join32(J,0,J.length-X,this.endian);for(var Q=0;Q>>24&255,Q[B++]=J>>>16&255,Q[B++]=J>>>8&255,Q[B++]=J&255}else{Q[B++]=J&255,Q[B++]=J>>>8&255,Q[B++]=J>>>16&255,Q[B++]=J>>>24&255,Q[B++]=0,Q[B++]=0,Q[B++]=0,Q[B++]=0;for(F=8;F>>3}s0.g0_256=B;function F(z){return U(z,17)^U(z,19)^z>>>10}return s0.g1_256=F,s0}var G9,OZ;function DX(){if(OZ)return G9;OZ=1;var $=G2(),U=F1(),Y=aQ(),Z=$.rotl32,J=$.sum32,G=$.sum32_5,X=Y.ft_1,Q=U.BlockHash,B=[1518500249,1859775393,2400959708,3395469782];function F(){if(!(this instanceof F))return new F;Q.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=Array(80)}return $.inherits(F,Q),G9=F,F.blockSize=512,F.outSize=160,F.hmacStrength=80,F.padLength=64,F.prototype._update=function(W,k){var D=this.W;for(var C=0;C<16;C++)D[C]=W[k+C];for(;Cthis.blockSize)J=new this.Hash().update(J).digest();U(J.length<=this.blockSize);for(var G=J.length;G{return(Y=U)=>{let Z="",J=Y|0;while(J--)Z+=$[Math.random()*$.length|0];return Z}},yX=($=21)=>{let U="",Y=$|0;while(Y--)U+=vX[Math.random()*64|0];return U},bX=($)=>Math.floor($/25.4*72*20),d0=($)=>Math.floor($*72*20),N1=($=0)=>{let U=$;return()=>++U},rQ=()=>N1(),sQ=()=>N1(1),nQ=()=>N1(),oQ=()=>N1(),R1=()=>yX().toLowerCase(),A9=($)=>SX.sha1().update($ instanceof ArrayBuffer?new Uint8Array($):$).digest("hex"),Y1=($)=>_X("1234567890abcdef",$)(),tQ=()=>`${Y1(8)}-${Y1(4)}-${Y1(4)}-${Y1(4)}-${Y1(12)}`,X1=($)=>new Uint8Array(new TextEncoder().encode($)),eQ={CHARACTER:"character",COLUMN:"column",INSIDE_MARGIN:"insideMargin",LEFT_MARGIN:"leftMargin",MARGIN:"margin",OUTSIDE_MARGIN:"outsideMargin",PAGE:"page",RIGHT_MARGIN:"rightMargin"},$J={BOTTOM_MARGIN:"bottomMargin",INSIDE_MARGIN:"insideMargin",LINE:"line",MARGIN:"margin",OUTSIDE_MARGIN:"outsideMargin",PAGE:"page",PARAGRAPH:"paragraph",TOP_MARGIN:"topMargin"},UJ=()=>new B0({name:"wp:simplePos",attributes:{x:{key:"x",value:0},y:{key:"y",value:0}}}),YJ=($)=>new B0({name:"wp:align",children:[$]}),ZJ=($)=>new B0({name:"wp:posOffset",children:[$.toString()]}),QJ=({relative:$,align:U,offset:Y})=>new B0({name:"wp:positionH",attributes:{relativeFrom:{key:"relativeFrom",value:$!=null?$:eQ.PAGE}},children:[(()=>{if(U)return YJ(U);else if(Y!==void 0)return ZJ(Y);else throw Error("There is no configuration provided for floating position (Align or offset)")})()]}),JJ=({relative:$,align:U,offset:Y})=>new B0({name:"wp:positionV",attributes:{relativeFrom:{key:"relativeFrom",value:$!=null?$:$J.PAGE}},children:[(()=>{if(U)return YJ(U);else if(Y!==void 0)return ZJ(Y);else throw Error("There is no configuration provided for floating position (Align or offset)")})()]}),GJ=(($)=>{return $.CENTER="ctr",$.TOP="t",$.BOTTOM="b",$})(GJ||{}),KJ=($={})=>{var U,Y,Z,J;return new B0({name:"wps:bodyPr",attributes:{lIns:{key:"lIns",value:(U=$.margins)==null?void 0:U.left},rIns:{key:"rIns",value:(Y=$.margins)==null?void 0:Y.right},tIns:{key:"tIns",value:(Z=$.margins)==null?void 0:Z.top},bIns:{key:"bIns",value:(J=$.margins)==null?void 0:J.bottom},anchor:{key:"anchor",value:$.verticalAnchor}},children:[...$.noAutoFit?[new X0("a:noAutofit",$.noAutoFit)]:[]]})},gX=($={txBox:"1"})=>new B0({name:"wps:cNvSpPr",attributes:{txBox:{key:"txBox",value:$.txBox}}}),xX=($)=>new B0({name:"w:txbxContent",children:[...$]}),fX=($)=>new B0({name:"wps:txbx",children:[xX($)]});class qJ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{cx:"cx",cy:"cy"})}}class XJ extends o{constructor($,U){super("a:ext");Y0(this,"attributes"),this.attributes=new qJ({cx:$,cy:U}),this.root.push(this.attributes)}}class VJ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{x:"x",y:"y"})}}class BJ extends o{constructor($,U){super("a:off");this.root.push(new VJ({x:$!=null?$:0,y:U!=null?U:0}))}}class LJ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{flipVertical:"flipV",flipHorizontal:"flipH",rotation:"rot"})}}class K$ extends o{constructor($){var U,Y,Z,J,G,X;super("a:xfrm");Y0(this,"extents"),Y0(this,"offset"),this.root.push(new LJ({flipVertical:(U=$.flip)==null?void 0:U.vertical,flipHorizontal:(Y=$.flip)==null?void 0:Y.horizontal,rotation:$.rotation})),this.offset=new BJ((J=(Z=$.offset)==null?void 0:Z.emus)==null?void 0:J.x,(X=(G=$.offset)==null?void 0:G.emus)==null?void 0:X.y),this.extents=new XJ($.emus.x,$.emus.y),this.root.push(this.offset),this.root.push(this.extents)}}var MJ=()=>new B0({name:"a:noFill"}),hX=($)=>new B0({name:"a:srgbClr",attributes:{value:{key:"val",value:$.value}}}),uX=($)=>new B0({name:"a:schemeClr",attributes:{value:{key:"val",value:$.value}}}),P9=($)=>new B0({name:"a:solidFill",children:[$.type==="rgb"?hX($):uX($)]}),dX=($)=>new B0({name:"a:ln",attributes:{width:{key:"w",value:$.width},cap:{key:"cap",value:$.cap},compoundLine:{key:"cmpd",value:$.compoundLine},align:{key:"algn",value:$.align}},children:[$.type==="noFill"?MJ():$.solidFillType==="rgb"?P9({type:"rgb",value:$.value}):P9({type:"scheme",value:$.value})]});class IJ extends o{constructor(){super("a:avLst")}}class wJ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{prst:"prst"})}}class WJ extends o{constructor(){super("a:prstGeom");this.root.push(new wJ({prst:"rect"})),this.root.push(new IJ)}}class HJ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{bwMode:"bwMode"})}}class q$ extends o{constructor({element:$,outline:U,solidFill:Y,transform:Z}){super(`${$}:spPr`);if(Y0(this,"form"),this.root.push(new HJ({bwMode:"auto"})),this.form=new K$(Z),this.root.push(this.form),this.root.push(new WJ),U)this.root.push(MJ()),this.root.push(dX(U));if(Y)this.root.push(P9(Y))}}var xZ=($)=>new B0({name:"wps:wsp",children:[gX($.nonVisualProperties),new q$({element:"wps",transform:$.transformation,outline:$.outline,solidFill:$.solidFill}),fX($.children),KJ($.bodyProperties)]});class x1 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{uri:"uri"})}}var cX=($)=>new B0({name:"asvg:svgBlip",attributes:{asvg:{key:"xmlns:asvg",value:"http://schemas.microsoft.com/office/drawing/2016/SVG/main"},embed:{key:"r:embed",value:`rId{${$.fileName}}`}}}),mX=($)=>new B0({name:"a:ext",attributes:{uri:{key:"uri",value:"{96DAC541-7B7A-43D3-8B79-37D633B846F1}"}},children:[cX($)]}),lX=($)=>new B0({name:"a:extLst",children:[mX($)]}),aX=($)=>new B0({name:"a:blip",attributes:{embed:{key:"r:embed",value:`rId{${$.type==="svg"?$.fallback.fileName:$.fileName}}`},cstate:{key:"cstate",value:"none"}},children:$.type==="svg"?[lX($)]:[]});class jJ extends o{constructor(){super("a:srcRect")}}class zJ extends o{constructor(){super("a:fillRect")}}class FJ extends o{constructor(){super("a:stretch");this.root.push(new zJ)}}class NJ extends o{constructor($){super("pic:blipFill");this.root.push(aX($)),this.root.push(new jJ),this.root.push(new FJ)}}class RJ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{noChangeAspect:"noChangeAspect",noChangeArrowheads:"noChangeArrowheads"})}}class DJ extends o{constructor(){super("a:picLocks");this.root.push(new RJ({noChangeAspect:1,noChangeArrowheads:1}))}}class AJ extends o{constructor(){super("pic:cNvPicPr");this.root.push(new DJ)}}var PJ=($,U)=>new B0({name:"a:hlinkClick",attributes:R0(W0({},U?{xmlns:{key:"xmlns:a",value:"http://schemas.openxmlformats.org/drawingml/2006/main"}}:{}),{id:{key:"r:id",value:`rId${$}`}})});class TJ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{id:"id",name:"name",descr:"descr"})}}class CJ extends o{constructor(){super("pic:cNvPr");this.root.push(new TJ({id:0,name:"",descr:""}))}prepForXml($){for(let U=$.stack.length-1;U>=0;U--){let Y=$.stack[U];if(!(Y instanceof _2))continue;this.root.push(PJ(Y.linkId,!1));break}return super.prepForXml($)}}class OJ extends o{constructor(){super("pic:nvPicPr");this.root.push(new CJ),this.root.push(new AJ)}}class kJ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{xmlns:"xmlns:pic"})}}class T9 extends o{constructor({mediaData:$,transform:U,outline:Y}){super("pic:pic");this.root.push(new kJ({xmlns:"http://schemas.openxmlformats.org/drawingml/2006/picture"})),this.root.push(new OJ),this.root.push(new NJ($)),this.root.push(new q$({element:"pic",transform:U,outline:Y}))}}var pX=($)=>new B0({name:"wpg:grpSpPr",children:[new K$($)]}),iX=()=>new B0({name:"wpg:cNvGrpSpPr"}),rX=($)=>new B0({name:"wpg:wgp",children:[iX(),pX($.transformation),...$.children]});class EJ extends o{constructor({mediaData:$,transform:U,outline:Y,solidFill:Z}){super("a:graphicData");if($.type==="wps"){this.root.push(new x1({uri:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"}));let J=xZ(R0(W0({},$.data),{transformation:U,outline:Y,solidFill:Z}));this.root.push(J)}else if($.type==="wpg"){this.root.push(new x1({uri:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"}));let G=$.children.map((Q)=>{if(Q.type==="wps")return xZ(R0(W0({},Q.data),{transformation:Q.transformation,outline:Q.outline,solidFill:Q.solidFill}));else return new T9({mediaData:Q,transform:Q.transformation,outline:Q.outline})}),X=rX({children:G,transformation:U});this.root.push(X)}else{this.root.push(new x1({uri:"http://schemas.openxmlformats.org/drawingml/2006/picture"}));let G=new T9({mediaData:$,transform:U,outline:Y});this.root.push(G)}}}class SJ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{a:"xmlns:a"})}}class X$ extends o{constructor({mediaData:$,transform:U,outline:Y,solidFill:Z}){super("a:graphic");Y0(this,"data"),this.root.push(new SJ({a:"http://schemas.openxmlformats.org/drawingml/2006/main"})),this.data=new EJ({mediaData:$,transform:U,outline:Y,solidFill:Z}),this.root.push(this.data)}}var G1={NONE:0,SQUARE:1,TIGHT:2,TOP_AND_BOTTOM:3},vJ={BOTH_SIDES:"bothSides",LEFT:"left",RIGHT:"right",LARGEST:"largest"},C9=()=>new B0({name:"wp:wrapNone"}),_J=($,U={top:0,bottom:0,left:0,right:0})=>new B0({name:"wp:wrapSquare",attributes:{wrapText:{key:"wrapText",value:$.side||vJ.BOTH_SIDES},distT:{key:"distT",value:U.top},distB:{key:"distB",value:U.bottom},distL:{key:"distL",value:U.left},distR:{key:"distR",value:U.right}}}),yJ=($={top:0,bottom:0})=>new B0({name:"wp:wrapTight",attributes:{distT:{key:"distT",value:$.top},distB:{key:"distB",value:$.bottom}}}),bJ=($={top:0,bottom:0})=>new B0({name:"wp:wrapTopAndBottom",attributes:{distT:{key:"distT",value:$.top},distB:{key:"distB",value:$.bottom}}});class V$ extends o{constructor({name:$,description:U,title:Y,id:Z}={name:"",description:"",title:""}){super("wp:docPr");Y0(this,"docPropertiesUniqueNumericId",nQ());let J={id:{key:"id",value:Z!=null?Z:this.docPropertiesUniqueNumericId()},name:{key:"name",value:$}};if(U!==null&&U!==void 0)J.description={key:"descr",value:U};if(Y!==null&&Y!==void 0)J.title={key:"title",value:Y};this.root.push(new n1(J))}prepForXml($){for(let U=$.stack.length-1;U>=0;U--){let Y=$.stack[U];if(!(Y instanceof _2))continue;this.root.push(PJ(Y.linkId,!0));break}return super.prepForXml($)}}var gJ=({top:$,right:U,bottom:Y,left:Z})=>new B0({name:"wp:effectExtent",attributes:{top:{key:"t",value:$},right:{key:"r",value:U},bottom:{key:"b",value:Y},left:{key:"l",value:Z}}}),xJ=({x:$,y:U})=>new B0({name:"wp:extent",attributes:{x:{key:"cx",value:$},y:{key:"cy",value:U}}});class fJ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{xmlns:"xmlns:a",noChangeAspect:"noChangeAspect"})}}class hJ extends o{constructor(){super("a:graphicFrameLocks");this.root.push(new fJ({xmlns:"http://schemas.openxmlformats.org/drawingml/2006/main",noChangeAspect:1}))}}var uJ=()=>new B0({name:"wp:cNvGraphicFramePr",children:[new hJ]});class dJ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{distT:"distT",distB:"distB",distL:"distL",distR:"distR",allowOverlap:"allowOverlap",behindDoc:"behindDoc",layoutInCell:"layoutInCell",locked:"locked",relativeHeight:"relativeHeight",simplePos:"simplePos"})}}class cJ extends o{constructor({mediaData:$,transform:U,drawingOptions:Y}){super("wp:anchor");let Z=W0({allowOverlap:!0,behindDocument:!1,lockAnchor:!1,layoutInCell:!0,verticalPosition:{},horizontalPosition:{}},Y.floating);if(this.root.push(new dJ({distT:Z.margins?Z.margins.top||0:0,distB:Z.margins?Z.margins.bottom||0:0,distL:Z.margins?Z.margins.left||0:0,distR:Z.margins?Z.margins.right||0:0,simplePos:"0",allowOverlap:Z.allowOverlap===!0?"1":"0",behindDoc:Z.behindDocument===!0?"1":"0",locked:Z.lockAnchor===!0?"1":"0",layoutInCell:Z.layoutInCell===!0?"1":"0",relativeHeight:Z.zIndex?Z.zIndex:U.emus.y})),this.root.push(UJ()),this.root.push(QJ(Z.horizontalPosition)),this.root.push(JJ(Z.verticalPosition)),this.root.push(xJ({x:U.emus.x,y:U.emus.y})),this.root.push(gJ({top:0,right:0,bottom:0,left:0})),Y.floating!==void 0&&Y.floating.wrap!==void 0)switch(Y.floating.wrap.type){case G1.SQUARE:this.root.push(_J(Y.floating.wrap,Y.floating.margins));break;case G1.TIGHT:this.root.push(yJ(Y.floating.margins));break;case G1.TOP_AND_BOTTOM:this.root.push(bJ(Y.floating.margins));break;case G1.NONE:default:this.root.push(C9())}else this.root.push(C9());this.root.push(new V$(Y.docProperties)),this.root.push(uJ()),this.root.push(new X$({mediaData:$,transform:U,outline:Y.outline,solidFill:Y.solidFill}))}}var sX=({mediaData:$,transform:U,docProperties:Y,outline:Z,solidFill:J})=>{var G,X,Q,B;return new B0({name:"wp:inline",attributes:{distanceTop:{key:"distT",value:0},distanceBottom:{key:"distB",value:0},distanceLeft:{key:"distL",value:0},distanceRight:{key:"distR",value:0}},children:[xJ({x:U.emus.x,y:U.emus.y}),gJ(Z?{top:((G=Z.width)!=null?G:9525)*2,right:((X=Z.width)!=null?X:9525)*2,bottom:((Q=Z.width)!=null?Q:9525)*2,left:((B=Z.width)!=null?B:9525)*2}:{top:0,right:0,bottom:0,left:0}),new V$(Y),uJ(),new X$({mediaData:$,transform:U,outline:Z,solidFill:J})]})};class D1 extends o{constructor($,U={}){super("w:drawing");if(!U.floating)this.root.push(sX({mediaData:$,transform:$.transformation,docProperties:U.docProperties,outline:U.outline,solidFill:U.solidFill}));else this.root.push(new cJ({mediaData:$,transform:$.transformation,drawingOptions:U}))}}var nX=($)=>{let Y=$.indexOf(";base64,"),Z=Y===-1?0:Y+8;return new Uint8Array(atob($.substring(Z)).split("").map((J)=>J.charCodeAt(0)))},mJ=($)=>typeof $==="string"?nX($):$,M9=($,U)=>({data:mJ($.data),fileName:U,transformation:{pixels:{x:Math.round($.transformation.width),y:Math.round($.transformation.height)},emus:{x:Math.round($.transformation.width*9525),y:Math.round($.transformation.height*9525)},flip:$.transformation.flip,rotation:$.transformation.rotation?$.transformation.rotation*60000:void 0}});class lJ extends C0{constructor($){super({});Y0(this,"imageData");let Y=`${A9($.data)}.${$.type}`;this.imageData=$.type==="svg"?R0(W0({type:$.type},M9($,Y)),{fallback:W0({type:$.fallback.type},M9(R0(W0({},$.fallback),{transformation:$.transformation}),`${A9($.fallback.data)}.${$.fallback.type}`))}):W0({type:$.type},M9($,Y));let Z=new D1(this.imageData,{floating:$.floating,docProperties:$.altText,outline:$.outline});this.root.push(Z)}prepForXml($){if($.file.Media.addImage(this.imageData.fileName,this.imageData),this.imageData.type==="svg")$.file.Media.addImage(this.imageData.fallback.fileName,this.imageData.fallback);return super.prepForXml($)}}var B$=($)=>{var U,Y,Z,J,G,X,Q,B;return{offset:{pixels:{x:Math.round((Y=(U=$.offset)==null?void 0:U.left)!=null?Y:0),y:Math.round((J=(Z=$.offset)==null?void 0:Z.top)!=null?J:0)},emus:{x:Math.round(((X=(G=$.offset)==null?void 0:G.left)!=null?X:0)*9525),y:Math.round(((B=(Q=$.offset)==null?void 0:Q.top)!=null?B:0)*9525)}},pixels:{x:Math.round($.width),y:Math.round($.height)},emus:{x:Math.round($.width*9525),y:Math.round($.height*9525)},flip:$.flip,rotation:$.rotation?$.rotation*60000:void 0}};class aJ extends C0{constructor($){super({});Y0(this,"wpsShapeData"),this.wpsShapeData={type:$.type,transformation:B$($.transformation),data:W0({},$)};let U=new D1(this.wpsShapeData,{floating:$.floating,docProperties:$.altText,outline:$.outline,solidFill:$.solidFill});this.root.push(U)}}class pJ extends C0{constructor($){super({});Y0(this,"wpgGroupData"),Y0(this,"mediaDatas"),this.wpgGroupData={type:$.type,transformation:B$($.transformation),children:$.children};let U=new D1(this.wpgGroupData,{floating:$.floating,docProperties:$.altText});this.mediaDatas=$.children.filter((Y)=>Y.type!=="wps").map((Y)=>Y),this.root.push(U)}prepForXml($){return this.mediaDatas.forEach((U)=>{if($.file.Media.addImage(U.fileName,U),U.type==="svg")$.file.Media.addImage(U.fallback.fileName,U.fallback)}),super.prepForXml($)}}class iJ extends o{constructor($){super("w:instrText");this.root.push(new x0({space:g0.PRESERVE})),this.root.push(`SEQ ${$}`)}}class rJ extends C0{constructor($){super({});this.root.push($2(!0)),this.root.push(new iJ($)),this.root.push(I2()),this.root.push(U2())}}class sJ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{instr:"w:instr"})}}class J8 extends o{constructor($,U){super("w:fldSimple");if(this.root.push(new sJ({instr:$})),U!==void 0)this.root.push(new p2(U))}}class nJ extends J8{constructor($){super(` MERGEFIELD ${$} `,`«${$}»`)}}class oJ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{xmlns:"xmlns"})}}var tJ={EXTERNAL:"External"},oX=($,U,Y,Z)=>new B0({name:"Relationship",attributes:{id:{key:"Id",value:$},type:{key:"Type",value:U},target:{key:"Target",value:Y},targetMode:{key:"TargetMode",value:Z}}});class W2 extends o{constructor(){super("Relationships");this.root.push(new oJ({xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"}))}addRelationship($,U,Y,Z){this.root.push(oX(`rId${$}`,U,Y,Z))}get RelationshipCount(){return this.root.length-1}}class eJ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{id:"w:id",initials:"w:initials",author:"w:author",date:"w:date"})}}class G8 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{id:"w:id"})}}class $G extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{"xmlns:cx":"xmlns:cx","xmlns:cx1":"xmlns:cx1","xmlns:cx2":"xmlns:cx2","xmlns:cx3":"xmlns:cx3","xmlns:cx4":"xmlns:cx4","xmlns:cx5":"xmlns:cx5","xmlns:cx6":"xmlns:cx6","xmlns:cx7":"xmlns:cx7","xmlns:cx8":"xmlns:cx8","xmlns:mc":"xmlns:mc","xmlns:aink":"xmlns:aink","xmlns:am3d":"xmlns:am3d","xmlns:o":"xmlns:o","xmlns:r":"xmlns:r","xmlns:m":"xmlns:m","xmlns:v":"xmlns:v","xmlns:wp14":"xmlns:wp14","xmlns:wp":"xmlns:wp","xmlns:w10":"xmlns:w10","xmlns:w":"xmlns:w","xmlns:w14":"xmlns:w14","xmlns:w15":"xmlns:w15","xmlns:w16cex":"xmlns:w16cex","xmlns:w16cid":"xmlns:w16cid","xmlns:w16":"xmlns:w16","xmlns:w16sdtdh":"xmlns:w16sdtdh","xmlns:w16se":"xmlns:w16se","xmlns:wpg":"xmlns:wpg","xmlns:wpi":"xmlns:wpi","xmlns:wne":"xmlns:wne","xmlns:wps":"xmlns:wps"})}}class UG extends o{constructor($){super("w:commentRangeStart");this.root.push(new G8({id:$}))}}class YG extends o{constructor($){super("w:commentRangeEnd");this.root.push(new G8({id:$}))}}class ZG extends o{constructor($){super("w:commentReference");this.root.push(new G8({id:$}))}}class L$ extends o{constructor({id:$,initials:U,author:Y,date:Z=new Date,children:J}){super("w:comment");this.root.push(new eJ({id:$,initials:U,author:Y,date:Z.toISOString()}));for(let G of J)this.root.push(G)}}class M$ extends o{constructor({children:$}){super("w:comments");Y0(this,"relationships"),this.root.push(new $G({"xmlns:cx":"http://schemas.microsoft.com/office/drawing/2014/chartex","xmlns:cx1":"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex","xmlns:cx2":"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex","xmlns:cx3":"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex","xmlns:cx4":"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex","xmlns:cx5":"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex","xmlns:cx6":"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex","xmlns:cx7":"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex","xmlns:cx8":"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","xmlns:aink":"http://schemas.microsoft.com/office/drawing/2016/ink","xmlns:am3d":"http://schemas.microsoft.com/office/drawing/2017/model3d","xmlns:o":"urn:schemas-microsoft-com:office:office","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:m":"http://schemas.openxmlformats.org/officeDocument/2006/math","xmlns:v":"urn:schemas-microsoft-com:vml","xmlns:wp14":"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing","xmlns:wp":"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing","xmlns:w10":"urn:schemas-microsoft-com:office:word","xmlns:w":"http://schemas.openxmlformats.org/wordprocessingml/2006/main","xmlns:w14":"http://schemas.microsoft.com/office/word/2010/wordml","xmlns:w15":"http://schemas.microsoft.com/office/word/2012/wordml","xmlns:w16cex":"http://schemas.microsoft.com/office/word/2018/wordml/cex","xmlns:w16cid":"http://schemas.microsoft.com/office/word/2016/wordml/cid","xmlns:w16":"http://schemas.microsoft.com/office/word/2018/wordml","xmlns:w16sdtdh":"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash","xmlns:w16se":"http://schemas.microsoft.com/office/word/2015/wordml/symex","xmlns:wpg":"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup","xmlns:wpi":"http://schemas.microsoft.com/office/word/2010/wordprocessingInk","xmlns:wne":"http://schemas.microsoft.com/office/word/2006/wordml","xmlns:wps":"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"}));for(let U of $)this.root.push(new L$(U));this.relationships=new W2}get Relationships(){return this.relationships}}class QG extends k0{constructor(){super("w:noBreakHyphen")}}class JG extends k0{constructor(){super("w:softHyphen")}}class GG extends k0{constructor(){super("w:dayShort")}}class KG extends k0{constructor(){super("w:monthShort")}}class qG extends k0{constructor(){super("w:yearShort")}}class XG extends k0{constructor(){super("w:dayLong")}}class VG extends k0{constructor(){super("w:monthLong")}}class BG extends k0{constructor(){super("w:yearLong")}}class LG extends k0{constructor(){super("w:annotationRef")}}class MG extends k0{constructor(){super("w:footnoteRef")}}class I$ extends k0{constructor(){super("w:endnoteRef")}}class IG extends k0{constructor(){super("w:separator")}}class wG extends k0{constructor(){super("w:continuationSeparator")}}class WG extends k0{constructor(){super("w:pgNum")}}class HG extends k0{constructor(){super("w:cr")}}class w$ extends k0{constructor(){super("w:tab")}}class jG extends k0{constructor(){super("w:lastRenderedPageBreak")}}var tX={LEFT:"left",CENTER:"center",RIGHT:"right"},eX={MARGIN:"margin",INDENT:"indent"},$V={NONE:"none",DOT:"dot",HYPHEN:"hyphen",UNDERSCORE:"underscore",MIDDLE_DOT:"middleDot"};class zG extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{alignment:"w:alignment",relativeTo:"w:relativeTo",leader:"w:leader"})}}class FG extends o{constructor($){super("w:ptab");this.root.push(new zG({alignment:$.alignment,relativeTo:$.relativeTo,leader:$.leader}))}}var NG={COLUMN:"column",PAGE:"page"};class W$ extends o{constructor($){super("w:br");this.root.push(new O0({type:$}))}}class RG extends C0{constructor(){super({});this.root.push(new W$(NG.PAGE))}}class DG extends C0{constructor(){super({});this.root.push(new W$(NG.COLUMN))}}class H$ extends o{constructor(){super("w:pageBreakBefore")}}var v2={AT_LEAST:"atLeast",EXACTLY:"exactly",EXACT:"exact",AUTO:"auto"},AG=({after:$,before:U,line:Y,lineRule:Z,beforeAutoSpacing:J,afterAutoSpacing:G})=>new B0({name:"w:spacing",attributes:{after:{key:"w:after",value:$},before:{key:"w:before",value:U},line:{key:"w:line",value:Y},lineRule:{key:"w:lineRule",value:Z},beforeAutoSpacing:{key:"w:beforeAutospacing",value:J},afterAutoSpacing:{key:"w:afterAutospacing",value:G}}}),UV={HEADING_1:"Heading1",HEADING_2:"Heading2",HEADING_3:"Heading3",HEADING_4:"Heading4",HEADING_5:"Heading5",HEADING_6:"Heading6",TITLE:"Title"},K1=($)=>new B0({name:"w:pStyle",attributes:{val:{key:"w:val",value:$}}}),O9={LEFT:"left",RIGHT:"right",CENTER:"center",BAR:"bar",CLEAR:"clear",DECIMAL:"decimal",END:"end",NUM:"num",START:"start"},YV={DOT:"dot",HYPHEN:"hyphen",MIDDLE_DOT:"middleDot",NONE:"none",UNDERSCORE:"underscore"},ZV={MAX:9026},PG=({type:$,position:U,leader:Y})=>new B0({name:"w:tab",attributes:{val:{key:"w:val",value:$},pos:{key:"w:pos",value:U},leader:{key:"w:leader",value:Y}}}),TG=($)=>new B0({name:"w:tabs",children:$.map((U)=>PG(U))});class V1 extends o{constructor($,U){super("w:numPr");this.root.push(new CG(U)),this.root.push(new OG($))}}class CG extends o{constructor($){super("w:ilvl");if($>9)throw Error("Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7");this.root.push(new O0({val:$}))}}class OG extends o{constructor($){super("w:numId");this.root.push(new O0({val:typeof $==="string"?`{${$}}`:$}))}}class r2 extends o{constructor(){super(...arguments);Y0(this,"fileChild",Symbol())}}class kG extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{id:"r:id",history:"w:history",anchor:"w:anchor"})}}var QV={INTERNAL:"INTERNAL",EXTERNAL:"EXTERNAL"};class _2 extends o{constructor($,U,Y){super("w:hyperlink");Y0(this,"linkId"),this.linkId=U;let Z={history:1,anchor:Y?Y:void 0,id:!Y?`rId${this.linkId}`:void 0},J=new kG(Z);this.root.push(J),$.forEach((G)=>{this.root.push(G)})}}class j$ extends _2{constructor($){super($.children,R1(),$.anchor)}}class K8 extends o{constructor($){super("w:externalHyperlink");this.options=$}}class EG extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{id:"w:id",name:"w:name"})}}class SG extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{id:"w:id"})}}class z${constructor($){Y0(this,"bookmarkUniqueNumericId",oQ()),Y0(this,"start"),Y0(this,"children"),Y0(this,"end");let U=this.bookmarkUniqueNumericId();this.start=new F$($.id,U),this.children=$.children,this.end=new N$(U)}}class F$ extends o{constructor($,U){super("w:bookmarkStart");let Y=new EG({name:$,id:U});this.root.push(Y)}}class N$ extends o{constructor($){super("w:bookmarkEnd");let U=new SG({id:$});this.root.push(U)}}var vG=(($)=>{return $.NONE="none",$.RELATIVE="relative",$.NO_CONTEXT="no_context",$.FULL_CONTEXT="full_context",$})(vG||{}),JV={["relative"]:"\\r",["no_context"]:"\\n",["full_context"]:"\\w",["none"]:void 0};class _G extends J8{constructor($,U,Y={}){let{hyperlink:Z=!0,referenceFormat:J="full_context"}=Y,G=`REF ${$}`,X=[...Z?["\\h"]:[],...[JV[J]].filter((B)=>!!B)],Q=`${G} ${X.join(" ")}`;super(Q,U)}}var yG=($)=>new B0({name:"w:outlineLvl",attributes:{val:{key:"w:val",value:$}}});class bG extends o{constructor($,U={}){super("w:instrText");this.root.push(new x0({space:g0.PRESERVE}));let Y=`PAGEREF ${$}`;if(U.hyperlink)Y=`${Y} \\h`;if(U.useRelativePosition)Y=`${Y} \\p`;this.root.push(Y)}}class gG extends C0{constructor($,U={}){super({children:[$2(!0),new bG($,U),U2()]})}}var GV={ANSI:"00",DEFAULT:"01",SYMBOL:"02",MAC:"4D",JIS:"80",HANGUL:"81",JOHAB:"82",GB_2312:"86",CHINESEBIG5:"88",GREEK:"A1",TURKISH:"A2",VIETNAMESE:"A3",HEBREW:"B1",ARABIC:"B2",BALTIC:"BA",RUSSIAN:"CC",THAI:"DE",EASTEUROPE:"EE",OEM:"FF"},_1=({id:$,fontKey:U,subsetted:Y},Z)=>new B0({name:Z,attributes:W0({id:{key:"r:id",value:$}},U?{fontKey:{key:"w:fontKey",value:`{${U}}`}}:{}),children:[...Y?[new X0("w:subsetted",Y)]:[]]}),KV=({name:$,altName:U,panose1:Y,charset:Z,family:J,notTrueType:G,pitch:X,sig:Q,embedRegular:B,embedBold:F,embedItalic:z,embedBoldItalic:W})=>new B0({name:"w:font",attributes:{name:{key:"w:name",value:$}},children:[...U?[u2("w:altName",U)]:[],...Y?[u2("w:panose1",Y)]:[],...Z?[u2("w:charset",Z)]:[],u2("w:family",J),...G?[new X0("w:notTrueType",G)]:[],u2("w:pitch",X),...Q?[new B0({name:"w:sig",attributes:{usb0:{key:"w:usb0",value:Q.usb0},usb1:{key:"w:usb1",value:Q.usb1},usb2:{key:"w:usb2",value:Q.usb2},usb3:{key:"w:usb3",value:Q.usb3},csb0:{key:"w:csb0",value:Q.csb0},csb1:{key:"w:csb1",value:Q.csb1}}})]:[],...B?[_1(B,"w:embedRegular")]:[],...F?[_1(F,"w:embedBold")]:[],...z?[_1(z,"w:embedItalic")]:[],...W?[_1(W,"w:embedBoldItalic")]:[]]}),qV=({name:$,index:U,fontKey:Y,characterSet:Z})=>KV({name:$,sig:{usb0:"E0002AFF",usb1:"C000247B",usb2:"00000009",usb3:"00000000",csb0:"000001FF",csb1:"00000000"},charset:Z,family:"auto",pitch:"variable",embedRegular:{fontKey:Y,id:`rId${U}`}}),XV=($)=>new B0({name:"w:fonts",attributes:{mc:{key:"xmlns:mc",value:"http://schemas.openxmlformats.org/markup-compatibility/2006"},r:{key:"xmlns:r",value:"http://schemas.openxmlformats.org/officeDocument/2006/relationships"},w:{key:"xmlns:w",value:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"},w14:{key:"xmlns:w14",value:"http://schemas.microsoft.com/office/word/2010/wordml"},w15:{key:"xmlns:w15",value:"http://schemas.microsoft.com/office/word/2012/wordml"},w16cex:{key:"xmlns:w16cex",value:"http://schemas.microsoft.com/office/word/2018/wordml/cex"},w16cid:{key:"xmlns:w16cid",value:"http://schemas.microsoft.com/office/word/2016/wordml/cid"},w16:{key:"xmlns:w16",value:"http://schemas.microsoft.com/office/word/2018/wordml"},w16sdtdh:{key:"xmlns:w16sdtdh",value:"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash"},w16se:{key:"xmlns:w16se",value:"http://schemas.microsoft.com/office/word/2015/wordml/symex"},Ignorable:{key:"mc:Ignorable",value:"w14 w15 w16se w16cid w16 w16cex w16sdtdh"}},children:$.map((U,Y)=>qV({name:U.name,index:Y+1,fontKey:U.fontKey,characterSet:U.characterSet}))});class R${constructor($){Y0(this,"fontTable"),Y0(this,"relationships"),Y0(this,"fontOptionsWithKey",[]),this.options=$,this.fontOptionsWithKey=$.map((U)=>R0(W0({},U),{fontKey:tQ()})),this.fontTable=XV(this.fontOptionsWithKey),this.relationships=new W2;for(let U=0;U<$.length;U++)this.relationships.addRelationship(U+1,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/font",`fonts/${$[U].name}.odttf`)}get View(){return this.fontTable}get Relationships(){return this.relationships}}var VV=()=>new B0({name:"w:wordWrap",attributes:{val:{key:"w:val",value:0}}}),BV={NONE:"none",DROP:"drop",MARGIN:"margin"},LV={MARGIN:"margin",PAGE:"page",TEXT:"text"},MV={AROUND:"around",AUTO:"auto",NONE:"none",NOT_BESIDE:"notBeside",THROUGH:"through",TIGHT:"tight"},xG=($)=>{var U,Y;return new B0({name:"w:framePr",attributes:{anchorLock:{key:"w:anchorLock",value:$.anchorLock},dropCap:{key:"w:dropCap",value:$.dropCap},width:{key:"w:w",value:$.width},height:{key:"w:h",value:$.height},x:{key:"w:x",value:$.position?$.position.x:void 0},y:{key:"w:y",value:$.position?$.position.y:void 0},anchorHorizontal:{key:"w:hAnchor",value:$.anchor.horizontal},anchorVertical:{key:"w:vAnchor",value:$.anchor.vertical},spaceHorizontal:{key:"w:hSpace",value:(U=$.space)==null?void 0:U.horizontal},spaceVertical:{key:"w:vSpace",value:(Y=$.space)==null?void 0:Y.vertical},rule:{key:"w:hRule",value:$.rule},alignmentX:{key:"w:xAlign",value:$.alignment?$.alignment.x:void 0},alignmentY:{key:"w:yAlign",value:$.alignment?$.alignment.y:void 0},lines:{key:"w:lines",value:$.lines},wrap:{key:"w:wrap",value:$.wrap}}})};class Z2 extends Q2{constructor($){var U,Y;super("w:pPr",$==null?void 0:$.includeIfEmpty);if(Y0(this,"numberingReferences",[]),!$)return this;if($.heading)this.push(K1($.heading));if($.bullet)this.push(K1("ListParagraph"));if($.numbering){if(!$.style&&!$.heading){if(!$.numbering.custom)this.push(K1("ListParagraph"))}}if($.style)this.push(K1($.style));if($.keepNext!==void 0)this.push(new X0("w:keepNext",$.keepNext));if($.keepLines!==void 0)this.push(new X0("w:keepLines",$.keepLines));if($.pageBreakBefore)this.push(new H$);if($.frame)this.push(xG($.frame));if($.widowControl!==void 0)this.push(new X0("w:widowControl",$.widowControl));if($.bullet)this.push(new V1(1,$.bullet.level));if($.numbering)this.numberingReferences.push({reference:$.numbering.reference,instance:(U=$.numbering.instance)!=null?U:0}),this.push(new V1(`${$.numbering.reference}-${(Y=$.numbering.instance)!=null?Y:0}`,$.numbering.level));else if($.numbering===!1)this.push(new V1(0,0));if($.border)this.push(new o9($.border));if($.thematicBreak)this.push(new t9);if($.shading)this.push(j1($.shading));if($.wordWrap)this.push(VV());if($.overflowPunctuation)this.push(new X0("w:overflowPunct",$.overflowPunctuation));let Z=[...$.rightTabStop!==void 0?[{type:O9.RIGHT,position:$.rightTabStop}]:[],...$.tabStops?$.tabStops:[],...$.leftTabStop!==void 0?[{type:O9.LEFT,position:$.leftTabStop}]:[]];if(Z.length>0)this.push(TG(Z));if($.bidirectional!==void 0)this.push(new X0("w:bidi",$.bidirectional));if($.spacing)this.push(AG($.spacing));if($.indent)this.push(EQ($.indent));if($.contextualSpacing!==void 0)this.push(new X0("w:contextualSpacing",$.contextualSpacing));if($.alignment)this.push(n9($.alignment));if($.outlineLevel!==void 0)this.push(yG($.outlineLevel));if($.suppressLineNumbers!==void 0)this.push(new X0("w:suppressLineNumbers",$.suppressLineNumbers));if($.autoSpaceEastAsianText!==void 0)this.push(new X0("w:autoSpaceDN",$.autoSpaceEastAsianText));if($.run)this.push(new Q$($.run));if($.revision)this.push(new D$($.revision))}push($){this.root.push($)}prepForXml($){if(!($.viewWrapper instanceof R$))for(let U of this.numberingReferences)$.file.Numbering.createConcreteNumberingInstance(U.reference,U.instance);return super.prepForXml($)}}class D$ extends o{constructor($){super("w:pPrChange");this.root.push(new _0({id:$.id,author:$.author,date:$.date})),this.root.push(new Z2(R0(W0({},$),{includeIfEmpty:!0})))}}class h0 extends r2{constructor($){super("w:p");if(Y0(this,"properties"),typeof $==="string")return this.properties=new Z2({}),this.root.push(this.properties),this.root.push(new p2($)),this;if(this.properties=new Z2($),this.root.push(this.properties),$.text)this.root.push(new p2($.text));if($.children)for(let U of $.children){if(U instanceof z$){this.root.push(U.start);for(let Y of U.children)this.root.push(Y);this.root.push(U.end);continue}this.root.push(U)}}prepForXml($){for(let U of this.root)if(U instanceof K8){let Y=this.root.indexOf(U),Z=new _2(U.options.children,R1());$.viewWrapper.Relationships.addRelationship(Z.linkId,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",U.options.link,tJ.EXTERNAL),this.root[Y]=Z}return super.prepForXml($)}addRunToFront($){return this.root.splice(1,0,$),this}}var IV=class extends o{constructor(U){super("m:oMath");for(let Y of U.children)this.root.push(Y)}};class fG extends o{constructor($){super("m:t");this.root.push($)}}class hG extends o{constructor($){super("m:r");this.root.push(new fG($))}}class A$ extends o{constructor($){super("m:den");for(let U of $)this.root.push(U)}}class P$ extends o{constructor($){super("m:num");for(let U of $)this.root.push(U)}}class uG extends o{constructor($){super("m:f");this.root.push(new P$($.numerator)),this.root.push(new A$($.denominator))}}var dG=({accent:$})=>new B0({name:"m:chr",attributes:{accent:{key:"m:val",value:$}}}),y0=({children:$})=>new B0({name:"m:e",children:$}),cG=({value:$})=>new B0({name:"m:limLoc",attributes:{value:{key:"m:val",value:$||"undOvr"}}}),wV=()=>new B0({name:"m:subHide",attributes:{hide:{key:"m:val",value:1}}}),WV=()=>new B0({name:"m:supHide",attributes:{hide:{key:"m:val",value:1}}}),T$=({accent:$,hasSuperScript:U,hasSubScript:Y,limitLocationVal:Z})=>new B0({name:"m:naryPr",children:[...$?[dG({accent:$})]:[],cG({value:Z}),...!U?[WV()]:[],...!Y?[wV()]:[]]}),s2=({children:$})=>new B0({name:"m:sub",children:$}),n2=({children:$})=>new B0({name:"m:sup",children:$});class mG extends o{constructor($){super("m:nary");if(this.root.push(T$({accent:"∑",hasSuperScript:!!$.superScript,hasSubScript:!!$.subScript})),$.subScript)this.root.push(s2({children:$.subScript}));if($.superScript)this.root.push(n2({children:$.superScript}));this.root.push(y0({children:$.children}))}}class lG extends o{constructor($){super("m:nary");if(this.root.push(T$({accent:"",hasSuperScript:!!$.superScript,hasSubScript:!!$.subScript,limitLocationVal:"subSup"})),$.subScript)this.root.push(s2({children:$.subScript}));if($.superScript)this.root.push(n2({children:$.superScript}));this.root.push(y0({children:$.children}))}}class q8 extends o{constructor($){super("m:lim");for(let U of $)this.root.push(U)}}class aG extends o{constructor($){super("m:limUpp");this.root.push(y0({children:$.children})),this.root.push(new q8($.limit))}}class pG extends o{constructor($){super("m:limLow");this.root.push(y0({children:$.children})),this.root.push(new q8($.limit))}}var iG=()=>new B0({name:"m:sSupPr"});class rG extends o{constructor($){super("m:sSup");this.root.push(iG()),this.root.push(y0({children:$.children})),this.root.push(n2({children:$.superScript}))}}var sG=()=>new B0({name:"m:sSubPr"});class nG extends o{constructor($){super("m:sSub");this.root.push(sG()),this.root.push(y0({children:$.children})),this.root.push(s2({children:$.subScript}))}}var oG=()=>new B0({name:"m:sSubSupPr"});class tG extends o{constructor($){super("m:sSubSup");this.root.push(oG()),this.root.push(y0({children:$.children})),this.root.push(s2({children:$.subScript})),this.root.push(n2({children:$.superScript}))}}var eG=()=>new B0({name:"m:sPrePr"});class $K extends B0{constructor({children:$,subScript:U,superScript:Y}){super({name:"m:sPre",children:[eG(),y0({children:$}),s2({children:U}),n2({children:Y})]})}}var HV="";class C$ extends o{constructor($){super("m:deg");if($)for(let U of $)this.root.push(U)}}class UK extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{hide:"m:val"})}}class YK extends o{constructor(){super("m:degHide");this.root.push(new UK({hide:1}))}}class O$ extends o{constructor($){super("m:radPr");if(!$)this.root.push(new YK)}}class ZK extends o{constructor($){super("m:rad");this.root.push(new O$(!!$.degree)),this.root.push(new C$($.degree)),this.root.push(y0({children:$.children}))}}class k$ extends o{constructor($){super("m:fName");for(let U of $)this.root.push(U)}}class E$ extends o{constructor(){super("m:funcPr")}}class QK extends o{constructor($){super("m:func");this.root.push(new E$),this.root.push(new k$($.name)),this.root.push(y0({children:$.children}))}}var jV=({character:$})=>new B0({name:"m:begChr",attributes:{character:{key:"m:val",value:$}}}),zV=({character:$})=>new B0({name:"m:endChr",attributes:{character:{key:"m:val",value:$}}}),X8=({characters:$})=>new B0({name:"m:dPr",children:$?[jV({character:$.beginningCharacter}),zV({character:$.endingCharacter})]:[]});class JK extends o{constructor($){super("m:d");this.root.push(X8({})),this.root.push(y0({children:$.children}))}}class GK extends o{constructor($){super("m:d");this.root.push(X8({characters:{beginningCharacter:"[",endingCharacter:"]"}})),this.root.push(y0({children:$.children}))}}class KK extends o{constructor($){super("m:d");this.root.push(X8({characters:{beginningCharacter:"{",endingCharacter:"}"}})),this.root.push(y0({children:$.children}))}}class qK extends o{constructor($){super("m:d");this.root.push(X8({characters:{beginningCharacter:"〈",endingCharacter:"〉"}})),this.root.push(y0({children:$.children}))}}var FV=($)=>new B0({name:"w:gridCol",attributes:$!==void 0?{width:{key:"w:w",value:T0($)}}:void 0});class S$ extends o{constructor($,U){super("w:tblGrid");for(let Y of $)this.root.push(FV(Y));if(U)this.root.push(new VK(U))}}class XK extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{id:"w:id"})}}class VK extends o{constructor($){super("w:tblGridChange");this.root.push(new XK({id:$.id})),this.root.push(new S$($.columnWidths))}}class BK extends o{constructor($){super("w:ins");this.root.push(new _0({id:$.id,author:$.author,date:$.date})),this.addChildElement(new p2($))}}class LK extends o{constructor(){super("w:delInstrText");this.root.push(new x0({space:g0.PRESERVE})),this.root.push("PAGE")}}class MK extends o{constructor(){super("w:delInstrText");this.root.push(new x0({space:g0.PRESERVE})),this.root.push("NUMPAGES")}}class IK extends o{constructor(){super("w:delInstrText");this.root.push(new x0({space:g0.PRESERVE})),this.root.push("SECTIONPAGES")}}class k9 extends o{constructor($){super("w:delText");this.root.push(new x0({space:g0.PRESERVE})),this.root.push($)}}class wK extends o{constructor($){super("w:del");Y0(this,"deletedTextRunWrapper"),this.root.push(new _0({id:$.id,author:$.author,date:$.date})),this.deletedTextRunWrapper=new WK($),this.addChildElement(this.deletedTextRunWrapper)}}class WK extends o{constructor($){super("w:r");if(this.root.push(new J2($)),$.children)for(let U of $.children){if(typeof U==="string"){switch(U){case N2.CURRENT:this.root.push($2()),this.root.push(new LK),this.root.push(I2()),this.root.push(U2());break;case N2.TOTAL_PAGES:this.root.push($2()),this.root.push(new MK),this.root.push(I2()),this.root.push(U2());break;case N2.TOTAL_PAGES_IN_SECTION:this.root.push($2()),this.root.push(new IK),this.root.push(I2()),this.root.push(U2());break;default:this.root.push(new k9(U));break}continue}this.root.push(U)}else if($.text)this.root.push(new k9($.text));if($.break)for(let U=0;U<$.break;U++)this.root.splice(1,0,SQ())}}class v$ extends o{constructor($){super("w:ins");this.root.push(new _0({id:$.id,author:$.author,date:$.date}))}}class _$ extends o{constructor($){super("w:del");this.root.push(new _0({id:$.id,author:$.author,date:$.date}))}}class y$ extends o{constructor($){super("w:cellIns");this.root.push(new _0({id:$.id,author:$.author,date:$.date}))}}class b$ extends o{constructor($){super("w:cellDel");this.root.push(new _0({id:$.id,author:$.author,date:$.date}))}}var NV={CONTINUE:"cont",RESTART:"rest"};class g$ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{id:"w:id",author:"w:author",date:"w:date",verticalMerge:"w:vMerge",verticalMergeOriginal:"w:vMergeOrig"})}}class x$ extends o{constructor($){super("w:cellMerge");this.root.push(new g$($))}}var HK={TOP:"top",CENTER:"center",BOTTOM:"bottom"},jK=R0(W0({},HK),{BOTH:"both"}),RV=jK,f$=($)=>new B0({name:"w:vAlign",attributes:{verticalAlign:{key:"w:val",value:$}}}),zK=({marginUnitType:$=l1.DXA,top:U,left:Y,bottom:Z,right:J})=>[{name:"w:top",size:U},{name:"w:left",size:Y},{name:"w:bottom",size:Z},{name:"w:right",size:J}].filter((G)=>G.size!==void 0).map(({name:G,size:X})=>M1(G,{type:$,size:X})),DV=($)=>{let U=zK($);if(U.length===0)return;return new B0({name:"w:tblCellMar",children:U})},AV=($)=>{let U=zK($);if(U.length===0)return;return new B0({name:"w:tcMar",children:U})},l1={AUTO:"auto",DXA:"dxa",NIL:"nil",PERCENTAGE:"pct"},M1=($,{type:U=l1.AUTO,size:Y})=>{let Z=Y;if(U===l1.PERCENTAGE&&typeof Y==="number")Z=`${Y}%`;return new B0({name:$,attributes:{type:{key:"w:type",value:U},size:{key:"w:w",value:s9(Z)}}})};class h$ extends Q2{constructor($){super("w:tcBorders");if($.top)this.root.push(N0("w:top",$.top));if($.start)this.root.push(N0("w:start",$.start));if($.left)this.root.push(N0("w:left",$.left));if($.bottom)this.root.push(N0("w:bottom",$.bottom));if($.end)this.root.push(N0("w:end",$.end));if($.right)this.root.push(N0("w:right",$.right))}}class FK extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{val:"w:val"})}}class u$ extends o{constructor($){super("w:gridSpan");this.root.push(new FK({val:S0($)}))}}var d$={CONTINUE:"continue",RESTART:"restart"};class NK extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{val:"w:val"})}}class a1 extends o{constructor($){super("w:vMerge");this.root.push(new NK({val:$}))}}var PV={BOTTOM_TO_TOP_LEFT_TO_RIGHT:"btLr",LEFT_TO_RIGHT_TOP_TO_BOTTOM:"lrTb",TOP_TO_BOTTOM_RIGHT_TO_LEFT:"tbRl"};class RK extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{val:"w:val"})}}class c$ extends o{constructor($){super("w:textDirection");this.root.push(new RK({val:$}))}}class m$ extends Q2{constructor($){super("w:tcPr",$.includeIfEmpty);if($.width)this.root.push(M1("w:tcW",$.width));if($.columnSpan)this.root.push(new u$($.columnSpan));if($.verticalMerge)this.root.push(new a1($.verticalMerge));else if($.rowSpan&&$.rowSpan>1)this.root.push(new a1(d$.RESTART));if($.borders)this.root.push(new h$($.borders));if($.shading)this.root.push(j1($.shading));if($.margins){let U=AV($.margins);if(U)this.root.push(U)}if($.textDirection)this.root.push(new c$($.textDirection));if($.verticalAlign)this.root.push(f$($.verticalAlign));if($.insertion)this.root.push(new y$($.insertion));if($.deletion)this.root.push(new b$($.deletion));if($.revision)this.root.push(new DK($.revision));if($.cellMerge)this.root.push(new x$($.cellMerge))}}class DK extends o{constructor($){super("w:tcPrChange");this.root.push(new _0({id:$.id,author:$.author,date:$.date})),this.root.push(new m$(R0(W0({},$),{includeIfEmpty:!0})))}}class V8 extends o{constructor($){super("w:tc");this.options=$,this.root.push(new m$($));for(let U of $.children)this.root.push(U)}prepForXml($){if(!(this.root[this.root.length-1]instanceof h0))this.root.push(new h0({}));return super.prepForXml($)}}var x2={style:Q8.NONE,size:0,color:"auto"},f2={style:Q8.SINGLE,size:4,color:"auto"};class B8 extends o{constructor($){var U,Y,Z,J,G,X;super("w:tblBorders");this.root.push(N0("w:top",(U=$.top)!=null?U:f2)),this.root.push(N0("w:left",(Y=$.left)!=null?Y:f2)),this.root.push(N0("w:bottom",(Z=$.bottom)!=null?Z:f2)),this.root.push(N0("w:right",(J=$.right)!=null?J:f2)),this.root.push(N0("w:insideH",(G=$.insideHorizontal)!=null?G:f2)),this.root.push(N0("w:insideV",(X=$.insideVertical)!=null?X:f2))}}Y0(B8,"NONE",{top:x2,bottom:x2,left:x2,right:x2,insideHorizontal:x2,insideVertical:x2});var TV={MARGIN:"margin",PAGE:"page",TEXT:"text"},CV={CENTER:"center",INSIDE:"inside",LEFT:"left",OUTSIDE:"outside",RIGHT:"right"},OV={CENTER:"center",INSIDE:"inside",BOTTOM:"bottom",OUTSIDE:"outside",INLINE:"inline",TOP:"top"},kV={NEVER:"never",OVERLAP:"overlap"},EV=($)=>new B0({name:"w:tblOverlap",attributes:{val:{key:"w:val",value:$}}}),AK=({horizontalAnchor:$,verticalAnchor:U,absoluteHorizontalPosition:Y,relativeHorizontalPosition:Z,absoluteVerticalPosition:J,relativeVerticalPosition:G,bottomFromText:X,topFromText:Q,leftFromText:B,rightFromText:F,overlap:z})=>new B0({name:"w:tblpPr",attributes:{leftFromText:{key:"w:leftFromText",value:B===void 0?void 0:T0(B)},rightFromText:{key:"w:rightFromText",value:F===void 0?void 0:T0(F)},topFromText:{key:"w:topFromText",value:Q===void 0?void 0:T0(Q)},bottomFromText:{key:"w:bottomFromText",value:X===void 0?void 0:T0(X)},absoluteHorizontalPosition:{key:"w:tblpX",value:Y===void 0?void 0:e0(Y)},absoluteVerticalPosition:{key:"w:tblpY",value:J===void 0?void 0:e0(J)},horizontalAnchor:{key:"w:horzAnchor",value:$},relativeHorizontalPosition:{key:"w:tblpXSpec",value:Z},relativeVerticalPosition:{key:"w:tblpYSpec",value:G},verticalAnchor:{key:"w:vertAnchor",value:U}},children:z?[EV(z)]:void 0}),SV={AUTOFIT:"autofit",FIXED:"fixed"},PK=($)=>new B0({name:"w:tblLayout",attributes:{type:{key:"w:type",value:$}}}),vV={DXA:"dxa"},TK=({type:$=vV.DXA,value:U})=>new B0({name:"w:tblCellSpacing",attributes:{type:{key:"w:type",value:$},value:{key:"w:w",value:s9(U)}}}),CK=({firstRow:$,lastRow:U,firstColumn:Y,lastColumn:Z,noHBand:J,noVBand:G})=>new B0({name:"w:tblLook",attributes:{firstRow:{key:"w:firstRow",value:$},lastRow:{key:"w:lastRow",value:U},firstColumn:{key:"w:firstColumn",value:Y},lastColumn:{key:"w:lastColumn",value:Z},noHBand:{key:"w:noHBand",value:J},noVBand:{key:"w:noVBand",value:G}}});class L8 extends Q2{constructor($){super("w:tblPr",$.includeIfEmpty);if($.style)this.root.push(new Y2("w:tblStyle",$.style));if($.float)this.root.push(AK($.float));if($.visuallyRightToLeft!==void 0)this.root.push(new X0("w:bidiVisual",$.visuallyRightToLeft));if($.width)this.root.push(M1("w:tblW",$.width));if($.alignment)this.root.push(n9($.alignment));if($.indent)this.root.push(M1("w:tblInd",$.indent));if($.borders)this.root.push(new B8($.borders));if($.shading)this.root.push(j1($.shading));if($.layout)this.root.push(PK($.layout));if($.cellMargin){let U=DV($.cellMargin);if(U)this.root.push(U)}if($.tableLook)this.root.push(CK($.tableLook));if($.cellSpacing)this.root.push(TK($.cellSpacing));if($.revision)this.root.push(new OK($.revision))}}class OK extends o{constructor($){super("w:tblPrChange");this.root.push(new _0({id:$.id,author:$.author,date:$.date})),this.root.push(new L8(R0(W0({},$),{includeIfEmpty:!0})))}}class kK extends r2{constructor({rows:$,width:U,columnWidths:Y=Array(Math.max(...$.map((H)=>H.CellCount))).fill(100),columnWidthsRevision:Z,margins:J,indent:G,float:X,layout:Q,style:B,borders:F,alignment:z,visuallyRightToLeft:W,tableLook:k,cellSpacing:D,revision:C}){super("w:tbl");this.root.push(new L8({borders:F!=null?F:{},width:U!=null?U:{size:100},indent:G,float:X,layout:Q,style:B,alignment:z,cellMargin:J,visuallyRightToLeft:W,tableLook:k,cellSpacing:D,revision:C})),this.root.push(new S$(Y,Z));for(let H of $)this.root.push(H);$.forEach((H,O)=>{if(O===$.length-1)return;let V=0;H.cells.forEach((j)=>{if(j.options.rowSpan&&j.options.rowSpan>1){let M=new V8({rowSpan:j.options.rowSpan-1,columnSpan:j.options.columnSpan,borders:j.options.borders,children:[],verticalMerge:d$.CONTINUE});$[O+1].addCellToColumnIndex(M,V)}V+=j.options.columnSpan||1})})}}var _V={AUTO:"auto",ATLEAST:"atLeast",EXACT:"exact"},EK=($,U)=>new B0({name:"w:trHeight",attributes:{value:{key:"w:val",value:T0($)},rule:{key:"w:hRule",value:U}}});class M8 extends Q2{constructor($){super("w:trPr",$.includeIfEmpty);if($.cantSplit!==void 0)this.root.push(new X0("w:cantSplit",$.cantSplit));if($.tableHeader!==void 0)this.root.push(new X0("w:tblHeader",$.tableHeader));if($.height)this.root.push(EK($.height.value,$.height.rule));if($.cellSpacing)this.root.push(TK($.cellSpacing));if($.insertion)this.root.push(new v$($.insertion));if($.deletion)this.root.push(new _$($.deletion));if($.revision)this.root.push(new l$($.revision))}}class l$ extends o{constructor($){super("w:trPrChange");this.root.push(new _0({id:$.id,author:$.author,date:$.date})),this.root.push(new M8(R0(W0({},$),{includeIfEmpty:!0})))}}class SK extends o{constructor($){super("w:tr");this.options=$,this.root.push(new M8($));for(let U of $.children)this.root.push(U)}get CellCount(){return this.options.children.length}get cells(){return this.root.filter(($)=>$ instanceof V8)}addCellToIndex($,U){this.root.splice(U+1,0,$)}addCellToColumnIndex($,U){let Y=this.columnIndexToRootIndex(U,!0);this.addCellToIndex($,Y-1)}rootIndexToColumnIndex($){if($<1||$>=this.root.length)throw Error(`cell 'rootIndex' should between 1 to ${this.root.length-1}`);let U=0;for(let Y=1;Y<$;Y++){let Z=this.root[Y];U+=Z.options.columnSpan||1}return U}columnIndexToRootIndex($,U=!1){if($<0)throw Error("cell 'columnIndex' should not less than zero");let Y=0,Z=1;while(Y<=$){if(Z>=this.root.length)if(U)return this.root.length;else throw Error(`cell 'columnIndex' should not great than ${Y-1}`);let J=this.root[Z];Z+=1,Y+=J&&J.options.columnSpan||1}return Z-1}}class vK extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{xmlns:"xmlns",vt:"xmlns:vt"})}}class _K extends o{constructor(){super("Properties");this.root.push(new vK({xmlns:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",vt:"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"}))}}class yK extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{xmlns:"xmlns"})}}var B2=($,U)=>new B0({name:"Default",attributes:{contentType:{key:"ContentType",value:$},extension:{key:"Extension",value:U}}}),f0=($,U)=>new B0({name:"Override",attributes:{contentType:{key:"ContentType",value:$},partName:{key:"PartName",value:U}}});class bK extends o{constructor(){super("Types");this.root.push(new yK({xmlns:"http://schemas.openxmlformats.org/package/2006/content-types"})),this.root.push(B2("image/png","png")),this.root.push(B2("image/jpeg","jpeg")),this.root.push(B2("image/jpeg","jpg")),this.root.push(B2("image/bmp","bmp")),this.root.push(B2("image/gif","gif")),this.root.push(B2("image/svg+xml","svg")),this.root.push(B2("application/vnd.openxmlformats-package.relationships+xml","rels")),this.root.push(B2("application/xml","xml")),this.root.push(B2("application/vnd.openxmlformats-officedocument.obfuscatedFont","odttf")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml","/word/document.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml","/word/styles.xml")),this.root.push(f0("application/vnd.openxmlformats-package.core-properties+xml","/docProps/core.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.custom-properties+xml","/docProps/custom.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.extended-properties+xml","/docProps/app.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml","/word/numbering.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml","/word/footnotes.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml","/word/endnotes.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml","/word/settings.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml","/word/comments.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml","/word/fontTable.xml"))}addFooter($){this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml",`/word/footer${$}.xml`))}addHeader($){this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml",`/word/header${$}.xml`))}}var p1={wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wpi:"http://schemas.microsoft.com/office/word/2010/wordprocessingInk",wne:"http://schemas.microsoft.com/office/word/2006/wordml",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape",cp:"http://schemas.openxmlformats.org/package/2006/metadata/core-properties",dc:"http://purl.org/dc/elements/1.1/",dcterms:"http://purl.org/dc/terms/",dcmitype:"http://purl.org/dc/dcmitype/",xsi:"http://www.w3.org/2001/XMLSchema-instance",cx:"http://schemas.microsoft.com/office/drawing/2014/chartex",cx1:"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex",cx2:"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex",cx3:"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex",cx4:"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex",cx5:"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex",cx6:"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex",cx7:"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex",cx8:"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex",aink:"http://schemas.microsoft.com/office/drawing/2016/ink",am3d:"http://schemas.microsoft.com/office/drawing/2017/model3d",w16cex:"http://schemas.microsoft.com/office/word/2018/wordml/cex",w16cid:"http://schemas.microsoft.com/office/word/2016/wordml/cid",w16:"http://schemas.microsoft.com/office/word/2018/wordml",w16sdtdh:"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash",w16se:"http://schemas.microsoft.com/office/word/2015/wordml/symex"};class o2 extends I0{constructor($,U){super(W0({Ignorable:U},Object.fromEntries($.map((Y)=>[Y,p1[Y]]))));Y0(this,"xmlKeys",W0({Ignorable:"mc:Ignorable"},Object.fromEntries(Object.keys(p1).map((Y)=>[Y,`xmlns:${Y}`]))))}}class gK extends o{constructor($){super("cp:coreProperties");if(this.root.push(new o2(["cp","dc","dcterms","dcmitype","xsi"])),$.title)this.root.push(new L2("dc:title",$.title));if($.subject)this.root.push(new L2("dc:subject",$.subject));if($.creator)this.root.push(new L2("dc:creator",$.creator));if($.keywords)this.root.push(new L2("cp:keywords",$.keywords));if($.description)this.root.push(new L2("dc:description",$.description));if($.lastModifiedBy)this.root.push(new L2("cp:lastModifiedBy",$.lastModifiedBy));if($.revision)this.root.push(new L2("cp:revision",String($.revision)));this.root.push(new E9("dcterms:created")),this.root.push(new E9("dcterms:modified"))}}class xK extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{type:"xsi:type"})}}class E9 extends o{constructor($){super($);this.root.push(new xK({type:"dcterms:W3CDTF"})),this.root.push(OQ(new Date))}}class fK extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{xmlns:"xmlns",vt:"xmlns:vt"})}}class hK extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{formatId:"fmtid",pid:"pid",name:"name"})}}class uK extends o{constructor($,U){super("property");this.root.push(new hK({formatId:"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",pid:$.toString(),name:U.name})),this.root.push(new dK(U.value))}}class dK extends o{constructor($){super("vt:lpwstr");this.root.push($)}}class cK extends o{constructor($){super("Properties");Y0(this,"nextId"),Y0(this,"properties",[]),this.root.push(new fK({xmlns:"http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",vt:"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"})),this.nextId=2;for(let U of $)this.addCustomProperty(U)}prepForXml($){return this.properties.forEach((U)=>this.root.push(U)),super.prepForXml($)}addCustomProperty($){this.properties.push(new uK(this.nextId++,$))}}var mK=({space:$,count:U,separate:Y,equalWidth:Z,children:J})=>new B0({name:"w:cols",attributes:{space:{key:"w:space",value:$===void 0?void 0:T0($)},count:{key:"w:num",value:U===void 0?void 0:S0(U)},separate:{key:"w:sep",value:Y},equalWidth:{key:"w:equalWidth",value:Z}},children:!Z&&J?J:void 0}),yV={DEFAULT:"default",LINES:"lines",LINES_AND_CHARS:"linesAndChars",SNAP_TO_CHARS:"snapToChars"},lK=({type:$,linePitch:U,charSpace:Y})=>new B0({name:"w:docGrid",attributes:{type:{key:"w:type",value:$},linePitch:{key:"w:linePitch",value:S0(U)},charSpace:{key:"w:charSpace",value:Y?S0(Y):void 0}}}),E2={DEFAULT:"default",FIRST:"first",EVEN:"even"},S9={HEADER:"w:headerReference",FOOTER:"w:footerReference"},f1=($,U)=>new B0({name:$,attributes:{type:{key:"w:type",value:U.type||E2.DEFAULT},id:{key:"r:id",value:`rId${U.id}`}}}),bV={NEW_PAGE:"newPage",NEW_SECTION:"newSection",CONTINUOUS:"continuous"},aK=({countBy:$,start:U,restart:Y,distance:Z})=>new B0({name:"w:lnNumType",attributes:{countBy:{key:"w:countBy",value:$===void 0?void 0:S0($)},start:{key:"w:start",value:U===void 0?void 0:S0(U)},restart:{key:"w:restart",value:Y},distance:{key:"w:distance",value:Z===void 0?void 0:T0(Z)}}}),gV={ALL_PAGES:"allPages",FIRST_PAGE:"firstPage",NOT_FIRST_PAGE:"notFirstPage"},xV={PAGE:"page",TEXT:"text"},fV={BACK:"back",FRONT:"front"};class v9 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{display:"w:display",offsetFrom:"w:offsetFrom",zOrder:"w:zOrder"})}}class a$ extends Q2{constructor($){super("w:pgBorders");if(!$)return this;if($.pageBorders)this.root.push(new v9({display:$.pageBorders.display,offsetFrom:$.pageBorders.offsetFrom,zOrder:$.pageBorders.zOrder}));else this.root.push(new v9({}));if($.pageBorderTop)this.root.push(N0("w:top",$.pageBorderTop));if($.pageBorderLeft)this.root.push(N0("w:left",$.pageBorderLeft));if($.pageBorderBottom)this.root.push(N0("w:bottom",$.pageBorderBottom));if($.pageBorderRight)this.root.push(N0("w:right",$.pageBorderRight))}}var pK=($,U,Y,Z,J,G,X)=>new B0({name:"w:pgMar",attributes:{top:{key:"w:top",value:e0($)},right:{key:"w:right",value:T0(U)},bottom:{key:"w:bottom",value:e0(Y)},left:{key:"w:left",value:T0(Z)},header:{key:"w:header",value:T0(J)},footer:{key:"w:footer",value:T0(G)},gutter:{key:"w:gutter",value:T0(X)}}}),hV={HYPHEN:"hyphen",PERIOD:"period",COLON:"colon",EM_DASH:"emDash",EN_DASH:"endash"},iK=({start:$,formatType:U,separator:Y})=>new B0({name:"w:pgNumType",attributes:{start:{key:"w:start",value:$===void 0?void 0:S0($)},formatType:{key:"w:fmt",value:U},separator:{key:"w:chapSep",value:Y}}}),i1={PORTRAIT:"portrait",LANDSCAPE:"landscape"},rK=({width:$,height:U,orientation:Y,code:Z})=>{let J=T0($),G=T0(U);return new B0({name:"w:pgSz",attributes:{width:{key:"w:w",value:Y===i1.LANDSCAPE?G:J},height:{key:"w:h",value:Y===i1.LANDSCAPE?J:G},orientation:{key:"w:orient",value:Y},code:{key:"w:code",value:Z}}})},uV={LEFT_TO_RIGHT_TOP_TO_BOTTOM:"lrTb",TOP_TO_BOTTOM_RIGHT_TO_LEFT:"tbRl"};class sK extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{val:"w:val"})}}class p$ extends o{constructor($){super("w:textDirection");this.root.push(new sK({val:$}))}}var dV={NEXT_PAGE:"nextPage",NEXT_COLUMN:"nextColumn",CONTINUOUS:"continuous",EVEN_PAGE:"evenPage",ODD_PAGE:"oddPage"},nK=($)=>new B0({name:"w:type",attributes:{val:{key:"w:val",value:$}}}),F2={TOP:1440,RIGHT:1440,BOTTOM:1440,LEFT:1440,HEADER:708,FOOTER:708,GUTTER:0},h1={WIDTH:11906,HEIGHT:16838,ORIENTATION:i1.PORTRAIT};class I8 extends o{constructor({page:{size:{width:$=h1.WIDTH,height:U=h1.HEIGHT,orientation:Y=h1.ORIENTATION}={},margin:{top:Z=F2.TOP,right:J=F2.RIGHT,bottom:G=F2.BOTTOM,left:X=F2.LEFT,header:Q=F2.HEADER,footer:B=F2.FOOTER,gutter:F=F2.GUTTER}={},pageNumbers:z={},borders:W,textDirection:k}={},grid:{linePitch:D=360,charSpace:C,type:H}={},headerWrapperGroup:O={},footerWrapperGroup:V={},lineNumbers:j,titlePage:M,verticalAlign:L,column:A,type:y,revision:g}={}){super("w:sectPr");if(this.addHeaderFooterGroup(S9.HEADER,O),this.addHeaderFooterGroup(S9.FOOTER,V),y)this.root.push(nK(y));if(this.root.push(rK({width:$,height:U,orientation:Y})),this.root.push(pK(Z,J,G,X,Q,B,F)),W)this.root.push(new a$(W));if(j)this.root.push(aK(j));if(this.root.push(iK(z)),A)this.root.push(mK(A));if(L)this.root.push(f$(L));if(M!==void 0)this.root.push(new X0("w:titlePg",M));if(k)this.root.push(new p$(k));if(g)this.root.push(new i$(g));this.root.push(lK({linePitch:D,charSpace:C,type:H}))}addHeaderFooterGroup($,U){if(U.default)this.root.push(f1($,{type:E2.DEFAULT,id:U.default.View.ReferenceId}));if(U.first)this.root.push(f1($,{type:E2.FIRST,id:U.first.View.ReferenceId}));if(U.even)this.root.push(f1($,{type:E2.EVEN,id:U.even.View.ReferenceId}))}}class i$ extends o{constructor($){super("w:sectPrChange");this.root.push(new _0({id:$.id,author:$.author,date:$.date})),this.root.push(new I8($))}}class oK extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{width:"w:w",space:"w:space"})}}class tK extends o{constructor($){super("w:col");this.root.push(new oK({width:T0($.width),space:$.space===void 0?void 0:T0($.space)}))}}class r$ extends o{constructor(){super("w:body");Y0(this,"sections",[])}addSection($){let U=this.sections.pop();this.root.push(this.createSectionParagraph(U)),this.sections.push(new I8($))}prepForXml($){if(this.sections.length===1)this.root.splice(0,1),this.root.push(this.sections.pop());return super.prepForXml($)}push($){this.root.push($)}createSectionParagraph($){let U=new h0({}),Y=new Z2({});return Y.push($),U.addChildElement(Y),U}}class s$ extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{color:"w:color",themeColor:"w:themeColor",themeShade:"w:themeShade",themeTint:"w:themeTint"})}}class n$ extends o{constructor($){super("w:background");this.root.push(new s$({color:$.color===void 0?void 0:S2($.color),themeColor:$.themeColor,themeShade:$.themeShade===void 0?void 0:D9($.themeShade),themeTint:$.themeTint===void 0?void 0:D9($.themeTint)}))}}class eK extends o{constructor($){super("w:document");if(Y0(this,"body"),this.root.push(new o2(["wpc","mc","o","r","m","v","wp14","wp","w10","w","w14","w15","wpg","wpi","wne","wps","cx","cx1","cx2","cx3","cx4","cx5","cx6","cx7","cx8","aink","am3d","w16cex","w16cid","w16","w16sdtdh","w16se"],"w14 w15 wp14")),this.body=new r$,$.background)this.root.push(new n$($.background));this.root.push(this.body)}add($){return this.body.push($),this}get Body(){return this.body}}class $5{constructor($){Y0(this,"document"),Y0(this,"relationships"),this.document=new eK($),this.relationships=new W2}get View(){return this.document}get Relationships(){return this.relationships}}class U5 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{wpc:"xmlns:wpc",mc:"xmlns:mc",o:"xmlns:o",r:"xmlns:r",m:"xmlns:m",v:"xmlns:v",wp14:"xmlns:wp14",wp:"xmlns:wp",w10:"xmlns:w10",w:"xmlns:w",w14:"xmlns:w14",w15:"xmlns:w15",wpg:"xmlns:wpg",wpi:"xmlns:wpi",wne:"xmlns:wne",wps:"xmlns:wps",Ignorable:"mc:Ignorable"})}}class Y5 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{type:"w:type",id:"w:id"})}}class Z5 extends C0{constructor(){super({style:"EndnoteReference"});this.root.push(new I$)}}var fZ={SEPARATOR:"separator",CONTINUATION_SEPARATOR:"continuationSeparator"};class u1 extends o{constructor($){super("w:endnote");this.root.push(new Y5({type:$.type,id:$.id}));for(let U=0;U<$.children.length;U++){let Y=$.children[U];if(U===0)Y.addRunToFront(new Z5);this.root.push(Y)}}}class Q5 extends o{constructor(){super("w:continuationSeparator")}}class o$ extends C0{constructor(){super({});this.root.push(new Q5)}}class J5 extends o{constructor(){super("w:separator")}}class t$ extends C0{constructor(){super({});this.root.push(new J5)}}class e$ extends o{constructor(){super("w:endnotes");this.root.push(new U5({wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wpi:"http://schemas.microsoft.com/office/word/2010/wordprocessingInk",wne:"http://schemas.microsoft.com/office/word/2006/wordml",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape",Ignorable:"w14 w15 wp14"}));let $=new u1({id:-1,type:fZ.SEPARATOR,children:[new h0({spacing:{after:0,line:240,lineRule:v2.AUTO},children:[new t$]})]});this.root.push($);let U=new u1({id:0,type:fZ.CONTINUATION_SEPARATOR,children:[new h0({spacing:{after:0,line:240,lineRule:v2.AUTO},children:[new o$]})]});this.root.push(U)}createEndnote($,U){let Y=new u1({id:$,children:U});this.root.push(Y)}}class G5{constructor(){Y0(this,"endnotes"),Y0(this,"relationships"),this.endnotes=new e$,this.relationships=new W2}get View(){return this.endnotes}get Relationships(){return this.relationships}}class K5 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{wpc:"xmlns:wpc",mc:"xmlns:mc",o:"xmlns:o",r:"xmlns:r",m:"xmlns:m",v:"xmlns:v",wp14:"xmlns:wp14",wp:"xmlns:wp",w10:"xmlns:w10",w:"xmlns:w",w14:"xmlns:w14",w15:"xmlns:w15",wpg:"xmlns:wpg",wpi:"xmlns:wpi",wne:"xmlns:wne",wps:"xmlns:wps",cp:"xmlns:cp",dc:"xmlns:dc",dcterms:"xmlns:dcterms",dcmitype:"xmlns:dcmitype",xsi:"xmlns:xsi",type:"xsi:type"})}}var cV=class extends Y8{constructor(U,Y){super("w:ftr",Y);if(Y0(this,"refId"),this.refId=U,!Y)this.root.push(new K5({wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wpi:"http://schemas.microsoft.com/office/word/2010/wordprocessingInk",wne:"http://schemas.microsoft.com/office/word/2006/wordml",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"}))}get ReferenceId(){return this.refId}add(U){this.root.push(U)}};class $U{constructor($,U,Y){Y0(this,"footer"),Y0(this,"relationships"),this.media=$,this.footer=new cV(U,Y),this.relationships=new W2}add($){this.footer.add($)}addChildElement($){this.footer.addChildElement($)}get View(){return this.footer}get Relationships(){return this.relationships}get Media(){return this.media}}class q5 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{type:"w:type",id:"w:id"})}}class X5 extends o{constructor(){super("w:footnoteRef")}}class V5 extends C0{constructor(){super({style:"FootnoteReference"});this.root.push(new X5)}}var hZ={SEPERATOR:"separator",CONTINUATION_SEPERATOR:"continuationSeparator"};class d1 extends o{constructor($){super("w:footnote");this.root.push(new q5({type:$.type,id:$.id}));for(let U=0;U<$.children.length;U++){let Y=$.children[U];if(U===0)Y.addRunToFront(new V5);this.root.push(Y)}}}class B5 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{wpc:"xmlns:wpc",mc:"xmlns:mc",o:"xmlns:o",r:"xmlns:r",m:"xmlns:m",v:"xmlns:v",wp14:"xmlns:wp14",wp:"xmlns:wp",w10:"xmlns:w10",w:"xmlns:w",w14:"xmlns:w14",w15:"xmlns:w15",wpg:"xmlns:wpg",wpi:"xmlns:wpi",wne:"xmlns:wne",wps:"xmlns:wps",Ignorable:"mc:Ignorable"})}}class UU extends o{constructor(){super("w:footnotes");this.root.push(new B5({wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wpi:"http://schemas.microsoft.com/office/word/2010/wordprocessingInk",wne:"http://schemas.microsoft.com/office/word/2006/wordml",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape",Ignorable:"w14 w15 wp14"}));let $=new d1({id:-1,type:hZ.SEPERATOR,children:[new h0({spacing:{after:0,line:240,lineRule:v2.AUTO},children:[new t$]})]});this.root.push($);let U=new d1({id:0,type:hZ.CONTINUATION_SEPERATOR,children:[new h0({spacing:{after:0,line:240,lineRule:v2.AUTO},children:[new o$]})]});this.root.push(U)}createFootNote($,U){let Y=new d1({id:$,children:U});this.root.push(Y)}}class L5{constructor(){Y0(this,"footnotess"),Y0(this,"relationships"),this.footnotess=new UU,this.relationships=new W2}get View(){return this.footnotess}get Relationships(){return this.relationships}}class M5 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{wpc:"xmlns:wpc",mc:"xmlns:mc",o:"xmlns:o",r:"xmlns:r",m:"xmlns:m",v:"xmlns:v",wp14:"xmlns:wp14",wp:"xmlns:wp",w10:"xmlns:w10",w:"xmlns:w",w14:"xmlns:w14",w15:"xmlns:w15",wpg:"xmlns:wpg",wpi:"xmlns:wpi",wne:"xmlns:wne",wps:"xmlns:wps",cp:"xmlns:cp",dc:"xmlns:dc",dcterms:"xmlns:dcterms",dcmitype:"xmlns:dcmitype",xsi:"xmlns:xsi",type:"xsi:type",cx:"xmlns:cx",cx1:"xmlns:cx1",cx2:"xmlns:cx2",cx3:"xmlns:cx3",cx4:"xmlns:cx4",cx5:"xmlns:cx5",cx6:"xmlns:cx6",cx7:"xmlns:cx7",cx8:"xmlns:cx8",w16cid:"xmlns:w16cid",w16se:"xmlns:w16se"})}}var mV=class extends Y8{constructor(U,Y){super("w:hdr",Y);if(Y0(this,"refId"),this.refId=U,!Y)this.root.push(new M5({wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wpi:"http://schemas.microsoft.com/office/word/2010/wordprocessingInk",wne:"http://schemas.microsoft.com/office/word/2006/wordml",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape",cx:"http://schemas.microsoft.com/office/drawing/2014/chartex",cx1:"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex",cx2:"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex",cx3:"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex",cx4:"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex",cx5:"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex",cx6:"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex",cx7:"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex",cx8:"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex",w16cid:"http://schemas.microsoft.com/office/word/2016/wordml/cid",w16se:"http://schemas.microsoft.com/office/word/2015/wordml/symex"}))}get ReferenceId(){return this.refId}add(U){this.root.push(U)}};class YU{constructor($,U,Y){Y0(this,"header"),Y0(this,"relationships"),this.media=$,this.header=new mV(U,Y),this.relationships=new W2}add($){return this.header.add($),this}addChildElement($){this.header.addChildElement($)}get View(){return this.header}get Relationships(){return this.relationships}get Media(){return this.media}}class w8{constructor(){Y0(this,"map"),this.map=new Map}addImage($,U){this.map.set($,U)}get Array(){return Array.from(this.map.values())}}var lV="",n0={DECIMAL:"decimal",UPPER_ROMAN:"upperRoman",LOWER_ROMAN:"lowerRoman",UPPER_LETTER:"upperLetter",LOWER_LETTER:"lowerLetter",ORDINAL:"ordinal",CARDINAL_TEXT:"cardinalText",ORDINAL_TEXT:"ordinalText",HEX:"hex",CHICAGO:"chicago",IDEOGRAPH__DIGITAL:"ideographDigital",JAPANESE_COUNTING:"japaneseCounting",AIUEO:"aiueo",IROHA:"iroha",DECIMAL_FULL_WIDTH:"decimalFullWidth",DECIMAL_HALF_WIDTH:"decimalHalfWidth",JAPANESE_LEGAL:"japaneseLegal",JAPANESE_DIGITAL_TEN_THOUSAND:"japaneseDigitalTenThousand",DECIMAL_ENCLOSED_CIRCLE:"decimalEnclosedCircle",DECIMAL_FULL_WIDTH2:"decimalFullWidth2",AIUEO_FULL_WIDTH:"aiueoFullWidth",IROHA_FULL_WIDTH:"irohaFullWidth",DECIMAL_ZERO:"decimalZero",BULLET:"bullet",GANADA:"ganada",CHOSUNG:"chosung",DECIMAL_ENCLOSED_FULLSTOP:"decimalEnclosedFullstop",DECIMAL_ENCLOSED_PARENTHESES:"decimalEnclosedParen",DECIMAL_ENCLOSED_CIRCLE_CHINESE:"decimalEnclosedCircleChinese",IDEOGRAPH_ENCLOSED_CIRCLE:"ideographEnclosedCircle",IDEOGRAPH_TRADITIONAL:"ideographTraditional",IDEOGRAPH_ZODIAC:"ideographZodiac",IDEOGRAPH_ZODIAC_TRADITIONAL:"ideographZodiacTraditional",TAIWANESE_COUNTING:"taiwaneseCounting",IDEOGRAPH_LEGAL_TRADITIONAL:"ideographLegalTraditional",TAIWANESE_COUNTING_THOUSAND:"taiwaneseCountingThousand",TAIWANESE_DIGITAL:"taiwaneseDigital",CHINESE_COUNTING:"chineseCounting",CHINESE_LEGAL_SIMPLIFIED:"chineseLegalSimplified",CHINESE_COUNTING_THOUSAND:"chineseCountingThousand",KOREAN_DIGITAL:"koreanDigital",KOREAN_COUNTING:"koreanCounting",KOREAN_LEGAL:"koreanLegal",KOREAN_DIGITAL2:"koreanDigital2",VIETNAMESE_COUNTING:"vietnameseCounting",RUSSIAN_LOWER:"russianLower",RUSSIAN_UPPER:"russianUpper",NONE:"none",NUMBER_IN_DASH:"numberInDash",HEBREW1:"hebrew1",HEBREW2:"hebrew2",ARABIC_ALPHA:"arabicAlpha",ARABIC_ABJAD:"arabicAbjad",HINDI_VOWELS:"hindiVowels",HINDI_CONSONANTS:"hindiConsonants",HINDI_NUMBERS:"hindiNumbers",HINDI_COUNTING:"hindiCounting",THAI_LETTERS:"thaiLetters",THAI_NUMBERS:"thaiNumbers",THAI_COUNTING:"thaiCounting",BAHT_TEXT:"bahtText",DOLLAR_TEXT:"dollarText",CUSTOM:"custom"};class I5 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{ilvl:"w:ilvl",tentative:"w15:tentative"})}}class w5 extends o{constructor($){super("w:numFmt");this.root.push(new O0({val:$}))}}class W5 extends o{constructor($){super("w:lvlText");this.root.push(new O0({val:$}))}}class H5 extends o{constructor($){super("w:lvlJc");this.root.push(new O0({val:$}))}}var aV={NOTHING:"nothing",SPACE:"space",TAB:"tab"};class j5 extends o{constructor($){super("w:suff");this.root.push(new O0({val:$}))}}class z5 extends o{constructor(){super("w:isLgl")}}class W8 extends o{constructor({level:$,format:U,text:Y,alignment:Z=m0.START,start:J=1,style:G,suffix:X,isLegalNumberingStyle:Q}){super("w:lvl");if(Y0(this,"paragraphProperties"),Y0(this,"runProperties"),this.root.push(new k2("w:start",S0(J))),U)this.root.push(new w5(U));if(X)this.root.push(new j5(X));if(Q)this.root.push(new z5);if(Y)this.root.push(new W5(Y));if(this.root.push(new H5(Z)),this.paragraphProperties=new Z2(G&&G.paragraph),this.runProperties=new J2(G&&G.run),this.root.push(this.paragraphProperties),this.root.push(this.runProperties),$>9)throw Error("Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7");this.root.push(new I5({ilvl:S0($),tentative:1}))}}class ZU extends W8{}class F5 extends W8{}class N5 extends o{constructor($){super("w:multiLevelType");this.root.push(new O0({val:$}))}}class R5 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{abstractNumId:"w:abstractNumId",restartNumberingAfterBreak:"w15:restartNumberingAfterBreak"})}}class r1 extends o{constructor($,U){super("w:abstractNum");Y0(this,"id"),this.root.push(new R5({abstractNumId:S0($),restartNumberingAfterBreak:0})),this.root.push(new N5("hybridMultilevel")),this.id=$;for(let Y of U)this.root.push(new ZU(Y))}}class D5 extends o{constructor($){super("w:abstractNumId");this.root.push(new O0({val:$}))}}class A5 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{numId:"w:numId"})}}class s1 extends o{constructor($){super("w:num");if(Y0(this,"numId"),Y0(this,"reference"),Y0(this,"instance"),this.numId=$.numId,this.reference=$.reference,this.instance=$.instance,this.root.push(new A5({numId:S0($.numId)})),this.root.push(new D5(S0($.abstractNumId))),$.overrideLevels&&$.overrideLevels.length)for(let U of $.overrideLevels)this.root.push(new QU(U.num,U.start))}}class P5 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{ilvl:"w:ilvl"})}}class QU extends o{constructor($,U){super("w:lvlOverride");if(this.root.push(new P5({ilvl:$})),U!==void 0)this.root.push(new C5(U))}}class T5 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{val:"w:val"})}}class C5 extends o{constructor($){super("w:startOverride");this.root.push(new T5({val:$}))}}class JU extends o{constructor($){super("w:numbering");Y0(this,"abstractNumberingMap",new Map),Y0(this,"concreteNumberingMap",new Map),Y0(this,"referenceConfigMap",new Map),Y0(this,"abstractNumUniqueNumericId",rQ()),Y0(this,"concreteNumUniqueNumericId",sQ()),this.root.push(new o2(["wpc","mc","o","r","m","v","wp14","wp","w10","w","w14","w15","wpg","wpi","wne","wps"],"w14 w15 wp14"));let U=new r1(this.abstractNumUniqueNumericId(),[{level:0,format:n0.BULLET,text:"●",alignment:m0.LEFT,style:{paragraph:{indent:{left:d0(0.5),hanging:d0(0.25)}}}},{level:1,format:n0.BULLET,text:"○",alignment:m0.LEFT,style:{paragraph:{indent:{left:d0(1),hanging:d0(0.25)}}}},{level:2,format:n0.BULLET,text:"■",alignment:m0.LEFT,style:{paragraph:{indent:{left:2160,hanging:d0(0.25)}}}},{level:3,format:n0.BULLET,text:"●",alignment:m0.LEFT,style:{paragraph:{indent:{left:2880,hanging:d0(0.25)}}}},{level:4,format:n0.BULLET,text:"○",alignment:m0.LEFT,style:{paragraph:{indent:{left:3600,hanging:d0(0.25)}}}},{level:5,format:n0.BULLET,text:"■",alignment:m0.LEFT,style:{paragraph:{indent:{left:4320,hanging:d0(0.25)}}}},{level:6,format:n0.BULLET,text:"●",alignment:m0.LEFT,style:{paragraph:{indent:{left:5040,hanging:d0(0.25)}}}},{level:7,format:n0.BULLET,text:"●",alignment:m0.LEFT,style:{paragraph:{indent:{left:5760,hanging:d0(0.25)}}}},{level:8,format:n0.BULLET,text:"●",alignment:m0.LEFT,style:{paragraph:{indent:{left:6480,hanging:d0(0.25)}}}}]);this.concreteNumberingMap.set("default-bullet-numbering",new s1({numId:1,abstractNumId:U.id,reference:"default-bullet-numbering",instance:0,overrideLevels:[{num:0,start:1}]})),this.abstractNumberingMap.set("default-bullet-numbering",U);for(let Y of $.config)this.abstractNumberingMap.set(Y.reference,new r1(this.abstractNumUniqueNumericId(),Y.levels)),this.referenceConfigMap.set(Y.reference,Y.levels)}prepForXml($){for(let U of this.abstractNumberingMap.values())this.root.push(U);for(let U of this.concreteNumberingMap.values())this.root.push(U);return super.prepForXml($)}createConcreteNumberingInstance($,U){let Y=this.abstractNumberingMap.get($);if(!Y)return;let Z=`${$}-${U}`;if(this.concreteNumberingMap.has(Z))return;let J=this.referenceConfigMap.get($),G=J&&J[0].start,X={numId:this.concreteNumUniqueNumericId(),abstractNumId:Y.id,reference:$,instance:U,overrideLevels:[typeof G==="number"&&Number.isInteger(G)?{num:0,start:G}:{num:0,start:1}]};this.concreteNumberingMap.set(Z,new s1(X))}get ConcreteNumbering(){return Array.from(this.concreteNumberingMap.values())}get ReferenceConfig(){return Array.from(this.referenceConfigMap.values())}}var pV=($)=>new B0({name:"w:compatSetting",attributes:{version:{key:"w:val",value:$},name:{key:"w:name",value:"compatibilityMode"},uri:{key:"w:uri",value:"http://schemas.microsoft.com/office/word"}}});class O5 extends o{constructor($){super("w:compat");if($.version)this.root.push(pV($.version));if($.useSingleBorderforContiguousCells)this.root.push(new X0("w:useSingleBorderforContiguousCells",$.useSingleBorderforContiguousCells));if($.wordPerfectJustification)this.root.push(new X0("w:wpJustification",$.wordPerfectJustification));if($.noTabStopForHangingIndent)this.root.push(new X0("w:noTabHangInd",$.noTabStopForHangingIndent));if($.noLeading)this.root.push(new X0("w:noLeading",$.noLeading));if($.spaceForUnderline)this.root.push(new X0("w:spaceForUL",$.spaceForUnderline));if($.noColumnBalance)this.root.push(new X0("w:noColumnBalance",$.noColumnBalance));if($.balanceSingleByteDoubleByteWidth)this.root.push(new X0("w:balanceSingleByteDoubleByteWidth",$.balanceSingleByteDoubleByteWidth));if($.noExtraLineSpacing)this.root.push(new X0("w:noExtraLineSpacing",$.noExtraLineSpacing));if($.doNotLeaveBackslashAlone)this.root.push(new X0("w:doNotLeaveBackslashAlone",$.doNotLeaveBackslashAlone));if($.underlineTrailingSpaces)this.root.push(new X0("w:ulTrailSpace",$.underlineTrailingSpaces));if($.doNotExpandShiftReturn)this.root.push(new X0("w:doNotExpandShiftReturn",$.doNotExpandShiftReturn));if($.spacingInWholePoints)this.root.push(new X0("w:spacingInWholePoints",$.spacingInWholePoints));if($.lineWrapLikeWord6)this.root.push(new X0("w:lineWrapLikeWord6",$.lineWrapLikeWord6));if($.printBodyTextBeforeHeader)this.root.push(new X0("w:printBodyTextBeforeHeader",$.printBodyTextBeforeHeader));if($.printColorsBlack)this.root.push(new X0("w:printColBlack",$.printColorsBlack));if($.spaceWidth)this.root.push(new X0("w:wpSpaceWidth",$.spaceWidth));if($.showBreaksInFrames)this.root.push(new X0("w:showBreaksInFrames",$.showBreaksInFrames));if($.subFontBySize)this.root.push(new X0("w:subFontBySize",$.subFontBySize));if($.suppressBottomSpacing)this.root.push(new X0("w:suppressBottomSpacing",$.suppressBottomSpacing));if($.suppressTopSpacing)this.root.push(new X0("w:suppressTopSpacing",$.suppressTopSpacing));if($.suppressSpacingAtTopOfPage)this.root.push(new X0("w:suppressSpacingAtTopOfPage",$.suppressSpacingAtTopOfPage));if($.suppressTopSpacingWP)this.root.push(new X0("w:suppressTopSpacingWP",$.suppressTopSpacingWP));if($.suppressSpBfAfterPgBrk)this.root.push(new X0("w:suppressSpBfAfterPgBrk",$.suppressSpBfAfterPgBrk));if($.swapBordersFacingPages)this.root.push(new X0("w:swapBordersFacingPages",$.swapBordersFacingPages));if($.convertMailMergeEsc)this.root.push(new X0("w:convMailMergeEsc",$.convertMailMergeEsc));if($.truncateFontHeightsLikeWP6)this.root.push(new X0("w:truncateFontHeightsLikeWP6",$.truncateFontHeightsLikeWP6));if($.macWordSmallCaps)this.root.push(new X0("w:mwSmallCaps",$.macWordSmallCaps));if($.usePrinterMetrics)this.root.push(new X0("w:usePrinterMetrics",$.usePrinterMetrics));if($.doNotSuppressParagraphBorders)this.root.push(new X0("w:doNotSuppressParagraphBorders",$.doNotSuppressParagraphBorders));if($.wrapTrailSpaces)this.root.push(new X0("w:wrapTrailSpaces",$.wrapTrailSpaces));if($.footnoteLayoutLikeWW8)this.root.push(new X0("w:footnoteLayoutLikeWW8",$.footnoteLayoutLikeWW8));if($.shapeLayoutLikeWW8)this.root.push(new X0("w:shapeLayoutLikeWW8",$.shapeLayoutLikeWW8));if($.alignTablesRowByRow)this.root.push(new X0("w:alignTablesRowByRow",$.alignTablesRowByRow));if($.forgetLastTabAlignment)this.root.push(new X0("w:forgetLastTabAlignment",$.forgetLastTabAlignment));if($.adjustLineHeightInTable)this.root.push(new X0("w:adjustLineHeightInTable",$.adjustLineHeightInTable));if($.autoSpaceLikeWord95)this.root.push(new X0("w:autoSpaceLikeWord95",$.autoSpaceLikeWord95));if($.noSpaceRaiseLower)this.root.push(new X0("w:noSpaceRaiseLower",$.noSpaceRaiseLower));if($.doNotUseHTMLParagraphAutoSpacing)this.root.push(new X0("w:doNotUseHTMLParagraphAutoSpacing",$.doNotUseHTMLParagraphAutoSpacing));if($.layoutRawTableWidth)this.root.push(new X0("w:layoutRawTableWidth",$.layoutRawTableWidth));if($.layoutTableRowsApart)this.root.push(new X0("w:layoutTableRowsApart",$.layoutTableRowsApart));if($.useWord97LineBreakRules)this.root.push(new X0("w:useWord97LineBreakRules",$.useWord97LineBreakRules));if($.doNotBreakWrappedTables)this.root.push(new X0("w:doNotBreakWrappedTables",$.doNotBreakWrappedTables));if($.doNotSnapToGridInCell)this.root.push(new X0("w:doNotSnapToGridInCell",$.doNotSnapToGridInCell));if($.selectFieldWithFirstOrLastCharacter)this.root.push(new X0("w:selectFldWithFirstOrLastChar",$.selectFieldWithFirstOrLastCharacter));if($.applyBreakingRules)this.root.push(new X0("w:applyBreakingRules",$.applyBreakingRules));if($.doNotWrapTextWithPunctuation)this.root.push(new X0("w:doNotWrapTextWithPunct",$.doNotWrapTextWithPunctuation));if($.doNotUseEastAsianBreakRules)this.root.push(new X0("w:doNotUseEastAsianBreakRules",$.doNotUseEastAsianBreakRules));if($.useWord2002TableStyleRules)this.root.push(new X0("w:useWord2002TableStyleRules",$.useWord2002TableStyleRules));if($.growAutofit)this.root.push(new X0("w:growAutofit",$.growAutofit));if($.useFELayout)this.root.push(new X0("w:useFELayout",$.useFELayout));if($.useNormalStyleForList)this.root.push(new X0("w:useNormalStyleForList",$.useNormalStyleForList));if($.doNotUseIndentAsNumberingTabStop)this.root.push(new X0("w:doNotUseIndentAsNumberingTabStop",$.doNotUseIndentAsNumberingTabStop));if($.useAlternateEastAsianLineBreakRules)this.root.push(new X0("w:useAltKinsokuLineBreakRules",$.useAlternateEastAsianLineBreakRules));if($.allowSpaceOfSameStyleInTable)this.root.push(new X0("w:allowSpaceOfSameStyleInTable",$.allowSpaceOfSameStyleInTable));if($.doNotSuppressIndentation)this.root.push(new X0("w:doNotSuppressIndentation",$.doNotSuppressIndentation));if($.doNotAutofitConstrainedTables)this.root.push(new X0("w:doNotAutofitConstrainedTables",$.doNotAutofitConstrainedTables));if($.autofitToFirstFixedWidthCell)this.root.push(new X0("w:autofitToFirstFixedWidthCell",$.autofitToFirstFixedWidthCell));if($.underlineTabInNumberingList)this.root.push(new X0("w:underlineTabInNumList",$.underlineTabInNumberingList));if($.displayHangulFixedWidth)this.root.push(new X0("w:displayHangulFixedWidth",$.displayHangulFixedWidth));if($.splitPgBreakAndParaMark)this.root.push(new X0("w:splitPgBreakAndParaMark",$.splitPgBreakAndParaMark));if($.doNotVerticallyAlignCellWithSp)this.root.push(new X0("w:doNotVertAlignCellWithSp",$.doNotVerticallyAlignCellWithSp));if($.doNotBreakConstrainedForcedTable)this.root.push(new X0("w:doNotBreakConstrainedForcedTable",$.doNotBreakConstrainedForcedTable));if($.ignoreVerticalAlignmentInTextboxes)this.root.push(new X0("w:doNotVertAlignInTxbx",$.ignoreVerticalAlignmentInTextboxes));if($.useAnsiKerningPairs)this.root.push(new X0("w:useAnsiKerningPairs",$.useAnsiKerningPairs));if($.cachedColumnBalance)this.root.push(new X0("w:cachedColBalance",$.cachedColumnBalance))}}class k5 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{wpc:"xmlns:wpc",mc:"xmlns:mc",o:"xmlns:o",r:"xmlns:r",m:"xmlns:m",v:"xmlns:v",wp14:"xmlns:wp14",wp:"xmlns:wp",w10:"xmlns:w10",w:"xmlns:w",w14:"xmlns:w14",w15:"xmlns:w15",wpg:"xmlns:wpg",wpi:"xmlns:wpi",wne:"xmlns:wne",wps:"xmlns:wps",Ignorable:"mc:Ignorable"})}}class E5 extends o{constructor($){var U,Y,Z,J,G,X,Q,B;super("w:settings");if(this.root.push(new k5({wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wpi:"http://schemas.microsoft.com/office/word/2010/wordprocessingInk",wne:"http://schemas.microsoft.com/office/word/2006/wordml",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape",Ignorable:"w14 w15 wp14"})),this.root.push(new X0("w:displayBackgroundShape",!0)),$.trackRevisions!==void 0)this.root.push(new X0("w:trackRevisions",$.trackRevisions));if($.evenAndOddHeaders!==void 0)this.root.push(new X0("w:evenAndOddHeaders",$.evenAndOddHeaders));if($.updateFields!==void 0)this.root.push(new X0("w:updateFields",$.updateFields));if($.defaultTabStop!==void 0)this.root.push(new k2("w:defaultTabStop",$.defaultTabStop));if(((U=$.hyphenation)==null?void 0:U.autoHyphenation)!==void 0)this.root.push(new X0("w:autoHyphenation",$.hyphenation.autoHyphenation));if(((Y=$.hyphenation)==null?void 0:Y.hyphenationZone)!==void 0)this.root.push(new k2("w:hyphenationZone",$.hyphenation.hyphenationZone));if(((Z=$.hyphenation)==null?void 0:Z.consecutiveHyphenLimit)!==void 0)this.root.push(new k2("w:consecutiveHyphenLimit",$.hyphenation.consecutiveHyphenLimit));if(((J=$.hyphenation)==null?void 0:J.doNotHyphenateCaps)!==void 0)this.root.push(new X0("w:doNotHyphenateCaps",$.hyphenation.doNotHyphenateCaps));this.root.push(new O5(R0(W0({},(G=$.compatibility)!=null?G:{}),{version:(B=(Q=(X=$.compatibility)==null?void 0:X.version)!=null?Q:$.compatibilityModeVersion)!=null?B:15})))}}class GU extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{val:"w:val"})}}class S5 extends o{constructor($){super("w:name");this.root.push(new GU({val:$}))}}class v5 extends o{constructor($){super("w:uiPriority");this.root.push(new GU({val:S0($)}))}}class _5 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{type:"w:type",styleId:"w:styleId",default:"w:default",customStyle:"w:customStyle"})}}class KU extends o{constructor($,U){super("w:style");if(this.root.push(new _5($)),U.name)this.root.push(new S5(U.name));if(U.basedOn)this.root.push(new Y2("w:basedOn",U.basedOn));if(U.next)this.root.push(new Y2("w:next",U.next));if(U.link)this.root.push(new Y2("w:link",U.link));if(U.uiPriority!==void 0)this.root.push(new v5(U.uiPriority));if(U.semiHidden!==void 0)this.root.push(new X0("w:semiHidden",U.semiHidden));if(U.unhideWhenUsed!==void 0)this.root.push(new X0("w:unhideWhenUsed",U.unhideWhenUsed));if(U.quickFormat!==void 0)this.root.push(new X0("w:qFormat",U.quickFormat))}}class y2 extends KU{constructor($){super({type:"paragraph",styleId:$.id},$);Y0(this,"paragraphProperties"),Y0(this,"runProperties"),this.paragraphProperties=new Z2($.paragraph),this.runProperties=new J2($.run),this.root.push(this.paragraphProperties),this.root.push(this.runProperties)}}class D2 extends KU{constructor($){super({type:"character",styleId:$.id},W0({uiPriority:99,unhideWhenUsed:!0},$));Y0(this,"runProperties"),this.runProperties=new J2($.run),this.root.push(this.runProperties)}}class H2 extends y2{constructor($){super(W0({basedOn:"Normal",next:"Normal",quickFormat:!0},$))}}class y5 extends H2{constructor($){super(W0({id:"Title",name:"Title"},$))}}class b5 extends H2{constructor($){super(W0({id:"Heading1",name:"Heading 1"},$))}}class g5 extends H2{constructor($){super(W0({id:"Heading2",name:"Heading 2"},$))}}class x5 extends H2{constructor($){super(W0({id:"Heading3",name:"Heading 3"},$))}}class f5 extends H2{constructor($){super(W0({id:"Heading4",name:"Heading 4"},$))}}class h5 extends H2{constructor($){super(W0({id:"Heading5",name:"Heading 5"},$))}}class u5 extends H2{constructor($){super(W0({id:"Heading6",name:"Heading 6"},$))}}class d5 extends H2{constructor($){super(W0({id:"Strong",name:"Strong"},$))}}class c5 extends y2{constructor($){super(W0({id:"ListParagraph",name:"List Paragraph",basedOn:"Normal",quickFormat:!0},$))}}class m5 extends y2{constructor($){super(W0({id:"FootnoteText",name:"footnote text",link:"FootnoteTextChar",basedOn:"Normal",uiPriority:99,semiHidden:!0,unhideWhenUsed:!0,paragraph:{spacing:{after:0,line:240,lineRule:v2.AUTO}},run:{size:20}},$))}}class l5 extends D2{constructor($){super(W0({id:"FootnoteReference",name:"footnote reference",basedOn:"DefaultParagraphFont",semiHidden:!0,run:{superScript:!0}},$))}}class a5 extends D2{constructor($){super(W0({id:"FootnoteTextChar",name:"Footnote Text Char",basedOn:"DefaultParagraphFont",link:"FootnoteText",semiHidden:!0,run:{size:20}},$))}}class p5 extends y2{constructor($){super(W0({id:"EndnoteText",name:"endnote text",link:"EndnoteTextChar",basedOn:"Normal",uiPriority:99,semiHidden:!0,unhideWhenUsed:!0,paragraph:{spacing:{after:0,line:240,lineRule:v2.AUTO}},run:{size:20}},$))}}class i5 extends D2{constructor($){super(W0({id:"EndnoteReference",name:"endnote reference",basedOn:"DefaultParagraphFont",semiHidden:!0,run:{superScript:!0}},$))}}class r5 extends D2{constructor($){super(W0({id:"EndnoteTextChar",name:"Endnote Text Char",basedOn:"DefaultParagraphFont",link:"EndnoteText",semiHidden:!0,run:{size:20}},$))}}class s5 extends D2{constructor($){super(W0({id:"Hyperlink",name:"Hyperlink",basedOn:"DefaultParagraphFont",run:{color:"0563C1",underline:{type:Z$.SINGLE}}},$))}}class B1 extends o{constructor($){super("w:styles");if($.initialStyles)this.root.push($.initialStyles);if($.importedStyles)for(let U of $.importedStyles)this.root.push(U);if($.paragraphStyles)for(let U of $.paragraphStyles)this.root.push(new y2(U));if($.characterStyles)for(let U of $.characterStyles)this.root.push(new D2(U))}}class qU extends o{constructor($){super("w:pPrDefault");this.root.push(new Z2($))}}class XU extends o{constructor($){super("w:rPrDefault");this.root.push(new J2($))}}class VU extends o{constructor($){super("w:docDefaults");Y0(this,"runPropertiesDefaults"),Y0(this,"paragraphPropertiesDefaults"),this.runPropertiesDefaults=new XU($.run),this.paragraphPropertiesDefaults=new qU($.paragraph),this.root.push(this.runPropertiesDefaults),this.root.push(this.paragraphPropertiesDefaults)}}class n5{newInstance($){let U=$8.xml2js($,{compact:!1}),Y;for(let J of U.elements||[])if(J.name==="w:styles")Y=J;if(Y===void 0)throw Error("can not find styles element");let Z=Y.elements||[];return{initialStyles:new i9(Y.attributes),importedStyles:Z.map((J)=>U8(J))}}}class c1{newInstance($={}){var U;return{initialStyles:new o2(["mc","r","w","w14","w15"],"w14 w15"),importedStyles:[new VU((U=$.document)!=null?U:{}),new y5(W0({run:{size:56}},$.title)),new b5(W0({run:{color:"2E74B5",size:32}},$.heading1)),new g5(W0({run:{color:"2E74B5",size:26}},$.heading2)),new x5(W0({run:{color:"1F4D78",size:24}},$.heading3)),new f5(W0({run:{color:"2E74B5",italics:!0}},$.heading4)),new h5(W0({run:{color:"2E74B5"}},$.heading5)),new u5(W0({run:{color:"1F4D78"}},$.heading6)),new d5(W0({run:{bold:!0}},$.strong)),new c5($.listParagraph||{}),new s5($.hyperlink||{}),new l5($.footnoteReference||{}),new m5($.footnoteText||{}),new a5($.footnoteTextChar||{}),new i5($.endnoteReference||{}),new p5($.endnoteText||{}),new r5($.endnoteTextChar||{})]}}}class o5{constructor($){Y0(this,"currentRelationshipId",1),Y0(this,"documentWrapper"),Y0(this,"headers",[]),Y0(this,"footers",[]),Y0(this,"coreProperties"),Y0(this,"numbering"),Y0(this,"media"),Y0(this,"fileRelationships"),Y0(this,"footnotesWrapper"),Y0(this,"endnotesWrapper"),Y0(this,"settings"),Y0(this,"contentTypes"),Y0(this,"customProperties"),Y0(this,"appProperties"),Y0(this,"styles"),Y0(this,"comments"),Y0(this,"fontWrapper");var U,Y,Z,J,G,X,Q,B,F,z,W,k,D;if(this.coreProperties=new gK(R0(W0({},$),{creator:(U=$.creator)!=null?U:"Un-named",revision:(Y=$.revision)!=null?Y:1,lastModifiedBy:(Z=$.lastModifiedBy)!=null?Z:"Un-named"})),this.numbering=new JU($.numbering?$.numbering:{config:[]}),this.comments=new M$((J=$.comments)!=null?J:{children:[]}),this.fileRelationships=new W2,this.customProperties=new cK((G=$.customProperties)!=null?G:[]),this.appProperties=new _K,this.footnotesWrapper=new L5,this.endnotesWrapper=new G5,this.contentTypes=new bK,this.documentWrapper=new $5({background:$.background}),this.settings=new E5({compatibilityModeVersion:$.compatabilityModeVersion,compatibility:$.compatibility,evenAndOddHeaders:$.evenAndOddHeaderAndFooters?!0:!1,trackRevisions:(X=$.features)==null?void 0:X.trackRevisions,updateFields:(Q=$.features)==null?void 0:Q.updateFields,defaultTabStop:$.defaultTabStop,hyphenation:{autoHyphenation:(B=$.hyphenation)==null?void 0:B.autoHyphenation,hyphenationZone:(F=$.hyphenation)==null?void 0:F.hyphenationZone,consecutiveHyphenLimit:(z=$.hyphenation)==null?void 0:z.consecutiveHyphenLimit,doNotHyphenateCaps:(W=$.hyphenation)==null?void 0:W.doNotHyphenateCaps}}),this.media=new w8,$.externalStyles!==void 0){let H=new c1().newInstance((k=$.styles)==null?void 0:k.default),V=new n5().newInstance($.externalStyles);this.styles=new B1(R0(W0({},V),{importedStyles:[...H.importedStyles,...V.importedStyles]}))}else if($.styles){let H=new c1().newInstance($.styles.default);this.styles=new B1(W0(W0({},H),$.styles))}else{let C=new c1;this.styles=new B1(C.newInstance())}this.addDefaultRelationships();for(let C of $.sections)this.addSection(C);if($.footnotes)for(let C in $.footnotes)this.footnotesWrapper.View.createFootNote(parseFloat(C),$.footnotes[C].children);if($.endnotes)for(let C in $.endnotes)this.endnotesWrapper.View.createEndnote(parseFloat(C),$.endnotes[C].children);this.fontWrapper=new R$((D=$.fonts)!=null?D:[])}addSection({headers:$={},footers:U={},children:Y,properties:Z}){this.documentWrapper.View.Body.addSection(R0(W0({},Z),{headerWrapperGroup:{default:$.default?this.createHeader($.default):void 0,first:$.first?this.createHeader($.first):void 0,even:$.even?this.createHeader($.even):void 0},footerWrapperGroup:{default:U.default?this.createFooter(U.default):void 0,first:U.first?this.createFooter(U.first):void 0,even:U.even?this.createFooter(U.even):void 0}}));for(let J of Y)this.documentWrapper.View.add(J)}createHeader($){let U=new YU(this.media,this.currentRelationshipId++);for(let Y of $.options.children)U.add(Y);return this.addHeaderToDocument(U),U}createFooter($){let U=new $U(this.media,this.currentRelationshipId++);for(let Y of $.options.children)U.add(Y);return this.addFooterToDocument(U),U}addHeaderToDocument($,U=E2.DEFAULT){this.headers.push({header:$,type:U}),this.documentWrapper.Relationships.addRelationship($.View.ReferenceId,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",`header${this.headers.length}.xml`),this.contentTypes.addHeader(this.headers.length)}addFooterToDocument($,U=E2.DEFAULT){this.footers.push({footer:$,type:U}),this.documentWrapper.Relationships.addRelationship($.View.ReferenceId,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",`footer${this.footers.length}.xml`),this.contentTypes.addFooter(this.footers.length)}addDefaultRelationships(){this.fileRelationships.addRelationship(1,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument","word/document.xml"),this.fileRelationships.addRelationship(2,"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties","docProps/core.xml"),this.fileRelationships.addRelationship(3,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties","docProps/app.xml"),this.fileRelationships.addRelationship(4,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties","docProps/custom.xml"),this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles","styles.xml"),this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering","numbering.xml"),this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes","footnotes.xml"),this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes","endnotes.xml"),this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings","settings.xml"),this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments","comments.xml")}get Document(){return this.documentWrapper}get Styles(){return this.styles}get CoreProperties(){return this.coreProperties}get Numbering(){return this.numbering}get Media(){return this.media}get FileRelationships(){return this.fileRelationships}get Headers(){return this.headers.map(($)=>$.header)}get Footers(){return this.footers.map(($)=>$.footer)}get ContentTypes(){return this.contentTypes}get CustomProperties(){return this.customProperties}get AppProperties(){return this.appProperties}get FootNotes(){return this.footnotesWrapper}get Endnotes(){return this.endnotesWrapper}get Settings(){return this.settings}get Comments(){return this.comments}get FontTable(){return this.fontWrapper}}class t5 extends o{constructor($={}){super("w:instrText");Y0(this,"properties"),this.properties=$,this.root.push(new x0({space:g0.PRESERVE}));let U="TOC";if(this.properties.captionLabel)U=`${U} \\a "${this.properties.captionLabel}"`;if(this.properties.entriesFromBookmark)U=`${U} \\b "${this.properties.entriesFromBookmark}"`;if(this.properties.captionLabelIncludingNumbers)U=`${U} \\c "${this.properties.captionLabelIncludingNumbers}"`;if(this.properties.sequenceAndPageNumbersSeparator)U=`${U} \\d "${this.properties.sequenceAndPageNumbersSeparator}"`;if(this.properties.tcFieldIdentifier)U=`${U} \\f "${this.properties.tcFieldIdentifier}"`;if(this.properties.hyperlink)U=`${U} \\h`;if(this.properties.tcFieldLevelRange)U=`${U} \\l "${this.properties.tcFieldLevelRange}"`;if(this.properties.pageNumbersEntryLevelsRange)U=`${U} \\n "${this.properties.pageNumbersEntryLevelsRange}"`;if(this.properties.headingStyleRange)U=`${U} \\o "${this.properties.headingStyleRange}"`;if(this.properties.entryAndPageNumberSeparator)U=`${U} \\p "${this.properties.entryAndPageNumberSeparator}"`;if(this.properties.seqFieldIdentifierForPrefix)U=`${U} \\s "${this.properties.seqFieldIdentifierForPrefix}"`;if(this.properties.stylesWithLevels&&this.properties.stylesWithLevels.length){let Y=this.properties.stylesWithLevels.map((Z)=>`${Z.styleName},${Z.level}`).join(",");U=`${U} \\t "${Y}"`}if(this.properties.useAppliedParagraphOutlineLevel)U=`${U} \\u`;if(this.properties.preserveTabInEntries)U=`${U} \\w`;if(this.properties.preserveNewLineInEntries)U=`${U} \\x`;if(this.properties.hideTabAndPageNumbersInWebView)U=`${U} \\z`;this.root.push(U)}}class BU extends o{constructor(){super("w:sdtContent")}}class LU extends o{constructor($){super("w:sdtPr");if($)this.root.push(new Y2("w:alias",$))}}class e5 extends r2{constructor($="Table of Contents",U={}){var Y=U,{contentChildren:Z=[],cachedEntries:J=[],beginDirty:G=!0}=Y,X=oZ(Y,["contentChildren","cachedEntries","beginDirty"]);super("w:sdt");this.root.push(new LU($));let Q=new BU,B=[new C0({children:[$2(G),new t5(X),I2()]})],F=[new C0({children:[U2()]})];if(J!==void 0&&J.length>0){let{stylesWithLevels:W}=X,k=J.map((C,H)=>{var O,V;let j=this.buildCachedContentParagraphChild(C,X),M=(V=(O=W==null?void 0:W.find((A)=>A.level===C.level))==null?void 0:O.styleName)!=null?V:`TOC${C.level}`,L=H===0?[...B,j]:H===J.length-1?[j,...F]:[j];return new h0({style:M,tabStops:this.getTabStopsForLevel(C.level),children:L})}),D=k;if(J.length<=1)D=[...k,new h0({children:F})];for(let C of D)Q.addChildElement(C)}else{let W=new h0({children:B});Q.addChildElement(W);for(let D of Z)Q.addChildElement(D);let k=new h0({children:F});Q.addChildElement(k)}this.root.push(Q)}getTabStopsForLevel($,U=9025){return[{type:"clear",position:U+1-($-1)*240},{type:"right",position:U,leader:"dot"}]}buildCachedContentRun($,U){var Y,Z;return new C0({style:(U==null?void 0:U.hyperlink)&&$.href!==void 0?"IndexLink":void 0,children:[new a2({text:$.title}),new w$,new a2({text:(Z=(Y=$.page)==null?void 0:Y.toString())!=null?Z:""})]})}buildCachedContentParagraphChild($,U){let Y=this.buildCachedContentRun($,U);if((U==null?void 0:U.hyperlink)&&$.href!==void 0)return new j$({anchor:$.href,children:[Y]});return Y}}class $7{constructor($,U){Y0(this,"styleName"),Y0(this,"level"),this.styleName=$,this.level=U}}class U7{constructor($={children:[]}){Y0(this,"options"),this.options=$}}class Y7{constructor($={children:[]}){Y0(this,"options"),this.options=$}}class MU extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{id:"w:id"})}}class IU extends o{constructor($){super("w:footnoteReference");this.root.push(new MU({id:$}))}}class Z7 extends C0{constructor($){super({style:"FootnoteReference"});this.root.push(new IU($))}}class wU extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{id:"w:id"})}}class WU extends o{constructor($){super("w:endnoteReference");this.root.push(new wU({id:$}))}}class Q7 extends C0{constructor($){super({style:"EndnoteReference"});this.root.push(new WU($))}}class _9 extends I0{constructor(){super(...arguments);Y0(this,"xmlKeys",{val:"w14:val",symbolfont:"w14:font"})}}class L1 extends o{constructor($,U,Y){super($);if(Y)this.root.push(new _9({val:DQ(U),symbolfont:Y}));else this.root.push(new _9({val:U}))}}class HU extends o{constructor($){var U,Y,Z,J,G,X,Q,B;super("w14:checkbox");Y0(this,"DEFAULT_UNCHECKED_SYMBOL","2610"),Y0(this,"DEFAULT_CHECKED_SYMBOL","2612"),Y0(this,"DEFAULT_FONT","MS Gothic");let F=($==null?void 0:$.checked)?"1":"0",z,W;this.root.push(new L1("w14:checked",F)),z=((U=$==null?void 0:$.checkedState)==null?void 0:U.value)?(Y=$==null?void 0:$.checkedState)==null?void 0:Y.value:this.DEFAULT_CHECKED_SYMBOL,W=((Z=$==null?void 0:$.checkedState)==null?void 0:Z.font)?(J=$==null?void 0:$.checkedState)==null?void 0:J.font:this.DEFAULT_FONT,this.root.push(new L1("w14:checkedState",z,W)),z=((G=$==null?void 0:$.uncheckedState)==null?void 0:G.value)?(X=$==null?void 0:$.uncheckedState)==null?void 0:X.value:this.DEFAULT_UNCHECKED_SYMBOL,W=((Q=$==null?void 0:$.uncheckedState)==null?void 0:Q.font)?(B=$==null?void 0:$.uncheckedState)==null?void 0:B.font:this.DEFAULT_FONT,this.root.push(new L1("w14:uncheckedState",z,W))}}class J7 extends o{constructor($){var U,Y,Z,J;super("w:sdt");Y0(this,"DEFAULT_UNCHECKED_SYMBOL","2610"),Y0(this,"DEFAULT_CHECKED_SYMBOL","2612"),Y0(this,"DEFAULT_FONT","MS Gothic");let G=new LU($==null?void 0:$.alias);G.addChildElement(new HU($)),this.root.push(G);let X=new BU,Q=(U=$==null?void 0:$.checkedState)==null?void 0:U.font,B=(Y=$==null?void 0:$.checkedState)==null?void 0:Y.value,F=(Z=$==null?void 0:$.uncheckedState)==null?void 0:Z.font,z=(J=$==null?void 0:$.uncheckedState)==null?void 0:J.value,W,k;if($==null?void 0:$.checked)W=Q?Q:this.DEFAULT_FONT,k=B?B:this.DEFAULT_CHECKED_SYMBOL;else W=F?F:this.DEFAULT_FONT,k=z?z:this.DEFAULT_UNCHECKED_SYMBOL;let D=new G$({char:k,symbolfont:W});X.addChildElement(D),this.root.push(X)}}var iV=({shape:$})=>new B0({name:"w:pict",children:[$]}),rV=({children:$=[]})=>new B0({name:"w:txbxContent",children:$}),sV=({style:$,children:U,inset:Y})=>new B0({name:"v:textbox",attributes:{style:{key:"style",value:$},insetMode:{key:"insetmode",value:Y?"custom":"auto"},inset:{key:"inset",value:Y?`${Y.left}, ${Y.top}, ${Y.right}, ${Y.bottom}`:void 0}},children:[rV({children:U})]}),nV="#_x0000_t202",oV={flip:"flip",height:"height",left:"left",marginBottom:"margin-bottom",marginLeft:"margin-left",marginRight:"margin-right",marginTop:"margin-top",positionHorizontal:"mso-position-horizontal",positionHorizontalRelative:"mso-position-horizontal-relative",positionVertical:"mso-position-vertical",positionVerticalRelative:"mso-position-vertical-relative",wrapDistanceBottom:"mso-wrap-distance-bottom",wrapDistanceLeft:"mso-wrap-distance-left",wrapDistanceRight:"mso-wrap-distance-right",wrapDistanceTop:"mso-wrap-distance-top",wrapEdited:"mso-wrap-edited",wrapStyle:"mso-wrap-style",position:"position",rotation:"rotation",top:"top",visibility:"visibility",width:"width",zIndex:"z-index"},tV=($)=>$?Object.entries($).map(([U,Y])=>`${oV[U]}:${Y}`).join(";"):void 0,eV=({id:$,children:U,type:Y=nV,style:Z})=>new B0({name:"v:shape",attributes:{id:{key:"id",value:$},type:{key:"type",value:Y},style:{key:"style",value:tV(Z)}},children:[sV({style:"mso-fit-shape-to-text:t;",children:U})]});class G7 extends r2{constructor($){var U=$,{style:Y,children:Z}=U,J=oZ(U,["style","children"]);super("w:p");this.root.push(new Z2(J)),this.root.push(iV({shape:eV({children:Z,id:R1(),style:Y})}))}}var $B=m9();function y1($){throw Error('Could not dynamically require "'+$+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var I9={exports:{}},uZ;function UB(){if(uZ)return I9.exports;return uZ=1,function($,U){(function(Y){$.exports=Y()})(function(){return function Y(Z,J,G){function X(F,z){if(!J[F]){if(!Z[F]){var W=typeof y1=="function"&&y1;if(!z&&W)return W(F,!0);if(Q)return Q(F,!0);var k=Error("Cannot find module '"+F+"'");throw k.code="MODULE_NOT_FOUND",k}var D=J[F]={exports:{}};Z[F][0].call(D.exports,function(C){var H=Z[F][1][C];return X(H||C)},D,D.exports,Y,Z,J,G)}return J[F].exports}for(var Q=typeof y1=="function"&&y1,B=0;B>2,D=(3&F)<<4|z>>4,C=1>6:64,H=2>4,z=(15&k)<<4|(D=Q.indexOf(B.charAt(H++)))>>2,W=(3&D)<<6|(C=Q.indexOf(B.charAt(H++))),j[O++]=F,D!==64&&(j[O++]=z),C!==64&&(j[O++]=W);return j}},{"./support":30,"./utils":32}],2:[function(Y,Z,J){var G=Y("./external"),X=Y("./stream/DataWorker"),Q=Y("./stream/Crc32Probe"),B=Y("./stream/DataLengthProbe");function F(z,W,k,D,C){this.compressedSize=z,this.uncompressedSize=W,this.crc32=k,this.compression=D,this.compressedContent=C}F.prototype={getContentWorker:function(){var z=new X(G.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new B("data_length")),W=this;return z.on("end",function(){if(this.streamInfo.data_length!==W.uncompressedSize)throw Error("Bug : uncompressed data size mismatch")}),z},getCompressedWorker:function(){return new X(G.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},F.createWorkerFrom=function(z,W,k){return z.pipe(new Q).pipe(new B("uncompressedSize")).pipe(W.compressWorker(k)).pipe(new B("compressedSize")).withStreamInfo("compression",W)},Z.exports=F},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(Y,Z,J){var G=Y("./stream/GenericWorker");J.STORE={magic:"\x00\x00",compressWorker:function(){return new G("STORE compression")},uncompressWorker:function(){return new G("STORE decompression")}},J.DEFLATE=Y("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(Y,Z,J){var G=Y("./utils"),X=function(){for(var Q,B=[],F=0;F<256;F++){Q=F;for(var z=0;z<8;z++)Q=1&Q?3988292384^Q>>>1:Q>>>1;B[F]=Q}return B}();Z.exports=function(Q,B){return Q!==void 0&&Q.length?G.getTypeOf(Q)!=="string"?function(F,z,W,k){var D=X,C=k+W;F^=-1;for(var H=k;H>>8^D[255&(F^z[H])];return-1^F}(0|B,Q,Q.length,0):function(F,z,W,k){var D=X,C=k+W;F^=-1;for(var H=k;H>>8^D[255&(F^z.charCodeAt(H))];return-1^F}(0|B,Q,Q.length,0):0}},{"./utils":32}],5:[function(Y,Z,J){J.base64=!1,J.binary=!1,J.dir=!1,J.createFolders=!0,J.date=null,J.compression=null,J.compressionOptions=null,J.comment=null,J.unixPermissions=null,J.dosPermissions=null},{}],6:[function(Y,Z,J){var G=null;G=typeof Promise<"u"?Promise:Y("lie"),Z.exports={Promise:G}},{lie:37}],7:[function(Y,Z,J){var G=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",X=Y("pako"),Q=Y("./utils"),B=Y("./stream/GenericWorker"),F=G?"uint8array":"array";function z(W,k){B.call(this,"FlateWorker/"+W),this._pako=null,this._pakoAction=W,this._pakoOptions=k,this.meta={}}J.magic="\b\x00",Q.inherits(z,B),z.prototype.processChunk=function(W){this.meta=W.meta,this._pako===null&&this._createPako(),this._pako.push(Q.transformTo(F,W.data),!1)},z.prototype.flush=function(){B.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},z.prototype.cleanUp=function(){B.prototype.cleanUp.call(this),this._pako=null},z.prototype._createPako=function(){this._pako=new X[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var W=this;this._pako.onData=function(k){W.push({data:k,meta:W.meta})}},J.compressWorker=function(W){return new z("Deflate",W)},J.uncompressWorker=function(){return new z("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(Y,Z,J){function G(D,C){var H,O="";for(H=0;H>>=8;return O}function X(D,C,H,O,V,j){var M,L,A=D.file,y=D.compression,g=j!==F.utf8encode,d=Q.transformTo("string",j(A.name)),E=Q.transformTo("string",F.utf8encode(A.name)),s=A.comment,V0=Q.transformTo("string",j(s)),S=Q.transformTo("string",F.utf8encode(s)),h=E.length!==A.name.length,N=S.length!==s.length,a="",$0="",m="",J0=A.dir,U0=A.date,L0={crc32:0,compressedSize:0,uncompressedSize:0};C&&!H||(L0.crc32=D.crc32,L0.compressedSize=D.compressedSize,L0.uncompressedSize=D.uncompressedSize);var i=0;C&&(i|=8),g||!h&&!N||(i|=2048);var _=0,r=0;J0&&(_|=16),V==="UNIX"?(r=798,_|=function(Z0,p){var P=Z0;return Z0||(P=p?16893:33204),(65535&P)<<16}(A.unixPermissions,J0)):(r=20,_|=function(Z0){return 63&(Z0||0)}(A.dosPermissions)),M=U0.getUTCHours(),M<<=6,M|=U0.getUTCMinutes(),M<<=5,M|=U0.getUTCSeconds()/2,L=U0.getUTCFullYear()-1980,L<<=4,L|=U0.getUTCMonth()+1,L<<=5,L|=U0.getUTCDate(),h&&($0=G(1,1)+G(z(d),4)+E,a+="up"+G($0.length,2)+$0),N&&(m=G(1,1)+G(z(V0),4)+S,a+="uc"+G(m.length,2)+m);var n="";return n+=` -\x00`,n+=G(i,2),n+=y.magic,n+=G(M,2),n+=G(L,2),n+=G(L0.crc32,4),n+=G(L0.compressedSize,4),n+=G(L0.uncompressedSize,4),n+=G(d.length,2),n+=G(a.length,2),{fileRecord:W.LOCAL_FILE_HEADER+n+d+a,dirRecord:W.CENTRAL_FILE_HEADER+G(r,2)+n+G(V0.length,2)+"\x00\x00\x00\x00"+G(_,4)+G(O,4)+d+a+V0}}var Q=Y("../utils"),B=Y("../stream/GenericWorker"),F=Y("../utf8"),z=Y("../crc32"),W=Y("../signature");function k(D,C,H,O){B.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=C,this.zipPlatform=H,this.encodeFileName=O,this.streamFiles=D,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}Q.inherits(k,B),k.prototype.push=function(D){var C=D.meta.percent||0,H=this.entriesCount,O=this._sources.length;this.accumulate?this.contentBuffer.push(D):(this.bytesWritten+=D.data.length,B.prototype.push.call(this,{data:D.data,meta:{currentFile:this.currentFile,percent:H?(C+100*(H-O-1))/H:100}}))},k.prototype.openedSource=function(D){this.currentSourceOffset=this.bytesWritten,this.currentFile=D.file.name;var C=this.streamFiles&&!D.file.dir;if(C){var H=X(D,C,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:H.fileRecord,meta:{percent:0}})}else this.accumulate=!0},k.prototype.closedSource=function(D){this.accumulate=!1;var C=this.streamFiles&&!D.file.dir,H=X(D,C,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(H.dirRecord),C)this.push({data:function(O){return W.DATA_DESCRIPTOR+G(O.crc32,4)+G(O.compressedSize,4)+G(O.uncompressedSize,4)}(D),meta:{percent:100}});else for(this.push({data:H.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},k.prototype.flush=function(){for(var D=this.bytesWritten,C=0;C=this.index;B--)F=(F<<8)+this.byteAt(B);return this.index+=Q,F},readString:function(Q){return G.transformTo("string",this.readData(Q))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var Q=this.readInt(4);return new Date(Date.UTC(1980+(Q>>25&127),(Q>>21&15)-1,Q>>16&31,Q>>11&31,Q>>5&63,(31&Q)<<1))}},Z.exports=X},{"../utils":32}],19:[function(Y,Z,J){var G=Y("./Uint8ArrayReader");function X(Q){G.call(this,Q)}Y("../utils").inherits(X,G),X.prototype.readData=function(Q){this.checkOffset(Q);var B=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,B},Z.exports=X},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(Y,Z,J){var G=Y("./DataReader");function X(Q){G.call(this,Q)}Y("../utils").inherits(X,G),X.prototype.byteAt=function(Q){return this.data.charCodeAt(this.zero+Q)},X.prototype.lastIndexOfSignature=function(Q){return this.data.lastIndexOf(Q)-this.zero},X.prototype.readAndCheckSignature=function(Q){return Q===this.readData(4)},X.prototype.readData=function(Q){this.checkOffset(Q);var B=this.data.slice(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,B},Z.exports=X},{"../utils":32,"./DataReader":18}],21:[function(Y,Z,J){var G=Y("./ArrayReader");function X(Q){G.call(this,Q)}Y("../utils").inherits(X,G),X.prototype.readData=function(Q){if(this.checkOffset(Q),Q===0)return new Uint8Array(0);var B=this.data.subarray(this.zero+this.index,this.zero+this.index+Q);return this.index+=Q,B},Z.exports=X},{"../utils":32,"./ArrayReader":17}],22:[function(Y,Z,J){var G=Y("../utils"),X=Y("../support"),Q=Y("./ArrayReader"),B=Y("./StringReader"),F=Y("./NodeBufferReader"),z=Y("./Uint8ArrayReader");Z.exports=function(W){var k=G.getTypeOf(W);return G.checkSupport(k),k!=="string"||X.uint8array?k==="nodebuffer"?new F(W):X.uint8array?new z(G.transformTo("uint8array",W)):new Q(G.transformTo("array",W)):new B(W)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(Y,Z,J){J.LOCAL_FILE_HEADER="PK\x03\x04",J.CENTRAL_FILE_HEADER="PK\x01\x02",J.CENTRAL_DIRECTORY_END="PK\x05\x06",J.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x06\x07",J.ZIP64_CENTRAL_DIRECTORY_END="PK\x06\x06",J.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(Y,Z,J){var G=Y("./GenericWorker"),X=Y("../utils");function Q(B){G.call(this,"ConvertWorker to "+B),this.destType=B}X.inherits(Q,G),Q.prototype.processChunk=function(B){this.push({data:X.transformTo(this.destType,B.data),meta:B.meta})},Z.exports=Q},{"../utils":32,"./GenericWorker":28}],25:[function(Y,Z,J){var G=Y("./GenericWorker"),X=Y("../crc32");function Q(){G.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}Y("../utils").inherits(Q,G),Q.prototype.processChunk=function(B){this.streamInfo.crc32=X(B.data,this.streamInfo.crc32||0),this.push(B)},Z.exports=Q},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(Y,Z,J){var G=Y("../utils"),X=Y("./GenericWorker");function Q(B){X.call(this,"DataLengthProbe for "+B),this.propName=B,this.withStreamInfo(B,0)}G.inherits(Q,X),Q.prototype.processChunk=function(B){if(B){var F=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=F+B.data.length}X.prototype.processChunk.call(this,B)},Z.exports=Q},{"../utils":32,"./GenericWorker":28}],27:[function(Y,Z,J){var G=Y("../utils"),X=Y("./GenericWorker");function Q(B){X.call(this,"DataWorker");var F=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,B.then(function(z){F.dataIsReady=!0,F.data=z,F.max=z&&z.length||0,F.type=G.getTypeOf(z),F.isPaused||F._tickAndRepeat()},function(z){F.error(z)})}G.inherits(Q,X),Q.prototype.cleanUp=function(){X.prototype.cleanUp.call(this),this.data=null},Q.prototype.resume=function(){return!!X.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,G.delay(this._tickAndRepeat,[],this)),!0)},Q.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(G.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},Q.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var B=null,F=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":B=this.data.substring(this.index,F);break;case"uint8array":B=this.data.subarray(this.index,F);break;case"array":case"nodebuffer":B=this.data.slice(this.index,F)}return this.index=F,this.push({data:B,meta:{percent:this.max?this.index/this.max*100:0}})},Z.exports=Q},{"../utils":32,"./GenericWorker":28}],28:[function(Y,Z,J){function G(X){this.name=X||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}G.prototype={push:function(X){this.emit("data",X)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(X){this.emit("error",X)}return!0},error:function(X){return!this.isFinished&&(this.isPaused?this.generatedError=X:(this.isFinished=!0,this.emit("error",X),this.previous&&this.previous.error(X),this.cleanUp()),!0)},on:function(X,Q){return this._listeners[X].push(Q),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(X,Q){if(this._listeners[X])for(var B=0;B "+X:X}},Z.exports=G},{}],29:[function(Y,Z,J){var G=Y("../utils"),X=Y("./ConvertWorker"),Q=Y("./GenericWorker"),B=Y("../base64"),F=Y("../support"),z=Y("../external"),W=null;if(F.nodestream)try{W=Y("../nodejs/NodejsStreamOutputAdapter")}catch(C){}function k(C,H){return new z.Promise(function(O,V){var j=[],M=C._internalType,L=C._outputType,A=C._mimeType;C.on("data",function(y,g){j.push(y),H&&H(g)}).on("error",function(y){j=[],V(y)}).on("end",function(){try{var y=function(g,d,E){switch(g){case"blob":return G.newBlob(G.transformTo("arraybuffer",d),E);case"base64":return B.encode(d);default:return G.transformTo(g,d)}}(L,function(g,d){var E,s=0,V0=null,S=0;for(E=0;E"u")J.blob=!1;else{var G=new ArrayBuffer(0);try{J.blob=new Blob([G],{type:"application/zip"}).size===0}catch(Q){try{var X=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);X.append(G),J.blob=X.getBlob("application/zip").size===0}catch(B){J.blob=!1}}}try{J.nodestream=!!Y("readable-stream").Readable}catch(Q){J.nodestream=!1}},{"readable-stream":16}],31:[function(Y,Z,J){for(var G=Y("./utils"),X=Y("./support"),Q=Y("./nodejsUtils"),B=Y("./stream/GenericWorker"),F=Array(256),z=0;z<256;z++)F[z]=252<=z?6:248<=z?5:240<=z?4:224<=z?3:192<=z?2:1;F[254]=F[254]=1;function W(){B.call(this,"utf-8 decode"),this.leftOver=null}function k(){B.call(this,"utf-8 encode")}J.utf8encode=function(D){return X.nodebuffer?Q.newBufferFrom(D,"utf-8"):function(C){var H,O,V,j,M,L=C.length,A=0;for(j=0;j>>6:(O<65536?H[M++]=224|O>>>12:(H[M++]=240|O>>>18,H[M++]=128|O>>>12&63),H[M++]=128|O>>>6&63),H[M++]=128|63&O);return H}(D)},J.utf8decode=function(D){return X.nodebuffer?G.transformTo("nodebuffer",D).toString("utf-8"):function(C){var H,O,V,j,M=C.length,L=Array(2*M);for(H=O=0;H>10&1023,L[O++]=56320|1023&V)}return L.length!==O&&(L.subarray?L=L.subarray(0,O):L.length=O),G.applyFromCharCode(L)}(D=G.transformTo(X.uint8array?"uint8array":"array",D))},G.inherits(W,B),W.prototype.processChunk=function(D){var C=G.transformTo(X.uint8array?"uint8array":"array",D.data);if(this.leftOver&&this.leftOver.length){if(X.uint8array){var H=C;(C=new Uint8Array(H.length+this.leftOver.length)).set(this.leftOver,0),C.set(H,this.leftOver.length)}else C=this.leftOver.concat(C);this.leftOver=null}var O=function(j,M){var L;for((M=M||j.length)>j.length&&(M=j.length),L=M-1;0<=L&&(192&j[L])==128;)L--;return L<0?M:L===0?M:L+F[j[L]]>M?L:M}(C),V=C;O!==C.length&&(X.uint8array?(V=C.subarray(0,O),this.leftOver=C.subarray(O,C.length)):(V=C.slice(0,O),this.leftOver=C.slice(O,C.length))),this.push({data:J.utf8decode(V),meta:D.meta})},W.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:J.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},J.Utf8DecodeWorker=W,G.inherits(k,B),k.prototype.processChunk=function(D){this.push({data:J.utf8encode(D.data),meta:D.meta})},J.Utf8EncodeWorker=k},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(Y,Z,J){var G=Y("./support"),X=Y("./base64"),Q=Y("./nodejsUtils"),B=Y("./external");function F(H){return H}function z(H,O){for(var V=0;V>8;this.dir=!!(16&this.externalFileAttributes),D==0&&(this.dosPermissions=63&this.externalFileAttributes),D==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var D=G(this.extraFields[1].value);this.uncompressedSize===X.MAX_VALUE_32BITS&&(this.uncompressedSize=D.readInt(8)),this.compressedSize===X.MAX_VALUE_32BITS&&(this.compressedSize=D.readInt(8)),this.localHeaderOffset===X.MAX_VALUE_32BITS&&(this.localHeaderOffset=D.readInt(8)),this.diskNumberStart===X.MAX_VALUE_32BITS&&(this.diskNumberStart=D.readInt(4))}},readExtraFields:function(D){var C,H,O,V=D.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});D.index+4>>6:(D<65536?k[O++]=224|D>>>12:(k[O++]=240|D>>>18,k[O++]=128|D>>>12&63),k[O++]=128|D>>>6&63),k[O++]=128|63&D);return k},J.buf2binstring=function(W){return z(W,W.length)},J.binstring2buf=function(W){for(var k=new G.Buf8(W.length),D=0,C=k.length;D>10&1023,j[C++]=56320|1023&H)}return z(j,C)},J.utf8border=function(W,k){var D;for((k=k||W.length)>W.length&&(k=W.length),D=k-1;0<=D&&(192&W[D])==128;)D--;return D<0?k:D===0?k:D+B[W[D]]>k?D:k}},{"./common":41}],43:[function(Y,Z,J){Z.exports=function(G,X,Q,B){for(var F=65535&G|0,z=G>>>16&65535|0,W=0;Q!==0;){for(Q-=W=2000>>1:X>>>1;Q[B]=X}return Q}();Z.exports=function(X,Q,B,F){var z=G,W=F+B;X^=-1;for(var k=F;k>>8^z[255&(X^Q[k])];return-1^X}},{}],46:[function(Y,Z,J){var G,X=Y("../utils/common"),Q=Y("./trees"),B=Y("./adler32"),F=Y("./crc32"),z=Y("./messages"),W=0,k=4,D=0,C=-2,H=-1,O=4,V=2,j=8,M=9,L=286,A=30,y=19,g=2*L+1,d=15,E=3,s=258,V0=s+E+1,S=42,h=113,N=1,a=2,$0=3,m=4;function J0(I,t){return I.msg=z[t],t}function U0(I){return(I<<1)-(4I.avail_out&&(T=I.avail_out),T!==0&&(X.arraySet(I.output,t.pending_buf,t.pending_out,T,I.next_out),I.next_out+=T,t.pending_out+=T,I.total_out+=T,I.avail_out-=T,t.pending-=T,t.pending===0&&(t.pending_out=0))}function _(I,t){Q._tr_flush_block(I,0<=I.block_start?I.block_start:-1,I.strstart-I.block_start,t),I.block_start=I.strstart,i(I.strm)}function r(I,t){I.pending_buf[I.pending++]=t}function n(I,t){I.pending_buf[I.pending++]=t>>>8&255,I.pending_buf[I.pending++]=255&t}function Z0(I,t){var T,K,q=I.max_chain_length,w=I.strstart,x=I.prev_length,l=I.nice_match,u=I.strstart>I.w_size-V0?I.strstart-(I.w_size-V0):0,Q0=I.window,q0=I.w_mask,K0=I.prev,M0=I.strstart+s,w0=Q0[w+x-1],H0=Q0[w+x];I.prev_length>=I.good_match&&(q>>=2),l>I.lookahead&&(l=I.lookahead);do if(Q0[(T=t)+x]===H0&&Q0[T+x-1]===w0&&Q0[T]===Q0[w]&&Q0[++T]===Q0[w+1]){w+=2,T++;do;while(Q0[++w]===Q0[++T]&&Q0[++w]===Q0[++T]&&Q0[++w]===Q0[++T]&&Q0[++w]===Q0[++T]&&Q0[++w]===Q0[++T]&&Q0[++w]===Q0[++T]&&Q0[++w]===Q0[++T]&&Q0[++w]===Q0[++T]&&wu&&--q!=0);return x<=I.lookahead?x:I.lookahead}function p(I){var t,T,K,q,w,x,l,u,Q0,q0,K0=I.w_size;do{if(q=I.window_size-I.lookahead-I.strstart,I.strstart>=K0+(K0-V0)){for(X.arraySet(I.window,I.window,K0,K0,0),I.match_start-=K0,I.strstart-=K0,I.block_start-=K0,t=T=I.hash_size;K=I.head[--t],I.head[t]=K0<=K?K-K0:0,--T;);for(t=T=K0;K=I.prev[--t],I.prev[t]=K0<=K?K-K0:0,--T;);q+=K0}if(I.strm.avail_in===0)break;if(x=I.strm,l=I.window,u=I.strstart+I.lookahead,Q0=q,q0=void 0,q0=x.avail_in,Q0=E)for(w=I.strstart-I.insert,I.ins_h=I.window[w],I.ins_h=(I.ins_h<=E&&(I.ins_h=(I.ins_h<=E)if(K=Q._tr_tally(I,I.strstart-I.match_start,I.match_length-E),I.lookahead-=I.match_length,I.match_length<=I.max_lazy_match&&I.lookahead>=E){for(I.match_length--;I.strstart++,I.ins_h=(I.ins_h<=E&&(I.ins_h=(I.ins_h<=E&&I.match_length<=I.prev_length){for(q=I.strstart+I.lookahead-E,K=Q._tr_tally(I,I.strstart-1-I.prev_match,I.prev_length-E),I.lookahead-=I.prev_length-1,I.prev_length-=2;++I.strstart<=q&&(I.ins_h=(I.ins_h<I.pending_buf_size-5&&(T=I.pending_buf_size-5);;){if(I.lookahead<=1){if(p(I),I.lookahead===0&&t===W)return N;if(I.lookahead===0)break}I.strstart+=I.lookahead,I.lookahead=0;var K=I.block_start+T;if((I.strstart===0||I.strstart>=K)&&(I.lookahead=I.strstart-K,I.strstart=K,_(I,!1),I.strm.avail_out===0))return N;if(I.strstart-I.block_start>=I.w_size-V0&&(_(I,!1),I.strm.avail_out===0))return N}return I.insert=0,t===k?(_(I,!0),I.strm.avail_out===0?$0:m):(I.strstart>I.block_start&&(_(I,!1),I.strm.avail_out),N)}),new c(4,4,8,4,P),new c(4,5,16,8,P),new c(4,6,32,32,P),new c(4,4,16,16,R),new c(8,16,32,32,R),new c(8,16,128,128,R),new c(8,32,128,256,R),new c(32,128,258,1024,R),new c(32,258,258,4096,R)],J.deflateInit=function(I,t){return e(I,t,j,15,8,0)},J.deflateInit2=e,J.deflateReset=b,J.deflateResetKeep=v,J.deflateSetHeader=function(I,t){return I&&I.state?I.state.wrap!==2?C:(I.state.gzhead=t,D):C},J.deflate=function(I,t){var T,K,q,w;if(!I||!I.state||5>8&255),r(K,K.gzhead.time>>16&255),r(K,K.gzhead.time>>24&255),r(K,K.level===9?2:2<=K.strategy||K.level<2?4:0),r(K,255&K.gzhead.os),K.gzhead.extra&&K.gzhead.extra.length&&(r(K,255&K.gzhead.extra.length),r(K,K.gzhead.extra.length>>8&255)),K.gzhead.hcrc&&(I.adler=F(I.adler,K.pending_buf,K.pending,0)),K.gzindex=0,K.status=69):(r(K,0),r(K,0),r(K,0),r(K,0),r(K,0),r(K,K.level===9?2:2<=K.strategy||K.level<2?4:0),r(K,3),K.status=h);else{var x=j+(K.w_bits-8<<4)<<8;x|=(2<=K.strategy||K.level<2?0:K.level<6?1:K.level===6?2:3)<<6,K.strstart!==0&&(x|=32),x+=31-x%31,K.status=h,n(K,x),K.strstart!==0&&(n(K,I.adler>>>16),n(K,65535&I.adler)),I.adler=1}if(K.status===69)if(K.gzhead.extra){for(q=K.pending;K.gzindex<(65535&K.gzhead.extra.length)&&(K.pending!==K.pending_buf_size||(K.gzhead.hcrc&&K.pending>q&&(I.adler=F(I.adler,K.pending_buf,K.pending-q,q)),i(I),q=K.pending,K.pending!==K.pending_buf_size));)r(K,255&K.gzhead.extra[K.gzindex]),K.gzindex++;K.gzhead.hcrc&&K.pending>q&&(I.adler=F(I.adler,K.pending_buf,K.pending-q,q)),K.gzindex===K.gzhead.extra.length&&(K.gzindex=0,K.status=73)}else K.status=73;if(K.status===73)if(K.gzhead.name){q=K.pending;do{if(K.pending===K.pending_buf_size&&(K.gzhead.hcrc&&K.pending>q&&(I.adler=F(I.adler,K.pending_buf,K.pending-q,q)),i(I),q=K.pending,K.pending===K.pending_buf_size)){w=1;break}w=K.gzindexq&&(I.adler=F(I.adler,K.pending_buf,K.pending-q,q)),w===0&&(K.gzindex=0,K.status=91)}else K.status=91;if(K.status===91)if(K.gzhead.comment){q=K.pending;do{if(K.pending===K.pending_buf_size&&(K.gzhead.hcrc&&K.pending>q&&(I.adler=F(I.adler,K.pending_buf,K.pending-q,q)),i(I),q=K.pending,K.pending===K.pending_buf_size)){w=1;break}w=K.gzindexq&&(I.adler=F(I.adler,K.pending_buf,K.pending-q,q)),w===0&&(K.status=103)}else K.status=103;if(K.status===103&&(K.gzhead.hcrc?(K.pending+2>K.pending_buf_size&&i(I),K.pending+2<=K.pending_buf_size&&(r(K,255&I.adler),r(K,I.adler>>8&255),I.adler=0,K.status=h)):K.status=h),K.pending!==0){if(i(I),I.avail_out===0)return K.last_flush=-1,D}else if(I.avail_in===0&&U0(t)<=U0(T)&&t!==k)return J0(I,-5);if(K.status===666&&I.avail_in!==0)return J0(I,-5);if(I.avail_in!==0||K.lookahead!==0||t!==W&&K.status!==666){var l=K.strategy===2?function(u,Q0){for(var q0;;){if(u.lookahead===0&&(p(u),u.lookahead===0)){if(Q0===W)return N;break}if(u.match_length=0,q0=Q._tr_tally(u,0,u.window[u.strstart]),u.lookahead--,u.strstart++,q0&&(_(u,!1),u.strm.avail_out===0))return N}return u.insert=0,Q0===k?(_(u,!0),u.strm.avail_out===0?$0:m):u.last_lit&&(_(u,!1),u.strm.avail_out===0)?N:a}(K,t):K.strategy===3?function(u,Q0){for(var q0,K0,M0,w0,H0=u.window;;){if(u.lookahead<=s){if(p(u),u.lookahead<=s&&Q0===W)return N;if(u.lookahead===0)break}if(u.match_length=0,u.lookahead>=E&&0u.lookahead&&(u.match_length=u.lookahead)}if(u.match_length>=E?(q0=Q._tr_tally(u,1,u.match_length-E),u.lookahead-=u.match_length,u.strstart+=u.match_length,u.match_length=0):(q0=Q._tr_tally(u,0,u.window[u.strstart]),u.lookahead--,u.strstart++),q0&&(_(u,!1),u.strm.avail_out===0))return N}return u.insert=0,Q0===k?(_(u,!0),u.strm.avail_out===0?$0:m):u.last_lit&&(_(u,!1),u.strm.avail_out===0)?N:a}(K,t):G[K.level].func(K,t);if(l!==$0&&l!==m||(K.status=666),l===N||l===$0)return I.avail_out===0&&(K.last_flush=-1),D;if(l===a&&(t===1?Q._tr_align(K):t!==5&&(Q._tr_stored_block(K,0,0,!1),t===3&&(L0(K.head),K.lookahead===0&&(K.strstart=0,K.block_start=0,K.insert=0))),i(I),I.avail_out===0))return K.last_flush=-1,D}return t!==k?D:K.wrap<=0?1:(K.wrap===2?(r(K,255&I.adler),r(K,I.adler>>8&255),r(K,I.adler>>16&255),r(K,I.adler>>24&255),r(K,255&I.total_in),r(K,I.total_in>>8&255),r(K,I.total_in>>16&255),r(K,I.total_in>>24&255)):(n(K,I.adler>>>16),n(K,65535&I.adler)),i(I),0=T.w_size&&(w===0&&(L0(T.head),T.strstart=0,T.block_start=0,T.insert=0),Q0=new X.Buf8(T.w_size),X.arraySet(Q0,t,q0-T.w_size,T.w_size,0),t=Q0,q0=T.w_size),x=I.avail_in,l=I.next_in,u=I.input,I.avail_in=q0,I.next_in=0,I.input=t,p(T);T.lookahead>=E;){for(K=T.strstart,q=T.lookahead-(E-1);T.ins_h=(T.ins_h<>>=E=d>>>24,M-=E,(E=d>>>16&255)===0)a[z++]=65535&d;else{if(!(16&E)){if((64&E)==0){d=L[(65535&d)+(j&(1<>>=E,M-=E),M<15&&(j+=N[B++]<>>=E=d>>>24,M-=E,!(16&(E=d>>>16&255))){if((64&E)==0){d=A[(65535&d)+(j&(1<>>=E,M-=E,(E=z-W)>3,j&=(1<<(M-=s<<3))-1,G.next_in=B,G.next_out=z,G.avail_in=B>>24&255)+(S>>>8&65280)+((65280&S)<<8)+((255&S)<<24)}function j(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new G.Buf16(320),this.work=new G.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function M(S){var h;return S&&S.state?(h=S.state,S.total_in=S.total_out=h.total=0,S.msg="",h.wrap&&(S.adler=1&h.wrap),h.mode=C,h.last=0,h.havedict=0,h.dmax=32768,h.head=null,h.hold=0,h.bits=0,h.lencode=h.lendyn=new G.Buf32(H),h.distcode=h.distdyn=new G.Buf32(O),h.sane=1,h.back=-1,k):D}function L(S){var h;return S&&S.state?((h=S.state).wsize=0,h.whave=0,h.wnext=0,M(S)):D}function A(S,h){var N,a;return S&&S.state?(a=S.state,h<0?(N=0,h=-h):(N=1+(h>>4),h<48&&(h&=15)),h&&(h<8||15=m.wsize?(G.arraySet(m.window,h,N-m.wsize,m.wsize,0),m.wnext=0,m.whave=m.wsize):(a<($0=m.wsize-m.wnext)&&($0=a),G.arraySet(m.window,h,N-a,$0,m.wnext),(a-=$0)?(G.arraySet(m.window,h,N-a,a,0),m.wnext=a,m.whave=m.wsize):(m.wnext+=$0,m.wnext===m.wsize&&(m.wnext=0),m.whave>>8&255,N.check=Q(N.check,w,2,0),_=i=0,N.mode=2;break}if(N.flags=0,N.head&&(N.head.done=!1),!(1&N.wrap)||(((255&i)<<8)+(i>>8))%31){S.msg="incorrect header check",N.mode=30;break}if((15&i)!=8){S.msg="unknown compression method",N.mode=30;break}if(_-=4,I=8+(15&(i>>>=4)),N.wbits===0)N.wbits=I;else if(I>N.wbits){S.msg="invalid window size",N.mode=30;break}N.dmax=1<>8&1),512&N.flags&&(w[0]=255&i,w[1]=i>>>8&255,N.check=Q(N.check,w,2,0)),_=i=0,N.mode=3;case 3:for(;_<32;){if(U0===0)break $;U0--,i+=a[m++]<<_,_+=8}N.head&&(N.head.time=i),512&N.flags&&(w[0]=255&i,w[1]=i>>>8&255,w[2]=i>>>16&255,w[3]=i>>>24&255,N.check=Q(N.check,w,4,0)),_=i=0,N.mode=4;case 4:for(;_<16;){if(U0===0)break $;U0--,i+=a[m++]<<_,_+=8}N.head&&(N.head.xflags=255&i,N.head.os=i>>8),512&N.flags&&(w[0]=255&i,w[1]=i>>>8&255,N.check=Q(N.check,w,2,0)),_=i=0,N.mode=5;case 5:if(1024&N.flags){for(;_<16;){if(U0===0)break $;U0--,i+=a[m++]<<_,_+=8}N.length=i,N.head&&(N.head.extra_len=i),512&N.flags&&(w[0]=255&i,w[1]=i>>>8&255,N.check=Q(N.check,w,2,0)),_=i=0}else N.head&&(N.head.extra=null);N.mode=6;case 6:if(1024&N.flags&&(U0<(Z0=N.length)&&(Z0=U0),Z0&&(N.head&&(I=N.head.extra_len-N.length,N.head.extra||(N.head.extra=Array(N.head.extra_len)),G.arraySet(N.head.extra,a,m,Z0,I)),512&N.flags&&(N.check=Q(N.check,a,Z0,m)),U0-=Z0,m+=Z0,N.length-=Z0),N.length))break $;N.length=0,N.mode=7;case 7:if(2048&N.flags){if(U0===0)break $;for(Z0=0;I=a[m+Z0++],N.head&&I&&N.length<65536&&(N.head.name+=String.fromCharCode(I)),I&&Z0>9&1,N.head.done=!0),S.adler=N.check=0,N.mode=12;break;case 10:for(;_<32;){if(U0===0)break $;U0--,i+=a[m++]<<_,_+=8}S.adler=N.check=V(i),_=i=0,N.mode=11;case 11:if(N.havedict===0)return S.next_out=J0,S.avail_out=L0,S.next_in=m,S.avail_in=U0,N.hold=i,N.bits=_,2;S.adler=N.check=1,N.mode=12;case 12:if(h===5||h===6)break $;case 13:if(N.last){i>>>=7&_,_-=7&_,N.mode=27;break}for(;_<3;){if(U0===0)break $;U0--,i+=a[m++]<<_,_+=8}switch(N.last=1&i,_-=1,3&(i>>>=1)){case 0:N.mode=14;break;case 1:if(s(N),N.mode=20,h!==6)break;i>>>=2,_-=2;break $;case 2:N.mode=17;break;case 3:S.msg="invalid block type",N.mode=30}i>>>=2,_-=2;break;case 14:for(i>>>=7&_,_-=7&_;_<32;){if(U0===0)break $;U0--,i+=a[m++]<<_,_+=8}if((65535&i)!=(i>>>16^65535)){S.msg="invalid stored block lengths",N.mode=30;break}if(N.length=65535&i,_=i=0,N.mode=15,h===6)break $;case 15:N.mode=16;case 16:if(Z0=N.length){if(U0>>=5,_-=5,N.ndist=1+(31&i),i>>>=5,_-=5,N.ncode=4+(15&i),i>>>=4,_-=4,286>>=3,_-=3}for(;N.have<19;)N.lens[x[N.have++]]=0;if(N.lencode=N.lendyn,N.lenbits=7,T={bits:N.lenbits},t=F(0,N.lens,0,19,N.lencode,0,N.work,T),N.lenbits=T.bits,t){S.msg="invalid code lengths set",N.mode=30;break}N.have=0,N.mode=19;case 19:for(;N.have>>16&255,f=65535&q,!((R=q>>>24)<=_);){if(U0===0)break $;U0--,i+=a[m++]<<_,_+=8}if(f<16)i>>>=R,_-=R,N.lens[N.have++]=f;else{if(f===16){for(K=R+2;_>>=R,_-=R,N.have===0){S.msg="invalid bit length repeat",N.mode=30;break}I=N.lens[N.have-1],Z0=3+(3&i),i>>>=2,_-=2}else if(f===17){for(K=R+3;_>>=R)),i>>>=3,_-=3}else{for(K=R+7;_>>=R)),i>>>=7,_-=7}if(N.have+Z0>N.nlen+N.ndist){S.msg="invalid bit length repeat",N.mode=30;break}for(;Z0--;)N.lens[N.have++]=I}}if(N.mode===30)break;if(N.lens[256]===0){S.msg="invalid code -- missing end-of-block",N.mode=30;break}if(N.lenbits=9,T={bits:N.lenbits},t=F(z,N.lens,0,N.nlen,N.lencode,0,N.work,T),N.lenbits=T.bits,t){S.msg="invalid literal/lengths set",N.mode=30;break}if(N.distbits=6,N.distcode=N.distdyn,T={bits:N.distbits},t=F(W,N.lens,N.nlen,N.ndist,N.distcode,0,N.work,T),N.distbits=T.bits,t){S.msg="invalid distances set",N.mode=30;break}if(N.mode=20,h===6)break $;case 20:N.mode=21;case 21:if(6<=U0&&258<=L0){S.next_out=J0,S.avail_out=L0,S.next_in=m,S.avail_in=U0,N.hold=i,N.bits=_,B(S,n),J0=S.next_out,$0=S.output,L0=S.avail_out,m=S.next_in,a=S.input,U0=S.avail_in,i=N.hold,_=N.bits,N.mode===12&&(N.back=-1);break}for(N.back=0;c=(q=N.lencode[i&(1<>>16&255,f=65535&q,!((R=q>>>24)<=_);){if(U0===0)break $;U0--,i+=a[m++]<<_,_+=8}if(c&&(240&c)==0){for(v=R,b=c,e=f;c=(q=N.lencode[e+((i&(1<>v)])>>>16&255,f=65535&q,!(v+(R=q>>>24)<=_);){if(U0===0)break $;U0--,i+=a[m++]<<_,_+=8}i>>>=v,_-=v,N.back+=v}if(i>>>=R,_-=R,N.back+=R,N.length=f,c===0){N.mode=26;break}if(32&c){N.back=-1,N.mode=12;break}if(64&c){S.msg="invalid literal/length code",N.mode=30;break}N.extra=15&c,N.mode=22;case 22:if(N.extra){for(K=N.extra;_>>=N.extra,_-=N.extra,N.back+=N.extra}N.was=N.length,N.mode=23;case 23:for(;c=(q=N.distcode[i&(1<>>16&255,f=65535&q,!((R=q>>>24)<=_);){if(U0===0)break $;U0--,i+=a[m++]<<_,_+=8}if((240&c)==0){for(v=R,b=c,e=f;c=(q=N.distcode[e+((i&(1<>v)])>>>16&255,f=65535&q,!(v+(R=q>>>24)<=_);){if(U0===0)break $;U0--,i+=a[m++]<<_,_+=8}i>>>=v,_-=v,N.back+=v}if(i>>>=R,_-=R,N.back+=R,64&c){S.msg="invalid distance code",N.mode=30;break}N.offset=f,N.extra=15&c,N.mode=24;case 24:if(N.extra){for(K=N.extra;_>>=N.extra,_-=N.extra,N.back+=N.extra}if(N.offset>N.dmax){S.msg="invalid distance too far back",N.mode=30;break}N.mode=25;case 25:if(L0===0)break $;if(Z0=n-L0,N.offset>Z0){if((Z0=N.offset-Z0)>N.whave&&N.sane){S.msg="invalid distance too far back",N.mode=30;break}p=Z0>N.wnext?(Z0-=N.wnext,N.wsize-Z0):N.wnext-Z0,Z0>N.length&&(Z0=N.length),P=N.window}else P=$0,p=J0-N.offset,Z0=N.length;for(L0g?(E=p[P+O[h]],_[r+O[h]]):(E=96,0),j=1<>J0)+(M-=j)]=d<<24|E<<16|s|0,M!==0;);for(j=1<>=1;if(j!==0?(i&=j-1,i+=j):i=0,h++,--n[S]==0){if(S===a)break;S=W[k+O[h]]}if($0>>7)]}function r(q,w){q.pending_buf[q.pending++]=255&w,q.pending_buf[q.pending++]=w>>>8&255}function n(q,w,x){q.bi_valid>V-x?(q.bi_buf|=w<>V-q.bi_valid,q.bi_valid+=x-V):(q.bi_buf|=w<>>=1,x<<=1,0<--w;);return x>>>1}function P(q,w,x){var l,u,Q0=Array(O+1),q0=0;for(l=1;l<=O;l++)Q0[l]=q0=q0+x[l-1]<<1;for(u=0;u<=w;u++){var K0=q[2*u+1];K0!==0&&(q[2*u]=p(Q0[K0]++,K0))}}function R(q){var w;for(w=0;w>1;1<=x;x--)v(q,Q0,x);for(u=M0;x=q.heap[1],q.heap[1]=q.heap[q.heap_len--],v(q,Q0,1),l=q.heap[1],q.heap[--q.heap_max]=x,q.heap[--q.heap_max]=l,Q0[2*u]=Q0[2*x]+Q0[2*l],q.depth[u]=(q.depth[x]>=q.depth[l]?q.depth[x]:q.depth[l])+1,Q0[2*x+1]=Q0[2*l+1]=u,q.heap[1]=u++,v(q,Q0,1),2<=q.heap_len;);q.heap[--q.heap_max]=q.heap[1],function(H0,v0){var j2,l0,t2,D0,A1,z8,K2=v0.dyn_tree,NU=v0.max_code,H7=v0.stat_desc.static_tree,j7=v0.stat_desc.has_stree,z7=v0.stat_desc.extra_bits,RU=v0.stat_desc.extra_base,e2=v0.stat_desc.max_length,P1=0;for(D0=0;D0<=O;D0++)H0.bl_count[D0]=0;for(K2[2*H0.heap[H0.heap_max]+1]=0,j2=H0.heap_max+1;j2>=7;u>>=1)if(1&w0&&K0.dyn_ltree[2*M0]!==0)return X;if(K0.dyn_ltree[18]!==0||K0.dyn_ltree[20]!==0||K0.dyn_ltree[26]!==0)return Q;for(M0=32;M0>>3,(Q0=q.static_len+3+7>>>3)<=u&&(u=Q0)):u=Q0=x+5,x+4<=u&&w!==-1?K(q,w,x,l):q.strategy===4||Q0===u?(n(q,2+(l?1:0),3),b(q,V0,S)):(n(q,4+(l?1:0),3),function(K0,M0,w0,H0){var v0;for(n(K0,M0-257,5),n(K0,w0-1,5),n(K0,H0-4,4),v0=0;v0>>8&255,q.pending_buf[q.d_buf+2*q.last_lit+1]=255&w,q.pending_buf[q.l_buf+q.last_lit]=255&x,q.last_lit++,w===0?q.dyn_ltree[2*x]++:(q.matches++,w--,q.dyn_ltree[2*(N[x]+W+1)]++,q.dyn_dtree[2*_(w)]++),q.last_lit===q.lit_bufsize-1},J._tr_align=function(q){n(q,2,3),Z0(q,M,V0),function(w){w.bi_valid===16?(r(w,w.bi_buf),w.bi_buf=0,w.bi_valid=0):8<=w.bi_valid&&(w.pending_buf[w.pending++]=255&w.bi_buf,w.bi_buf>>=8,w.bi_valid-=8)}(q)}},{"../utils/common":41}],53:[function(Y,Z,J){Z.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(Y,Z,J){(function(G){(function(X,Q){if(!X.setImmediate){var B,F,z,W,k=1,D={},C=!1,H=X.document,O=Object.getPrototypeOf&&Object.getPrototypeOf(X);O=O&&O.setTimeout?O:X,B={}.toString.call(X.process)==="[object process]"?function(L){j0.nextTick(function(){j(L)})}:function(){if(X.postMessage&&!X.importScripts){var L=!0,A=X.onmessage;return X.onmessage=function(){L=!1},X.postMessage("","*"),X.onmessage=A,L}}()?(W="setImmediate$"+Math.random()+"$",X.addEventListener?X.addEventListener("message",M,!1):X.attachEvent("onmessage",M),function(L){X.postMessage(W+L,"*")}):X.MessageChannel?((z=new MessageChannel).port1.onmessage=function(L){j(L.data)},function(L){z.port2.postMessage(L)}):H&&("onreadystatechange"in H.createElement("script"))?(F=H.documentElement,function(L){var A=H.createElement("script");A.onreadystatechange=function(){j(L),A.onreadystatechange=null,F.removeChild(A),A=null},F.appendChild(A)}):function(L){setTimeout(j,0,L)},O.setImmediate=function(L){typeof L!="function"&&(L=Function(""+L));for(var A=Array(arguments.length-1),y=0;y"u"?G===void 0?this:G:self)}).call(this,typeof c0<"u"?c0:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})}(I9),I9.exports}var YB=UB(),c2=g9(YB),Z1={exports:{}},w9,dZ;function ZB(){if(dZ)return w9;dZ=1;var $={"&":"&",'"':""","'":"'","<":"<",">":">"};function U(Y){return Y&&Y.replace?Y.replace(/([&"<>'])/g,function(Z,J){return $[J]}):Y}return w9=U,w9}var cZ;function QB(){if(cZ)return Z1.exports;cZ=1;var $=ZB(),U=m9().Stream,Y=" ";function Z(F,z){if(typeof z!=="object")z={indent:z};var W=z.stream?new U:null,k="",D=!1,C=!z.indent?"":z.indent===!0?Y:z.indent,H=!0;function O(A){if(!H)A();else j0.nextTick(A)}function V(A,y){if(y!==void 0)k+=y;if(A&&!D)W=W||new U,D=!0;if(A&&D){var g=k;O(function(){W.emit("data",g)}),k=""}}function j(A,y){Q(V,X(A,C,C?1:0),y)}function M(){if(W){var A=k;O(function(){W.emit("data",A),W.emit("end"),W.readable=!1,W.emit("close")})}}function L(A){var y=A.encoding||"UTF-8",g={version:"1.0",encoding:y};if(A.standalone)g.standalone=A.standalone;j({"?xml":{_attr:g}}),k=k.replace("/>","?>")}if(O(function(){H=!1}),z.declaration)L(z.declaration);if(F&&F.forEach)F.forEach(function(A,y){var g;if(y+1===F.length)g=M;j(A,g)});else j(F,M);if(W)return W.readable=!0,W;return k}function J(){var F=Array.prototype.slice.call(arguments),z={_elem:X(F)};return z.push=function(W){if(!this.append)throw Error("not assigned to a parent!");var k=this,D=this._elem.indent;Q(this.append,X(W,D,this._elem.icount+(D?1:0)),function(){k.append(!0)})},z.close=function(W){if(W!==void 0)this.push(W);if(this.end)this.end()},z}function G(F,z){return Array(z||0).join(F||"")}function X(F,z,W){W=W||0;var k=G(z,W),D,C=F,H=!1;if(typeof F==="object"){var O=Object.keys(F);if(D=O[0],C=F[D],C&&C._elem)return C._elem.name=D,C._elem.icount=W,C._elem.indent=z,C._elem.indents=k,C._elem.interrupt=C,C._elem}var V=[],j=[],M;function L(A){var y=Object.keys(A);y.forEach(function(g){V.push(B(g,A[g]))})}switch(typeof C){case"object":if(C===null)break;if(C._attr)L(C._attr);if(C._cdata)j.push(("/g,"]]]]>")+"]]>");if(C.forEach){if(M=!1,j.push(""),C.forEach(function(A){if(typeof A=="object"){var y=Object.keys(A)[0];if(y=="_attr")L(A._attr);else j.push(X(A,z,W+1))}else j.pop(),M=!0,j.push($(A))}),!M)j.push("")}break;default:j.push($(C))}return{name:D,interrupt:H,attributes:V,content:j,icount:W,indents:k,indent:z}}function Q(F,z,W){if(typeof z!="object")return F(!1,z);var k=z.interrupt?1:z.content.length;function D(){while(z.content.length){var H=z.content.shift();if(H===void 0)continue;if(C(H))return;Q(F,H)}if(F(!1,(k>1?z.indents:"")+(z.name?"":"")+(z.indent&&!W?` -`:"")),W)W()}function C(H){if(H.interrupt)return H.interrupt.append=F,H.interrupt.end=D,H.interrupt=!1,F(!0),!0;return!1}if(F(!1,z.indents+(z.name?"<"+z.name:"")+(z.attributes.length?" "+z.attributes.join(" "):"")+(k?z.name?">":"":z.name?"/>":"")+(z.indent&&k>1?` -`:"")),!k)return F(!1,z.indent?` -`:"");if(!C(z))D()}function B(F,z){return F+'="'+$(z)+'"'}return Z1.exports=Z,Z1.exports.element=Z1.exports.Element=J,Z1.exports}var JB=QB(),F0=g9(JB),Q1=0,W9=32,GB=32,KB=($,U)=>{let Y=U.replace(/-/g,"");if(Y.length!==GB)throw Error(`Error: Cannot extract GUID from font filename: ${U}`);let J=Y.replace(/(..)/g,"$1 ").trim().split(" ").map((B)=>parseInt(B,16));J.reverse();let X=$.slice(Q1,W9).map((B,F)=>B^J[F%J.length]),Q=new Uint8Array(Q1+X.length+Math.max(0,$.length-W9));return Q.set($.slice(0,Q1)),Q.set(X,Q1),Q.set($.slice(W9),Q1+X.length),Q};class H8{format($,U={stack:[]}){let Y=$.prepForXml(U);if(Y)return Y;else throw Error("XMLComponent did not format correctly")}}class jU{replace($,U,Y){let Z=$;return U.forEach((J,G)=>{Z=Z.replace(new RegExp(`{${J.fileName}}`,"g"),(Y+G).toString())}),Z}getMediaData($,U){return U.Array.filter((Y)=>$.search(`{${Y.fileName}}`)>0)}}class K7{replace($,U){let Y=$;for(let Z of U)Y=Y.replace(new RegExp(`{${Z.reference}-${Z.instance}}`,"g"),Z.numId.toString());return Y}}class q7{constructor(){Y0(this,"formatter"),Y0(this,"imageReplacer"),Y0(this,"numberingReplacer"),this.formatter=new H8,this.imageReplacer=new jU,this.numberingReplacer=new K7}compile($,U,Y=[]){let Z=new c2,J=this.xmlifyFile($,U),G=new Map(Object.entries(J));for(let[,X]of G)if(Array.isArray(X))for(let Q of X)Z.file(Q.path,X1(Q.data));else Z.file(X.path,X1(X.data));for(let X of Y)Z.file(X.path,X1(X.data));for(let X of $.Media.Array)if(X.type!=="svg")Z.file(`word/media/${X.fileName}`,X.data);else Z.file(`word/media/${X.fileName}`,X.data),Z.file(`word/media/${X.fallback.fileName}`,X.fallback.data);for(let{data:X,name:Q,fontKey:B}of $.FontTable.fontOptionsWithKey){let[F]=Q.split(".");Z.file(`word/fonts/${F}.odttf`,KB(X,B))}return Z}xmlifyFile($,U){let Y=$.Document.Relationships.RelationshipCount+1,Z=F0(this.formatter.format($.Document.View,{viewWrapper:$.Document,file:$,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),J=$.Comments.Relationships.RelationshipCount+1,G=F0(this.formatter.format($.Comments,{viewWrapper:{View:$.Comments,Relationships:$.Comments.Relationships},file:$,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),X=$.FootNotes.Relationships.RelationshipCount+1,Q=F0(this.formatter.format($.FootNotes.View,{viewWrapper:$.FootNotes,file:$,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),B=this.imageReplacer.getMediaData(Z,$.Media),F=this.imageReplacer.getMediaData(G,$.Media),z=this.imageReplacer.getMediaData(Q,$.Media);return{Relationships:{data:(()=>{return B.forEach((W,k)=>{$.Document.Relationships.addRelationship(Y+k,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`media/${W.fileName}`)}),$.Document.Relationships.addRelationship($.Document.Relationships.RelationshipCount+1,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable","fontTable.xml"),F0(this.formatter.format($.Document.Relationships,{viewWrapper:$.Document,file:$,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}})})(),path:"word/_rels/document.xml.rels"},Document:{data:(()=>{let W=this.imageReplacer.replace(Z,B,Y);return this.numberingReplacer.replace(W,$.Numbering.ConcreteNumbering)})(),path:"word/document.xml"},Styles:{data:(()=>{let W=F0(this.formatter.format($.Styles,{viewWrapper:$.Document,file:$,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}});return this.numberingReplacer.replace(W,$.Numbering.ConcreteNumbering)})(),path:"word/styles.xml"},Properties:{data:F0(this.formatter.format($.CoreProperties,{viewWrapper:$.Document,file:$,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"docProps/core.xml"},Numbering:{data:F0(this.formatter.format($.Numbering,{viewWrapper:$.Document,file:$,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"word/numbering.xml"},FileRelationships:{data:F0(this.formatter.format($.FileRelationships,{viewWrapper:$.Document,file:$,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),path:"_rels/.rels"},HeaderRelationships:$.Headers.map((W,k)=>{let D=F0(this.formatter.format(W.View,{viewWrapper:W,file:$,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}});return this.imageReplacer.getMediaData(D,$.Media).forEach((H,O)=>{W.Relationships.addRelationship(O,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`media/${H.fileName}`)}),{data:F0(this.formatter.format(W.Relationships,{viewWrapper:W,file:$,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),path:`word/_rels/header${k+1}.xml.rels`}}),FooterRelationships:$.Footers.map((W,k)=>{let D=F0(this.formatter.format(W.View,{viewWrapper:W,file:$,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}});return this.imageReplacer.getMediaData(D,$.Media).forEach((H,O)=>{W.Relationships.addRelationship(O,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`media/${H.fileName}`)}),{data:F0(this.formatter.format(W.Relationships,{viewWrapper:W,file:$,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),path:`word/_rels/footer${k+1}.xml.rels`}}),Headers:$.Headers.map((W,k)=>{let D=F0(this.formatter.format(W.View,{viewWrapper:W,file:$,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),C=this.imageReplacer.getMediaData(D,$.Media),H=this.imageReplacer.replace(D,C,0);return{data:this.numberingReplacer.replace(H,$.Numbering.ConcreteNumbering),path:`word/header${k+1}.xml`}}),Footers:$.Footers.map((W,k)=>{let D=F0(this.formatter.format(W.View,{viewWrapper:W,file:$,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),C=this.imageReplacer.getMediaData(D,$.Media),H=this.imageReplacer.replace(D,C,0);return{data:this.numberingReplacer.replace(H,$.Numbering.ConcreteNumbering),path:`word/footer${k+1}.xml`}}),ContentTypes:{data:F0(this.formatter.format($.ContentTypes,{viewWrapper:$.Document,file:$,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),path:"[Content_Types].xml"},CustomProperties:{data:F0(this.formatter.format($.CustomProperties,{viewWrapper:$.Document,file:$,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"docProps/custom.xml"},AppProperties:{data:F0(this.formatter.format($.AppProperties,{viewWrapper:$.Document,file:$,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"docProps/app.xml"},FootNotes:{data:(()=>{let W=this.imageReplacer.replace(Q,z,X);return this.numberingReplacer.replace(W,$.Numbering.ConcreteNumbering)})(),path:"word/footnotes.xml"},FootNotesRelationships:{data:(()=>{return z.forEach((W,k)=>{$.FootNotes.Relationships.addRelationship(X+k,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`media/${W.fileName}`)}),F0(this.formatter.format($.FootNotes.Relationships,{viewWrapper:$.FootNotes,file:$,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}})})(),path:"word/_rels/footnotes.xml.rels"},Endnotes:{data:F0(this.formatter.format($.Endnotes.View,{viewWrapper:$.Endnotes,file:$,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),path:"word/endnotes.xml"},EndnotesRelationships:{data:F0(this.formatter.format($.Endnotes.Relationships,{viewWrapper:$.Endnotes,file:$,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),path:"word/_rels/endnotes.xml.rels"},Settings:{data:F0(this.formatter.format($.Settings,{viewWrapper:$.Document,file:$,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"word/settings.xml"},Comments:{data:(()=>{let W=this.imageReplacer.replace(G,F,J);return this.numberingReplacer.replace(W,$.Numbering.ConcreteNumbering)})(),path:"word/comments.xml"},CommentsRelationships:{data:(()=>{return F.forEach((W,k)=>{$.Comments.Relationships.addRelationship(J+k,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`media/${W.fileName}`)}),F0(this.formatter.format($.Comments.Relationships,{viewWrapper:{View:$.Comments,Relationships:$.Comments.Relationships},file:$,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}})})(),path:"word/_rels/comments.xml.rels"},FontTable:{data:F0(this.formatter.format($.FontTable.View,{viewWrapper:$.Document,file:$,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"word/fontTable.xml"},FontTableRelationships:{data:(()=>F0(this.formatter.format($.FontTable.Relationships,{viewWrapper:$.Document,file:$,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}))(),path:"word/_rels/fontTable.xml.rels"}}}}var X7={NONE:"",WITH_2_BLANKS:" ",WITH_4_BLANKS:" ",WITH_TAB:"\t"},mZ=($)=>$===!0?X7.WITH_2_BLANKS:$===!1?void 0:$,V7=class ${static pack(U,Y,Z){return b9(this,arguments,function*(J,G,X,Q=[]){return this.compiler.compile(J,mZ(X),Q).generateAsync({type:G,mimeType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",compression:"DEFLATE"})})}static toString(U,Y,Z=[]){return $.pack(U,"string",Y,Z)}static toBuffer(U,Y,Z=[]){return $.pack(U,"nodebuffer",Y,Z)}static toBase64String(U,Y,Z=[]){return $.pack(U,"base64",Y,Z)}static toBlob(U,Y,Z=[]){return $.pack(U,"blob",Y,Z)}static toArrayBuffer(U,Y,Z=[]){return $.pack(U,"arraybuffer",Y,Z)}static toStream(U,Y,Z=[]){let J=new $B.Stream;return this.compiler.compile(U,mZ(Y),Z).generateAsync({type:"nodebuffer",mimeType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",compression:"DEFLATE"}).then((X)=>{J.emit("data",X),J.emit("end")}),J}};Y0(V7,"compiler",new q7);var qB=V7,XB=new H8,j8=($)=>{return $8.xml2js($,{compact:!1,captureSpacesBetweenElements:!0})},B7=($)=>{var U;return(U=j8(F0(XB.format(new a2({text:$})))).elements[0].elements)!=null?U:[]},L7=($)=>R0(W0({},$),{attributes:{"xml:space":"preserve"}}),zU=($,U)=>{var Y,Z;return(Z=(Y=$.elements)==null?void 0:Y.filter((J)=>J.name===U)[0].elements)!=null?Z:[]},h2=($,U,Y)=>{let Z=zU($,"Types");if(Z.some((G)=>{var X,Q;return G.type==="element"&&G.name==="Default"&&((X=G==null?void 0:G.attributes)==null?void 0:X.ContentType)===U&&((Q=G==null?void 0:G.attributes)==null?void 0:Q.Extension)===Y}))return;Z.push({attributes:{ContentType:U,Extension:Y},name:"Default",type:"element"})},VB=($)=>{let U=parseInt($.substring(3),10);return isNaN(U)?0:U},BB=($)=>{return zU($,"Relationships").map((Y)=>{var Z,J,G;return VB((G=(J=(Z=Y.attributes)==null?void 0:Z.Id)==null?void 0:J.toString())!=null?G:"")}).reduce((Y,Z)=>Math.max(Y,Z),0)+1},lZ=($,U,Y,Z,J)=>{let G=zU($,"Relationships");return G.push({attributes:{Id:`rId${U}`,Type:Y,Target:Z,TargetMode:J},name:"Relationship",type:"element"}),G};class M7 extends Error{constructor($){super(`Token ${$} not found`);this.name="TokenNotFoundError"}}var LB=($,U)=>{var Y,Z,J,G;for(let X=0;X<((Y=$.elements)!=null?Y:[]).length;X++){let Q=$.elements[X];if(Q.type==="element"&&Q.name==="w:r"){let B=((Z=Q.elements)!=null?Z:[]).filter((F)=>F.type==="element"&&F.name==="w:t");for(let F of B){if(!((J=F.elements)==null?void 0:J[0]))continue;if((G=F.elements[0].text)==null?void 0:G.includes(U))return X}}}throw new M7(U)},MB=($,U)=>{var Y,Z;let J=-1,G=(Z=(Y=$.elements)==null?void 0:Y.map((B,F)=>{var z,W,k;if(J!==-1)return B;if(B.type==="element"&&B.name==="w:t"){let C=((k=(W=(z=B.elements)==null?void 0:z[0])==null?void 0:W.text)!=null?k:"").split(U),H=C.map((O)=>R0(W0(W0({},B),L7(B)),{elements:B7(O)}));if(C.length>1)J=F;return H}else return B}).flat())!=null?Z:[],X=R0(W0({},JSON.parse(JSON.stringify($))),{elements:G.slice(0,J+1)}),Q=R0(W0({},JSON.parse(JSON.stringify($))),{elements:G.slice(J+1)});return{left:X,right:Q}},J1={START:0,MIDDLE:1,END:2},IB=({paragraphElement:$,renderedParagraph:U,originalText:Y,replacementText:Z})=>{let J=U.text.indexOf(Y),G=J+Y.length-1,X=J1.START;for(let Q of U.runs)for(let{text:B,index:F,start:z,end:W}of Q.parts)switch(X){case J1.START:if(J>=z&&J<=W){let k=J-z,D=Math.min(G,W)-z,C=Q.text.substring(k,D+1);if(C==="")continue;let H=B.replace(C,Z);H9($.elements[Q.index].elements[F],H),X=J1.MIDDLE;continue}break;case J1.MIDDLE:if(G<=W){let k=B.substring(G-z+1);H9($.elements[Q.index].elements[F],k);let D=$.elements[Q.index].elements[F];$.elements[Q.index].elements[F]=L7(D),X=J1.END}else H9($.elements[Q.index].elements[F],"");break}return $},H9=($,U)=>{return $.elements=B7(U),$},wB=($)=>{if($.element.name!=="w:p")throw Error(`Invalid node type: ${$.element.name}`);if(!$.element.elements)return{text:"",runs:[],index:-1,pathToParagraph:[]};let U=0,Y=$.element.elements.map((J,G)=>({element:J,i:G})).filter(({element:J})=>J.name==="w:r").map(({element:J,i:G})=>{let X=WB(J,G,U);return U+=X.text.length,X}).filter((J)=>!!J);return{text:Y.reduce((J,G)=>J+G.text,""),runs:Y,index:$.index,pathToParagraph:I7($)}},WB=($,U,Y)=>{if(!$.elements)return{text:"",parts:[],index:-1,start:Y,end:Y};let Z=Y,J=$.elements.map((X,Q)=>{var B,F;return X.name==="w:t"&&X.elements&&X.elements.length>0?{text:(F=(B=X.elements[0].text)==null?void 0:B.toString())!=null?F:"",index:Q,start:Z,end:(()=>{var z,W;return Z+=((W=(z=X.elements[0].text)==null?void 0:z.toString())!=null?W:"").length-1,Z})()}:void 0}).filter((X)=>!!X).map((X)=>X);return{text:J.reduce((X,Q)=>X+Q.text,""),parts:J,index:U,start:Y,end:Z}},I7=($)=>$.parent?[...I7($.parent),$.index]:[$.index],aZ=($)=>{var U,Y;return(Y=(U=$.element.elements)==null?void 0:U.map((Z,J)=>({element:Z,index:J,parent:$})))!=null?Y:[]},w7=($)=>{let U=[],Y=[...aZ({element:$,index:0,parent:void 0})],Z;while(Y.length>0){if(Z=Y.shift(),Z.element.name==="w:p")U=[...U,wB(Z)];Y.push(...aZ(Z))}return U},HB=($,U)=>w7($).filter((Y)=>Y.text.includes(U)),jB=new H8,j9="ɵ",zB=({json:$,patch:U,patchText:Y,context:Z,keepOriginalStyles:J=!0})=>{let G=HB($,Y);if(G.length===0)return{element:$,didFindOccurrence:!1};for(let X of G){let Q=U.children.map((B)=>j8(F0(jB.format(B,Z)))).map((B)=>B.elements[0]);switch(U.type){case y9.DOCUMENT:{let B=FB($,X.pathToParagraph),F=NB(X.pathToParagraph);B.elements.splice(F,1,...Q);break}case y9.PARAGRAPH:default:{let B=W7($,X.pathToParagraph);IB({paragraphElement:B,renderedParagraph:X,originalText:Y,replacementText:j9});let F=LB(B,j9),z=B.elements[F],{left:W,right:k}=MB(z,j9),D=Q,C=k;if(J){let H=z.elements.filter((O)=>O.type==="element"&&O.name==="w:rPr");D=Q.map((O)=>{var V;return R0(W0({},O),{elements:[...H,...(V=O.elements)!=null?V:[]]})}),C=R0(W0({},k),{elements:[...H,...k.elements]})}B.elements.splice(F,1,W,...D,C);break}}}return{element:$,didFindOccurrence:!0}},W7=($,U)=>{let Y=$;for(let Z=1;ZW7($,U.slice(0,U.length-1)),NB=($)=>$[$.length-1],y9={DOCUMENT:"file",PARAGRAPH:"paragraph"},pZ=new jU,RB=new Uint8Array([255,254]),DB=new Uint8Array([254,255]),iZ=($,U)=>{if($.length!==U.length)return!1;for(let Y=0;Y<$.length;Y++)if($[Y]!==U[Y])return!1;return!0},AB=($)=>b9(null,[$],function*({outputType:U,data:Y,patches:Z,keepOriginalStyles:J,placeholderDelimiters:G={start:"{{",end:"}}"},recursive:X=!0}){var Q,B,F;let z=Y instanceof c2?Y:yield c2.loadAsync(Y),W=new Map,k={Media:new w8},D=new Map,C=[],H=[],O=!1,V=new Map;for(let[M,L]of Object.entries(z.files)){let A=yield L.async("uint8array"),y=A.slice(0,2);if(iZ(y,RB)||iZ(y,DB)){V.set(M,A);continue}if(!M.endsWith(".xml")&&!M.endsWith(".rels")){V.set(M,A);continue}let g=j8(yield L.async("text"));if(M==="word/document.xml"){let d=(Q=g.elements)==null?void 0:Q.find((E)=>E.name==="w:document");if(d&&d.attributes){for(let E of["mc","wp","r","w15","m"])d.attributes[`xmlns:${E}`]=p1[E];d.attributes["mc:Ignorable"]=`${d.attributes["mc:Ignorable"]||""} w15`.trim()}}if(M.startsWith("word/")&&!M.endsWith(".xml.rels")){let d={file:k,viewWrapper:{Relationships:{addRelationship:(S,h,N,a)=>{H.push({key:M,hyperlink:{id:S,link:N}})}}},stack:[]};if(W.set(M,d),!(G==null?void 0:G.start.trim())||!(G==null?void 0:G.end.trim()))throw Error("Both start and end delimiters must be non-empty strings.");let{start:E,end:s}=G;for(let[S,h]of Object.entries(Z)){let N=`${E}${S}${s}`;while(!0){let{didFindOccurrence:a}=zB({json:g,patch:R0(W0({},h),{children:h.children.map(($0)=>{if($0 instanceof K8){let m=new _2($0.options.children,R1());return H.push({key:M,hyperlink:{id:m.linkId,link:$0.options.link}}),m}else return $0})}),patchText:N,context:d,keepOriginalStyles:J});if(!X||!a)break}}let V0=pZ.getMediaData(JSON.stringify(g),d.file.Media);if(V0.length>0)O=!0,C.push({key:M,mediaDatas:V0})}D.set(M,g)}for(let{key:M,mediaDatas:L}of C){let A=`word/_rels/${M.split("/").pop()}.rels`,y=(B=D.get(A))!=null?B:rZ();D.set(A,y);let g=BB(y),d=pZ.replace(JSON.stringify(D.get(M)),L,g);D.set(M,JSON.parse(d));for(let E=0;E{return $8.js2xml($,{attributeValueFn:(Y)=>String(Y).replace(/&(?!amp;|lt;|gt;|quot;|apos;)/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")})},rZ=()=>({declaration:{attributes:{version:"1.0",encoding:"UTF-8",standalone:"yes"}},elements:[{type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[]}]}),TB=($)=>b9(null,[$],function*({data:U}){let Y=U instanceof c2?U:yield c2.loadAsync(U),Z=new Set;for(let[J,G]of Object.entries(Y.files)){if(!J.endsWith(".xml")&&!J.endsWith(".rels"))continue;if(J.startsWith("word/")&&!J.endsWith(".xml.rels")){let X=j8(yield G.async("text"));w7(X).forEach((Q)=>CB(Q.text).forEach((B)=>Z.add(B)))}}return Array.from(Z)}),CB=($)=>{var U;let Y=new RegExp("(?<=\\{\\{).+?(?=\\}\\})","gs");return(U=$.match(Y))!=null?U:[]};if(typeof globalThis.Buffer>"u")globalThis.Buffer=G0;if(typeof globalThis.process>"u")globalThis.process=OB;globalThis.__bundles=globalThis.__bundles||{};globalThis.__bundles.docx=FU;})(); +(()=>{var R5=Object.create;var{getPrototypeOf:L5,defineProperty:p1,getOwnPropertyNames:I5}=Object;var O5=Object.prototype.hasOwnProperty;function F5(B){return this[B]}var H5,W5,P5=(B,U,G)=>{var Y=B!=null&&typeof B==="object";if(Y){var Q=U?H5??=new WeakMap:W5??=new WeakMap,K=Q.get(B);if(K)return K}G=B!=null?R5(L5(B)):{};let Z=U||!B||!B.__esModule?p1(G,"default",{value:B,enumerable:!0}):G;for(let J of I5(B))if(!O5.call(Z,J))p1(Z,J,{get:F5.bind(B,J),enumerable:!0});if(Y)Q.set(B,Z);return Z};var w5=(B,U)=>()=>(U||B((U={exports:{}}).exports,U),U.exports);var A5=(B)=>B;function j5(B,U){this[B]=A5.bind(null,U)}var N5=(B,U)=>{for(var G in U)p1(B,G,{get:U[G],enumerable:!0,configurable:!0,set:j5.bind(U,G)})};var h6=w5((L7,_6)=>{var z0=_6.exports={},p0,r0;function Y8(){throw Error("setTimeout has not been defined")}function Z8(){throw Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function")p0=setTimeout;else p0=Y8}catch(B){p0=Y8}try{if(typeof clearTimeout==="function")r0=clearTimeout;else r0=Z8}catch(B){r0=Z8}})();function g6(B){if(p0===setTimeout)return setTimeout(B,0);if((p0===Y8||!p0)&&setTimeout)return p0=setTimeout,setTimeout(B,0);try{return p0(B,0)}catch(U){try{return p0.call(null,B,0)}catch(G){return p0.call(this,B,0)}}}function UU(B){if(r0===clearTimeout)return clearTimeout(B);if((r0===Z8||!r0)&&clearTimeout)return r0=clearTimeout,clearTimeout(B);try{return r0(B)}catch(U){try{return r0.call(null,B)}catch(G){return r0.call(this,B)}}}var Q2=[],b2=!1,z2,j1=-1;function GU(){if(!b2||!z2)return;if(b2=!1,z2.length)Q2=z2.concat(Q2);else j1=-1;if(Q2.length)f6()}function f6(){if(b2)return;var B=g6(GU);b2=!0;var U=Q2.length;while(U){z2=Q2,Q2=[];while(++j11)for(var G=1;G"u")O6.global=globalThis;var l0=[],h0=[],r1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(j2=0,F6=r1.length;j20)throw Error("Invalid string. Length must be a multiple of 4");var G=B.indexOf("=");if(G===-1)G=U;var Y=G===U?0:4-G%4;return[G,Y]}function E5(B,U){return(B+U)*3/4-U}function T5(B){var U,G=z5(B),Y=G[0],Q=G[1],K=new Uint8Array(E5(Y,Q)),Z=0,J=Q>0?Y-4:Y,M;for(M=0;M>16&255,K[Z++]=U>>8&255,K[Z++]=U&255;if(Q===2)U=h0[B.charCodeAt(M)]<<2|h0[B.charCodeAt(M+1)]>>4,K[Z++]=U&255;if(Q===1)U=h0[B.charCodeAt(M)]<<10|h0[B.charCodeAt(M+1)]<<4|h0[B.charCodeAt(M+2)]>>2,K[Z++]=U>>8&255,K[Z++]=U&255;return K}function D5(B){return l0[B>>18&63]+l0[B>>12&63]+l0[B>>6&63]+l0[B&63]}function C5(B,U,G){var Y,Q=[];for(var K=U;KJ?J:Z+K));if(Y===1)U=B[G-1],Q.push(l0[U>>2]+l0[U<<4&63]+"==");else if(Y===2)U=(B[G-2]<<8)+B[G-1],Q.push(l0[U>>10]+l0[U>>4&63]+l0[U<<2&63]+"=");return Q.join("")}function w1(B,U,G,Y,Q){var K,Z,J=Q*8-Y-1,M=(1<>1,I=-7,F=G?Q-1:0,D=G?-1:1,w=B[U+F];F+=D,K=w&(1<<-I)-1,w>>=-I,I+=J;for(;I>0;K=K*256+B[U+F],F+=D,I-=8);Z=K&(1<<-I)-1,K>>=-I,I+=Y;for(;I>0;Z=Z*256+B[U+F],F+=D,I-=8);if(K===0)K=1-W;else if(K===M)return Z?NaN:(w?-1:1)*(1/0);else Z=Z+Math.pow(2,Y),K=K-W;return(w?-1:1)*Z*Math.pow(2,K-Y)}function j6(B,U,G,Y,Q,K){var Z,J,M,W=K*8-Q-1,I=(1<>1,D=Q===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=Y?0:K-1,P=Y?1:-1,A=U<0||U===0&&1/U<0?1:0;if(U=Math.abs(U),isNaN(U)||U===1/0)J=isNaN(U)?1:0,Z=I;else{if(Z=Math.floor(Math.log(U)/Math.LN2),U*(M=Math.pow(2,-Z))<1)Z--,M*=2;if(Z+F>=1)U+=D/M;else U+=D*Math.pow(2,1-F);if(U*M>=2)Z++,M/=2;if(Z+F>=I)J=0,Z=I;else if(Z+F>=1)J=(U*M-1)*Math.pow(2,Q),Z=Z+F;else J=U*Math.pow(2,F-1)*Math.pow(2,Q),Z=0}for(;Q>=8;B[G+w]=J&255,w+=P,J/=256,Q-=8);Z=Z<0;B[G+w]=Z&255,w+=P,Z/=256,W-=8);B[G+w-P]|=A*128}var W6=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null,k5=50,i1=2147483647;var{btoa:Z7,atob:Q7,File:J7,Blob:K7}=globalThis;function Z2(B){if(B>i1)throw RangeError('The value "'+B+'" is invalid for option "size"');let U=new Uint8Array(B);return Object.setPrototypeOf(U,J0.prototype),U}function e1(B,U,G){return class extends G{constructor(){super();Object.defineProperty(this,"message",{value:U.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${B}]`,this.stack,delete this.name}get code(){return B}set code(Y){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:Y,writable:!0})}toString(){return`${this.name} [${B}]: ${this.message}`}}}var $5=e1("ERR_BUFFER_OUT_OF_BOUNDS",function(B){if(B)return`${B} is outside of buffer bounds`;return"Attempt to access memory outside buffer bounds"},RangeError),S5=e1("ERR_INVALID_ARG_TYPE",function(B,U){return`The "${B}" argument must be of type number. Received type ${typeof U}`},TypeError),n1=e1("ERR_OUT_OF_RANGE",function(B,U,G){let Y=`The value of "${B}" is out of range.`,Q=G;if(Number.isInteger(G)&&Math.abs(G)>4294967296)Q=A6(String(G));else if(typeof G==="bigint"){if(Q=String(G),G>BigInt(2)**BigInt(32)||G<-(BigInt(2)**BigInt(32)))Q=A6(Q);Q+="n"}return Y+=` It must be ${U}. Received ${Q}`,Y},RangeError);function J0(B,U,G){if(typeof B==="number"){if(typeof U==="string")throw TypeError('The "string" argument must be of type string. Received type number');return B8(B)}return N6(B,U,G)}Object.defineProperty(J0.prototype,"parent",{enumerable:!0,get:function(){if(!J0.isBuffer(this))return;return this.buffer}});Object.defineProperty(J0.prototype,"offset",{enumerable:!0,get:function(){if(!J0.isBuffer(this))return;return this.byteOffset}});J0.poolSize=8192;function N6(B,U,G){if(typeof B==="string")return v5(B,U);if(ArrayBuffer.isView(B))return y5(B);if(B==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof B);if(a0(B,ArrayBuffer)||B&&a0(B.buffer,ArrayBuffer))return o1(B,U,G);if(typeof SharedArrayBuffer<"u"&&(a0(B,SharedArrayBuffer)||B&&a0(B.buffer,SharedArrayBuffer)))return o1(B,U,G);if(typeof B==="number")throw TypeError('The "value" argument must not be of type number. Received type number');let Y=B.valueOf&&B.valueOf();if(Y!=null&&Y!==B)return J0.from(Y,U,G);let Q=g5(B);if(Q)return Q;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof B[Symbol.toPrimitive]==="function")return J0.from(B[Symbol.toPrimitive]("string"),U,G);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof B)}J0.from=function(B,U,G){return N6(B,U,G)};Object.setPrototypeOf(J0.prototype,Uint8Array.prototype);Object.setPrototypeOf(J0,Uint8Array);function z6(B){if(typeof B!=="number")throw TypeError('"size" argument must be of type number');else if(B<0)throw RangeError('The value "'+B+'" is invalid for option "size"')}function b5(B,U,G){if(z6(B),B<=0)return Z2(B);if(U!==void 0)return typeof G==="string"?Z2(B).fill(U,G):Z2(B).fill(U);return Z2(B)}J0.alloc=function(B,U,G){return b5(B,U,G)};function B8(B){return z6(B),Z2(B<0?0:U8(B)|0)}J0.allocUnsafe=function(B){return B8(B)};J0.allocUnsafeSlow=function(B){return B8(B)};function v5(B,U){if(typeof U!=="string"||U==="")U="utf8";if(!J0.isEncoding(U))throw TypeError("Unknown encoding: "+U);let G=E6(B,U)|0,Y=Z2(G),Q=Y.write(B,U);if(Q!==G)Y=Y.slice(0,Q);return Y}function s1(B){let U=B.length<0?0:U8(B.length)|0,G=Z2(U);for(let Y=0;Y=i1)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i1.toString(16)+" bytes");return B|0}J0.isBuffer=function(B){return B!=null&&B._isBuffer===!0&&B!==J0.prototype};J0.compare=function(B,U){if(a0(B,Uint8Array))B=J0.from(B,B.offset,B.byteLength);if(a0(U,Uint8Array))U=J0.from(U,U.offset,U.byteLength);if(!J0.isBuffer(B)||!J0.isBuffer(U))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(B===U)return 0;let G=B.length,Y=U.length;for(let Q=0,K=Math.min(G,Y);QY.length){if(!J0.isBuffer(K))K=J0.from(K);K.copy(Y,Q)}else Uint8Array.prototype.set.call(Y,K,Q);else if(!J0.isBuffer(K))throw TypeError('"list" argument must be an Array of Buffers');else K.copy(Y,Q);Q+=K.length}return Y};function E6(B,U){if(J0.isBuffer(B))return B.length;if(ArrayBuffer.isView(B)||a0(B,ArrayBuffer))return B.byteLength;if(typeof B!=="string")throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof B);let G=B.length,Y=arguments.length>2&&arguments[2]===!0;if(!Y&&G===0)return 0;let Q=!1;for(;;)switch(U){case"ascii":case"latin1":case"binary":return G;case"utf8":case"utf-8":return t1(B).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G*2;case"hex":return G>>>1;case"base64":return y6(B).length;default:if(Q)return Y?-1:t1(B).length;U=(""+U).toLowerCase(),Q=!0}}J0.byteLength=E6;function f5(B,U,G){let Y=!1;if(U===void 0||U<0)U=0;if(U>this.length)return"";if(G===void 0||G>this.length)G=this.length;if(G<=0)return"";if(G>>>=0,U>>>=0,G<=U)return"";if(!B)B="utf8";while(!0)switch(B){case"hex":return p5(this,U,G);case"utf8":case"utf-8":return D6(this,U,G);case"ascii":return l5(this,U,G);case"latin1":case"binary":return a5(this,U,G);case"base64":return c5(this,U,G);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r5(this,U,G);default:if(Y)throw TypeError("Unknown encoding: "+B);B=(B+"").toLowerCase(),Y=!0}}J0.prototype._isBuffer=!0;function N2(B,U,G){let Y=B[U];B[U]=B[G],B[G]=Y}J0.prototype.swap16=function(){let B=this.length;if(B%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let U=0;UU)B+=" ... ";return""};if(W6)J0.prototype[W6]=J0.prototype.inspect;J0.prototype.compare=function(B,U,G,Y,Q){if(a0(B,Uint8Array))B=J0.from(B,B.offset,B.byteLength);if(!J0.isBuffer(B))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof B);if(U===void 0)U=0;if(G===void 0)G=B?B.length:0;if(Y===void 0)Y=0;if(Q===void 0)Q=this.length;if(U<0||G>B.length||Y<0||Q>this.length)throw RangeError("out of range index");if(Y>=Q&&U>=G)return 0;if(Y>=Q)return-1;if(U>=G)return 1;if(U>>>=0,G>>>=0,Y>>>=0,Q>>>=0,this===B)return 0;let K=Q-Y,Z=G-U,J=Math.min(K,Z),M=this.slice(Y,Q),W=B.slice(U,G);for(let I=0;I2147483647)G=2147483647;else if(G<-2147483648)G=-2147483648;if(G=+G,Number.isNaN(G))G=Q?0:B.length-1;if(G<0)G=B.length+G;if(G>=B.length)if(Q)return-1;else G=B.length-1;else if(G<0)if(Q)G=0;else return-1;if(typeof U==="string")U=J0.from(U,Y);if(J0.isBuffer(U)){if(U.length===0)return-1;return P6(B,U,G,Y,Q)}else if(typeof U==="number"){if(U=U&255,typeof Uint8Array.prototype.indexOf==="function")if(Q)return Uint8Array.prototype.indexOf.call(B,U,G);else return Uint8Array.prototype.lastIndexOf.call(B,U,G);return P6(B,[U],G,Y,Q)}throw TypeError("val must be string, number or Buffer")}function P6(B,U,G,Y,Q){let K=1,Z=B.length,J=U.length;if(Y!==void 0){if(Y=String(Y).toLowerCase(),Y==="ucs2"||Y==="ucs-2"||Y==="utf16le"||Y==="utf-16le"){if(B.length<2||U.length<2)return-1;K=2,Z/=2,J/=2,G/=2}}function M(I,F){if(K===1)return I[F];else return I.readUInt16BE(F*K)}let W;if(Q){let I=-1;for(W=G;WZ)G=Z-J;for(W=G;W>=0;W--){let I=!0;for(let F=0;FQ)Y=Q;let K=U.length;if(Y>K/2)Y=K/2;let Z;for(Z=0;Z>>0,isFinite(G)){if(G=G>>>0,Y===void 0)Y="utf8"}else Y=G,G=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let Q=this.length-U;if(G===void 0||G>Q)G=Q;if(B.length>0&&(G<0||U<0)||U>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!Y)Y="utf8";let K=!1;for(;;)switch(Y){case"hex":return x5(this,B,U,G);case"utf8":case"utf-8":return _5(this,B,U,G);case"ascii":case"latin1":case"binary":return h5(this,B,U,G);case"base64":return u5(this,B,U,G);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d5(this,B,U,G);default:if(K)throw TypeError("Unknown encoding: "+Y);Y=(""+Y).toLowerCase(),K=!0}};J0.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function c5(B,U,G){if(U===0&&G===B.length)return H6(B);else return H6(B.slice(U,G))}function D6(B,U,G){G=Math.min(B.length,G);let Y=[],Q=U;while(Q239?4:K>223?3:K>191?2:1;if(Q+J<=G){let M,W,I,F;switch(J){case 1:if(K<128)Z=K;break;case 2:if(M=B[Q+1],(M&192)===128){if(F=(K&31)<<6|M&63,F>127)Z=F}break;case 3:if(M=B[Q+1],W=B[Q+2],(M&192)===128&&(W&192)===128){if(F=(K&15)<<12|(M&63)<<6|W&63,F>2047&&(F<55296||F>57343))Z=F}break;case 4:if(M=B[Q+1],W=B[Q+2],I=B[Q+3],(M&192)===128&&(W&192)===128&&(I&192)===128){if(F=(K&15)<<18|(M&63)<<12|(W&63)<<6|I&63,F>65535&&F<1114112)Z=F}}}if(Z===null)Z=65533,J=1;else if(Z>65535)Z-=65536,Y.push(Z>>>10&1023|55296),Z=56320|Z&1023;Y.push(Z),Q+=J}return m5(Y)}var w6=4096;function m5(B){let U=B.length;if(U<=w6)return String.fromCharCode.apply(String,B);let G="",Y=0;while(YY)G=Y;let Q="";for(let K=U;KG)B=G;if(U<0){if(U+=G,U<0)U=0}else if(U>G)U=G;if(UG)throw RangeError("Trying to access beyond buffer length")}J0.prototype.readUintLE=J0.prototype.readUIntLE=function(B,U,G){if(B=B>>>0,U=U>>>0,!G)$0(B,U,this.length);let Y=this[B],Q=1,K=0;while(++K>>0,U=U>>>0,!G)$0(B,U,this.length);let Y=this[B+--U],Q=1;while(U>0&&(Q*=256))Y+=this[B+--U]*Q;return Y};J0.prototype.readUint8=J0.prototype.readUInt8=function(B,U){if(B=B>>>0,!U)$0(B,1,this.length);return this[B]};J0.prototype.readUint16LE=J0.prototype.readUInt16LE=function(B,U){if(B=B>>>0,!U)$0(B,2,this.length);return this[B]|this[B+1]<<8};J0.prototype.readUint16BE=J0.prototype.readUInt16BE=function(B,U){if(B=B>>>0,!U)$0(B,2,this.length);return this[B]<<8|this[B+1]};J0.prototype.readUint32LE=J0.prototype.readUInt32LE=function(B,U){if(B=B>>>0,!U)$0(B,4,this.length);return(this[B]|this[B+1]<<8|this[B+2]<<16)+this[B+3]*16777216};J0.prototype.readUint32BE=J0.prototype.readUInt32BE=function(B,U){if(B=B>>>0,!U)$0(B,4,this.length);return this[B]*16777216+(this[B+1]<<16|this[B+2]<<8|this[B+3])};J0.prototype.readBigUInt64LE=I2(function(B){B=B>>>0,S2(B,"offset");let U=this[B],G=this[B+7];if(U===void 0||G===void 0)n2(B,this.length-8);let Y=U+this[++B]*256+this[++B]*65536+this[++B]*16777216,Q=this[++B]+this[++B]*256+this[++B]*65536+G*16777216;return BigInt(Y)+(BigInt(Q)<>>0,S2(B,"offset");let U=this[B],G=this[B+7];if(U===void 0||G===void 0)n2(B,this.length-8);let Y=U*16777216+this[++B]*65536+this[++B]*256+this[++B],Q=this[++B]*16777216+this[++B]*65536+this[++B]*256+G;return(BigInt(Y)<>>0,U=U>>>0,!G)$0(B,U,this.length);let Y=this[B],Q=1,K=0;while(++K=Q)Y-=Math.pow(2,8*U);return Y};J0.prototype.readIntBE=function(B,U,G){if(B=B>>>0,U=U>>>0,!G)$0(B,U,this.length);let Y=U,Q=1,K=this[B+--Y];while(Y>0&&(Q*=256))K+=this[B+--Y]*Q;if(Q*=128,K>=Q)K-=Math.pow(2,8*U);return K};J0.prototype.readInt8=function(B,U){if(B=B>>>0,!U)$0(B,1,this.length);if(!(this[B]&128))return this[B];return(255-this[B]+1)*-1};J0.prototype.readInt16LE=function(B,U){if(B=B>>>0,!U)$0(B,2,this.length);let G=this[B]|this[B+1]<<8;return G&32768?G|4294901760:G};J0.prototype.readInt16BE=function(B,U){if(B=B>>>0,!U)$0(B,2,this.length);let G=this[B+1]|this[B]<<8;return G&32768?G|4294901760:G};J0.prototype.readInt32LE=function(B,U){if(B=B>>>0,!U)$0(B,4,this.length);return this[B]|this[B+1]<<8|this[B+2]<<16|this[B+3]<<24};J0.prototype.readInt32BE=function(B,U){if(B=B>>>0,!U)$0(B,4,this.length);return this[B]<<24|this[B+1]<<16|this[B+2]<<8|this[B+3]};J0.prototype.readBigInt64LE=I2(function(B){B=B>>>0,S2(B,"offset");let U=this[B],G=this[B+7];if(U===void 0||G===void 0)n2(B,this.length-8);let Y=this[B+4]+this[B+5]*256+this[B+6]*65536+(G<<24);return(BigInt(Y)<>>0,S2(B,"offset");let U=this[B],G=this[B+7];if(U===void 0||G===void 0)n2(B,this.length-8);let Y=(U<<24)+this[++B]*65536+this[++B]*256+this[++B];return(BigInt(Y)<>>0,!U)$0(B,4,this.length);return w1(this,B,!0,23,4)};J0.prototype.readFloatBE=function(B,U){if(B=B>>>0,!U)$0(B,4,this.length);return w1(this,B,!1,23,4)};J0.prototype.readDoubleLE=function(B,U){if(B=B>>>0,!U)$0(B,8,this.length);return w1(this,B,!0,52,8)};J0.prototype.readDoubleBE=function(B,U){if(B=B>>>0,!U)$0(B,8,this.length);return w1(this,B,!1,52,8)};function g0(B,U,G,Y,Q,K){if(!J0.isBuffer(B))throw TypeError('"buffer" argument must be a Buffer instance');if(U>Q||UB.length)throw RangeError("Index out of range")}J0.prototype.writeUintLE=J0.prototype.writeUIntLE=function(B,U,G,Y){if(B=+B,U=U>>>0,G=G>>>0,!Y){let Z=Math.pow(2,8*G)-1;g0(this,B,U,G,Z,0)}let Q=1,K=0;this[U]=B&255;while(++K>>0,G=G>>>0,!Y){let Z=Math.pow(2,8*G)-1;g0(this,B,U,G,Z,0)}let Q=G-1,K=1;this[U+Q]=B&255;while(--Q>=0&&(K*=256))this[U+Q]=B/K&255;return U+G};J0.prototype.writeUint8=J0.prototype.writeUInt8=function(B,U,G){if(B=+B,U=U>>>0,!G)g0(this,B,U,1,255,0);return this[U]=B&255,U+1};J0.prototype.writeUint16LE=J0.prototype.writeUInt16LE=function(B,U,G){if(B=+B,U=U>>>0,!G)g0(this,B,U,2,65535,0);return this[U]=B&255,this[U+1]=B>>>8,U+2};J0.prototype.writeUint16BE=J0.prototype.writeUInt16BE=function(B,U,G){if(B=+B,U=U>>>0,!G)g0(this,B,U,2,65535,0);return this[U]=B>>>8,this[U+1]=B&255,U+2};J0.prototype.writeUint32LE=J0.prototype.writeUInt32LE=function(B,U,G){if(B=+B,U=U>>>0,!G)g0(this,B,U,4,4294967295,0);return this[U+3]=B>>>24,this[U+2]=B>>>16,this[U+1]=B>>>8,this[U]=B&255,U+4};J0.prototype.writeUint32BE=J0.prototype.writeUInt32BE=function(B,U,G){if(B=+B,U=U>>>0,!G)g0(this,B,U,4,4294967295,0);return this[U]=B>>>24,this[U+1]=B>>>16,this[U+2]=B>>>8,this[U+3]=B&255,U+4};function C6(B,U,G,Y,Q){v6(U,Y,Q,B,G,7);let K=Number(U&BigInt(4294967295));B[G++]=K,K=K>>8,B[G++]=K,K=K>>8,B[G++]=K,K=K>>8,B[G++]=K;let Z=Number(U>>BigInt(32)&BigInt(4294967295));return B[G++]=Z,Z=Z>>8,B[G++]=Z,Z=Z>>8,B[G++]=Z,Z=Z>>8,B[G++]=Z,G}function k6(B,U,G,Y,Q){v6(U,Y,Q,B,G,7);let K=Number(U&BigInt(4294967295));B[G+7]=K,K=K>>8,B[G+6]=K,K=K>>8,B[G+5]=K,K=K>>8,B[G+4]=K;let Z=Number(U>>BigInt(32)&BigInt(4294967295));return B[G+3]=Z,Z=Z>>8,B[G+2]=Z,Z=Z>>8,B[G+1]=Z,Z=Z>>8,B[G]=Z,G+8}J0.prototype.writeBigUInt64LE=I2(function(B,U=0){return C6(this,B,U,BigInt(0),BigInt("0xffffffffffffffff"))});J0.prototype.writeBigUInt64BE=I2(function(B,U=0){return k6(this,B,U,BigInt(0),BigInt("0xffffffffffffffff"))});J0.prototype.writeIntLE=function(B,U,G,Y){if(B=+B,U=U>>>0,!Y){let J=Math.pow(2,8*G-1);g0(this,B,U,G,J-1,-J)}let Q=0,K=1,Z=0;this[U]=B&255;while(++Q>0)-Z&255}return U+G};J0.prototype.writeIntBE=function(B,U,G,Y){if(B=+B,U=U>>>0,!Y){let J=Math.pow(2,8*G-1);g0(this,B,U,G,J-1,-J)}let Q=G-1,K=1,Z=0;this[U+Q]=B&255;while(--Q>=0&&(K*=256)){if(B<0&&Z===0&&this[U+Q+1]!==0)Z=1;this[U+Q]=(B/K>>0)-Z&255}return U+G};J0.prototype.writeInt8=function(B,U,G){if(B=+B,U=U>>>0,!G)g0(this,B,U,1,127,-128);if(B<0)B=255+B+1;return this[U]=B&255,U+1};J0.prototype.writeInt16LE=function(B,U,G){if(B=+B,U=U>>>0,!G)g0(this,B,U,2,32767,-32768);return this[U]=B&255,this[U+1]=B>>>8,U+2};J0.prototype.writeInt16BE=function(B,U,G){if(B=+B,U=U>>>0,!G)g0(this,B,U,2,32767,-32768);return this[U]=B>>>8,this[U+1]=B&255,U+2};J0.prototype.writeInt32LE=function(B,U,G){if(B=+B,U=U>>>0,!G)g0(this,B,U,4,2147483647,-2147483648);return this[U]=B&255,this[U+1]=B>>>8,this[U+2]=B>>>16,this[U+3]=B>>>24,U+4};J0.prototype.writeInt32BE=function(B,U,G){if(B=+B,U=U>>>0,!G)g0(this,B,U,4,2147483647,-2147483648);if(B<0)B=4294967295+B+1;return this[U]=B>>>24,this[U+1]=B>>>16,this[U+2]=B>>>8,this[U+3]=B&255,U+4};J0.prototype.writeBigInt64LE=I2(function(B,U=0){return C6(this,B,U,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});J0.prototype.writeBigInt64BE=I2(function(B,U=0){return k6(this,B,U,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function $6(B,U,G,Y,Q,K){if(G+Y>B.length)throw RangeError("Index out of range");if(G<0)throw RangeError("Index out of range")}function S6(B,U,G,Y,Q){if(U=+U,G=G>>>0,!Q)$6(B,U,G,4,340282346638528860000000000000000000000,-340282346638528860000000000000000000000);return j6(B,U,G,Y,23,4),G+4}J0.prototype.writeFloatLE=function(B,U,G){return S6(this,B,U,!0,G)};J0.prototype.writeFloatBE=function(B,U,G){return S6(this,B,U,!1,G)};function b6(B,U,G,Y,Q){if(U=+U,G=G>>>0,!Q)$6(B,U,G,8,179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);return j6(B,U,G,Y,52,8),G+8}J0.prototype.writeDoubleLE=function(B,U,G){return b6(this,B,U,!0,G)};J0.prototype.writeDoubleBE=function(B,U,G){return b6(this,B,U,!1,G)};J0.prototype.copy=function(B,U,G,Y){if(!J0.isBuffer(B))throw TypeError("argument should be a Buffer");if(!G)G=0;if(!Y&&Y!==0)Y=this.length;if(U>=B.length)U=B.length;if(!U)U=0;if(Y>0&&Y=this.length)throw RangeError("Index out of range");if(Y<0)throw RangeError("sourceEnd out of bounds");if(Y>this.length)Y=this.length;if(B.length-U>>0,G=G===void 0?this.length:G>>>0,!B)B=0;let Q;if(typeof B==="number")for(Q=U;Q=Y+4;G-=3)U=`_${B.slice(G-3,G)}${U}`;return`${B.slice(0,G)}${U}`}function i5(B,U,G){if(S2(U,"offset"),B[U]===void 0||B[U+G]===void 0)n2(U,B.length-(G+1))}function v6(B,U,G,Y,Q,K){if(B>G||B3)if(U===0||U===BigInt(0))J=`>= 0${Z} and < 2${Z} ** ${(K+1)*8}${Z}`;else J=`>= -(2${Z} ** ${(K+1)*8-1}${Z}) and < 2 ** ${(K+1)*8-1}${Z}`;else J=`>= ${U}${Z} and <= ${G}${Z}`;throw new n1("value",J,B)}i5(Y,Q,K)}function S2(B,U){if(typeof B!=="number")throw new S5(U,"number",B)}function n2(B,U,G){if(Math.floor(B)!==B)throw S2(B,G),new n1(G||"offset","an integer",B);if(U<0)throw new $5;throw new n1(G||"offset",`>= ${G?1:0} and <= ${U}`,B)}var n5=/[^+/0-9A-Za-z-_]/g;function s5(B){if(B=B.split("=")[0],B=B.trim().replace(n5,""),B.length<2)return"";while(B.length%4!==0)B=B+"=";return B}function t1(B,U){U=U||1/0;let G,Y=B.length,Q=null,K=[];for(let Z=0;Z55295&&G<57344){if(!Q){if(G>56319){if((U-=3)>-1)K.push(239,191,189);continue}else if(Z+1===Y){if((U-=3)>-1)K.push(239,191,189);continue}Q=G;continue}if(G<56320){if((U-=3)>-1)K.push(239,191,189);Q=G;continue}G=(Q-55296<<10|G-56320)+65536}else if(Q){if((U-=3)>-1)K.push(239,191,189)}if(Q=null,G<128){if((U-=1)<0)break;K.push(G)}else if(G<2048){if((U-=2)<0)break;K.push(G>>6|192,G&63|128)}else if(G<65536){if((U-=3)<0)break;K.push(G>>12|224,G>>6&63|128,G&63|128)}else if(G<1114112){if((U-=4)<0)break;K.push(G>>18|240,G>>12&63|128,G>>6&63|128,G&63|128)}else throw Error("Invalid code point")}return K}function o5(B){let U=[];for(let G=0;G>8,Q=G%256,K.push(Q),K.push(Y)}return K}function y6(B){return T5(s5(B))}function A1(B,U,G,Y){let Q;for(Q=0;Q=U.length||Q>=B.length)break;U[Q+G]=B[Q]}return Q}function a0(B,U){return B instanceof U||B!=null&&B.constructor!=null&&B.constructor.name!=null&&B.constructor.name===U.name}var e5=function(){let B=Array(256);for(let U=0;U<16;++U){let G=U*16;for(let Y=0;Y<16;++Y)B[G+Y]="0123456789abcdef"[U]+"0123456789abcdef"[Y]}return B}();function I2(B){return typeof BigInt>"u"?BU:B}function BU(){throw Error("BigInt not supported")}function G8(B){return()=>{throw Error(B+" is not implemented for node:buffer browser polyfill")}}var V7=G8("resolveObjectURL"),q7=G8("isUtf8");var M7=G8("transcode");var G7=P5(h6(),1);var R6={};N5(R6,{unsignedDecimalNumber:()=>q1,universalMeasureValue:()=>M1,uniqueUuid:()=>eB,uniqueNumericIdCreator:()=>I1,uniqueId:()=>O1,uCharHexNumber:()=>H8,twipsMeasureValue:()=>E0,standardizeData:()=>A4,signedTwipsMeasureValue:()=>t0,signedHpsMeasureValue:()=>VG,shortHexNumber:()=>SB,sectionPageSizeDefaults:()=>k1,sectionMarginDefaults:()=>F2,positiveUniversalMeasureValue:()=>u8,pointMeasureValue:()=>gB,percentageValue:()=>vB,patchDocument:()=>tK,patchDetector:()=>B7,measurementOrPercentValue:()=>d8,longHexNumber:()=>KG,hpsMeasureValue:()=>bB,hexColorValue:()=>C2,hashedId:()=>W8,encodeUtf8:()=>U1,eighthPointMeasureValue:()=>yB,docPropertiesUniqueNumericIdGen:()=>oB,decimalNumber:()=>D0,dateTimeValue:()=>fB,createWrapTopAndBottom:()=>F4,createWrapTight:()=>O4,createWrapSquare:()=>I4,createWrapNone:()=>w8,createVerticalPosition:()=>J4,createVerticalAlign:()=>B6,createUnderline:()=>cB,createTransformation:()=>i8,createTableWidthElement:()=>J1,createTableRowHeight:()=>W9,createTableLook:()=>H9,createTableLayout:()=>O9,createTableFloatProperties:()=>I9,createTabStopItem:()=>b4,createTabStop:()=>v4,createStringElement:()=>f2,createSpacing:()=>S4,createSimplePos:()=>G4,createShading:()=>X1,createSectionType:()=>C9,createRunFonts:()=>T1,createParagraphStyle:()=>x2,createPageSize:()=>T9,createPageNumberType:()=>E9,createPageMargin:()=>z9,createOutlineLevel:()=>_4,createMathSuperScriptProperties:()=>p4,createMathSuperScriptElement:()=>a2,createMathSubSuperScriptProperties:()=>i4,createMathSubScriptProperties:()=>r4,createMathSubScriptElement:()=>l2,createMathPreSubSuperScriptProperties:()=>n4,createMathNAryProperties:()=>t8,createMathLimitLocation:()=>a4,createMathBase:()=>y0,createMathAccentCharacter:()=>l4,createLineNumberType:()=>j9,createIndent:()=>hB,createHorizontalPosition:()=>Q4,createHeaderFooterReference:()=>C1,createFrameProperties:()=>u4,createEmphasisMark:()=>p8,createDotEmphasisMark:()=>wG,createDocumentGrid:()=>A9,createColumns:()=>w9,createBorderElement:()=>A0,createBodyProperties:()=>K4,createAlignment:()=>c8,convertToXmlComponent:()=>h1,convertMillimetersToTwip:()=>dG,convertInchesToTwip:()=>u0,concreteNumUniqueNumericIdGen:()=>sB,commentIdToParaId:()=>N4,bookmarkUniqueNumericIdGen:()=>tB,abstractNumUniqueNumericIdGen:()=>nB,YearShort:()=>oY,YearLong:()=>BZ,XmlComponent:()=>t,XmlAttributeComponent:()=>F0,WpsShapeRun:()=>SY,WpgGroupRun:()=>bY,WidthType:()=>b1,WORKAROUND4:()=>oZ,WORKAROUND3:()=>JG,WORKAROUND2:()=>jJ,VerticalPositionRelativeFrom:()=>U4,VerticalPositionAlign:()=>XG,VerticalMergeType:()=>U6,VerticalMergeRevisionType:()=>HQ,VerticalMerge:()=>N8,VerticalAnchor:()=>cG,VerticalAlignTable:()=>K9,VerticalAlignSection:()=>V9,VerticalAlign:()=>WQ,UnderlineType:()=>r8,ThematicBreak:()=>_B,Textbox:()=>DK,TextWrappingType:()=>e2,TextWrappingSide:()=>L4,TextRun:()=>Q1,TextEffect:()=>CG,TextDirection:()=>NQ,TableRowPropertiesChange:()=>P9,TableRowProperties:()=>Q6,TableRow:()=>fQ,TableProperties:()=>Z6,TableOfContents:()=>RK,TableLayoutType:()=>SQ,TableCellBorders:()=>M9,TableCell:()=>G6,TableBorders:()=>Y6,TableAnchorType:()=>TQ,Table:()=>yQ,TabStopType:()=>j8,TabStopPosition:()=>HZ,Tab:()=>D4,TDirection:()=>R9,SymbolRun:()=>aB,Styles:()=>$1,StyleLevel:()=>LK,StyleForParagraph:()=>p2,StyleForCharacter:()=>$2,StringValueElement:()=>M2,StringEnumValueElement:()=>qG,StringContainer:()=>O2,SpaceType:()=>x0,SoftHyphen:()=>iY,SimpleMailMergeField:()=>fY,SimpleField:()=>n8,ShadingType:()=>HG,SequentialIdentifier:()=>yY,Separator:()=>YZ,SectionType:()=>GJ,SectionPropertiesChange:()=>k9,SectionProperties:()=>J6,RunPropertiesDefaults:()=>a9,RunPropertiesChange:()=>lB,RunProperties:()=>U2,Run:()=>T0,RelativeVerticalPosition:()=>CQ,RelativeHorizontalPosition:()=>DQ,PrettifyType:()=>G5,PositionalTabRelativeTo:()=>qZ,PositionalTabLeader:()=>MZ,PositionalTabAlignment:()=>VZ,PositionalTab:()=>RZ,PatchType:()=>D8,ParagraphRunProperties:()=>mB,ParagraphPropertiesDefaults:()=>l9,ParagraphPropertiesChange:()=>d4,ParagraphProperties:()=>X2,Paragraph:()=>d0,PageTextDirectionType:()=>BJ,PageTextDirection:()=>D9,PageReference:()=>CZ,PageOrientation:()=>y1,PageNumberSeparator:()=>eQ,PageNumberElement:()=>QZ,PageNumber:()=>H2,PageBreakBefore:()=>$4,PageBreak:()=>LZ,PageBorders:()=>N9,PageBorderZOrder:()=>tQ,PageBorderOffsetFrom:()=>oQ,PageBorderDisplay:()=>sQ,Packer:()=>Y5,OverlapType:()=>kQ,OnOffElement:()=>M0,Numbering:()=>d9,NumberedItemReferenceFormat:()=>zZ,NumberedItemReference:()=>TZ,NumberValueElement:()=>_2,NumberProperties:()=>D1,NumberFormat:()=>RG,NoBreakHyphen:()=>rY,NextAttributeComponent:()=>k8,MonthShort:()=>sY,MonthLong:()=>eY,Media:()=>K6,MathSuperScript:()=>rZ,MathSum:()=>mZ,MathSubSuperScript:()=>nZ,MathSubScript:()=>iZ,MathSquareBrackets:()=>QQ,MathRun:()=>hZ,MathRoundBrackets:()=>ZQ,MathRadicalProperties:()=>o4,MathRadical:()=>BQ,MathPreSubSuperScript:()=>sZ,MathNumerator:()=>m4,MathLimitUpper:()=>aZ,MathLimitLower:()=>pZ,MathLimit:()=>e8,MathIntegral:()=>lZ,MathFunctionProperties:()=>e4,MathFunctionName:()=>t4,MathFunction:()=>UQ,MathFraction:()=>uZ,MathDenominator:()=>c4,MathDegree:()=>s4,MathCurlyBrackets:()=>JQ,MathAngledBrackets:()=>KQ,Math:()=>xZ,LineRuleType:()=>k2,LineNumberRestartFormat:()=>nQ,LevelSuffix:()=>DJ,LevelOverride:()=>u9,LevelFormat:()=>i0,LevelForOverride:()=>$J,LevelBase:()=>V6,Level:()=>h9,LeaderType:()=>FZ,LastRenderedPageBreak:()=>KZ,InternalHyperlink:()=>y4,InsertedTextRun:()=>XQ,InsertedTableRow:()=>U9,InsertedTableCell:()=>Y9,InitializableXmlComponent:()=>h8,ImportedXmlComponent:()=>kB,ImportedRootElementAttributes:()=>$B,ImageRun:()=>$Y,IgnoreIfEmptyXmlComponent:()=>R2,HyperlinkType:()=>AZ,HpsMeasureElement:()=>E1,HorizontalPositionRelativeFrom:()=>B4,HorizontalPositionAlign:()=>MG,HighlightColor:()=>kG,HeightRule:()=>gQ,HeadingLevel:()=>OZ,HeaderWrapper:()=>_9,HeaderFooterType:()=>z8,HeaderFooterReferenceType:()=>D2,Header:()=>IK,GridSpan:()=>X9,FrameWrap:()=>fZ,FrameAnchorType:()=>gZ,FootnoteReferenceRun:()=>FK,FootnoteReferenceElement:()=>GZ,FootnoteReference:()=>o9,FooterWrapper:()=>f9,Footer:()=>OK,FootNotes:()=>x9,FootNoteReferenceRunAttributes:()=>s9,FileChild:()=>F1,File:()=>VK,ExternalHyperlink:()=>o8,Endnotes:()=>g9,EndnoteReferenceRunAttributes:()=>t9,EndnoteReferenceRun:()=>HK,EndnoteReference:()=>T4,EndnoteIdReference:()=>e9,EmptyElement:()=>S0,EmphasisMarkType:()=>a8,EMPTY_OBJECT:()=>KB,DropCapType:()=>yZ,Drawing:()=>c1,DocumentGridType:()=>iQ,DocumentDefaults:()=>p9,DocumentBackgroundAttributes:()=>S9,DocumentBackground:()=>b9,DocumentAttributes:()=>H1,DocumentAttributeNamespaces:()=>v1,Document:()=>VK,DeletedTextRun:()=>OQ,DeletedTableRow:()=>G9,DeletedTableCell:()=>Z9,DayShort:()=>nY,DayLong:()=>tY,ContinuationSeparator:()=>ZZ,ConcreteNumbering:()=>T8,ConcreteHyperlink:()=>m2,CommentsExtended:()=>E4,Comments:()=>z4,CommentReference:()=>mY,CommentRangeStart:()=>dY,CommentRangeEnd:()=>cY,Comment:()=>A8,ColumnBreak:()=>IZ,Column:()=>ZJ,CheckBoxUtil:()=>B5,CheckBoxSymbolElement:()=>S1,CheckBox:()=>WK,CharacterSet:()=>kZ,CellMergeAttributes:()=>Q9,CellMerge:()=>J9,CarriageReturn:()=>JZ,BuilderElement:()=>X0,BorderStyle:()=>d1,Border:()=>xB,BookmarkStart:()=>f4,BookmarkEnd:()=>x4,Bookmark:()=>g4,Body:()=>$9,BaseXmlComponent:()=>Y1,Attributes:()=>C0,AnnotationReference:()=>UZ,AlignmentType:()=>c0,AbstractNumbering:()=>E8});var{create:YU,defineProperty:QB,getOwnPropertyDescriptor:ZU,getOwnPropertyNames:QU,getPrototypeOf:JU}=Object,KU=Object.prototype.hasOwnProperty,JB=(B,U)=>()=>(B&&(U=B(B=0)),U),R0=(B,U)=>()=>(U||(B((U={exports:{}}).exports,U),B=null),U.exports),VU=(B,U,G,Y)=>{if(U&&typeof U==="object"||typeof U==="function"){for(var Q=QU(U),K=0,Z=Q.length,J;KU[M]).bind(null,J),enumerable:!(Y=ZU(U,J))||Y.enumerable})}return B},C8=(B,U,G)=>(G=B!=null?YU(JU(B)):{},VU(U||!B||!B.__esModule?QB(G,"default",{value:B,enumerable:!0}):G,B)),N1=((B)=>__require)(function(B){return __require.apply(this,arguments)});function G1(B){return G1=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(U){return typeof U}:function(U){return U&&typeof Symbol=="function"&&U.constructor===Symbol&&U!==Symbol.prototype?"symbol":typeof U},G1(B)}function qU(B,U){if(G1(B)!="object"||!B)return B;var G=B[Symbol.toPrimitive];if(G!==void 0){var Y=G.call(B,U||"default");if(G1(Y)!="object")return Y;throw TypeError("@@toPrimitive must return a primitive value.")}return(U==="string"?String:Number)(B)}function MU(B){var U=qU(B,"string");return G1(U)=="symbol"?U:U+""}function e(B,U,G){return(U=MU(U))in B?Object.defineProperty(B,U,{value:G,enumerable:!0,configurable:!0,writable:!0}):B[U]=G,B}var Y1=class{constructor(B){e(this,"rootKey",void 0),this.rootKey=B}},KB=Object.seal({}),t=class extends Y1{constructor(B){super(B);e(this,"root",void 0),this.root=[]}prepForXml(B){var U;B.stack.push(this);let G=this.root.map((Y)=>{if(Y instanceof Y1)return Y.prepForXml(B);return Y}).filter((Y)=>Y!==void 0);return B.stack.pop(),{[this.rootKey]:G.length?G.length===1&&((U=G[0])===null||U===void 0?void 0:U._attr)?G[0]:G:KB}}addChildElement(B){return this.root.push(B),this}},R2=class extends t{constructor(B,U){super(B);e(this,"includeIfEmpty",void 0),this.includeIfEmpty=U}prepForXml(B){let U=super.prepForXml(B);if(this.includeIfEmpty)return U;if(U&&(typeof U[this.rootKey]!=="object"||Object.keys(U[this.rootKey]).length))return U}};function u6(B,U){var G=Object.keys(B);if(Object.getOwnPropertySymbols){var Y=Object.getOwnPropertySymbols(B);U&&(Y=Y.filter(function(Q){return Object.getOwnPropertyDescriptor(B,Q).enumerable})),G.push.apply(G,Y)}return G}function L0(B){for(var U=1;U{if(Y!==void 0){let Q=this.xmlKeys&&this.xmlKeys[G]||G;U[Q]=Y}}),{_attr:U}}},k8=class extends Y1{constructor(B){super("_attr");e(this,"root",void 0),this.root=B}prepForXml(B){return{_attr:Object.values(this.root).filter(({value:U})=>U!==void 0).reduce((U,{key:G,value:Y})=>L0(L0({},U),{},{[G]:Y}),{})}}},C0=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{val:"w:val",color:"w:color",fill:"w:fill",space:"w:space",sz:"w:sz",type:"w:type",rsidR:"w:rsidR",rsidRPr:"w:rsidRPr",rsidSect:"w:rsidSect",w:"w:w",h:"w:h",top:"w:top",right:"w:right",bottom:"w:bottom",left:"w:left",header:"w:header",footer:"w:footer",gutter:"w:gutter",linePitch:"w:linePitch",pos:"w:pos"})}},$8=R0((B,U)=>{var G=typeof Reflect==="object"?Reflect:null,Y=G&&typeof G.apply==="function"?G.apply:function($,x,N){return Function.prototype.apply.call($,x,N)},Q;if(G&&typeof G.ownKeys==="function")Q=G.ownKeys;else if(Object.getOwnPropertySymbols)Q=function($){return Object.getOwnPropertyNames($).concat(Object.getOwnPropertySymbols($))};else Q=function($){return Object.getOwnPropertyNames($)};function K(X){if(console&&console.warn)console.warn(X)}var Z=Number.isNaN||function($){return $!==$};function J(){J.init.call(this)}U.exports=J,U.exports.once=v,J.EventEmitter=J,J.prototype._events=void 0,J.prototype._eventsCount=0,J.prototype._maxListeners=void 0;var M=10;function W(X){if(typeof X!=="function")throw TypeError('The "listener" argument must be of type Function. Received type '+typeof X)}Object.defineProperty(J,"defaultMaxListeners",{enumerable:!0,get:function(){return M},set:function(X){if(typeof X!=="number"||X<0||Z(X))throw RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+X+".");M=X}}),J.init=function(){if(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)this._events=Object.create(null),this._eventsCount=0;this._maxListeners=this._maxListeners||void 0},J.prototype.setMaxListeners=function($){if(typeof $!=="number"||$<0||Z($))throw RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+$+".");return this._maxListeners=$,this};function I(X){if(X._maxListeners===void 0)return J.defaultMaxListeners;return X._maxListeners}J.prototype.getMaxListeners=function(){return I(this)},J.prototype.emit=function($){var x=[];for(var N=1;N0)b=x[0];if(b instanceof Error)throw b;var c=Error("Unhandled error."+(b?" ("+b.message+")":""));throw c.context=b,c}var T=U0[$];if(T===void 0)return!1;if(typeof T==="function")Y(T,this,x);else{var m=T.length,B0=E(T,m);for(var N=0;N0&&b.length>a&&!b.warned){b.warned=!0;var c=Error("Possible EventEmitter memory leak detected. "+b.length+" "+String($)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=X,c.type=$,c.count=b.length,K(c)}}return X}J.prototype.addListener=function($,x){return F(this,$,x,!1)},J.prototype.on=J.prototype.addListener,J.prototype.prependListener=function($,x){return F(this,$,x,!0)};function D(){if(!this.fired){if(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0)return this.listener.call(this.target);return this.listener.apply(this.target,arguments)}}function w(X,$,x){var N={fired:!1,wrapFn:void 0,target:X,type:$,listener:x},a=D.bind(N);return a.listener=x,N.wrapFn=a,a}J.prototype.once=function($,x){return W(x),this.on($,w(this,$,x)),this},J.prototype.prependOnceListener=function($,x){return W(x),this.prependListener($,w(this,$,x)),this},J.prototype.removeListener=function($,x){var N,a,U0,b,c;if(W(x),a=this._events,a===void 0)return this;if(N=a[$],N===void 0)return this;if(N===x||N.listener===x){if(--this._eventsCount===0)this._events=Object.create(null);else if(delete a[$],a.removeListener)this.emit("removeListener",$,N.listener||x)}else if(typeof N!=="function"){U0=-1;for(b=N.length-1;b>=0;b--)if(N[b]===x||N[b].listener===x){c=N[b].listener,U0=b;break}if(U0<0)return this;if(U0===0)N.shift();else C(N,U0);if(N.length===1)a[$]=N[0];if(a.removeListener!==void 0)this.emit("removeListener",$,c||x)}return this},J.prototype.off=J.prototype.removeListener,J.prototype.removeAllListeners=function($){var x,N=this._events,a;if(N===void 0)return this;if(N.removeListener===void 0){if(arguments.length===0)this._events=Object.create(null),this._eventsCount=0;else if(N[$]!==void 0)if(--this._eventsCount===0)this._events=Object.create(null);else delete N[$];return this}if(arguments.length===0){var U0=Object.keys(N),b;for(a=0;a=0;a--)this.removeListener($,x[a]);return this};function P(X,$,x){var N=X._events;if(N===void 0)return[];var a=N[$];if(a===void 0)return[];if(typeof a==="function")return x?[a.listener||a]:[a];return x?j(a):E(a,a.length)}J.prototype.listeners=function($){return P(this,$,!0)},J.prototype.rawListeners=function($){return P(this,$,!1)},J.listenerCount=function(X,$){if(typeof X.listenerCount==="function")return X.listenerCount($);else return A.call(X,$)},J.prototype.listenerCount=A;function A(X){var $=this._events;if($!==void 0){var x=$[X];if(typeof x==="function")return 1;else if(x!==void 0)return x.length}return 0}J.prototype.eventNames=function(){return this._eventsCount>0?Q(this._events):[]};function E(X,$){var x=Array($);for(var N=0;N<$;++N)x[N]=X[N];return x}function C(X,$){for(;$+1{if(typeof Object.create==="function")U.exports=function(Y,Q){if(Q)Y.super_=Q,Y.prototype=Object.create(Q.prototype,{constructor:{value:Y,enumerable:!1,writable:!0,configurable:!0}})};else U.exports=function(Y,Q){if(Q){Y.super_=Q;var K=function(){};K.prototype=Q.prototype,Y.prototype=new K,Y.prototype.constructor=Y}}}),v0,d2=JB(()=>{v0=globalThis||self});function XU(B){return B&&B.__esModule&&Object.prototype.hasOwnProperty.call(B,"default")?B.default:B}function I8(){throw Error("setTimeout has not been defined")}function O8(){throw Error("clearTimeout has not been defined")}function VB(B){if(n0===setTimeout)return setTimeout(B,0);if((n0===I8||!n0)&&setTimeout)return n0=setTimeout,setTimeout(B,0);try{return n0(B,0)}catch(U){try{return n0.call(null,B,0)}catch(G){return n0.call(this,B,0)}}}function RU(B){if(s0===clearTimeout)return clearTimeout(B);if((s0===O8||!s0)&&clearTimeout)return s0=clearTimeout,clearTimeout(B);try{return s0(B)}catch(U){try{return s0.call(null,B)}catch(G){return s0.call(this,B)}}}function LU(){if(!T2||!E2)return;if(T2=!1,E2.length)o0=E2.concat(o0);else B1=-1;if(o0.length)qB()}function qB(){if(T2)return;var B=VB(LU);T2=!0;var U=o0.length;while(U){E2=o0,o0=[];while(++B1{Q8={exports:{}},j0=Q8.exports={},function(){try{if(typeof setTimeout==="function")n0=setTimeout;else n0=I8}catch(B){n0=I8}try{if(typeof clearTimeout==="function")s0=clearTimeout;else s0=O8}catch(B){s0=O8}}(),o0=[],T2=!1,B1=-1,j0.nextTick=function(B){var U=Array(arguments.length-1);if(arguments.length>1)for(var G=1;G{U.exports=$8().EventEmitter}),IU=R0((B)=>{B.byteLength=M,B.toByteArray=I,B.fromByteArray=w;var U=[],G=[],Y=typeof Uint8Array<"u"?Uint8Array:Array,Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var K=0,Z=Q.length;K0)throw Error("Invalid string. Length must be a multiple of 4");var E=P.indexOf("=");if(E===-1)E=A;var C=E===A?0:4-E%4;return[E,C]}function M(P){var A=J(P),E=A[0],C=A[1];return(E+C)*3/4-C}function W(P,A,E){return(A+E)*3/4-E}function I(P){var A,E=J(P),C=E[0],j=E[1],v=new Y(W(P,C,j)),S=0,H=j>0?C-4:C,X;for(X=0;X>16&255,v[S++]=A>>8&255,v[S++]=A&255;if(j===2)A=G[P.charCodeAt(X)]<<2|G[P.charCodeAt(X+1)]>>4,v[S++]=A&255;if(j===1)A=G[P.charCodeAt(X)]<<10|G[P.charCodeAt(X+1)]<<4|G[P.charCodeAt(X+2)]>>2,v[S++]=A>>8&255,v[S++]=A&255;return v}function F(P){return U[P>>18&63]+U[P>>12&63]+U[P>>6&63]+U[P&63]}function D(P,A,E){var C,j=[];for(var v=A;vH?H:S+v));if(C===1)A=P[E-1],j.push(U[A>>2]+U[A<<4&63]+"==");else if(C===2)A=(P[E-2]<<8)+P[E-1],j.push(U[A>>10]+U[A>>4&63]+U[A<<2&63]+"=");return j.join("")}}),OU=R0((B)=>{/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */B.read=function(U,G,Y,Q,K){var Z,J,M=K*8-Q-1,W=(1<>1,F=-7,D=Y?K-1:0,w=Y?-1:1,P=U[G+D];D+=w,Z=P&(1<<-F)-1,P>>=-F,F+=M;for(;F>0;Z=Z*256+U[G+D],D+=w,F-=8);J=Z&(1<<-F)-1,Z>>=-F,F+=Q;for(;F>0;J=J*256+U[G+D],D+=w,F-=8);if(Z===0)Z=1-I;else if(Z===W)return J?NaN:(P?-1:1)*(1/0);else J=J+Math.pow(2,Q),Z=Z-I;return(P?-1:1)*J*Math.pow(2,Z-Q)},B.write=function(U,G,Y,Q,K,Z){var J,M,W,I=Z*8-K-1,F=(1<>1,w=K===23?Math.pow(2,-24)-Math.pow(2,-77):0,P=Q?0:Z-1,A=Q?1:-1,E=G<0||G===0&&1/G<0?1:0;if(G=Math.abs(G),isNaN(G)||G===1/0)M=isNaN(G)?1:0,J=F;else{if(J=Math.floor(Math.log(G)/Math.LN2),G*(W=Math.pow(2,-J))<1)J--,W*=2;if(J+D>=1)G+=w/W;else G+=w*Math.pow(2,1-D);if(G*W>=2)J++,W/=2;if(J+D>=F)M=0,J=F;else if(J+D>=1)M=(G*W-1)*Math.pow(2,K),J=J+D;else M=G*Math.pow(2,D-1)*Math.pow(2,K),J=0}for(;K>=8;U[Y+P]=M&255,P+=A,M/=256,K-=8);J=J<0;U[Y+P]=J&255,P+=A,J/=256,I-=8);U[Y+P-A]|=E*128}});/*! +* The buffer module from node.js, for the browser. +* +* @author Feross Aboukhadijeh +* @license MIT +*/var g1=R0((B)=>{var U=IU(),G=OU(),Y=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null;B.Buffer=J,B.SlowBuffer=j,B.INSPECT_MAX_BYTES=50;var Q=2147483647;if(B.kMaxLength=Q,J.TYPED_ARRAY_SUPPORT=K(),!J.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error==="function")console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function K(){try{var k=new Uint8Array(1),V={foo:function(){return 42}};return Object.setPrototypeOf(V,Uint8Array.prototype),Object.setPrototypeOf(k,V),k.foo()===42}catch(q){return!1}}Object.defineProperty(J.prototype,"parent",{enumerable:!0,get:function(){if(!J.isBuffer(this))return;return this.buffer}}),Object.defineProperty(J.prototype,"offset",{enumerable:!0,get:function(){if(!J.isBuffer(this))return;return this.byteOffset}});function Z(k){if(k>Q)throw RangeError('The value "'+k+'" is invalid for option "size"');var V=new Uint8Array(k);return Object.setPrototypeOf(V,J.prototype),V}function J(k,V,q){if(typeof k==="number"){if(typeof V==="string")throw TypeError('The "string" argument must be of type string. Received type number');return F(k)}return M(k,V,q)}J.poolSize=8192;function M(k,V,q){if(typeof k==="string")return D(k,V);if(ArrayBuffer.isView(k))return P(k);if(k==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof k);if(f(k,ArrayBuffer)||k&&f(k.buffer,ArrayBuffer))return A(k,V,q);if(typeof SharedArrayBuffer<"u"&&(f(k,SharedArrayBuffer)||k&&f(k.buffer,SharedArrayBuffer)))return A(k,V,q);if(typeof k==="number")throw TypeError('The "value" argument must not be of type number. Received type number');var O=k.valueOf&&k.valueOf();if(O!=null&&O!==k)return J.from(O,V,q);var _=E(k);if(_)return _;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof k[Symbol.toPrimitive]==="function")return J.from(k[Symbol.toPrimitive]("string"),V,q);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof k)}J.from=function(k,V,q){return M(k,V,q)},Object.setPrototypeOf(J.prototype,Uint8Array.prototype),Object.setPrototypeOf(J,Uint8Array);function W(k){if(typeof k!=="number")throw TypeError('"size" argument must be of type number');else if(k<0)throw RangeError('The value "'+k+'" is invalid for option "size"')}function I(k,V,q){if(W(k),k<=0)return Z(k);if(V!==void 0)return typeof q==="string"?Z(k).fill(V,q):Z(k).fill(V);return Z(k)}J.alloc=function(k,V,q){return I(k,V,q)};function F(k){return W(k),Z(k<0?0:C(k)|0)}J.allocUnsafe=function(k){return F(k)},J.allocUnsafeSlow=function(k){return F(k)};function D(k,V){if(typeof V!=="string"||V==="")V="utf8";if(!J.isEncoding(V))throw TypeError("Unknown encoding: "+V);var q=v(k,V)|0,O=Z(q),_=O.write(k,V);if(_!==q)O=O.slice(0,_);return O}function w(k){var V=k.length<0?0:C(k.length)|0,q=Z(V);for(var O=0;O=Q)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Q.toString(16)+" bytes");return k|0}function j(k){if(+k!=k)k=0;return J.alloc(+k)}J.isBuffer=function(V){return V!=null&&V._isBuffer===!0&&V!==J.prototype},J.compare=function(V,q){if(f(V,Uint8Array))V=J.from(V,V.offset,V.byteLength);if(f(q,Uint8Array))q=J.from(q,q.offset,q.byteLength);if(!J.isBuffer(V)||!J.isBuffer(q))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(V===q)return 0;var O=V.length,_=q.length;for(var l=0,d=Math.min(O,_);l_.length)J.from(d).copy(_,l);else Uint8Array.prototype.set.call(_,d,l);else if(!J.isBuffer(d))throw TypeError('"list" argument must be an Array of Buffers');else d.copy(_,l);l+=d.length}return _};function v(k,V){if(J.isBuffer(k))return k.length;if(ArrayBuffer.isView(k)||f(k,ArrayBuffer))return k.byteLength;if(typeof k!=="string")throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof k);var q=k.length,O=arguments.length>2&&arguments[2]===!0;if(!O&&q===0)return 0;var _=!1;for(;;)switch(V){case"ascii":case"latin1":case"binary":return q;case"utf8":case"utf-8":return L(k).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q*2;case"hex":return q>>>1;case"base64":return Z0(k).length;default:if(_)return O?-1:L(k).length;V=(""+V).toLowerCase(),_=!0}}J.byteLength=v;function S(k,V,q){var O=!1;if(V===void 0||V<0)V=0;if(V>this.length)return"";if(q===void 0||q>this.length)q=this.length;if(q<=0)return"";if(q>>>=0,V>>>=0,q<=V)return"";if(!k)k="utf8";while(!0)switch(k){case"hex":return s(this,V,q);case"utf8":case"utf-8":return T(this,V,q);case"ascii":return i(this,V,q);case"latin1":case"binary":return V0(this,V,q);case"base64":return c(this,V,q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G0(this,V,q);default:if(O)throw TypeError("Unknown encoding: "+k);k=(k+"").toLowerCase(),O=!0}}J.prototype._isBuffer=!0;function H(k,V,q){var O=k[V];k[V]=k[q],k[q]=O}if(J.prototype.swap16=function(){var V=this.length;if(V%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var q=0;qq)V+=" ... ";return""},Y)J.prototype[Y]=J.prototype.inspect;J.prototype.compare=function(V,q,O,_,l){if(f(V,Uint8Array))V=J.from(V,V.offset,V.byteLength);if(!J.isBuffer(V))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof V);if(q===void 0)q=0;if(O===void 0)O=V?V.length:0;if(_===void 0)_=0;if(l===void 0)l=this.length;if(q<0||O>V.length||_<0||l>this.length)throw RangeError("out of range index");if(_>=l&&q>=O)return 0;if(_>=l)return-1;if(q>=O)return 1;if(q>>>=0,O>>>=0,_>>>=0,l>>>=0,this===V)return 0;var d=l-_,Q0=O-q,q0=Math.min(d,Q0),K0=this.slice(_,l),I0=V.slice(q,O);for(var H0=0;H02147483647)q=2147483647;else if(q<-2147483648)q=-2147483648;if(q=+q,R(q))q=_?0:k.length-1;if(q<0)q=k.length+q;if(q>=k.length)if(_)return-1;else q=k.length-1;else if(q<0)if(_)q=0;else return-1;if(typeof V==="string")V=J.from(V,O);if(J.isBuffer(V)){if(V.length===0)return-1;return $(k,V,q,O,_)}else if(typeof V==="number"){if(V=V&255,typeof Uint8Array.prototype.indexOf==="function")if(_)return Uint8Array.prototype.indexOf.call(k,V,q);else return Uint8Array.prototype.lastIndexOf.call(k,V,q);return $(k,[V],q,O,_)}throw TypeError("val must be string, number or Buffer")}function $(k,V,q,O,_){var l=1,d=k.length,Q0=V.length;if(O!==void 0){if(O=String(O).toLowerCase(),O==="ucs2"||O==="ucs-2"||O==="utf16le"||O==="utf-16le"){if(k.length<2||V.length<2)return-1;l=2,d/=2,Q0/=2,q/=2}}function q0(k0,L2){if(l===1)return k0[L2];else return k0.readUInt16BE(L2*l)}var K0;if(_){var I0=-1;for(K0=q;K0d)q=d-Q0;for(K0=q;K0>=0;K0--){var H0=!0;for(var W0=0;W0_)O=_;var l=V.length;if(O>l/2)O=l/2;for(var d=0;d>>0,isFinite(O)){if(O=O>>>0,_===void 0)_="utf8"}else _=O,O=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var l=this.length-q;if(O===void 0||O>l)O=l;if(V.length>0&&(O<0||q<0)||q>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!_)_="utf8";var d=!1;for(;;)switch(_){case"hex":return x(this,V,q,O);case"utf8":case"utf-8":return N(this,V,q,O);case"ascii":case"latin1":case"binary":return a(this,V,q,O);case"base64":return U0(this,V,q,O);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,V,q,O);default:if(d)throw TypeError("Unknown encoding: "+_);_=(""+_).toLowerCase(),d=!0}},J.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function c(k,V,q){if(V===0&&q===k.length)return U.fromByteArray(k);else return U.fromByteArray(k.slice(V,q))}function T(k,V,q){q=Math.min(k.length,q);var O=[],_=V;while(_239?4:l>223?3:l>191?2:1;if(_+Q0<=q){var q0,K0,I0,H0;switch(Q0){case 1:if(l<128)d=l;break;case 2:if(q0=k[_+1],(q0&192)===128){if(H0=(l&31)<<6|q0&63,H0>127)d=H0}break;case 3:if(q0=k[_+1],K0=k[_+2],(q0&192)===128&&(K0&192)===128){if(H0=(l&15)<<12|(q0&63)<<6|K0&63,H0>2047&&(H0<55296||H0>57343))d=H0}break;case 4:if(q0=k[_+1],K0=k[_+2],I0=k[_+3],(q0&192)===128&&(K0&192)===128&&(I0&192)===128){if(H0=(l&15)<<18|(q0&63)<<12|(K0&63)<<6|I0&63,H0>65535&&H0<1114112)d=H0}}}if(d===null)d=65533,Q0=1;else if(d>65535)d-=65536,O.push(d>>>10&1023|55296),d=56320|d&1023;O.push(d),_+=Q0}return B0(O)}var m=4096;function B0(k){var V=k.length;if(V<=m)return String.fromCharCode.apply(String,k);var q="",O=0;while(OO)q=O;var _="";for(var l=V;lO)V=O;if(q<0){if(q+=O,q<0)q=0}else if(q>O)q=O;if(qq)throw RangeError("Trying to access beyond buffer length")}J.prototype.readUintLE=J.prototype.readUIntLE=function(V,q,O){if(V=V>>>0,q=q>>>0,!O)r(V,q,this.length);var _=this[V],l=1,d=0;while(++d>>0,q=q>>>0,!O)r(V,q,this.length);var _=this[V+--q],l=1;while(q>0&&(l*=256))_+=this[V+--q]*l;return _},J.prototype.readUint8=J.prototype.readUInt8=function(V,q){if(V=V>>>0,!q)r(V,1,this.length);return this[V]},J.prototype.readUint16LE=J.prototype.readUInt16LE=function(V,q){if(V=V>>>0,!q)r(V,2,this.length);return this[V]|this[V+1]<<8},J.prototype.readUint16BE=J.prototype.readUInt16BE=function(V,q){if(V=V>>>0,!q)r(V,2,this.length);return this[V]<<8|this[V+1]},J.prototype.readUint32LE=J.prototype.readUInt32LE=function(V,q){if(V=V>>>0,!q)r(V,4,this.length);return(this[V]|this[V+1]<<8|this[V+2]<<16)+this[V+3]*16777216},J.prototype.readUint32BE=J.prototype.readUInt32BE=function(V,q){if(V=V>>>0,!q)r(V,4,this.length);return this[V]*16777216+(this[V+1]<<16|this[V+2]<<8|this[V+3])},J.prototype.readIntLE=function(V,q,O){if(V=V>>>0,q=q>>>0,!O)r(V,q,this.length);var _=this[V],l=1,d=0;while(++d=l)_-=Math.pow(2,8*q);return _},J.prototype.readIntBE=function(V,q,O){if(V=V>>>0,q=q>>>0,!O)r(V,q,this.length);var _=q,l=1,d=this[V+--_];while(_>0&&(l*=256))d+=this[V+--_]*l;if(l*=128,d>=l)d-=Math.pow(2,8*q);return d},J.prototype.readInt8=function(V,q){if(V=V>>>0,!q)r(V,1,this.length);if(!(this[V]&128))return this[V];return(255-this[V]+1)*-1},J.prototype.readInt16LE=function(V,q){if(V=V>>>0,!q)r(V,2,this.length);var O=this[V]|this[V+1]<<8;return O&32768?O|4294901760:O},J.prototype.readInt16BE=function(V,q){if(V=V>>>0,!q)r(V,2,this.length);var O=this[V+1]|this[V]<<8;return O&32768?O|4294901760:O},J.prototype.readInt32LE=function(V,q){if(V=V>>>0,!q)r(V,4,this.length);return this[V]|this[V+1]<<8|this[V+2]<<16|this[V+3]<<24},J.prototype.readInt32BE=function(V,q){if(V=V>>>0,!q)r(V,4,this.length);return this[V]<<24|this[V+1]<<16|this[V+2]<<8|this[V+3]},J.prototype.readFloatLE=function(V,q){if(V=V>>>0,!q)r(V,4,this.length);return G.read(this,V,!0,23,4)},J.prototype.readFloatBE=function(V,q){if(V=V>>>0,!q)r(V,4,this.length);return G.read(this,V,!1,23,4)},J.prototype.readDoubleLE=function(V,q){if(V=V>>>0,!q)r(V,8,this.length);return G.read(this,V,!0,52,8)},J.prototype.readDoubleBE=function(V,q){if(V=V>>>0,!q)r(V,8,this.length);return G.read(this,V,!1,52,8)};function y(k,V,q,O,_,l){if(!J.isBuffer(k))throw TypeError('"buffer" argument must be a Buffer instance');if(V>_||Vk.length)throw RangeError("Index out of range")}J.prototype.writeUintLE=J.prototype.writeUIntLE=function(V,q,O,_){if(V=+V,q=q>>>0,O=O>>>0,!_){var l=Math.pow(2,8*O)-1;y(this,V,q,O,l,0)}var d=1,Q0=0;this[q]=V&255;while(++Q0>>0,O=O>>>0,!_){var l=Math.pow(2,8*O)-1;y(this,V,q,O,l,0)}var d=O-1,Q0=1;this[q+d]=V&255;while(--d>=0&&(Q0*=256))this[q+d]=V/Q0&255;return q+O},J.prototype.writeUint8=J.prototype.writeUInt8=function(V,q,O){if(V=+V,q=q>>>0,!O)y(this,V,q,1,255,0);return this[q]=V&255,q+1},J.prototype.writeUint16LE=J.prototype.writeUInt16LE=function(V,q,O){if(V=+V,q=q>>>0,!O)y(this,V,q,2,65535,0);return this[q]=V&255,this[q+1]=V>>>8,q+2},J.prototype.writeUint16BE=J.prototype.writeUInt16BE=function(V,q,O){if(V=+V,q=q>>>0,!O)y(this,V,q,2,65535,0);return this[q]=V>>>8,this[q+1]=V&255,q+2},J.prototype.writeUint32LE=J.prototype.writeUInt32LE=function(V,q,O){if(V=+V,q=q>>>0,!O)y(this,V,q,4,4294967295,0);return this[q+3]=V>>>24,this[q+2]=V>>>16,this[q+1]=V>>>8,this[q]=V&255,q+4},J.prototype.writeUint32BE=J.prototype.writeUInt32BE=function(V,q,O){if(V=+V,q=q>>>0,!O)y(this,V,q,4,4294967295,0);return this[q]=V>>>24,this[q+1]=V>>>16,this[q+2]=V>>>8,this[q+3]=V&255,q+4},J.prototype.writeIntLE=function(V,q,O,_){if(V=+V,q=q>>>0,!_){var l=Math.pow(2,8*O-1);y(this,V,q,O,l-1,-l)}var d=0,Q0=1,q0=0;this[q]=V&255;while(++d>0)-q0&255}return q+O},J.prototype.writeIntBE=function(V,q,O,_){if(V=+V,q=q>>>0,!_){var l=Math.pow(2,8*O-1);y(this,V,q,O,l-1,-l)}var d=O-1,Q0=1,q0=0;this[q+d]=V&255;while(--d>=0&&(Q0*=256)){if(V<0&&q0===0&&this[q+d+1]!==0)q0=1;this[q+d]=(V/Q0>>0)-q0&255}return q+O},J.prototype.writeInt8=function(V,q,O){if(V=+V,q=q>>>0,!O)y(this,V,q,1,127,-128);if(V<0)V=255+V+1;return this[q]=V&255,q+1},J.prototype.writeInt16LE=function(V,q,O){if(V=+V,q=q>>>0,!O)y(this,V,q,2,32767,-32768);return this[q]=V&255,this[q+1]=V>>>8,q+2},J.prototype.writeInt16BE=function(V,q,O){if(V=+V,q=q>>>0,!O)y(this,V,q,2,32767,-32768);return this[q]=V>>>8,this[q+1]=V&255,q+2},J.prototype.writeInt32LE=function(V,q,O){if(V=+V,q=q>>>0,!O)y(this,V,q,4,2147483647,-2147483648);return this[q]=V&255,this[q+1]=V>>>8,this[q+2]=V>>>16,this[q+3]=V>>>24,q+4},J.prototype.writeInt32BE=function(V,q,O){if(V=+V,q=q>>>0,!O)y(this,V,q,4,2147483647,-2147483648);if(V<0)V=4294967295+V+1;return this[q]=V>>>24,this[q+1]=V>>>16,this[q+2]=V>>>8,this[q+3]=V&255,q+4};function n(k,V,q,O,_,l){if(q+O>k.length)throw RangeError("Index out of range");if(q<0)throw RangeError("Index out of range")}function o(k,V,q,O,_){if(V=+V,q=q>>>0,!_)n(k,V,q,4,340282346638528860000000000000000000000,-340282346638528860000000000000000000000);return G.write(k,V,q,O,23,4),q+4}J.prototype.writeFloatLE=function(V,q,O){return o(this,V,q,!0,O)},J.prototype.writeFloatBE=function(V,q,O){return o(this,V,q,!1,O)};function Y0(k,V,q,O,_){if(V=+V,q=q>>>0,!_)n(k,V,q,8,179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);return G.write(k,V,q,O,52,8),q+8}J.prototype.writeDoubleLE=function(V,q,O){return Y0(this,V,q,!0,O)},J.prototype.writeDoubleBE=function(V,q,O){return Y0(this,V,q,!1,O)},J.prototype.copy=function(V,q,O,_){if(!J.isBuffer(V))throw TypeError("argument should be a Buffer");if(!O)O=0;if(!_&&_!==0)_=this.length;if(q>=V.length)q=V.length;if(!q)q=0;if(_>0&&_=this.length)throw RangeError("Index out of range");if(_<0)throw RangeError("sourceEnd out of bounds");if(_>this.length)_=this.length;if(V.length-q<_-O)_=V.length-q+O;var l=_-O;if(this===V&&typeof Uint8Array.prototype.copyWithin==="function")this.copyWithin(q,O,_);else Uint8Array.prototype.set.call(V,this.subarray(O,_),q);return l},J.prototype.fill=function(V,q,O,_){if(typeof V==="string"){if(typeof q==="string")_=q,q=0,O=this.length;else if(typeof O==="string")_=O,O=this.length;if(_!==void 0&&typeof _!=="string")throw TypeError("encoding must be a string");if(typeof _==="string"&&!J.isEncoding(_))throw TypeError("Unknown encoding: "+_);if(V.length===1){var l=V.charCodeAt(0);if(_==="utf8"&&l<128||_==="latin1")V=l}}else if(typeof V==="number")V=V&255;else if(typeof V==="boolean")V=Number(V);if(q<0||this.length>>0,O=O===void 0?this.length:O>>>0,!V)V=0;var d;if(typeof V==="number")for(d=q;d55295&&q<57344){if(!_){if(q>56319){if((V-=3)>-1)l.push(239,191,189);continue}else if(d+1===O){if((V-=3)>-1)l.push(239,191,189);continue}_=q;continue}if(q<56320){if((V-=3)>-1)l.push(239,191,189);_=q;continue}q=(_-55296<<10|q-56320)+65536}else if(_){if((V-=3)>-1)l.push(239,191,189)}if(_=null,q<128){if((V-=1)<0)break;l.push(q)}else if(q<2048){if((V-=2)<0)break;l.push(q>>6|192,q&63|128)}else if(q<65536){if((V-=3)<0)break;l.push(q>>12|224,q>>6&63|128,q&63|128)}else if(q<1114112){if((V-=4)<0)break;l.push(q>>18|240,q>>12&63|128,q>>6&63|128,q&63|128)}else throw Error("Invalid code point")}return l}function u(k){var V=[];for(var q=0;q>8,_=q%256,l.push(_),l.push(O)}return l}function Z0(k){return U.toByteArray(z(k))}function g(k,V,q,O){for(var _=0;_=V.length||_>=k.length)break;V[_+q]=k[_]}return _}function f(k,V){return k instanceof V||k!=null&&k.constructor!=null&&k.constructor.name!=null&&k.constructor.name===V.name}function R(k){return k!==k}var p=function(){var k="0123456789abcdef",V=Array(256);for(var q=0;q<16;++q){var O=q*16;for(var _=0;_<16;++_)V[O+_]=k[q]+k[_]}return V}()}),XB=R0((B,U)=>{U.exports=function(){if(typeof Symbol!=="function"||typeof Object.getOwnPropertySymbols!=="function")return!1;if(typeof Symbol.iterator==="symbol")return!0;var Y={},Q=Symbol("test"),K=Object(Q);if(typeof Q==="string")return!1;if(Object.prototype.toString.call(Q)!=="[object Symbol]")return!1;if(Object.prototype.toString.call(K)!=="[object Symbol]")return!1;var Z=42;Y[Q]=Z;for(var J in Y)return!1;if(typeof Object.keys==="function"&&Object.keys(Y).length!==0)return!1;if(typeof Object.getOwnPropertyNames==="function"&&Object.getOwnPropertyNames(Y).length!==0)return!1;var M=Object.getOwnPropertySymbols(Y);if(M.length!==1||M[0]!==Q)return!1;if(!Object.prototype.propertyIsEnumerable.call(Y,Q))return!1;if(typeof Object.getOwnPropertyDescriptor==="function"){var W=Object.getOwnPropertyDescriptor(Y,Q);if(W.value!==Z||W.enumerable!==!0)return!1}return!0}}),S8=R0((B,U)=>{var G=XB();U.exports=function(){return G()&&!!Symbol.toStringTag}}),RB=R0((B,U)=>{U.exports=Object}),FU=R0((B,U)=>{U.exports=Error}),HU=R0((B,U)=>{U.exports=EvalError}),WU=R0((B,U)=>{U.exports=RangeError}),PU=R0((B,U)=>{U.exports=ReferenceError}),LB=R0((B,U)=>{U.exports=SyntaxError}),f1=R0((B,U)=>{U.exports=TypeError}),wU=R0((B,U)=>{U.exports=URIError}),AU=R0((B,U)=>{U.exports=Math.abs}),jU=R0((B,U)=>{U.exports=Math.floor}),NU=R0((B,U)=>{U.exports=Math.max}),zU=R0((B,U)=>{U.exports=Math.min}),EU=R0((B,U)=>{U.exports=Math.pow}),TU=R0((B,U)=>{U.exports=Math.round}),DU=R0((B,U)=>{U.exports=Number.isNaN||function(Y){return Y!==Y}}),CU=R0((B,U)=>{var G=DU();U.exports=function(Q){if(G(Q)||Q===0)return Q;return Q<0?-1:1}}),kU=R0((B,U)=>{U.exports=Object.getOwnPropertyDescriptor}),K1=R0((B,U)=>{var G=kU();if(G)try{G([],"length")}catch(Y){G=null}U.exports=G}),x1=R0((B,U)=>{var G=Object.defineProperty||!1;if(G)try{G({},"a",{value:1})}catch(Y){G=!1}U.exports=G}),$U=R0((B,U)=>{var G=typeof Symbol<"u"&&Symbol,Y=XB();U.exports=function(){if(typeof G!=="function")return!1;if(typeof Symbol!=="function")return!1;if(typeof G("foo")!=="symbol")return!1;if(typeof Symbol("bar")!=="symbol")return!1;return Y()}}),IB=R0((B,U)=>{U.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null}),OB=R0((B,U)=>{U.exports=RB().getPrototypeOf||null}),SU=R0((B,U)=>{var G="Function.prototype.bind called on incompatible ",Y=Object.prototype.toString,Q=Math.max,K="[object Function]",Z=function(I,F){var D=[];for(var w=0;w{var G=SU();U.exports=Function.prototype.bind||G}),b8=R0((B,U)=>{U.exports=Function.prototype.call}),v8=R0((B,U)=>{U.exports=Function.prototype.apply}),bU=R0((B,U)=>{U.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply}),FB=R0((B,U)=>{var G=V1(),Y=v8(),Q=b8();U.exports=bU()||G.call(Q,Y)}),y8=R0((B,U)=>{var G=V1(),Y=f1(),Q=b8(),K=FB();U.exports=function(J){if(J.length<1||typeof J[0]!=="function")throw new Y("a function is required");return K(G,Q,J)}}),vU=R0((B,U)=>{var G=y8(),Y=K1(),Q;try{Q=[].__proto__===Array.prototype}catch(M){if(!M||typeof M!=="object"||!("code"in M)||M.code!=="ERR_PROTO_ACCESS")throw M}var K=!!Q&&Y&&Y(Object.prototype,"__proto__"),Z=Object,J=Z.getPrototypeOf;U.exports=K&&typeof K.get==="function"?G([K.get]):typeof J==="function"?function(W){return J(W==null?W:Z(W))}:!1}),HB=R0((B,U)=>{var G=IB(),Y=OB(),Q=vU();U.exports=G?function(Z){return G(Z)}:Y?function(Z){if(!Z||typeof Z!=="object"&&typeof Z!=="function")throw TypeError("getProto: not an object");return Y(Z)}:Q?function(Z){return Q(Z)}:null}),yU=R0((B,U)=>{var G=Function.prototype.call,Y=Object.prototype.hasOwnProperty;U.exports=V1().call(G,Y)}),WB=R0((B,U)=>{var G,Y=RB(),Q=FU(),K=HU(),Z=WU(),J=PU(),M=LB(),W=f1(),I=wU(),F=AU(),D=jU(),w=NU(),P=zU(),A=EU(),E=TU(),C=CU(),j=Function,v=function(h){try{return j('"use strict"; return ('+h+").constructor;")()}catch(Z0){}},S=K1(),H=x1(),X=function(){throw new W},$=S?function(){try{return arguments.callee,X}catch(h){try{return S(arguments,"callee").get}catch(Z0){return X}}}():X,x=$U()(),N=HB(),a=OB(),U0=IB(),b=v8(),c=b8(),T={},m=typeof Uint8Array>"u"||!N?G:N(Uint8Array),B0={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?G:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?G:ArrayBuffer,"%ArrayIteratorPrototype%":x&&N?N([][Symbol.iterator]()):G,"%AsyncFromSyncIteratorPrototype%":G,"%AsyncFunction%":T,"%AsyncGenerator%":T,"%AsyncGeneratorFunction%":T,"%AsyncIteratorPrototype%":T,"%Atomics%":typeof Atomics>"u"?G:Atomics,"%BigInt%":typeof BigInt>"u"?G:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?G:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?G:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?G:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Q,"%eval%":eval,"%EvalError%":K,"%Float16Array%":typeof Float16Array>"u"?G:Float16Array,"%Float32Array%":typeof Float32Array>"u"?G:Float32Array,"%Float64Array%":typeof Float64Array>"u"?G:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?G:FinalizationRegistry,"%Function%":j,"%GeneratorFunction%":T,"%Int8Array%":typeof Int8Array>"u"?G:Int8Array,"%Int16Array%":typeof Int16Array>"u"?G:Int16Array,"%Int32Array%":typeof Int32Array>"u"?G:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":x&&N?N(N([][Symbol.iterator]())):G,"%JSON%":typeof JSON==="object"?JSON:G,"%Map%":typeof Map>"u"?G:Map,"%MapIteratorPrototype%":typeof Map>"u"||!x||!N?G:N(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Y,"%Object.getOwnPropertyDescriptor%":S,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?G:Promise,"%Proxy%":typeof Proxy>"u"?G:Proxy,"%RangeError%":Z,"%ReferenceError%":J,"%Reflect%":typeof Reflect>"u"?G:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?G:Set,"%SetIteratorPrototype%":typeof Set>"u"||!x||!N?G:N(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?G:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":x&&N?N(""[Symbol.iterator]()):G,"%Symbol%":x?Symbol:G,"%SyntaxError%":M,"%ThrowTypeError%":$,"%TypedArray%":m,"%TypeError%":W,"%Uint8Array%":typeof Uint8Array>"u"?G:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?G:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?G:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?G:Uint32Array,"%URIError%":I,"%WeakMap%":typeof WeakMap>"u"?G:WeakMap,"%WeakRef%":typeof WeakRef>"u"?G:WeakRef,"%WeakSet%":typeof WeakSet>"u"?G:WeakSet,"%Function.prototype.call%":c,"%Function.prototype.apply%":b,"%Object.defineProperty%":H,"%Object.getPrototypeOf%":a,"%Math.abs%":F,"%Math.floor%":D,"%Math.max%":w,"%Math.min%":P,"%Math.pow%":A,"%Math.round%":E,"%Math.sign%":C,"%Reflect.getPrototypeOf%":U0};if(N)try{null.error}catch(h){B0["%Error.prototype%"]=N(N(h))}var i=function h(Z0){var g;if(Z0==="%AsyncFunction%")g=v("async function () {}");else if(Z0==="%GeneratorFunction%")g=v("function* () {}");else if(Z0==="%AsyncGeneratorFunction%")g=v("async function* () {}");else if(Z0==="%AsyncGenerator%"){var f=h("%AsyncGeneratorFunction%");if(f)g=f.prototype}else if(Z0==="%AsyncIteratorPrototype%"){var R=h("%AsyncGenerator%");if(R&&N)g=N(R.prototype)}return B0[Z0]=g,g},V0={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},s=V1(),G0=yU(),r=s.call(c,Array.prototype.concat),y=s.call(b,Array.prototype.splice),n=s.call(c,String.prototype.replace),o=s.call(c,String.prototype.slice),Y0=s.call(c,RegExp.prototype.exec),O0=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,z=/\\(\\)?/g,L=function(Z0){var g=o(Z0,0,1),f=o(Z0,-1);if(g==="%"&&f!=="%")throw new M("invalid intrinsic syntax, expected closing `%`");else if(f==="%"&&g!=="%")throw new M("invalid intrinsic syntax, expected opening `%`");var R=[];return n(Z0,O0,function(p,k,V,q){R[R.length]=V?n(q,z,"$1"):k||p}),R},u=function(Z0,g){var f=Z0,R;if(G0(V0,f))R=V0[f],f="%"+R[0]+"%";if(G0(B0,f)){var p=B0[f];if(p===T)p=i(f);if(typeof p>"u"&&!g)throw new W("intrinsic "+Z0+" exists, but is not available. Please file an issue!");return{alias:R,name:f,value:p}}throw new M("intrinsic "+Z0+" does not exist!")};U.exports=function(Z0,g){if(typeof Z0!=="string"||Z0.length===0)throw new W("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof g!=="boolean")throw new W('"allowMissing" argument must be a boolean');if(Y0(/^%?[^%]*%?$/,Z0)===null)throw new M("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var f=L(Z0),R=f.length>0?f[0]:"",p=u("%"+R+"%",g),k=p.name,V=p.value,q=!1,O=p.alias;if(O)R=O[0],y(f,r([0,1],O));for(var _=1,l=!0;_=f.length){var K0=S(V,d);if(l=!!K0,l&&"get"in K0&&!("originalValue"in K0.get))V=K0.get;else V=V[d]}else l=G0(V,d),V=V[d];if(l&&!q)B0[k]=V}}return V}}),PB=R0((B,U)=>{var G=WB(),Y=y8(),Q=Y([G("%String.prototype.indexOf%")]);U.exports=function(Z,J){var M=G(Z,!!J);if(typeof M==="function"&&Q(Z,".prototype.")>-1)return Y([M]);return M}}),gU=R0((B,U)=>{var G=S8()(),Y=PB()("Object.prototype.toString"),Q=function(M){if(G&&M&&typeof M==="object"&&Symbol.toStringTag in M)return!1;return Y(M)==="[object Arguments]"},K=function(M){if(Q(M))return!0;return M!==null&&typeof M==="object"&&"length"in M&&typeof M.length==="number"&&M.length>=0&&Y(M)!=="[object Array]"&&"callee"in M&&Y(M.callee)==="[object Function]"},Z=function(){return Q(arguments)}();Q.isLegacyArguments=K,U.exports=Z?Q:K}),fU=R0((B,U)=>{var G=Object.prototype.toString,Y=Function.prototype.toString,Q=/^\s*(?:function)?\*/,K=S8()(),Z=Object.getPrototypeOf,J=function(){if(!K)return!1;try{return Function("return function*() {}")()}catch(W){}},M;U.exports=function(I){if(typeof I!=="function")return!1;if(Q.test(Y.call(I)))return!0;if(!K)return G.call(I)==="[object GeneratorFunction]";if(!Z)return!1;if(typeof M>"u"){var F=J();M=F?Z(F):!1}return Z(I)===M}}),xU=R0((B,U)=>{var G=Function.prototype.toString,Y=typeof Reflect==="object"&&Reflect!==null&&Reflect.apply,Q,K;if(typeof Y==="function"&&typeof Object.defineProperty==="function")try{Q=Object.defineProperty({},"length",{get:function(){throw K}}),K={},Y(function(){throw 42},null,Q)}catch(S){if(S!==K)Y=null}else Y=null;var Z=/^\s*class\b/,J=function(H){try{var X=G.call(H);return Z.test(X)}catch($){return!1}},M=function(H){try{if(J(H))return!1;return G.call(H),!0}catch(X){return!1}},W=Object.prototype.toString,I="[object Object]",F="[object Function]",D="[object GeneratorFunction]",w="[object HTMLAllCollection]",P="[object HTML document.all class]",A="[object HTMLCollection]",E=typeof Symbol==="function"&&!!Symbol.toStringTag,C=!(0 in[,]),j=function(){return!1};if(typeof document==="object"){var v=document.all;if(W.call(v)===W.call(document.all))j=function(H){if((C||!H)&&(typeof H>"u"||typeof H==="object"))try{var X=W.call(H);return(X===w||X===P||X===A||X===I)&&H("")==null}catch($){}return!1}}U.exports=Y?function(H){if(j(H))return!0;if(!H)return!1;if(typeof H!=="function"&&typeof H!=="object")return!1;try{Y(H,null,Q)}catch(X){if(X!==K)return!1}return!J(H)&&M(H)}:function(H){if(j(H))return!0;if(!H)return!1;if(typeof H!=="function"&&typeof H!=="object")return!1;if(E)return M(H);if(J(H))return!1;var X=W.call(H);if(X!==F&&X!==D&&!/^\[object HTML/.test(X))return!1;return M(H)}}),_U=R0((B,U)=>{var G=xU(),Y=Object.prototype.toString,Q=Object.prototype.hasOwnProperty,K=function(I,F,D){for(var w=0,P=I.length;w=3)w=D;if(M(I))K(I,F,w);else if(typeof I==="string")Z(I,F,w);else J(I,F,w)}}),hU=R0((B,U)=>{U.exports=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]}),uU=R0((B,U)=>{d2();var G=hU(),Y=typeof globalThis>"u"?v0:globalThis;U.exports=function(){var K=[];for(var Z=0;Z{var G=x1(),Y=LB(),Q=f1(),K=K1();U.exports=function(J,M,W){if(!J||typeof J!=="object"&&typeof J!=="function")throw new Q("`obj` must be an object or a function`");if(typeof M!=="string"&&typeof M!=="symbol")throw new Q("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!=="boolean"&&arguments[3]!==null)throw new Q("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!=="boolean"&&arguments[4]!==null)throw new Q("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!=="boolean"&&arguments[5]!==null)throw new Q("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!=="boolean")throw new Q("`loose`, if provided, must be a boolean");var I=arguments.length>3?arguments[3]:null,F=arguments.length>4?arguments[4]:null,D=arguments.length>5?arguments[5]:null,w=arguments.length>6?arguments[6]:!1,P=!!K&&K(J,M);if(G)G(J,M,{configurable:D===null&&P?P.configurable:!D,enumerable:I===null&&P?P.enumerable:!I,value:W,writable:F===null&&P?P.writable:!F});else if(w||!I&&!F&&!D)J[M]=W;else throw new Y("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}}),cU=R0((B,U)=>{var G=x1(),Y=function(){return!!G};Y.hasArrayLengthDefineBug=function(){if(!G)return null;try{return G([],"length",{value:1}).length!==1}catch(K){return!0}},U.exports=Y}),mU=R0((B,U)=>{var G=WB(),Y=dU(),Q=cU()(),K=K1(),Z=f1(),J=G("%Math.floor%");U.exports=function(W,I){if(typeof W!=="function")throw new Z("`fn` is not a function");if(typeof I!=="number"||I<0||I>4294967295||J(I)!==I)throw new Z("`length` must be a positive 32-bit integer");var F=arguments.length>2&&!!arguments[2],D=!0,w=!0;if("length"in W&&K){var P=K(W,"length");if(P&&!P.configurable)D=!1;if(P&&!P.writable)w=!1}if(D||w||!F)if(Q)Y(W,"length",I,!0,!0);else Y(W,"length",I);return W}}),lU=R0((B,U)=>{var G=V1(),Y=v8(),Q=FB();U.exports=function(){return Q(G,Y,arguments)}}),aU=R0((B,U)=>{var G=mU(),Y=x1(),Q=y8(),K=lU();if(U.exports=function(J){var M=Q(arguments),W=J.length-(arguments.length-1);return G(M,1+(W>0?W:0),!0)},Y)Y(U.exports,"apply",{value:K});else U.exports.apply=K}),wB=R0((B,U)=>{d2();var G=_U(),Y=uU(),Q=aU(),K=PB(),Z=K1(),J=HB(),M=K("Object.prototype.toString"),W=S8()(),I=typeof globalThis>"u"?v0:globalThis,F=Y(),D=K("String.prototype.slice"),w=K("Array.prototype.indexOf",!0)||function(j,v){for(var S=0;S-1)return v;if(v!=="Object")return!1;return E(j)}if(!Z)return null;return A(j)}}),pU=R0((B,U)=>{var G=wB();U.exports=function(Q){return!!G(Q)}}),rU=R0((B)=>{var U=gU(),G=fU(),Y=wB(),Q=pU();function K(O){return O.call.bind(O)}var Z=typeof BigInt<"u",J=typeof Symbol<"u",M=K(Object.prototype.toString),W=K(Number.prototype.valueOf),I=K(String.prototype.valueOf),F=K(Boolean.prototype.valueOf);if(Z)var D=K(BigInt.prototype.valueOf);if(J)var w=K(Symbol.prototype.valueOf);function P(O,_){if(typeof O!=="object")return!1;try{return _(O),!0}catch(l){return!1}}B.isArgumentsObject=U,B.isGeneratorFunction=G,B.isTypedArray=Q;function A(O){return typeof Promise<"u"&&O instanceof Promise||O!==null&&typeof O==="object"&&typeof O.then==="function"&&typeof O.catch==="function"}B.isPromise=A;function E(O){if(typeof ArrayBuffer<"u"&&ArrayBuffer.isView)return ArrayBuffer.isView(O);return Q(O)||n(O)}B.isArrayBufferView=E;function C(O){return Y(O)==="Uint8Array"}B.isUint8Array=C;function j(O){return Y(O)==="Uint8ClampedArray"}B.isUint8ClampedArray=j;function v(O){return Y(O)==="Uint16Array"}B.isUint16Array=v;function S(O){return Y(O)==="Uint32Array"}B.isUint32Array=S;function H(O){return Y(O)==="Int8Array"}B.isInt8Array=H;function X(O){return Y(O)==="Int16Array"}B.isInt16Array=X;function $(O){return Y(O)==="Int32Array"}B.isInt32Array=$;function x(O){return Y(O)==="Float32Array"}B.isFloat32Array=x;function N(O){return Y(O)==="Float64Array"}B.isFloat64Array=N;function a(O){return Y(O)==="BigInt64Array"}B.isBigInt64Array=a;function U0(O){return Y(O)==="BigUint64Array"}B.isBigUint64Array=U0;function b(O){return M(O)==="[object Map]"}b.working=typeof Map<"u"&&b(new Map);function c(O){if(typeof Map>"u")return!1;return b.working?b(O):O instanceof Map}B.isMap=c;function T(O){return M(O)==="[object Set]"}T.working=typeof Set<"u"&&T(new Set);function m(O){if(typeof Set>"u")return!1;return T.working?T(O):O instanceof Set}B.isSet=m;function B0(O){return M(O)==="[object WeakMap]"}B0.working=typeof WeakMap<"u"&&B0(new WeakMap);function i(O){if(typeof WeakMap>"u")return!1;return B0.working?B0(O):O instanceof WeakMap}B.isWeakMap=i;function V0(O){return M(O)==="[object WeakSet]"}V0.working=typeof WeakSet<"u"&&V0(new WeakSet);function s(O){return V0(O)}B.isWeakSet=s;function G0(O){return M(O)==="[object ArrayBuffer]"}G0.working=typeof ArrayBuffer<"u"&&G0(new ArrayBuffer);function r(O){if(typeof ArrayBuffer>"u")return!1;return G0.working?G0(O):O instanceof ArrayBuffer}B.isArrayBuffer=r;function y(O){return M(O)==="[object DataView]"}y.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&y(new DataView(new ArrayBuffer(1),0,1));function n(O){if(typeof DataView>"u")return!1;return y.working?y(O):O instanceof DataView}B.isDataView=n;var o=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function Y0(O){return M(O)==="[object SharedArrayBuffer]"}function O0(O){if(typeof o>"u")return!1;if(typeof Y0.working>"u")Y0.working=Y0(new o);return Y0.working?Y0(O):O instanceof o}B.isSharedArrayBuffer=O0;function z(O){return M(O)==="[object AsyncFunction]"}B.isAsyncFunction=z;function L(O){return M(O)==="[object Map Iterator]"}B.isMapIterator=L;function u(O){return M(O)==="[object Set Iterator]"}B.isSetIterator=u;function h(O){return M(O)==="[object Generator]"}B.isGeneratorObject=h;function Z0(O){return M(O)==="[object WebAssembly.Module]"}B.isWebAssemblyCompiledModule=Z0;function g(O){return P(O,W)}B.isNumberObject=g;function f(O){return P(O,I)}B.isStringObject=f;function R(O){return P(O,F)}B.isBooleanObject=R;function p(O){return Z&&P(O,D)}B.isBigIntObject=p;function k(O){return J&&P(O,w)}B.isSymbolObject=k;function V(O){return g(O)||f(O)||R(O)||p(O)||k(O)}B.isBoxedPrimitive=V;function q(O){return typeof Uint8Array<"u"&&(r(O)||O0(O))}B.isAnyArrayBuffer=q,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(O){Object.defineProperty(B,O,{enumerable:!1,value:function(){throw Error(O+" is not supported in userland")}})})}),iU=R0((B,U)=>{U.exports=function(Y){return Y&&typeof Y==="object"&&typeof Y.copy==="function"&&typeof Y.fill==="function"&&typeof Y.readUInt8==="function"}}),AB=R0((B)=>{P2();var U=Object.getOwnPropertyDescriptors||function(n){var o=Object.keys(n),Y0={};for(var O0=0;O0=O0)return u;switch(u){case"%s":return String(Y0[o++]);case"%d":return Number(Y0[o++]);case"%j":try{return JSON.stringify(Y0[o++])}catch(h){return"[Circular]"}default:return u}});for(var L=Y0[o];o"u")return function(){return B.deprecate(y,n).apply(this,arguments)};var o=!1;function Y0(){if(!o){if(P0.throwDeprecation)throw Error(n);else if(P0.traceDeprecation)console.trace(n);else console.error(n);o=!0}return y.apply(this,arguments)}return Y0};var Y={},Q=/^$/;if(P0.env.NODE_DEBUG){var K=P0.env.NODE_DEBUG;K=K.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),Q=new RegExp("^"+K+"$","i")}B.debuglog=function(y){if(y=y.toUpperCase(),!Y[y])if(Q.test(y)){var n=P0.pid;Y[y]=function(){var o=B.format.apply(B,arguments);console.error("%s %d: %s",y,n,o)}}else Y[y]=function(){};return Y[y]};function Z(y,n){var o={seen:[],stylize:M};if(arguments.length>=3)o.depth=arguments[2];if(arguments.length>=4)o.colors=arguments[3];if(C(n))o.showHidden=n;else if(n)B._extend(o,n);if($(o.showHidden))o.showHidden=!1;if($(o.depth))o.depth=2;if($(o.colors))o.colors=!1;if($(o.customInspect))o.customInspect=!0;if(o.colors)o.stylize=J;return I(o,y,o.depth)}B.inspect=Z,Z.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},Z.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function J(y,n){var o=Z.styles[n];if(o)return"\x1B["+Z.colors[o][0]+"m"+y+"\x1B["+Z.colors[o][1]+"m";else return y}function M(y,n){return y}function W(y){var n={};return y.forEach(function(o,Y0){n[o]=!0}),n}function I(y,n,o){if(y.customInspect&&n&&b(n.inspect)&&n.inspect!==B.inspect&&!(n.constructor&&n.constructor.prototype===n)){var Y0=n.inspect(o,y);if(!H(Y0))Y0=I(y,Y0,o);return Y0}var O0=F(y,n);if(O0)return O0;var z=Object.keys(n),L=W(z);if(y.showHidden)z=Object.getOwnPropertyNames(n);if(U0(n)&&(z.indexOf("message")>=0||z.indexOf("description")>=0))return D(n);if(z.length===0){if(b(n)){var u=n.name?": "+n.name:"";return y.stylize("[Function"+u+"]","special")}if(x(n))return y.stylize(RegExp.prototype.toString.call(n),"regexp");if(a(n))return y.stylize(Date.prototype.toString.call(n),"date");if(U0(n))return D(n)}var h="",Z0=!1,g=["{","}"];if(E(n))Z0=!0,g=["[","]"];if(b(n))h=" [Function"+(n.name?": "+n.name:"")+"]";if(x(n))h=" "+RegExp.prototype.toString.call(n);if(a(n))h=" "+Date.prototype.toUTCString.call(n);if(U0(n))h=" "+D(n);if(z.length===0&&(!Z0||n.length==0))return g[0]+h+g[1];if(o<0)if(x(n))return y.stylize(RegExp.prototype.toString.call(n),"regexp");else return y.stylize("[Object]","special");y.seen.push(n);var f;if(Z0)f=w(y,n,o,L,z);else f=z.map(function(R){return P(y,n,o,L,R,Z0)});return y.seen.pop(),A(f,h,g)}function F(y,n){if($(n))return y.stylize("undefined","undefined");if(H(n)){var o="'"+JSON.stringify(n).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return y.stylize(o,"string")}if(S(n))return y.stylize(""+n,"number");if(C(n))return y.stylize(""+n,"boolean");if(j(n))return y.stylize("null","null")}function D(y){return"["+Error.prototype.toString.call(y)+"]"}function w(y,n,o,Y0,O0){var z=[];for(var L=0,u=n.length;L-1)if(z)u=u.split(` +`).map(function(Z0){return" "+Z0}).join(` +`).slice(2);else u=` +`+u.split(` +`).map(function(Z0){return" "+Z0}).join(` +`)}else u=y.stylize("[Circular]","special");if($(L)){if(z&&O0.match(/^\d+$/))return u;if(L=JSON.stringify(""+O0),L.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/))L=L.slice(1,-1),L=y.stylize(L,"name");else L=L.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),L=y.stylize(L,"string")}return L+": "+u}function A(y,n,o){var Y0=0;if(y.reduce(function(O0,z){if(Y0++,z.indexOf(` +`)>=0)Y0++;return O0+z.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return o[0]+(n===""?"":n+` + `)+" "+y.join(`, + `)+" "+o[1];return o[0]+n+" "+y.join(", ")+" "+o[1]}B.types=rU();function E(y){return Array.isArray(y)}B.isArray=E;function C(y){return typeof y==="boolean"}B.isBoolean=C;function j(y){return y===null}B.isNull=j;function v(y){return y==null}B.isNullOrUndefined=v;function S(y){return typeof y==="number"}B.isNumber=S;function H(y){return typeof y==="string"}B.isString=H;function X(y){return typeof y==="symbol"}B.isSymbol=X;function $(y){return y===void 0}B.isUndefined=$;function x(y){return N(y)&&T(y)==="[object RegExp]"}B.isRegExp=x,B.types.isRegExp=x;function N(y){return typeof y==="object"&&y!==null}B.isObject=N;function a(y){return N(y)&&T(y)==="[object Date]"}B.isDate=a,B.types.isDate=a;function U0(y){return N(y)&&(T(y)==="[object Error]"||y instanceof Error)}B.isError=U0,B.types.isNativeError=U0;function b(y){return typeof y==="function"}B.isFunction=b;function c(y){return y===null||typeof y==="boolean"||typeof y==="number"||typeof y==="string"||typeof y==="symbol"||typeof y>"u"}B.isPrimitive=c,B.isBuffer=iU();function T(y){return Object.prototype.toString.call(y)}function m(y){return y<10?"0"+y.toString(10):y.toString(10)}var B0=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function i(){var y=new Date,n=[m(y.getHours()),m(y.getMinutes()),m(y.getSeconds())].join(":");return[y.getDate(),B0[y.getMonth()],n].join(" ")}B.log=function(){console.log("%s - %s",i(),B.format.apply(B,arguments))},B.inherits=W2(),B._extend=function(y,n){if(!n||!N(n))return y;var o=Object.keys(n),Y0=o.length;while(Y0--)y[o[Y0]]=n[o[Y0]];return y};function V0(y,n){return Object.prototype.hasOwnProperty.call(y,n)}var s=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;B.promisify=function(n){if(typeof n!=="function")throw TypeError('The "original" argument must be of type Function');if(s&&n[s]){var o=n[s];if(typeof o!=="function")throw TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(o,s,{value:o,enumerable:!1,writable:!1,configurable:!0}),o}function o(){var Y0,O0,z=new Promise(function(h,Z0){Y0=h,O0=Z0}),L=[];for(var u=0;u{function G(P,A){var E=Object.keys(P);if(Object.getOwnPropertySymbols){var C=Object.getOwnPropertySymbols(P);A&&(C=C.filter(function(j){return Object.getOwnPropertyDescriptor(P,j).enumerable})),E.push.apply(E,C)}return E}function Y(P){for(var A=1;A0)this.tail.next=C;else this.head=C;this.tail=C,++this.length}},{key:"unshift",value:function(E){var C={data:E,next:this.head};if(this.length===0)this.tail=C;this.head=C,++this.length}},{key:"shift",value:function(){if(this.length===0)return;var E=this.head.data;if(this.length===1)this.head=this.tail=null;else this.head=this.head.next;return--this.length,E}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(E){if(this.length===0)return"";var C=this.head,j=""+C.data;while(C=C.next)j+=E+C.data;return j}},{key:"concat",value:function(E){if(this.length===0)return I.alloc(0);var C=I.allocUnsafe(E>>>0),j=this.head,v=0;while(j)w(j.data,C,v),v+=j.data.length,j=j.next;return C}},{key:"consume",value:function(E,C){var j;if(ES.length?S.length:E;if(H===S.length)v+=S;else v+=S.slice(0,E);if(E-=H,E===0){if(H===S.length)if(++j,C.next)this.head=C.next;else this.head=this.tail=null;else this.head=C,C.data=S.slice(H);break}++j}return this.length-=j,v}},{key:"_getBuffer",value:function(E){var C=I.allocUnsafe(E),j=this.head,v=1;j.data.copy(C),E-=j.data.length;while(j=j.next){var S=j.data,H=E>S.length?S.length:E;if(S.copy(C,C.length-E,0,H),E-=H,E===0){if(H===S.length)if(++v,j.next)this.head=j.next;else this.head=this.tail=null;else this.head=j,j.data=S.slice(H);break}++v}return this.length-=v,C}},{key:D,value:function(E,C){return F(this,Y(Y({},C),{},{depth:0,customInspect:!1}))}}]),P}()}),jB=R0((B,U)=>{P2();function G(M,W){var I=this,F=this._readableState&&this._readableState.destroyed,D=this._writableState&&this._writableState.destroyed;if(F||D){if(W)W(M);else if(M){if(!this._writableState)P0.nextTick(Z,this,M);else if(!this._writableState.errorEmitted)this._writableState.errorEmitted=!0,P0.nextTick(Z,this,M)}return this}if(this._readableState)this._readableState.destroyed=!0;if(this._writableState)this._writableState.destroyed=!0;return this._destroy(M||null,function(w){if(!W&&w)if(!I._writableState)P0.nextTick(Y,I,w);else if(!I._writableState.errorEmitted)I._writableState.errorEmitted=!0,P0.nextTick(Y,I,w);else P0.nextTick(Q,I);else if(W)P0.nextTick(Q,I),W(w);else P0.nextTick(Q,I)}),this}function Y(M,W){Z(M,W),Q(M)}function Q(M){if(M._writableState&&!M._writableState.emitClose)return;if(M._readableState&&!M._readableState.emitClose)return;M.emit("close")}function K(){if(this._readableState)this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1;if(this._writableState)this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1}function Z(M,W){M.emit("error",W)}function J(M,W){var{_readableState:I,_writableState:F}=M;if(I&&I.autoDestroy||F&&F.autoDestroy)M.destroy(W);else M.emit("error",W)}U.exports={destroy:G,undestroy:K,errorOrDestroy:J}}),c2=R0((B,U)=>{function G(W,I){W.prototype=Object.create(I.prototype),W.prototype.constructor=W,W.__proto__=I}var Y={};function Q(W,I,F){if(!F)F=Error;function D(P,A,E){if(typeof I==="string")return I;else return I(P,A,E)}var w=function(P){G(A,P);function A(E,C,j){return P.call(this,D(E,C,j))||this}return A}(F);w.prototype.name=F.name,w.prototype.code=W,Y[W]=w}function K(W,I){if(Array.isArray(W)){var F=W.length;if(W=W.map(function(D){return String(D)}),F>2)return"one of ".concat(I," ").concat(W.slice(0,F-1).join(", "),", or ")+W[F-1];else if(F===2)return"one of ".concat(I," ").concat(W[0]," or ").concat(W[1]);else return"of ".concat(I," ").concat(W[0])}else return"of ".concat(I," ").concat(String(W))}function Z(W,I,F){return W.substr(!F||F<0?0:+F,I.length)===I}function J(W,I,F){if(F===void 0||F>W.length)F=W.length;return W.substring(F-I.length,F)===I}function M(W,I,F){if(typeof F!=="number")F=0;if(F+I.length>W.length)return!1;else return W.indexOf(I,F)!==-1}Q("ERR_INVALID_OPT_VALUE",function(W,I){return'The value "'+I+'" is invalid for option "'+W+'"'},TypeError),Q("ERR_INVALID_ARG_TYPE",function(W,I,F){var D;if(typeof I==="string"&&Z(I,"not "))D="must not be",I=I.replace(/^not /,"");else D="must be";var w;if(J(W," argument"))w="The ".concat(W," ").concat(D," ").concat(K(I,"type"));else{var P=M(W,".")?"property":"argument";w='The "'.concat(W,'" ').concat(P," ").concat(D," ").concat(K(I,"type"))}return w+=". Received type ".concat(typeof F),w},TypeError),Q("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),Q("ERR_METHOD_NOT_IMPLEMENTED",function(W){return"The "+W+" method is not implemented"}),Q("ERR_STREAM_PREMATURE_CLOSE","Premature close"),Q("ERR_STREAM_DESTROYED",function(W){return"Cannot call "+W+" after a stream was destroyed"}),Q("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),Q("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),Q("ERR_STREAM_WRITE_AFTER_END","write after end"),Q("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Q("ERR_UNKNOWN_ENCODING",function(W){return"Unknown encoding: "+W},TypeError),Q("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),U.exports.codes=Y}),NB=R0((B,U)=>{var G=c2().codes.ERR_INVALID_OPT_VALUE;function Y(K,Z,J){return K.highWaterMark!=null?K.highWaterMark:Z?K[J]:null}function Q(K,Z,J,M){var W=Y(Z,M,J);if(W!=null){if(!(isFinite(W)&&Math.floor(W)===W)||W<0)throw new G(M?J:"highWaterMark",W);return Math.floor(W)}return K.objectMode?16:16384}U.exports={getHighWaterMark:Q}}),sU=R0((B,U)=>{d2(),U.exports=G;function G(Q,K){if(Y("noDeprecation"))return Q;var Z=!1;function J(){if(!Z){if(Y("throwDeprecation"))throw Error(K);else if(Y("traceDeprecation"))console.trace(K);else console.warn(K);Z=!0}return Q.apply(this,arguments)}return J}function Y(Q){try{if(!v0.localStorage)return!1}catch(Z){return!1}var K=v0.localStorage[Q];if(K==null)return!1;return String(K).toLowerCase()==="true"}}),zB=R0((B,U)=>{d2(),P2(),U.exports=N;function G(z){var L=this;this.next=null,this.entry=null,this.finish=function(){O0(L,z)}}var Y;N.WritableState=$;var Q={deprecate:sU()},K=MB(),Z=g1().Buffer,J=(typeof v0<"u"?v0:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function M(z){return Z.from(z)}function W(z){return Z.isBuffer(z)||z instanceof J}var I=jB(),F=NB().getHighWaterMark,D=c2().codes,w=D.ERR_INVALID_ARG_TYPE,P=D.ERR_METHOD_NOT_IMPLEMENTED,A=D.ERR_MULTIPLE_CALLBACK,E=D.ERR_STREAM_CANNOT_PIPE,C=D.ERR_STREAM_DESTROYED,j=D.ERR_STREAM_NULL_VALUES,v=D.ERR_STREAM_WRITE_AFTER_END,S=D.ERR_UNKNOWN_ENCODING,H=I.errorOrDestroy;W2()(N,K);function X(){}function $(z,L,u){if(Y=Y||u2(),z=z||{},typeof u!=="boolean")u=L instanceof Y;if(this.objectMode=!!z.objectMode,u)this.objectMode=this.objectMode||!!z.writableObjectMode;this.highWaterMark=F(this,z,"writableHighWaterMark",u),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=z.decodeStrings===!1;this.decodeStrings=!h,this.defaultEncoding=z.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(Z0){i(L,Z0)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=z.emitClose!==!1,this.autoDestroy=!!z.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new G(this)}$.prototype.getBuffer=function(){var L=this.bufferedRequest,u=[];while(L)u.push(L),L=L.next;return u},function(){try{Object.defineProperty($.prototype,"buffer",{get:Q.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(z){}}();var x;if(typeof Symbol==="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==="function")x=Function.prototype[Symbol.hasInstance],Object.defineProperty(N,Symbol.hasInstance,{value:function(L){if(x.call(this,L))return!0;if(this!==N)return!1;return L&&L._writableState instanceof $}});else x=function(L){return L instanceof this};function N(z){Y=Y||u2();var L=this instanceof Y;if(!L&&!x.call(N,this))return new N(z);if(this._writableState=new $(z,this,L),this.writable=!0,z){if(typeof z.write==="function")this._write=z.write;if(typeof z.writev==="function")this._writev=z.writev;if(typeof z.destroy==="function")this._destroy=z.destroy;if(typeof z.final==="function")this._final=z.final}K.call(this)}N.prototype.pipe=function(){H(this,new E)};function a(z,L){var u=new v;H(z,u),P0.nextTick(L,u)}function U0(z,L,u,h){var Z0;if(u===null)Z0=new j;else if(typeof u!=="string"&&!L.objectMode)Z0=new w("chunk",["string","Buffer"],u);if(Z0)return H(z,Z0),P0.nextTick(h,Z0),!1;return!0}N.prototype.write=function(z,L,u){var h=this._writableState,Z0=!1,g=!h.objectMode&&W(z);if(g&&!Z.isBuffer(z))z=M(z);if(typeof L==="function")u=L,L=null;if(g)L="buffer";else if(!L)L=h.defaultEncoding;if(typeof u!=="function")u=X;if(h.ending)a(this,u);else if(g||U0(this,h,z,u))h.pendingcb++,Z0=c(this,h,g,z,L,u);return Z0},N.prototype.cork=function(){this._writableState.corked++},N.prototype.uncork=function(){var z=this._writableState;if(z.corked){if(z.corked--,!z.writing&&!z.corked&&!z.bufferProcessing&&z.bufferedRequest)G0(this,z)}},N.prototype.setDefaultEncoding=function(L){if(typeof L==="string")L=L.toLowerCase();if(!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((L+"").toLowerCase())>-1))throw new S(L);return this._writableState.defaultEncoding=L,this},Object.defineProperty(N.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function b(z,L,u){if(!z.objectMode&&z.decodeStrings!==!1&&typeof L==="string")L=Z.from(L,u);return L}Object.defineProperty(N.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function c(z,L,u,h,Z0,g){if(!u){var f=b(L,h,Z0);if(h!==f)u=!0,Z0="buffer",h=f}var R=L.objectMode?1:h.length;L.length+=R;var p=L.length{P2();var G=Object.keys||function(F){var D=[];for(var w in F)D.push(w);return D};U.exports=M;var Y=EB(),Q=zB();W2()(M,Y);var K=G(Q.prototype);for(var Z=0;Z{var G=g1(),Y=G.Buffer;function Q(Z,J){for(var M in Z)J[M]=Z[M]}if(Y.from&&Y.alloc&&Y.allocUnsafe&&Y.allocUnsafeSlow)U.exports=G;else Q(G,B),B.Buffer=K;function K(Z,J,M){return Y(Z,J,M)}Q(Y,K),K.from=function(Z,J,M){if(typeof Z==="number")throw TypeError("Argument must not be a number");return Y(Z,J,M)},K.alloc=function(Z,J,M){if(typeof Z!=="number")throw TypeError("Argument must be a number");var W=Y(Z);if(J!==void 0)if(typeof M==="string")W.fill(J,M);else W.fill(J);else W.fill(0);return W},K.allocUnsafe=function(Z){if(typeof Z!=="number")throw TypeError("Argument must be a number");return Y(Z)},K.allocUnsafeSlow=function(Z){if(typeof Z!=="number")throw TypeError("Argument must be a number");return G.SlowBuffer(Z)}}),F8=R0((B)=>{var U=oU().Buffer,G=U.isEncoding||function(j){switch(j=""+j,j&&j.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Y(j){if(!j)return"utf8";var v;while(!0)switch(j){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return j;default:if(v)return;j=(""+j).toLowerCase(),v=!0}}function Q(j){var v=Y(j);if(typeof v!=="string"&&(U.isEncoding===G||!G(j)))throw Error("Unknown encoding: "+j);return v||j}B.StringDecoder=K;function K(j){this.encoding=Q(j);var v;switch(this.encoding){case"utf16le":this.text=D,this.end=w,v=4;break;case"utf8":this.fillLast=W,v=4;break;case"base64":this.text=P,this.end=A,v=3;break;default:this.write=E,this.end=C;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=U.allocUnsafe(v)}K.prototype.write=function(j){if(j.length===0)return"";var v,S;if(this.lastNeed){if(v=this.fillLast(j),v===void 0)return"";S=this.lastNeed,this.lastNeed=0}else S=0;if(S>5===6)return 2;else if(j>>4===14)return 3;else if(j>>3===30)return 4;return j>>6===2?-1:-2}function J(j,v,S){var H=v.length-1;if(H=0){if(X>0)j.lastNeed=X-1;return X}if(--H=0){if(X>0)j.lastNeed=X-2;return X}if(--H=0){if(X>0)if(X===2)X=0;else j.lastNeed=X-3;return X}return 0}function M(j,v,S){if((v[0]&192)!==128)return j.lastNeed=0,"�";if(j.lastNeed>1&&v.length>1){if((v[1]&192)!==128)return j.lastNeed=1,"�";if(j.lastNeed>2&&v.length>2){if((v[2]&192)!==128)return j.lastNeed=2,"�"}}}function W(j){var v=this.lastTotal-this.lastNeed,S=M(this,j,v);if(S!==void 0)return S;if(this.lastNeed<=j.length)return j.copy(this.lastChar,v,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);j.copy(this.lastChar,v,0,j.length),this.lastNeed-=j.length}function I(j,v){var S=J(this,j,v);if(!this.lastNeed)return j.toString("utf8",v);this.lastTotal=S;var H=j.length-(S-this.lastNeed);return j.copy(this.lastChar,0,H),j.toString("utf8",v,H)}function F(j){var v=j&&j.length?this.write(j):"";if(this.lastNeed)return v+"�";return v}function D(j,v){if((j.length-v)%2===0){var S=j.toString("utf16le",v);if(S){var H=S.charCodeAt(S.length-1);if(H>=55296&&H<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=j[j.length-2],this.lastChar[1]=j[j.length-1],S.slice(0,-1)}return S}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=j[j.length-1],j.toString("utf16le",v,j.length-1)}function w(j){var v=j&&j.length?this.write(j):"";if(this.lastNeed){var S=this.lastTotal-this.lastNeed;return v+this.lastChar.toString("utf16le",0,S)}return v}function P(j,v){var S=(j.length-v)%3;if(S===0)return j.toString("base64",v);if(this.lastNeed=3-S,this.lastTotal=3,S===1)this.lastChar[0]=j[j.length-1];else this.lastChar[0]=j[j.length-2],this.lastChar[1]=j[j.length-1];return j.toString("base64",v,j.length-S)}function A(j){var v=j&&j.length?this.write(j):"";if(this.lastNeed)return v+this.lastChar.toString("base64",0,3-this.lastNeed);return v}function E(j){return j.toString(this.encoding)}function C(j){return j&&j.length?this.write(j):""}}),g8=R0((B,U)=>{var G=c2().codes.ERR_STREAM_PREMATURE_CLOSE;function Y(J){var M=!1;return function(){if(M)return;M=!0;for(var W=arguments.length,I=Array(W),F=0;F{P2();var G;function Y(S,H,X){if(H=Q(H),H in S)Object.defineProperty(S,H,{value:X,enumerable:!0,configurable:!0,writable:!0});else S[H]=X;return S}function Q(S){var H=K(S,"string");return typeof H==="symbol"?H:String(H)}function K(S,H){if(typeof S!=="object"||S===null)return S;var X=S[Symbol.toPrimitive];if(X!==void 0){var $=X.call(S,H||"default");if(typeof $!=="object")return $;throw TypeError("@@toPrimitive must return a primitive value.")}return(H==="string"?String:Number)(S)}var Z=g8(),J=Symbol("lastResolve"),M=Symbol("lastReject"),W=Symbol("error"),I=Symbol("ended"),F=Symbol("lastPromise"),D=Symbol("handlePromise"),w=Symbol("stream");function P(S,H){return{value:S,done:H}}function A(S){var H=S[J];if(H!==null){var X=S[w].read();if(X!==null)S[F]=null,S[J]=null,S[M]=null,H(P(X,!1))}}function E(S){P0.nextTick(A,S)}function C(S,H){return function(X,$){S.then(function(){if(H[I]){X(P(void 0,!0));return}H[D](X,$)},$)}}var j=Object.getPrototypeOf(function(){}),v=Object.setPrototypeOf((G={get stream(){return this[w]},next:function(){var H=this,X=this[W];if(X!==null)return Promise.reject(X);if(this[I])return Promise.resolve(P(void 0,!0));if(this[w].destroyed)return new Promise(function(a,U0){P0.nextTick(function(){if(H[W])U0(H[W]);else a(P(void 0,!0))})});var $=this[F],x;if($)x=new Promise(C($,this));else{var N=this[w].read();if(N!==null)return Promise.resolve(P(N,!1));x=new Promise(this[D])}return this[F]=x,x}},Y(G,Symbol.asyncIterator,function(){return this}),Y(G,"return",function(){var H=this;return new Promise(function(X,$){H[w].destroy(null,function(x){if(x){$(x);return}X(P(void 0,!0))})})}),G),j);U.exports=function(H){var X,$=Object.create(v,(X={},Y(X,w,{value:H,writable:!0}),Y(X,J,{value:null,writable:!0}),Y(X,M,{value:null,writable:!0}),Y(X,W,{value:null,writable:!0}),Y(X,I,{value:H._readableState.endEmitted,writable:!0}),Y(X,D,{value:function(N,a){var U0=$[w].read();if(U0)$[F]=null,$[J]=null,$[M]=null,N(P(U0,!1));else $[J]=N,$[M]=a},writable:!0}),X));return $[F]=null,Z(H,function(x){if(x&&x.code!=="ERR_STREAM_PREMATURE_CLOSE"){var N=$[M];if(N!==null)$[F]=null,$[J]=null,$[M]=null,N(x);$[W]=x;return}var a=$[J];if(a!==null)$[F]=null,$[J]=null,$[M]=null,a(P(void 0,!0));$[I]=!0}),H.on("readable",E.bind(null,$)),$}}),eU=R0((B,U)=>{U.exports=function(){throw Error("Readable.from is not available in the browser")}}),EB=R0((B,U)=>{d2(),P2(),U.exports=a;var G;a.ReadableState=N,$8().EventEmitter;var Y=function(f,R){return f.listeners(R).length},Q=MB(),K=g1().Buffer,Z=(typeof v0<"u"?v0:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function J(g){return K.from(g)}function M(g){return K.isBuffer(g)||g instanceof Z}var W=AB(),I;if(W&&W.debuglog)I=W.debuglog("stream");else I=function(){};var F=nU(),D=jB(),w=NB().getHighWaterMark,P=c2().codes,A=P.ERR_INVALID_ARG_TYPE,E=P.ERR_STREAM_PUSH_AFTER_EOF,C=P.ERR_METHOD_NOT_IMPLEMENTED,j=P.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,v,S,H;W2()(a,Q);var X=D.errorOrDestroy,$=["error","close","destroy","pause","resume"];function x(g,f,R){if(typeof g.prependListener==="function")return g.prependListener(f,R);if(!g._events||!g._events[f])g.on(f,R);else if(Array.isArray(g._events[f]))g._events[f].unshift(R);else g._events[f]=[R,g._events[f]]}function N(g,f,R){if(G=G||u2(),g=g||{},typeof R!=="boolean")R=f instanceof G;if(this.objectMode=!!g.objectMode,R)this.objectMode=this.objectMode||!!g.readableObjectMode;if(this.highWaterMark=w(this,g,"readableHighWaterMark",R),this.buffer=new F,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=g.emitClose!==!1,this.autoDestroy=!!g.autoDestroy,this.destroyed=!1,this.defaultEncoding=g.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,g.encoding){if(!v)v=F8().StringDecoder;this.decoder=new v(g.encoding),this.encoding=g.encoding}}function a(g){if(G=G||u2(),!(this instanceof a))return new a(g);var f=this instanceof G;if(this._readableState=new N(g,this,f),this.readable=!0,g){if(typeof g.read==="function")this._read=g.read;if(typeof g.destroy==="function")this._destroy=g.destroy}Q.call(this)}Object.defineProperty(a.prototype,"destroyed",{enumerable:!1,get:function(){if(this._readableState===void 0)return!1;return this._readableState.destroyed},set:function(f){if(!this._readableState)return;this._readableState.destroyed=f}}),a.prototype.destroy=D.destroy,a.prototype._undestroy=D.undestroy,a.prototype._destroy=function(g,f){f(g)},a.prototype.push=function(g,f){var R=this._readableState,p;if(!R.objectMode){if(typeof g==="string"){if(f=f||R.defaultEncoding,f!==R.encoding)g=K.from(g,f),f="";p=!0}}else p=!0;return U0(this,g,f,!1,p)},a.prototype.unshift=function(g){return U0(this,g,null,!0,!1)};function U0(g,f,R,p,k){I("readableAddChunk",f);var V=g._readableState;if(f===null)V.reading=!1,i(g,V);else{var q;if(!k)q=c(V,f);if(q)X(g,q);else if(V.objectMode||f&&f.length>0){if(typeof f!=="string"&&!V.objectMode&&Object.getPrototypeOf(f)!==K.prototype)f=J(f);if(p)if(V.endEmitted)X(g,new j);else b(g,V,f,!0);else if(V.ended)X(g,new E);else if(V.destroyed)return!1;else if(V.reading=!1,V.decoder&&!R)if(f=V.decoder.write(f),V.objectMode||f.length!==0)b(g,V,f,!1);else G0(g,V);else b(g,V,f,!1)}else if(!p)V.reading=!1,G0(g,V)}return!V.ended&&(V.length=T)g=T;else g--,g|=g>>>1,g|=g>>>2,g|=g>>>4,g|=g>>>8,g|=g>>>16,g++;return g}function B0(g,f){if(g<=0||f.length===0&&f.ended)return 0;if(f.objectMode)return 1;if(g!==g)if(f.flowing&&f.length)return f.buffer.head.data.length;else return f.length;if(g>f.highWaterMark)f.highWaterMark=m(g);if(g<=f.length)return g;if(!f.ended)return f.needReadable=!0,0;return f.length}a.prototype.read=function(g){I("read",g),g=parseInt(g,10);var f=this._readableState,R=g;if(g!==0)f.emittedReadable=!1;if(g===0&&f.needReadable&&((f.highWaterMark!==0?f.length>=f.highWaterMark:f.length>0)||f.ended)){if(I("read: emitReadable",f.length,f.ended),f.length===0&&f.ended)u(this);else V0(this);return null}if(g=B0(g,f),g===0&&f.ended){if(f.length===0)u(this);return null}var p=f.needReadable;if(I("need readable",p),f.length===0||f.length-g0)k=L(g,f);else k=null;if(k===null)f.needReadable=f.length<=f.highWaterMark,g=0;else f.length-=g,f.awaitDrain=0;if(f.length===0){if(!f.ended)f.needReadable=!0;if(R!==g&&f.ended)u(this)}if(k!==null)this.emit("data",k);return k};function i(g,f){if(I("onEofChunk"),f.ended)return;if(f.decoder){var R=f.decoder.end();if(R&&R.length)f.buffer.push(R),f.length+=f.objectMode?1:R.length}if(f.ended=!0,f.sync)V0(g);else if(f.needReadable=!1,!f.emittedReadable)f.emittedReadable=!0,s(g)}function V0(g){var f=g._readableState;if(I("emitReadable",f.needReadable,f.emittedReadable),f.needReadable=!1,!f.emittedReadable)I("emitReadable",f.flowing),f.emittedReadable=!0,P0.nextTick(s,g)}function s(g){var f=g._readableState;if(I("emitReadable_",f.destroyed,f.length,f.ended),!f.destroyed&&(f.length||f.ended))g.emit("readable"),f.emittedReadable=!1;f.needReadable=!f.flowing&&!f.ended&&f.length<=f.highWaterMark,z(g)}function G0(g,f){if(!f.readingMore)f.readingMore=!0,P0.nextTick(r,g,f)}function r(g,f){while(!f.reading&&!f.ended&&(f.length1&&Z0(p.pipes,g)!==-1)&&!_)I("false write response, pause",p.awaitDrain),p.awaitDrain++;R.pause()}}function Q0(H0){if(I("onerror",H0),I0(),g.removeListener("error",Q0),Y(g,"error")===0)X(g,H0)}x(g,"error",Q0);function q0(){g.removeListener("finish",K0),I0()}g.once("close",q0);function K0(){I("onfinish"),g.removeListener("close",q0),I0()}g.once("finish",K0);function I0(){I("unpipe"),R.unpipe(g)}if(g.emit("pipe",R),!p.flowing)I("pipe resume"),R.resume();return g};function y(g){return function(){var R=g._readableState;if(I("pipeOnDrain",R.awaitDrain),R.awaitDrain)R.awaitDrain--;if(R.awaitDrain===0&&Y(g,"data"))R.flowing=!0,z(g)}}a.prototype.unpipe=function(g){var f=this._readableState,R={hasUnpiped:!1};if(f.pipesCount===0)return this;if(f.pipesCount===1){if(g&&g!==f.pipes)return this;if(!g)g=f.pipes;if(f.pipes=null,f.pipesCount=0,f.flowing=!1,g)g.emit("unpipe",this,R);return this}if(!g){var{pipes:p,pipesCount:k}=f;f.pipes=null,f.pipesCount=0,f.flowing=!1;for(var V=0;V0,p.flowing!==!1)this.resume()}else if(g==="readable"){if(!p.endEmitted&&!p.readableListening){if(p.readableListening=p.needReadable=!0,p.flowing=!1,p.emittedReadable=!1,I("on readable",p.length,p.reading),p.length)V0(this);else if(!p.reading)P0.nextTick(o,this)}}return R},a.prototype.addListener=a.prototype.on,a.prototype.removeListener=function(g,f){var R=Q.prototype.removeListener.call(this,g,f);if(g==="readable")P0.nextTick(n,this);return R},a.prototype.removeAllListeners=function(g){var f=Q.prototype.removeAllListeners.apply(this,arguments);if(g==="readable"||g===void 0)P0.nextTick(n,this);return f};function n(g){var f=g._readableState;if(f.readableListening=g.listenerCount("readable")>0,f.resumeScheduled&&!f.paused)f.flowing=!0;else if(g.listenerCount("data")>0)g.resume()}function o(g){I("readable nexttick read 0"),g.read(0)}a.prototype.resume=function(){var g=this._readableState;if(!g.flowing)I("resume"),g.flowing=!g.readableListening,Y0(this,g);return g.paused=!1,this};function Y0(g,f){if(!f.resumeScheduled)f.resumeScheduled=!0,P0.nextTick(O0,g,f)}function O0(g,f){if(I("resume",f.reading),!f.reading)g.read(0);if(f.resumeScheduled=!1,g.emit("resume"),z(g),f.flowing&&!f.reading)g.read(0)}a.prototype.pause=function(){if(I("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1)I("pause"),this._readableState.flowing=!1,this.emit("pause");return this._readableState.paused=!0,this};function z(g){var f=g._readableState;I("flow",f.flowing);while(f.flowing&&g.read()!==null);}if(a.prototype.wrap=function(g){var f=this,R=this._readableState,p=!1;g.on("end",function(){if(I("wrapped end"),R.decoder&&!R.ended){var q=R.decoder.end();if(q&&q.length)f.push(q)}f.push(null)}),g.on("data",function(q){if(I("wrapped data"),R.decoder)q=R.decoder.write(q);if(R.objectMode&&(q===null||q===void 0))return;else if(!R.objectMode&&(!q||!q.length))return;if(!f.push(q))p=!0,g.pause()});for(var k in g)if(this[k]===void 0&&typeof g[k]==="function")this[k]=function(O){return function(){return g[O].apply(g,arguments)}}(k);for(var V=0;V<$.length;V++)g.on($[V],this.emit.bind(this,$[V]));return this._read=function(q){if(I("wrapped _read",q),p)p=!1,g.resume()},this},typeof Symbol==="function")a.prototype[Symbol.asyncIterator]=function(){if(S===void 0)S=tU();return S(this)};Object.defineProperty(a.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(a.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(a.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(f){if(this._readableState)this._readableState.flowing=f}}),a._fromList=L,Object.defineProperty(a.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function L(g,f){if(f.length===0)return null;var R;if(f.objectMode)R=f.buffer.shift();else if(!g||g>=f.length){if(f.decoder)R=f.buffer.join("");else if(f.buffer.length===1)R=f.buffer.first();else R=f.buffer.concat(f.length);f.buffer.clear()}else R=f.buffer.consume(g,f.decoder);return R}function u(g){var f=g._readableState;if(I("endReadable",f.endEmitted),!f.endEmitted)f.ended=!0,P0.nextTick(h,f,g)}function h(g,f){if(I("endReadableNT",g.endEmitted,g.length),!g.endEmitted&&g.length===0){if(g.endEmitted=!0,f.readable=!1,f.emit("end"),g.autoDestroy){var R=f._writableState;if(!R||R.autoDestroy&&R.finished)f.destroy()}}}if(typeof Symbol==="function")a.from=function(g,f){if(H===void 0)H=eU();return H(a,g,f)};function Z0(g,f){for(var R=0,p=g.length;R{U.exports=W;var G=c2().codes,Y=G.ERR_METHOD_NOT_IMPLEMENTED,Q=G.ERR_MULTIPLE_CALLBACK,K=G.ERR_TRANSFORM_ALREADY_TRANSFORMING,Z=G.ERR_TRANSFORM_WITH_LENGTH_0,J=u2();W2()(W,J);function M(D,w){var P=this._transformState;P.transforming=!1;var A=P.writecb;if(A===null)return this.emit("error",new Q);if(P.writechunk=null,P.writecb=null,w!=null)this.push(w);A(D);var E=this._readableState;if(E.reading=!1,E.needReadable||E.length{U.exports=Y;var G=TB();W2()(Y,G);function Y(Q){if(!(this instanceof Y))return new Y(Q);G.call(this,Q)}Y.prototype._transform=function(Q,K,Z){Z(null,Q)}}),UG=R0((B,U)=>{var G;function Y(P){var A=!1;return function(){if(A)return;A=!0,P.apply(void 0,arguments)}}var Q=c2().codes,K=Q.ERR_MISSING_ARGS,Z=Q.ERR_STREAM_DESTROYED;function J(P){if(P)throw P}function M(P){return P.setHeader&&typeof P.abort==="function"}function W(P,A,E,C){C=Y(C);var j=!1;if(P.on("close",function(){j=!0}),G===void 0)G=g8();G(P,{readable:A,writable:E},function(S){if(S)return C(S);j=!0,C()});var v=!1;return function(S){if(j)return;if(v)return;if(v=!0,M(P))return P.abort();if(typeof P.destroy==="function")return P.destroy();C(S||new Z("pipe"))}}function I(P){P()}function F(P,A){return P.pipe(A)}function D(P){if(!P.length)return J;if(typeof P[P.length-1]!=="function")return J;return P.pop()}function w(){for(var P=arguments.length,A=Array(P),E=0;E0,function($){if(!j)j=$;if($)v.forEach(I);if(X)return;v.forEach(I),C(j)})});return A.reduce(F)}U.exports=w}),f8=R0((B,U)=>{U.exports=Y;var G=$8().EventEmitter;W2()(Y,G),Y.Readable=EB(),Y.Writable=zB(),Y.Duplex=u2(),Y.Transform=TB(),Y.PassThrough=BG(),Y.finished=g8(),Y.pipeline=UG(),Y.Stream=Y;function Y(){G.call(this)}Y.prototype.pipe=function(Q,K){var Z=this;function J(P){if(Q.writable){if(Q.write(P)===!1&&Z.pause)Z.pause()}}Z.on("data",J);function M(){if(Z.readable&&Z.resume)Z.resume()}if(Q.on("drain",M),!Q._isStdio&&(!K||K.end!==!1))Z.on("end",I),Z.on("close",F);var W=!1;function I(){if(W)return;W=!0,Q.end()}function F(){if(W)return;if(W=!0,typeof Q.destroy==="function")Q.destroy()}function D(P){if(w(),G.listenerCount(this,"error")===0)throw P}Z.on("error",D),Q.on("error",D);function w(){Z.removeListener("data",J),Q.removeListener("drain",M),Z.removeListener("end",I),Z.removeListener("close",F),Z.removeListener("error",D),Q.removeListener("error",D),Z.removeListener("end",w),Z.removeListener("close",w),Q.removeListener("close",w)}return Z.on("end",w),Z.on("close",w),Q.on("close",w),Q.emit("pipe",Z),Q}}),GG=R0((B)=>{(function(U){U.parser=function(z,L){return new Y(z,L)},U.SAXParser=Y,U.SAXStream=I,U.createStream=W,U.MAX_BUFFER_LENGTH=65536;var G=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];U.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function Y(z,L){if(!(this instanceof Y))return new Y(z,L);var u=this;if(K(u),u.q=u.c="",u.bufferCheckPosition=U.MAX_BUFFER_LENGTH,u.opt=L||{},u.opt.lowercase=u.opt.lowercase||u.opt.lowercasetags,u.looseCase=u.opt.lowercase?"toLowerCase":"toUpperCase",u.tags=[],u.closed=u.closedRoot=u.sawRoot=!1,u.tag=u.error=null,u.strict=!!z,u.noscript=!!(z||u.opt.noscript),u.state=N.BEGIN,u.strictEntities=u.opt.strictEntities,u.ENTITIES=u.strictEntities?Object.create(U.XML_ENTITIES):Object.create(U.ENTITIES),u.attribList=[],u.opt.xmlns)u.ns=Object.create(A);if(u.trackPosition=u.opt.position!==!1,u.trackPosition)u.position=u.line=u.column=0;U0(u,"onready")}if(!Object.create)Object.create=function(z){function L(){}return L.prototype=z,new L};if(!Object.keys)Object.keys=function(z){var L=[];for(var u in z)if(z.hasOwnProperty(u))L.push(u);return L};function Q(z){var L=Math.max(U.MAX_BUFFER_LENGTH,10),u=0;for(var h=0,Z0=G.length;hL)switch(G[h]){case"textNode":c(z);break;case"cdata":b(z,"oncdata",z.cdata),z.cdata="";break;case"script":b(z,"onscript",z.script),z.script="";break;default:m(z,"Max buffer length exceeded: "+G[h])}u=Math.max(u,g)}z.bufferCheckPosition=U.MAX_BUFFER_LENGTH-u+z.position}function K(z){for(var L=0,u=G.length;L"||S(z)}function $(z,L){return z.test(L)}function x(z,L){return!$(z,L)}var N=0;U.STATE={BEGIN:N++,BEGIN_WHITESPACE:N++,TEXT:N++,TEXT_ENTITY:N++,OPEN_WAKA:N++,SGML_DECL:N++,SGML_DECL_QUOTED:N++,DOCTYPE:N++,DOCTYPE_QUOTED:N++,DOCTYPE_DTD:N++,DOCTYPE_DTD_QUOTED:N++,COMMENT_STARTING:N++,COMMENT:N++,COMMENT_ENDING:N++,COMMENT_ENDED:N++,CDATA:N++,CDATA_ENDING:N++,CDATA_ENDING_2:N++,PROC_INST:N++,PROC_INST_BODY:N++,PROC_INST_ENDING:N++,OPEN_TAG:N++,OPEN_TAG_SLASH:N++,ATTRIB:N++,ATTRIB_NAME:N++,ATTRIB_NAME_SAW_WHITE:N++,ATTRIB_VALUE:N++,ATTRIB_VALUE_QUOTED:N++,ATTRIB_VALUE_CLOSED:N++,ATTRIB_VALUE_UNQUOTED:N++,ATTRIB_VALUE_ENTITY_Q:N++,ATTRIB_VALUE_ENTITY_U:N++,CLOSE_TAG:N++,CLOSE_TAG_SAW_WHITE:N++,SCRIPT:N++,SCRIPT_ENDING:N++},U.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},U.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(U.ENTITIES).forEach(function(z){var L=U.ENTITIES[z],u=typeof L==="number"?String.fromCharCode(L):L;U.ENTITIES[z]=u});for(var a in U.STATE)U.STATE[U.STATE[a]]=a;N=U.STATE;function U0(z,L,u){z[L]&&z[L](u)}function b(z,L,u){if(z.textNode)c(z);U0(z,L,u)}function c(z){if(z.textNode=T(z.opt,z.textNode),z.textNode)U0(z,"ontext",z.textNode);z.textNode=""}function T(z,L){if(z.trim)L=L.trim();if(z.normalize)L=L.replace(/\s+/g," ");return L}function m(z,L){if(c(z),z.trackPosition)L+=` +Line: `+z.line+` +Column: `+z.column+` +Char: `+z.c;return L=Error(L),z.error=L,U0(z,"onerror",L),z}function B0(z){if(z.sawRoot&&!z.closedRoot)i(z,"Unclosed root tag");if(z.state!==N.BEGIN&&z.state!==N.BEGIN_WHITESPACE&&z.state!==N.TEXT)m(z,"Unexpected end");return c(z),z.c="",z.closed=!0,U0(z,"onend"),Y.call(z,z.strict,z.opt),z}function i(z,L){if(typeof z!=="object"||!(z instanceof Y))throw Error("bad call to strictFail");if(z.strict)m(z,L)}function V0(z){if(!z.strict)z.tagName=z.tagName[z.looseCase]();var L=z.tags[z.tags.length-1]||z,u=z.tag={name:z.tagName,attributes:{}};if(z.opt.xmlns)u.ns=L.ns;z.attribList.length=0,b(z,"onopentagstart",u)}function s(z,L){var u=z.indexOf(":")<0?["",z]:z.split(":"),h=u[0],Z0=u[1];if(L&&z==="xmlns")h="xmlns",Z0="";return{prefix:h,local:Z0}}function G0(z){if(!z.strict)z.attribName=z.attribName[z.looseCase]();if(z.attribList.indexOf(z.attribName)!==-1||z.tag.attributes.hasOwnProperty(z.attribName)){z.attribName=z.attribValue="";return}if(z.opt.xmlns){var L=s(z.attribName,!0),u=L.prefix,h=L.local;if(u==="xmlns")if(h==="xml"&&z.attribValue!==w)i(z,"xml: prefix must be bound to "+w+` +Actual: `+z.attribValue);else if(h==="xmlns"&&z.attribValue!==P)i(z,"xmlns: prefix must be bound to "+P+` +Actual: `+z.attribValue);else{var Z0=z.tag,g=z.tags[z.tags.length-1]||z;if(Z0.ns===g.ns)Z0.ns=Object.create(g.ns);Z0.ns[h]=z.attribValue}z.attribList.push([z.attribName,z.attribValue])}else z.tag.attributes[z.attribName]=z.attribValue,b(z,"onattribute",{name:z.attribName,value:z.attribValue});z.attribName=z.attribValue=""}function r(z,L){if(z.opt.xmlns){var u=z.tag,h=s(z.tagName);if(u.prefix=h.prefix,u.local=h.local,u.uri=u.ns[h.prefix]||"",u.prefix&&!u.uri)i(z,"Unbound namespace prefix: "+JSON.stringify(z.tagName)),u.uri=h.prefix;var Z0=z.tags[z.tags.length-1]||z;if(u.ns&&Z0.ns!==u.ns)Object.keys(u.ns).forEach(function(d){b(z,"onopennamespace",{prefix:d,uri:u.ns[d]})});for(var g=0,f=z.attribList.length;g",z.tagName="",z.state=N.SCRIPT;return}b(z,"onscript",z.script),z.script=""}var L=z.tags.length,u=z.tagName;if(!z.strict)u=u[z.looseCase]();var h=u;while(L--)if(z.tags[L].name!==h)i(z,"Unexpected close tag");else break;if(L<0){i(z,"Unmatched closing tag: "+z.tagName),z.textNode+="",z.state=N.TEXT;return}z.tagName=u;var Z0=z.tags.length;while(Z0-- >L){var g=z.tag=z.tags.pop();z.tagName=z.tag.name,b(z,"onclosetag",z.tagName);var f={};for(var R in g.ns)f[R]=g.ns[R];var p=z.tags[z.tags.length-1]||z;if(z.opt.xmlns&&g.ns!==p.ns)Object.keys(g.ns).forEach(function(k){var V=g.ns[k];b(z,"onclosenamespace",{prefix:k,uri:V})})}if(L===0)z.closedRoot=!0;z.tagName=z.attribValue=z.attribName="",z.attribList.length=0,z.state=N.TEXT}function n(z){var L=z.entity,u=L.toLowerCase(),h,Z0="";if(z.ENTITIES[L])return z.ENTITIES[L];if(z.ENTITIES[u])return z.ENTITIES[u];if(L=u,L.charAt(0)==="#")if(L.charAt(1)==="x")L=L.slice(2),h=parseInt(L,16),Z0=h.toString(16);else L=L.slice(1),h=parseInt(L,10),Z0=h.toString(10);if(L=L.replace(/^0+/,""),isNaN(h)||Z0.toLowerCase()!==L)return i(z,"Invalid character entity"),"&"+z.entity+";";return String.fromCodePoint(h)}function o(z,L){if(L==="<")z.state=N.OPEN_WAKA,z.startTagPosition=z.position;else if(!S(L))i(z,"Non-whitespace before first tag."),z.textNode=L,z.state=N.TEXT}function Y0(z,L){var u="";if(L")b(L,"onsgmldeclaration",L.sgmlDecl),L.sgmlDecl="",L.state=N.TEXT;else if(H(h))L.state=N.SGML_DECL_QUOTED,L.sgmlDecl+=h;else L.sgmlDecl+=h;continue;case N.SGML_DECL_QUOTED:if(h===L.q)L.state=N.SGML_DECL,L.q="";L.sgmlDecl+=h;continue;case N.DOCTYPE:if(h===">")L.state=N.TEXT,b(L,"ondoctype",L.doctype),L.doctype=!0;else if(L.doctype+=h,h==="[")L.state=N.DOCTYPE_DTD;else if(H(h))L.state=N.DOCTYPE_QUOTED,L.q=h;continue;case N.DOCTYPE_QUOTED:if(L.doctype+=h,h===L.q)L.q="",L.state=N.DOCTYPE;continue;case N.DOCTYPE_DTD:if(L.doctype+=h,h==="]")L.state=N.DOCTYPE;else if(H(h))L.state=N.DOCTYPE_DTD_QUOTED,L.q=h;continue;case N.DOCTYPE_DTD_QUOTED:if(L.doctype+=h,h===L.q)L.state=N.DOCTYPE_DTD,L.q="";continue;case N.COMMENT:if(h==="-")L.state=N.COMMENT_ENDING;else L.comment+=h;continue;case N.COMMENT_ENDING:if(h==="-"){if(L.state=N.COMMENT_ENDED,L.comment=T(L.opt,L.comment),L.comment)b(L,"oncomment",L.comment);L.comment=""}else L.comment+="-"+h,L.state=N.COMMENT;continue;case N.COMMENT_ENDED:if(h!==">")i(L,"Malformed comment"),L.comment+="--"+h,L.state=N.COMMENT;else L.state=N.TEXT;continue;case N.CDATA:if(h==="]")L.state=N.CDATA_ENDING;else L.cdata+=h;continue;case N.CDATA_ENDING:if(h==="]")L.state=N.CDATA_ENDING_2;else L.cdata+="]"+h,L.state=N.CDATA;continue;case N.CDATA_ENDING_2:if(h===">"){if(L.cdata)b(L,"oncdata",L.cdata);b(L,"onclosecdata"),L.cdata="",L.state=N.TEXT}else if(h==="]")L.cdata+="]";else L.cdata+="]]"+h,L.state=N.CDATA;continue;case N.PROC_INST:if(h==="?")L.state=N.PROC_INST_ENDING;else if(S(h))L.state=N.PROC_INST_BODY;else L.procInstName+=h;continue;case N.PROC_INST_BODY:if(!L.procInstBody&&S(h))continue;else if(h==="?")L.state=N.PROC_INST_ENDING;else L.procInstBody+=h;continue;case N.PROC_INST_ENDING:if(h===">")b(L,"onprocessinginstruction",{name:L.procInstName,body:L.procInstBody}),L.procInstName=L.procInstBody="",L.state=N.TEXT;else L.procInstBody+="?"+h,L.state=N.PROC_INST_BODY;continue;case N.OPEN_TAG:if($(C,h))L.tagName+=h;else if(V0(L),h===">")r(L);else if(h==="/")L.state=N.OPEN_TAG_SLASH;else{if(!S(h))i(L,"Invalid character in tag name");L.state=N.ATTRIB}continue;case N.OPEN_TAG_SLASH:if(h===">")r(L,!0),y(L);else i(L,"Forward-slash in opening tag not followed by >"),L.state=N.ATTRIB;continue;case N.ATTRIB:if(S(h))continue;else if(h===">")r(L);else if(h==="/")L.state=N.OPEN_TAG_SLASH;else if($(E,h))L.attribName=h,L.attribValue="",L.state=N.ATTRIB_NAME;else i(L,"Invalid attribute name");continue;case N.ATTRIB_NAME:if(h==="=")L.state=N.ATTRIB_VALUE;else if(h===">")i(L,"Attribute without value"),L.attribValue=L.attribName,G0(L),r(L);else if(S(h))L.state=N.ATTRIB_NAME_SAW_WHITE;else if($(C,h))L.attribName+=h;else i(L,"Invalid attribute name");continue;case N.ATTRIB_NAME_SAW_WHITE:if(h==="=")L.state=N.ATTRIB_VALUE;else if(S(h))continue;else if(i(L,"Attribute without value"),L.tag.attributes[L.attribName]="",L.attribValue="",b(L,"onattribute",{name:L.attribName,value:""}),L.attribName="",h===">")r(L);else if($(E,h))L.attribName=h,L.state=N.ATTRIB_NAME;else i(L,"Invalid attribute name"),L.state=N.ATTRIB;continue;case N.ATTRIB_VALUE:if(S(h))continue;else if(H(h))L.q=h,L.state=N.ATTRIB_VALUE_QUOTED;else i(L,"Unquoted attribute value"),L.state=N.ATTRIB_VALUE_UNQUOTED,L.attribValue=h;continue;case N.ATTRIB_VALUE_QUOTED:if(h!==L.q){if(h==="&")L.state=N.ATTRIB_VALUE_ENTITY_Q;else L.attribValue+=h;continue}G0(L),L.q="",L.state=N.ATTRIB_VALUE_CLOSED;continue;case N.ATTRIB_VALUE_CLOSED:if(S(h))L.state=N.ATTRIB;else if(h===">")r(L);else if(h==="/")L.state=N.OPEN_TAG_SLASH;else if($(E,h))i(L,"No whitespace between attributes"),L.attribName=h,L.attribValue="",L.state=N.ATTRIB_NAME;else i(L,"Invalid attribute name");continue;case N.ATTRIB_VALUE_UNQUOTED:if(!X(h)){if(h==="&")L.state=N.ATTRIB_VALUE_ENTITY_U;else L.attribValue+=h;continue}if(G0(L),h===">")r(L);else L.state=N.ATTRIB;continue;case N.CLOSE_TAG:if(!L.tagName)if(S(h))continue;else if(x(E,h))if(L.script)L.script+="")y(L);else if($(C,h))L.tagName+=h;else if(L.script)L.script+="")y(L);else i(L,"Invalid characters in closing tag");continue;case N.TEXT_ENTITY:case N.ATTRIB_VALUE_ENTITY_Q:case N.ATTRIB_VALUE_ENTITY_U:var f,R;switch(L.state){case N.TEXT_ENTITY:f=N.TEXT,R="textNode";break;case N.ATTRIB_VALUE_ENTITY_Q:f=N.ATTRIB_VALUE_QUOTED,R="attribValue";break;case N.ATTRIB_VALUE_ENTITY_U:f=N.ATTRIB_VALUE_UNQUOTED,R="attribValue";break}if(h===";")L[R]+=n(L),L.entity="",L.state=f;else if($(L.entity.length?v:j,h))L.entity+=h;else i(L,"Invalid character in entity name"),L[R]+="&"+L.entity+h,L.entity="",L.state=f;continue;default:throw Error(L,"Unknown state: "+L.state)}}if(L.position>=L.bufferCheckPosition)Q(L);return L}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */if(!String.fromCodePoint)(function(){var z=String.fromCharCode,L=Math.floor,u=function(){var h=16384,Z0=[],g,f,R=-1,p=arguments.length;if(!p)return"";var k="";while(++R1114111||L(V)!==V)throw RangeError("Invalid code point: "+V);if(V<=65535)Z0.push(V);else V-=65536,g=(V>>10)+55296,f=V%1024+56320,Z0.push(g,f);if(R+1===p||Z0.length>h)k+=z.apply(null,Z0),Z0.length=0}return k};if(Object.defineProperty)Object.defineProperty(String,"fromCodePoint",{value:u,configurable:!0,writable:!0});else String.fromCodePoint=u})()})(typeof B>"u"?B.sax={}:B)}),x8=R0((B,U)=>{U.exports={isArray:function(G){if(Array.isArray)return Array.isArray(G);return Object.prototype.toString.call(G)==="[object Array]"}}}),_8=R0((B,U)=>{var G=x8().isArray;U.exports={copyOptions:function(Y){var Q,K={};for(Q in Y)if(Y.hasOwnProperty(Q))K[Q]=Y[Q];return K},ensureFlagExists:function(Y,Q){if(!(Y in Q)||typeof Q[Y]!=="boolean")Q[Y]=!1},ensureSpacesExists:function(Y){if(!("spaces"in Y)||typeof Y.spaces!=="number"&&typeof Y.spaces!=="string")Y.spaces=0},ensureAlwaysArrayExists:function(Y){if(!("alwaysArray"in Y)||typeof Y.alwaysArray!=="boolean"&&!G(Y.alwaysArray))Y.alwaysArray=!1},ensureKeyExists:function(Y,Q){if(!(Y+"Key"in Q)||typeof Q[Y+"Key"]!=="string")Q[Y+"Key"]=Q.compact?"_"+Y:Y},checkFnExists:function(Y,Q){return Y+"Fn"in Q}}}),DB=R0((B,U)=>{var G=GG(),Y={on:function(){},parse:function(){}},Q=_8(),K=x8().isArray,Z,J=!0,M;function W(H){return Z=Q.copyOptions(H),Q.ensureFlagExists("ignoreDeclaration",Z),Q.ensureFlagExists("ignoreInstruction",Z),Q.ensureFlagExists("ignoreAttributes",Z),Q.ensureFlagExists("ignoreText",Z),Q.ensureFlagExists("ignoreComment",Z),Q.ensureFlagExists("ignoreCdata",Z),Q.ensureFlagExists("ignoreDoctype",Z),Q.ensureFlagExists("compact",Z),Q.ensureFlagExists("alwaysChildren",Z),Q.ensureFlagExists("addParent",Z),Q.ensureFlagExists("trim",Z),Q.ensureFlagExists("nativeType",Z),Q.ensureFlagExists("nativeTypeAttributes",Z),Q.ensureFlagExists("sanitize",Z),Q.ensureFlagExists("instructionHasAttributes",Z),Q.ensureFlagExists("captureSpacesBetweenElements",Z),Q.ensureAlwaysArrayExists(Z),Q.ensureKeyExists("declaration",Z),Q.ensureKeyExists("instruction",Z),Q.ensureKeyExists("attributes",Z),Q.ensureKeyExists("text",Z),Q.ensureKeyExists("comment",Z),Q.ensureKeyExists("cdata",Z),Q.ensureKeyExists("doctype",Z),Q.ensureKeyExists("type",Z),Q.ensureKeyExists("name",Z),Q.ensureKeyExists("elements",Z),Q.ensureKeyExists("parent",Z),Q.checkFnExists("doctype",Z),Q.checkFnExists("instruction",Z),Q.checkFnExists("cdata",Z),Q.checkFnExists("comment",Z),Q.checkFnExists("text",Z),Q.checkFnExists("instructionName",Z),Q.checkFnExists("elementName",Z),Q.checkFnExists("attributeName",Z),Q.checkFnExists("attributeValue",Z),Q.checkFnExists("attributes",Z),Z}function I(H){var X=Number(H);if(!isNaN(X))return X;var $=H.toLowerCase();if($==="true")return!0;else if($==="false")return!1;return H}function F(H,X){var $;if(Z.compact){if(!M[Z[H+"Key"]]&&(K(Z.alwaysArray)?Z.alwaysArray.indexOf(Z[H+"Key"])!==-1:Z.alwaysArray))M[Z[H+"Key"]]=[];if(M[Z[H+"Key"]]&&!K(M[Z[H+"Key"]]))M[Z[H+"Key"]]=[M[Z[H+"Key"]]];if(H+"Fn"in Z&&typeof X==="string")X=Z[H+"Fn"](X,M);if(H==="instruction"&&(("instructionFn"in Z)||("instructionNameFn"in Z))){for($ in X)if(X.hasOwnProperty($))if("instructionFn"in Z)X[$]=Z.instructionFn(X[$],$,M);else{var x=X[$];delete X[$],X[Z.instructionNameFn($,x,M)]=x}}if(K(M[Z[H+"Key"]]))M[Z[H+"Key"]].push(X);else M[Z[H+"Key"]]=X}else{if(!M[Z.elementsKey])M[Z.elementsKey]=[];var N={};if(N[Z.typeKey]=H,H==="instruction"){for($ in X)if(X.hasOwnProperty($))break;if(N[Z.nameKey]="instructionNameFn"in Z?Z.instructionNameFn($,X,M):$,Z.instructionHasAttributes){if(N[Z.attributesKey]=X[$][Z.attributesKey],"instructionFn"in Z)N[Z.attributesKey]=Z.instructionFn(N[Z.attributesKey],$,M)}else{if("instructionFn"in Z)X[$]=Z.instructionFn(X[$],$,M);N[Z.instructionKey]=X[$]}}else{if(H+"Fn"in Z)X=Z[H+"Fn"](X,M);N[Z[H+"Key"]]=X}if(Z.addParent)N[Z.parentKey]=M;M[Z.elementsKey].push(N)}}function D(H){if("attributesFn"in Z&&H)H=Z.attributesFn(H,M);if((Z.trim||("attributeValueFn"in Z)||("attributeNameFn"in Z)||Z.nativeTypeAttributes)&&H){var X;for(X in H)if(H.hasOwnProperty(X)){if(Z.trim)H[X]=H[X].trim();if(Z.nativeTypeAttributes)H[X]=I(H[X]);if("attributeValueFn"in Z)H[X]=Z.attributeValueFn(H[X],X,M);if("attributeNameFn"in Z){var $=H[X];delete H[X],H[Z.attributeNameFn(X,H[X],M)]=$}}}return H}function w(H){var X={};if(H.body&&(H.name.toLowerCase()==="xml"||Z.instructionHasAttributes)){var $=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,x;while((x=$.exec(H.body))!==null)X[x[1]]=x[2]||x[3]||x[4];X=D(X)}if(H.name.toLowerCase()==="xml"){if(Z.ignoreDeclaration)return;if(M[Z.declarationKey]={},Object.keys(X).length)M[Z.declarationKey][Z.attributesKey]=X;if(Z.addParent)M[Z.declarationKey][Z.parentKey]=M}else{if(Z.ignoreInstruction)return;if(Z.trim)H.body=H.body.trim();var N={};if(Z.instructionHasAttributes&&Object.keys(X).length)N[H.name]={},N[H.name][Z.attributesKey]=X;else N[H.name]=H.body;F("instruction",N)}}function P(H,X){var $;if(typeof H==="object")X=H.attributes,H=H.name;if(X=D(X),"elementNameFn"in Z)H=Z.elementNameFn(H,M);if(Z.compact){if($={},!Z.ignoreAttributes&&X&&Object.keys(X).length){$[Z.attributesKey]={};var x;for(x in X)if(X.hasOwnProperty(x))$[Z.attributesKey][x]=X[x]}if(!(H in M)&&(K(Z.alwaysArray)?Z.alwaysArray.indexOf(H)!==-1:Z.alwaysArray))M[H]=[];if(M[H]&&!K(M[H]))M[H]=[M[H]];if(K(M[H]))M[H].push($);else M[H]=$}else{if(!M[Z.elementsKey])M[Z.elementsKey]=[];if($={},$[Z.typeKey]="element",$[Z.nameKey]=H,!Z.ignoreAttributes&&X&&Object.keys(X).length)$[Z.attributesKey]=X;if(Z.alwaysChildren)$[Z.elementsKey]=[];M[Z.elementsKey].push($)}$[Z.parentKey]=M,M=$}function A(H){if(Z.ignoreText)return;if(!H.trim()&&!Z.captureSpacesBetweenElements)return;if(Z.trim)H=H.trim();if(Z.nativeType)H=I(H);if(Z.sanitize)H=H.replace(/&/g,"&").replace(//g,">");F("text",H)}function E(H){if(Z.ignoreComment)return;if(Z.trim)H=H.trim();F("comment",H)}function C(H){var X=M[Z.parentKey];if(!Z.addParent)delete M[Z.parentKey];M=X}function j(H){if(Z.ignoreCdata)return;if(Z.trim)H=H.trim();F("cdata",H)}function v(H){if(Z.ignoreDoctype)return;if(H=H.replace(/^ /,""),Z.trim)H=H.trim();F("doctype",H)}function S(H){H.note=H}U.exports=function(H,X){var $=J?G.parser(!0,{}):$=new Y.Parser("UTF-8"),x={};if(M=x,Z=W(X),J)$.opt={strictEntities:!0},$.onopentag=P,$.ontext=A,$.oncomment=E,$.onclosetag=C,$.onerror=S,$.oncdata=j,$.ondoctype=v,$.onprocessinginstruction=w;else $.on("startElement",P),$.on("text",A),$.on("comment",E),$.on("endElement",C),$.on("error",S);if(J)$.write(H).close();else if(!$.parse(H))throw Error("XML parsing error: "+$.getError());if(x[Z.elementsKey]){var N=x[Z.elementsKey];delete x[Z.elementsKey],x[Z.elementsKey]=N,delete x.text}return x}}),YG=R0((B,U)=>{var G=_8(),Y=DB();function Q(K){var Z=G.copyOptions(K);return G.ensureSpacesExists(Z),Z}U.exports=function(K,Z){var J=Q(Z),M=Y(K,J),W,I="compact"in J&&J.compact?"_parent":"parent";if("addParent"in J&&J.addParent)W=JSON.stringify(M,function(F,D){return F===I?"_":D},J.spaces);else W=JSON.stringify(M,null,J.spaces);return W.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}}),CB=R0((B,U)=>{var G=_8(),Y=x8().isArray,Q,K;function Z(H){var X=G.copyOptions(H);if(G.ensureFlagExists("ignoreDeclaration",X),G.ensureFlagExists("ignoreInstruction",X),G.ensureFlagExists("ignoreAttributes",X),G.ensureFlagExists("ignoreText",X),G.ensureFlagExists("ignoreComment",X),G.ensureFlagExists("ignoreCdata",X),G.ensureFlagExists("ignoreDoctype",X),G.ensureFlagExists("compact",X),G.ensureFlagExists("indentText",X),G.ensureFlagExists("indentCdata",X),G.ensureFlagExists("indentAttributes",X),G.ensureFlagExists("indentInstruction",X),G.ensureFlagExists("fullTagEmptyElement",X),G.ensureFlagExists("noQuotesForNativeAttributes",X),G.ensureSpacesExists(X),typeof X.spaces==="number")X.spaces=Array(X.spaces+1).join(" ");return G.ensureKeyExists("declaration",X),G.ensureKeyExists("instruction",X),G.ensureKeyExists("attributes",X),G.ensureKeyExists("text",X),G.ensureKeyExists("comment",X),G.ensureKeyExists("cdata",X),G.ensureKeyExists("doctype",X),G.ensureKeyExists("type",X),G.ensureKeyExists("name",X),G.ensureKeyExists("elements",X),G.checkFnExists("doctype",X),G.checkFnExists("instruction",X),G.checkFnExists("cdata",X),G.checkFnExists("comment",X),G.checkFnExists("text",X),G.checkFnExists("instructionName",X),G.checkFnExists("elementName",X),G.checkFnExists("attributeName",X),G.checkFnExists("attributeValue",X),G.checkFnExists("attributes",X),G.checkFnExists("fullTagEmptyElement",X),X}function J(H,X,$){return(!$&&H.spaces?` +`:"")+Array(X+1).join(H.spaces)}function M(H,X,$){if(X.ignoreAttributes)return"";if("attributesFn"in X)H=X.attributesFn(H,K,Q);var x,N,a,U0,b=[];for(x in H)if(H.hasOwnProperty(x)&&H[x]!==null&&H[x]!==void 0)U0=X.noQuotesForNativeAttributes&&typeof H[x]!=="string"?"":'"',N=""+H[x],N=N.replace(/"/g,"""),a="attributeNameFn"in X?X.attributeNameFn(x,N,K,Q):x,b.push(X.spaces&&X.indentAttributes?J(X,$+1,!1):" "),b.push(a+"="+U0+("attributeValueFn"in X?X.attributeValueFn(N,x,K,Q):N)+U0);if(H&&Object.keys(H).length&&X.spaces&&X.indentAttributes)b.push(J(X,$,!1));return b.join("")}function W(H,X,$){return Q=H,K="xml",X.ignoreDeclaration?"":""}function I(H,X,$){if(X.ignoreInstruction)return"";var x;for(x in H)if(H.hasOwnProperty(x))break;var N="instructionNameFn"in X?X.instructionNameFn(x,H[x],K,Q):x;if(typeof H[x]==="object")return Q=H,K=N,"";else{var a=H[x]?H[x]:"";if("instructionFn"in X)a=X.instructionFn(a,x,K,Q);return""}}function F(H,X){return X.ignoreComment?"":""}function D(H,X){return X.ignoreCdata?"":"","]]]]>"))+"]]>"}function w(H,X){return X.ignoreDoctype?"":""}function P(H,X){if(X.ignoreText)return"";return H=""+H,H=H.replace(/&/g,"&"),H=H.replace(/&/g,"&").replace(//g,">"),"textFn"in X?X.textFn(H,K,Q):H}function A(H,X){var $;if(H.elements&&H.elements.length)for($=0;$"),H[X.elementsKey]&&H[X.elementsKey].length)x.push(C(H[X.elementsKey],X,$+1)),Q=H,K=H.name;x.push(X.spaces&&A(H,X)?` +`+Array($+1).join(X.spaces):""),x.push("")}else x.push("/>");return x.join("")}function C(H,X,$,x){return H.reduce(function(N,a){var U0=J(X,$,x&&!N);switch(a.type){case"element":return N+U0+E(a,X,$);case"comment":return N+U0+F(a[X.commentKey],X);case"doctype":return N+U0+w(a[X.doctypeKey],X);case"cdata":return N+(X.indentCdata?U0:"")+D(a[X.cdataKey],X);case"text":return N+(X.indentText?U0:"")+P(a[X.textKey],X);case"instruction":var b={};return b[a[X.nameKey]]=a[X.attributesKey]?a:a[X.instructionKey],N+(X.indentInstruction?U0:"")+I(b,X,$)}},"")}function j(H,X,$){var x;for(x in H)if(H.hasOwnProperty(x))switch(x){case X.parentKey:case X.attributesKey:break;case X.textKey:if(X.indentText||$)return!0;break;case X.cdataKey:if(X.indentCdata||$)return!0;break;case X.instructionKey:if(X.indentInstruction||$)return!0;break;case X.doctypeKey:case X.commentKey:return!0;default:return!0}return!1}function v(H,X,$,x,N){Q=H,K=X;var a="elementNameFn"in $?$.elementNameFn(X,H):X;if(typeof H>"u"||H===null||H==="")return"fullTagEmptyElementFn"in $&&$.fullTagEmptyElementFn(X,H)||$.fullTagEmptyElement?"<"+a+">":"<"+a+"/>";var U0=[];if(X){if(U0.push("<"+a),typeof H!=="object")return U0.push(">"+P(H,$)+""),U0.join("");if(H[$.attributesKey])U0.push(M(H[$.attributesKey],$,x));var b=j(H,$,!0)||H[$.attributesKey]&&H[$.attributesKey]["xml:space"]==="preserve";if(!b)if("fullTagEmptyElementFn"in $)b=$.fullTagEmptyElementFn(X,H);else b=$.fullTagEmptyElement;if(b)U0.push(">");else return U0.push("/>"),U0.join("")}if(U0.push(S(H,$,x+1,!1)),Q=H,K=X,X)U0.push((N?J($,x,!1):"")+"");return U0.join("")}function S(H,X,$,x){var N,a,U0,b=[];for(a in H)if(H.hasOwnProperty(a)){U0=Y(H[a])?H[a]:[H[a]];for(N=0;N{var G=CB();U.exports=function(Y,Q){if(Y instanceof Buffer)Y=Y.toString();var K=null;if(typeof Y==="string")try{K=JSON.parse(Y)}catch(Z){throw Error("The JSON structure is invalid")}else K=Y;return G(K,Q)}}),_1=R0((B,U)=>{U.exports={xml2js:DB(),xml2json:YG(),js2xml:CB(),json2xml:ZG()}})(),h1=(B)=>{switch(B.type){case void 0:case"element":let U=new kB(B.name,B.attributes),G=B.elements||[];for(let Y of G){let Q=h1(Y);if(Q!==void 0)U.push(Q)}return U;case"text":return B.text;default:return}},QG=class extends F0{},kB=class extends t{static fromXmlString(B){return h1((0,_1.xml2js)(B,{compact:!1}))}constructor(B,U){super(B);if(U)this.root.push(new QG(U))}push(B){this.root.push(B)}},$B=class extends t{constructor(B){super("");e(this,"_attr",void 0),this._attr=B}prepForXml(B){return{_attr:this._attr}}},JG="",h8=class extends t{constructor(B,U){super(B);if(U)this.root=U.root}},D0=(B)=>{if(isNaN(B))throw Error(`Invalid value '${B}' specified. Must be an integer.`);return Math.floor(B)},q1=(B)=>{let U=D0(B);if(U<0)throw Error(`Invalid value '${B}' specified. Must be a positive integer.`);return U},u1=(B,U)=>{let G=U*2;if(B.length!==G||isNaN(Number(`0x${B}`)))throw Error(`Invalid hex value '${B}'. Expected ${G} digit hex value`);return B},KG=(B)=>u1(B,4),SB=(B)=>u1(B,2),H8=(B)=>u1(B,1),M1=(B)=>{let U=B.slice(-2),G=B.substring(0,B.length-2);return`${Number(G)}${U}`},u8=(B)=>{let U=M1(B);if(parseFloat(U)<0)throw Error(`Invalid value '${U}' specified. Expected a positive number.`);return U},C2=(B)=>{if(B==="auto")return B;return u1(B.charAt(0)==="#"?B.substring(1):B,3)},t0=(B)=>typeof B==="string"?M1(B):D0(B),bB=(B)=>typeof B==="string"?u8(B):q1(B),VG=(B)=>typeof B==="string"?M1(B):D0(B),E0=(B)=>typeof B==="string"?u8(B):q1(B),vB=(B)=>{let U=B.substring(0,B.length-1);return`${Number(U)}%`},d8=(B)=>{if(typeof B==="number")return D0(B);if(B.slice(-1)==="%")return vB(B);return M1(B)},yB=q1,gB=q1,fB=(B)=>B.toISOString(),M0=class extends t{constructor(B,U=!0){super(B);if(U!==!0)this.root.push(new C0({val:U}))}},E1=class extends t{constructor(B,U){super(B);this.root.push(new C0({val:bB(U)}))}},S0=class extends t{},M2=class extends t{constructor(B,U){super(B);this.root.push(new C0({val:U}))}},f2=(B,U)=>new X0({name:B,attributes:{value:{key:"w:val",value:U}}}),_2=class extends t{constructor(B,U){super(B);this.root.push(new C0({val:U}))}},qG=class extends t{constructor(B,U){super(B);this.root.push(new C0({val:U}))}},O2=class extends t{constructor(B,U){super(B);this.root.push(U)}},X0=class extends t{constructor({name:B,attributes:U,children:G}){super(B);if(U)this.root.push(new k8(U));if(G)this.root.push(...G)}},c0={START:"start",CENTER:"center",END:"end",BOTH:"both",MEDIUM_KASHIDA:"mediumKashida",DISTRIBUTE:"distribute",NUM_TAB:"numTab",HIGH_KASHIDA:"highKashida",LOW_KASHIDA:"lowKashida",THAI_DISTRIBUTE:"thaiDistribute",LEFT:"left",RIGHT:"right",JUSTIFIED:"both"},c8=(B)=>new X0({name:"w:jc",attributes:{val:{key:"w:val",value:B}}}),A0=(B,{color:U,size:G,space:Y,style:Q})=>new X0({name:B,attributes:{style:{key:"w:val",value:Q},color:{key:"w:color",value:U===void 0?void 0:C2(U)},size:{key:"w:sz",value:G===void 0?void 0:yB(G)},space:{key:"w:space",value:Y===void 0?void 0:gB(Y)}}}),d1={SINGLE:"single",DASH_DOT_STROKED:"dashDotStroked",DASHED:"dashed",DASH_SMALL_GAP:"dashSmallGap",DOT_DASH:"dotDash",DOT_DOT_DASH:"dotDotDash",DOTTED:"dotted",DOUBLE:"double",DOUBLE_WAVE:"doubleWave",INSET:"inset",NIL:"nil",NONE:"none",OUTSET:"outset",THICK:"thick",THICK_THIN_LARGE_GAP:"thickThinLargeGap",THICK_THIN_MEDIUM_GAP:"thickThinMediumGap",THICK_THIN_SMALL_GAP:"thickThinSmallGap",THIN_THICK_LARGE_GAP:"thinThickLargeGap",THIN_THICK_MEDIUM_GAP:"thinThickMediumGap",THIN_THICK_SMALL_GAP:"thinThickSmallGap",THIN_THICK_THIN_LARGE_GAP:"thinThickThinLargeGap",THIN_THICK_THIN_MEDIUM_GAP:"thinThickThinMediumGap",THIN_THICK_THIN_SMALL_GAP:"thinThickThinSmallGap",THREE_D_EMBOSS:"threeDEmboss",THREE_D_ENGRAVE:"threeDEngrave",TRIPLE:"triple",WAVE:"wave"},xB=class extends R2{constructor(B){super("w:pBdr");if(B.top)this.root.push(A0("w:top",B.top));if(B.bottom)this.root.push(A0("w:bottom",B.bottom));if(B.left)this.root.push(A0("w:left",B.left));if(B.right)this.root.push(A0("w:right",B.right));if(B.between)this.root.push(A0("w:between",B.between))}},_B=class extends t{constructor(){super("w:pBdr");let B=A0("w:bottom",{color:"auto",space:1,style:d1.SINGLE,size:6});this.root.push(B)}},hB=({start:B,end:U,left:G,right:Y,hanging:Q,firstLine:K,firstLineChars:Z})=>new X0({name:"w:ind",attributes:{start:{key:"w:start",value:B===void 0?void 0:t0(B)},end:{key:"w:end",value:U===void 0?void 0:t0(U)},left:{key:"w:left",value:G===void 0?void 0:t0(G)},right:{key:"w:right",value:Y===void 0?void 0:t0(Y)},hanging:{key:"w:hanging",value:Q===void 0?void 0:E0(Q)},firstLine:{key:"w:firstLine",value:K===void 0?void 0:E0(K)},firstLineChars:{key:"w:firstLineChars",value:Z===void 0?void 0:D0(Z)}}}),uB=()=>new X0({name:"w:br"}),m8={BEGIN:"begin",END:"end",SEPARATE:"separate"},l8=(B,U)=>new X0({name:"w:fldChar",attributes:{type:{key:"w:fldCharType",value:B},dirty:{key:"w:dirty",value:U}}}),e0=(B)=>l8(m8.BEGIN,B),q2=(B)=>l8(m8.SEPARATE,B),B2=(B)=>l8(m8.END,B),MG={CENTER:"center",INSIDE:"inside",LEFT:"left",OUTSIDE:"outside",RIGHT:"right"},XG={BOTTOM:"bottom",CENTER:"center",INSIDE:"inside",OUTSIDE:"outside",TOP:"top"},RG={DECIMAL:"decimal",UPPER_ROMAN:"upperRoman",LOWER_ROMAN:"lowerRoman",UPPER_LETTER:"upperLetter",LOWER_LETTER:"lowerLetter",ORDINAL:"ordinal",CARDINAL_TEXT:"cardinalText",ORDINAL_TEXT:"ordinalText",HEX:"hex",CHICAGO:"chicago",IDEOGRAPH_DIGITAL:"ideographDigital",JAPANESE_COUNTING:"japaneseCounting",AIUEO:"aiueo",IROHA:"iroha",DECIMAL_FULL_WIDTH:"decimalFullWidth",DECIMAL_HALF_WIDTH:"decimalHalfWidth",JAPANESE_LEGAL:"japaneseLegal",JAPANESE_DIGITAL_TEN_THOUSAND:"japaneseDigitalTenThousand",DECIMAL_ENCLOSED_CIRCLE:"decimalEnclosedCircle",DECIMAL_FULL_WIDTH_2:"decimalFullWidth2",AIUEO_FULL_WIDTH:"aiueoFullWidth",IROHA_FULL_WIDTH:"irohaFullWidth",DECIMAL_ZERO:"decimalZero",BULLET:"bullet",GANADA:"ganada",CHOSUNG:"chosung",DECIMAL_ENCLOSED_FULL_STOP:"decimalEnclosedFullstop",DECIMAL_ENCLOSED_PAREN:"decimalEnclosedParen",DECIMAL_ENCLOSED_CIRCLE_CHINESE:"decimalEnclosedCircleChinese",IDEOGRAPH_ENCLOSED_CIRCLE:"ideographEnclosedCircle",IDEOGRAPH_TRADITIONAL:"ideographTraditional",IDEOGRAPH_ZODIAC:"ideographZodiac",IDEOGRAPH_ZODIAC_TRADITIONAL:"ideographZodiacTraditional",TAIWANESE_COUNTING:"taiwaneseCounting",IDEOGRAPH_LEGAL_TRADITIONAL:"ideographLegalTraditional",TAIWANESE_COUNTING_THOUSAND:"taiwaneseCountingThousand",TAIWANESE_DIGITAL:"taiwaneseDigital",CHINESE_COUNTING:"chineseCounting",CHINESE_LEGAL_SIMPLIFIED:"chineseLegalSimplified",CHINESE_COUNTING_TEN_THOUSAND:"chineseCountingThousand",KOREAN_DIGITAL:"koreanDigital",KOREAN_COUNTING:"koreanCounting",KOREAN_LEGAL:"koreanLegal",KOREAN_DIGITAL_2:"koreanDigital2",VIETNAMESE_COUNTING:"vietnameseCounting",RUSSIAN_LOWER:"russianLower",RUSSIAN_UPPER:"russianUpper",NONE:"none",NUMBER_IN_DASH:"numberInDash",HEBREW_1:"hebrew1",HEBREW_2:"hebrew2",ARABIC_ALPHA:"arabicAlpha",ARABIC_ABJAD:"arabicAbjad",HINDI_VOWELS:"hindiVowels",HINDI_CONSONANTS:"hindiConsonants",HINDI_NUMBERS:"hindiNumbers",HINDI_COUNTING:"hindiCounting",THAI_LETTERS:"thaiLetters",THAI_NUMBERS:"thaiNumbers",THAI_COUNTING:"thaiCounting",BAHT_TEXT:"bahtText",DOLLAR_TEXT:"dollarText"},x0={DEFAULT:"default",PRESERVE:"preserve"},_0=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{space:"xml:space"})}},LG=class extends t{constructor(){super("w:instrText");this.root.push(new _0({space:x0.PRESERVE})),this.root.push("PAGE")}},IG=class extends t{constructor(){super("w:instrText");this.root.push(new _0({space:x0.PRESERVE})),this.root.push("NUMPAGES")}},OG=class extends t{constructor(){super("w:instrText");this.root.push(new _0({space:x0.PRESERVE})),this.root.push("SECTIONPAGES")}},FG=class extends t{constructor(){super("w:instrText");this.root.push(new _0({space:x0.PRESERVE})),this.root.push("SECTION")}},X1=({fill:B,color:U,type:G})=>new X0({name:"w:shd",attributes:{fill:{key:"w:fill",value:B===void 0?void 0:C2(B)},color:{key:"w:color",value:U===void 0?void 0:C2(U)},type:{key:"w:val",value:G}}}),HG={CLEAR:"clear",DIAGONAL_CROSS:"diagCross",DIAGONAL_STRIPE:"diagStripe",HORIZONTAL_CROSS:"horzCross",HORIZONTAL_STRIPE:"horzStripe",NIL:"nil",PERCENT_5:"pct5",PERCENT_10:"pct10",PERCENT_12:"pct12",PERCENT_15:"pct15",PERCENT_20:"pct20",PERCENT_25:"pct25",PERCENT_30:"pct30",PERCENT_35:"pct35",PERCENT_37:"pct37",PERCENT_40:"pct40",PERCENT_45:"pct45",PERCENT_50:"pct50",PERCENT_55:"pct55",PERCENT_60:"pct60",PERCENT_62:"pct62",PERCENT_65:"pct65",PERCENT_70:"pct70",PERCENT_75:"pct75",PERCENT_80:"pct80",PERCENT_85:"pct85",PERCENT_87:"pct87",PERCENT_90:"pct90",PERCENT_95:"pct95",REVERSE_DIAGONAL_STRIPE:"reverseDiagStripe",SOLID:"solid",THIN_DIAGONAL_CROSS:"thinDiagCross",THIN_DIAGONAL_STRIPE:"thinDiagStripe",THIN_HORIZONTAL_CROSS:"thinHorzCross",THIN_REVERSE_DIAGONAL_STRIPE:"thinReverseDiagStripe",THIN_VERTICAL_STRIPE:"thinVertStripe",VERTICAL_STRIPE:"vertStripe"},b0=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{id:"w:id",author:"w:author",date:"w:date"})}},WG=class extends t{constructor(B){super("w:del");this.root.push(new b0({id:B.id,author:B.author,date:B.date}))}},PG=class extends t{constructor(B){super("w:ins");this.root.push(new b0({id:B.id,author:B.author,date:B.date}))}},a8={DOT:"dot"},p8=(B=a8.DOT)=>new X0({name:"w:em",attributes:{val:{key:"w:val",value:B}}}),wG=()=>p8(a8.DOT),AG=class extends t{constructor(B){super("w:spacing");this.root.push(new C0({val:t0(B)}))}},jG=class extends t{constructor(B){super("w:color");this.root.push(new C0({val:C2(B)}))}},NG=class extends t{constructor(B){super("w:highlight");this.root.push(new C0({val:B}))}},zG=class extends t{constructor(B){super("w:highlightCs");this.root.push(new C0({val:B}))}},EG=(B)=>new X0({name:"w:lang",attributes:{value:{key:"w:val",value:B.value},eastAsia:{key:"w:eastAsia",value:B.eastAsia},bidirectional:{key:"w:bidi",value:B.bidirectional}}}),T1=(B,U)=>{if(typeof B==="string"){let Y=B;return new X0({name:"w:rFonts",attributes:{ascii:{key:"w:ascii",value:Y},cs:{key:"w:cs",value:Y},eastAsia:{key:"w:eastAsia",value:Y},hAnsi:{key:"w:hAnsi",value:Y},hint:{key:"w:hint",value:U}}})}let G=B;return new X0({name:"w:rFonts",attributes:{ascii:{key:"w:ascii",value:G.ascii},cs:{key:"w:cs",value:G.cs},eastAsia:{key:"w:eastAsia",value:G.eastAsia},hAnsi:{key:"w:hAnsi",value:G.hAnsi},hint:{key:"w:hint",value:G.hint}}})},dB=(B)=>new X0({name:"w:vertAlign",attributes:{val:{key:"w:val",value:B}}}),TG=()=>dB("superscript"),DG=()=>dB("subscript"),r8={SINGLE:"single",WORDS:"words",DOUBLE:"double",THICK:"thick",DOTTED:"dotted",DOTTEDHEAVY:"dottedHeavy",DASH:"dash",DASHEDHEAVY:"dashedHeavy",DASHLONG:"dashLong",DASHLONGHEAVY:"dashLongHeavy",DOTDASH:"dotDash",DASHDOTHEAVY:"dashDotHeavy",DOTDOTDASH:"dotDotDash",DASHDOTDOTHEAVY:"dashDotDotHeavy",WAVE:"wave",WAVYHEAVY:"wavyHeavy",WAVYDOUBLE:"wavyDouble",NONE:"none"},cB=(B=r8.SINGLE,U)=>new X0({name:"w:u",attributes:{val:{key:"w:val",value:B},color:{key:"w:color",value:U===void 0?void 0:C2(U)}}}),CG={BLINK_BACKGROUND:"blinkBackground",LIGHTS:"lights",ANTS_BLACK:"antsBlack",ANTS_RED:"antsRed",SHIMMER:"shimmer",SPARKLE:"sparkle",NONE:"none"},kG={BLACK:"black",BLUE:"blue",CYAN:"cyan",DARK_BLUE:"darkBlue",DARK_CYAN:"darkCyan",DARK_GRAY:"darkGray",DARK_GREEN:"darkGreen",DARK_MAGENTA:"darkMagenta",DARK_RED:"darkRed",DARK_YELLOW:"darkYellow",GREEN:"green",LIGHT_GRAY:"lightGray",MAGENTA:"magenta",NONE:"none",RED:"red",WHITE:"white",YELLOW:"yellow"},U2=class extends R2{constructor(B){super("w:rPr");if(!B)return;if(B.style)this.push(new M2("w:rStyle",B.style));if(B.font)if(typeof B.font==="string")this.push(T1(B.font));else if("name"in B.font)this.push(T1(B.font.name,B.font.hint));else this.push(T1(B.font));if(B.bold!==void 0)this.push(new M0("w:b",B.bold));if(B.boldComplexScript===void 0&&B.bold!==void 0||B.boldComplexScript){var U;this.push(new M0("w:bCs",(U=B.boldComplexScript)!==null&&U!==void 0?U:B.bold))}if(B.italics!==void 0)this.push(new M0("w:i",B.italics));if(B.italicsComplexScript===void 0&&B.italics!==void 0||B.italicsComplexScript){var G;this.push(new M0("w:iCs",(G=B.italicsComplexScript)!==null&&G!==void 0?G:B.italics))}if(B.smallCaps!==void 0)this.push(new M0("w:smallCaps",B.smallCaps));else if(B.allCaps!==void 0)this.push(new M0("w:caps",B.allCaps));if(B.strike!==void 0)this.push(new M0("w:strike",B.strike));if(B.doubleStrike!==void 0)this.push(new M0("w:dstrike",B.doubleStrike));if(B.emboss!==void 0)this.push(new M0("w:emboss",B.emboss));if(B.imprint!==void 0)this.push(new M0("w:imprint",B.imprint));if(B.noProof!==void 0)this.push(new M0("w:noProof",B.noProof));if(B.snapToGrid!==void 0)this.push(new M0("w:snapToGrid",B.snapToGrid));if(B.vanish)this.push(new M0("w:vanish",B.vanish));if(B.color)this.push(new jG(B.color));if(B.characterSpacing)this.push(new AG(B.characterSpacing));if(B.scale!==void 0)this.push(new _2("w:w",B.scale));if(B.kern)this.push(new E1("w:kern",B.kern));if(B.position)this.push(new M2("w:position",B.position));if(B.size!==void 0)this.push(new E1("w:sz",B.size));let Y=B.sizeComplexScript===void 0||B.sizeComplexScript===!0?B.size:B.sizeComplexScript;if(Y)this.push(new E1("w:szCs",Y));if(B.highlight)this.push(new NG(B.highlight));let Q=B.highlightComplexScript===void 0||B.highlightComplexScript===!0?B.highlight:B.highlightComplexScript;if(Q)this.push(new zG(Q));if(B.underline)this.push(cB(B.underline.type,B.underline.color));if(B.effect)this.push(new M2("w:effect",B.effect));if(B.border)this.push(A0("w:bdr",B.border));if(B.shading)this.push(X1(B.shading));if(B.subScript)this.push(DG());if(B.superScript)this.push(TG());if(B.rightToLeft!==void 0)this.push(new M0("w:rtl",B.rightToLeft));if(B.emphasisMark)this.push(p8(B.emphasisMark.type));if(B.language)this.push(EG(B.language));if(B.specVanish)this.push(new M0("w:specVanish",B.vanish));if(B.math)this.push(new M0("w:oMath",B.math));if(B.revision)this.push(new lB(B.revision))}push(B){this.root.push(B)}},mB=class extends U2{constructor(B){super(B);if(B===null||B===void 0?void 0:B.insertion)this.push(new PG(B.insertion));if(B===null||B===void 0?void 0:B.deletion)this.push(new WG(B.deletion))}},lB=class extends t{constructor(B){super("w:rPrChange");this.root.push(new b0({id:B.id,author:B.author,date:B.date})),this.addChildElement(new U2(B))}},Z1=class extends t{constructor(B){super("w:t");if(typeof B==="string")this.root.push(new _0({space:x0.PRESERVE})),this.root.push(B);else{var U;this.root.push(new _0({space:(U=B.space)!==null&&U!==void 0?U:x0.DEFAULT})),this.root.push(B.text)}}},H2={CURRENT:"CURRENT",TOTAL_PAGES:"TOTAL_PAGES",TOTAL_PAGES_IN_SECTION:"TOTAL_PAGES_IN_SECTION",CURRENT_SECTION:"SECTION"},T0=class extends t{constructor(B){super("w:r");if(e(this,"properties",void 0),this.properties=new U2(B),this.root.push(this.properties),B.break)for(let U=0;U{U.exports=G;function G(Y,Q){if(!Y)throw Error(Q||"Assertion failed")}G.equal=function(Q,K,Z){if(Q!=K)throw Error(Z||"Assertion failed: "+Q+" != "+K)}}),G2=R0((B)=>{var U=R1();B.inherits=W2();function G(b,c){if((b.charCodeAt(c)&64512)!==55296)return!1;if(c<0||c+1>=b.length)return!1;return(b.charCodeAt(c+1)&64512)===56320}function Y(b,c){if(Array.isArray(b))return b.slice();if(!b)return[];var T=[];if(typeof b==="string"){if(!c){var m=0;for(var B0=0;B0>6|192,T[m++]=i&63|128;else if(G(b,B0))i=65536+((i&1023)<<10)+(b.charCodeAt(++B0)&1023),T[m++]=i>>18|240,T[m++]=i>>12&63|128,T[m++]=i>>6&63|128,T[m++]=i&63|128;else T[m++]=i>>12|224,T[m++]=i>>6&63|128,T[m++]=i&63|128}}else if(c==="hex"){if(b=b.replace(/[^a-z0-9]+/gi,""),b.length%2!==0)b="0"+b;for(B0=0;B0>>24|b>>>8&65280|b<<8&16711680|(b&255)<<24)>>>0}B.htonl=K;function Z(b,c){var T="";for(var m=0;m>>0}return i}B.join32=W;function I(b,c){var T=Array(b.length*4);for(var m=0,B0=0;m>>24,T[B0+1]=i>>>16&255,T[B0+2]=i>>>8&255,T[B0+3]=i&255;else T[B0+3]=i>>>24,T[B0+2]=i>>>16&255,T[B0+1]=i>>>8&255,T[B0]=i&255}return T}B.split32=I;function F(b,c){return b>>>c|b<<32-c}B.rotr32=F;function D(b,c){return b<>>32-c}B.rotl32=D;function w(b,c){return b+c>>>0}B.sum32=w;function P(b,c,T){return b+c+T>>>0}B.sum32_3=P;function A(b,c,T,m){return b+c+T+m>>>0}B.sum32_4=A;function E(b,c,T,m,B0){return b+c+T+m+B0>>>0}B.sum32_5=E;function C(b,c,T,m){var B0=b[c],i=m+b[c+1]>>>0;b[c]=(i>>0,b[c+1]=i}B.sum64=C;function j(b,c,T,m){return(c+m>>>0>>0}B.sum64_hi=j;function v(b,c,T,m){return c+m>>>0}B.sum64_lo=v;function S(b,c,T,m,B0,i,V0,s){var G0=0,r=c;return r=r+m>>>0,G0+=r>>0,G0+=r>>0,G0+=r>>0}B.sum64_4_hi=S;function H(b,c,T,m,B0,i,V0,s){return c+m+i+s>>>0}B.sum64_4_lo=H;function X(b,c,T,m,B0,i,V0,s,G0,r){var y=0,n=c;return n=n+m>>>0,y+=n>>0,y+=n>>0,y+=n>>0,y+=n>>0}B.sum64_5_hi=X;function $(b,c,T,m,B0,i,V0,s,G0,r){return c+m+i+s+r>>>0}B.sum64_5_lo=$;function x(b,c,T){return(c<<32-T|b>>>T)>>>0}B.rotr64_hi=x;function N(b,c,T){return(b<<32-T|c>>>T)>>>0}B.rotr64_lo=N;function a(b,c,T){return b>>>T}B.shr64_hi=a;function U0(b,c,T){return(b<<32-T|c>>>T)>>>0}B.shr64_lo=U0}),L1=R0((B)=>{var U=G2(),G=R1();function Y(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}B.BlockHash=Y,Y.prototype.update=function(K,Z){if(K=U.toArray(K,Z),!this.pending)this.pending=K;else this.pending=this.pending.concat(K);if(this.pendingTotal+=K.length,this.pending.length>=this._delta8){K=this.pending;var J=K.length%this._delta8;if(this.pending=K.slice(K.length-J,K.length),this.pending.length===0)this.pending=null;K=U.join32(K,0,K.length-J,this.endian);for(var M=0;M>>24&255,M[W++]=K>>>16&255,M[W++]=K>>>8&255,M[W++]=K&255}else{M[W++]=K&255,M[W++]=K>>>8&255,M[W++]=K>>>16&255,M[W++]=K>>>24&255,M[W++]=0,M[W++]=0,M[W++]=0,M[W++]=0;for(I=8;I{var U=G2().rotr32;function G(I,F,D,w){if(I===0)return Y(F,D,w);if(I===1||I===3)return K(F,D,w);if(I===2)return Q(F,D,w)}B.ft_1=G;function Y(I,F,D){return I&F^~I&D}B.ch32=Y;function Q(I,F,D){return I&F^I&D^F&D}B.maj32=Q;function K(I,F,D){return I^F^D}B.p32=K;function Z(I){return U(I,2)^U(I,13)^U(I,22)}B.s0_256=Z;function J(I){return U(I,6)^U(I,11)^U(I,25)}B.s1_256=J;function M(I){return U(I,7)^U(I,18)^I>>>3}B.g0_256=M;function W(I){return U(I,17)^U(I,19)^I>>>10}B.g1_256=W}),SG=R0((B,U)=>{var G=G2(),Y=L1(),Q=pB(),K=G.rotl32,Z=G.sum32,J=G.sum32_5,M=Q.ft_1,W=Y.BlockHash,I=[1518500249,1859775393,2400959708,3395469782];function F(){if(!(this instanceof F))return new F;W.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=Array(80)}G.inherits(F,W),U.exports=F,F.blockSize=512,F.outSize=160,F.hmacStrength=80,F.padLength=64,F.prototype._update=function(w,P){var A=this.W;for(var E=0;E<16;E++)A[E]=w[P+E];for(;E{var G=G2(),Y=L1(),Q=pB(),K=R1(),Z=G.sum32,J=G.sum32_4,M=G.sum32_5,W=Q.ch32,I=Q.maj32,F=Q.s0_256,D=Q.s1_256,w=Q.g0_256,P=Q.g1_256,A=Y.BlockHash,E=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function C(){if(!(this instanceof C))return new C;A.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=E,this.W=Array(64)}G.inherits(C,A),U.exports=C,C.blockSize=512,C.outSize=256,C.hmacStrength=192,C.padLength=64,C.prototype._update=function(v,S){var H=this.W;for(var X=0;X<16;X++)H[X]=v[S+X];for(;X{var G=G2(),Y=rB();function Q(){if(!(this instanceof Q))return new Q;Y.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}G.inherits(Q,Y),U.exports=Q,Q.blockSize=512,Q.outSize=224,Q.hmacStrength=192,Q.padLength=64,Q.prototype._digest=function(Z){if(Z==="hex")return G.toHex32(this.h.slice(0,7),"big");else return G.split32(this.h.slice(0,7),"big")}}),iB=R0((B,U)=>{var G=G2(),Y=L1(),Q=R1(),K=G.rotr64_hi,Z=G.rotr64_lo,J=G.shr64_hi,M=G.shr64_lo,W=G.sum64,I=G.sum64_hi,F=G.sum64_lo,D=G.sum64_4_hi,w=G.sum64_4_lo,P=G.sum64_5_hi,A=G.sum64_5_lo,E=Y.BlockHash,C=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function j(){if(!(this instanceof j))return new j;E.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=C,this.W=Array(160)}G.inherits(j,E),U.exports=j,j.blockSize=1024,j.outSize=512,j.hmacStrength=192,j.padLength=128,j.prototype._prepareBlock=function(B0,i){var V0=this.W;for(var s=0;s<32;s++)V0[s]=B0[i+s];for(;s{var G=G2(),Y=iB();function Q(){if(!(this instanceof Q))return new Q;Y.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}G.inherits(Q,Y),U.exports=Q,Q.blockSize=1024,Q.outSize=384,Q.hmacStrength=192,Q.padLength=128,Q.prototype._digest=function(Z){if(Z==="hex")return G.toHex32(this.h.slice(0,12),"big");else return G.split32(this.h.slice(0,12),"big")}}),yG=R0((B)=>{B.sha1=SG(),B.sha224=bG(),B.sha256=rB(),B.sha384=vG(),B.sha512=iB()}),gG=R0((B)=>{var U=G2(),G=L1(),Y=U.rotl32,Q=U.sum32,K=U.sum32_3,Z=U.sum32_4,J=G.BlockHash;function M(){if(!(this instanceof M))return new M;J.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}U.inherits(M,J),B.ripemd160=M,M.blockSize=512,M.outSize=160,M.hmacStrength=192,M.padLength=64,M.prototype._update=function(C,j){var v=this.h[0],S=this.h[1],H=this.h[2],X=this.h[3],$=this.h[4],x=v,N=S,a=H,U0=X,b=$;for(var c=0;c<80;c++){var T=Q(Y(Z(v,W(c,S,H,X),C[D[c]+j],I(c)),P[c]),$);v=$,$=X,X=Y(H,10),H=S,S=T,T=Q(Y(Z(x,W(79-c,N,a,U0),C[w[c]+j],F(c)),A[c]),b),x=b,b=U0,U0=Y(a,10),a=N,N=T}T=K(this.h[1],H,U0),this.h[1]=K(this.h[2],X,b),this.h[2]=K(this.h[3],$,x),this.h[3]=K(this.h[4],v,N),this.h[4]=K(this.h[0],S,a),this.h[0]=T},M.prototype._digest=function(C){if(C==="hex")return U.toHex32(this.h,"little");else return U.split32(this.h,"little")};function W(E,C,j,v){if(E<=15)return C^j^v;else if(E<=31)return C&j|~C&v;else if(E<=47)return(C|~j)^v;else if(E<=63)return C&v|j&~v;else return C^(j|~v)}function I(E){if(E<=15)return 0;else if(E<=31)return 1518500249;else if(E<=47)return 1859775393;else if(E<=63)return 2400959708;else return 2840853838}function F(E){if(E<=15)return 1352829926;else if(E<=31)return 1548603684;else if(E<=47)return 1836072691;else if(E<=63)return 2053994217;else return 0}var D=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],w=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],P=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],A=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]}),fG=R0((B,U)=>{var G=G2(),Y=R1();function Q(K,Z,J){if(!(this instanceof Q))return new Q(K,Z,J);this.Hash=K,this.blockSize=K.blockSize/8,this.outSize=K.outSize/8,this.inner=null,this.outer=null,this._init(G.toArray(Z,J))}U.exports=Q,Q.prototype._init=function(Z){if(Z.length>this.blockSize)Z=new this.Hash().update(Z).digest();Y(Z.length<=this.blockSize);for(var J=Z.length;J{var U=B;U.utils=G2(),U.common=L1(),U.sha=yG(),U.ripemd=gG(),U.hmac=fG(),U.sha1=U.sha.sha1,U.sha256=U.sha.sha256,U.sha224=U.sha.sha224,U.sha384=U.sha.sha384,U.sha512=U.sha.sha512,U.ripemd160=U.ripemd.ripemd160})(),1),_G="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",hG=(B,U=21)=>{return(G=U)=>{let Y="",Q=G|0;while(Q--)Y+=B[Math.random()*B.length|0];return Y}},uG=(B=21)=>{let U="",G=B|0;while(G--)U+=_G[Math.random()*64|0];return U},dG=(B)=>Math.floor(B/25.4*72*20),u0=(B)=>Math.floor(B*72*20),I1=(B=0)=>{let U=B;return()=>++U},nB=()=>I1(),sB=()=>I1(1),oB=()=>I1(),tB=()=>I1(),O1=()=>uG().toLowerCase(),W8=(B)=>xG.default.sha1().update(B instanceof ArrayBuffer?new Uint8Array(B):B).digest("hex"),s2=(B)=>hG("1234567890abcdef",B)(),eB=()=>`${s2(8)}-${s2(4)}-${s2(4)}-${s2(4)}-${s2(12)}`,U1=(B)=>new Uint8Array(new TextEncoder().encode(B)),B4={CHARACTER:"character",COLUMN:"column",INSIDE_MARGIN:"insideMargin",LEFT_MARGIN:"leftMargin",MARGIN:"margin",OUTSIDE_MARGIN:"outsideMargin",PAGE:"page",RIGHT_MARGIN:"rightMargin"},U4={BOTTOM_MARGIN:"bottomMargin",INSIDE_MARGIN:"insideMargin",LINE:"line",MARGIN:"margin",OUTSIDE_MARGIN:"outsideMargin",PAGE:"page",PARAGRAPH:"paragraph",TOP_MARGIN:"topMargin"},G4=()=>new X0({name:"wp:simplePos",attributes:{x:{key:"x",value:0},y:{key:"y",value:0}}}),Y4=(B)=>new X0({name:"wp:align",children:[B]}),Z4=(B)=>new X0({name:"wp:posOffset",children:[B.toString()]}),Q4=({relative:B,align:U,offset:G})=>new X0({name:"wp:positionH",attributes:{relativeFrom:{key:"relativeFrom",value:B!==null&&B!==void 0?B:B4.PAGE}},children:[(()=>{if(U)return Y4(U);else if(G!==void 0)return Z4(G);else throw Error("There is no configuration provided for floating position (Align or offset)")})()]}),J4=({relative:B,align:U,offset:G})=>new X0({name:"wp:positionV",attributes:{relativeFrom:{key:"relativeFrom",value:B!==null&&B!==void 0?B:U4.PAGE}},children:[(()=>{if(U)return Y4(U);else if(G!==void 0)return Z4(G);else throw Error("There is no configuration provided for floating position (Align or offset)")})()]}),cG=function(B){return B.CENTER="ctr",B.TOP="t",B.BOTTOM="b",B}({}),K4=(B={})=>{var U,G,Y,Q;return new X0({name:"wps:bodyPr",attributes:{lIns:{key:"lIns",value:(U=B.margins)===null||U===void 0?void 0:U.left},rIns:{key:"rIns",value:(G=B.margins)===null||G===void 0?void 0:G.right},tIns:{key:"tIns",value:(Y=B.margins)===null||Y===void 0?void 0:Y.top},bIns:{key:"bIns",value:(Q=B.margins)===null||Q===void 0?void 0:Q.bottom},anchor:{key:"anchor",value:B.verticalAnchor}},children:[...B.noAutoFit?[new M0("a:noAutofit",B.noAutoFit)]:[]]})},mG=(B={txBox:"1"})=>new X0({name:"wps:cNvSpPr",attributes:{txBox:{key:"txBox",value:B.txBox}}}),lG=(B)=>new X0({name:"w:txbxContent",children:[...B]}),aG=(B)=>new X0({name:"wps:txbx",children:[lG(B)]}),pG=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{cx:"cx",cy:"cy"})}},rG=class extends t{constructor(B,U){super("a:ext");e(this,"attributes",void 0),this.attributes=new pG({cx:B,cy:U}),this.root.push(this.attributes)}},iG=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{x:"x",y:"y"})}},nG=class extends t{constructor(B,U){super("a:off");this.root.push(new iG({x:B!==null&&B!==void 0?B:0,y:U!==null&&U!==void 0?U:0}))}},sG=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{flipVertical:"flipV",flipHorizontal:"flipH",rotation:"rot"})}},V4=class extends t{constructor(B){var U,G,Y,Q;super("a:xfrm");e(this,"extents",void 0),e(this,"offset",void 0),this.root.push(new sG({flipVertical:(U=B.flip)===null||U===void 0?void 0:U.vertical,flipHorizontal:(G=B.flip)===null||G===void 0?void 0:G.horizontal,rotation:B.rotation})),this.offset=new nG((Y=B.offset)===null||Y===void 0||(Y=Y.emus)===null||Y===void 0?void 0:Y.x,(Q=B.offset)===null||Q===void 0||(Q=Q.emus)===null||Q===void 0?void 0:Q.y),this.extents=new rG(B.emus.x,B.emus.y),this.root.push(this.offset),this.root.push(this.extents)}},q4=()=>new X0({name:"a:noFill"}),oG=(B)=>new X0({name:"a:srgbClr",attributes:{value:{key:"val",value:B.value}}}),tG=(B)=>new X0({name:"a:schemeClr",attributes:{value:{key:"val",value:B.value}}}),P8=(B)=>new X0({name:"a:solidFill",children:[B.type==="rgb"?oG(B):tG(B)]}),eG=(B)=>new X0({name:"a:ln",attributes:{width:{key:"w",value:B.width},cap:{key:"cap",value:B.cap},compoundLine:{key:"cmpd",value:B.compoundLine},align:{key:"algn",value:B.align}},children:[B.type==="noFill"?q4():B.solidFillType==="rgb"?P8({type:"rgb",value:B.value}):P8({type:"scheme",value:B.value})]}),BY=class extends t{constructor(){super("a:avLst")}},UY=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{prst:"prst"})}},GY=class extends t{constructor(){super("a:prstGeom");this.root.push(new UY({prst:"rect"})),this.root.push(new BY)}},YY=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{bwMode:"bwMode"})}},M4=class extends t{constructor({element:B,outline:U,solidFill:G,transform:Y}){super(`${B}:spPr`);if(e(this,"form",void 0),this.root.push(new YY({bwMode:"auto"})),this.form=new V4(Y),this.root.push(this.form),this.root.push(new GY),U)this.root.push(q4()),this.root.push(eG(U));if(G)this.root.push(P8(G))}},l6=(B)=>new X0({name:"wps:wsp",children:[mG(B.nonVisualProperties),new M4({element:"wps",transform:B.transformation,outline:B.outline,solidFill:B.solidFill}),aG(B.children),K4(B.bodyProperties)]}),J8=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{uri:"uri"})}},ZY=(B)=>new X0({name:"asvg:svgBlip",attributes:{asvg:{key:"xmlns:asvg",value:"http://schemas.microsoft.com/office/drawing/2016/SVG/main"},embed:{key:"r:embed",value:`rId{${B.fileName}}`}}}),QY=(B)=>new X0({name:"a:ext",attributes:{uri:{key:"uri",value:"{96DAC541-7B7A-43D3-8B79-37D633B846F1}"}},children:[ZY(B)]}),JY=(B)=>new X0({name:"a:extLst",children:[QY(B)]}),KY=(B)=>new X0({name:"a:blip",attributes:{embed:{key:"r:embed",value:`rId{${B.type==="svg"?B.fallback.fileName:B.fileName}}`},cstate:{key:"cstate",value:"none"}},children:B.type==="svg"?[JY(B)]:[]}),VY=class extends t{constructor(){super("a:srcRect")}},qY=class extends t{constructor(){super("a:fillRect")}},MY=class extends t{constructor(){super("a:stretch");this.root.push(new qY)}},XY=class extends t{constructor(B){super("pic:blipFill");this.root.push(KY(B)),this.root.push(new VY),this.root.push(new MY)}},RY=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{noChangeAspect:"noChangeAspect",noChangeArrowheads:"noChangeArrowheads"})}},LY=class extends t{constructor(){super("a:picLocks");this.root.push(new RY({noChangeAspect:1,noChangeArrowheads:1}))}},IY=class extends t{constructor(){super("pic:cNvPicPr");this.root.push(new LY)}},X4=(B,U)=>new X0({name:"a:hlinkClick",attributes:L0(L0({},U?{xmlns:{key:"xmlns:a",value:"http://schemas.openxmlformats.org/drawingml/2006/main"}}:{}),{},{id:{key:"r:id",value:`rId${B}`}})}),OY=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{id:"id",name:"name",descr:"descr"})}},FY=class extends t{constructor(){super("pic:cNvPr");this.root.push(new OY({id:0,name:"",descr:""}))}prepForXml(B){for(let U=B.stack.length-1;U>=0;U--){let G=B.stack[U];if(!(G instanceof m2))continue;this.root.push(X4(G.linkId,!1));break}return super.prepForXml(B)}},HY=class extends t{constructor(){super("pic:nvPicPr");this.root.push(new FY),this.root.push(new IY)}},WY=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{xmlns:"xmlns:pic"})}},a6=class extends t{constructor({mediaData:B,transform:U,outline:G}){super("pic:pic");this.root.push(new WY({xmlns:"http://schemas.openxmlformats.org/drawingml/2006/picture"})),this.root.push(new HY),this.root.push(new XY(B)),this.root.push(new M4({element:"pic",transform:U,outline:G}))}},PY=(B)=>new X0({name:"wpg:grpSpPr",children:[new V4(B)]}),wY=()=>new X0({name:"wpg:cNvGrpSpPr"}),AY=(B)=>new X0({name:"wpg:wgp",children:[wY(),PY(B.transformation),...B.children]}),jY=class extends t{constructor({mediaData:B,transform:U,outline:G,solidFill:Y}){super("a:graphicData");if(B.type==="wps"){this.root.push(new J8({uri:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"}));let Q=l6(L0(L0({},B.data),{},{transformation:U,outline:G,solidFill:Y}));this.root.push(Q)}else if(B.type==="wpg"){this.root.push(new J8({uri:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"}));let Q=AY({children:B.children.map((K)=>{if(K.type==="wps")return l6(L0(L0({},K.data),{},{transformation:K.transformation,outline:K.outline,solidFill:K.solidFill}));else return new a6({mediaData:K,transform:K.transformation,outline:K.outline})}),transformation:U});this.root.push(Q)}else{this.root.push(new J8({uri:"http://schemas.openxmlformats.org/drawingml/2006/picture"}));let Q=new a6({mediaData:B,transform:U,outline:G});this.root.push(Q)}}},NY=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{a:"xmlns:a"})}},R4=class extends t{constructor({mediaData:B,transform:U,outline:G,solidFill:Y}){super("a:graphic");e(this,"data",void 0),this.root.push(new NY({a:"http://schemas.openxmlformats.org/drawingml/2006/main"})),this.data=new jY({mediaData:B,transform:U,outline:G,solidFill:Y}),this.root.push(this.data)}},e2={NONE:0,SQUARE:1,TIGHT:2,TOP_AND_BOTTOM:3},L4={BOTH_SIDES:"bothSides",LEFT:"left",RIGHT:"right",LARGEST:"largest"},w8=()=>new X0({name:"wp:wrapNone"}),I4=(B,U={top:0,bottom:0,left:0,right:0})=>new X0({name:"wp:wrapSquare",attributes:{wrapText:{key:"wrapText",value:B.side||L4.BOTH_SIDES},distT:{key:"distT",value:U.top},distB:{key:"distB",value:U.bottom},distL:{key:"distL",value:U.left},distR:{key:"distR",value:U.right}}}),O4=(B={top:0,bottom:0})=>new X0({name:"wp:wrapTight",attributes:{distT:{key:"distT",value:B.top},distB:{key:"distB",value:B.bottom}}}),F4=(B={top:0,bottom:0})=>new X0({name:"wp:wrapTopAndBottom",attributes:{distT:{key:"distT",value:B.top},distB:{key:"distB",value:B.bottom}}}),H4=class extends t{constructor({name:B,description:U,title:G,id:Y}={name:"",description:"",title:""}){super("wp:docPr");e(this,"docPropertiesUniqueNumericId",oB());let Q={id:{key:"id",value:Y!==null&&Y!==void 0?Y:this.docPropertiesUniqueNumericId()},name:{key:"name",value:B}};if(U!==null&&U!==void 0)Q.description={key:"descr",value:U};if(G!==null&&G!==void 0)Q.title={key:"title",value:G};this.root.push(new k8(Q))}prepForXml(B){for(let U=B.stack.length-1;U>=0;U--){let G=B.stack[U];if(!(G instanceof m2))continue;this.root.push(X4(G.linkId,!0));break}return super.prepForXml(B)}},W4=({top:B,right:U,bottom:G,left:Y})=>new X0({name:"wp:effectExtent",attributes:{top:{key:"t",value:B},right:{key:"r",value:U},bottom:{key:"b",value:G},left:{key:"l",value:Y}}}),P4=({x:B,y:U})=>new X0({name:"wp:extent",attributes:{x:{key:"cx",value:B},y:{key:"cy",value:U}}}),zY=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{xmlns:"xmlns:a",noChangeAspect:"noChangeAspect"})}},EY=class extends t{constructor(){super("a:graphicFrameLocks");this.root.push(new zY({xmlns:"http://schemas.openxmlformats.org/drawingml/2006/main",noChangeAspect:1}))}},w4=()=>new X0({name:"wp:cNvGraphicFramePr",children:[new EY]}),TY=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{distT:"distT",distB:"distB",distL:"distL",distR:"distR",allowOverlap:"allowOverlap",behindDoc:"behindDoc",layoutInCell:"layoutInCell",locked:"locked",relativeHeight:"relativeHeight",simplePos:"simplePos"})}},DY=class extends t{constructor({mediaData:B,transform:U,drawingOptions:G}){super("wp:anchor");let Y=L0({allowOverlap:!0,behindDocument:!1,lockAnchor:!1,layoutInCell:!0,verticalPosition:{},horizontalPosition:{}},G.floating);if(this.root.push(new TY({distT:Y.margins?Y.margins.top||0:0,distB:Y.margins?Y.margins.bottom||0:0,distL:Y.margins?Y.margins.left||0:0,distR:Y.margins?Y.margins.right||0:0,simplePos:"0",allowOverlap:Y.allowOverlap===!0?"1":"0",behindDoc:Y.behindDocument===!0?"1":"0",locked:Y.lockAnchor===!0?"1":"0",layoutInCell:Y.layoutInCell===!0?"1":"0",relativeHeight:Y.zIndex?Y.zIndex:U.emus.y})),this.root.push(G4()),this.root.push(Q4(Y.horizontalPosition)),this.root.push(J4(Y.verticalPosition)),this.root.push(P4({x:U.emus.x,y:U.emus.y})),this.root.push(W4({top:0,right:0,bottom:0,left:0})),G.floating!==void 0&&G.floating.wrap!==void 0)switch(G.floating.wrap.type){case e2.SQUARE:this.root.push(I4(G.floating.wrap,G.floating.margins));break;case e2.TIGHT:this.root.push(O4(G.floating.margins));break;case e2.TOP_AND_BOTTOM:this.root.push(F4(G.floating.margins));break;case e2.NONE:default:this.root.push(w8())}else this.root.push(w8());this.root.push(new H4(G.docProperties)),this.root.push(w4()),this.root.push(new R4({mediaData:B,transform:U,outline:G.outline,solidFill:G.solidFill}))}},CY=({mediaData:B,transform:U,docProperties:G,outline:Y,solidFill:Q})=>{var K,Z,J,M;return new X0({name:"wp:inline",attributes:{distanceTop:{key:"distT",value:0},distanceBottom:{key:"distB",value:0},distanceLeft:{key:"distL",value:0},distanceRight:{key:"distR",value:0}},children:[P4({x:U.emus.x,y:U.emus.y}),W4(Y?{top:((K=Y.width)!==null&&K!==void 0?K:9525)*2,right:((Z=Y.width)!==null&&Z!==void 0?Z:9525)*2,bottom:((J=Y.width)!==null&&J!==void 0?J:9525)*2,left:((M=Y.width)!==null&&M!==void 0?M:9525)*2}:{top:0,right:0,bottom:0,left:0}),new H4(G),w4(),new R4({mediaData:B,transform:U,outline:Y,solidFill:Q})]})},c1=class extends t{constructor(B,U={}){super("w:drawing");if(!U.floating)this.root.push(CY({mediaData:B,transform:B.transformation,docProperties:U.docProperties,outline:U.outline,solidFill:U.solidFill}));else this.root.push(new DY({mediaData:B,transform:B.transformation,drawingOptions:U}))}},kY=(B)=>{let U=B.indexOf(";base64,"),G=U===-1?0:U+8;return new Uint8Array(atob(B.substring(G)).split("").map((Y)=>Y.charCodeAt(0)))},A4=(B)=>typeof B==="string"?kY(B):B,K8=(B,U)=>({data:A4(B.data),fileName:U,transformation:{pixels:{x:Math.round(B.transformation.width),y:Math.round(B.transformation.height)},emus:{x:Math.round(B.transformation.width*9525),y:Math.round(B.transformation.height*9525)},flip:B.transformation.flip,rotation:B.transformation.rotation?B.transformation.rotation*60000:void 0}}),$Y=class extends t{constructor(B){var U=(...Z)=>(super(...Z),e(this,"imageData",void 0),this);let G=`${W8(B.data)}.${B.type}`,Y=B.type==="svg"?L0(L0({type:B.type},K8(B,G)),{},{fallback:L0({type:B.fallback.type},K8(L0(L0({},B.fallback),{},{transformation:B.transformation}),`${W8(B.fallback.data)}.${B.fallback.type}`))}):L0({type:B.type},K8(B,G)),Q=new c1(Y,{floating:B.floating,docProperties:B.altText,outline:B.outline}),K=new T0({children:[Q]});if(B.insertion)U("w:ins"),this.root.push(new b0({id:B.insertion.id,author:B.insertion.author,date:B.insertion.date})),this.addChildElement(K);else if(B.deletion)U("w:del"),this.root.push(new b0({id:B.deletion.id,author:B.deletion.author,date:B.deletion.date})),this.addChildElement(K);else U("w:r"),this.root.push(new U2({})),this.root.push(Q);this.imageData=Y}prepForXml(B){if(B.file.Media.addImage(this.imageData.fileName,this.imageData),this.imageData.type==="svg")B.file.Media.addImage(this.imageData.fallback.fileName,this.imageData.fallback);return super.prepForXml(B)}},i8=(B)=>{var U,G,Y,Q,K,Z,J,M;return{offset:{pixels:{x:Math.round((U=(G=B.offset)===null||G===void 0?void 0:G.left)!==null&&U!==void 0?U:0),y:Math.round((Y=(Q=B.offset)===null||Q===void 0?void 0:Q.top)!==null&&Y!==void 0?Y:0)},emus:{x:Math.round(((K=(Z=B.offset)===null||Z===void 0?void 0:Z.left)!==null&&K!==void 0?K:0)*9525),y:Math.round(((J=(M=B.offset)===null||M===void 0?void 0:M.top)!==null&&J!==void 0?J:0)*9525)}},pixels:{x:Math.round(B.width),y:Math.round(B.height)},emus:{x:Math.round(B.width*9525),y:Math.round(B.height*9525)},flip:B.flip,rotation:B.rotation?B.rotation*60000:void 0}},SY=class extends T0{constructor(B){super({});e(this,"wpsShapeData",void 0),this.wpsShapeData={type:B.type,transformation:i8(B.transformation),data:L0({},B)};let U=new c1(this.wpsShapeData,{floating:B.floating,docProperties:B.altText,outline:B.outline,solidFill:B.solidFill});this.root.push(U)}},bY=class extends T0{constructor(B){super({});e(this,"wpgGroupData",void 0),e(this,"mediaDatas",void 0),this.wpgGroupData={type:B.type,transformation:i8(B.transformation),children:B.children};let U=new c1(this.wpgGroupData,{floating:B.floating,docProperties:B.altText});this.mediaDatas=B.children.filter((G)=>G.type!=="wps").map((G)=>G),this.root.push(U)}prepForXml(B){return this.mediaDatas.forEach((U)=>{if(B.file.Media.addImage(U.fileName,U),U.type==="svg")B.file.Media.addImage(U.fallback.fileName,U.fallback)}),super.prepForXml(B)}},vY=class extends t{constructor(B){super("w:instrText");this.root.push(new _0({space:x0.PRESERVE})),this.root.push(`SEQ ${B}`)}},yY=class extends T0{constructor(B){super({});this.root.push(e0(!0)),this.root.push(new vY(B)),this.root.push(q2()),this.root.push(B2())}},gY=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{instr:"w:instr"})}},n8=class extends t{constructor(B,U){super("w:fldSimple");if(this.root.push(new gY({instr:B})),U!==void 0)this.root.push(new Q1(U))}},fY=class extends n8{constructor(B){super(` MERGEFIELD ${B} `,`«${B}»`)}},xY=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{xmlns:"xmlns"})}},j4={EXTERNAL:"External"},_Y=(B,U,G,Y)=>new X0({name:"Relationship",attributes:{id:{key:"Id",value:B},type:{key:"Type",value:U},target:{key:"Target",value:G},targetMode:{key:"TargetMode",value:Y}}}),w2=class extends t{constructor(){super("Relationships");this.root.push(new xY({xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"}))}addRelationship(B,U,G,Y){this.root.push(_Y(`rId${B}`,U,G,Y))}get RelationshipCount(){return this.root.length-1}},hY=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{id:"w:id",initials:"w:initials",author:"w:author",date:"w:date"})}},s8=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{id:"w:id"})}},uY=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{"xmlns:cx":"xmlns:cx","xmlns:cx1":"xmlns:cx1","xmlns:cx2":"xmlns:cx2","xmlns:cx3":"xmlns:cx3","xmlns:cx4":"xmlns:cx4","xmlns:cx5":"xmlns:cx5","xmlns:cx6":"xmlns:cx6","xmlns:cx7":"xmlns:cx7","xmlns:cx8":"xmlns:cx8","xmlns:mc":"xmlns:mc","xmlns:aink":"xmlns:aink","xmlns:am3d":"xmlns:am3d","xmlns:o":"xmlns:o","xmlns:r":"xmlns:r","xmlns:m":"xmlns:m","xmlns:v":"xmlns:v","xmlns:wp14":"xmlns:wp14","xmlns:wp":"xmlns:wp","xmlns:w10":"xmlns:w10","xmlns:w":"xmlns:w","xmlns:w14":"xmlns:w14","xmlns:w15":"xmlns:w15","xmlns:w16cex":"xmlns:w16cex","xmlns:w16cid":"xmlns:w16cid","xmlns:w16":"xmlns:w16","xmlns:w16sdtdh":"xmlns:w16sdtdh","xmlns:w16se":"xmlns:w16se","xmlns:wpg":"xmlns:wpg","xmlns:wpi":"xmlns:wpi","xmlns:wne":"xmlns:wne","xmlns:wps":"xmlns:wps"})}},dY=class extends t{constructor(B){super("w:commentRangeStart");this.root.push(new s8({id:B}))}},cY=class extends t{constructor(B){super("w:commentRangeEnd");this.root.push(new s8({id:B}))}},mY=class extends t{constructor(B){super("w:commentReference");this.root.push(new s8({id:B}))}},A8=class extends t{constructor({id:B,initials:U,author:G,date:Y=new Date,children:Q},K){super("w:comment");e(this,"paraId",void 0),this.paraId=K,this.root.push(new hY({id:B,initials:U,author:G,date:Y.toISOString()}));for(let Z of Q)this.root.push(Z)}prepForXml(B){let U=super.prepForXml(B);if(!U||!this.paraId)return U;let G=U["w:comment"];if(!Array.isArray(G))return U;for(let Y=G.length-1;Y>=0;Y--){let Q=G[Y];if(Q&&typeof Q==="object"&&"w:p"in Q){let K=Q["w:p"];if(Array.isArray(K))K.unshift({_attr:{"w14:paraId":this.paraId,"w14:textId":this.paraId}});break}}return U}},N4=(B)=>(B+1).toString(16).toUpperCase().padStart(8,"0"),z4=class extends t{constructor({children:B}){super("w:comments");if(e(this,"relationships",void 0),e(this,"threadData",void 0),this.root.push(new uY({"xmlns:cx":"http://schemas.microsoft.com/office/drawing/2014/chartex","xmlns:cx1":"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex","xmlns:cx2":"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex","xmlns:cx3":"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex","xmlns:cx4":"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex","xmlns:cx5":"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex","xmlns:cx6":"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex","xmlns:cx7":"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex","xmlns:cx8":"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","xmlns:aink":"http://schemas.microsoft.com/office/drawing/2016/ink","xmlns:am3d":"http://schemas.microsoft.com/office/drawing/2017/model3d","xmlns:o":"urn:schemas-microsoft-com:office:office","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:m":"http://schemas.openxmlformats.org/officeDocument/2006/math","xmlns:v":"urn:schemas-microsoft-com:vml","xmlns:wp14":"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing","xmlns:wp":"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing","xmlns:w10":"urn:schemas-microsoft-com:office:word","xmlns:w":"http://schemas.openxmlformats.org/wordprocessingml/2006/main","xmlns:w14":"http://schemas.microsoft.com/office/word/2010/wordml","xmlns:w15":"http://schemas.microsoft.com/office/word/2012/wordml","xmlns:w16cex":"http://schemas.microsoft.com/office/word/2018/wordml/cex","xmlns:w16cid":"http://schemas.microsoft.com/office/word/2016/wordml/cid","xmlns:w16":"http://schemas.microsoft.com/office/word/2018/wordml","xmlns:w16sdtdh":"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash","xmlns:w16se":"http://schemas.microsoft.com/office/word/2015/wordml/symex","xmlns:wpg":"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup","xmlns:wpi":"http://schemas.microsoft.com/office/word/2010/wordprocessingInk","xmlns:wne":"http://schemas.microsoft.com/office/word/2006/wordml","xmlns:wps":"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"})),B.some((U)=>U.parentId!==void 0)){let U=new Map(B.map((G)=>[G.id,N4(G.id)]));for(let G of B)this.root.push(new A8(G,U.get(G.id)));this.threadData=B.map((G)=>({paraId:U.get(G.id),parentParaId:G.parentId!==void 0?U.get(G.parentId):void 0,done:G.resolved}))}else for(let U of B)this.root.push(new A8(U));this.relationships=new w2}get Relationships(){return this.relationships}get ThreadData(){return this.threadData}},lY=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{"xmlns:wpc":"xmlns:wpc","xmlns:mc":"xmlns:mc","xmlns:w15":"xmlns:w15","mc:Ignorable":"mc:Ignorable"})}},aY=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{paraId:"w15:paraId",paraIdParent:"w15:paraIdParent",done:"w15:done"})}},pY=class extends t{constructor(B){super("w15:commentEx");this.root.push(new aY({paraId:B.paraId,paraIdParent:B.parentParaId,done:B.done!==void 0?B.done?"1":"0":void 0}))}},E4=class extends t{constructor(B){super("w15:commentsEx");this.root.push(new lY({"xmlns:wpc":"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","xmlns:w15":"http://schemas.microsoft.com/office/word/2012/wordml","mc:Ignorable":"w15"}));for(let U of B)this.root.push(new pY(U))}},rY=class extends S0{constructor(){super("w:noBreakHyphen")}},iY=class extends S0{constructor(){super("w:softHyphen")}},nY=class extends S0{constructor(){super("w:dayShort")}},sY=class extends S0{constructor(){super("w:monthShort")}},oY=class extends S0{constructor(){super("w:yearShort")}},tY=class extends S0{constructor(){super("w:dayLong")}},eY=class extends S0{constructor(){super("w:monthLong")}},BZ=class extends S0{constructor(){super("w:yearLong")}},UZ=class extends S0{constructor(){super("w:annotationRef")}},GZ=class extends S0{constructor(){super("w:footnoteRef")}},T4=class extends S0{constructor(){super("w:endnoteRef")}},YZ=class extends S0{constructor(){super("w:separator")}},ZZ=class extends S0{constructor(){super("w:continuationSeparator")}},QZ=class extends S0{constructor(){super("w:pgNum")}},JZ=class extends S0{constructor(){super("w:cr")}},D4=class extends S0{constructor(){super("w:tab")}},KZ=class extends S0{constructor(){super("w:lastRenderedPageBreak")}},VZ={LEFT:"left",CENTER:"center",RIGHT:"right"},qZ={MARGIN:"margin",INDENT:"indent"},MZ={NONE:"none",DOT:"dot",HYPHEN:"hyphen",UNDERSCORE:"underscore",MIDDLE_DOT:"middleDot"},XZ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{alignment:"w:alignment",relativeTo:"w:relativeTo",leader:"w:leader"})}},RZ=class extends t{constructor(B){super("w:ptab");this.root.push(new XZ({alignment:B.alignment,relativeTo:B.relativeTo,leader:B.leader}))}},C4={COLUMN:"column",PAGE:"page"},k4=class extends t{constructor(B){super("w:br");this.root.push(new C0({type:B}))}},LZ=class extends T0{constructor(){super({});this.root.push(new k4(C4.PAGE))}},IZ=class extends T0{constructor(){super({});this.root.push(new k4(C4.COLUMN))}},$4=class extends t{constructor(){super("w:pageBreakBefore")}},k2={AT_LEAST:"atLeast",EXACTLY:"exactly",EXACT:"exact",AUTO:"auto"},S4=({after:B,before:U,line:G,lineRule:Y,beforeAutoSpacing:Q,afterAutoSpacing:K})=>new X0({name:"w:spacing",attributes:{after:{key:"w:after",value:B},before:{key:"w:before",value:U},line:{key:"w:line",value:G},lineRule:{key:"w:lineRule",value:Y},beforeAutoSpacing:{key:"w:beforeAutospacing",value:Q},afterAutoSpacing:{key:"w:afterAutospacing",value:K}}}),OZ={HEADING_1:"Heading1",HEADING_2:"Heading2",HEADING_3:"Heading3",HEADING_4:"Heading4",HEADING_5:"Heading5",HEADING_6:"Heading6",TITLE:"Title"},x2=(B)=>new X0({name:"w:pStyle",attributes:{val:{key:"w:val",value:B}}}),j8={LEFT:"left",RIGHT:"right",CENTER:"center",BAR:"bar",CLEAR:"clear",DECIMAL:"decimal",END:"end",NUM:"num",START:"start"},FZ={DOT:"dot",HYPHEN:"hyphen",MIDDLE_DOT:"middleDot",NONE:"none",UNDERSCORE:"underscore"},HZ={MAX:9026},b4=({type:B,position:U,leader:G})=>new X0({name:"w:tab",attributes:{val:{key:"w:val",value:B},pos:{key:"w:pos",value:U},leader:{key:"w:leader",value:G}}}),v4=(B)=>new X0({name:"w:tabs",children:B.map((U)=>b4(U))}),D1=class extends t{constructor(B,U){super("w:numPr");this.root.push(new WZ(U)),this.root.push(new PZ(B))}},WZ=class extends t{constructor(B){super("w:ilvl");if(B>9)throw Error("Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7");this.root.push(new C0({val:B}))}},PZ=class extends t{constructor(B){super("w:numId");this.root.push(new C0({val:typeof B==="string"?`{${B}}`:B}))}},F1=class extends t{constructor(...B){super(...B);e(this,"fileChild",Symbol())}},wZ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{id:"r:id",history:"w:history",anchor:"w:anchor"})}},AZ={INTERNAL:"INTERNAL",EXTERNAL:"EXTERNAL"},m2=class extends t{constructor(B,U,G){super("w:hyperlink");e(this,"linkId",void 0),this.linkId=U;let Y=new wZ({history:1,anchor:G?G:void 0,id:!G?`rId${this.linkId}`:void 0});this.root.push(Y),B.forEach((Q)=>{this.root.push(Q)})}},y4=class extends m2{constructor(B){super(B.children,O1(),B.anchor)}},o8=class extends t{constructor(B){super("w:externalHyperlink");e(this,"options",void 0),this.options=B}},jZ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{id:"w:id",name:"w:name"})}},NZ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{id:"w:id"})}},g4=class{constructor(B){e(this,"bookmarkUniqueNumericId",tB()),e(this,"start",void 0),e(this,"children",void 0),e(this,"end",void 0);let U=this.bookmarkUniqueNumericId();this.start=new f4(B.id,U),this.children=B.children,this.end=new x4(U)}},f4=class extends t{constructor(B,U){super("w:bookmarkStart");let G=new jZ({name:B,id:U});this.root.push(G)}},x4=class extends t{constructor(B){super("w:bookmarkEnd");let U=new NZ({id:B});this.root.push(U)}},zZ=function(B){return B.NONE="none",B.RELATIVE="relative",B.NO_CONTEXT="no_context",B.FULL_CONTEXT="full_context",B}({}),EZ={["relative"]:"\\r",["no_context"]:"\\n",["full_context"]:"\\w",["none"]:void 0},TZ=class extends n8{constructor(B,U,G={}){let{hyperlink:Y=!0,referenceFormat:Q="full_context"}=G,K=`${`REF ${B}`} ${[...Y?["\\h"]:[],...[EZ[Q]].filter((Z)=>!!Z)].join(" ")}`;super(K,U)}},_4=(B)=>new X0({name:"w:outlineLvl",attributes:{val:{key:"w:val",value:B}}}),DZ=class extends t{constructor(B,U={}){super("w:instrText");this.root.push(new _0({space:x0.PRESERVE}));let G=`PAGEREF ${B}`;if(U.hyperlink)G=`${G} \\h`;if(U.useRelativePosition)G=`${G} \\p`;this.root.push(G)}},CZ=class extends T0{constructor(B,U={}){super({children:[e0(!0),new DZ(B,U),B2()]})}},kZ={ANSI:"00",DEFAULT:"01",SYMBOL:"02",MAC:"4D",JIS:"80",HANGUL:"81",JOHAB:"82",GB_2312:"86",CHINESEBIG5:"88",GREEK:"A1",TURKISH:"A2",VIETNAMESE:"A3",HEBREW:"B1",ARABIC:"B2",BALTIC:"BA",RUSSIAN:"CC",THAI:"DE",EASTEUROPE:"EE",OEM:"FF"},z1=({id:B,fontKey:U,subsetted:G},Y)=>new X0({name:Y,attributes:L0({id:{key:"r:id",value:B}},U?{fontKey:{key:"w:fontKey",value:`{${U}}`}}:{}),children:[...G?[new M0("w:subsetted",G)]:[]]}),$Z=({name:B,altName:U,panose1:G,charset:Y,family:Q,notTrueType:K,pitch:Z,sig:J,embedRegular:M,embedBold:W,embedItalic:I,embedBoldItalic:F})=>new X0({name:"w:font",attributes:{name:{key:"w:name",value:B}},children:[...U?[f2("w:altName",U)]:[],...G?[f2("w:panose1",G)]:[],...Y?[f2("w:charset",Y)]:[],...Q?[f2("w:family",Q)]:[],...K?[new M0("w:notTrueType",K)]:[],...Z?[f2("w:pitch",Z)]:[],...J?[new X0({name:"w:sig",attributes:{usb0:{key:"w:usb0",value:J.usb0},usb1:{key:"w:usb1",value:J.usb1},usb2:{key:"w:usb2",value:J.usb2},usb3:{key:"w:usb3",value:J.usb3},csb0:{key:"w:csb0",value:J.csb0},csb1:{key:"w:csb1",value:J.csb1}}})]:[],...M?[z1(M,"w:embedRegular")]:[],...W?[z1(W,"w:embedBold")]:[],...I?[z1(I,"w:embedItalic")]:[],...F?[z1(F,"w:embedBoldItalic")]:[]]}),SZ=({name:B,index:U,fontKey:G,characterSet:Y})=>$Z({name:B,sig:{usb0:"E0002AFF",usb1:"C000247B",usb2:"00000009",usb3:"00000000",csb0:"000001FF",csb1:"00000000"},charset:Y,family:"auto",pitch:"variable",embedRegular:{fontKey:G,id:`rId${U}`}}),bZ=(B)=>new X0({name:"w:fonts",attributes:{mc:{key:"xmlns:mc",value:"http://schemas.openxmlformats.org/markup-compatibility/2006"},r:{key:"xmlns:r",value:"http://schemas.openxmlformats.org/officeDocument/2006/relationships"},w:{key:"xmlns:w",value:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"},w14:{key:"xmlns:w14",value:"http://schemas.microsoft.com/office/word/2010/wordml"},w15:{key:"xmlns:w15",value:"http://schemas.microsoft.com/office/word/2012/wordml"},w16cex:{key:"xmlns:w16cex",value:"http://schemas.microsoft.com/office/word/2018/wordml/cex"},w16cid:{key:"xmlns:w16cid",value:"http://schemas.microsoft.com/office/word/2016/wordml/cid"},w16:{key:"xmlns:w16",value:"http://schemas.microsoft.com/office/word/2018/wordml"},w16sdtdh:{key:"xmlns:w16sdtdh",value:"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash"},w16se:{key:"xmlns:w16se",value:"http://schemas.microsoft.com/office/word/2015/wordml/symex"},Ignorable:{key:"mc:Ignorable",value:"w14 w15 w16se w16cid w16 w16cex w16sdtdh"}},children:B.map((U,G)=>SZ({name:U.name,index:G+1,fontKey:U.fontKey,characterSet:U.characterSet}))}),h4=class{constructor(B){e(this,"options",void 0),e(this,"fontTable",void 0),e(this,"relationships",void 0),e(this,"fontOptionsWithKey",[]),this.options=B,this.fontOptionsWithKey=B.map((U)=>L0(L0({},U),{},{fontKey:eB()})),this.fontTable=bZ(this.fontOptionsWithKey),this.relationships=new w2;for(let U=0;Unew X0({name:"w:wordWrap",attributes:{val:{key:"w:val",value:0}}}),yZ={NONE:"none",DROP:"drop",MARGIN:"margin"},gZ={MARGIN:"margin",PAGE:"page",TEXT:"text"},fZ={AROUND:"around",AUTO:"auto",NONE:"none",NOT_BESIDE:"notBeside",THROUGH:"through",TIGHT:"tight"},u4=(B)=>{var U,G;return new X0({name:"w:framePr",attributes:{anchorLock:{key:"w:anchorLock",value:B.anchorLock},dropCap:{key:"w:dropCap",value:B.dropCap},width:{key:"w:w",value:B.width},height:{key:"w:h",value:B.height},x:{key:"w:x",value:B.position?B.position.x:void 0},y:{key:"w:y",value:B.position?B.position.y:void 0},anchorHorizontal:{key:"w:hAnchor",value:B.anchor.horizontal},anchorVertical:{key:"w:vAnchor",value:B.anchor.vertical},spaceHorizontal:{key:"w:hSpace",value:(U=B.space)===null||U===void 0?void 0:U.horizontal},spaceVertical:{key:"w:vSpace",value:(G=B.space)===null||G===void 0?void 0:G.vertical},rule:{key:"w:hRule",value:B.rule},alignmentX:{key:"w:xAlign",value:B.alignment?B.alignment.x:void 0},alignmentY:{key:"w:yAlign",value:B.alignment?B.alignment.y:void 0},lines:{key:"w:lines",value:B.lines},wrap:{key:"w:wrap",value:B.wrap}}})},X2=class extends R2{constructor(B){super("w:pPr",B===null||B===void 0?void 0:B.includeIfEmpty);if(e(this,"numberingReferences",[]),!B)return this;if(B.heading)this.push(x2(B.heading));if(B.bullet)this.push(x2("ListParagraph"));if(B.numbering){if(!B.style&&!B.heading){if(!B.numbering.custom)this.push(x2("ListParagraph"))}}if(B.style)this.push(x2(B.style));if(B.keepNext!==void 0)this.push(new M0("w:keepNext",B.keepNext));if(B.keepLines!==void 0)this.push(new M0("w:keepLines",B.keepLines));if(B.pageBreakBefore)this.push(new $4);if(B.frame)this.push(u4(B.frame));if(B.widowControl!==void 0)this.push(new M0("w:widowControl",B.widowControl));if(B.bullet)this.push(new D1(1,B.bullet.level));if(B.numbering){var U,G;this.numberingReferences.push({reference:B.numbering.reference,instance:(U=B.numbering.instance)!==null&&U!==void 0?U:0}),this.push(new D1(`${B.numbering.reference}-${(G=B.numbering.instance)!==null&&G!==void 0?G:0}`,B.numbering.level))}else if(B.numbering===!1)this.push(new D1(0,0));if(B.border)this.push(new xB(B.border));if(B.thematicBreak)this.push(new _B);if(B.shading)this.push(X1(B.shading));if(B.wordWrap)this.push(vZ());if(B.overflowPunctuation)this.push(new M0("w:overflowPunct",B.overflowPunctuation));let Y=[...B.rightTabStop!==void 0?[{type:j8.RIGHT,position:B.rightTabStop}]:[],...B.tabStops?B.tabStops:[],...B.leftTabStop!==void 0?[{type:j8.LEFT,position:B.leftTabStop}]:[]];if(Y.length>0)this.push(v4(Y));if(B.bidirectional!==void 0)this.push(new M0("w:bidi",B.bidirectional));if(B.spacing)this.push(S4(B.spacing));if(B.indent)this.push(hB(B.indent));if(B.contextualSpacing!==void 0)this.push(new M0("w:contextualSpacing",B.contextualSpacing));if(B.alignment)this.push(c8(B.alignment));if(B.outlineLevel!==void 0)this.push(_4(B.outlineLevel));if(B.suppressLineNumbers!==void 0)this.push(new M0("w:suppressLineNumbers",B.suppressLineNumbers));if(B.autoSpaceEastAsianText!==void 0)this.push(new M0("w:autoSpaceDN",B.autoSpaceEastAsianText));if(B.run)this.push(new mB(B.run));if(B.revision)this.push(new d4(B.revision))}push(B){this.root.push(B)}prepForXml(B){if(!(B.viewWrapper instanceof h4))for(let U of this.numberingReferences)B.file.Numbering.createConcreteNumberingInstance(U.reference,U.instance);return super.prepForXml(B)}},d4=class extends t{constructor(B){super("w:pPrChange");this.root.push(new b0({id:B.id,author:B.author,date:B.date})),this.root.push(new X2(L0(L0({},B),{},{includeIfEmpty:!0})))}},d0=class extends F1{constructor(B){super("w:p");if(e(this,"properties",void 0),typeof B==="string")return this.properties=new X2({}),this.root.push(this.properties),this.root.push(new Q1(B)),this;if(this.properties=new X2(B),this.root.push(this.properties),B.text)this.root.push(new Q1(B.text));if(B.children)for(let U of B.children){if(U instanceof g4){this.root.push(U.start);for(let G of U.children)this.root.push(G);this.root.push(U.end);continue}this.root.push(U)}}prepForXml(B){for(let U of this.root)if(U instanceof o8){let G=this.root.indexOf(U),Y=new m2(U.options.children,O1());B.viewWrapper.Relationships.addRelationship(Y.linkId,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",U.options.link,j4.EXTERNAL),this.root[G]=Y}return super.prepForXml(B)}addRunToFront(B){return this.root.splice(1,0,B),this}},xZ=class extends t{constructor(B){super("m:oMath");for(let U of B.children)this.root.push(U)}},_Z=class extends t{constructor(B){super("m:t");this.root.push(B)}},hZ=class extends t{constructor(B){super("m:r");this.root.push(new _Z(B))}},c4=class extends t{constructor(B){super("m:den");for(let U of B)this.root.push(U)}},m4=class extends t{constructor(B){super("m:num");for(let U of B)this.root.push(U)}},uZ=class extends t{constructor(B){super("m:f");this.root.push(new m4(B.numerator)),this.root.push(new c4(B.denominator))}},l4=({accent:B})=>new X0({name:"m:chr",attributes:{accent:{key:"m:val",value:B}}}),y0=({children:B})=>new X0({name:"m:e",children:B}),a4=({value:B})=>new X0({name:"m:limLoc",attributes:{value:{key:"m:val",value:B||"undOvr"}}}),dZ=()=>new X0({name:"m:subHide",attributes:{hide:{key:"m:val",value:1}}}),cZ=()=>new X0({name:"m:supHide",attributes:{hide:{key:"m:val",value:1}}}),t8=({accent:B,hasSuperScript:U,hasSubScript:G,limitLocationVal:Y})=>new X0({name:"m:naryPr",children:[...B?[l4({accent:B})]:[],a4({value:Y}),...!U?[cZ()]:[],...!G?[dZ()]:[]]}),l2=({children:B})=>new X0({name:"m:sub",children:B}),a2=({children:B})=>new X0({name:"m:sup",children:B}),mZ=class extends t{constructor(B){super("m:nary");if(this.root.push(t8({accent:"∑",hasSuperScript:!!B.superScript,hasSubScript:!!B.subScript})),B.subScript)this.root.push(l2({children:B.subScript}));if(B.superScript)this.root.push(a2({children:B.superScript}));this.root.push(y0({children:B.children}))}},lZ=class extends t{constructor(B){super("m:nary");if(this.root.push(t8({accent:"",hasSuperScript:!!B.superScript,hasSubScript:!!B.subScript,limitLocationVal:"subSup"})),B.subScript)this.root.push(l2({children:B.subScript}));if(B.superScript)this.root.push(a2({children:B.superScript}));this.root.push(y0({children:B.children}))}},e8=class extends t{constructor(B){super("m:lim");for(let U of B)this.root.push(U)}},aZ=class extends t{constructor(B){super("m:limUpp");this.root.push(y0({children:B.children})),this.root.push(new e8(B.limit))}},pZ=class extends t{constructor(B){super("m:limLow");this.root.push(y0({children:B.children})),this.root.push(new e8(B.limit))}},p4=()=>new X0({name:"m:sSupPr"}),rZ=class extends t{constructor(B){super("m:sSup");this.root.push(p4()),this.root.push(y0({children:B.children})),this.root.push(a2({children:B.superScript}))}},r4=()=>new X0({name:"m:sSubPr"}),iZ=class extends t{constructor(B){super("m:sSub");this.root.push(r4()),this.root.push(y0({children:B.children})),this.root.push(l2({children:B.subScript}))}},i4=()=>new X0({name:"m:sSubSupPr"}),nZ=class extends t{constructor(B){super("m:sSubSup");this.root.push(i4()),this.root.push(y0({children:B.children})),this.root.push(l2({children:B.subScript})),this.root.push(a2({children:B.superScript}))}},n4=()=>new X0({name:"m:sPrePr"}),sZ=class extends X0{constructor({children:B,subScript:U,superScript:G}){super({name:"m:sPre",children:[n4(),y0({children:B}),l2({children:U}),a2({children:G})]})}},oZ="",s4=class extends t{constructor(B){super("m:deg");if(B)for(let U of B)this.root.push(U)}},tZ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{hide:"m:val"})}},eZ=class extends t{constructor(){super("m:degHide");this.root.push(new tZ({hide:1}))}},o4=class extends t{constructor(B){super("m:radPr");if(!B)this.root.push(new eZ)}},BQ=class extends t{constructor(B){super("m:rad");this.root.push(new o4(!!B.degree)),this.root.push(new s4(B.degree)),this.root.push(y0({children:B.children}))}},t4=class extends t{constructor(B){super("m:fName");for(let U of B)this.root.push(U)}},e4=class extends t{constructor(){super("m:funcPr")}},UQ=class extends t{constructor(B){super("m:func");this.root.push(new e4),this.root.push(new t4(B.name)),this.root.push(y0({children:B.children}))}},GQ=({character:B})=>new X0({name:"m:begChr",attributes:{character:{key:"m:val",value:B}}}),YQ=({character:B})=>new X0({name:"m:endChr",attributes:{character:{key:"m:val",value:B}}}),m1=({characters:B})=>new X0({name:"m:dPr",children:B?[GQ({character:B.beginningCharacter}),YQ({character:B.endingCharacter})]:[]}),ZQ=class extends t{constructor(B){super("m:d");this.root.push(m1({})),this.root.push(y0({children:B.children}))}},QQ=class extends t{constructor(B){super("m:d");this.root.push(m1({characters:{beginningCharacter:"[",endingCharacter:"]"}})),this.root.push(y0({children:B.children}))}},JQ=class extends t{constructor(B){super("m:d");this.root.push(m1({characters:{beginningCharacter:"{",endingCharacter:"}"}})),this.root.push(y0({children:B.children}))}},KQ=class extends t{constructor(B){super("m:d");this.root.push(m1({characters:{beginningCharacter:"〈",endingCharacter:"〉"}})),this.root.push(y0({children:B.children}))}},VQ=(B)=>new X0({name:"w:gridCol",attributes:B!==void 0?{width:{key:"w:w",value:E0(B)}}:void 0}),B9=class extends t{constructor(B,U){super("w:tblGrid");for(let G of B)this.root.push(VQ(G));if(U)this.root.push(new MQ(U))}},qQ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{id:"w:id"})}},MQ=class extends t{constructor(B){super("w:tblGridChange");this.root.push(new qQ({id:B.id})),this.root.push(new B9(B.columnWidths))}},XQ=class extends t{constructor(B){super("w:ins");this.root.push(new b0({id:B.id,author:B.author,date:B.date})),this.addChildElement(new Q1(B))}},RQ=class extends t{constructor(){super("w:delInstrText");this.root.push(new _0({space:x0.PRESERVE})),this.root.push("PAGE")}},LQ=class extends t{constructor(){super("w:delInstrText");this.root.push(new _0({space:x0.PRESERVE})),this.root.push("NUMPAGES")}},IQ=class extends t{constructor(){super("w:delInstrText");this.root.push(new _0({space:x0.PRESERVE})),this.root.push("SECTIONPAGES")}},p6=class extends t{constructor(B){super("w:delText");this.root.push(new _0({space:x0.PRESERVE})),this.root.push(B)}},OQ=class extends t{constructor(B){super("w:del");e(this,"deletedTextRunWrapper",void 0),this.root.push(new b0({id:B.id,author:B.author,date:B.date})),this.deletedTextRunWrapper=new FQ(B),this.addChildElement(this.deletedTextRunWrapper)}},FQ=class extends t{constructor(B){super("w:r");if(this.root.push(new U2(B)),B.children)for(let U of B.children){if(typeof U==="string"){switch(U){case H2.CURRENT:this.root.push(e0()),this.root.push(new RQ),this.root.push(q2()),this.root.push(B2());break;case H2.TOTAL_PAGES:this.root.push(e0()),this.root.push(new LQ),this.root.push(q2()),this.root.push(B2());break;case H2.TOTAL_PAGES_IN_SECTION:this.root.push(e0()),this.root.push(new IQ),this.root.push(q2()),this.root.push(B2());break;default:this.root.push(new p6(U));break}continue}this.root.push(U)}else if(B.text)this.root.push(new p6(B.text));if(B.break)for(let U=0;Unew X0({name:"w:vAlign",attributes:{verticalAlign:{key:"w:val",value:B}}}),q9=({marginUnitType:B=b1.DXA,top:U,left:G,bottom:Y,right:Q})=>[{name:"w:top",size:U},{name:"w:left",size:G},{name:"w:bottom",size:Y},{name:"w:right",size:Q}].filter((K)=>K.size!==void 0).map(({name:K,size:Z})=>J1(K,{type:B,size:Z})),PQ=(B)=>{let U=q9(B);if(U.length===0)return;return new X0({name:"w:tblCellMar",children:U})},wQ=(B)=>{let U=q9(B);if(U.length===0)return;return new X0({name:"w:tcMar",children:U})},b1={AUTO:"auto",DXA:"dxa",NIL:"nil",PERCENTAGE:"pct"},J1=(B,{type:U=b1.AUTO,size:G})=>{let Y=G;if(U===b1.PERCENTAGE&&typeof G==="number")Y=`${G}%`;return new X0({name:B,attributes:{type:{key:"w:type",value:U},size:{key:"w:w",value:d8(Y)}}})},M9=class extends R2{constructor(B){super("w:tcBorders");if(B.top)this.root.push(A0("w:top",B.top));if(B.start)this.root.push(A0("w:start",B.start));if(B.left)this.root.push(A0("w:left",B.left));if(B.bottom)this.root.push(A0("w:bottom",B.bottom));if(B.end)this.root.push(A0("w:end",B.end));if(B.right)this.root.push(A0("w:right",B.right))}},AQ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{val:"w:val"})}},X9=class extends t{constructor(B){super("w:gridSpan");this.root.push(new AQ({val:D0(B)}))}},U6={CONTINUE:"continue",RESTART:"restart"},jQ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{val:"w:val"})}},N8=class extends t{constructor(B){super("w:vMerge");this.root.push(new jQ({val:B}))}},NQ={BOTTOM_TO_TOP_LEFT_TO_RIGHT:"btLr",LEFT_TO_RIGHT_TOP_TO_BOTTOM:"lrTb",TOP_TO_BOTTOM_RIGHT_TO_LEFT:"tbRl"},zQ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{val:"w:val"})}},R9=class extends t{constructor(B){super("w:textDirection");this.root.push(new zQ({val:B}))}},L9=class extends R2{constructor(B){super("w:tcPr",B.includeIfEmpty);if(B.width)this.root.push(J1("w:tcW",B.width));if(B.columnSpan)this.root.push(new X9(B.columnSpan));if(B.verticalMerge)this.root.push(new N8(B.verticalMerge));else if(B.rowSpan&&B.rowSpan>1)this.root.push(new N8(U6.RESTART));if(B.borders)this.root.push(new M9(B.borders));if(B.shading)this.root.push(X1(B.shading));if(B.margins){let U=wQ(B.margins);if(U)this.root.push(U)}if(B.textDirection)this.root.push(new R9(B.textDirection));if(B.verticalAlign)this.root.push(B6(B.verticalAlign));if(B.insertion)this.root.push(new Y9(B.insertion));if(B.deletion)this.root.push(new Z9(B.deletion));if(B.revision)this.root.push(new EQ(B.revision));if(B.cellMerge)this.root.push(new J9(B.cellMerge))}},EQ=class extends t{constructor(B){super("w:tcPrChange");this.root.push(new b0({id:B.id,author:B.author,date:B.date})),this.root.push(new L9(L0(L0({},B),{},{includeIfEmpty:!0})))}},G6=class extends t{constructor(B){super("w:tc");e(this,"options",void 0),this.options=B,this.root.push(new L9(B));for(let U of B.children)this.root.push(U)}prepForXml(B){if(!(this.root[this.root.length-1]instanceof d0))this.root.push(new d0({}));return super.prepForXml(B)}},v2={style:d1.NONE,size:0,color:"auto"},y2={style:d1.SINGLE,size:4,color:"auto"},Y6=class extends t{constructor(B){var U,G,Y,Q,K,Z;super("w:tblBorders");this.root.push(A0("w:top",(U=B.top)!==null&&U!==void 0?U:y2)),this.root.push(A0("w:left",(G=B.left)!==null&&G!==void 0?G:y2)),this.root.push(A0("w:bottom",(Y=B.bottom)!==null&&Y!==void 0?Y:y2)),this.root.push(A0("w:right",(Q=B.right)!==null&&Q!==void 0?Q:y2)),this.root.push(A0("w:insideH",(K=B.insideHorizontal)!==null&&K!==void 0?K:y2)),this.root.push(A0("w:insideV",(Z=B.insideVertical)!==null&&Z!==void 0?Z:y2))}};e(Y6,"NONE",{top:v2,bottom:v2,left:v2,right:v2,insideHorizontal:v2,insideVertical:v2});var TQ={MARGIN:"margin",PAGE:"page",TEXT:"text"},DQ={CENTER:"center",INSIDE:"inside",LEFT:"left",OUTSIDE:"outside",RIGHT:"right"},CQ={CENTER:"center",INSIDE:"inside",BOTTOM:"bottom",OUTSIDE:"outside",INLINE:"inline",TOP:"top"},kQ={NEVER:"never",OVERLAP:"overlap"},$Q=(B)=>new X0({name:"w:tblOverlap",attributes:{val:{key:"w:val",value:B}}}),I9=({horizontalAnchor:B,verticalAnchor:U,absoluteHorizontalPosition:G,relativeHorizontalPosition:Y,absoluteVerticalPosition:Q,relativeVerticalPosition:K,bottomFromText:Z,topFromText:J,leftFromText:M,rightFromText:W,overlap:I})=>new X0({name:"w:tblpPr",attributes:{leftFromText:{key:"w:leftFromText",value:M===void 0?void 0:E0(M)},rightFromText:{key:"w:rightFromText",value:W===void 0?void 0:E0(W)},topFromText:{key:"w:topFromText",value:J===void 0?void 0:E0(J)},bottomFromText:{key:"w:bottomFromText",value:Z===void 0?void 0:E0(Z)},absoluteHorizontalPosition:{key:"w:tblpX",value:G===void 0?void 0:t0(G)},absoluteVerticalPosition:{key:"w:tblpY",value:Q===void 0?void 0:t0(Q)},horizontalAnchor:{key:"w:horzAnchor",value:B},relativeHorizontalPosition:{key:"w:tblpXSpec",value:Y},relativeVerticalPosition:{key:"w:tblpYSpec",value:K},verticalAnchor:{key:"w:vertAnchor",value:U}},children:I?[$Q(I)]:void 0}),SQ={AUTOFIT:"autofit",FIXED:"fixed"},O9=(B)=>new X0({name:"w:tblLayout",attributes:{type:{key:"w:type",value:B}}}),bQ={DXA:"dxa",NIL:"nil"},F9=({type:B=bQ.DXA,value:U})=>new X0({name:"w:tblCellSpacing",attributes:{type:{key:"w:type",value:B},value:{key:"w:w",value:d8(U)}}}),H9=({firstRow:B,lastRow:U,firstColumn:G,lastColumn:Y,noHBand:Q,noVBand:K})=>new X0({name:"w:tblLook",attributes:{firstRow:{key:"w:firstRow",value:B},lastRow:{key:"w:lastRow",value:U},firstColumn:{key:"w:firstColumn",value:G},lastColumn:{key:"w:lastColumn",value:Y},noHBand:{key:"w:noHBand",value:Q},noVBand:{key:"w:noVBand",value:K}}}),Z6=class extends R2{constructor(B){super("w:tblPr",B.includeIfEmpty);if(B.style)this.root.push(new M2("w:tblStyle",B.style));if(B.float)this.root.push(I9(B.float));if(B.visuallyRightToLeft!==void 0)this.root.push(new M0("w:bidiVisual",B.visuallyRightToLeft));if(B.width)this.root.push(J1("w:tblW",B.width));if(B.alignment)this.root.push(c8(B.alignment));if(B.indent)this.root.push(J1("w:tblInd",B.indent));if(B.borders)this.root.push(new Y6(B.borders));if(B.shading)this.root.push(X1(B.shading));if(B.layout)this.root.push(O9(B.layout));if(B.cellMargin){let U=PQ(B.cellMargin);if(U)this.root.push(U)}if(B.tableLook)this.root.push(H9(B.tableLook));if(B.cellSpacing)this.root.push(F9(B.cellSpacing));if(B.revision)this.root.push(new vQ(B.revision))}},vQ=class extends t{constructor(B){super("w:tblPrChange");this.root.push(new b0({id:B.id,author:B.author,date:B.date})),this.root.push(new Z6(L0(L0({},B),{},{includeIfEmpty:!0})))}},yQ=class extends F1{constructor({rows:B,width:U,columnWidths:G=Array(Math.max(...B.map((A)=>A.CellCount))).fill(100),columnWidthsRevision:Y,margins:Q,indent:K,float:Z,layout:J,style:M,borders:W,alignment:I,visuallyRightToLeft:F,tableLook:D,cellSpacing:w,revision:P}){super("w:tbl");this.root.push(new Z6({borders:W!==null&&W!==void 0?W:{},width:U!==null&&U!==void 0?U:{size:100},indent:K,float:Z,layout:J,style:M,alignment:I,cellMargin:Q,visuallyRightToLeft:F,tableLook:D,cellSpacing:w,revision:P})),this.root.push(new B9(G,Y));for(let A of B)this.root.push(A);B.forEach((A,E)=>{if(E===B.length-1)return;let C=0;A.cells.forEach((j)=>{if(j.options.rowSpan&&j.options.rowSpan>1){let v=new G6({rowSpan:j.options.rowSpan-1,columnSpan:j.options.columnSpan,borders:j.options.borders,children:[],verticalMerge:U6.CONTINUE});B[E+1].addCellToColumnIndex(v,C)}C+=j.options.columnSpan||1})})}},gQ={AUTO:"auto",ATLEAST:"atLeast",EXACT:"exact"},W9=(B,U)=>new X0({name:"w:trHeight",attributes:{value:{key:"w:val",value:E0(B)},rule:{key:"w:hRule",value:U}}}),Q6=class extends R2{constructor(B){super("w:trPr",B.includeIfEmpty);if(B.cantSplit!==void 0)this.root.push(new M0("w:cantSplit",B.cantSplit));if(B.tableHeader!==void 0)this.root.push(new M0("w:tblHeader",B.tableHeader));if(B.height)this.root.push(W9(B.height.value,B.height.rule));if(B.cellSpacing)this.root.push(F9(B.cellSpacing));if(B.insertion)this.root.push(new U9(B.insertion));if(B.deletion)this.root.push(new G9(B.deletion));if(B.revision)this.root.push(new P9(B.revision))}},P9=class extends t{constructor(B){super("w:trPrChange");this.root.push(new b0({id:B.id,author:B.author,date:B.date})),this.root.push(new Q6(L0(L0({},B),{},{includeIfEmpty:!0})))}},fQ=class extends t{constructor(B){super("w:tr");e(this,"options",void 0),this.options=B,this.root.push(new Q6(B));for(let U of B.children)this.root.push(U)}get CellCount(){return this.options.children.length}get cells(){return this.root.filter((B)=>B instanceof G6)}addCellToIndex(B,U){this.root.splice(U+1,0,B)}addCellToColumnIndex(B,U){let G=this.columnIndexToRootIndex(U,!0);this.addCellToIndex(B,G-1)}rootIndexToColumnIndex(B){if(B<1||B>=this.root.length)throw Error(`cell 'rootIndex' should between 1 to ${this.root.length-1}`);let U=0;for(let G=1;G=this.root.length)if(U)return this.root.length;else throw Error(`cell 'columnIndex' should not great than ${G-1}`);let Q=this.root[Y];Y+=1,G+=Q&&Q.options.columnSpan||1}return Y-1}},xQ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{xmlns:"xmlns",vt:"xmlns:vt"})}},_Q=class extends t{constructor(){super("Properties");this.root.push(new xQ({xmlns:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",vt:"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"}))}},hQ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{xmlns:"xmlns"})}},V2=(B,U)=>new X0({name:"Default",attributes:{contentType:{key:"ContentType",value:B},extension:{key:"Extension",value:U}}}),f0=(B,U)=>new X0({name:"Override",attributes:{contentType:{key:"ContentType",value:B},partName:{key:"PartName",value:U}}}),uQ=class extends t{constructor(){super("Types");this.root.push(new hQ({xmlns:"http://schemas.openxmlformats.org/package/2006/content-types"})),this.root.push(V2("image/png","png")),this.root.push(V2("image/jpeg","jpeg")),this.root.push(V2("image/jpeg","jpg")),this.root.push(V2("image/bmp","bmp")),this.root.push(V2("image/gif","gif")),this.root.push(V2("image/svg+xml","svg")),this.root.push(V2("application/vnd.openxmlformats-package.relationships+xml","rels")),this.root.push(V2("application/xml","xml")),this.root.push(V2("application/vnd.openxmlformats-officedocument.obfuscatedFont","odttf")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml","/word/document.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml","/word/styles.xml")),this.root.push(f0("application/vnd.openxmlformats-package.core-properties+xml","/docProps/core.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.custom-properties+xml","/docProps/custom.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.extended-properties+xml","/docProps/app.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml","/word/numbering.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml","/word/footnotes.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml","/word/endnotes.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml","/word/settings.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml","/word/comments.xml")),this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml","/word/fontTable.xml"))}addCommentsExtended(){this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml","/word/commentsExtended.xml"))}addFooter(B){this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml",`/word/footer${B}.xml`))}addHeader(B){this.root.push(f0("application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml",`/word/header${B}.xml`))}},v1={wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wpi:"http://schemas.microsoft.com/office/word/2010/wordprocessingInk",wne:"http://schemas.microsoft.com/office/word/2006/wordml",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape",cp:"http://schemas.openxmlformats.org/package/2006/metadata/core-properties",dc:"http://purl.org/dc/elements/1.1/",dcterms:"http://purl.org/dc/terms/",dcmitype:"http://purl.org/dc/dcmitype/",xsi:"http://www.w3.org/2001/XMLSchema-instance",cx:"http://schemas.microsoft.com/office/drawing/2014/chartex",cx1:"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex",cx2:"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex",cx3:"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex",cx4:"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex",cx5:"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex",cx6:"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex",cx7:"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex",cx8:"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex",aink:"http://schemas.microsoft.com/office/drawing/2016/ink",am3d:"http://schemas.microsoft.com/office/drawing/2017/model3d",w16cex:"http://schemas.microsoft.com/office/word/2018/wordml/cex",w16cid:"http://schemas.microsoft.com/office/word/2016/wordml/cid",w16:"http://schemas.microsoft.com/office/word/2018/wordml",w16sdtdh:"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash",w16se:"http://schemas.microsoft.com/office/word/2015/wordml/symex"},H1=class extends F0{constructor(B,U){super(L0({Ignorable:U},Object.fromEntries(B.map((G)=>[G,v1[G]]))));e(this,"xmlKeys",L0({Ignorable:"mc:Ignorable"},Object.fromEntries(Object.keys(v1).map((G)=>[G,`xmlns:${G}`]))))}},dQ=class extends t{constructor(B){super("cp:coreProperties");if(this.root.push(new H1(["cp","dc","dcterms","dcmitype","xsi"])),B.title)this.root.push(new O2("dc:title",B.title));if(B.subject)this.root.push(new O2("dc:subject",B.subject));if(B.creator)this.root.push(new O2("dc:creator",B.creator));if(B.keywords)this.root.push(new O2("cp:keywords",B.keywords));if(B.description)this.root.push(new O2("dc:description",B.description));if(B.lastModifiedBy)this.root.push(new O2("cp:lastModifiedBy",B.lastModifiedBy));if(B.revision)this.root.push(new O2("cp:revision",String(B.revision)));this.root.push(new r6("dcterms:created")),this.root.push(new r6("dcterms:modified"))}},cQ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{type:"xsi:type"})}},r6=class extends t{constructor(B){super(B);this.root.push(new cQ({type:"dcterms:W3CDTF"})),this.root.push(fB(new Date))}},mQ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{xmlns:"xmlns",vt:"xmlns:vt"})}},lQ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{formatId:"fmtid",pid:"pid",name:"name"})}},aQ=class extends t{constructor(B,U){super("property");this.root.push(new lQ({formatId:"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",pid:B.toString(),name:U.name})),this.root.push(new pQ(U.value))}},pQ=class extends t{constructor(B){super("vt:lpwstr");this.root.push(B)}},rQ=class extends t{constructor(B){super("Properties");e(this,"nextId",void 0),e(this,"properties",[]),this.root.push(new mQ({xmlns:"http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",vt:"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"})),this.nextId=2;for(let U of B)this.addCustomProperty(U)}prepForXml(B){return this.properties.forEach((U)=>this.root.push(U)),super.prepForXml(B)}addCustomProperty(B){this.properties.push(new aQ(this.nextId++,B))}},w9=({space:B,count:U,separate:G,equalWidth:Y,children:Q})=>new X0({name:"w:cols",attributes:{space:{key:"w:space",value:B===void 0?void 0:E0(B)},count:{key:"w:num",value:U===void 0?void 0:D0(U)},separate:{key:"w:sep",value:G},equalWidth:{key:"w:equalWidth",value:Y}},children:!Y&&Q?Q:void 0}),iQ={DEFAULT:"default",LINES:"lines",LINES_AND_CHARS:"linesAndChars",SNAP_TO_CHARS:"snapToChars"},A9=({type:B,linePitch:U,charSpace:G})=>new X0({name:"w:docGrid",attributes:{type:{key:"w:type",value:B},linePitch:{key:"w:linePitch",value:D0(U)},charSpace:{key:"w:charSpace",value:G?D0(G):void 0}}}),D2={DEFAULT:"default",FIRST:"first",EVEN:"even"},z8={HEADER:"w:headerReference",FOOTER:"w:footerReference"},C1=(B,U)=>new X0({name:B,attributes:{type:{key:"w:type",value:U.type||D2.DEFAULT},id:{key:"r:id",value:`rId${U.id}`}}}),nQ={NEW_PAGE:"newPage",NEW_SECTION:"newSection",CONTINUOUS:"continuous"},j9=({countBy:B,start:U,restart:G,distance:Y})=>new X0({name:"w:lnNumType",attributes:{countBy:{key:"w:countBy",value:B===void 0?void 0:D0(B)},start:{key:"w:start",value:U===void 0?void 0:D0(U)},restart:{key:"w:restart",value:G},distance:{key:"w:distance",value:Y===void 0?void 0:E0(Y)}}}),sQ={ALL_PAGES:"allPages",FIRST_PAGE:"firstPage",NOT_FIRST_PAGE:"notFirstPage"},oQ={PAGE:"page",TEXT:"text"},tQ={BACK:"back",FRONT:"front"},i6=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{display:"w:display",offsetFrom:"w:offsetFrom",zOrder:"w:zOrder"})}},N9=class extends R2{constructor(B){super("w:pgBorders");if(!B)return this;if(B.pageBorders)this.root.push(new i6({display:B.pageBorders.display,offsetFrom:B.pageBorders.offsetFrom,zOrder:B.pageBorders.zOrder}));else this.root.push(new i6({}));if(B.pageBorderTop)this.root.push(A0("w:top",B.pageBorderTop));if(B.pageBorderLeft)this.root.push(A0("w:left",B.pageBorderLeft));if(B.pageBorderBottom)this.root.push(A0("w:bottom",B.pageBorderBottom));if(B.pageBorderRight)this.root.push(A0("w:right",B.pageBorderRight))}},z9=(B,U,G,Y,Q,K,Z)=>new X0({name:"w:pgMar",attributes:{top:{key:"w:top",value:t0(B)},right:{key:"w:right",value:E0(U)},bottom:{key:"w:bottom",value:t0(G)},left:{key:"w:left",value:E0(Y)},header:{key:"w:header",value:E0(Q)},footer:{key:"w:footer",value:E0(K)},gutter:{key:"w:gutter",value:E0(Z)}}}),eQ={HYPHEN:"hyphen",PERIOD:"period",COLON:"colon",EM_DASH:"emDash",EN_DASH:"endash"},E9=({start:B,formatType:U,separator:G})=>new X0({name:"w:pgNumType",attributes:{start:{key:"w:start",value:B===void 0?void 0:D0(B)},formatType:{key:"w:fmt",value:U},separator:{key:"w:chapSep",value:G}}}),y1={PORTRAIT:"portrait",LANDSCAPE:"landscape"},T9=({width:B,height:U,orientation:G,code:Y})=>{let Q=E0(B),K=E0(U);return new X0({name:"w:pgSz",attributes:{width:{key:"w:w",value:G===y1.LANDSCAPE?K:Q},height:{key:"w:h",value:G===y1.LANDSCAPE?Q:K},orientation:{key:"w:orient",value:G},code:{key:"w:code",value:Y}}})},BJ={LEFT_TO_RIGHT_TOP_TO_BOTTOM:"lrTb",TOP_TO_BOTTOM_RIGHT_TO_LEFT:"tbRl"},UJ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{val:"w:val"})}},D9=class extends t{constructor(B){super("w:textDirection");this.root.push(new UJ({val:B}))}},GJ={NEXT_PAGE:"nextPage",NEXT_COLUMN:"nextColumn",CONTINUOUS:"continuous",EVEN_PAGE:"evenPage",ODD_PAGE:"oddPage"},C9=(B)=>new X0({name:"w:type",attributes:{val:{key:"w:val",value:B}}}),F2={TOP:1440,RIGHT:1440,BOTTOM:1440,LEFT:1440,HEADER:708,FOOTER:708,GUTTER:0},k1={WIDTH:11906,HEIGHT:16838,ORIENTATION:y1.PORTRAIT},J6=class extends t{constructor({page:{size:{width:B=k1.WIDTH,height:U=k1.HEIGHT,orientation:G=k1.ORIENTATION,code:Y}={},margin:{top:Q=F2.TOP,right:K=F2.RIGHT,bottom:Z=F2.BOTTOM,left:J=F2.LEFT,header:M=F2.HEADER,footer:W=F2.FOOTER,gutter:I=F2.GUTTER}={},pageNumbers:F={},borders:D,textDirection:w}={},grid:{linePitch:P=360,charSpace:A,type:E}={},headerWrapperGroup:C={},footerWrapperGroup:j={},lineNumbers:v,titlePage:S,verticalAlign:H,column:X,type:$,revision:x}={}){super("w:sectPr");if(this.addHeaderFooterGroup(z8.HEADER,C),this.addHeaderFooterGroup(z8.FOOTER,j),$)this.root.push(C9($));if(this.root.push(T9({width:B,height:U,orientation:G,code:Y})),this.root.push(z9(Q,K,Z,J,M,W,I)),D)this.root.push(new N9(D));if(v)this.root.push(j9(v));if(this.root.push(E9(F)),X)this.root.push(w9(X));if(H)this.root.push(B6(H));if(S!==void 0)this.root.push(new M0("w:titlePg",S));if(w)this.root.push(new D9(w));if(x)this.root.push(new k9(x));this.root.push(A9({linePitch:P,charSpace:A,type:E}))}addHeaderFooterGroup(B,U){if(U.default)this.root.push(C1(B,{type:D2.DEFAULT,id:U.default.View.ReferenceId}));if(U.first)this.root.push(C1(B,{type:D2.FIRST,id:U.first.View.ReferenceId}));if(U.even)this.root.push(C1(B,{type:D2.EVEN,id:U.even.View.ReferenceId}))}},k9=class extends t{constructor(B){super("w:sectPrChange");this.root.push(new b0({id:B.id,author:B.author,date:B.date})),this.root.push(new J6(B))}},YJ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{width:"w:w",space:"w:space"})}},ZJ=class extends t{constructor(B){super("w:col");this.root.push(new YJ({width:E0(B.width),space:B.space===void 0?void 0:E0(B.space)}))}},$9=class extends t{constructor(){super("w:body");e(this,"sections",[])}addSection(B){let U=this.sections.pop();this.root.push(this.createSectionParagraph(U)),this.sections.push(new J6(B))}prepForXml(B){if(this.sections.length===1)this.root.splice(0,1),this.root.push(this.sections.pop());return super.prepForXml(B)}push(B){this.root.push(B)}createSectionParagraph(B){let U=new d0({}),G=new X2({});return G.push(B),U.addChildElement(G),U}},S9=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{color:"w:color",themeColor:"w:themeColor",themeShade:"w:themeShade",themeTint:"w:themeTint"})}},b9=class extends t{constructor(B){super("w:background");this.root.push(new S9({color:B.color===void 0?void 0:C2(B.color),themeColor:B.themeColor,themeShade:B.themeShade===void 0?void 0:H8(B.themeShade),themeTint:B.themeTint===void 0?void 0:H8(B.themeTint)}))}},QJ=class extends t{constructor(B){super("w:document");if(e(this,"body",void 0),this.root.push(new H1(["wpc","mc","o","r","m","v","wp14","wp","w10","w","w14","w15","wpg","wpi","wne","wps","cx","cx1","cx2","cx3","cx4","cx5","cx6","cx7","cx8","aink","am3d","w16cex","w16cid","w16","w16sdtdh","w16se"],"w14 w15 wp14")),this.body=new $9,B.background)this.root.push(new b9(B.background));this.root.push(this.body)}add(B){return this.body.push(B),this}get Body(){return this.body}},JJ=class{constructor(B){e(this,"document",void 0),e(this,"relationships",void 0),this.document=new QJ(B),this.relationships=new w2}get View(){return this.document}get Relationships(){return this.relationships}},KJ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{wpc:"xmlns:wpc",mc:"xmlns:mc",o:"xmlns:o",r:"xmlns:r",m:"xmlns:m",v:"xmlns:v",wp14:"xmlns:wp14",wp:"xmlns:wp",w10:"xmlns:w10",w:"xmlns:w",w14:"xmlns:w14",w15:"xmlns:w15",wpg:"xmlns:wpg",wpi:"xmlns:wpi",wne:"xmlns:wne",wps:"xmlns:wps",Ignorable:"mc:Ignorable"})}},VJ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{type:"w:type",id:"w:id"})}},qJ=class extends T0{constructor(){super({style:"EndnoteReference"});this.root.push(new T4)}},n6={SEPARATOR:"separator",CONTINUATION_SEPARATOR:"continuationSeparator"},V8=class extends t{constructor(B){super("w:endnote");this.root.push(new VJ({type:B.type,id:B.id}));for(let U=0;U9)throw Error("Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7");this.root.push(new NJ({ilvl:D0(B),tentative:1}))}},h9=class extends V6{},$J=class extends V6{},SJ=class extends t{constructor(B){super("w:multiLevelType");this.root.push(new C0({val:B}))}},bJ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{abstractNumId:"w:abstractNumId",restartNumberingAfterBreak:"w15:restartNumberingAfterBreak"})}},E8=class extends t{constructor(B,U){super("w:abstractNum");e(this,"id",void 0),this.root.push(new bJ({abstractNumId:D0(B),restartNumberingAfterBreak:0})),this.root.push(new SJ("hybridMultilevel")),this.id=B;for(let G of U)this.root.push(new h9(G))}},vJ=class extends t{constructor(B){super("w:abstractNumId");this.root.push(new C0({val:B}))}},yJ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{numId:"w:numId"})}},T8=class extends t{constructor(B){super("w:num");if(e(this,"numId",void 0),e(this,"reference",void 0),e(this,"instance",void 0),this.numId=B.numId,this.reference=B.reference,this.instance=B.instance,this.root.push(new yJ({numId:D0(B.numId)})),this.root.push(new vJ(D0(B.abstractNumId))),B.overrideLevels&&B.overrideLevels.length)for(let U of B.overrideLevels)this.root.push(new u9(U.num,U.start))}},gJ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{ilvl:"w:ilvl"})}},u9=class extends t{constructor(B,U){super("w:lvlOverride");if(this.root.push(new gJ({ilvl:B})),U!==void 0)this.root.push(new xJ(U))}},fJ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{val:"w:val"})}},xJ=class extends t{constructor(B){super("w:startOverride");this.root.push(new fJ({val:B}))}},d9=class extends t{constructor(B){super("w:numbering");e(this,"abstractNumberingMap",new Map),e(this,"concreteNumberingMap",new Map),e(this,"referenceConfigMap",new Map),e(this,"abstractNumUniqueNumericId",nB()),e(this,"concreteNumUniqueNumericId",sB()),this.root.push(new H1(["wpc","mc","o","r","m","v","wp14","wp","w10","w","w14","w15","wpg","wpi","wne","wps"],"w14 w15 wp14"));let U=new E8(this.abstractNumUniqueNumericId(),[{level:0,format:i0.BULLET,text:"●",alignment:c0.LEFT,style:{paragraph:{indent:{left:u0(0.5),hanging:u0(0.25)}}}},{level:1,format:i0.BULLET,text:"○",alignment:c0.LEFT,style:{paragraph:{indent:{left:u0(1),hanging:u0(0.25)}}}},{level:2,format:i0.BULLET,text:"■",alignment:c0.LEFT,style:{paragraph:{indent:{left:2160,hanging:u0(0.25)}}}},{level:3,format:i0.BULLET,text:"●",alignment:c0.LEFT,style:{paragraph:{indent:{left:2880,hanging:u0(0.25)}}}},{level:4,format:i0.BULLET,text:"○",alignment:c0.LEFT,style:{paragraph:{indent:{left:3600,hanging:u0(0.25)}}}},{level:5,format:i0.BULLET,text:"■",alignment:c0.LEFT,style:{paragraph:{indent:{left:4320,hanging:u0(0.25)}}}},{level:6,format:i0.BULLET,text:"●",alignment:c0.LEFT,style:{paragraph:{indent:{left:5040,hanging:u0(0.25)}}}},{level:7,format:i0.BULLET,text:"●",alignment:c0.LEFT,style:{paragraph:{indent:{left:5760,hanging:u0(0.25)}}}},{level:8,format:i0.BULLET,text:"●",alignment:c0.LEFT,style:{paragraph:{indent:{left:6480,hanging:u0(0.25)}}}}]);this.concreteNumberingMap.set("default-bullet-numbering",new T8({numId:1,abstractNumId:U.id,reference:"default-bullet-numbering",instance:0,overrideLevels:[{num:0,start:1}]})),this.abstractNumberingMap.set("default-bullet-numbering",U);for(let G of B.config)this.abstractNumberingMap.set(G.reference,new E8(this.abstractNumUniqueNumericId(),G.levels)),this.referenceConfigMap.set(G.reference,G.levels)}prepForXml(B){for(let U of this.abstractNumberingMap.values())this.root.push(U);for(let U of this.concreteNumberingMap.values())this.root.push(U);return super.prepForXml(B)}createConcreteNumberingInstance(B,U){let G=this.abstractNumberingMap.get(B);if(!G)return;let Y=`${B}-${U}`;if(this.concreteNumberingMap.has(Y))return;let Q=this.referenceConfigMap.get(B),K=Q&&Q[0].start,Z={numId:this.concreteNumUniqueNumericId(),abstractNumId:G.id,reference:B,instance:U,overrideLevels:[typeof K==="number"&&Number.isInteger(K)?{num:0,start:K}:{num:0,start:1}]};this.concreteNumberingMap.set(Y,new T8(Z))}get ConcreteNumbering(){return Array.from(this.concreteNumberingMap.values())}get ReferenceConfig(){return Array.from(this.referenceConfigMap.values())}},_J=(B)=>new X0({name:"w:compatSetting",attributes:{version:{key:"w:val",value:B},name:{key:"w:name",value:"compatibilityMode"},uri:{key:"w:uri",value:"http://schemas.microsoft.com/office/word"}}}),hJ=class extends t{constructor(B){super("w:compat");if(B.version)this.root.push(_J(B.version));if(B.useSingleBorderforContiguousCells)this.root.push(new M0("w:useSingleBorderforContiguousCells",B.useSingleBorderforContiguousCells));if(B.wordPerfectJustification)this.root.push(new M0("w:wpJustification",B.wordPerfectJustification));if(B.noTabStopForHangingIndent)this.root.push(new M0("w:noTabHangInd",B.noTabStopForHangingIndent));if(B.noLeading)this.root.push(new M0("w:noLeading",B.noLeading));if(B.spaceForUnderline)this.root.push(new M0("w:spaceForUL",B.spaceForUnderline));if(B.noColumnBalance)this.root.push(new M0("w:noColumnBalance",B.noColumnBalance));if(B.balanceSingleByteDoubleByteWidth)this.root.push(new M0("w:balanceSingleByteDoubleByteWidth",B.balanceSingleByteDoubleByteWidth));if(B.noExtraLineSpacing)this.root.push(new M0("w:noExtraLineSpacing",B.noExtraLineSpacing));if(B.doNotLeaveBackslashAlone)this.root.push(new M0("w:doNotLeaveBackslashAlone",B.doNotLeaveBackslashAlone));if(B.underlineTrailingSpaces)this.root.push(new M0("w:ulTrailSpace",B.underlineTrailingSpaces));if(B.doNotExpandShiftReturn)this.root.push(new M0("w:doNotExpandShiftReturn",B.doNotExpandShiftReturn));if(B.spacingInWholePoints)this.root.push(new M0("w:spacingInWholePoints",B.spacingInWholePoints));if(B.lineWrapLikeWord6)this.root.push(new M0("w:lineWrapLikeWord6",B.lineWrapLikeWord6));if(B.printBodyTextBeforeHeader)this.root.push(new M0("w:printBodyTextBeforeHeader",B.printBodyTextBeforeHeader));if(B.printColorsBlack)this.root.push(new M0("w:printColBlack",B.printColorsBlack));if(B.spaceWidth)this.root.push(new M0("w:wpSpaceWidth",B.spaceWidth));if(B.showBreaksInFrames)this.root.push(new M0("w:showBreaksInFrames",B.showBreaksInFrames));if(B.subFontBySize)this.root.push(new M0("w:subFontBySize",B.subFontBySize));if(B.suppressBottomSpacing)this.root.push(new M0("w:suppressBottomSpacing",B.suppressBottomSpacing));if(B.suppressTopSpacing)this.root.push(new M0("w:suppressTopSpacing",B.suppressTopSpacing));if(B.suppressSpacingAtTopOfPage)this.root.push(new M0("w:suppressSpacingAtTopOfPage",B.suppressSpacingAtTopOfPage));if(B.suppressTopSpacingWP)this.root.push(new M0("w:suppressTopSpacingWP",B.suppressTopSpacingWP));if(B.suppressSpBfAfterPgBrk)this.root.push(new M0("w:suppressSpBfAfterPgBrk",B.suppressSpBfAfterPgBrk));if(B.swapBordersFacingPages)this.root.push(new M0("w:swapBordersFacingPages",B.swapBordersFacingPages));if(B.convertMailMergeEsc)this.root.push(new M0("w:convMailMergeEsc",B.convertMailMergeEsc));if(B.truncateFontHeightsLikeWP6)this.root.push(new M0("w:truncateFontHeightsLikeWP6",B.truncateFontHeightsLikeWP6));if(B.macWordSmallCaps)this.root.push(new M0("w:mwSmallCaps",B.macWordSmallCaps));if(B.usePrinterMetrics)this.root.push(new M0("w:usePrinterMetrics",B.usePrinterMetrics));if(B.doNotSuppressParagraphBorders)this.root.push(new M0("w:doNotSuppressParagraphBorders",B.doNotSuppressParagraphBorders));if(B.wrapTrailSpaces)this.root.push(new M0("w:wrapTrailSpaces",B.wrapTrailSpaces));if(B.footnoteLayoutLikeWW8)this.root.push(new M0("w:footnoteLayoutLikeWW8",B.footnoteLayoutLikeWW8));if(B.shapeLayoutLikeWW8)this.root.push(new M0("w:shapeLayoutLikeWW8",B.shapeLayoutLikeWW8));if(B.alignTablesRowByRow)this.root.push(new M0("w:alignTablesRowByRow",B.alignTablesRowByRow));if(B.forgetLastTabAlignment)this.root.push(new M0("w:forgetLastTabAlignment",B.forgetLastTabAlignment));if(B.adjustLineHeightInTable)this.root.push(new M0("w:adjustLineHeightInTable",B.adjustLineHeightInTable));if(B.autoSpaceLikeWord95)this.root.push(new M0("w:autoSpaceLikeWord95",B.autoSpaceLikeWord95));if(B.noSpaceRaiseLower)this.root.push(new M0("w:noSpaceRaiseLower",B.noSpaceRaiseLower));if(B.doNotUseHTMLParagraphAutoSpacing)this.root.push(new M0("w:doNotUseHTMLParagraphAutoSpacing",B.doNotUseHTMLParagraphAutoSpacing));if(B.layoutRawTableWidth)this.root.push(new M0("w:layoutRawTableWidth",B.layoutRawTableWidth));if(B.layoutTableRowsApart)this.root.push(new M0("w:layoutTableRowsApart",B.layoutTableRowsApart));if(B.useWord97LineBreakRules)this.root.push(new M0("w:useWord97LineBreakRules",B.useWord97LineBreakRules));if(B.doNotBreakWrappedTables)this.root.push(new M0("w:doNotBreakWrappedTables",B.doNotBreakWrappedTables));if(B.doNotSnapToGridInCell)this.root.push(new M0("w:doNotSnapToGridInCell",B.doNotSnapToGridInCell));if(B.selectFieldWithFirstOrLastCharacter)this.root.push(new M0("w:selectFldWithFirstOrLastChar",B.selectFieldWithFirstOrLastCharacter));if(B.applyBreakingRules)this.root.push(new M0("w:applyBreakingRules",B.applyBreakingRules));if(B.doNotWrapTextWithPunctuation)this.root.push(new M0("w:doNotWrapTextWithPunct",B.doNotWrapTextWithPunctuation));if(B.doNotUseEastAsianBreakRules)this.root.push(new M0("w:doNotUseEastAsianBreakRules",B.doNotUseEastAsianBreakRules));if(B.useWord2002TableStyleRules)this.root.push(new M0("w:useWord2002TableStyleRules",B.useWord2002TableStyleRules));if(B.growAutofit)this.root.push(new M0("w:growAutofit",B.growAutofit));if(B.useFELayout)this.root.push(new M0("w:useFELayout",B.useFELayout));if(B.useNormalStyleForList)this.root.push(new M0("w:useNormalStyleForList",B.useNormalStyleForList));if(B.doNotUseIndentAsNumberingTabStop)this.root.push(new M0("w:doNotUseIndentAsNumberingTabStop",B.doNotUseIndentAsNumberingTabStop));if(B.useAlternateEastAsianLineBreakRules)this.root.push(new M0("w:useAltKinsokuLineBreakRules",B.useAlternateEastAsianLineBreakRules));if(B.allowSpaceOfSameStyleInTable)this.root.push(new M0("w:allowSpaceOfSameStyleInTable",B.allowSpaceOfSameStyleInTable));if(B.doNotSuppressIndentation)this.root.push(new M0("w:doNotSuppressIndentation",B.doNotSuppressIndentation));if(B.doNotAutofitConstrainedTables)this.root.push(new M0("w:doNotAutofitConstrainedTables",B.doNotAutofitConstrainedTables));if(B.autofitToFirstFixedWidthCell)this.root.push(new M0("w:autofitToFirstFixedWidthCell",B.autofitToFirstFixedWidthCell));if(B.underlineTabInNumberingList)this.root.push(new M0("w:underlineTabInNumList",B.underlineTabInNumberingList));if(B.displayHangulFixedWidth)this.root.push(new M0("w:displayHangulFixedWidth",B.displayHangulFixedWidth));if(B.splitPgBreakAndParaMark)this.root.push(new M0("w:splitPgBreakAndParaMark",B.splitPgBreakAndParaMark));if(B.doNotVerticallyAlignCellWithSp)this.root.push(new M0("w:doNotVertAlignCellWithSp",B.doNotVerticallyAlignCellWithSp));if(B.doNotBreakConstrainedForcedTable)this.root.push(new M0("w:doNotBreakConstrainedForcedTable",B.doNotBreakConstrainedForcedTable));if(B.ignoreVerticalAlignmentInTextboxes)this.root.push(new M0("w:doNotVertAlignInTxbx",B.ignoreVerticalAlignmentInTextboxes));if(B.useAnsiKerningPairs)this.root.push(new M0("w:useAnsiKerningPairs",B.useAnsiKerningPairs));if(B.cachedColumnBalance)this.root.push(new M0("w:cachedColBalance",B.cachedColumnBalance))}},uJ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{wpc:"xmlns:wpc",mc:"xmlns:mc",o:"xmlns:o",r:"xmlns:r",m:"xmlns:m",v:"xmlns:v",wp14:"xmlns:wp14",wp:"xmlns:wp",w10:"xmlns:w10",w:"xmlns:w",w14:"xmlns:w14",w15:"xmlns:w15",wpg:"xmlns:wpg",wpi:"xmlns:wpi",wne:"xmlns:wne",wps:"xmlns:wps",Ignorable:"mc:Ignorable"})}},dJ=class extends t{constructor(B){var U,G,Y,Q,K,Z,J,M;super("w:settings");if(this.root.push(new uJ({wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wpi:"http://schemas.microsoft.com/office/word/2010/wordprocessingInk",wne:"http://schemas.microsoft.com/office/word/2006/wordml",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape",Ignorable:"w14 w15 wp14"})),this.root.push(new M0("w:displayBackgroundShape",!0)),B.trackRevisions!==void 0)this.root.push(new M0("w:trackRevisions",B.trackRevisions));if(B.evenAndOddHeaders!==void 0)this.root.push(new M0("w:evenAndOddHeaders",B.evenAndOddHeaders));if(B.updateFields!==void 0)this.root.push(new M0("w:updateFields",B.updateFields));if(B.defaultTabStop!==void 0)this.root.push(new _2("w:defaultTabStop",B.defaultTabStop));if(((U=B.hyphenation)===null||U===void 0?void 0:U.autoHyphenation)!==void 0)this.root.push(new M0("w:autoHyphenation",B.hyphenation.autoHyphenation));if(((G=B.hyphenation)===null||G===void 0?void 0:G.hyphenationZone)!==void 0)this.root.push(new _2("w:hyphenationZone",B.hyphenation.hyphenationZone));if(((Y=B.hyphenation)===null||Y===void 0?void 0:Y.consecutiveHyphenLimit)!==void 0)this.root.push(new _2("w:consecutiveHyphenLimit",B.hyphenation.consecutiveHyphenLimit));if(((Q=B.hyphenation)===null||Q===void 0?void 0:Q.doNotHyphenateCaps)!==void 0)this.root.push(new M0("w:doNotHyphenateCaps",B.hyphenation.doNotHyphenateCaps));this.root.push(new hJ(L0(L0({},(K=B.compatibility)!==null&&K!==void 0?K:{}),{},{version:(Z=(J=(M=B.compatibility)===null||M===void 0?void 0:M.version)!==null&&J!==void 0?J:B.compatibilityModeVersion)!==null&&Z!==void 0?Z:15})))}},c9=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{val:"w:val"})}},cJ=class extends t{constructor(B){super("w:name");this.root.push(new c9({val:B}))}},mJ=class extends t{constructor(B){super("w:uiPriority");this.root.push(new c9({val:D0(B)}))}},lJ=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{type:"w:type",styleId:"w:styleId",default:"w:default",customStyle:"w:customStyle"})}},m9=class extends t{constructor(B,U){super("w:style");if(this.root.push(new lJ(B)),U.name)this.root.push(new cJ(U.name));if(U.basedOn)this.root.push(new M2("w:basedOn",U.basedOn));if(U.next)this.root.push(new M2("w:next",U.next));if(U.link)this.root.push(new M2("w:link",U.link));if(U.uiPriority!==void 0)this.root.push(new mJ(U.uiPriority));if(U.semiHidden!==void 0)this.root.push(new M0("w:semiHidden",U.semiHidden));if(U.unhideWhenUsed!==void 0)this.root.push(new M0("w:unhideWhenUsed",U.unhideWhenUsed));if(U.quickFormat!==void 0)this.root.push(new M0("w:qFormat",U.quickFormat))}},p2=class extends m9{constructor(B){super({type:"paragraph",styleId:B.id},B);e(this,"paragraphProperties",void 0),e(this,"runProperties",void 0),this.paragraphProperties=new X2(B.paragraph),this.runProperties=new U2(B.run),this.root.push(this.paragraphProperties),this.root.push(this.runProperties)}},$2=class extends m9{constructor(B){super({type:"character",styleId:B.id},L0({uiPriority:99,unhideWhenUsed:!0},B));e(this,"runProperties",void 0),this.runProperties=new U2(B.run),this.root.push(this.runProperties)}},A2=class extends p2{constructor(B){super(L0({basedOn:"Normal",next:"Normal",quickFormat:!0},B))}},aJ=class extends A2{constructor(B){super(L0({id:"Title",name:"Title"},B))}},pJ=class extends A2{constructor(B){super(L0({id:"Heading1",name:"Heading 1"},B))}},rJ=class extends A2{constructor(B){super(L0({id:"Heading2",name:"Heading 2"},B))}},iJ=class extends A2{constructor(B){super(L0({id:"Heading3",name:"Heading 3"},B))}},nJ=class extends A2{constructor(B){super(L0({id:"Heading4",name:"Heading 4"},B))}},sJ=class extends A2{constructor(B){super(L0({id:"Heading5",name:"Heading 5"},B))}},oJ=class extends A2{constructor(B){super(L0({id:"Heading6",name:"Heading 6"},B))}},tJ=class extends A2{constructor(B){super(L0({id:"Strong",name:"Strong"},B))}},eJ=class extends p2{constructor(B){super(L0({id:"ListParagraph",name:"List Paragraph",basedOn:"Normal",quickFormat:!0},B))}},BK=class extends p2{constructor(B){super(L0({id:"FootnoteText",name:"footnote text",link:"FootnoteTextChar",basedOn:"Normal",uiPriority:99,semiHidden:!0,unhideWhenUsed:!0,paragraph:{spacing:{after:0,line:240,lineRule:k2.AUTO}},run:{size:20}},B))}},UK=class extends $2{constructor(B){super(L0({id:"FootnoteReference",name:"footnote reference",basedOn:"DefaultParagraphFont",semiHidden:!0,run:{superScript:!0}},B))}},GK=class extends $2{constructor(B){super(L0({id:"FootnoteTextChar",name:"Footnote Text Char",basedOn:"DefaultParagraphFont",link:"FootnoteText",semiHidden:!0,run:{size:20}},B))}},YK=class extends p2{constructor(B){super(L0({id:"EndnoteText",name:"endnote text",link:"EndnoteTextChar",basedOn:"Normal",uiPriority:99,semiHidden:!0,unhideWhenUsed:!0,paragraph:{spacing:{after:0,line:240,lineRule:k2.AUTO}},run:{size:20}},B))}},ZK=class extends $2{constructor(B){super(L0({id:"EndnoteReference",name:"endnote reference",basedOn:"DefaultParagraphFont",semiHidden:!0,run:{superScript:!0}},B))}},QK=class extends $2{constructor(B){super(L0({id:"EndnoteTextChar",name:"Endnote Text Char",basedOn:"DefaultParagraphFont",link:"EndnoteText",semiHidden:!0,run:{size:20}},B))}},JK=class extends $2{constructor(B){super(L0({id:"Hyperlink",name:"Hyperlink",basedOn:"DefaultParagraphFont",run:{color:"0563C1",underline:{type:r8.SINGLE}}},B))}},$1=class extends t{constructor(B){super("w:styles");if(B.initialStyles)this.root.push(B.initialStyles);if(B.importedStyles)for(let U of B.importedStyles)this.root.push(U);if(B.paragraphStyles)for(let U of B.paragraphStyles)this.root.push(new p2(U));if(B.characterStyles)for(let U of B.characterStyles)this.root.push(new $2(U))}},l9=class extends t{constructor(B){super("w:pPrDefault");this.root.push(new X2(B))}},a9=class extends t{constructor(B){super("w:rPrDefault");this.root.push(new U2(B))}},p9=class extends t{constructor(B){super("w:docDefaults");e(this,"runPropertiesDefaults",void 0),e(this,"paragraphPropertiesDefaults",void 0),this.runPropertiesDefaults=new a9(B.run),this.paragraphPropertiesDefaults=new l9(B.paragraph),this.root.push(this.runPropertiesDefaults),this.root.push(this.paragraphPropertiesDefaults)}},KK=class{newInstance(B){let U=(0,_1.xml2js)(B,{compact:!1}),G;for(let Q of U.elements||[])if(Q.name==="w:styles")G=Q;if(G===void 0)throw Error("can not find styles element");let Y=G.elements||[];return{initialStyles:new $B(G.attributes),importedStyles:Y.map((Q)=>h1(Q))}}},M8=class{newInstance(B={}){var U;return{initialStyles:new H1(["mc","r","w","w14","w15"],"w14 w15"),importedStyles:[new p9((U=B.document)!==null&&U!==void 0?U:{}),new aJ(L0({run:{size:56}},B.title)),new pJ(L0({run:{color:"2E74B5",size:32}},B.heading1)),new rJ(L0({run:{color:"2E74B5",size:26}},B.heading2)),new iJ(L0({run:{color:"1F4D78",size:24}},B.heading3)),new nJ(L0({run:{color:"2E74B5",italics:!0}},B.heading4)),new sJ(L0({run:{color:"2E74B5"}},B.heading5)),new oJ(L0({run:{color:"1F4D78"}},B.heading6)),new tJ(L0({run:{bold:!0}},B.strong)),new eJ(B.listParagraph||{}),new JK(B.hyperlink||{}),new UK(B.footnoteReference||{}),new BK(B.footnoteText||{}),new GK(B.footnoteTextChar||{}),new ZK(B.endnoteReference||{}),new YK(B.endnoteText||{}),new QK(B.endnoteTextChar||{})]}}},VK=class{constructor(B){var U,G,Y,Q,K,Z,J,M,W,I,F,D;if(e(this,"currentRelationshipId",1),e(this,"documentWrapper",void 0),e(this,"headers",[]),e(this,"footers",[]),e(this,"coreProperties",void 0),e(this,"numbering",void 0),e(this,"media",void 0),e(this,"fileRelationships",void 0),e(this,"footnotesWrapper",void 0),e(this,"endnotesWrapper",void 0),e(this,"settings",void 0),e(this,"contentTypes",void 0),e(this,"customProperties",void 0),e(this,"appProperties",void 0),e(this,"styles",void 0),e(this,"comments",void 0),e(this,"commentsExtended",void 0),e(this,"fontWrapper",void 0),this.coreProperties=new dQ(L0(L0({},B),{},{creator:(U=B.creator)!==null&&U!==void 0?U:"Un-named",revision:(G=B.revision)!==null&&G!==void 0?G:1,lastModifiedBy:(Y=B.lastModifiedBy)!==null&&Y!==void 0?Y:"Un-named"})),this.numbering=new d9(B.numbering?B.numbering:{config:[]}),this.comments=new z4((Q=B.comments)!==null&&Q!==void 0?Q:{children:[]}),this.comments.ThreadData)this.commentsExtended=new E4(this.comments.ThreadData);if(this.fileRelationships=new w2,this.customProperties=new rQ((K=B.customProperties)!==null&&K!==void 0?K:[]),this.appProperties=new _Q,this.footnotesWrapper=new PJ,this.endnotesWrapper=new RJ,this.contentTypes=new uQ,this.documentWrapper=new JJ({background:B.background}),this.settings=new dJ({compatibilityModeVersion:B.compatabilityModeVersion,compatibility:B.compatibility,evenAndOddHeaders:B.evenAndOddHeaderAndFooters?!0:!1,trackRevisions:(Z=B.features)===null||Z===void 0?void 0:Z.trackRevisions,updateFields:(J=B.features)===null||J===void 0?void 0:J.updateFields,defaultTabStop:B.defaultTabStop,hyphenation:{autoHyphenation:(M=B.hyphenation)===null||M===void 0?void 0:M.autoHyphenation,hyphenationZone:(W=B.hyphenation)===null||W===void 0?void 0:W.hyphenationZone,consecutiveHyphenLimit:(I=B.hyphenation)===null||I===void 0?void 0:I.consecutiveHyphenLimit,doNotHyphenateCaps:(F=B.hyphenation)===null||F===void 0?void 0:F.doNotHyphenateCaps}}),this.media=new K6,B.externalStyles!==void 0){var w;let P=new M8().newInstance((w=B.styles)===null||w===void 0?void 0:w.default),A=new KK().newInstance(B.externalStyles);this.styles=new $1(L0(L0({},A),{},{importedStyles:[...P.importedStyles,...A.importedStyles]}))}else if(B.styles){let P=new M8().newInstance(B.styles.default);this.styles=new $1(L0(L0({},P),B.styles))}else{let P=new M8;this.styles=new $1(P.newInstance())}this.addDefaultRelationships();for(let P of B.sections)this.addSection(P);if(B.footnotes)for(let P in B.footnotes)this.footnotesWrapper.View.createFootNote(parseFloat(P),B.footnotes[P].children);if(B.endnotes)for(let P in B.endnotes)this.endnotesWrapper.View.createEndnote(parseFloat(P),B.endnotes[P].children);this.fontWrapper=new h4((D=B.fonts)!==null&&D!==void 0?D:[])}addSection({headers:B={},footers:U={},children:G,properties:Y}){this.documentWrapper.View.Body.addSection(L0(L0({},Y),{},{headerWrapperGroup:{default:B.default?this.createHeader(B.default):void 0,first:B.first?this.createHeader(B.first):void 0,even:B.even?this.createHeader(B.even):void 0},footerWrapperGroup:{default:U.default?this.createFooter(U.default):void 0,first:U.first?this.createFooter(U.first):void 0,even:U.even?this.createFooter(U.even):void 0}}));for(let Q of G)this.documentWrapper.View.add(Q)}createHeader(B){let U=new _9(this.media,this.currentRelationshipId++);for(let G of B.options.children)U.add(G);return this.addHeaderToDocument(U),U}createFooter(B){let U=new f9(this.media,this.currentRelationshipId++);for(let G of B.options.children)U.add(G);return this.addFooterToDocument(U),U}addHeaderToDocument(B,U=D2.DEFAULT){this.headers.push({header:B,type:U}),this.documentWrapper.Relationships.addRelationship(B.View.ReferenceId,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",`header${this.headers.length}.xml`),this.contentTypes.addHeader(this.headers.length)}addFooterToDocument(B,U=D2.DEFAULT){this.footers.push({footer:B,type:U}),this.documentWrapper.Relationships.addRelationship(B.View.ReferenceId,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",`footer${this.footers.length}.xml`),this.contentTypes.addFooter(this.footers.length)}addDefaultRelationships(){if(this.fileRelationships.addRelationship(1,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument","word/document.xml"),this.fileRelationships.addRelationship(2,"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties","docProps/core.xml"),this.fileRelationships.addRelationship(3,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties","docProps/app.xml"),this.fileRelationships.addRelationship(4,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties","docProps/custom.xml"),this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles","styles.xml"),this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering","numbering.xml"),this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes","footnotes.xml"),this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes","endnotes.xml"),this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings","settings.xml"),this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments","comments.xml"),this.commentsExtended)this.documentWrapper.Relationships.addRelationship(this.currentRelationshipId++,"http://schemas.microsoft.com/office/2011/relationships/commentsExtended","commentsExtended.xml"),this.contentTypes.addCommentsExtended()}get Document(){return this.documentWrapper}get Styles(){return this.styles}get CoreProperties(){return this.coreProperties}get Numbering(){return this.numbering}get Media(){return this.media}get FileRelationships(){return this.fileRelationships}get Headers(){return this.headers.map((B)=>B.header)}get Footers(){return this.footers.map((B)=>B.footer)}get ContentTypes(){return this.contentTypes}get CustomProperties(){return this.customProperties}get AppProperties(){return this.appProperties}get FootNotes(){return this.footnotesWrapper}get Endnotes(){return this.endnotesWrapper}get Settings(){return this.settings}get Comments(){return this.comments}get CommentsExtended(){return this.commentsExtended}get FontTable(){return this.fontWrapper}},qK=class extends t{constructor(B={}){super("w:instrText");e(this,"properties",void 0),this.properties=B,this.root.push(new _0({space:x0.PRESERVE}));let U="TOC";if(this.properties.captionLabel)U=`${U} \\a "${this.properties.captionLabel}"`;if(this.properties.entriesFromBookmark)U=`${U} \\b "${this.properties.entriesFromBookmark}"`;if(this.properties.captionLabelIncludingNumbers)U=`${U} \\c "${this.properties.captionLabelIncludingNumbers}"`;if(this.properties.sequenceAndPageNumbersSeparator)U=`${U} \\d "${this.properties.sequenceAndPageNumbersSeparator}"`;if(this.properties.tcFieldIdentifier)U=`${U} \\f "${this.properties.tcFieldIdentifier}"`;if(this.properties.hyperlink)U=`${U} \\h`;if(this.properties.tcFieldLevelRange)U=`${U} \\l "${this.properties.tcFieldLevelRange}"`;if(this.properties.pageNumbersEntryLevelsRange)U=`${U} \\n "${this.properties.pageNumbersEntryLevelsRange}"`;if(this.properties.headingStyleRange)U=`${U} \\o "${this.properties.headingStyleRange}"`;if(this.properties.entryAndPageNumberSeparator)U=`${U} \\p "${this.properties.entryAndPageNumberSeparator}"`;if(this.properties.seqFieldIdentifierForPrefix)U=`${U} \\s "${this.properties.seqFieldIdentifierForPrefix}"`;if(this.properties.stylesWithLevels&&this.properties.stylesWithLevels.length){let G=this.properties.stylesWithLevels.map((Y)=>`${Y.styleName},${Y.level}`).join(",");U=`${U} \\t "${G}"`}if(this.properties.useAppliedParagraphOutlineLevel)U=`${U} \\u`;if(this.properties.preserveTabInEntries)U=`${U} \\w`;if(this.properties.preserveNewLineInEntries)U=`${U} \\x`;if(this.properties.hideTabAndPageNumbersInWebView)U=`${U} \\z`;this.root.push(U)}},r9=class extends t{constructor(){super("w:sdtContent")}},i9=class extends t{constructor(B){super("w:sdtPr");if(B)this.root.push(new M2("w:alias",B))}};function MK(B,U){if(B==null)return{};var G={};for(var Y in B)if({}.hasOwnProperty.call(B,Y)){if(U.includes(Y))continue;G[Y]=B[Y]}return G}function n9(B,U){if(B==null)return{};var G,Y,Q=MK(B,U);if(Object.getOwnPropertySymbols){var K=Object.getOwnPropertySymbols(B);for(Y=0;Y0){let{stylesWithLevels:W}=K,I=Y.map((D,w)=>{var P,A;let E=this.buildCachedContentParagraphChild(D,K),C=(P=W===null||W===void 0||(A=W.find((v)=>v.level===D.level))===null||A===void 0?void 0:A.styleName)!==null&&P!==void 0?P:`TOC${D.level}`,j=w===0?[...J,E]:w===Y.length-1?[E,...M]:[E];return new d0({style:C,tabStops:this.getTabStopsForLevel(D.level),children:j})}),F=I;if(Y.length<=1)F=[...I,new d0({children:M})];for(let D of F)Z.addChildElement(D)}else{let W=new d0({children:J});Z.addChildElement(W);for(let F of G)Z.addChildElement(F);let I=new d0({children:M});Z.addChildElement(I)}this.root.push(Z)}getTabStopsForLevel(B,U=9025){return[{type:"clear",position:U+1-(B-1)*240},{type:"right",position:U,leader:"dot"}]}buildCachedContentRun(B,U){var G,Y;return new T0({style:(U===null||U===void 0?void 0:U.hyperlink)&&B.href!==void 0?"IndexLink":void 0,children:[new Z1({text:B.title}),new D4,new Z1({text:(G=(Y=B.page)===null||Y===void 0?void 0:Y.toString())!==null&&G!==void 0?G:""})]})}buildCachedContentParagraphChild(B,U){let G=this.buildCachedContentRun(B,U);if((U===null||U===void 0?void 0:U.hyperlink)&&B.href!==void 0)return new y4({anchor:B.href,children:[G]});return G}},LK=class{constructor(B,U){e(this,"styleName",void 0),e(this,"level",void 0),this.styleName=B,this.level=U}},IK=class{constructor(B={children:[]}){e(this,"options",void 0),this.options=B}},OK=class{constructor(B={children:[]}){e(this,"options",void 0),this.options=B}},s9=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{id:"w:id"})}},o9=class extends t{constructor(B){super("w:footnoteReference");this.root.push(new s9({id:B}))}},FK=class extends T0{constructor(B){super({style:"FootnoteReference"});this.root.push(new o9(B))}},t9=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{id:"w:id"})}},e9=class extends t{constructor(B){super("w:endnoteReference");this.root.push(new t9({id:B}))}},HK=class extends T0{constructor(B){super({style:"EndnoteReference"});this.root.push(new e9(B))}},o6=class extends F0{constructor(...B){super(...B);e(this,"xmlKeys",{val:"w14:val",symbolfont:"w14:font"})}},S1=class extends t{constructor(B,U,G){super(B);if(G)this.root.push(new o6({val:SB(U),symbolfont:G}));else this.root.push(new o6({val:U}))}},B5=class extends t{constructor(B){var U,G,Y,Q,K,Z,J,M;super("w14:checkbox");e(this,"DEFAULT_UNCHECKED_SYMBOL","2610"),e(this,"DEFAULT_CHECKED_SYMBOL","2612"),e(this,"DEFAULT_FONT","MS Gothic");let W=(B===null||B===void 0?void 0:B.checked)?"1":"0",I,F;this.root.push(new S1("w14:checked",W)),I=(B===null||B===void 0||(U=B.checkedState)===null||U===void 0?void 0:U.value)?B===null||B===void 0||(G=B.checkedState)===null||G===void 0?void 0:G.value:this.DEFAULT_CHECKED_SYMBOL,F=(B===null||B===void 0||(Y=B.checkedState)===null||Y===void 0?void 0:Y.font)?B===null||B===void 0||(Q=B.checkedState)===null||Q===void 0?void 0:Q.font:this.DEFAULT_FONT,this.root.push(new S1("w14:checkedState",I,F)),I=(B===null||B===void 0||(K=B.uncheckedState)===null||K===void 0?void 0:K.value)?B===null||B===void 0||(Z=B.uncheckedState)===null||Z===void 0?void 0:Z.value:this.DEFAULT_UNCHECKED_SYMBOL,F=(B===null||B===void 0||(J=B.uncheckedState)===null||J===void 0?void 0:J.font)?B===null||B===void 0||(M=B.uncheckedState)===null||M===void 0?void 0:M.font:this.DEFAULT_FONT,this.root.push(new S1("w14:uncheckedState",I,F))}},WK=class extends t{constructor(B){var U,G,Y,Q;super("w:sdt");e(this,"DEFAULT_UNCHECKED_SYMBOL","2610"),e(this,"DEFAULT_CHECKED_SYMBOL","2612"),e(this,"DEFAULT_FONT","MS Gothic");let K=new i9(B===null||B===void 0?void 0:B.alias);K.addChildElement(new B5(B)),this.root.push(K);let Z=new r9,J=B===null||B===void 0||(U=B.checkedState)===null||U===void 0?void 0:U.font,M=B===null||B===void 0||(G=B.checkedState)===null||G===void 0?void 0:G.value,W=B===null||B===void 0||(Y=B.uncheckedState)===null||Y===void 0?void 0:Y.font,I=B===null||B===void 0||(Q=B.uncheckedState)===null||Q===void 0?void 0:Q.value,F,D;if(B===null||B===void 0?void 0:B.checked)F=J?J:this.DEFAULT_FONT,D=M?M:this.DEFAULT_CHECKED_SYMBOL;else F=W?W:this.DEFAULT_FONT,D=I?I:this.DEFAULT_UNCHECKED_SYMBOL;let w=new aB({char:D,symbolfont:F});Z.addChildElement(w),this.root.push(Z)}},PK=({shape:B})=>new X0({name:"w:pict",children:[B]}),wK=({children:B=[]})=>new X0({name:"w:txbxContent",children:B}),AK=({style:B,children:U,inset:G})=>new X0({name:"v:textbox",attributes:{style:{key:"style",value:B},insetMode:{key:"insetmode",value:G?"custom":"auto"},inset:{key:"inset",value:G?`${G.left}, ${G.top}, ${G.right}, ${G.bottom}`:void 0}},children:[wK({children:U})]}),jK="#_x0000_t202",NK={flip:"flip",height:"height",left:"left",marginBottom:"margin-bottom",marginLeft:"margin-left",marginRight:"margin-right",marginTop:"margin-top",positionHorizontal:"mso-position-horizontal",positionHorizontalRelative:"mso-position-horizontal-relative",positionVertical:"mso-position-vertical",positionVerticalRelative:"mso-position-vertical-relative",wrapDistanceBottom:"mso-wrap-distance-bottom",wrapDistanceLeft:"mso-wrap-distance-left",wrapDistanceRight:"mso-wrap-distance-right",wrapDistanceTop:"mso-wrap-distance-top",wrapEdited:"mso-wrap-edited",wrapStyle:"mso-wrap-style",position:"position",rotation:"rotation",top:"top",visibility:"visibility",width:"width",zIndex:"z-index"},zK=(B)=>B?Object.entries(B).map(([U,G])=>`${NK[U]}:${G}`).join(";"):void 0,EK=({id:B,children:U,type:G=jK,style:Y})=>new X0({name:"v:shape",attributes:{id:{key:"id",value:B},type:{key:"type",value:G},style:{key:"style",value:zK(Y)}},children:[AK({style:"mso-fit-shape-to-text:t;",children:U})]}),TK=["style","children"],DK=class extends F1{constructor(B){let{style:U,children:G}=B,Y=n9(B,TK);super("w:p");this.root.push(new X2(Y)),this.root.push(PK({shape:EK({children:G,id:O1(),style:U})}))}},CK=R0((B,U)=>{d2(),P2();/*! + + JSZip v3.10.1 - A JavaScript class for generating and reading zip files + + + (c) 2009-2016 Stuart Knightley + Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. + + JSZip uses the library pako released under the MIT license : + https://github.com/nodeca/pako/blob/main/LICENSE + */(function(G){if(typeof B=="object"&&typeof U<"u")U.exports=G();else if(typeof define=="function"&&define.amd)define([],G);else(typeof window<"u"?window:typeof v0<"u"?v0:typeof self<"u"?self:this).JSZip=G()})(function(){return function G(Y,Q,K){function Z(W,I){if(!Q[W]){if(!Y[W]){var F=typeof N1=="function"&&N1;if(!I&&F)return F(W,!0);if(J)return J(W,!0);var D=Error("Cannot find module '"+W+"'");throw D.code="MODULE_NOT_FOUND",D}var w=Q[W]={exports:{}};Y[W][0].call(w.exports,function(P){var A=Y[W][1][P];return Z(A||P)},w,w.exports,G,Y,Q,K)}return Q[W].exports}for(var J=typeof N1=="function"&&N1,M=0;M>2,w=(3&W)<<4|I>>4,P=1>6:64,A=2>4,I=(15&D)<<4|(w=J.indexOf(M.charAt(A++)))>>2,F=(3&w)<<6|(P=J.indexOf(M.charAt(A++))),j[E++]=W,w!==64&&(j[E++]=I),P!==64&&(j[E++]=F);return j}},{"./support":30,"./utils":32}],2:[function(G,Y,Q){var K=G("./external"),Z=G("./stream/DataWorker"),J=G("./stream/Crc32Probe"),M=G("./stream/DataLengthProbe");function W(I,F,D,w,P){this.compressedSize=I,this.uncompressedSize=F,this.crc32=D,this.compression=w,this.compressedContent=P}W.prototype={getContentWorker:function(){var I=new Z(K.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new M("data_length")),F=this;return I.on("end",function(){if(this.streamInfo.data_length!==F.uncompressedSize)throw Error("Bug : uncompressed data size mismatch")}),I},getCompressedWorker:function(){return new Z(K.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},W.createWorkerFrom=function(I,F,D){return I.pipe(new J).pipe(new M("uncompressedSize")).pipe(F.compressWorker(D)).pipe(new M("compressedSize")).withStreamInfo("compression",F)},Y.exports=W},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(G,Y,Q){var K=G("./stream/GenericWorker");Q.STORE={magic:"\x00\x00",compressWorker:function(){return new K("STORE compression")},uncompressWorker:function(){return new K("STORE decompression")}},Q.DEFLATE=G("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(G,Y,Q){var K=G("./utils"),Z=function(){for(var J,M=[],W=0;W<256;W++){J=W;for(var I=0;I<8;I++)J=1&J?3988292384^J>>>1:J>>>1;M[W]=J}return M}();Y.exports=function(J,M){return J!==void 0&&J.length?K.getTypeOf(J)!=="string"?function(W,I,F,D){var w=Z,P=D+F;W^=-1;for(var A=D;A>>8^w[255&(W^I[A])];return-1^W}(0|M,J,J.length,0):function(W,I,F,D){var w=Z,P=D+F;W^=-1;for(var A=D;A>>8^w[255&(W^I.charCodeAt(A))];return-1^W}(0|M,J,J.length,0):0}},{"./utils":32}],5:[function(G,Y,Q){Q.base64=!1,Q.binary=!1,Q.dir=!1,Q.createFolders=!0,Q.date=null,Q.compression=null,Q.compressionOptions=null,Q.comment=null,Q.unixPermissions=null,Q.dosPermissions=null},{}],6:[function(G,Y,Q){var K=null;K=typeof Promise<"u"?Promise:G("lie"),Y.exports={Promise:K}},{lie:37}],7:[function(G,Y,Q){var K=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",Z=G("pako"),J=G("./utils"),M=G("./stream/GenericWorker"),W=K?"uint8array":"array";function I(F,D){M.call(this,"FlateWorker/"+F),this._pako=null,this._pakoAction=F,this._pakoOptions=D,this.meta={}}Q.magic="\b\x00",J.inherits(I,M),I.prototype.processChunk=function(F){this.meta=F.meta,this._pako===null&&this._createPako(),this._pako.push(J.transformTo(W,F.data),!1)},I.prototype.flush=function(){M.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},I.prototype.cleanUp=function(){M.prototype.cleanUp.call(this),this._pako=null},I.prototype._createPako=function(){this._pako=new Z[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var F=this;this._pako.onData=function(D){F.push({data:D,meta:F.meta})}},Q.compressWorker=function(F){return new I("Deflate",F)},Q.uncompressWorker=function(){return new I("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(G,Y,Q){function K(w,P){var A,E="";for(A=0;A>>=8;return E}function Z(w,P,A,E,C,j){var v,S,H=w.file,X=w.compression,$=j!==W.utf8encode,x=J.transformTo("string",j(H.name)),N=J.transformTo("string",W.utf8encode(H.name)),a=H.comment,U0=J.transformTo("string",j(a)),b=J.transformTo("string",W.utf8encode(a)),c=N.length!==H.name.length,T=b.length!==a.length,m="",B0="",i="",V0=H.dir,s=H.date,G0={crc32:0,compressedSize:0,uncompressedSize:0};P&&!A||(G0.crc32=w.crc32,G0.compressedSize=w.compressedSize,G0.uncompressedSize=w.uncompressedSize);var r=0;P&&(r|=8),$||!c&&!T||(r|=2048);var y=0,n=0;V0&&(y|=16),C==="UNIX"?(n=798,y|=function(Y0,O0){var z=Y0;return Y0||(z=O0?16893:33204),(65535&z)<<16}(H.unixPermissions,V0)):(n=20,y|=function(Y0){return 63&(Y0||0)}(H.dosPermissions)),v=s.getUTCHours(),v<<=6,v|=s.getUTCMinutes(),v<<=5,v|=s.getUTCSeconds()/2,S=s.getUTCFullYear()-1980,S<<=4,S|=s.getUTCMonth()+1,S<<=5,S|=s.getUTCDate(),c&&(B0=K(1,1)+K(I(x),4)+N,m+="up"+K(B0.length,2)+B0),T&&(i=K(1,1)+K(I(U0),4)+b,m+="uc"+K(i.length,2)+i);var o="";return o+=` +\x00`,o+=K(r,2),o+=X.magic,o+=K(v,2),o+=K(S,2),o+=K(G0.crc32,4),o+=K(G0.compressedSize,4),o+=K(G0.uncompressedSize,4),o+=K(x.length,2),o+=K(m.length,2),{fileRecord:F.LOCAL_FILE_HEADER+o+x+m,dirRecord:F.CENTRAL_FILE_HEADER+K(n,2)+o+K(U0.length,2)+"\x00\x00\x00\x00"+K(y,4)+K(E,4)+x+m+U0}}var J=G("../utils"),M=G("../stream/GenericWorker"),W=G("../utf8"),I=G("../crc32"),F=G("../signature");function D(w,P,A,E){M.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=P,this.zipPlatform=A,this.encodeFileName=E,this.streamFiles=w,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}J.inherits(D,M),D.prototype.push=function(w){var P=w.meta.percent||0,A=this.entriesCount,E=this._sources.length;this.accumulate?this.contentBuffer.push(w):(this.bytesWritten+=w.data.length,M.prototype.push.call(this,{data:w.data,meta:{currentFile:this.currentFile,percent:A?(P+100*(A-E-1))/A:100}}))},D.prototype.openedSource=function(w){this.currentSourceOffset=this.bytesWritten,this.currentFile=w.file.name;var P=this.streamFiles&&!w.file.dir;if(P){var A=Z(w,P,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:A.fileRecord,meta:{percent:0}})}else this.accumulate=!0},D.prototype.closedSource=function(w){this.accumulate=!1;var P=this.streamFiles&&!w.file.dir,A=Z(w,P,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(A.dirRecord),P)this.push({data:function(E){return F.DATA_DESCRIPTOR+K(E.crc32,4)+K(E.compressedSize,4)+K(E.uncompressedSize,4)}(w),meta:{percent:100}});else for(this.push({data:A.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},D.prototype.flush=function(){for(var w=this.bytesWritten,P=0;P=this.index;M--)W=(W<<8)+this.byteAt(M);return this.index+=J,W},readString:function(J){return K.transformTo("string",this.readData(J))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var J=this.readInt(4);return new Date(Date.UTC(1980+(J>>25&127),(J>>21&15)-1,J>>16&31,J>>11&31,J>>5&63,(31&J)<<1))}},Y.exports=Z},{"../utils":32}],19:[function(G,Y,Q){var K=G("./Uint8ArrayReader");function Z(J){K.call(this,J)}G("../utils").inherits(Z,K),Z.prototype.readData=function(J){this.checkOffset(J);var M=this.data.slice(this.zero+this.index,this.zero+this.index+J);return this.index+=J,M},Y.exports=Z},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(G,Y,Q){var K=G("./DataReader");function Z(J){K.call(this,J)}G("../utils").inherits(Z,K),Z.prototype.byteAt=function(J){return this.data.charCodeAt(this.zero+J)},Z.prototype.lastIndexOfSignature=function(J){return this.data.lastIndexOf(J)-this.zero},Z.prototype.readAndCheckSignature=function(J){return J===this.readData(4)},Z.prototype.readData=function(J){this.checkOffset(J);var M=this.data.slice(this.zero+this.index,this.zero+this.index+J);return this.index+=J,M},Y.exports=Z},{"../utils":32,"./DataReader":18}],21:[function(G,Y,Q){var K=G("./ArrayReader");function Z(J){K.call(this,J)}G("../utils").inherits(Z,K),Z.prototype.readData=function(J){if(this.checkOffset(J),J===0)return new Uint8Array(0);var M=this.data.subarray(this.zero+this.index,this.zero+this.index+J);return this.index+=J,M},Y.exports=Z},{"../utils":32,"./ArrayReader":17}],22:[function(G,Y,Q){var K=G("../utils"),Z=G("../support"),J=G("./ArrayReader"),M=G("./StringReader"),W=G("./NodeBufferReader"),I=G("./Uint8ArrayReader");Y.exports=function(F){var D=K.getTypeOf(F);return K.checkSupport(D),D!=="string"||Z.uint8array?D==="nodebuffer"?new W(F):Z.uint8array?new I(K.transformTo("uint8array",F)):new J(K.transformTo("array",F)):new M(F)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(G,Y,Q){Q.LOCAL_FILE_HEADER="PK\x03\x04",Q.CENTRAL_FILE_HEADER="PK\x01\x02",Q.CENTRAL_DIRECTORY_END="PK\x05\x06",Q.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x06\x07",Q.ZIP64_CENTRAL_DIRECTORY_END="PK\x06\x06",Q.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(G,Y,Q){var K=G("./GenericWorker"),Z=G("../utils");function J(M){K.call(this,"ConvertWorker to "+M),this.destType=M}Z.inherits(J,K),J.prototype.processChunk=function(M){this.push({data:Z.transformTo(this.destType,M.data),meta:M.meta})},Y.exports=J},{"../utils":32,"./GenericWorker":28}],25:[function(G,Y,Q){var K=G("./GenericWorker"),Z=G("../crc32");function J(){K.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}G("../utils").inherits(J,K),J.prototype.processChunk=function(M){this.streamInfo.crc32=Z(M.data,this.streamInfo.crc32||0),this.push(M)},Y.exports=J},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(G,Y,Q){var K=G("../utils"),Z=G("./GenericWorker");function J(M){Z.call(this,"DataLengthProbe for "+M),this.propName=M,this.withStreamInfo(M,0)}K.inherits(J,Z),J.prototype.processChunk=function(M){if(M){var W=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=W+M.data.length}Z.prototype.processChunk.call(this,M)},Y.exports=J},{"../utils":32,"./GenericWorker":28}],27:[function(G,Y,Q){var K=G("../utils"),Z=G("./GenericWorker");function J(M){Z.call(this,"DataWorker");var W=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,M.then(function(I){W.dataIsReady=!0,W.data=I,W.max=I&&I.length||0,W.type=K.getTypeOf(I),W.isPaused||W._tickAndRepeat()},function(I){W.error(I)})}K.inherits(J,Z),J.prototype.cleanUp=function(){Z.prototype.cleanUp.call(this),this.data=null},J.prototype.resume=function(){return!!Z.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,K.delay(this._tickAndRepeat,[],this)),!0)},J.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(K.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},J.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var M=null,W=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":M=this.data.substring(this.index,W);break;case"uint8array":M=this.data.subarray(this.index,W);break;case"array":case"nodebuffer":M=this.data.slice(this.index,W)}return this.index=W,this.push({data:M,meta:{percent:this.max?this.index/this.max*100:0}})},Y.exports=J},{"../utils":32,"./GenericWorker":28}],28:[function(G,Y,Q){function K(Z){this.name=Z||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}K.prototype={push:function(Z){this.emit("data",Z)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(Z){this.emit("error",Z)}return!0},error:function(Z){return!this.isFinished&&(this.isPaused?this.generatedError=Z:(this.isFinished=!0,this.emit("error",Z),this.previous&&this.previous.error(Z),this.cleanUp()),!0)},on:function(Z,J){return this._listeners[Z].push(J),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(Z,J){if(this._listeners[Z])for(var M=0;M "+Z:Z}},Y.exports=K},{}],29:[function(G,Y,Q){var K=G("../utils"),Z=G("./ConvertWorker"),J=G("./GenericWorker"),M=G("../base64"),W=G("../support"),I=G("../external"),F=null;if(W.nodestream)try{F=G("../nodejs/NodejsStreamOutputAdapter")}catch(P){}function D(P,A){return new I.Promise(function(E,C){var j=[],v=P._internalType,S=P._outputType,H=P._mimeType;P.on("data",function(X,$){j.push(X),A&&A($)}).on("error",function(X){j=[],C(X)}).on("end",function(){try{E(function(X,$,x){switch(X){case"blob":return K.newBlob(K.transformTo("arraybuffer",$),x);case"base64":return M.encode($);default:return K.transformTo(X,$)}}(S,function(X,$){var x,N=0,a=null,U0=0;for(x=0;x<$.length;x++)U0+=$[x].length;switch(X){case"string":return $.join("");case"array":return Array.prototype.concat.apply([],$);case"uint8array":for(a=new Uint8Array(U0),x=0;x<$.length;x++)a.set($[x],N),N+=$[x].length;return a;case"nodebuffer":return Buffer.concat($);default:throw Error("concat : unsupported type '"+X+"'")}}(v,j),H))}catch(X){C(X)}j=[]}).resume()})}function w(P,A,E){var C=A;switch(A){case"blob":case"arraybuffer":C="uint8array";break;case"base64":C="string"}try{this._internalType=C,this._outputType=A,this._mimeType=E,K.checkSupport(C),this._worker=P.pipe(new Z(C)),P.lock()}catch(j){this._worker=new J("error"),this._worker.error(j)}}w.prototype={accumulate:function(P){return D(this,P)},on:function(P,A){var E=this;return P==="data"?this._worker.on(P,function(C){A.call(E,C.data,C.meta)}):this._worker.on(P,function(){K.delay(A,arguments,E)}),this},resume:function(){return K.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(P){if(K.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw Error(this._outputType+" is not supported by this method");return new F(this,{objectMode:this._outputType!=="nodebuffer"},P)}},Y.exports=w},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(G,Y,Q){if(Q.base64=!0,Q.array=!0,Q.string=!0,Q.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",Q.nodebuffer=typeof Buffer<"u",Q.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")Q.blob=!1;else{var K=new ArrayBuffer(0);try{Q.blob=new Blob([K],{type:"application/zip"}).size===0}catch(J){try{var Z=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);Z.append(K),Q.blob=Z.getBlob("application/zip").size===0}catch(M){Q.blob=!1}}}try{Q.nodestream=!!G("readable-stream").Readable}catch(J){Q.nodestream=!1}},{"readable-stream":16}],31:[function(G,Y,Q){for(var K=G("./utils"),Z=G("./support"),J=G("./nodejsUtils"),M=G("./stream/GenericWorker"),W=Array(256),I=0;I<256;I++)W[I]=252<=I?6:248<=I?5:240<=I?4:224<=I?3:192<=I?2:1;W[254]=W[254]=1;function F(){M.call(this,"utf-8 decode"),this.leftOver=null}function D(){M.call(this,"utf-8 encode")}Q.utf8encode=function(w){return Z.nodebuffer?J.newBufferFrom(w,"utf-8"):function(P){var A,E,C,j,v,S=P.length,H=0;for(j=0;j>>6:(E<65536?A[v++]=224|E>>>12:(A[v++]=240|E>>>18,A[v++]=128|E>>>12&63),A[v++]=128|E>>>6&63),A[v++]=128|63&E);return A}(w)},Q.utf8decode=function(w){return Z.nodebuffer?K.transformTo("nodebuffer",w).toString("utf-8"):function(P){var A,E,C,j,v=P.length,S=Array(2*v);for(A=E=0;A>10&1023,S[E++]=56320|1023&C)}return S.length!==E&&(S.subarray?S=S.subarray(0,E):S.length=E),K.applyFromCharCode(S)}(w=K.transformTo(Z.uint8array?"uint8array":"array",w))},K.inherits(F,M),F.prototype.processChunk=function(w){var P=K.transformTo(Z.uint8array?"uint8array":"array",w.data);if(this.leftOver&&this.leftOver.length){if(Z.uint8array){var A=P;(P=new Uint8Array(A.length+this.leftOver.length)).set(this.leftOver,0),P.set(A,this.leftOver.length)}else P=this.leftOver.concat(P);this.leftOver=null}var E=function(j,v){var S;for((v=v||j.length)>j.length&&(v=j.length),S=v-1;0<=S&&(192&j[S])==128;)S--;return S<0?v:S===0?v:S+W[j[S]]>v?S:v}(P),C=P;E!==P.length&&(Z.uint8array?(C=P.subarray(0,E),this.leftOver=P.subarray(E,P.length)):(C=P.slice(0,E),this.leftOver=P.slice(E,P.length))),this.push({data:Q.utf8decode(C),meta:w.meta})},F.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:Q.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},Q.Utf8DecodeWorker=F,K.inherits(D,M),D.prototype.processChunk=function(w){this.push({data:Q.utf8encode(w.data),meta:w.meta})},Q.Utf8EncodeWorker=D},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(G,Y,Q){var K=G("./support"),Z=G("./base64"),J=G("./nodejsUtils"),M=G("./external");function W(A){return A}function I(A,E){for(var C=0;C>8;this.dir=!!(16&this.externalFileAttributes),w==0&&(this.dosPermissions=63&this.externalFileAttributes),w==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var w=K(this.extraFields[1].value);this.uncompressedSize===Z.MAX_VALUE_32BITS&&(this.uncompressedSize=w.readInt(8)),this.compressedSize===Z.MAX_VALUE_32BITS&&(this.compressedSize=w.readInt(8)),this.localHeaderOffset===Z.MAX_VALUE_32BITS&&(this.localHeaderOffset=w.readInt(8)),this.diskNumberStart===Z.MAX_VALUE_32BITS&&(this.diskNumberStart=w.readInt(4))}},readExtraFields:function(w){var P,A,E,C=w.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});w.index+4>>6:(w<65536?D[E++]=224|w>>>12:(D[E++]=240|w>>>18,D[E++]=128|w>>>12&63),D[E++]=128|w>>>6&63),D[E++]=128|63&w);return D},Q.buf2binstring=function(F){return I(F,F.length)},Q.binstring2buf=function(F){for(var D=new K.Buf8(F.length),w=0,P=D.length;w>10&1023,j[P++]=56320|1023&A)}return I(j,P)},Q.utf8border=function(F,D){var w;for((D=D||F.length)>F.length&&(D=F.length),w=D-1;0<=w&&(192&F[w])==128;)w--;return w<0?D:w===0?D:w+M[F[w]]>D?w:D}},{"./common":41}],43:[function(G,Y,Q){Y.exports=function(K,Z,J,M){for(var W=65535&K|0,I=K>>>16&65535|0,F=0;J!==0;){for(J-=F=2000>>1:Z>>>1;J[M]=Z}return J}();Y.exports=function(Z,J,M,W){var I=K,F=W+M;Z^=-1;for(var D=W;D>>8^I[255&(Z^J[D])];return-1^Z}},{}],46:[function(G,Y,Q){var K,Z=G("../utils/common"),J=G("./trees"),M=G("./adler32"),W=G("./crc32"),I=G("./messages"),F=0,D=4,w=0,P=-2,A=-1,E=4,C=2,j=8,v=9,S=286,H=30,X=19,$=2*S+1,x=15,N=3,a=258,U0=a+N+1,b=42,c=113,T=1,m=2,B0=3,i=4;function V0(R,p){return R.msg=I[p],p}function s(R){return(R<<1)-(4R.avail_out&&(k=R.avail_out),k!==0&&(Z.arraySet(R.output,p.pending_buf,p.pending_out,k,R.next_out),R.next_out+=k,p.pending_out+=k,R.total_out+=k,R.avail_out-=k,p.pending-=k,p.pending===0&&(p.pending_out=0))}function y(R,p){J._tr_flush_block(R,0<=R.block_start?R.block_start:-1,R.strstart-R.block_start,p),R.block_start=R.strstart,r(R.strm)}function n(R,p){R.pending_buf[R.pending++]=p}function o(R,p){R.pending_buf[R.pending++]=p>>>8&255,R.pending_buf[R.pending++]=255&p}function Y0(R,p){var k,V,q=R.max_chain_length,O=R.strstart,_=R.prev_length,l=R.nice_match,d=R.strstart>R.w_size-U0?R.strstart-(R.w_size-U0):0,Q0=R.window,q0=R.w_mask,K0=R.prev,I0=R.strstart+a,H0=Q0[O+_-1],W0=Q0[O+_];R.prev_length>=R.good_match&&(q>>=2),l>R.lookahead&&(l=R.lookahead);do if(Q0[(k=p)+_]===W0&&Q0[k+_-1]===H0&&Q0[k]===Q0[O]&&Q0[++k]===Q0[O+1]){O+=2,k++;do;while(Q0[++O]===Q0[++k]&&Q0[++O]===Q0[++k]&&Q0[++O]===Q0[++k]&&Q0[++O]===Q0[++k]&&Q0[++O]===Q0[++k]&&Q0[++O]===Q0[++k]&&Q0[++O]===Q0[++k]&&Q0[++O]===Q0[++k]&&Od&&--q!=0);return _<=R.lookahead?_:R.lookahead}function O0(R){var p,k,V,q,O,_,l,d,Q0,q0,K0=R.w_size;do{if(q=R.window_size-R.lookahead-R.strstart,R.strstart>=K0+(K0-U0)){for(Z.arraySet(R.window,R.window,K0,K0,0),R.match_start-=K0,R.strstart-=K0,R.block_start-=K0,p=k=R.hash_size;V=R.head[--p],R.head[p]=K0<=V?V-K0:0,--k;);for(p=k=K0;V=R.prev[--p],R.prev[p]=K0<=V?V-K0:0,--k;);q+=K0}if(R.strm.avail_in===0)break;if(_=R.strm,l=R.window,d=R.strstart+R.lookahead,Q0=q,q0=void 0,q0=_.avail_in,Q0=N)for(O=R.strstart-R.insert,R.ins_h=R.window[O],R.ins_h=(R.ins_h<=N&&(R.ins_h=(R.ins_h<=N)if(V=J._tr_tally(R,R.strstart-R.match_start,R.match_length-N),R.lookahead-=R.match_length,R.match_length<=R.max_lazy_match&&R.lookahead>=N){for(R.match_length--;R.strstart++,R.ins_h=(R.ins_h<=N&&(R.ins_h=(R.ins_h<=N&&R.match_length<=R.prev_length){for(q=R.strstart+R.lookahead-N,V=J._tr_tally(R,R.strstart-1-R.prev_match,R.prev_length-N),R.lookahead-=R.prev_length-1,R.prev_length-=2;++R.strstart<=q&&(R.ins_h=(R.ins_h<R.pending_buf_size-5&&(k=R.pending_buf_size-5);;){if(R.lookahead<=1){if(O0(R),R.lookahead===0&&p===F)return T;if(R.lookahead===0)break}R.strstart+=R.lookahead,R.lookahead=0;var V=R.block_start+k;if((R.strstart===0||R.strstart>=V)&&(R.lookahead=R.strstart-V,R.strstart=V,y(R,!1),R.strm.avail_out===0))return T;if(R.strstart-R.block_start>=R.w_size-U0&&(y(R,!1),R.strm.avail_out===0))return T}return R.insert=0,p===D?(y(R,!0),R.strm.avail_out===0?B0:i):(R.strstart>R.block_start&&(y(R,!1),R.strm.avail_out),T)}),new u(4,4,8,4,z),new u(4,5,16,8,z),new u(4,6,32,32,z),new u(4,4,16,16,L),new u(8,16,32,32,L),new u(8,16,128,128,L),new u(8,32,128,256,L),new u(32,128,258,1024,L),new u(32,258,258,4096,L)],Q.deflateInit=function(R,p){return f(R,p,j,15,8,0)},Q.deflateInit2=f,Q.deflateReset=g,Q.deflateResetKeep=Z0,Q.deflateSetHeader=function(R,p){return R&&R.state?R.state.wrap!==2?P:(R.state.gzhead=p,w):P},Q.deflate=function(R,p){var k,V,q,O;if(!R||!R.state||5>8&255),n(V,V.gzhead.time>>16&255),n(V,V.gzhead.time>>24&255),n(V,V.level===9?2:2<=V.strategy||V.level<2?4:0),n(V,255&V.gzhead.os),V.gzhead.extra&&V.gzhead.extra.length&&(n(V,255&V.gzhead.extra.length),n(V,V.gzhead.extra.length>>8&255)),V.gzhead.hcrc&&(R.adler=W(R.adler,V.pending_buf,V.pending,0)),V.gzindex=0,V.status=69):(n(V,0),n(V,0),n(V,0),n(V,0),n(V,0),n(V,V.level===9?2:2<=V.strategy||V.level<2?4:0),n(V,3),V.status=c);else{var _=j+(V.w_bits-8<<4)<<8;_|=(2<=V.strategy||V.level<2?0:V.level<6?1:V.level===6?2:3)<<6,V.strstart!==0&&(_|=32),_+=31-_%31,V.status=c,o(V,_),V.strstart!==0&&(o(V,R.adler>>>16),o(V,65535&R.adler)),R.adler=1}if(V.status===69)if(V.gzhead.extra){for(q=V.pending;V.gzindex<(65535&V.gzhead.extra.length)&&(V.pending!==V.pending_buf_size||(V.gzhead.hcrc&&V.pending>q&&(R.adler=W(R.adler,V.pending_buf,V.pending-q,q)),r(R),q=V.pending,V.pending!==V.pending_buf_size));)n(V,255&V.gzhead.extra[V.gzindex]),V.gzindex++;V.gzhead.hcrc&&V.pending>q&&(R.adler=W(R.adler,V.pending_buf,V.pending-q,q)),V.gzindex===V.gzhead.extra.length&&(V.gzindex=0,V.status=73)}else V.status=73;if(V.status===73)if(V.gzhead.name){q=V.pending;do{if(V.pending===V.pending_buf_size&&(V.gzhead.hcrc&&V.pending>q&&(R.adler=W(R.adler,V.pending_buf,V.pending-q,q)),r(R),q=V.pending,V.pending===V.pending_buf_size)){O=1;break}O=V.gzindexq&&(R.adler=W(R.adler,V.pending_buf,V.pending-q,q)),O===0&&(V.gzindex=0,V.status=91)}else V.status=91;if(V.status===91)if(V.gzhead.comment){q=V.pending;do{if(V.pending===V.pending_buf_size&&(V.gzhead.hcrc&&V.pending>q&&(R.adler=W(R.adler,V.pending_buf,V.pending-q,q)),r(R),q=V.pending,V.pending===V.pending_buf_size)){O=1;break}O=V.gzindexq&&(R.adler=W(R.adler,V.pending_buf,V.pending-q,q)),O===0&&(V.status=103)}else V.status=103;if(V.status===103&&(V.gzhead.hcrc?(V.pending+2>V.pending_buf_size&&r(R),V.pending+2<=V.pending_buf_size&&(n(V,255&R.adler),n(V,R.adler>>8&255),R.adler=0,V.status=c)):V.status=c),V.pending!==0){if(r(R),R.avail_out===0)return V.last_flush=-1,w}else if(R.avail_in===0&&s(p)<=s(k)&&p!==D)return V0(R,-5);if(V.status===666&&R.avail_in!==0)return V0(R,-5);if(R.avail_in!==0||V.lookahead!==0||p!==F&&V.status!==666){var l=V.strategy===2?function(d,Q0){for(var q0;;){if(d.lookahead===0&&(O0(d),d.lookahead===0)){if(Q0===F)return T;break}if(d.match_length=0,q0=J._tr_tally(d,0,d.window[d.strstart]),d.lookahead--,d.strstart++,q0&&(y(d,!1),d.strm.avail_out===0))return T}return d.insert=0,Q0===D?(y(d,!0),d.strm.avail_out===0?B0:i):d.last_lit&&(y(d,!1),d.strm.avail_out===0)?T:m}(V,p):V.strategy===3?function(d,Q0){for(var q0,K0,I0,H0,W0=d.window;;){if(d.lookahead<=a){if(O0(d),d.lookahead<=a&&Q0===F)return T;if(d.lookahead===0)break}if(d.match_length=0,d.lookahead>=N&&0d.lookahead&&(d.match_length=d.lookahead)}if(d.match_length>=N?(q0=J._tr_tally(d,1,d.match_length-N),d.lookahead-=d.match_length,d.strstart+=d.match_length,d.match_length=0):(q0=J._tr_tally(d,0,d.window[d.strstart]),d.lookahead--,d.strstart++),q0&&(y(d,!1),d.strm.avail_out===0))return T}return d.insert=0,Q0===D?(y(d,!0),d.strm.avail_out===0?B0:i):d.last_lit&&(y(d,!1),d.strm.avail_out===0)?T:m}(V,p):K[V.level].func(V,p);if(l!==B0&&l!==i||(V.status=666),l===T||l===B0)return R.avail_out===0&&(V.last_flush=-1),w;if(l===m&&(p===1?J._tr_align(V):p!==5&&(J._tr_stored_block(V,0,0,!1),p===3&&(G0(V.head),V.lookahead===0&&(V.strstart=0,V.block_start=0,V.insert=0))),r(R),R.avail_out===0))return V.last_flush=-1,w}return p!==D?w:V.wrap<=0?1:(V.wrap===2?(n(V,255&R.adler),n(V,R.adler>>8&255),n(V,R.adler>>16&255),n(V,R.adler>>24&255),n(V,255&R.total_in),n(V,R.total_in>>8&255),n(V,R.total_in>>16&255),n(V,R.total_in>>24&255)):(o(V,R.adler>>>16),o(V,65535&R.adler)),r(R),0=k.w_size&&(O===0&&(G0(k.head),k.strstart=0,k.block_start=0,k.insert=0),Q0=new Z.Buf8(k.w_size),Z.arraySet(Q0,p,q0-k.w_size,k.w_size,0),p=Q0,q0=k.w_size),_=R.avail_in,l=R.next_in,d=R.input,R.avail_in=q0,R.next_in=0,R.input=p,O0(k);k.lookahead>=N;){for(V=k.strstart,q=k.lookahead-(N-1);k.ins_h=(k.ins_h<>>=N=x>>>24,v-=N,(N=x>>>16&255)===0)m[I++]=65535&x;else{if(!(16&N)){if((64&N)==0){x=S[(65535&x)+(j&(1<>>=N,v-=N),v<15&&(j+=T[M++]<>>=N=x>>>24,v-=N,!(16&(N=x>>>16&255))){if((64&N)==0){x=H[(65535&x)+(j&(1<>>=N,v-=N,(N=I-F)>3,j&=(1<<(v-=a<<3))-1,K.next_in=M,K.next_out=I,K.avail_in=M>>24&255)+(b>>>8&65280)+((65280&b)<<8)+((255&b)<<24)}function j(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new K.Buf16(320),this.work=new K.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function v(b){var c;return b&&b.state?(c=b.state,b.total_in=b.total_out=c.total=0,b.msg="",c.wrap&&(b.adler=1&c.wrap),c.mode=P,c.last=0,c.havedict=0,c.dmax=32768,c.head=null,c.hold=0,c.bits=0,c.lencode=c.lendyn=new K.Buf32(A),c.distcode=c.distdyn=new K.Buf32(E),c.sane=1,c.back=-1,D):w}function S(b){var c;return b&&b.state?((c=b.state).wsize=0,c.whave=0,c.wnext=0,v(b)):w}function H(b,c){var T,m;return b&&b.state?(m=b.state,c<0?(T=0,c=-c):(T=1+(c>>4),c<48&&(c&=15)),c&&(c<8||15=i.wsize?(K.arraySet(i.window,c,T-i.wsize,i.wsize,0),i.wnext=0,i.whave=i.wsize):(m<(B0=i.wsize-i.wnext)&&(B0=m),K.arraySet(i.window,c,T-m,B0,i.wnext),(m-=B0)?(K.arraySet(i.window,c,T-m,m,0),i.wnext=m,i.whave=i.wsize):(i.wnext+=B0,i.wnext===i.wsize&&(i.wnext=0),i.whave>>8&255,T.check=J(T.check,O,2,0),y=r=0,T.mode=2;break}if(T.flags=0,T.head&&(T.head.done=!1),!(1&T.wrap)||(((255&r)<<8)+(r>>8))%31){b.msg="incorrect header check",T.mode=30;break}if((15&r)!=8){b.msg="unknown compression method",T.mode=30;break}if(y-=4,R=8+(15&(r>>>=4)),T.wbits===0)T.wbits=R;else if(R>T.wbits){b.msg="invalid window size",T.mode=30;break}T.dmax=1<>8&1),512&T.flags&&(O[0]=255&r,O[1]=r>>>8&255,T.check=J(T.check,O,2,0)),y=r=0,T.mode=3;case 3:for(;y<32;){if(s===0)break B;s--,r+=m[i++]<>>8&255,O[2]=r>>>16&255,O[3]=r>>>24&255,T.check=J(T.check,O,4,0)),y=r=0,T.mode=4;case 4:for(;y<16;){if(s===0)break B;s--,r+=m[i++]<>8),512&T.flags&&(O[0]=255&r,O[1]=r>>>8&255,T.check=J(T.check,O,2,0)),y=r=0,T.mode=5;case 5:if(1024&T.flags){for(;y<16;){if(s===0)break B;s--,r+=m[i++]<>>8&255,T.check=J(T.check,O,2,0)),y=r=0}else T.head&&(T.head.extra=null);T.mode=6;case 6:if(1024&T.flags&&(s<(Y0=T.length)&&(Y0=s),Y0&&(T.head&&(R=T.head.extra_len-T.length,T.head.extra||(T.head.extra=Array(T.head.extra_len)),K.arraySet(T.head.extra,m,i,Y0,R)),512&T.flags&&(T.check=J(T.check,m,Y0,i)),s-=Y0,i+=Y0,T.length-=Y0),T.length))break B;T.length=0,T.mode=7;case 7:if(2048&T.flags){if(s===0)break B;for(Y0=0;R=m[i+Y0++],T.head&&R&&T.length<65536&&(T.head.name+=String.fromCharCode(R)),R&&Y0>9&1,T.head.done=!0),b.adler=T.check=0,T.mode=12;break;case 10:for(;y<32;){if(s===0)break B;s--,r+=m[i++]<>>=7&y,y-=7&y,T.mode=27;break}for(;y<3;){if(s===0)break B;s--,r+=m[i++]<>>=1)){case 0:T.mode=14;break;case 1:if(a(T),T.mode=20,c!==6)break;r>>>=2,y-=2;break B;case 2:T.mode=17;break;case 3:b.msg="invalid block type",T.mode=30}r>>>=2,y-=2;break;case 14:for(r>>>=7&y,y-=7&y;y<32;){if(s===0)break B;s--,r+=m[i++]<>>16^65535)){b.msg="invalid stored block lengths",T.mode=30;break}if(T.length=65535&r,y=r=0,T.mode=15,c===6)break B;case 15:T.mode=16;case 16:if(Y0=T.length){if(s>>=5,y-=5,T.ndist=1+(31&r),r>>>=5,y-=5,T.ncode=4+(15&r),r>>>=4,y-=4,286>>=3,y-=3}for(;T.have<19;)T.lens[_[T.have++]]=0;if(T.lencode=T.lendyn,T.lenbits=7,k={bits:T.lenbits},p=W(0,T.lens,0,19,T.lencode,0,T.work,k),T.lenbits=k.bits,p){b.msg="invalid code lengths set",T.mode=30;break}T.have=0,T.mode=19;case 19:for(;T.have>>16&255,h=65535&q,!((L=q>>>24)<=y);){if(s===0)break B;s--,r+=m[i++]<>>=L,y-=L,T.lens[T.have++]=h;else{if(h===16){for(V=L+2;y>>=L,y-=L,T.have===0){b.msg="invalid bit length repeat",T.mode=30;break}R=T.lens[T.have-1],Y0=3+(3&r),r>>>=2,y-=2}else if(h===17){for(V=L+3;y>>=L)),r>>>=3,y-=3}else{for(V=L+7;y>>=L)),r>>>=7,y-=7}if(T.have+Y0>T.nlen+T.ndist){b.msg="invalid bit length repeat",T.mode=30;break}for(;Y0--;)T.lens[T.have++]=R}}if(T.mode===30)break;if(T.lens[256]===0){b.msg="invalid code -- missing end-of-block",T.mode=30;break}if(T.lenbits=9,k={bits:T.lenbits},p=W(I,T.lens,0,T.nlen,T.lencode,0,T.work,k),T.lenbits=k.bits,p){b.msg="invalid literal/lengths set",T.mode=30;break}if(T.distbits=6,T.distcode=T.distdyn,k={bits:T.distbits},p=W(F,T.lens,T.nlen,T.ndist,T.distcode,0,T.work,k),T.distbits=k.bits,p){b.msg="invalid distances set",T.mode=30;break}if(T.mode=20,c===6)break B;case 20:T.mode=21;case 21:if(6<=s&&258<=G0){b.next_out=V0,b.avail_out=G0,b.next_in=i,b.avail_in=s,T.hold=r,T.bits=y,M(b,o),V0=b.next_out,B0=b.output,G0=b.avail_out,i=b.next_in,m=b.input,s=b.avail_in,r=T.hold,y=T.bits,T.mode===12&&(T.back=-1);break}for(T.back=0;u=(q=T.lencode[r&(1<>>16&255,h=65535&q,!((L=q>>>24)<=y);){if(s===0)break B;s--,r+=m[i++]<>Z0)])>>>16&255,h=65535&q,!(Z0+(L=q>>>24)<=y);){if(s===0)break B;s--,r+=m[i++]<>>=Z0,y-=Z0,T.back+=Z0}if(r>>>=L,y-=L,T.back+=L,T.length=h,u===0){T.mode=26;break}if(32&u){T.back=-1,T.mode=12;break}if(64&u){b.msg="invalid literal/length code",T.mode=30;break}T.extra=15&u,T.mode=22;case 22:if(T.extra){for(V=T.extra;y>>=T.extra,y-=T.extra,T.back+=T.extra}T.was=T.length,T.mode=23;case 23:for(;u=(q=T.distcode[r&(1<>>16&255,h=65535&q,!((L=q>>>24)<=y);){if(s===0)break B;s--,r+=m[i++]<>Z0)])>>>16&255,h=65535&q,!(Z0+(L=q>>>24)<=y);){if(s===0)break B;s--,r+=m[i++]<>>=Z0,y-=Z0,T.back+=Z0}if(r>>>=L,y-=L,T.back+=L,64&u){b.msg="invalid distance code",T.mode=30;break}T.offset=h,T.extra=15&u,T.mode=24;case 24:if(T.extra){for(V=T.extra;y>>=T.extra,y-=T.extra,T.back+=T.extra}if(T.offset>T.dmax){b.msg="invalid distance too far back",T.mode=30;break}T.mode=25;case 25:if(G0===0)break B;if(Y0=o-G0,T.offset>Y0){if((Y0=T.offset-Y0)>T.whave&&T.sane){b.msg="invalid distance too far back",T.mode=30;break}O0=Y0>T.wnext?(Y0-=T.wnext,T.wsize-Y0):T.wnext-Y0,Y0>T.length&&(Y0=T.length),z=T.window}else z=B0,O0=V0-T.offset,Y0=T.length;for(G0$?(N=O0[z+E[c]],y[n+E[c]]):(N=96,0),j=1<>V0)+(v-=j)]=x<<24|N<<16|a|0,v!==0;);for(j=1<>=1;if(j!==0?(r&=j-1,r+=j):r=0,c++,--o[b]==0){if(b===m)break;b=F[D+E[c]]}if(B0>>7)]}function n(q,O){q.pending_buf[q.pending++]=255&O,q.pending_buf[q.pending++]=O>>>8&255}function o(q,O,_){q.bi_valid>C-_?(q.bi_buf|=O<>C-q.bi_valid,q.bi_valid+=_-C):(q.bi_buf|=O<>>=1,_<<=1,0<--O;);return _>>>1}function z(q,O,_){var l,d,Q0=Array(E+1),q0=0;for(l=1;l<=E;l++)Q0[l]=q0=q0+_[l-1]<<1;for(d=0;d<=O;d++){var K0=q[2*d+1];K0!==0&&(q[2*d]=O0(Q0[K0]++,K0))}}function L(q){var O;for(O=0;O>1;1<=_;_--)Z0(q,Q0,_);for(d=I0;_=q.heap[1],q.heap[1]=q.heap[q.heap_len--],Z0(q,Q0,1),l=q.heap[1],q.heap[--q.heap_max]=_,q.heap[--q.heap_max]=l,Q0[2*d]=Q0[2*_]+Q0[2*l],q.depth[d]=(q.depth[_]>=q.depth[l]?q.depth[_]:q.depth[l])+1,Q0[2*_+1]=Q0[2*l+1]=d,q.heap[1]=d++,Z0(q,Q0,1),2<=q.heap_len;);q.heap[--q.heap_max]=q.heap[1],function(W0,k0){var L2,m0,r2,N0,W1,a1,Y2=k0.dyn_tree,L6=k0.max_code,q5=k0.stat_desc.static_tree,M5=k0.stat_desc.has_stree,X5=k0.stat_desc.extra_bits,I6=k0.stat_desc.extra_base,i2=k0.stat_desc.max_length,P1=0;for(N0=0;N0<=E;N0++)W0.bl_count[N0]=0;for(Y2[2*W0.heap[W0.heap_max]+1]=0,L2=W0.heap_max+1;L2>=7;d>>=1)if(1&H0&&K0.dyn_ltree[2*I0]!==0)return Z;if(K0.dyn_ltree[18]!==0||K0.dyn_ltree[20]!==0||K0.dyn_ltree[26]!==0)return J;for(I0=32;I0>>3,(Q0=q.static_len+3+7>>>3)<=d&&(d=Q0)):d=Q0=_+5,_+4<=d&&O!==-1?V(q,O,_,l):q.strategy===4||Q0===d?(o(q,2+(l?1:0),3),g(q,U0,b)):(o(q,4+(l?1:0),3),function(K0,I0,H0,W0){var k0;for(o(K0,I0-257,5),o(K0,H0-1,5),o(K0,W0-4,4),k0=0;k0>>8&255,q.pending_buf[q.d_buf+2*q.last_lit+1]=255&O,q.pending_buf[q.l_buf+q.last_lit]=255&_,q.last_lit++,O===0?q.dyn_ltree[2*_]++:(q.matches++,O--,q.dyn_ltree[2*(T[_]+F+1)]++,q.dyn_dtree[2*y(O)]++),q.last_lit===q.lit_bufsize-1},Q._tr_align=function(q){o(q,2,3),Y0(q,v,U0),function(O){O.bi_valid===16?(n(O,O.bi_buf),O.bi_buf=0,O.bi_valid=0):8<=O.bi_valid&&(O.pending_buf[O.pending++]=255&O.bi_buf,O.bi_buf>>=8,O.bi_valid-=8)}(q)}},{"../utils/common":41}],53:[function(G,Y,Q){Y.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(G,Y,Q){(function(K){(function(Z,J){if(!Z.setImmediate){var M,W,I,F,D=1,w={},P=!1,A=Z.document,E=Object.getPrototypeOf&&Object.getPrototypeOf(Z);E=E&&E.setTimeout?E:Z,M={}.toString.call(Z.process)==="[object process]"?function(S){P0.nextTick(function(){j(S)})}:function(){if(Z.postMessage&&!Z.importScripts){var S=!0,H=Z.onmessage;return Z.onmessage=function(){S=!1},Z.postMessage("","*"),Z.onmessage=H,S}}()?(F="setImmediate$"+Math.random()+"$",Z.addEventListener?Z.addEventListener("message",v,!1):Z.attachEvent("onmessage",v),function(S){Z.postMessage(F+S,"*")}):Z.MessageChannel?((I=new MessageChannel).port1.onmessage=function(S){j(S.data)},function(S){I.port2.postMessage(S)}):A&&("onreadystatechange"in A.createElement("script"))?(W=A.documentElement,function(S){var H=A.createElement("script");H.onreadystatechange=function(){j(S),H.onreadystatechange=null,W.removeChild(H),H=null},W.appendChild(H)}):function(S){setTimeout(j,0,S)},E.setImmediate=function(S){typeof S!="function"&&(S=Function(""+S));for(var H=Array(arguments.length-1),X=0;X"u"?K===void 0?this:K:self)}).call(this,typeof v0<"u"?v0:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})}),kK=R0((B,U)=>{var G={"&":"&",'"':""","'":"'","<":"<",">":">"};function Y(Q){return Q&&Q.replace?Q.replace(/([&"<>'])/g,function(K,Z){return G[Z]}):Q}U.exports=Y}),$K=R0((B,U)=>{P2();var G=kK(),Y=f8().Stream,Q=" ";function K(F,D){if(typeof D!=="object")D={indent:D};var w=D.stream?new Y:null,P="",A=!1,E=!D.indent?"":D.indent===!0?Q:D.indent,C=!0;function j($){if(!C)$();else P0.nextTick($)}function v($,x){if(x!==void 0)P+=x;if($&&!A)w=w||new Y,A=!0;if($&&A){var N=P;j(function(){w.emit("data",N)}),P=""}}function S($,x){W(v,M($,E,E?1:0),x)}function H(){if(w){var $=P;j(function(){w.emit("data",$),w.emit("end"),w.readable=!1,w.emit("close")})}}function X($){var x={version:"1.0",encoding:$.encoding||"UTF-8"};if($.standalone)x.standalone=$.standalone;S({"?xml":{_attr:x}}),P=P.replace("/>","?>")}if(j(function(){C=!1}),D.declaration)X(D.declaration);if(F&&F.forEach)F.forEach(function($,x){var N;if(x+1===F.length)N=H;S($,N)});else S(F,H);if(w)return w.readable=!0,w;return P}function Z(){var F={_elem:M(Array.prototype.slice.call(arguments))};return F.push=function(D){if(!this.append)throw Error("not assigned to a parent!");var w=this,P=this._elem.indent;W(this.append,M(D,P,this._elem.icount+(P?1:0)),function(){w.append(!0)})},F.close=function(D){if(D!==void 0)this.push(D);if(this.end)this.end()},F}function J(F,D){return Array(D||0).join(F||"")}function M(F,D,w){w=w||0;var P=J(D,w),A,E=F,C=!1;if(typeof F==="object"){if(A=Object.keys(F)[0],E=F[A],E&&E._elem)return E._elem.name=A,E._elem.icount=w,E._elem.indent=D,E._elem.indents=P,E._elem.interrupt=E,E._elem}var j=[],v=[],S;function H(X){Object.keys(X).forEach(function($){j.push(I($,X[$]))})}switch(typeof E){case"object":if(E===null)break;if(E._attr)H(E._attr);if(E._cdata)v.push(("/g,"]]]]>")+"]]>");if(E.forEach){if(S=!1,v.push(""),E.forEach(function(X){if(typeof X=="object")if(Object.keys(X)[0]=="_attr")H(X._attr);else v.push(M(X,D,w+1));else v.pop(),S=!0,v.push(G(X))}),!S)v.push("")}break;default:v.push(G(E))}return{name:A,interrupt:C,attributes:j,content:v,icount:w,indents:P,indent:D}}function W(F,D,w){if(typeof D!="object")return F(!1,D);var P=D.interrupt?1:D.content.length;function A(){while(D.content.length){var C=D.content.shift();if(C===void 0)continue;if(E(C))return;W(F,C)}if(F(!1,(P>1?D.indents:"")+(D.name?"":"")+(D.indent&&!w?` +`:"")),w)w()}function E(C){if(C.interrupt)return C.interrupt.append=F,C.interrupt.end=A,C.interrupt=!1,F(!0),!0;return!1}if(F(!1,D.indents+(D.name?"<"+D.name:"")+(D.attributes.length?" "+D.attributes.join(" "):"")+(P?D.name?">":"":D.name?"/>":"")+(D.indent&&P>1?` +`:"")),!P)return F(!1,D.indent?` +`:"");if(!E(D))A()}function I(F,D){return F+'="'+G(D)+'"'}U.exports=K,U.exports.element=U.exports.Element=Z}),SK=f8(),h2=C8(CK(),1),w0=C8($K(),1),o2=0,X8=32,bK=32,vK=(B,U)=>{let G=U.replace(/-/g,"");if(G.length!==bK)throw Error(`Error: Cannot extract GUID from font filename: ${U}`);let Y=G.replace(/(..)/g,"$1 ").trim().split(" ").map((Z)=>parseInt(Z,16));Y.reverse();let Q=B.slice(o2,X8).map((Z,J)=>Z^Y[J%Y.length]),K=new Uint8Array(o2+Q.length+Math.max(0,B.length-X8));return K.set(B.slice(0,o2)),K.set(Q,o2),K.set(B.slice(X8),o2+Q.length),K},q6=class{format(B,U={stack:[]}){let G=B.prepForXml(U);if(G)return G;else throw Error("XMLComponent did not format correctly")}},U5=class{replace(B,U,G){let Y=B;return U.forEach((Q,K)=>{Y=Y.replace(new RegExp(`{${Q.fileName}}`,"g"),(G+K).toString())}),Y}getMediaData(B,U){return U.Array.filter((G)=>B.search(`{${G.fileName}}`)>0)}},yK=class{replace(B,U){let G=B;for(let Y of U)G=G.replace(new RegExp(`{${Y.reference}-${Y.instance}}`,"g"),Y.numId.toString());return G}},gK=class{constructor(){e(this,"formatter",void 0),e(this,"imageReplacer",void 0),e(this,"numberingReplacer",void 0),this.formatter=new q6,this.imageReplacer=new U5,this.numberingReplacer=new yK}compile(B,U,G=[]){let Y=new h2.default,Q=this.xmlifyFile(B,U),K=new Map(Object.entries(Q));for(let[,Z]of K)if(Array.isArray(Z))for(let J of Z)Y.file(J.path,U1(J.data));else Y.file(Z.path,U1(Z.data));for(let Z of G)Y.file(Z.path,U1(Z.data));for(let Z of B.Media.Array)if(Z.type!=="svg")Y.file(`word/media/${Z.fileName}`,Z.data);else Y.file(`word/media/${Z.fileName}`,Z.data),Y.file(`word/media/${Z.fallback.fileName}`,Z.fallback.data);for(let[Z,{data:J,fontKey:M}]of B.FontTable.fontOptionsWithKey.entries())Y.file(`word/fonts/font${Z+1}.odttf`,vK(J,M));return Y}xmlifyFile(B,U){let G=B.Document.Relationships.RelationshipCount+1,Y=(0,w0.default)(this.formatter.format(B.Document.View,{viewWrapper:B.Document,file:B,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),Q=B.Comments.Relationships.RelationshipCount+1,K=(0,w0.default)(this.formatter.format(B.Comments,{viewWrapper:{View:B.Comments,Relationships:B.Comments.Relationships},file:B,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),Z=B.FootNotes.Relationships.RelationshipCount+1,J=(0,w0.default)(this.formatter.format(B.FootNotes.View,{viewWrapper:B.FootNotes,file:B,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),M=this.imageReplacer.getMediaData(Y,B.Media),W=this.imageReplacer.getMediaData(K,B.Media),I=this.imageReplacer.getMediaData(J,B.Media);return L0(L0({Relationships:{data:(()=>{return M.forEach((F,D)=>{B.Document.Relationships.addRelationship(G+D,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`media/${F.fileName}`)}),B.Document.Relationships.addRelationship(B.Document.Relationships.RelationshipCount+1,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable","fontTable.xml"),(0,w0.default)(this.formatter.format(B.Document.Relationships,{viewWrapper:B.Document,file:B,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}})})(),path:"word/_rels/document.xml.rels"},Document:{data:(()=>{let F=this.imageReplacer.replace(Y,M,G);return this.numberingReplacer.replace(F,B.Numbering.ConcreteNumbering)})(),path:"word/document.xml"},Styles:{data:(()=>{let F=(0,w0.default)(this.formatter.format(B.Styles,{viewWrapper:B.Document,file:B,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}});return this.numberingReplacer.replace(F,B.Numbering.ConcreteNumbering)})(),path:"word/styles.xml"},Properties:{data:(0,w0.default)(this.formatter.format(B.CoreProperties,{viewWrapper:B.Document,file:B,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"docProps/core.xml"},Numbering:{data:(0,w0.default)(this.formatter.format(B.Numbering,{viewWrapper:B.Document,file:B,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"word/numbering.xml"},FileRelationships:{data:(0,w0.default)(this.formatter.format(B.FileRelationships,{viewWrapper:B.Document,file:B,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),path:"_rels/.rels"},HeaderRelationships:B.Headers.map((F,D)=>{let w=(0,w0.default)(this.formatter.format(F.View,{viewWrapper:F,file:B,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}});return this.imageReplacer.getMediaData(w,B.Media).forEach((P,A)=>{F.Relationships.addRelationship(A,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`media/${P.fileName}`)}),{data:(0,w0.default)(this.formatter.format(F.Relationships,{viewWrapper:F,file:B,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),path:`word/_rels/header${D+1}.xml.rels`}}),FooterRelationships:B.Footers.map((F,D)=>{let w=(0,w0.default)(this.formatter.format(F.View,{viewWrapper:F,file:B,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}});return this.imageReplacer.getMediaData(w,B.Media).forEach((P,A)=>{F.Relationships.addRelationship(A,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`media/${P.fileName}`)}),{data:(0,w0.default)(this.formatter.format(F.Relationships,{viewWrapper:F,file:B,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),path:`word/_rels/footer${D+1}.xml.rels`}}),Headers:B.Headers.map((F,D)=>{let w=(0,w0.default)(this.formatter.format(F.View,{viewWrapper:F,file:B,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),P=this.imageReplacer.getMediaData(w,B.Media),A=this.imageReplacer.replace(w,P,0);return{data:this.numberingReplacer.replace(A,B.Numbering.ConcreteNumbering),path:`word/header${D+1}.xml`}}),Footers:B.Footers.map((F,D)=>{let w=(0,w0.default)(this.formatter.format(F.View,{viewWrapper:F,file:B,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),P=this.imageReplacer.getMediaData(w,B.Media),A=this.imageReplacer.replace(w,P,0);return{data:this.numberingReplacer.replace(A,B.Numbering.ConcreteNumbering),path:`word/footer${D+1}.xml`}}),ContentTypes:{data:(0,w0.default)(this.formatter.format(B.ContentTypes,{viewWrapper:B.Document,file:B,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),path:"[Content_Types].xml"},CustomProperties:{data:(0,w0.default)(this.formatter.format(B.CustomProperties,{viewWrapper:B.Document,file:B,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"docProps/custom.xml"},AppProperties:{data:(0,w0.default)(this.formatter.format(B.AppProperties,{viewWrapper:B.Document,file:B,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"docProps/app.xml"},FootNotes:{data:(()=>{let F=this.imageReplacer.replace(J,I,Z);return this.numberingReplacer.replace(F,B.Numbering.ConcreteNumbering)})(),path:"word/footnotes.xml"},FootNotesRelationships:{data:(()=>{return I.forEach((F,D)=>{B.FootNotes.Relationships.addRelationship(Z+D,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`media/${F.fileName}`)}),(0,w0.default)(this.formatter.format(B.FootNotes.Relationships,{viewWrapper:B.FootNotes,file:B,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}})})(),path:"word/_rels/footnotes.xml.rels"},Endnotes:{data:(0,w0.default)(this.formatter.format(B.Endnotes.View,{viewWrapper:B.Endnotes,file:B,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),path:"word/endnotes.xml"},EndnotesRelationships:{data:(0,w0.default)(this.formatter.format(B.Endnotes.Relationships,{viewWrapper:B.Endnotes,file:B,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),path:"word/_rels/endnotes.xml.rels"},Settings:{data:(0,w0.default)(this.formatter.format(B.Settings,{viewWrapper:B.Document,file:B,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"word/settings.xml"},Comments:{data:(()=>{let F=this.imageReplacer.replace(K,W,Q);return this.numberingReplacer.replace(F,B.Numbering.ConcreteNumbering)})(),path:"word/comments.xml"},CommentsRelationships:{data:(()=>{return W.forEach((F,D)=>{B.Comments.Relationships.addRelationship(Q+D,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`media/${F.fileName}`)}),(0,w0.default)(this.formatter.format(B.Comments.Relationships,{viewWrapper:{View:B.Comments,Relationships:B.Comments.Relationships},file:B,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}})})(),path:"word/_rels/comments.xml.rels"}},B.CommentsExtended?{CommentsExtended:{data:(0,w0.default)(this.formatter.format(B.CommentsExtended,{viewWrapper:{View:B.CommentsExtended,Relationships:B.Comments.Relationships},file:B,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"word/commentsExtended.xml"}}:{}),{},{FontTable:{data:(0,w0.default)(this.formatter.format(B.FontTable.View,{viewWrapper:B.Document,file:B,stack:[]}),{indent:U,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"word/fontTable.xml"},FontTableRelationships:{data:(0,w0.default)(this.formatter.format(B.FontTable.Relationships,{viewWrapper:B.Document,file:B,stack:[]}),{indent:U,declaration:{encoding:"UTF-8"}}),path:"word/_rels/fontTable.xml.rels"}})}};function t6(B,U,G,Y,Q,K,Z){try{var J=B[K](Z),M=J.value}catch(W){G(W);return}J.done?U(M):Promise.resolve(M).then(Y,Q)}function M6(B){return function(){var U=this,G=arguments;return new Promise(function(Y,Q){var K=B.apply(U,G);function Z(M){t6(K,Y,Q,Z,J,"next",M)}function J(M){t6(K,Y,Q,Z,J,"throw",M)}Z(void 0)})}}var G5={NONE:"",WITH_2_BLANKS:" ",WITH_4_BLANKS:" ",WITH_TAB:"\t"},e6=(B)=>B===!0?G5.WITH_2_BLANKS:B===!1?void 0:B,Y5=class B{static pack(U,G,Y){var Q=this;return M6(function*(K,Z,J,M=[]){return Q.compiler.compile(K,e6(J),M).generateAsync({type:Z,mimeType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",compression:"DEFLATE"})}).apply(this,arguments)}static toString(U,G,Y=[]){return B.pack(U,"string",G,Y)}static toBuffer(U,G,Y=[]){return B.pack(U,"nodebuffer",G,Y)}static toBase64String(U,G,Y=[]){return B.pack(U,"base64",G,Y)}static toBlob(U,G,Y=[]){return B.pack(U,"blob",G,Y)}static toArrayBuffer(U,G,Y=[]){return B.pack(U,"arraybuffer",G,Y)}static toStream(U,G,Y=[]){let Q=new SK.Stream;return this.compiler.compile(U,e6(G),Y).generateAsync({type:"nodebuffer",mimeType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",compression:"DEFLATE"}).then((K)=>{Q.emit("data",K),Q.emit("end")}),Q}};e(Y5,"compiler",new gK);var fK=new q6,l1=(B)=>{return(0,_1.xml2js)(B,{compact:!1,captureSpacesBetweenElements:!0})},Z5=(B)=>{var U;return(U=l1((0,w0.default)(fK.format(new Z1({text:B})))).elements[0].elements)!==null&&U!==void 0?U:[]},Q5=(B)=>L0(L0({},B),{},{attributes:{"xml:space":"preserve"}}),X6=(B,U)=>{var G,Y;return(G=(Y=B.elements)===null||Y===void 0?void 0:Y.filter((Q)=>Q.name===U)[0].elements)!==null&&G!==void 0?G:[]},g2=(B,U,G)=>{let Y=X6(B,"Types");if(Y.some((Q)=>{var K,Z;return Q.type==="element"&&Q.name==="Default"&&(Q===null||Q===void 0||(K=Q.attributes)===null||K===void 0?void 0:K.ContentType)===U&&(Q===null||Q===void 0||(Z=Q.attributes)===null||Z===void 0?void 0:Z.Extension)===G}))return;Y.push({attributes:{ContentType:U,Extension:G},name:"Default",type:"element"})},xK=(B)=>{let U=parseInt(B.substring(3),10);return isNaN(U)?0:U},_K=(B)=>{return X6(B,"Relationships").map((U)=>{var G,Y;return xK((G=(Y=U.attributes)===null||Y===void 0||(Y=Y.Id)===null||Y===void 0?void 0:Y.toString())!==null&&G!==void 0?G:"")}).reduce((U,G)=>Math.max(U,G),0)+1},BB=(B,U,G,Y,Q)=>{let K=X6(B,"Relationships");return K.push({attributes:{Id:`rId${U}`,Type:G,Target:Y,TargetMode:Q},name:"Relationship",type:"element"}),K},hK=class extends Error{constructor(B){super(`Token ${B} not found`);this.name="TokenNotFoundError"}},uK=(B,U)=>{var G;for(let Z=0;Z<((G=B.elements)!==null&&G!==void 0?G:[]).length;Z++){let J=B.elements[Z];if(J.type==="element"&&J.name==="w:r"){var Y;let M=((Y=J.elements)!==null&&Y!==void 0?Y:[]).filter((W)=>W.type==="element"&&W.name==="w:t");for(let W of M){var Q,K;if(!((Q=W.elements)===null||Q===void 0?void 0:Q[0]))continue;if((K=W.elements[0].text)===null||K===void 0?void 0:K.includes(U))return Z}}}throw new hK(U)},dK=(B,U)=>{var G,Y;let Q=-1,K=(G=(Y=B.elements)===null||Y===void 0?void 0:Y.map((Z,J)=>{if(Q!==-1)return Z;if(Z.type==="element"&&Z.name==="w:t"){var M,W;let I=((M=(W=Z.elements)===null||W===void 0||(W=W[0])===null||W===void 0?void 0:W.text)!==null&&M!==void 0?M:"").split(U),F=I.map((D)=>L0(L0(L0({},Z),Q5(Z)),{},{elements:Z5(D)}));if(I.length>1)Q=J;return F}else return Z}).flat())!==null&&G!==void 0?G:[];return{left:L0(L0({},JSON.parse(JSON.stringify(B))),{},{elements:K.slice(0,Q+1)}),right:L0(L0({},JSON.parse(JSON.stringify(B))),{},{elements:K.slice(Q+1)})}},t2={START:0,MIDDLE:1,END:2},cK=({paragraphElement:B,renderedParagraph:U,originalText:G,replacementText:Y})=>{let Q=U.text.indexOf(G),K=Q+G.length-1,Z=t2.START;for(let J of U.runs)for(let{text:M,index:W,start:I,end:F}of J.parts)switch(Z){case t2.START:if(Q>=I&&Q<=F){let D=Q-I,w=Math.min(K,F)-I,P=J.text.substring(D,w+1);if(P==="")continue;let A=M.replace(P,Y);R8(B.elements[J.index].elements[W],A),Z=t2.MIDDLE;continue}break;case t2.MIDDLE:if(K<=F){let D=M.substring(K-I+1);R8(B.elements[J.index].elements[W],D);let w=B.elements[J.index].elements[W];B.elements[J.index].elements[W]=Q5(w),Z=t2.END}else R8(B.elements[J.index].elements[W],"");break;default:}return B},R8=(B,U)=>{return B.elements=Z5(U),B},mK=(B)=>{if(B.element.name!=="w:p")throw Error(`Invalid node type: ${B.element.name}`);if(!B.element.elements)return{text:"",runs:[],index:-1,pathToParagraph:[]};let U=0,G=B.element.elements.map((Y,Q)=>({element:Y,i:Q})).filter(({element:Y})=>Y.name==="w:r").map(({element:Y,i:Q})=>{let K=lK(Y,Q,U);return U+=K.text.length,K}).filter((Y)=>!!Y);return{text:G.reduce((Y,Q)=>Y+Q.text,""),runs:G,index:B.index,pathToParagraph:J5(B)}},lK=(B,U,G)=>{if(!B.elements)return{text:"",parts:[],index:-1,start:G,end:G};let Y=G,Q=B.elements.map((K,Z)=>{var J,M;return K.name==="w:t"&&K.elements&&K.elements.length>0?{text:(J=(M=K.elements[0].text)===null||M===void 0?void 0:M.toString())!==null&&J!==void 0?J:"",index:Z,start:Y,end:(()=>{var W,I;return Y+=((W=(I=K.elements[0].text)===null||I===void 0?void 0:I.toString())!==null&&W!==void 0?W:"").length-1,Y})()}:void 0}).filter((K)=>!!K).map((K)=>K);return{text:Q.reduce((K,Z)=>K+Z.text,""),parts:Q,index:U,start:G,end:Y}},J5=(B)=>B.parent?[...J5(B.parent),B.index]:[B.index],UB=(B)=>{var U,G;return(U=(G=B.element.elements)===null||G===void 0?void 0:G.map((Y,Q)=>({element:Y,index:Q,parent:B})))!==null&&U!==void 0?U:[]},K5=(B)=>{let U=[],G=[...UB({element:B,index:0,parent:void 0})],Y;while(G.length>0){if(Y=G.shift(),Y.element.name==="w:p")U=[...U,mK(Y)];G.push(...UB(Y))}return U},aK=(B,U)=>K5(B).filter((G)=>G.text.includes(U)),pK=new q6,L8="ɵ",rK=({json:B,patch:U,patchText:G,context:Y,keepOriginalStyles:Q=!0})=>{let K=aK(B,G);if(K.length===0)return{element:B,didFindOccurrence:!1};for(let Z of K){let J=U.children.map((M)=>l1((0,w0.default)(pK.format(M,Y)))).map((M)=>M.elements[0]);switch(U.type){case D8.DOCUMENT:{let M=iK(B,Z.pathToParagraph),W=nK(Z.pathToParagraph);M.elements.splice(W,1,...J);break}case D8.PARAGRAPH:default:{let M=V5(B,Z.pathToParagraph);cK({paragraphElement:M,renderedParagraph:Z,originalText:G,replacementText:L8});let W=uK(M,L8),I=M.elements[W],{left:F,right:D}=dK(I,L8),w=J,P=D;if(Q){let A=I.elements.filter((E)=>E.type==="element"&&E.name==="w:rPr");w=J.map((E)=>{var C;return L0(L0({},E),{},{elements:[...A,...(C=E.elements)!==null&&C!==void 0?C:[]]})}),P=L0(L0({},D),{},{elements:[...A,...D.elements]})}M.elements.splice(W,1,F,...w,P);break}}}return{element:B,didFindOccurrence:!0}},V5=(B,U)=>{let G=B;for(let Y=1;YV5(B,U.slice(0,U.length-1)),nK=(B)=>B[B.length-1],D8={DOCUMENT:"file",PARAGRAPH:"paragraph"},GB=new U5,sK=new Uint8Array([255,254]),oK=new Uint8Array([254,255]),YB=(B,U)=>{if(B.length!==U.length)return!1;for(let G=0;GN.name==="w:document");if(x&&x.attributes){for(let N of["mc","wp","r","w15","m"])x.attributes[`xmlns:${N}`]=v1[N];x.attributes["mc:Ignorable"]=`${x.attributes["mc:Ignorable"]||""} w15`.trim()}}if(v.startsWith("word/")&&!v.endsWith(".xml.rels")){let x={file:W,viewWrapper:{Relationships:{addRelationship:(b,c,T,m)=>{D.push({key:v,hyperlink:{id:b,link:T}})}}},stack:[]};if(M.set(v,x),!(K===null||K===void 0?void 0:K.start.trim())||!(K===null||K===void 0?void 0:K.end.trim()))throw Error("Both start and end delimiters must be non-empty strings.");let{start:N,end:a}=K;for(let[b,c]of Object.entries(Y)){let T=`${N}${b}${a}`;while(!0){let{didFindOccurrence:m}=rK({json:$,patch:L0(L0({},c),{},{children:c.children.map((B0)=>{if(B0 instanceof o8){let i=new m2(B0.options.children,O1());return D.push({key:v,hyperlink:{id:i.linkId,link:B0.options.link}}),i}else return B0})}),patchText:T,context:x,keepOriginalStyles:Q});if(!Z||!m)break}}let U0=GB.getMediaData(JSON.stringify($),x.file.Media);if(U0.length>0)w=!0,F.push({key:v,mediaDatas:U0})}I.set(v,$)}for(let{key:v,mediaDatas:S}of F){var E;let H=`word/_rels/${v.split("/").pop()}.rels`,X=(E=I.get(H))!==null&&E!==void 0?E:ZB();I.set(H,X);let $=_K(X),x=GB.replace(JSON.stringify(I.get(v)),S,$);I.set(v,JSON.parse(x));for(let N=0;N{return(0,_1.js2xml)(B,{attributeValueFn:(U)=>String(U).replace(/&(?!amp;|lt;|gt;|quot;|apos;)/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")})},ZB=()=>({declaration:{attributes:{version:"1.0",encoding:"UTF-8",standalone:"yes"}},elements:[{type:"element",name:"Relationships",attributes:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},elements:[]}]}),B7=function(){var B=M6(function*({data:U}){let G=U instanceof h2.default?U:yield h2.default.loadAsync(U),Y=new Set;for(let[Q,K]of Object.entries(G.files)){if(!Q.endsWith(".xml")&&!Q.endsWith(".rels"))continue;if(Q.startsWith("word/")&&!Q.endsWith(".xml.rels"))K5(l1(yield K.async("text"))).forEach((Z)=>U7(Z.text).forEach((J)=>Y.add(J)))}return Array.from(Y)});return function(G){return B.apply(this,arguments)}}(),U7=(B)=>{var U;let G=new RegExp("(?<=\\{\\{).+?(?=\\}\\})","gs");return(U=B.match(G))!==null&&U!==void 0?U:[]};if(typeof globalThis.Buffer>"u")globalThis.Buffer=J0;if(typeof globalThis.process>"u")globalThis.process=G7;globalThis.__bundles=globalThis.__bundles||{};globalThis.__bundles.docx=R6;})(); diff --git a/apps/sim/lib/execution/sandbox/bundles/pdf-lib.cjs b/apps/sim/lib/execution/sandbox/bundles/pdf-lib.cjs index f56f8e9699a..78b81395b66 100644 --- a/apps/sim/lib/execution/sandbox/bundles/pdf-lib.cjs +++ b/apps/sim/lib/execution/sandbox/bundles/pdf-lib.cjs @@ -1,7 +1,7 @@ // sandbox bundle: pdf-lib // generated by apps/sim/lib/execution/sandbox/bundles/build.ts // do not edit by hand. run `bun run build:sandbox-bundles` to regenerate. -(()=>{var dK=Object.create;var{getPrototypeOf:nK,defineProperty:fq,getOwnPropertyNames:rK}=Object;var iK=Object.prototype.hasOwnProperty;function aK(q){return this[q]}var oK,sK,$8=(q,X,V)=>{var K=q!=null&&typeof q==="object";if(K){var Q=X?oK??=new WeakMap:sK??=new WeakMap,Y=Q.get(q);if(Y)return Y}V=q!=null?dK(nK(q)):{};let J=X||!q||!q.__esModule?fq(V,"default",{value:q,enumerable:!0}):V;for(let G of rK(q))if(!iK.call(J,G))fq(J,G,{get:aK.bind(q,G),enumerable:!0});if(K)Q.set(q,J);return J};var g0=(q,X)=>()=>(X||q((X={exports:{}}).exports,X),X.exports);var tK=(q)=>q;function eK(q,X){this[q]=tK.bind(null,X)}var qQ=(q,X)=>{for(var V in X)fq(q,V,{get:X[V],enumerable:!0,configurable:!0,set:eK.bind(X,V)})};var gX=g0((b3,uX)=>{var A0=uX.exports={},F2,P2;function sq(){throw Error("setTimeout has not been defined")}function tq(){throw Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function")F2=setTimeout;else F2=sq}catch(q){F2=sq}try{if(typeof clearTimeout==="function")P2=clearTimeout;else P2=tq}catch(q){P2=tq}})();function FX(q){if(F2===setTimeout)return setTimeout(q,0);if((F2===sq||!F2)&&setTimeout)return F2=setTimeout,setTimeout(q,0);try{return F2(q,0)}catch(X){try{return F2.call(null,q,0)}catch(V){return F2.call(this,q,0)}}}function FQ(q){if(P2===clearTimeout)return clearTimeout(q);if((P2===tq||!P2)&&clearTimeout)return P2=clearTimeout,clearTimeout(q);try{return P2(q)}catch(X){try{return P2.call(null,q)}catch(V){return P2.call(this,q)}}}var o2=[],$5=!1,d6,h1=-1;function PQ(){if(!$5||!d6)return;if($5=!1,d6.length)o2=d6.concat(o2);else h1=-1;if(o2.length)PX()}function PX(){if($5)return;var q=FX(PQ);$5=!0;var X=o2.length;while(X){d6=o2,o2=[];while(++h11)for(var V=1;V{var _Q=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function cQ(q,X){return Object.prototype.hasOwnProperty.call(q,X)}r0.assign=function(q){var X=Array.prototype.slice.call(arguments,1);while(X.length){var V=X.shift();if(!V)continue;if(typeof V!=="object")throw TypeError(V+"must be non-object");for(var K in V)if(cQ(V,K))q[K]=V[K]}return q};r0.shrinkBuf=function(q,X){if(q.length===X)return q;if(q.subarray)return q.subarray(0,X);return q.length=X,q};var pQ={arraySet:function(q,X,V,K,Q){if(X.subarray&&q.subarray){q.set(X.subarray(V,V+K),Q);return}for(var Y=0;Y{var nQ=t2(),rQ=4,pX=0,dX=1,iQ=2;function u5(q){var X=q.length;while(--X>=0)q[X]=0}var aQ=0,sX=1,oQ=2,sQ=3,tQ=258,N4=29,p8=256,f8=p8+1+N4,D5=30,S4=19,tX=2*f8+1,i6=15,T4=16,eQ=7,y4=256,eX=16,qV=17,XV=18,w4=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],g1=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],qY=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],VV=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],XY=512,e2=Array((f8+2)*2);u5(e2);var m8=Array(D5*2);u5(m8);var l8=Array(XY);u5(l8);var _8=Array(tQ-sQ+1);u5(_8);var $4=Array(N4);u5($4);var x1=Array(D5);u5(x1);function v4(q,X,V,K,Q){this.static_tree=q,this.extra_bits=X,this.extra_base=V,this.elems=K,this.max_length=Q,this.has_stree=q&&q.length}var KV,QV,YV;function R4(q,X){this.dyn_tree=q,this.max_code=0,this.stat_desc=X}function JV(q){return q<256?l8[q]:l8[256+(q>>>7)]}function c8(q,X){q.pending_buf[q.pending++]=X&255,q.pending_buf[q.pending++]=X>>>8&255}function q2(q,X,V){if(q.bi_valid>T4-V)q.bi_buf|=X<>T4-q.bi_valid,q.bi_valid+=V-T4;else q.bi_buf|=X<>>=1,V<<=1;while(--X>0);return V>>>1}function VY(q){if(q.bi_valid===16)c8(q,q.bi_buf),q.bi_buf=0,q.bi_valid=0;else if(q.bi_valid>=8)q.pending_buf[q.pending++]=q.bi_buf&255,q.bi_buf>>=8,q.bi_valid-=8}function KY(q,X){var{dyn_tree:V,max_code:K}=X,Q=X.stat_desc.static_tree,Y=X.stat_desc.has_stree,J=X.stat_desc.extra_bits,G=X.stat_desc.extra_base,W=X.stat_desc.max_length,Z,H,U,z,k,M,j=0;for(z=0;z<=i6;z++)q.bl_count[z]=0;V[q.heap[q.heap_max]*2+1]=0;for(Z=q.heap_max+1;ZW)z=W,j++;if(V[H*2+1]=z,H>K)continue;if(q.bl_count[z]++,k=0,H>=G)k=J[H-G];if(M=V[H*2],q.opt_len+=M*(z+k),Y)q.static_len+=M*(Q[H*2+1]+k)}if(j===0)return;do{z=W-1;while(q.bl_count[z]===0)z--;q.bl_count[z]--,q.bl_count[z+1]+=2,q.bl_count[W]--,j-=2}while(j>0);for(z=W;z!==0;z--){H=q.bl_count[z];while(H!==0){if(U=q.heap[--Z],U>K)continue;if(V[U*2+1]!==z)q.opt_len+=(z-V[U*2+1])*V[U*2],V[U*2+1]=z;H--}}}function ZV(q,X,V){var K=Array(i6+1),Q=0,Y,J;for(Y=1;Y<=i6;Y++)K[Y]=Q=Q+V[Y-1]<<1;for(J=0;J<=X;J++){var G=q[J*2+1];if(G===0)continue;q[J*2]=GV(K[G]++,G)}}function QY(){var q,X,V,K,Q,Y=Array(i6+1);V=0;for(K=0;K>=7;for(;K8)c8(q,q.bi_buf);else if(q.bi_valid>0)q.pending_buf[q.pending++]=q.bi_buf;q.bi_buf=0,q.bi_valid=0}function YY(q,X,V,K){if(HV(q),K)c8(q,V),c8(q,~V);nQ.arraySet(q.pending_buf,q.window,X,V,q.pending),q.pending+=V}function nX(q,X,V,K){var Q=X*2,Y=V*2;return q[Q]>1;J>=1;J--)O4(q,V,J);Z=Y;do J=q.heap[1],q.heap[1]=q.heap[q.heap_len--],O4(q,V,1),G=q.heap[1],q.heap[--q.heap_max]=J,q.heap[--q.heap_max]=G,V[Z*2]=V[J*2]+V[G*2],q.depth[Z]=(q.depth[J]>=q.depth[G]?q.depth[J]:q.depth[G])+1,V[J*2+1]=V[G*2+1]=Z,q.heap[1]=Z++,O4(q,V,1);while(q.heap_len>=2);q.heap[--q.heap_max]=q.heap[1],KY(q,X),ZV(V,W,q.bl_count)}function iX(q,X,V){var K,Q=-1,Y,J=X[1],G=0,W=7,Z=4;if(J===0)W=138,Z=3;X[(V+1)*2+1]=65535;for(K=0;K<=V;K++){if(Y=J,J=X[(K+1)*2+1],++G=3;X--)if(q.bl_tree[VV[X]*2+1]!==0)break;return q.opt_len+=3*(X+1)+5+5+4,X}function GY(q,X,V,K){var Q;q2(q,X-257,5),q2(q,V-1,5),q2(q,K-4,4);for(Q=0;Q>>=1)if(X&1&&q.dyn_ltree[V*2]!==0)return pX;if(q.dyn_ltree[18]!==0||q.dyn_ltree[20]!==0||q.dyn_ltree[26]!==0)return dX;for(V=32;V0){if(q.strm.data_type===iQ)q.strm.data_type=ZY(q);if(A4(q,q.l_desc),A4(q,q.d_desc),J=JY(q),Q=q.opt_len+3+7>>>3,Y=q.static_len+3+7>>>3,Y<=Q)Q=Y}else Q=Y=V+5;if(V+4<=Q&&X!==-1)UV(q,X,V,K);else if(q.strategy===rQ||Y===Q)q2(q,(sX<<1)+(K?1:0),3),rX(q,e2,m8);else q2(q,(oQ<<1)+(K?1:0),3),GY(q,q.l_desc.max_code+1,q.d_desc.max_code+1,J+1),rX(q,q.dyn_ltree,q.dyn_dtree);if(WV(q),K)HV(q)}function zY(q,X,V){if(q.pending_buf[q.d_buf+q.last_lit*2]=X>>>8&255,q.pending_buf[q.d_buf+q.last_lit*2+1]=X&255,q.pending_buf[q.l_buf+q.last_lit]=V&255,q.last_lit++,X===0)q.dyn_ltree[V*2]++;else q.matches++,X--,q.dyn_ltree[(_8[V]+p8+1)*2]++,q.dyn_dtree[JV(X)*2]++;return q.last_lit===q.lit_bufsize-1}g5._tr_init=WY;g5._tr_stored_block=UV;g5._tr_flush_block=UY;g5._tr_tally=zY;g5._tr_align=HY});var C4=g0((t3,MV)=>{function MY(q,X,V,K){var Q=q&65535|0,Y=q>>>16&65535|0,J=0;while(V!==0){J=V>2000?2000:V,V-=J;do Q=Q+X[K++]|0,Y=Y+Q|0;while(--J);Q%=65521,Y%=65521}return Q|Y<<16|0}MV.exports=MY});var h4=g0((e3,kV)=>{function kY(){var q,X=[];for(var V=0;V<256;V++){q=V;for(var K=0;K<8;K++)q=q&1?3988292384^q>>>1:q>>>1;X[V]=q}return X}var IY=kY();function EY(q,X,V,K){var Q=IY,Y=K+V;q^=-1;for(var J=K;J>>8^Q[(q^X[J])&255];return q^-1}kV.exports=EY});var b1=g0((qW,IV)=>{IV.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var wV=g0((m2)=>{var i0=t2(),H2=zV(),BV=C4(),B6=h4(),jY=b1(),t6=0,LY=1,BY=3,w6=4,EV=5,b2=0,jV=1,U2=-2,TY=-3,F4=-5,vY=-1,RY=1,m1=2,OY=3,wY=4,AY=0,NY=2,c1=8,SY=9,yY=15,$Y=8,CY=29,hY=256,D4=hY+1+CY,FY=30,PY=19,DY=2*D4+1,uY=15,H0=3,R6=258,O2=R6+H0+1,gY=32,p1=42,u4=69,f1=73,l1=91,_1=103,a6=113,n8=666,h0=1,r8=2,o6=3,m5=4,xY=3;function O6(q,X){return q.msg=jY[X],X}function LV(q){return(q<<1)-(q>4?9:0)}function v6(q){var X=q.length;while(--X>=0)q[X]=0}function T6(q){var X=q.state,V=X.pending;if(V>q.avail_out)V=q.avail_out;if(V===0)return;if(i0.arraySet(q.output,X.pending_buf,X.pending_out,V,q.next_out),q.next_out+=V,X.pending_out+=V,q.total_out+=V,q.avail_out-=V,X.pending-=V,X.pending===0)X.pending_out=0}function x0(q,X){H2._tr_flush_block(q,q.block_start>=0?q.block_start:-1,q.strstart-q.block_start,X),q.block_start=q.strstart,T6(q.strm)}function U0(q,X){q.pending_buf[q.pending++]=X}function d8(q,X){q.pending_buf[q.pending++]=X>>>8&255,q.pending_buf[q.pending++]=X&255}function bY(q,X,V,K){var Q=q.avail_in;if(Q>K)Q=K;if(Q===0)return 0;if(q.avail_in-=Q,i0.arraySet(X,q.input,q.next_in,Q,V),q.state.wrap===1)q.adler=BV(q.adler,X,Q,V);else if(q.state.wrap===2)q.adler=B6(q.adler,X,Q,V);return q.next_in+=Q,q.total_in+=Q,Q}function TV(q,X){var{max_chain_length:V,strstart:K}=q,Q,Y,J=q.prev_length,G=q.nice_match,W=q.strstart>q.w_size-O2?q.strstart-(q.w_size-O2):0,Z=q.window,H=q.w_mask,U=q.prev,z=q.strstart+R6,k=Z[K+J-1],M=Z[K+J];if(q.prev_length>=q.good_match)V>>=2;if(G>q.lookahead)G=q.lookahead;do{if(Q=X,Z[Q+J]!==M||Z[Q+J-1]!==k||Z[Q]!==Z[K]||Z[++Q]!==Z[K+1])continue;K+=2,Q++;do;while(Z[++K]===Z[++Q]&&Z[++K]===Z[++Q]&&Z[++K]===Z[++Q]&&Z[++K]===Z[++Q]&&Z[++K]===Z[++Q]&&Z[++K]===Z[++Q]&&Z[++K]===Z[++Q]&&Z[++K]===Z[++Q]&&KJ){if(q.match_start=X,J=Y,Y>=G)break;k=Z[K+J-1],M=Z[K+J]}}while((X=U[X&H])>W&&--V!==0);if(J<=q.lookahead)return J;return q.lookahead}function s6(q){var X=q.w_size,V,K,Q,Y,J;do{if(Y=q.window_size-q.lookahead-q.strstart,q.strstart>=X+(X-O2)){i0.arraySet(q.window,q.window,X,X,0),q.match_start-=X,q.strstart-=X,q.block_start-=X,K=q.hash_size,V=K;do Q=q.head[--V],q.head[V]=Q>=X?Q-X:0;while(--K);K=X,V=K;do Q=q.prev[--V],q.prev[V]=Q>=X?Q-X:0;while(--K);Y+=X}if(q.strm.avail_in===0)break;if(K=bY(q.strm,q.window,q.strstart+q.lookahead,Y),q.lookahead+=K,q.lookahead+q.insert>=H0){J=q.strstart-q.insert,q.ins_h=q.window[J],q.ins_h=(q.ins_h<q.pending_buf_size-5)V=q.pending_buf_size-5;for(;;){if(q.lookahead<=1){if(s6(q),q.lookahead===0&&X===t6)return h0;if(q.lookahead===0)break}q.strstart+=q.lookahead,q.lookahead=0;var K=q.block_start+V;if(q.strstart===0||q.strstart>=K){if(q.lookahead=q.strstart-K,q.strstart=K,x0(q,!1),q.strm.avail_out===0)return h0}if(q.strstart-q.block_start>=q.w_size-O2){if(x0(q,!1),q.strm.avail_out===0)return h0}}if(q.insert=0,X===w6){if(x0(q,!0),q.strm.avail_out===0)return o6;return m5}if(q.strstart>q.block_start){if(x0(q,!1),q.strm.avail_out===0)return h0}return h0}function P4(q,X){var V,K;for(;;){if(q.lookahead=H0)q.ins_h=(q.ins_h<=H0)if(K=H2._tr_tally(q,q.strstart-q.match_start,q.match_length-H0),q.lookahead-=q.match_length,q.match_length<=q.max_lazy_match&&q.lookahead>=H0){q.match_length--;do q.strstart++,q.ins_h=(q.ins_h<=H0)q.ins_h=(q.ins_h<4096))q.match_length=H0-1}if(q.prev_length>=H0&&q.match_length<=q.prev_length){Q=q.strstart+q.lookahead-H0,K=H2._tr_tally(q,q.strstart-1-q.prev_match,q.prev_length-H0),q.lookahead-=q.prev_length-1,q.prev_length-=2;do if(++q.strstart<=Q)q.ins_h=(q.ins_h<=H0&&q.strstart>0){if(Q=q.strstart-1,K=J[Q],K===J[++Q]&&K===J[++Q]&&K===J[++Q]){Y=q.strstart+R6;do;while(K===J[++Q]&&K===J[++Q]&&K===J[++Q]&&K===J[++Q]&&K===J[++Q]&&K===J[++Q]&&K===J[++Q]&&K===J[++Q]&&Qq.lookahead)q.match_length=q.lookahead}}if(q.match_length>=H0)V=H2._tr_tally(q,1,q.match_length-H0),q.lookahead-=q.match_length,q.strstart+=q.match_length,q.match_length=0;else V=H2._tr_tally(q,0,q.window[q.strstart]),q.lookahead--,q.strstart++;if(V){if(x0(q,!1),q.strm.avail_out===0)return h0}}if(q.insert=0,X===w6){if(x0(q,!0),q.strm.avail_out===0)return o6;return m5}if(q.last_lit){if(x0(q,!1),q.strm.avail_out===0)return h0}return r8}function lY(q,X){var V;for(;;){if(q.lookahead===0){if(s6(q),q.lookahead===0){if(X===t6)return h0;break}}if(q.match_length=0,V=H2._tr_tally(q,0,q.window[q.strstart]),q.lookahead--,q.strstart++,V){if(x0(q,!1),q.strm.avail_out===0)return h0}}if(q.insert=0,X===w6){if(x0(q,!0),q.strm.avail_out===0)return o6;return m5}if(q.last_lit){if(x0(q,!1),q.strm.avail_out===0)return h0}return r8}function x2(q,X,V,K,Q){this.good_length=q,this.max_lazy=X,this.nice_length=V,this.max_chain=K,this.func=Q}var b5;b5=[new x2(0,0,0,0,mY),new x2(4,4,8,4,P4),new x2(4,5,16,8,P4),new x2(4,6,32,32,P4),new x2(4,4,16,16,x5),new x2(8,16,32,32,x5),new x2(8,16,128,128,x5),new x2(8,32,128,256,x5),new x2(32,128,258,1024,x5),new x2(32,258,258,4096,x5)];function _Y(q){q.window_size=2*q.w_size,v6(q.head),q.max_lazy_match=b5[q.level].max_lazy,q.good_match=b5[q.level].good_length,q.nice_match=b5[q.level].nice_length,q.max_chain_length=b5[q.level].max_chain,q.strstart=0,q.block_start=0,q.lookahead=0,q.insert=0,q.match_length=q.prev_length=H0-1,q.match_available=0,q.ins_h=0}function cY(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=c1,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i0.Buf16(DY*2),this.dyn_dtree=new i0.Buf16((2*FY+1)*2),this.bl_tree=new i0.Buf16((2*PY+1)*2),v6(this.dyn_ltree),v6(this.dyn_dtree),v6(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i0.Buf16(uY+1),this.heap=new i0.Buf16(2*D4+1),v6(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i0.Buf16(2*D4+1),v6(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function vV(q){var X;if(!q||!q.state)return O6(q,U2);if(q.total_in=q.total_out=0,q.data_type=NY,X=q.state,X.pending=0,X.pending_out=0,X.wrap<0)X.wrap=-X.wrap;return X.status=X.wrap?p1:a6,q.adler=X.wrap===2?0:1,X.last_flush=t6,H2._tr_init(X),b2}function RV(q){var X=vV(q);if(X===b2)_Y(q.state);return X}function pY(q,X){if(!q||!q.state)return U2;if(q.state.wrap!==2)return U2;return q.state.gzhead=X,b2}function OV(q,X,V,K,Q,Y){if(!q)return U2;var J=1;if(X===vY)X=6;if(K<0)J=0,K=-K;else if(K>15)J=2,K-=16;if(Q<1||Q>SY||V!==c1||K<8||K>15||X<0||X>9||Y<0||Y>wY)return O6(q,U2);if(K===8)K=9;var G=new cY;return q.state=G,G.strm=q,G.wrap=J,G.gzhead=null,G.w_bits=K,G.w_size=1<EV||X<0)return q?O6(q,U2):U2;if(K=q.state,!q.output||!q.input&&q.avail_in!==0||K.status===n8&&X!==w6)return O6(q,q.avail_out===0?F4:U2);if(K.strm=q,V=K.last_flush,K.last_flush=X,K.status===p1)if(K.wrap===2)if(q.adler=0,U0(K,31),U0(K,139),U0(K,8),!K.gzhead)U0(K,0),U0(K,0),U0(K,0),U0(K,0),U0(K,0),U0(K,K.level===9?2:K.strategy>=m1||K.level<2?4:0),U0(K,xY),K.status=a6;else{if(U0(K,(K.gzhead.text?1:0)+(K.gzhead.hcrc?2:0)+(!K.gzhead.extra?0:4)+(!K.gzhead.name?0:8)+(!K.gzhead.comment?0:16)),U0(K,K.gzhead.time&255),U0(K,K.gzhead.time>>8&255),U0(K,K.gzhead.time>>16&255),U0(K,K.gzhead.time>>24&255),U0(K,K.level===9?2:K.strategy>=m1||K.level<2?4:0),U0(K,K.gzhead.os&255),K.gzhead.extra&&K.gzhead.extra.length)U0(K,K.gzhead.extra.length&255),U0(K,K.gzhead.extra.length>>8&255);if(K.gzhead.hcrc)q.adler=B6(q.adler,K.pending_buf,K.pending,0);K.gzindex=0,K.status=u4}else{var J=c1+(K.w_bits-8<<4)<<8,G=-1;if(K.strategy>=m1||K.level<2)G=0;else if(K.level<6)G=1;else if(K.level===6)G=2;else G=3;if(J|=G<<6,K.strstart!==0)J|=gY;if(J+=31-J%31,K.status=a6,d8(K,J),K.strstart!==0)d8(K,q.adler>>>16),d8(K,q.adler&65535);q.adler=1}if(K.status===u4)if(K.gzhead.extra){Q=K.pending;while(K.gzindex<(K.gzhead.extra.length&65535)){if(K.pending===K.pending_buf_size){if(K.gzhead.hcrc&&K.pending>Q)q.adler=B6(q.adler,K.pending_buf,K.pending-Q,Q);if(T6(q),Q=K.pending,K.pending===K.pending_buf_size)break}U0(K,K.gzhead.extra[K.gzindex]&255),K.gzindex++}if(K.gzhead.hcrc&&K.pending>Q)q.adler=B6(q.adler,K.pending_buf,K.pending-Q,Q);if(K.gzindex===K.gzhead.extra.length)K.gzindex=0,K.status=f1}else K.status=f1;if(K.status===f1)if(K.gzhead.name){Q=K.pending;do{if(K.pending===K.pending_buf_size){if(K.gzhead.hcrc&&K.pending>Q)q.adler=B6(q.adler,K.pending_buf,K.pending-Q,Q);if(T6(q),Q=K.pending,K.pending===K.pending_buf_size){Y=1;break}}if(K.gzindexQ)q.adler=B6(q.adler,K.pending_buf,K.pending-Q,Q);if(Y===0)K.gzindex=0,K.status=l1}else K.status=l1;if(K.status===l1)if(K.gzhead.comment){Q=K.pending;do{if(K.pending===K.pending_buf_size){if(K.gzhead.hcrc&&K.pending>Q)q.adler=B6(q.adler,K.pending_buf,K.pending-Q,Q);if(T6(q),Q=K.pending,K.pending===K.pending_buf_size){Y=1;break}}if(K.gzindexQ)q.adler=B6(q.adler,K.pending_buf,K.pending-Q,Q);if(Y===0)K.status=_1}else K.status=_1;if(K.status===_1)if(K.gzhead.hcrc){if(K.pending+2>K.pending_buf_size)T6(q);if(K.pending+2<=K.pending_buf_size)U0(K,q.adler&255),U0(K,q.adler>>8&255),q.adler=0,K.status=a6}else K.status=a6;if(K.pending!==0){if(T6(q),q.avail_out===0)return K.last_flush=-1,b2}else if(q.avail_in===0&&LV(X)<=LV(V)&&X!==w6)return O6(q,F4);if(K.status===n8&&q.avail_in!==0)return O6(q,F4);if(q.avail_in!==0||K.lookahead!==0||X!==t6&&K.status!==n8){var W=K.strategy===m1?lY(K,X):K.strategy===OY?fY(K,X):b5[K.level].func(K,X);if(W===o6||W===m5)K.status=n8;if(W===h0||W===o6){if(q.avail_out===0)K.last_flush=-1;return b2}if(W===r8){if(X===LY)H2._tr_align(K);else if(X!==EV){if(H2._tr_stored_block(K,0,0,!1),X===BY){if(v6(K.head),K.lookahead===0)K.strstart=0,K.block_start=0,K.insert=0}}if(T6(q),q.avail_out===0)return K.last_flush=-1,b2}}if(X!==w6)return b2;if(K.wrap<=0)return jV;if(K.wrap===2)U0(K,q.adler&255),U0(K,q.adler>>8&255),U0(K,q.adler>>16&255),U0(K,q.adler>>24&255),U0(K,q.total_in&255),U0(K,q.total_in>>8&255),U0(K,q.total_in>>16&255),U0(K,q.total_in>>24&255);else d8(K,q.adler>>>16),d8(K,q.adler&65535);if(T6(q),K.wrap>0)K.wrap=-K.wrap;return K.pending!==0?b2:jV}function rY(q){var X;if(!q||!q.state)return U2;if(X=q.state.status,X!==p1&&X!==u4&&X!==f1&&X!==l1&&X!==_1&&X!==a6&&X!==n8)return O6(q,U2);return q.state=null,X===a6?O6(q,TY):b2}function iY(q,X){var V=X.length,K,Q,Y,J,G,W,Z,H;if(!q||!q.state)return U2;if(K=q.state,J=K.wrap,J===2||J===1&&K.status!==p1||K.lookahead)return U2;if(J===1)q.adler=BV(q.adler,X,V,0);if(K.wrap=0,V>=K.w_size){if(J===0)v6(K.head),K.strstart=0,K.block_start=0,K.insert=0;H=new i0.Buf8(K.w_size),i0.arraySet(H,X,V-K.w_size,K.w_size,0),X=H,V=K.w_size}G=q.avail_in,W=q.next_in,Z=q.input,q.avail_in=V,q.next_in=0,q.input=X,s6(K);while(K.lookahead>=H0){Q=K.strstart,Y=K.lookahead-(H0-1);do K.ins_h=(K.ins_h<{var d1=t2(),AV=!0,NV=!0;try{String.fromCharCode.apply(null,[0])}catch(q){AV=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(q){NV=!1}var i8=new d1.Buf8(256);for(f2=0;f2<256;f2++)i8[f2]=f2>=252?6:f2>=248?5:f2>=240?4:f2>=224?3:f2>=192?2:1;var f2;i8[254]=i8[254]=1;f5.string2buf=function(q){var X,V,K,Q,Y,J=q.length,G=0;for(Q=0;Q>>6,X[Y++]=128|V&63;else if(V<65536)X[Y++]=224|V>>>12,X[Y++]=128|V>>>6&63,X[Y++]=128|V&63;else X[Y++]=240|V>>>18,X[Y++]=128|V>>>12&63,X[Y++]=128|V>>>6&63,X[Y++]=128|V&63}return X};function SV(q,X){if(X<65534){if(q.subarray&&NV||!q.subarray&&AV)return String.fromCharCode.apply(null,d1.shrinkBuf(q,X))}var V="";for(var K=0;K4){G[K++]=65533,V+=Y-1;continue}Q&=Y===2?31:Y===3?15:7;while(Y>1&&V1){G[K++]=65533;continue}if(Q<65536)G[K++]=Q;else Q-=65536,G[K++]=55296|Q>>10&1023,G[K++]=56320|Q&1023}return SV(G,K)};f5.utf8border=function(q,X){var V;if(X=X||q.length,X>q.length)X=q.length;V=X-1;while(V>=0&&(q[V]&192)===128)V--;if(V<0)return X;if(V===0)return X;return V+i8[q[V]]>X?V:X}});var x4=g0((KW,yV)=>{function aY(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}yV.exports=aY});var FV=g0((s8)=>{var a8=wV(),o8=t2(),m4=g4(),f4=b1(),oY=x4(),hV=Object.prototype.toString,sY=0,b4=4,l5=0,$V=1,CV=2,tY=-1,eY=0,qJ=8;function e6(q){if(!(this instanceof e6))return new e6(q);this.options=o8.assign({level:tY,method:qJ,chunkSize:16384,windowBits:15,memLevel:8,strategy:eY,to:""},q||{});var X=this.options;if(X.raw&&X.windowBits>0)X.windowBits=-X.windowBits;else if(X.gzip&&X.windowBits>0&&X.windowBits<16)X.windowBits+=16;this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new oY,this.strm.avail_out=0;var V=a8.deflateInit2(this.strm,X.level,X.method,X.windowBits,X.memLevel,X.strategy);if(V!==l5)throw Error(f4[V]);if(X.header)a8.deflateSetHeader(this.strm,X.header);if(X.dictionary){var K;if(typeof X.dictionary==="string")K=m4.string2buf(X.dictionary);else if(hV.call(X.dictionary)==="[object ArrayBuffer]")K=new Uint8Array(X.dictionary);else K=X.dictionary;if(V=a8.deflateSetDictionary(this.strm,K),V!==l5)throw Error(f4[V]);this._dict_set=!0}}e6.prototype.push=function(q,X){var V=this.strm,K=this.options.chunkSize,Q,Y;if(this.ended)return!1;if(Y=X===~~X?X:X===!0?b4:sY,typeof q==="string")V.input=m4.string2buf(q);else if(hV.call(q)==="[object ArrayBuffer]")V.input=new Uint8Array(q);else V.input=q;V.next_in=0,V.avail_in=V.input.length;do{if(V.avail_out===0)V.output=new o8.Buf8(K),V.next_out=0,V.avail_out=K;if(Q=a8.deflate(V,Y),Q!==$V&&Q!==l5)return this.onEnd(Q),this.ended=!0,!1;if(V.avail_out===0||V.avail_in===0&&(Y===b4||Y===CV))if(this.options.to==="string")this.onData(m4.buf2binstring(o8.shrinkBuf(V.output,V.next_out)));else this.onData(o8.shrinkBuf(V.output,V.next_out))}while((V.avail_in>0||V.avail_out===0)&&Q!==$V);if(Y===b4)return Q=a8.deflateEnd(this.strm),this.onEnd(Q),this.ended=!0,Q===l5;if(Y===CV)return this.onEnd(l5),V.avail_out=0,!0;return!0};e6.prototype.onData=function(q){this.chunks.push(q)};e6.prototype.onEnd=function(q){if(q===l5)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=o8.flattenChunks(this.chunks);this.chunks=[],this.err=q,this.msg=this.strm.msg};function l4(q,X){var V=new e6(X);if(V.push(q,!0),V.err)throw V.msg||f4[V.err];return V.result}function XJ(q,X){return X=X||{},X.raw=!0,l4(q,X)}function VJ(q,X){return X=X||{},X.gzip=!0,l4(q,X)}s8.Deflate=e6;s8.deflate=l4;s8.deflateRaw=XJ;s8.gzip=VJ});var DV=g0((YW,PV)=>{var n1=30,KJ=12;PV.exports=function(X,V){var K,Q,Y,J,G,W,Z,H,U,z,k,M,j,B,L,O,N,R,v,w,$,S,h,b,C;K=X.state,Q=X.next_in,b=X.input,Y=Q+(X.avail_in-5),J=X.next_out,C=X.output,G=J-(V-X.avail_out),W=J+(X.avail_out-257),Z=K.dmax,H=K.wsize,U=K.whave,z=K.wnext,k=K.window,M=K.hold,j=K.bits,B=K.lencode,L=K.distcode,O=(1<>>24,M>>>=v,j-=v,v=R>>>16&255,v===0)C[J++]=R&65535;else if(v&16){if(w=R&65535,v&=15,v){if(j>>=v,j-=v}if(j<15)M+=b[Q++]<>>24,M>>>=v,j-=v,v=R>>>16&255,v&16){if($=R&65535,v&=15,jZ){X.msg="invalid distance too far back",K.mode=n1;break q}if(M>>>=v,j-=v,v=J-G,$>v){if(v=$-v,v>U){if(K.sane){X.msg="invalid distance too far back",K.mode=n1;break q}}if(S=0,h=k,z===0){if(S+=H-v,v2)C[J++]=h[S++],C[J++]=h[S++],C[J++]=h[S++],w-=3;if(w){if(C[J++]=h[S++],w>1)C[J++]=h[S++]}}else{S=J-$;do C[J++]=C[S++],C[J++]=C[S++],C[J++]=C[S++],w-=3;while(w>2);if(w){if(C[J++]=C[S++],w>1)C[J++]=C[S++]}}}else if((v&64)===0){R=L[(R&65535)+(M&(1<>3,Q-=w,j-=w<<3,M&=(1<{var uV=t2(),_5=15,gV=852,xV=592,bV=0,_4=1,mV=2,QJ=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],YJ=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],JJ=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],GJ=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];fV.exports=function(X,V,K,Q,Y,J,G,W){var Z=W.bits,H=0,U=0,z=0,k=0,M=0,j=0,B=0,L=0,O=0,N=0,R,v,w,$,S,h=null,b=0,C,D=new uV.Buf16(_5+1),l=new uV.Buf16(_5+1),u=null,q0=0,J0,r,I0;for(H=0;H<=_5;H++)D[H]=0;for(U=0;U=1;k--)if(D[k]!==0)break;if(M>k)M=k;if(k===0)return Y[J++]=20971520,Y[J++]=20971520,W.bits=1,0;for(z=1;z0&&(X===bV||k!==1))return-1;l[1]=0;for(H=1;H<_5;H++)l[H+1]=l[H]+D[H];for(U=0;UgV||X===mV&&O>xV)return 1;for(;;){if(J0=H-B,G[U]C)r=u[q0+G[U]],I0=h[b+G[U]];else r=96,I0=0;R=1<>B)+v]=J0<<24|r<<16|I0|0;while(v!==0);R=1<>=1;if(R!==0)N&=R-1,N+=R;else N=0;if(U++,--D[H]===0){if(H===k)break;H=V[K+G[U]]}if(H>M&&(N&$)!==w){if(B===0)B=M;S+=z,j=H-B,L=1<gV||X===mV&&O>xV)return 1;w=N&$,Y[w]=M<<24|j<<16|S-J|0}}if(N!==0)Y[S+N]=H-B<<24|4194304|0;return W.bits=M,0}});var R9=g0((w2)=>{var Q2=t2(),i4=C4(),l2=h4(),ZJ=DV(),t8=lV(),WJ=0,M9=1,k9=2,_V=4,HJ=5,r1=6,q5=0,UJ=1,zJ=2,z2=-2,I9=-3,a4=-4,MJ=-5,cV=8,E9=1,pV=2,dV=3,nV=4,rV=5,iV=6,aV=7,oV=8,sV=9,tV=10,o1=11,q6=12,c4=13,eV=14,p4=15,q9=16,X9=17,V9=18,K9=19,i1=20,a1=21,Q9=22,Y9=23,J9=24,G9=25,Z9=26,d4=27,W9=28,H9=29,L0=30,o4=31,kJ=32,IJ=852,EJ=592,jJ=15,LJ=jJ;function U9(q){return(q>>>24&255)+(q>>>8&65280)+((q&65280)<<8)+((q&255)<<24)}function BJ(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Q2.Buf16(320),this.work=new Q2.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function j9(q){var X;if(!q||!q.state)return z2;if(X=q.state,q.total_in=q.total_out=X.total=0,q.msg="",X.wrap)q.adler=X.wrap&1;return X.mode=E9,X.last=0,X.havedict=0,X.dmax=32768,X.head=null,X.hold=0,X.bits=0,X.lencode=X.lendyn=new Q2.Buf32(IJ),X.distcode=X.distdyn=new Q2.Buf32(EJ),X.sane=1,X.back=-1,q5}function L9(q){var X;if(!q||!q.state)return z2;return X=q.state,X.wsize=0,X.whave=0,X.wnext=0,j9(q)}function B9(q,X){var V,K;if(!q||!q.state)return z2;if(K=q.state,X<0)V=0,X=-X;else if(V=(X>>4)+1,X<48)X&=15;if(X&&(X<8||X>15))return z2;if(K.window!==null&&K.wbits!==X)K.window=null;return K.wrap=V,K.wbits=X,L9(q)}function T9(q,X){var V,K;if(!q)return z2;if(K=new BJ,q.state=K,K.window=null,V=B9(q,X),V!==q5)q.state=null;return V}function TJ(q){return T9(q,LJ)}var z9=!0,n4,r4;function vJ(q){if(z9){var X;n4=new Q2.Buf32(512),r4=new Q2.Buf32(32),X=0;while(X<144)q.lens[X++]=8;while(X<256)q.lens[X++]=9;while(X<280)q.lens[X++]=7;while(X<288)q.lens[X++]=8;t8(M9,q.lens,0,288,n4,0,q.work,{bits:9}),X=0;while(X<32)q.lens[X++]=5;t8(k9,q.lens,0,32,r4,0,q.work,{bits:5}),z9=!1}q.lencode=n4,q.lenbits=9,q.distcode=r4,q.distbits=5}function v9(q,X,V,K){var Q,Y=q.state;if(Y.window===null)Y.wsize=1<=Y.wsize)Q2.arraySet(Y.window,X,V-Y.wsize,Y.wsize,0),Y.wnext=0,Y.whave=Y.wsize;else{if(Q=Y.wsize-Y.wnext,Q>K)Q=K;if(Q2.arraySet(Y.window,X,V-K,Q,Y.wnext),K-=Q,K)Q2.arraySet(Y.window,X,V-K,K,0),Y.wnext=K,Y.whave=Y.wsize;else{if(Y.wnext+=Q,Y.wnext===Y.wsize)Y.wnext=0;if(Y.whave>>8&255,V.check=l2(V.check,h,2,0),Z=0,H=0,V.mode=pV;break}if(V.flags=0,V.head)V.head.done=!1;if(!(V.wrap&1)||(((Z&255)<<8)+(Z>>8))%31){q.msg="incorrect header check",V.mode=L0;break}if((Z&15)!==cV){q.msg="unknown compression method",V.mode=L0;break}if(Z>>>=4,H-=4,$=(Z&15)+8,V.wbits===0)V.wbits=$;else if($>V.wbits){q.msg="invalid window size",V.mode=L0;break}V.dmax=1<<$,q.adler=V.check=1,V.mode=Z&512?tV:q6,Z=0,H=0;break;case pV:while(H<16){if(G===0)break q;G--,Z+=K[Y++]<>8&1;if(V.flags&512)h[0]=Z&255,h[1]=Z>>>8&255,V.check=l2(V.check,h,2,0);Z=0,H=0,V.mode=dV;case dV:while(H<32){if(G===0)break q;G--,Z+=K[Y++]<>>8&255,h[2]=Z>>>16&255,h[3]=Z>>>24&255,V.check=l2(V.check,h,4,0);Z=0,H=0,V.mode=nV;case nV:while(H<16){if(G===0)break q;G--,Z+=K[Y++]<>8;if(V.flags&512)h[0]=Z&255,h[1]=Z>>>8&255,V.check=l2(V.check,h,2,0);Z=0,H=0,V.mode=rV;case rV:if(V.flags&1024){while(H<16){if(G===0)break q;G--,Z+=K[Y++]<>>8&255,V.check=l2(V.check,h,2,0);Z=0,H=0}else if(V.head)V.head.extra=null;V.mode=iV;case iV:if(V.flags&1024){if(k=V.length,k>G)k=G;if(k){if(V.head){if($=V.head.extra_len-V.length,!V.head.extra)V.head.extra=Array(V.head.extra_len);Q2.arraySet(V.head.extra,K,Y,k,$)}if(V.flags&512)V.check=l2(V.check,K,k,Y);G-=k,Y+=k,V.length-=k}if(V.length)break q}V.length=0,V.mode=aV;case aV:if(V.flags&2048){if(G===0)break q;k=0;do if($=K[Y+k++],V.head&&$&&V.length<65536)V.head.name+=String.fromCharCode($);while($&&k>9&1,V.head.done=!0;q.adler=V.check=0,V.mode=q6;break;case tV:while(H<32){if(G===0)break q;G--,Z+=K[Y++]<>>=H&7,H-=H&7,V.mode=d4;break}while(H<3){if(G===0)break q;G--,Z+=K[Y++]<>>=1,H-=1,Z&3){case 0:V.mode=eV;break;case 1:if(vJ(V),V.mode=i1,X===r1){Z>>>=2,H-=2;break q}break;case 2:V.mode=X9;break;case 3:q.msg="invalid block type",V.mode=L0}Z>>>=2,H-=2;break;case eV:Z>>>=H&7,H-=H&7;while(H<32){if(G===0)break q;G--,Z+=K[Y++]<>>16^65535)){q.msg="invalid stored block lengths",V.mode=L0;break}if(V.length=Z&65535,Z=0,H=0,V.mode=p4,X===r1)break q;case p4:V.mode=q9;case q9:if(k=V.length,k){if(k>G)k=G;if(k>W)k=W;if(k===0)break q;Q2.arraySet(Q,K,Y,k,J),G-=k,Y+=k,W-=k,J+=k,V.length-=k;break}V.mode=q6;break;case X9:while(H<14){if(G===0)break q;G--,Z+=K[Y++]<>>=5,H-=5,V.ndist=(Z&31)+1,Z>>>=5,H-=5,V.ncode=(Z&15)+4,Z>>>=4,H-=4,V.nlen>286||V.ndist>30){q.msg="too many length or distance symbols",V.mode=L0;break}V.have=0,V.mode=V9;case V9:while(V.have>>=3,H-=3}while(V.have<19)V.lens[D[V.have++]]=0;if(V.lencode=V.lendyn,V.lenbits=7,b={bits:V.lenbits},S=t8(WJ,V.lens,0,19,V.lencode,0,V.work,b),V.lenbits=b.bits,S){q.msg="invalid code lengths set",V.mode=L0;break}V.have=0,V.mode=K9;case K9:while(V.have>>24,O=B>>>16&255,N=B&65535,L<=H)break;if(G===0)break q;G--,Z+=K[Y++]<>>=L,H-=L,V.lens[V.have++]=N;else{if(N===16){C=L+2;while(H>>=L,H-=L,V.have===0){q.msg="invalid bit length repeat",V.mode=L0;break}$=V.lens[V.have-1],k=3+(Z&3),Z>>>=2,H-=2}else if(N===17){C=L+3;while(H>>=L,H-=L,$=0,k=3+(Z&7),Z>>>=3,H-=3}else{C=L+7;while(H>>=L,H-=L,$=0,k=11+(Z&127),Z>>>=7,H-=7}if(V.have+k>V.nlen+V.ndist){q.msg="invalid bit length repeat",V.mode=L0;break}while(k--)V.lens[V.have++]=$}}if(V.mode===L0)break;if(V.lens[256]===0){q.msg="invalid code -- missing end-of-block",V.mode=L0;break}if(V.lenbits=9,b={bits:V.lenbits},S=t8(M9,V.lens,0,V.nlen,V.lencode,0,V.work,b),V.lenbits=b.bits,S){q.msg="invalid literal/lengths set",V.mode=L0;break}if(V.distbits=6,V.distcode=V.distdyn,b={bits:V.distbits},S=t8(k9,V.lens,V.nlen,V.ndist,V.distcode,0,V.work,b),V.distbits=b.bits,S){q.msg="invalid distances set",V.mode=L0;break}if(V.mode=i1,X===r1)break q;case i1:V.mode=a1;case a1:if(G>=6&&W>=258){if(q.next_out=J,q.avail_out=W,q.next_in=Y,q.avail_in=G,V.hold=Z,V.bits=H,ZJ(q,z),J=q.next_out,Q=q.output,W=q.avail_out,Y=q.next_in,K=q.input,G=q.avail_in,Z=V.hold,H=V.bits,V.mode===q6)V.back=-1;break}V.back=0;for(;;){if(B=V.lencode[Z&(1<>>24,O=B>>>16&255,N=B&65535,L<=H)break;if(G===0)break q;G--,Z+=K[Y++]<>R)],L=B>>>24,O=B>>>16&255,N=B&65535,R+L<=H)break;if(G===0)break q;G--,Z+=K[Y++]<>>=R,H-=R,V.back+=R}if(Z>>>=L,H-=L,V.back+=L,V.length=N,O===0){V.mode=Z9;break}if(O&32){V.back=-1,V.mode=q6;break}if(O&64){q.msg="invalid literal/length code",V.mode=L0;break}V.extra=O&15,V.mode=Q9;case Q9:if(V.extra){C=V.extra;while(H>>=V.extra,H-=V.extra,V.back+=V.extra}V.was=V.length,V.mode=Y9;case Y9:for(;;){if(B=V.distcode[Z&(1<>>24,O=B>>>16&255,N=B&65535,L<=H)break;if(G===0)break q;G--,Z+=K[Y++]<>R)],L=B>>>24,O=B>>>16&255,N=B&65535,R+L<=H)break;if(G===0)break q;G--,Z+=K[Y++]<>>=R,H-=R,V.back+=R}if(Z>>>=L,H-=L,V.back+=L,O&64){q.msg="invalid distance code",V.mode=L0;break}V.offset=N,V.extra=O&15,V.mode=J9;case J9:if(V.extra){C=V.extra;while(H>>=V.extra,H-=V.extra,V.back+=V.extra}if(V.offset>V.dmax){q.msg="invalid distance too far back",V.mode=L0;break}V.mode=G9;case G9:if(W===0)break q;if(k=z-W,V.offset>k){if(k=V.offset-k,k>V.whave){if(V.sane){q.msg="invalid distance too far back",V.mode=L0;break}}if(k>V.wnext)k-=V.wnext,M=V.wsize-k;else M=V.wnext-k;if(k>V.length)k=V.length;j=V.window}else j=Q,M=J-V.offset,k=V.length;if(k>W)k=W;W-=k,V.length-=k;do Q[J++]=j[M++];while(--k);if(V.length===0)V.mode=a1;break;case Z9:if(W===0)break q;Q[J++]=V.length,W--,V.mode=a1;break;case d4:if(V.wrap){while(H<32){if(G===0)break q;G--,Z|=K[Y++]<{O9.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var A9=g0((WW,w9)=>{function NJ(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}w9.exports=NJ});var S9=g0((q1)=>{var c5=R9(),e8=t2(),s1=g4(),N0=s4(),t4=b1(),SJ=x4(),yJ=A9(),N9=Object.prototype.toString;function X5(q){if(!(this instanceof X5))return new X5(q);this.options=e8.assign({chunkSize:16384,windowBits:0,to:""},q||{});var X=this.options;if(X.raw&&X.windowBits>=0&&X.windowBits<16){if(X.windowBits=-X.windowBits,X.windowBits===0)X.windowBits=-15}if(X.windowBits>=0&&X.windowBits<16&&!(q&&q.windowBits))X.windowBits+=32;if(X.windowBits>15&&X.windowBits<48){if((X.windowBits&15)===0)X.windowBits|=15}this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new SJ,this.strm.avail_out=0;var V=c5.inflateInit2(this.strm,X.windowBits);if(V!==N0.Z_OK)throw Error(t4[V]);if(this.header=new yJ,c5.inflateGetHeader(this.strm,this.header),X.dictionary){if(typeof X.dictionary==="string")X.dictionary=s1.string2buf(X.dictionary);else if(N9.call(X.dictionary)==="[object ArrayBuffer]")X.dictionary=new Uint8Array(X.dictionary);if(X.raw){if(V=c5.inflateSetDictionary(this.strm,X.dictionary),V!==N0.Z_OK)throw Error(t4[V])}}}X5.prototype.push=function(q,X){var V=this.strm,K=this.options.chunkSize,Q=this.options.dictionary,Y,J,G,W,Z,H=!1;if(this.ended)return!1;if(J=X===~~X?X:X===!0?N0.Z_FINISH:N0.Z_NO_FLUSH,typeof q==="string")V.input=s1.binstring2buf(q);else if(N9.call(q)==="[object ArrayBuffer]")V.input=new Uint8Array(q);else V.input=q;V.next_in=0,V.avail_in=V.input.length;do{if(V.avail_out===0)V.output=new e8.Buf8(K),V.next_out=0,V.avail_out=K;if(Y=c5.inflate(V,N0.Z_NO_FLUSH),Y===N0.Z_NEED_DICT&&Q)Y=c5.inflateSetDictionary(this.strm,Q);if(Y===N0.Z_BUF_ERROR&&H===!0)Y=N0.Z_OK,H=!1;if(Y!==N0.Z_STREAM_END&&Y!==N0.Z_OK)return this.onEnd(Y),this.ended=!0,!1;if(V.next_out){if(V.avail_out===0||Y===N0.Z_STREAM_END||V.avail_in===0&&(J===N0.Z_FINISH||J===N0.Z_SYNC_FLUSH))if(this.options.to==="string"){if(G=s1.utf8border(V.output,V.next_out),W=V.next_out-G,Z=s1.buf2string(V.output,G),V.next_out=W,V.avail_out=K-W,W)e8.arraySet(V.output,V.output,G,W,0);this.onData(Z)}else this.onData(e8.shrinkBuf(V.output,V.next_out))}if(V.avail_in===0&&V.avail_out===0)H=!0}while((V.avail_in>0||V.avail_out===0)&&Y!==N0.Z_STREAM_END);if(Y===N0.Z_STREAM_END)J=N0.Z_FINISH;if(J===N0.Z_FINISH)return Y=c5.inflateEnd(this.strm),this.onEnd(Y),this.ended=!0,Y===N0.Z_OK;if(J===N0.Z_SYNC_FLUSH)return this.onEnd(N0.Z_OK),V.avail_out=0,!0;return!0};X5.prototype.onData=function(q){this.chunks.push(q)};X5.prototype.onEnd=function(q){if(q===N0.Z_OK)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=e8.flattenChunks(this.chunks);this.chunks=[],this.err=q,this.msg=this.strm.msg};function e4(q,X){var V=new X5(X);if(V.push(q,!0),V.err)throw V.msg||t4[V.err];return V.result}function $J(q,X){return X=X||{},X.raw=!0,e4(q,X)}q1.Inflate=X5;q1.inflate=e4;q1.inflateRaw=$J;q1.ungzip=e4});var X1=g0((UW,$9)=>{var CJ=t2().assign,hJ=FV(),FJ=S9(),PJ=s4(),y9={};CJ(y9,hJ,FJ,PJ);$9.exports=y9});var zX=globalThis;if(typeof zX.global>"u")zX.global=globalThis;var C2=[],W2=[],lq="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(c6=0,MX=lq.length;c60)throw Error("Invalid string. Length must be a multiple of 4");var V=q.indexOf("=");if(V===-1)V=X;var K=V===X?0:4-V%4;return[V,K]}function VQ(q,X){return(q+X)*3/4-X}function KQ(q){var X,V=XQ(q),K=V[0],Q=V[1],Y=new Uint8Array(VQ(K,Q)),J=0,G=Q>0?K-4:K,W;for(W=0;W>16&255,Y[J++]=X>>8&255,Y[J++]=X&255;if(Q===2)X=W2[q.charCodeAt(W)]<<2|W2[q.charCodeAt(W+1)]>>4,Y[J++]=X&255;if(Q===1)X=W2[q.charCodeAt(W)]<<10|W2[q.charCodeAt(W+1)]<<4|W2[q.charCodeAt(W+2)]>>2,Y[J++]=X>>8&255,Y[J++]=X&255;return Y}function QQ(q){return C2[q>>18&63]+C2[q>>12&63]+C2[q>>6&63]+C2[q&63]}function YQ(q,X,V){var K,Q=[];for(var Y=X;YG?G:J+Y));if(K===1)X=q[V-1],Q.push(C2[X>>2]+C2[X<<4&63]+"==");else if(K===2)X=(q[V-2]<<8)+q[V-1],Q.push(C2[X>>10]+C2[X>>4&63]+C2[X<<2&63]+"=");return Q.join("")}function $1(q,X,V,K,Q){var Y,J,G=Q*8-K-1,W=(1<>1,H=-7,U=V?Q-1:0,z=V?-1:1,k=q[X+U];U+=z,Y=k&(1<<-H)-1,k>>=-H,H+=G;for(;H>0;Y=Y*256+q[X+U],U+=z,H-=8);J=Y&(1<<-H)-1,Y>>=-H,H+=K;for(;H>0;J=J*256+q[X+U],U+=z,H-=8);if(Y===0)Y=1-Z;else if(Y===W)return J?NaN:(k?-1:1)*(1/0);else J=J+Math.pow(2,K),Y=Y-Z;return(k?-1:1)*J*Math.pow(2,Y-K)}function BX(q,X,V,K,Q,Y){var J,G,W,Z=Y*8-Q-1,H=(1<>1,z=Q===23?Math.pow(2,-24)-Math.pow(2,-77):0,k=K?0:Y-1,M=K?1:-1,j=X<0||X===0&&1/X<0?1:0;if(X=Math.abs(X),isNaN(X)||X===1/0)G=isNaN(X)?1:0,J=H;else{if(J=Math.floor(Math.log(X)/Math.LN2),X*(W=Math.pow(2,-J))<1)J--,W*=2;if(J+U>=1)X+=z/W;else X+=z*Math.pow(2,1-U);if(X*W>=2)J++,W/=2;if(J+U>=H)G=0,J=H;else if(J+U>=1)G=(X*W-1)*Math.pow(2,Q),J=J+U;else G=X*Math.pow(2,U-1)*Math.pow(2,Q),J=0}for(;Q>=8;q[V+k]=G&255,k+=M,G/=256,Q-=8);J=J<0;q[V+k]=J&255,k+=M,J/=256,Z-=8);q[V+k-M]|=j*128}var IX=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null,JQ=50,_q=2147483647;var{btoa:$3,atob:C3,File:h3,Blob:F3}=globalThis;function a2(q){if(q>_q)throw RangeError('The value "'+q+'" is invalid for option "size"');let X=new Uint8Array(q);return Object.setPrototypeOf(X,y.prototype),X}function rq(q,X,V){return class extends V{constructor(){super();Object.defineProperty(this,"message",{value:X.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${q}]`,this.stack,delete this.name}get code(){return q}set code(K){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:K,writable:!0})}toString(){return`${this.name} [${q}]: ${this.message}`}}}var GQ=rq("ERR_BUFFER_OUT_OF_BOUNDS",function(q){if(q)return`${q} is outside of buffer bounds`;return"Attempt to access memory outside buffer bounds"},RangeError),ZQ=rq("ERR_INVALID_ARG_TYPE",function(q,X){return`The "${q}" argument must be of type number. Received type ${typeof X}`},TypeError),cq=rq("ERR_OUT_OF_RANGE",function(q,X,V){let K=`The value of "${q}" is out of range.`,Q=V;if(Number.isInteger(V)&&Math.abs(V)>4294967296)Q=LX(String(V));else if(typeof V==="bigint"){if(Q=String(V),V>BigInt(2)**BigInt(32)||V<-(BigInt(2)**BigInt(32)))Q=LX(Q);Q+="n"}return K+=` It must be ${X}. Received ${Q}`,K},RangeError);function y(q,X,V){if(typeof q==="number"){if(typeof X==="string")throw TypeError('The "string" argument must be of type string. Received type number');return iq(q)}return TX(q,X,V)}Object.defineProperty(y.prototype,"parent",{enumerable:!0,get:function(){if(!y.isBuffer(this))return;return this.buffer}});Object.defineProperty(y.prototype,"offset",{enumerable:!0,get:function(){if(!y.isBuffer(this))return;return this.byteOffset}});y.poolSize=8192;function TX(q,X,V){if(typeof q==="string")return HQ(q,X);if(ArrayBuffer.isView(q))return UQ(q);if(q==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof q);if(h2(q,ArrayBuffer)||q&&h2(q.buffer,ArrayBuffer))return dq(q,X,V);if(typeof SharedArrayBuffer<"u"&&(h2(q,SharedArrayBuffer)||q&&h2(q.buffer,SharedArrayBuffer)))return dq(q,X,V);if(typeof q==="number")throw TypeError('The "value" argument must not be of type number. Received type number');let K=q.valueOf&&q.valueOf();if(K!=null&&K!==q)return y.from(K,X,V);let Q=zQ(q);if(Q)return Q;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof q[Symbol.toPrimitive]==="function")return y.from(q[Symbol.toPrimitive]("string"),X,V);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof q)}y.from=function(q,X,V){return TX(q,X,V)};Object.setPrototypeOf(y.prototype,Uint8Array.prototype);Object.setPrototypeOf(y,Uint8Array);function vX(q){if(typeof q!=="number")throw TypeError('"size" argument must be of type number');else if(q<0)throw RangeError('The value "'+q+'" is invalid for option "size"')}function WQ(q,X,V){if(vX(q),q<=0)return a2(q);if(X!==void 0)return typeof V==="string"?a2(q).fill(X,V):a2(q).fill(X);return a2(q)}y.alloc=function(q,X,V){return WQ(q,X,V)};function iq(q){return vX(q),a2(q<0?0:aq(q)|0)}y.allocUnsafe=function(q){return iq(q)};y.allocUnsafeSlow=function(q){return iq(q)};function HQ(q,X){if(typeof X!=="string"||X==="")X="utf8";if(!y.isEncoding(X))throw TypeError("Unknown encoding: "+X);let V=RX(q,X)|0,K=a2(V),Q=K.write(q,X);if(Q!==V)K=K.slice(0,Q);return K}function pq(q){let X=q.length<0?0:aq(q.length)|0,V=a2(X);for(let K=0;K=_q)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+_q.toString(16)+" bytes");return q|0}y.isBuffer=function(q){return q!=null&&q._isBuffer===!0&&q!==y.prototype};y.compare=function(q,X){if(h2(q,Uint8Array))q=y.from(q,q.offset,q.byteLength);if(h2(X,Uint8Array))X=y.from(X,X.offset,X.byteLength);if(!y.isBuffer(q)||!y.isBuffer(X))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(q===X)return 0;let V=q.length,K=X.length;for(let Q=0,Y=Math.min(V,K);QK.length){if(!y.isBuffer(Y))Y=y.from(Y);Y.copy(K,Q)}else Uint8Array.prototype.set.call(K,Y,Q);else if(!y.isBuffer(Y))throw TypeError('"list" argument must be an Array of Buffers');else Y.copy(K,Q);Q+=Y.length}return K};function RX(q,X){if(y.isBuffer(q))return q.length;if(ArrayBuffer.isView(q)||h2(q,ArrayBuffer))return q.byteLength;if(typeof q!=="string")throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof q);let V=q.length,K=arguments.length>2&&arguments[2]===!0;if(!K&&V===0)return 0;let Q=!1;for(;;)switch(X){case"ascii":case"latin1":case"binary":return V;case"utf8":case"utf-8":return nq(q).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return V*2;case"hex":return V>>>1;case"base64":return hX(q).length;default:if(Q)return K?-1:nq(q).length;X=(""+X).toLowerCase(),Q=!0}}y.byteLength=RX;function MQ(q,X,V){let K=!1;if(X===void 0||X<0)X=0;if(X>this.length)return"";if(V===void 0||V>this.length)V=this.length;if(V<=0)return"";if(V>>>=0,X>>>=0,V<=X)return"";if(!q)q="utf8";while(!0)switch(q){case"hex":return OQ(this,X,V);case"utf8":case"utf-8":return wX(this,X,V);case"ascii":return vQ(this,X,V);case"latin1":case"binary":return RQ(this,X,V);case"base64":return BQ(this,X,V);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return wQ(this,X,V);default:if(K)throw TypeError("Unknown encoding: "+q);q=(q+"").toLowerCase(),K=!0}}y.prototype._isBuffer=!0;function p6(q,X,V){let K=q[X];q[X]=q[V],q[V]=K}y.prototype.swap16=function(){let q=this.length;if(q%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let X=0;XX)q+=" ... ";return""};if(IX)y.prototype[IX]=y.prototype.inspect;y.prototype.compare=function(q,X,V,K,Q){if(h2(q,Uint8Array))q=y.from(q,q.offset,q.byteLength);if(!y.isBuffer(q))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof q);if(X===void 0)X=0;if(V===void 0)V=q?q.length:0;if(K===void 0)K=0;if(Q===void 0)Q=this.length;if(X<0||V>q.length||K<0||Q>this.length)throw RangeError("out of range index");if(K>=Q&&X>=V)return 0;if(K>=Q)return-1;if(X>=V)return 1;if(X>>>=0,V>>>=0,K>>>=0,Q>>>=0,this===q)return 0;let Y=Q-K,J=V-X,G=Math.min(Y,J),W=this.slice(K,Q),Z=q.slice(X,V);for(let H=0;H2147483647)V=2147483647;else if(V<-2147483648)V=-2147483648;if(V=+V,Number.isNaN(V))V=Q?0:q.length-1;if(V<0)V=q.length+V;if(V>=q.length)if(Q)return-1;else V=q.length-1;else if(V<0)if(Q)V=0;else return-1;if(typeof X==="string")X=y.from(X,K);if(y.isBuffer(X)){if(X.length===0)return-1;return EX(q,X,V,K,Q)}else if(typeof X==="number"){if(X=X&255,typeof Uint8Array.prototype.indexOf==="function")if(Q)return Uint8Array.prototype.indexOf.call(q,X,V);else return Uint8Array.prototype.lastIndexOf.call(q,X,V);return EX(q,[X],V,K,Q)}throw TypeError("val must be string, number or Buffer")}function EX(q,X,V,K,Q){let Y=1,J=q.length,G=X.length;if(K!==void 0){if(K=String(K).toLowerCase(),K==="ucs2"||K==="ucs-2"||K==="utf16le"||K==="utf-16le"){if(q.length<2||X.length<2)return-1;Y=2,J/=2,G/=2,V/=2}}function W(H,U){if(Y===1)return H[U];else return H.readUInt16BE(U*Y)}let Z;if(Q){let H=-1;for(Z=V;ZJ)V=J-G;for(Z=V;Z>=0;Z--){let H=!0;for(let U=0;UQ)K=Q;let Y=X.length;if(K>Y/2)K=Y/2;let J;for(J=0;J>>0,isFinite(V)){if(V=V>>>0,K===void 0)K="utf8"}else K=V,V=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let Q=this.length-X;if(V===void 0||V>Q)V=Q;if(q.length>0&&(V<0||X<0)||X>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!K)K="utf8";let Y=!1;for(;;)switch(K){case"hex":return kQ(this,q,X,V);case"utf8":case"utf-8":return IQ(this,q,X,V);case"ascii":case"latin1":case"binary":return EQ(this,q,X,V);case"base64":return jQ(this,q,X,V);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return LQ(this,q,X,V);default:if(Y)throw TypeError("Unknown encoding: "+K);K=(""+K).toLowerCase(),Y=!0}};y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function BQ(q,X,V){if(X===0&&V===q.length)return kX(q);else return kX(q.slice(X,V))}function wX(q,X,V){V=Math.min(q.length,V);let K=[],Q=X;while(Q239?4:Y>223?3:Y>191?2:1;if(Q+G<=V){let W,Z,H,U;switch(G){case 1:if(Y<128)J=Y;break;case 2:if(W=q[Q+1],(W&192)===128){if(U=(Y&31)<<6|W&63,U>127)J=U}break;case 3:if(W=q[Q+1],Z=q[Q+2],(W&192)===128&&(Z&192)===128){if(U=(Y&15)<<12|(W&63)<<6|Z&63,U>2047&&(U<55296||U>57343))J=U}break;case 4:if(W=q[Q+1],Z=q[Q+2],H=q[Q+3],(W&192)===128&&(Z&192)===128&&(H&192)===128){if(U=(Y&15)<<18|(W&63)<<12|(Z&63)<<6|H&63,U>65535&&U<1114112)J=U}}}if(J===null)J=65533,G=1;else if(J>65535)J-=65536,K.push(J>>>10&1023|55296),J=56320|J&1023;K.push(J),Q+=G}return TQ(K)}var jX=4096;function TQ(q){let X=q.length;if(X<=jX)return String.fromCharCode.apply(String,q);let V="",K=0;while(KK)V=K;let Q="";for(let Y=X;YV)q=V;if(X<0){if(X+=V,X<0)X=0}else if(X>V)X=V;if(XV)throw RangeError("Trying to access beyond buffer length")}y.prototype.readUintLE=y.prototype.readUIntLE=function(q,X,V){if(q=q>>>0,X=X>>>0,!V)D0(q,X,this.length);let K=this[q],Q=1,Y=0;while(++Y>>0,X=X>>>0,!V)D0(q,X,this.length);let K=this[q+--X],Q=1;while(X>0&&(Q*=256))K+=this[q+--X]*Q;return K};y.prototype.readUint8=y.prototype.readUInt8=function(q,X){if(q=q>>>0,!X)D0(q,1,this.length);return this[q]};y.prototype.readUint16LE=y.prototype.readUInt16LE=function(q,X){if(q=q>>>0,!X)D0(q,2,this.length);return this[q]|this[q+1]<<8};y.prototype.readUint16BE=y.prototype.readUInt16BE=function(q,X){if(q=q>>>0,!X)D0(q,2,this.length);return this[q]<<8|this[q+1]};y.prototype.readUint32LE=y.prototype.readUInt32LE=function(q,X){if(q=q>>>0,!X)D0(q,4,this.length);return(this[q]|this[q+1]<<8|this[q+2]<<16)+this[q+3]*16777216};y.prototype.readUint32BE=y.prototype.readUInt32BE=function(q,X){if(q=q>>>0,!X)D0(q,4,this.length);return this[q]*16777216+(this[q+1]<<16|this[q+2]<<8|this[q+3])};y.prototype.readBigUInt64LE=M6(function(q){q=q>>>0,y5(q,"offset");let X=this[q],V=this[q+7];if(X===void 0||V===void 0)C8(q,this.length-8);let K=X+this[++q]*256+this[++q]*65536+this[++q]*16777216,Q=this[++q]+this[++q]*256+this[++q]*65536+V*16777216;return BigInt(K)+(BigInt(Q)<>>0,y5(q,"offset");let X=this[q],V=this[q+7];if(X===void 0||V===void 0)C8(q,this.length-8);let K=X*16777216+this[++q]*65536+this[++q]*256+this[++q],Q=this[++q]*16777216+this[++q]*65536+this[++q]*256+V;return(BigInt(K)<>>0,X=X>>>0,!V)D0(q,X,this.length);let K=this[q],Q=1,Y=0;while(++Y=Q)K-=Math.pow(2,8*X);return K};y.prototype.readIntBE=function(q,X,V){if(q=q>>>0,X=X>>>0,!V)D0(q,X,this.length);let K=X,Q=1,Y=this[q+--K];while(K>0&&(Q*=256))Y+=this[q+--K]*Q;if(Q*=128,Y>=Q)Y-=Math.pow(2,8*X);return Y};y.prototype.readInt8=function(q,X){if(q=q>>>0,!X)D0(q,1,this.length);if(!(this[q]&128))return this[q];return(255-this[q]+1)*-1};y.prototype.readInt16LE=function(q,X){if(q=q>>>0,!X)D0(q,2,this.length);let V=this[q]|this[q+1]<<8;return V&32768?V|4294901760:V};y.prototype.readInt16BE=function(q,X){if(q=q>>>0,!X)D0(q,2,this.length);let V=this[q+1]|this[q]<<8;return V&32768?V|4294901760:V};y.prototype.readInt32LE=function(q,X){if(q=q>>>0,!X)D0(q,4,this.length);return this[q]|this[q+1]<<8|this[q+2]<<16|this[q+3]<<24};y.prototype.readInt32BE=function(q,X){if(q=q>>>0,!X)D0(q,4,this.length);return this[q]<<24|this[q+1]<<16|this[q+2]<<8|this[q+3]};y.prototype.readBigInt64LE=M6(function(q){q=q>>>0,y5(q,"offset");let X=this[q],V=this[q+7];if(X===void 0||V===void 0)C8(q,this.length-8);let K=this[q+4]+this[q+5]*256+this[q+6]*65536+(V<<24);return(BigInt(K)<>>0,y5(q,"offset");let X=this[q],V=this[q+7];if(X===void 0||V===void 0)C8(q,this.length-8);let K=(X<<24)+this[++q]*65536+this[++q]*256+this[++q];return(BigInt(K)<>>0,!X)D0(q,4,this.length);return $1(this,q,!0,23,4)};y.prototype.readFloatBE=function(q,X){if(q=q>>>0,!X)D0(q,4,this.length);return $1(this,q,!1,23,4)};y.prototype.readDoubleLE=function(q,X){if(q=q>>>0,!X)D0(q,8,this.length);return $1(this,q,!0,52,8)};y.prototype.readDoubleBE=function(q,X){if(q=q>>>0,!X)D0(q,8,this.length);return $1(this,q,!1,52,8)};function s0(q,X,V,K,Q,Y){if(!y.isBuffer(q))throw TypeError('"buffer" argument must be a Buffer instance');if(X>Q||Xq.length)throw RangeError("Index out of range")}y.prototype.writeUintLE=y.prototype.writeUIntLE=function(q,X,V,K){if(q=+q,X=X>>>0,V=V>>>0,!K){let J=Math.pow(2,8*V)-1;s0(this,q,X,V,J,0)}let Q=1,Y=0;this[X]=q&255;while(++Y>>0,V=V>>>0,!K){let J=Math.pow(2,8*V)-1;s0(this,q,X,V,J,0)}let Q=V-1,Y=1;this[X+Q]=q&255;while(--Q>=0&&(Y*=256))this[X+Q]=q/Y&255;return X+V};y.prototype.writeUint8=y.prototype.writeUInt8=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,1,255,0);return this[X]=q&255,X+1};y.prototype.writeUint16LE=y.prototype.writeUInt16LE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,2,65535,0);return this[X]=q&255,this[X+1]=q>>>8,X+2};y.prototype.writeUint16BE=y.prototype.writeUInt16BE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,2,65535,0);return this[X]=q>>>8,this[X+1]=q&255,X+2};y.prototype.writeUint32LE=y.prototype.writeUInt32LE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,4,4294967295,0);return this[X+3]=q>>>24,this[X+2]=q>>>16,this[X+1]=q>>>8,this[X]=q&255,X+4};y.prototype.writeUint32BE=y.prototype.writeUInt32BE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,4,4294967295,0);return this[X]=q>>>24,this[X+1]=q>>>16,this[X+2]=q>>>8,this[X+3]=q&255,X+4};function AX(q,X,V,K,Q){CX(X,K,Q,q,V,7);let Y=Number(X&BigInt(4294967295));q[V++]=Y,Y=Y>>8,q[V++]=Y,Y=Y>>8,q[V++]=Y,Y=Y>>8,q[V++]=Y;let J=Number(X>>BigInt(32)&BigInt(4294967295));return q[V++]=J,J=J>>8,q[V++]=J,J=J>>8,q[V++]=J,J=J>>8,q[V++]=J,V}function NX(q,X,V,K,Q){CX(X,K,Q,q,V,7);let Y=Number(X&BigInt(4294967295));q[V+7]=Y,Y=Y>>8,q[V+6]=Y,Y=Y>>8,q[V+5]=Y,Y=Y>>8,q[V+4]=Y;let J=Number(X>>BigInt(32)&BigInt(4294967295));return q[V+3]=J,J=J>>8,q[V+2]=J,J=J>>8,q[V+1]=J,J=J>>8,q[V]=J,V+8}y.prototype.writeBigUInt64LE=M6(function(q,X=0){return AX(this,q,X,BigInt(0),BigInt("0xffffffffffffffff"))});y.prototype.writeBigUInt64BE=M6(function(q,X=0){return NX(this,q,X,BigInt(0),BigInt("0xffffffffffffffff"))});y.prototype.writeIntLE=function(q,X,V,K){if(q=+q,X=X>>>0,!K){let G=Math.pow(2,8*V-1);s0(this,q,X,V,G-1,-G)}let Q=0,Y=1,J=0;this[X]=q&255;while(++Q>0)-J&255}return X+V};y.prototype.writeIntBE=function(q,X,V,K){if(q=+q,X=X>>>0,!K){let G=Math.pow(2,8*V-1);s0(this,q,X,V,G-1,-G)}let Q=V-1,Y=1,J=0;this[X+Q]=q&255;while(--Q>=0&&(Y*=256)){if(q<0&&J===0&&this[X+Q+1]!==0)J=1;this[X+Q]=(q/Y>>0)-J&255}return X+V};y.prototype.writeInt8=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,1,127,-128);if(q<0)q=255+q+1;return this[X]=q&255,X+1};y.prototype.writeInt16LE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,2,32767,-32768);return this[X]=q&255,this[X+1]=q>>>8,X+2};y.prototype.writeInt16BE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,2,32767,-32768);return this[X]=q>>>8,this[X+1]=q&255,X+2};y.prototype.writeInt32LE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,4,2147483647,-2147483648);return this[X]=q&255,this[X+1]=q>>>8,this[X+2]=q>>>16,this[X+3]=q>>>24,X+4};y.prototype.writeInt32BE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,4,2147483647,-2147483648);if(q<0)q=4294967295+q+1;return this[X]=q>>>24,this[X+1]=q>>>16,this[X+2]=q>>>8,this[X+3]=q&255,X+4};y.prototype.writeBigInt64LE=M6(function(q,X=0){return AX(this,q,X,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});y.prototype.writeBigInt64BE=M6(function(q,X=0){return NX(this,q,X,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function SX(q,X,V,K,Q,Y){if(V+K>q.length)throw RangeError("Index out of range");if(V<0)throw RangeError("Index out of range")}function yX(q,X,V,K,Q){if(X=+X,V=V>>>0,!Q)SX(q,X,V,4,340282346638528860000000000000000000000,-340282346638528860000000000000000000000);return BX(q,X,V,K,23,4),V+4}y.prototype.writeFloatLE=function(q,X,V){return yX(this,q,X,!0,V)};y.prototype.writeFloatBE=function(q,X,V){return yX(this,q,X,!1,V)};function $X(q,X,V,K,Q){if(X=+X,V=V>>>0,!Q)SX(q,X,V,8,179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);return BX(q,X,V,K,52,8),V+8}y.prototype.writeDoubleLE=function(q,X,V){return $X(this,q,X,!0,V)};y.prototype.writeDoubleBE=function(q,X,V){return $X(this,q,X,!1,V)};y.prototype.copy=function(q,X,V,K){if(!y.isBuffer(q))throw TypeError("argument should be a Buffer");if(!V)V=0;if(!K&&K!==0)K=this.length;if(X>=q.length)X=q.length;if(!X)X=0;if(K>0&&K=this.length)throw RangeError("Index out of range");if(K<0)throw RangeError("sourceEnd out of bounds");if(K>this.length)K=this.length;if(q.length-X>>0,V=V===void 0?this.length:V>>>0,!q)q=0;let Q;if(typeof q==="number")for(Q=X;Q=K+4;V-=3)X=`_${q.slice(V-3,V)}${X}`;return`${q.slice(0,V)}${X}`}function AQ(q,X,V){if(y5(X,"offset"),q[X]===void 0||q[X+V]===void 0)C8(X,q.length-(V+1))}function CX(q,X,V,K,Q,Y){if(q>V||q3)if(X===0||X===BigInt(0))G=`>= 0${J} and < 2${J} ** ${(Y+1)*8}${J}`;else G=`>= -(2${J} ** ${(Y+1)*8-1}${J}) and < 2 ** ${(Y+1)*8-1}${J}`;else G=`>= ${X}${J} and <= ${V}${J}`;throw new cq("value",G,q)}AQ(K,Q,Y)}function y5(q,X){if(typeof q!=="number")throw new ZQ(X,"number",q)}function C8(q,X,V){if(Math.floor(q)!==q)throw y5(q,V),new cq(V||"offset","an integer",q);if(X<0)throw new GQ;throw new cq(V||"offset",`>= ${V?1:0} and <= ${X}`,q)}var NQ=/[^+/0-9A-Za-z-_]/g;function SQ(q){if(q=q.split("=")[0],q=q.trim().replace(NQ,""),q.length<2)return"";while(q.length%4!==0)q=q+"=";return q}function nq(q,X){X=X||1/0;let V,K=q.length,Q=null,Y=[];for(let J=0;J55295&&V<57344){if(!Q){if(V>56319){if((X-=3)>-1)Y.push(239,191,189);continue}else if(J+1===K){if((X-=3)>-1)Y.push(239,191,189);continue}Q=V;continue}if(V<56320){if((X-=3)>-1)Y.push(239,191,189);Q=V;continue}V=(Q-55296<<10|V-56320)+65536}else if(Q){if((X-=3)>-1)Y.push(239,191,189)}if(Q=null,V<128){if((X-=1)<0)break;Y.push(V)}else if(V<2048){if((X-=2)<0)break;Y.push(V>>6|192,V&63|128)}else if(V<65536){if((X-=3)<0)break;Y.push(V>>12|224,V>>6&63|128,V&63|128)}else if(V<1114112){if((X-=4)<0)break;Y.push(V>>18|240,V>>12&63|128,V>>6&63|128,V&63|128)}else throw Error("Invalid code point")}return Y}function yQ(q){let X=[];for(let V=0;V>8,Q=V%256,Y.push(Q),Y.push(K)}return Y}function hX(q){return KQ(SQ(q))}function C1(q,X,V,K){let Q;for(Q=0;Q=X.length||Q>=q.length)break;X[Q+V]=q[Q]}return Q}function h2(q,X){return q instanceof X||q!=null&&q.constructor!=null&&q.constructor.name!=null&&q.constructor.name===X.name}var CQ=function(){let q=Array(256);for(let X=0;X<16;++X){let V=X*16;for(let K=0;K<16;++K)q[V+K]="0123456789abcdef"[X]+"0123456789abcdef"[K]}return q}();function M6(q){return typeof BigInt>"u"?hQ:q}function hQ(){throw Error("BigInt not supported")}function oq(q){return()=>{throw Error(q+" is not implemented for node:buffer browser polyfill")}}var P3=oq("resolveObjectURL"),D3=oq("isUtf8");var u3=oq("transcode");var N3=$8(gX(),1);var UX={};qQ(UX,{waitForTick:()=>R2,values:()=>d5,utf8Encode:()=>mQ,utf16Encode:()=>E4,utf16Decode:()=>x8,typedArrayFor:()=>D8,translate:()=>c0,toUint8Array:()=>r6,toRadians:()=>O0,toHexStringOfMinLength:()=>D2,toHexString:()=>u2,toDegrees:()=>k1,toCodePoint:()=>K4,toCharCode:()=>s,sum:()=>z4,stroke:()=>B5,square:()=>lZ,sortedUniq:()=>U4,skewRadians:()=>k8,skewDegrees:()=>bZ,sizeInBytes:()=>P5,singleQuote:()=>t9,showText:()=>L1,setWordSpacing:()=>pZ,setTextRise:()=>nZ,setTextRenderingMode:()=>rZ,setTextMatrix:()=>FK,setStrokingRgbColor:()=>g7,setStrokingGrayscaleColor:()=>D7,setStrokingColor:()=>v5,setStrokingCmykColor:()=>b7,setLineWidth:()=>L5,setLineJoin:()=>fZ,setLineHeight:()=>F7,setLineCap:()=>I8,setGraphicsState:()=>i2,setFontAndSize:()=>T5,setFillingRgbColor:()=>u7,setFillingGrayscaleColor:()=>P7,setFillingColor:()=>E2,setFillingCmykColor:()=>x7,setDashPattern:()=>j5,setCharacterSqueeze:()=>dZ,setCharacterSpacing:()=>cZ,scale:()=>g6,rotateRectangle:()=>y7,rotateRadians:()=>x6,rotateInPlace:()=>j2,rotateDegrees:()=>M8,rotateAndSkewTextRadiansAndTranslate:()=>j8,rotateAndSkewTextDegreesAndTranslate:()=>iZ,rgb:()=>Y0,reverseArray:()=>I6,restoreDashPattern:()=>mZ,reduceRotation:()=>I2,rectanglesAreEqual:()=>n5,rectangle:()=>hK,range:()=>M4,radiansToDegrees:()=>CK,radians:()=>gZ,pushGraphicsState:()=>B0,popGraphicsState:()=>T0,pluckIndices:()=>k4,pdfDocEncodingDecode:()=>J1,parseDate:()=>P8,padStart:()=>e0,numberToString:()=>B4,normalizeAppearance:()=>G2,nextLine:()=>h7,newlineChars:()=>gQ,moveTo:()=>J2,moveText:()=>_Z,mergeUint8Arrays:()=>W4,mergeLines:()=>F1,mergeIntoTypedArray:()=>Z4,lowSurrogate:()=>u1,lineTo:()=>S0,lineSplit:()=>F8,layoutSinglelineText:()=>v8,layoutMultilineText:()=>uq,layoutCombedText:()=>KX,last:()=>n6,isWithinBMP:()=>j4,isType:()=>XK,isStandardFont:()=>e1,isNewlineChar:()=>Y4,highSurrogate:()=>D1,hasUtf16BOM:()=>b8,hasSurrogates:()=>L4,grayscale:()=>Sq,getType:()=>qK,findLastMatch:()=>F5,fillAndStroke:()=>j1,fill:()=>E1,escapedNewlineChars:()=>mX,escapeRegExp:()=>bX,error:()=>L6,endText:()=>T1,endPath:()=>wq,endMarkedContent:()=>Nq,encodeToBase64:()=>X4,drawTextLines:()=>Fq,drawTextField:()=>Pq,drawText:()=>eZ,drawSvgPath:()=>d7,drawRectangle:()=>b6,drawRadioButton:()=>T8,drawPage:()=>c7,drawOptionList:()=>n7,drawObject:()=>L8,drawLinesOfText:()=>_7,drawLine:()=>p7,drawImage:()=>w1,drawEllipsePath:()=>xK,drawEllipse:()=>O1,drawCheckMark:()=>bK,drawCheckBox:()=>B8,drawButton:()=>hq,degreesToRadians:()=>H6,degrees:()=>p,defaultTextFieldAppearanceProvider:()=>GX,defaultRadioGroupAppearanceProvider:()=>YX,defaultOptionListAppearanceProvider:()=>WX,defaultDropdownAppearanceProvider:()=>ZX,defaultCheckBoxAppearanceProvider:()=>QX,defaultButtonAppearanceProvider:()=>JX,decodePDFRawStream:()=>V8,decodeFromBase64DataUri:()=>V4,decodeFromBase64:()=>q4,createValueErrorMsg:()=>e9,createTypeErrorMsg:()=>VK,createPDFAcroFields:()=>Z8,createPDFAcroField:()=>kq,copyStringIntoBuffer:()=>k0,concatTransformationMatrix:()=>I1,componentsToColor:()=>l0,colorToComponents:()=>$q,cmyk:()=>yq,closePath:()=>N2,clipEvenOdd:()=>xZ,clip:()=>Oq,cleanText:()=>k6,charSplit:()=>J4,charFromHexCode:()=>Q4,charFromCode:()=>t0,charAtIndex:()=>P1,canBeConvertedToUint8Array:()=>I4,bytesFor:()=>j6,byAscendingId:()=>H4,breakTextIntoLines:()=>G4,beginText:()=>B1,beginMarkedContent:()=>Aq,backtick:()=>$0,assertRangeOrUndefined:()=>X2,assertRange:()=>b0,assertPositive:()=>X6,assertOrUndefined:()=>F,assertMultiple:()=>Y1,assertIsSubset:()=>V7,assertIsOneOfOrUndefined:()=>a0,assertIsOneOf:()=>M2,assertIs:()=>T,assertInteger:()=>K7,assertEachIs:()=>Q1,asPDFNumber:()=>f,asPDFName:()=>z8,asNumber:()=>t,arrayAsString:()=>u8,appendQuadraticCurve:()=>E8,appendBezierCurve:()=>p0,adjustDimsForRotation:()=>r2,addRandomSuffix:()=>uQ,ViewerPreferences:()=>W1,UnsupportedEncodingError:()=>Q7,UnrecognizedStreamTypeError:()=>J7,UnexpectedObjectTypeError:()=>A6,UnexpectedFieldTypeError:()=>z6,UnbalancedParenthesisError:()=>E7,TextRenderingMode:()=>C7,TextAlignment:()=>v0,StandardFonts:()=>N5,StandardFontValues:()=>o9,StandardFontEmbedder:()=>$6,StalledParserError:()=>j7,RotationTypes:()=>E5,RichTextFieldReadError:()=>e7,ReparseError:()=>Q5,RemovePageFromEmptyDocumentError:()=>o7,ReadingDirection:()=>U5,PrivateConstructorError:()=>K5,PrintScaling:()=>z5,PngEmbedder:()=>X8,ParseSpeeds:()=>A1,PageSizes:()=>HX,PageEmbeddingMismatchedContextError:()=>G7,PDFXRefStreamParser:()=>Lq,PDFWriter:()=>o5,PDFWidgetAnnotation:()=>M5,PDFTrailerDict:()=>Qq,PDFTrailer:()=>S6,PDFTextField:()=>A5,PDFString:()=>K0,PDFStreamWriter:()=>Jq,PDFStreamParsingError:()=>I7,PDFStream:()=>E0,PDFSignature:()=>O8,PDFRef:()=>a,PDFRawStream:()=>A2,PDFRadioGroup:()=>l6,PDFParsingError:()=>V6,PDFParser:()=>Bq,PDFPageTree:()=>H8,PDFPageLeaf:()=>_0,PDFPageEmbedder:()=>K8,PDFPage:()=>y0,PDFOptionList:()=>w5,PDFOperatorNames:()=>X0,PDFOperator:()=>e,PDFObjectStreamParser:()=>jq,PDFObjectStream:()=>a5,PDFObjectParsingError:()=>M7,PDFObjectParser:()=>U8,PDFObjectCopier:()=>Z1,PDFObject:()=>z0,PDFNumber:()=>x,PDFNull:()=>F0,PDFName:()=>I,PDFJavaScript:()=>xq,PDFInvalidObjectParsingError:()=>k7,PDFInvalidObject:()=>s5,PDFImage:()=>R5,PDFHexString:()=>g,PDFHeader:()=>_2,PDFForm:()=>gq,PDFFont:()=>w0,PDFFlateStream:()=>N6,PDFField:()=>d0,PDFEmbeddedPage:()=>R8,PDFDropdown:()=>O5,PDFDocument:()=>o0,PDFDict:()=>m,PDFCrossRefStream:()=>Yq,PDFCrossRefSection:()=>i5,PDFContext:()=>Z5,PDFContentStream:()=>p2,PDFCheckBox:()=>f6,PDFCatalog:()=>W8,PDFButton:()=>S5,PDFBool:()=>c2,PDFArrayIsNotRectangleError:()=>Z7,PDFArray:()=>i,PDFAnnotation:()=>Mq,PDFAcroText:()=>J6,PDFAcroTerminal:()=>K2,PDFAcroSignature:()=>F6,PDFAcroRadioButton:()=>Z6,PDFAcroPushButton:()=>G6,PDFAcroNonTerminal:()=>Y6,PDFAcroListBox:()=>W6,PDFAcroForm:()=>P6,PDFAcroField:()=>Y8,PDFAcroComboBox:()=>Q6,PDFAcroChoice:()=>G8,PDFAcroCheckBox:()=>K6,PDFAcroButton:()=>h6,NumberParsingError:()=>Vq,NonFullScreenPageMode:()=>H5,NoSuchFieldError:()=>s7,NextByteAssertionError:()=>z7,MultiSelectValueError:()=>W7,MissingTfOperatorError:()=>U7,MissingPageContentsEmbeddingError:()=>Y7,MissingPDFHeaderError:()=>L7,MissingOnValueCheckError:()=>X3,MissingKeywordError:()=>B7,MissingDAEntryError:()=>H7,MissingCatalogError:()=>qG,MethodNotImplementedError:()=>u0,LineJoinStyle:()=>$7,LineCapStyle:()=>u6,JpegEmbedder:()=>q8,InvalidTargetIndexError:()=>qq,InvalidPDFDateStringError:()=>G1,InvalidMaxLengthError:()=>VX,InvalidFieldNamePartError:()=>t7,InvalidAcroFieldValueError:()=>J5,IndexOutOfBoundsError:()=>Y5,ImageAlignment:()=>T2,ForeignPageError:()=>a7,FontkitNotRegisteredError:()=>i7,FileEmbedder:()=>Wq,FieldExistsAsNonTerminalError:()=>V3,FieldAlreadyExistsError:()=>Dq,ExceededMaxLengthError:()=>XX,EncryptedPDFError:()=>r7,Duplex:()=>Q8,CustomFontSubsetEmbedder:()=>Zq,CustomFontEmbedder:()=>C6,CorruptPageTreeError:()=>Xq,CombedTextLayoutError:()=>qX,ColorTypes:()=>U6,CharCodes:()=>E,Cache:()=>m0,BlendMode:()=>S2,AppearanceCharacteristics:()=>J8,AnnotationFlags:()=>I5,AcroTextFlags:()=>j0,AcroFieldFlags:()=>Y2,AcroChoiceFlags:()=>G0,AcroButtonFlags:()=>f0,AFRelationship:()=>t5});/*! ***************************************************************************** +(()=>{var dK=Object.create;var{getPrototypeOf:nK,defineProperty:fq,getOwnPropertyNames:rK}=Object;var iK=Object.prototype.hasOwnProperty;function aK(q){return this[q]}var oK,sK,$8=(q,X,V)=>{var K=q!=null&&typeof q==="object";if(K){var Q=X?oK??=new WeakMap:sK??=new WeakMap,Y=Q.get(q);if(Y)return Y}V=q!=null?dK(nK(q)):{};let J=X||!q||!q.__esModule?fq(V,"default",{value:q,enumerable:!0}):V;for(let G of rK(q))if(!iK.call(J,G))fq(J,G,{get:aK.bind(q,G),enumerable:!0});if(K)Q.set(q,J);return J};var g0=(q,X)=>()=>(X||q((X={exports:{}}).exports,X),X.exports);var tK=(q)=>q;function eK(q,X){this[q]=tK.bind(null,X)}var qQ=(q,X)=>{for(var V in X)fq(q,V,{get:X[V],enumerable:!0,configurable:!0,set:eK.bind(X,V)})};var gX=g0((b3,uX)=>{var w0=uX.exports={},F2,P2;function sq(){throw Error("setTimeout has not been defined")}function tq(){throw Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function")F2=setTimeout;else F2=sq}catch(q){F2=sq}try{if(typeof clearTimeout==="function")P2=clearTimeout;else P2=tq}catch(q){P2=tq}})();function FX(q){if(F2===setTimeout)return setTimeout(q,0);if((F2===sq||!F2)&&setTimeout)return F2=setTimeout,setTimeout(q,0);try{return F2(q,0)}catch(X){try{return F2.call(null,q,0)}catch(V){return F2.call(this,q,0)}}}function FQ(q){if(P2===clearTimeout)return clearTimeout(q);if((P2===tq||!P2)&&clearTimeout)return P2=clearTimeout,clearTimeout(q);try{return P2(q)}catch(X){try{return P2.call(null,q)}catch(V){return P2.call(this,q)}}}var o2=[],$5=!1,d6,h1=-1;function PQ(){if(!$5||!d6)return;if($5=!1,d6.length)o2=d6.concat(o2);else h1=-1;if(o2.length)PX()}function PX(){if($5)return;var q=FX(PQ);$5=!0;var X=o2.length;while(X){d6=o2,o2=[];while(++h11)for(var V=1;V{var _Q=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function cQ(q,X){return Object.prototype.hasOwnProperty.call(q,X)}r0.assign=function(q){var X=Array.prototype.slice.call(arguments,1);while(X.length){var V=X.shift();if(!V)continue;if(typeof V!=="object")throw TypeError(V+"must be non-object");for(var K in V)if(cQ(V,K))q[K]=V[K]}return q};r0.shrinkBuf=function(q,X){if(q.length===X)return q;if(q.subarray)return q.subarray(0,X);return q.length=X,q};var pQ={arraySet:function(q,X,V,K,Q){if(X.subarray&&q.subarray){q.set(X.subarray(V,V+K),Q);return}for(var Y=0;Y{var nQ=t2(),rQ=4,pX=0,dX=1,iQ=2;function u5(q){var X=q.length;while(--X>=0)q[X]=0}var aQ=0,sX=1,oQ=2,sQ=3,tQ=258,N4=29,p8=256,f8=p8+1+N4,D5=30,S4=19,tX=2*f8+1,i6=15,T4=16,eQ=7,y4=256,eX=16,qV=17,XV=18,A4=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],g1=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],qY=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],VV=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],XY=512,e2=Array((f8+2)*2);u5(e2);var m8=Array(D5*2);u5(m8);var l8=Array(XY);u5(l8);var _8=Array(tQ-sQ+1);u5(_8);var $4=Array(N4);u5($4);var x1=Array(D5);u5(x1);function v4(q,X,V,K,Q){this.static_tree=q,this.extra_bits=X,this.extra_base=V,this.elems=K,this.max_length=Q,this.has_stree=q&&q.length}var KV,QV,YV;function R4(q,X){this.dyn_tree=q,this.max_code=0,this.stat_desc=X}function JV(q){return q<256?l8[q]:l8[256+(q>>>7)]}function c8(q,X){q.pending_buf[q.pending++]=X&255,q.pending_buf[q.pending++]=X>>>8&255}function q2(q,X,V){if(q.bi_valid>T4-V)q.bi_buf|=X<>T4-q.bi_valid,q.bi_valid+=V-T4;else q.bi_buf|=X<>>=1,V<<=1;while(--X>0);return V>>>1}function VY(q){if(q.bi_valid===16)c8(q,q.bi_buf),q.bi_buf=0,q.bi_valid=0;else if(q.bi_valid>=8)q.pending_buf[q.pending++]=q.bi_buf&255,q.bi_buf>>=8,q.bi_valid-=8}function KY(q,X){var{dyn_tree:V,max_code:K}=X,Q=X.stat_desc.static_tree,Y=X.stat_desc.has_stree,J=X.stat_desc.extra_bits,G=X.stat_desc.extra_base,W=X.stat_desc.max_length,Z,H,U,z,k,M,j=0;for(z=0;z<=i6;z++)q.bl_count[z]=0;V[q.heap[q.heap_max]*2+1]=0;for(Z=q.heap_max+1;ZW)z=W,j++;if(V[H*2+1]=z,H>K)continue;if(q.bl_count[z]++,k=0,H>=G)k=J[H-G];if(M=V[H*2],q.opt_len+=M*(z+k),Y)q.static_len+=M*(Q[H*2+1]+k)}if(j===0)return;do{z=W-1;while(q.bl_count[z]===0)z--;q.bl_count[z]--,q.bl_count[z+1]+=2,q.bl_count[W]--,j-=2}while(j>0);for(z=W;z!==0;z--){H=q.bl_count[z];while(H!==0){if(U=q.heap[--Z],U>K)continue;if(V[U*2+1]!==z)q.opt_len+=(z-V[U*2+1])*V[U*2],V[U*2+1]=z;H--}}}function ZV(q,X,V){var K=Array(i6+1),Q=0,Y,J;for(Y=1;Y<=i6;Y++)K[Y]=Q=Q+V[Y-1]<<1;for(J=0;J<=X;J++){var G=q[J*2+1];if(G===0)continue;q[J*2]=GV(K[G]++,G)}}function QY(){var q,X,V,K,Q,Y=Array(i6+1);V=0;for(K=0;K>=7;for(;K8)c8(q,q.bi_buf);else if(q.bi_valid>0)q.pending_buf[q.pending++]=q.bi_buf;q.bi_buf=0,q.bi_valid=0}function YY(q,X,V,K){if(HV(q),K)c8(q,V),c8(q,~V);nQ.arraySet(q.pending_buf,q.window,X,V,q.pending),q.pending+=V}function nX(q,X,V,K){var Q=X*2,Y=V*2;return q[Q]>1;J>=1;J--)O4(q,V,J);Z=Y;do J=q.heap[1],q.heap[1]=q.heap[q.heap_len--],O4(q,V,1),G=q.heap[1],q.heap[--q.heap_max]=J,q.heap[--q.heap_max]=G,V[Z*2]=V[J*2]+V[G*2],q.depth[Z]=(q.depth[J]>=q.depth[G]?q.depth[J]:q.depth[G])+1,V[J*2+1]=V[G*2+1]=Z,q.heap[1]=Z++,O4(q,V,1);while(q.heap_len>=2);q.heap[--q.heap_max]=q.heap[1],KY(q,X),ZV(V,W,q.bl_count)}function iX(q,X,V){var K,Q=-1,Y,J=X[1],G=0,W=7,Z=4;if(J===0)W=138,Z=3;X[(V+1)*2+1]=65535;for(K=0;K<=V;K++){if(Y=J,J=X[(K+1)*2+1],++G=3;X--)if(q.bl_tree[VV[X]*2+1]!==0)break;return q.opt_len+=3*(X+1)+5+5+4,X}function GY(q,X,V,K){var Q;q2(q,X-257,5),q2(q,V-1,5),q2(q,K-4,4);for(Q=0;Q>>=1)if(X&1&&q.dyn_ltree[V*2]!==0)return pX;if(q.dyn_ltree[18]!==0||q.dyn_ltree[20]!==0||q.dyn_ltree[26]!==0)return dX;for(V=32;V0){if(q.strm.data_type===iQ)q.strm.data_type=ZY(q);if(w4(q,q.l_desc),w4(q,q.d_desc),J=JY(q),Q=q.opt_len+3+7>>>3,Y=q.static_len+3+7>>>3,Y<=Q)Q=Y}else Q=Y=V+5;if(V+4<=Q&&X!==-1)UV(q,X,V,K);else if(q.strategy===rQ||Y===Q)q2(q,(sX<<1)+(K?1:0),3),rX(q,e2,m8);else q2(q,(oQ<<1)+(K?1:0),3),GY(q,q.l_desc.max_code+1,q.d_desc.max_code+1,J+1),rX(q,q.dyn_ltree,q.dyn_dtree);if(WV(q),K)HV(q)}function zY(q,X,V){if(q.pending_buf[q.d_buf+q.last_lit*2]=X>>>8&255,q.pending_buf[q.d_buf+q.last_lit*2+1]=X&255,q.pending_buf[q.l_buf+q.last_lit]=V&255,q.last_lit++,X===0)q.dyn_ltree[V*2]++;else q.matches++,X--,q.dyn_ltree[(_8[V]+p8+1)*2]++,q.dyn_dtree[JV(X)*2]++;return q.last_lit===q.lit_bufsize-1}g5._tr_init=WY;g5._tr_stored_block=UV;g5._tr_flush_block=UY;g5._tr_tally=zY;g5._tr_align=HY});var C4=g0((t3,MV)=>{function MY(q,X,V,K){var Q=q&65535|0,Y=q>>>16&65535|0,J=0;while(V!==0){J=V>2000?2000:V,V-=J;do Q=Q+X[K++]|0,Y=Y+Q|0;while(--J);Q%=65521,Y%=65521}return Q|Y<<16|0}MV.exports=MY});var h4=g0((e3,kV)=>{function kY(){var q,X=[];for(var V=0;V<256;V++){q=V;for(var K=0;K<8;K++)q=q&1?3988292384^q>>>1:q>>>1;X[V]=q}return X}var IY=kY();function EY(q,X,V,K){var Q=IY,Y=K+V;q^=-1;for(var J=K;J>>8^Q[(q^X[J])&255];return q^-1}kV.exports=EY});var b1=g0((qW,IV)=>{IV.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var AV=g0((m2)=>{var i0=t2(),H2=zV(),BV=C4(),B6=h4(),jY=b1(),t6=0,LY=1,BY=3,A6=4,EV=5,b2=0,jV=1,U2=-2,TY=-3,F4=-5,vY=-1,RY=1,m1=2,OY=3,AY=4,wY=0,NY=2,c1=8,SY=9,yY=15,$Y=8,CY=29,hY=256,D4=hY+1+CY,FY=30,PY=19,DY=2*D4+1,uY=15,H0=3,R6=258,O2=R6+H0+1,gY=32,p1=42,u4=69,f1=73,l1=91,_1=103,a6=113,n8=666,h0=1,r8=2,o6=3,m5=4,xY=3;function O6(q,X){return q.msg=jY[X],X}function LV(q){return(q<<1)-(q>4?9:0)}function v6(q){var X=q.length;while(--X>=0)q[X]=0}function T6(q){var X=q.state,V=X.pending;if(V>q.avail_out)V=q.avail_out;if(V===0)return;if(i0.arraySet(q.output,X.pending_buf,X.pending_out,V,q.next_out),q.next_out+=V,X.pending_out+=V,q.total_out+=V,q.avail_out-=V,X.pending-=V,X.pending===0)X.pending_out=0}function x0(q,X){H2._tr_flush_block(q,q.block_start>=0?q.block_start:-1,q.strstart-q.block_start,X),q.block_start=q.strstart,T6(q.strm)}function U0(q,X){q.pending_buf[q.pending++]=X}function d8(q,X){q.pending_buf[q.pending++]=X>>>8&255,q.pending_buf[q.pending++]=X&255}function bY(q,X,V,K){var Q=q.avail_in;if(Q>K)Q=K;if(Q===0)return 0;if(q.avail_in-=Q,i0.arraySet(X,q.input,q.next_in,Q,V),q.state.wrap===1)q.adler=BV(q.adler,X,Q,V);else if(q.state.wrap===2)q.adler=B6(q.adler,X,Q,V);return q.next_in+=Q,q.total_in+=Q,Q}function TV(q,X){var{max_chain_length:V,strstart:K}=q,Q,Y,J=q.prev_length,G=q.nice_match,W=q.strstart>q.w_size-O2?q.strstart-(q.w_size-O2):0,Z=q.window,H=q.w_mask,U=q.prev,z=q.strstart+R6,k=Z[K+J-1],M=Z[K+J];if(q.prev_length>=q.good_match)V>>=2;if(G>q.lookahead)G=q.lookahead;do{if(Q=X,Z[Q+J]!==M||Z[Q+J-1]!==k||Z[Q]!==Z[K]||Z[++Q]!==Z[K+1])continue;K+=2,Q++;do;while(Z[++K]===Z[++Q]&&Z[++K]===Z[++Q]&&Z[++K]===Z[++Q]&&Z[++K]===Z[++Q]&&Z[++K]===Z[++Q]&&Z[++K]===Z[++Q]&&Z[++K]===Z[++Q]&&Z[++K]===Z[++Q]&&KJ){if(q.match_start=X,J=Y,Y>=G)break;k=Z[K+J-1],M=Z[K+J]}}while((X=U[X&H])>W&&--V!==0);if(J<=q.lookahead)return J;return q.lookahead}function s6(q){var X=q.w_size,V,K,Q,Y,J;do{if(Y=q.window_size-q.lookahead-q.strstart,q.strstart>=X+(X-O2)){i0.arraySet(q.window,q.window,X,X,0),q.match_start-=X,q.strstart-=X,q.block_start-=X,K=q.hash_size,V=K;do Q=q.head[--V],q.head[V]=Q>=X?Q-X:0;while(--K);K=X,V=K;do Q=q.prev[--V],q.prev[V]=Q>=X?Q-X:0;while(--K);Y+=X}if(q.strm.avail_in===0)break;if(K=bY(q.strm,q.window,q.strstart+q.lookahead,Y),q.lookahead+=K,q.lookahead+q.insert>=H0){J=q.strstart-q.insert,q.ins_h=q.window[J],q.ins_h=(q.ins_h<q.pending_buf_size-5)V=q.pending_buf_size-5;for(;;){if(q.lookahead<=1){if(s6(q),q.lookahead===0&&X===t6)return h0;if(q.lookahead===0)break}q.strstart+=q.lookahead,q.lookahead=0;var K=q.block_start+V;if(q.strstart===0||q.strstart>=K){if(q.lookahead=q.strstart-K,q.strstart=K,x0(q,!1),q.strm.avail_out===0)return h0}if(q.strstart-q.block_start>=q.w_size-O2){if(x0(q,!1),q.strm.avail_out===0)return h0}}if(q.insert=0,X===A6){if(x0(q,!0),q.strm.avail_out===0)return o6;return m5}if(q.strstart>q.block_start){if(x0(q,!1),q.strm.avail_out===0)return h0}return h0}function P4(q,X){var V,K;for(;;){if(q.lookahead=H0)q.ins_h=(q.ins_h<=H0)if(K=H2._tr_tally(q,q.strstart-q.match_start,q.match_length-H0),q.lookahead-=q.match_length,q.match_length<=q.max_lazy_match&&q.lookahead>=H0){q.match_length--;do q.strstart++,q.ins_h=(q.ins_h<=H0)q.ins_h=(q.ins_h<4096))q.match_length=H0-1}if(q.prev_length>=H0&&q.match_length<=q.prev_length){Q=q.strstart+q.lookahead-H0,K=H2._tr_tally(q,q.strstart-1-q.prev_match,q.prev_length-H0),q.lookahead-=q.prev_length-1,q.prev_length-=2;do if(++q.strstart<=Q)q.ins_h=(q.ins_h<=H0&&q.strstart>0){if(Q=q.strstart-1,K=J[Q],K===J[++Q]&&K===J[++Q]&&K===J[++Q]){Y=q.strstart+R6;do;while(K===J[++Q]&&K===J[++Q]&&K===J[++Q]&&K===J[++Q]&&K===J[++Q]&&K===J[++Q]&&K===J[++Q]&&K===J[++Q]&&Qq.lookahead)q.match_length=q.lookahead}}if(q.match_length>=H0)V=H2._tr_tally(q,1,q.match_length-H0),q.lookahead-=q.match_length,q.strstart+=q.match_length,q.match_length=0;else V=H2._tr_tally(q,0,q.window[q.strstart]),q.lookahead--,q.strstart++;if(V){if(x0(q,!1),q.strm.avail_out===0)return h0}}if(q.insert=0,X===A6){if(x0(q,!0),q.strm.avail_out===0)return o6;return m5}if(q.last_lit){if(x0(q,!1),q.strm.avail_out===0)return h0}return r8}function lY(q,X){var V;for(;;){if(q.lookahead===0){if(s6(q),q.lookahead===0){if(X===t6)return h0;break}}if(q.match_length=0,V=H2._tr_tally(q,0,q.window[q.strstart]),q.lookahead--,q.strstart++,V){if(x0(q,!1),q.strm.avail_out===0)return h0}}if(q.insert=0,X===A6){if(x0(q,!0),q.strm.avail_out===0)return o6;return m5}if(q.last_lit){if(x0(q,!1),q.strm.avail_out===0)return h0}return r8}function x2(q,X,V,K,Q){this.good_length=q,this.max_lazy=X,this.nice_length=V,this.max_chain=K,this.func=Q}var b5;b5=[new x2(0,0,0,0,mY),new x2(4,4,8,4,P4),new x2(4,5,16,8,P4),new x2(4,6,32,32,P4),new x2(4,4,16,16,x5),new x2(8,16,32,32,x5),new x2(8,16,128,128,x5),new x2(8,32,128,256,x5),new x2(32,128,258,1024,x5),new x2(32,258,258,4096,x5)];function _Y(q){q.window_size=2*q.w_size,v6(q.head),q.max_lazy_match=b5[q.level].max_lazy,q.good_match=b5[q.level].good_length,q.nice_match=b5[q.level].nice_length,q.max_chain_length=b5[q.level].max_chain,q.strstart=0,q.block_start=0,q.lookahead=0,q.insert=0,q.match_length=q.prev_length=H0-1,q.match_available=0,q.ins_h=0}function cY(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=c1,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i0.Buf16(DY*2),this.dyn_dtree=new i0.Buf16((2*FY+1)*2),this.bl_tree=new i0.Buf16((2*PY+1)*2),v6(this.dyn_ltree),v6(this.dyn_dtree),v6(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i0.Buf16(uY+1),this.heap=new i0.Buf16(2*D4+1),v6(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i0.Buf16(2*D4+1),v6(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function vV(q){var X;if(!q||!q.state)return O6(q,U2);if(q.total_in=q.total_out=0,q.data_type=NY,X=q.state,X.pending=0,X.pending_out=0,X.wrap<0)X.wrap=-X.wrap;return X.status=X.wrap?p1:a6,q.adler=X.wrap===2?0:1,X.last_flush=t6,H2._tr_init(X),b2}function RV(q){var X=vV(q);if(X===b2)_Y(q.state);return X}function pY(q,X){if(!q||!q.state)return U2;if(q.state.wrap!==2)return U2;return q.state.gzhead=X,b2}function OV(q,X,V,K,Q,Y){if(!q)return U2;var J=1;if(X===vY)X=6;if(K<0)J=0,K=-K;else if(K>15)J=2,K-=16;if(Q<1||Q>SY||V!==c1||K<8||K>15||X<0||X>9||Y<0||Y>AY)return O6(q,U2);if(K===8)K=9;var G=new cY;return q.state=G,G.strm=q,G.wrap=J,G.gzhead=null,G.w_bits=K,G.w_size=1<EV||X<0)return q?O6(q,U2):U2;if(K=q.state,!q.output||!q.input&&q.avail_in!==0||K.status===n8&&X!==A6)return O6(q,q.avail_out===0?F4:U2);if(K.strm=q,V=K.last_flush,K.last_flush=X,K.status===p1)if(K.wrap===2)if(q.adler=0,U0(K,31),U0(K,139),U0(K,8),!K.gzhead)U0(K,0),U0(K,0),U0(K,0),U0(K,0),U0(K,0),U0(K,K.level===9?2:K.strategy>=m1||K.level<2?4:0),U0(K,xY),K.status=a6;else{if(U0(K,(K.gzhead.text?1:0)+(K.gzhead.hcrc?2:0)+(!K.gzhead.extra?0:4)+(!K.gzhead.name?0:8)+(!K.gzhead.comment?0:16)),U0(K,K.gzhead.time&255),U0(K,K.gzhead.time>>8&255),U0(K,K.gzhead.time>>16&255),U0(K,K.gzhead.time>>24&255),U0(K,K.level===9?2:K.strategy>=m1||K.level<2?4:0),U0(K,K.gzhead.os&255),K.gzhead.extra&&K.gzhead.extra.length)U0(K,K.gzhead.extra.length&255),U0(K,K.gzhead.extra.length>>8&255);if(K.gzhead.hcrc)q.adler=B6(q.adler,K.pending_buf,K.pending,0);K.gzindex=0,K.status=u4}else{var J=c1+(K.w_bits-8<<4)<<8,G=-1;if(K.strategy>=m1||K.level<2)G=0;else if(K.level<6)G=1;else if(K.level===6)G=2;else G=3;if(J|=G<<6,K.strstart!==0)J|=gY;if(J+=31-J%31,K.status=a6,d8(K,J),K.strstart!==0)d8(K,q.adler>>>16),d8(K,q.adler&65535);q.adler=1}if(K.status===u4)if(K.gzhead.extra){Q=K.pending;while(K.gzindex<(K.gzhead.extra.length&65535)){if(K.pending===K.pending_buf_size){if(K.gzhead.hcrc&&K.pending>Q)q.adler=B6(q.adler,K.pending_buf,K.pending-Q,Q);if(T6(q),Q=K.pending,K.pending===K.pending_buf_size)break}U0(K,K.gzhead.extra[K.gzindex]&255),K.gzindex++}if(K.gzhead.hcrc&&K.pending>Q)q.adler=B6(q.adler,K.pending_buf,K.pending-Q,Q);if(K.gzindex===K.gzhead.extra.length)K.gzindex=0,K.status=f1}else K.status=f1;if(K.status===f1)if(K.gzhead.name){Q=K.pending;do{if(K.pending===K.pending_buf_size){if(K.gzhead.hcrc&&K.pending>Q)q.adler=B6(q.adler,K.pending_buf,K.pending-Q,Q);if(T6(q),Q=K.pending,K.pending===K.pending_buf_size){Y=1;break}}if(K.gzindexQ)q.adler=B6(q.adler,K.pending_buf,K.pending-Q,Q);if(Y===0)K.gzindex=0,K.status=l1}else K.status=l1;if(K.status===l1)if(K.gzhead.comment){Q=K.pending;do{if(K.pending===K.pending_buf_size){if(K.gzhead.hcrc&&K.pending>Q)q.adler=B6(q.adler,K.pending_buf,K.pending-Q,Q);if(T6(q),Q=K.pending,K.pending===K.pending_buf_size){Y=1;break}}if(K.gzindexQ)q.adler=B6(q.adler,K.pending_buf,K.pending-Q,Q);if(Y===0)K.status=_1}else K.status=_1;if(K.status===_1)if(K.gzhead.hcrc){if(K.pending+2>K.pending_buf_size)T6(q);if(K.pending+2<=K.pending_buf_size)U0(K,q.adler&255),U0(K,q.adler>>8&255),q.adler=0,K.status=a6}else K.status=a6;if(K.pending!==0){if(T6(q),q.avail_out===0)return K.last_flush=-1,b2}else if(q.avail_in===0&&LV(X)<=LV(V)&&X!==A6)return O6(q,F4);if(K.status===n8&&q.avail_in!==0)return O6(q,F4);if(q.avail_in!==0||K.lookahead!==0||X!==t6&&K.status!==n8){var W=K.strategy===m1?lY(K,X):K.strategy===OY?fY(K,X):b5[K.level].func(K,X);if(W===o6||W===m5)K.status=n8;if(W===h0||W===o6){if(q.avail_out===0)K.last_flush=-1;return b2}if(W===r8){if(X===LY)H2._tr_align(K);else if(X!==EV){if(H2._tr_stored_block(K,0,0,!1),X===BY){if(v6(K.head),K.lookahead===0)K.strstart=0,K.block_start=0,K.insert=0}}if(T6(q),q.avail_out===0)return K.last_flush=-1,b2}}if(X!==A6)return b2;if(K.wrap<=0)return jV;if(K.wrap===2)U0(K,q.adler&255),U0(K,q.adler>>8&255),U0(K,q.adler>>16&255),U0(K,q.adler>>24&255),U0(K,q.total_in&255),U0(K,q.total_in>>8&255),U0(K,q.total_in>>16&255),U0(K,q.total_in>>24&255);else d8(K,q.adler>>>16),d8(K,q.adler&65535);if(T6(q),K.wrap>0)K.wrap=-K.wrap;return K.pending!==0?b2:jV}function rY(q){var X;if(!q||!q.state)return U2;if(X=q.state.status,X!==p1&&X!==u4&&X!==f1&&X!==l1&&X!==_1&&X!==a6&&X!==n8)return O6(q,U2);return q.state=null,X===a6?O6(q,TY):b2}function iY(q,X){var V=X.length,K,Q,Y,J,G,W,Z,H;if(!q||!q.state)return U2;if(K=q.state,J=K.wrap,J===2||J===1&&K.status!==p1||K.lookahead)return U2;if(J===1)q.adler=BV(q.adler,X,V,0);if(K.wrap=0,V>=K.w_size){if(J===0)v6(K.head),K.strstart=0,K.block_start=0,K.insert=0;H=new i0.Buf8(K.w_size),i0.arraySet(H,X,V-K.w_size,K.w_size,0),X=H,V=K.w_size}G=q.avail_in,W=q.next_in,Z=q.input,q.avail_in=V,q.next_in=0,q.input=X,s6(K);while(K.lookahead>=H0){Q=K.strstart,Y=K.lookahead-(H0-1);do K.ins_h=(K.ins_h<{var d1=t2(),wV=!0,NV=!0;try{String.fromCharCode.apply(null,[0])}catch(q){wV=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(q){NV=!1}var i8=new d1.Buf8(256);for(f2=0;f2<256;f2++)i8[f2]=f2>=252?6:f2>=248?5:f2>=240?4:f2>=224?3:f2>=192?2:1;var f2;i8[254]=i8[254]=1;f5.string2buf=function(q){var X,V,K,Q,Y,J=q.length,G=0;for(Q=0;Q>>6,X[Y++]=128|V&63;else if(V<65536)X[Y++]=224|V>>>12,X[Y++]=128|V>>>6&63,X[Y++]=128|V&63;else X[Y++]=240|V>>>18,X[Y++]=128|V>>>12&63,X[Y++]=128|V>>>6&63,X[Y++]=128|V&63}return X};function SV(q,X){if(X<65534){if(q.subarray&&NV||!q.subarray&&wV)return String.fromCharCode.apply(null,d1.shrinkBuf(q,X))}var V="";for(var K=0;K4){G[K++]=65533,V+=Y-1;continue}Q&=Y===2?31:Y===3?15:7;while(Y>1&&V1){G[K++]=65533;continue}if(Q<65536)G[K++]=Q;else Q-=65536,G[K++]=55296|Q>>10&1023,G[K++]=56320|Q&1023}return SV(G,K)};f5.utf8border=function(q,X){var V;if(X=X||q.length,X>q.length)X=q.length;V=X-1;while(V>=0&&(q[V]&192)===128)V--;if(V<0)return X;if(V===0)return X;return V+i8[q[V]]>X?V:X}});var x4=g0((KW,yV)=>{function aY(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}yV.exports=aY});var FV=g0((s8)=>{var a8=AV(),o8=t2(),m4=g4(),f4=b1(),oY=x4(),hV=Object.prototype.toString,sY=0,b4=4,l5=0,$V=1,CV=2,tY=-1,eY=0,qJ=8;function e6(q){if(!(this instanceof e6))return new e6(q);this.options=o8.assign({level:tY,method:qJ,chunkSize:16384,windowBits:15,memLevel:8,strategy:eY,to:""},q||{});var X=this.options;if(X.raw&&X.windowBits>0)X.windowBits=-X.windowBits;else if(X.gzip&&X.windowBits>0&&X.windowBits<16)X.windowBits+=16;this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new oY,this.strm.avail_out=0;var V=a8.deflateInit2(this.strm,X.level,X.method,X.windowBits,X.memLevel,X.strategy);if(V!==l5)throw Error(f4[V]);if(X.header)a8.deflateSetHeader(this.strm,X.header);if(X.dictionary){var K;if(typeof X.dictionary==="string")K=m4.string2buf(X.dictionary);else if(hV.call(X.dictionary)==="[object ArrayBuffer]")K=new Uint8Array(X.dictionary);else K=X.dictionary;if(V=a8.deflateSetDictionary(this.strm,K),V!==l5)throw Error(f4[V]);this._dict_set=!0}}e6.prototype.push=function(q,X){var V=this.strm,K=this.options.chunkSize,Q,Y;if(this.ended)return!1;if(Y=X===~~X?X:X===!0?b4:sY,typeof q==="string")V.input=m4.string2buf(q);else if(hV.call(q)==="[object ArrayBuffer]")V.input=new Uint8Array(q);else V.input=q;V.next_in=0,V.avail_in=V.input.length;do{if(V.avail_out===0)V.output=new o8.Buf8(K),V.next_out=0,V.avail_out=K;if(Q=a8.deflate(V,Y),Q!==$V&&Q!==l5)return this.onEnd(Q),this.ended=!0,!1;if(V.avail_out===0||V.avail_in===0&&(Y===b4||Y===CV))if(this.options.to==="string")this.onData(m4.buf2binstring(o8.shrinkBuf(V.output,V.next_out)));else this.onData(o8.shrinkBuf(V.output,V.next_out))}while((V.avail_in>0||V.avail_out===0)&&Q!==$V);if(Y===b4)return Q=a8.deflateEnd(this.strm),this.onEnd(Q),this.ended=!0,Q===l5;if(Y===CV)return this.onEnd(l5),V.avail_out=0,!0;return!0};e6.prototype.onData=function(q){this.chunks.push(q)};e6.prototype.onEnd=function(q){if(q===l5)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=o8.flattenChunks(this.chunks);this.chunks=[],this.err=q,this.msg=this.strm.msg};function l4(q,X){var V=new e6(X);if(V.push(q,!0),V.err)throw V.msg||f4[V.err];return V.result}function XJ(q,X){return X=X||{},X.raw=!0,l4(q,X)}function VJ(q,X){return X=X||{},X.gzip=!0,l4(q,X)}s8.Deflate=e6;s8.deflate=l4;s8.deflateRaw=XJ;s8.gzip=VJ});var DV=g0((YW,PV)=>{var n1=30,KJ=12;PV.exports=function(X,V){var K,Q,Y,J,G,W,Z,H,U,z,k,M,j,B,L,O,N,R,v,A,$,S,h,b,C;K=X.state,Q=X.next_in,b=X.input,Y=Q+(X.avail_in-5),J=X.next_out,C=X.output,G=J-(V-X.avail_out),W=J+(X.avail_out-257),Z=K.dmax,H=K.wsize,U=K.whave,z=K.wnext,k=K.window,M=K.hold,j=K.bits,B=K.lencode,L=K.distcode,O=(1<>>24,M>>>=v,j-=v,v=R>>>16&255,v===0)C[J++]=R&65535;else if(v&16){if(A=R&65535,v&=15,v){if(j>>=v,j-=v}if(j<15)M+=b[Q++]<>>24,M>>>=v,j-=v,v=R>>>16&255,v&16){if($=R&65535,v&=15,jZ){X.msg="invalid distance too far back",K.mode=n1;break q}if(M>>>=v,j-=v,v=J-G,$>v){if(v=$-v,v>U){if(K.sane){X.msg="invalid distance too far back",K.mode=n1;break q}}if(S=0,h=k,z===0){if(S+=H-v,v2)C[J++]=h[S++],C[J++]=h[S++],C[J++]=h[S++],A-=3;if(A){if(C[J++]=h[S++],A>1)C[J++]=h[S++]}}else{S=J-$;do C[J++]=C[S++],C[J++]=C[S++],C[J++]=C[S++],A-=3;while(A>2);if(A){if(C[J++]=C[S++],A>1)C[J++]=C[S++]}}}else if((v&64)===0){R=L[(R&65535)+(M&(1<>3,Q-=A,j-=A<<3,M&=(1<{var uV=t2(),_5=15,gV=852,xV=592,bV=0,_4=1,mV=2,QJ=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],YJ=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],JJ=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],GJ=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];fV.exports=function(X,V,K,Q,Y,J,G,W){var Z=W.bits,H=0,U=0,z=0,k=0,M=0,j=0,B=0,L=0,O=0,N=0,R,v,A,$,S,h=null,b=0,C,D=new uV.Buf16(_5+1),l=new uV.Buf16(_5+1),u=null,q0=0,J0,r,I0;for(H=0;H<=_5;H++)D[H]=0;for(U=0;U=1;k--)if(D[k]!==0)break;if(M>k)M=k;if(k===0)return Y[J++]=20971520,Y[J++]=20971520,W.bits=1,0;for(z=1;z0&&(X===bV||k!==1))return-1;l[1]=0;for(H=1;H<_5;H++)l[H+1]=l[H]+D[H];for(U=0;UgV||X===mV&&O>xV)return 1;for(;;){if(J0=H-B,G[U]C)r=u[q0+G[U]],I0=h[b+G[U]];else r=96,I0=0;R=1<>B)+v]=J0<<24|r<<16|I0|0;while(v!==0);R=1<>=1;if(R!==0)N&=R-1,N+=R;else N=0;if(U++,--D[H]===0){if(H===k)break;H=V[K+G[U]]}if(H>M&&(N&$)!==A){if(B===0)B=M;S+=z,j=H-B,L=1<gV||X===mV&&O>xV)return 1;A=N&$,Y[A]=M<<24|j<<16|S-J|0}}if(N!==0)Y[S+N]=H-B<<24|4194304|0;return W.bits=M,0}});var R9=g0((A2)=>{var Q2=t2(),i4=C4(),l2=h4(),ZJ=DV(),t8=lV(),WJ=0,M9=1,k9=2,_V=4,HJ=5,r1=6,q5=0,UJ=1,zJ=2,z2=-2,I9=-3,a4=-4,MJ=-5,cV=8,E9=1,pV=2,dV=3,nV=4,rV=5,iV=6,aV=7,oV=8,sV=9,tV=10,o1=11,q6=12,c4=13,eV=14,p4=15,q9=16,X9=17,V9=18,K9=19,i1=20,a1=21,Q9=22,Y9=23,J9=24,G9=25,Z9=26,d4=27,W9=28,H9=29,L0=30,o4=31,kJ=32,IJ=852,EJ=592,jJ=15,LJ=jJ;function U9(q){return(q>>>24&255)+(q>>>8&65280)+((q&65280)<<8)+((q&255)<<24)}function BJ(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Q2.Buf16(320),this.work=new Q2.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function j9(q){var X;if(!q||!q.state)return z2;if(X=q.state,q.total_in=q.total_out=X.total=0,q.msg="",X.wrap)q.adler=X.wrap&1;return X.mode=E9,X.last=0,X.havedict=0,X.dmax=32768,X.head=null,X.hold=0,X.bits=0,X.lencode=X.lendyn=new Q2.Buf32(IJ),X.distcode=X.distdyn=new Q2.Buf32(EJ),X.sane=1,X.back=-1,q5}function L9(q){var X;if(!q||!q.state)return z2;return X=q.state,X.wsize=0,X.whave=0,X.wnext=0,j9(q)}function B9(q,X){var V,K;if(!q||!q.state)return z2;if(K=q.state,X<0)V=0,X=-X;else if(V=(X>>4)+1,X<48)X&=15;if(X&&(X<8||X>15))return z2;if(K.window!==null&&K.wbits!==X)K.window=null;return K.wrap=V,K.wbits=X,L9(q)}function T9(q,X){var V,K;if(!q)return z2;if(K=new BJ,q.state=K,K.window=null,V=B9(q,X),V!==q5)q.state=null;return V}function TJ(q){return T9(q,LJ)}var z9=!0,n4,r4;function vJ(q){if(z9){var X;n4=new Q2.Buf32(512),r4=new Q2.Buf32(32),X=0;while(X<144)q.lens[X++]=8;while(X<256)q.lens[X++]=9;while(X<280)q.lens[X++]=7;while(X<288)q.lens[X++]=8;t8(M9,q.lens,0,288,n4,0,q.work,{bits:9}),X=0;while(X<32)q.lens[X++]=5;t8(k9,q.lens,0,32,r4,0,q.work,{bits:5}),z9=!1}q.lencode=n4,q.lenbits=9,q.distcode=r4,q.distbits=5}function v9(q,X,V,K){var Q,Y=q.state;if(Y.window===null)Y.wsize=1<=Y.wsize)Q2.arraySet(Y.window,X,V-Y.wsize,Y.wsize,0),Y.wnext=0,Y.whave=Y.wsize;else{if(Q=Y.wsize-Y.wnext,Q>K)Q=K;if(Q2.arraySet(Y.window,X,V-K,Q,Y.wnext),K-=Q,K)Q2.arraySet(Y.window,X,V-K,K,0),Y.wnext=K,Y.whave=Y.wsize;else{if(Y.wnext+=Q,Y.wnext===Y.wsize)Y.wnext=0;if(Y.whave>>8&255,V.check=l2(V.check,h,2,0),Z=0,H=0,V.mode=pV;break}if(V.flags=0,V.head)V.head.done=!1;if(!(V.wrap&1)||(((Z&255)<<8)+(Z>>8))%31){q.msg="incorrect header check",V.mode=L0;break}if((Z&15)!==cV){q.msg="unknown compression method",V.mode=L0;break}if(Z>>>=4,H-=4,$=(Z&15)+8,V.wbits===0)V.wbits=$;else if($>V.wbits){q.msg="invalid window size",V.mode=L0;break}V.dmax=1<<$,q.adler=V.check=1,V.mode=Z&512?tV:q6,Z=0,H=0;break;case pV:while(H<16){if(G===0)break q;G--,Z+=K[Y++]<>8&1;if(V.flags&512)h[0]=Z&255,h[1]=Z>>>8&255,V.check=l2(V.check,h,2,0);Z=0,H=0,V.mode=dV;case dV:while(H<32){if(G===0)break q;G--,Z+=K[Y++]<>>8&255,h[2]=Z>>>16&255,h[3]=Z>>>24&255,V.check=l2(V.check,h,4,0);Z=0,H=0,V.mode=nV;case nV:while(H<16){if(G===0)break q;G--,Z+=K[Y++]<>8;if(V.flags&512)h[0]=Z&255,h[1]=Z>>>8&255,V.check=l2(V.check,h,2,0);Z=0,H=0,V.mode=rV;case rV:if(V.flags&1024){while(H<16){if(G===0)break q;G--,Z+=K[Y++]<>>8&255,V.check=l2(V.check,h,2,0);Z=0,H=0}else if(V.head)V.head.extra=null;V.mode=iV;case iV:if(V.flags&1024){if(k=V.length,k>G)k=G;if(k){if(V.head){if($=V.head.extra_len-V.length,!V.head.extra)V.head.extra=Array(V.head.extra_len);Q2.arraySet(V.head.extra,K,Y,k,$)}if(V.flags&512)V.check=l2(V.check,K,k,Y);G-=k,Y+=k,V.length-=k}if(V.length)break q}V.length=0,V.mode=aV;case aV:if(V.flags&2048){if(G===0)break q;k=0;do if($=K[Y+k++],V.head&&$&&V.length<65536)V.head.name+=String.fromCharCode($);while($&&k>9&1,V.head.done=!0;q.adler=V.check=0,V.mode=q6;break;case tV:while(H<32){if(G===0)break q;G--,Z+=K[Y++]<>>=H&7,H-=H&7,V.mode=d4;break}while(H<3){if(G===0)break q;G--,Z+=K[Y++]<>>=1,H-=1,Z&3){case 0:V.mode=eV;break;case 1:if(vJ(V),V.mode=i1,X===r1){Z>>>=2,H-=2;break q}break;case 2:V.mode=X9;break;case 3:q.msg="invalid block type",V.mode=L0}Z>>>=2,H-=2;break;case eV:Z>>>=H&7,H-=H&7;while(H<32){if(G===0)break q;G--,Z+=K[Y++]<>>16^65535)){q.msg="invalid stored block lengths",V.mode=L0;break}if(V.length=Z&65535,Z=0,H=0,V.mode=p4,X===r1)break q;case p4:V.mode=q9;case q9:if(k=V.length,k){if(k>G)k=G;if(k>W)k=W;if(k===0)break q;Q2.arraySet(Q,K,Y,k,J),G-=k,Y+=k,W-=k,J+=k,V.length-=k;break}V.mode=q6;break;case X9:while(H<14){if(G===0)break q;G--,Z+=K[Y++]<>>=5,H-=5,V.ndist=(Z&31)+1,Z>>>=5,H-=5,V.ncode=(Z&15)+4,Z>>>=4,H-=4,V.nlen>286||V.ndist>30){q.msg="too many length or distance symbols",V.mode=L0;break}V.have=0,V.mode=V9;case V9:while(V.have>>=3,H-=3}while(V.have<19)V.lens[D[V.have++]]=0;if(V.lencode=V.lendyn,V.lenbits=7,b={bits:V.lenbits},S=t8(WJ,V.lens,0,19,V.lencode,0,V.work,b),V.lenbits=b.bits,S){q.msg="invalid code lengths set",V.mode=L0;break}V.have=0,V.mode=K9;case K9:while(V.have>>24,O=B>>>16&255,N=B&65535,L<=H)break;if(G===0)break q;G--,Z+=K[Y++]<>>=L,H-=L,V.lens[V.have++]=N;else{if(N===16){C=L+2;while(H>>=L,H-=L,V.have===0){q.msg="invalid bit length repeat",V.mode=L0;break}$=V.lens[V.have-1],k=3+(Z&3),Z>>>=2,H-=2}else if(N===17){C=L+3;while(H>>=L,H-=L,$=0,k=3+(Z&7),Z>>>=3,H-=3}else{C=L+7;while(H>>=L,H-=L,$=0,k=11+(Z&127),Z>>>=7,H-=7}if(V.have+k>V.nlen+V.ndist){q.msg="invalid bit length repeat",V.mode=L0;break}while(k--)V.lens[V.have++]=$}}if(V.mode===L0)break;if(V.lens[256]===0){q.msg="invalid code -- missing end-of-block",V.mode=L0;break}if(V.lenbits=9,b={bits:V.lenbits},S=t8(M9,V.lens,0,V.nlen,V.lencode,0,V.work,b),V.lenbits=b.bits,S){q.msg="invalid literal/lengths set",V.mode=L0;break}if(V.distbits=6,V.distcode=V.distdyn,b={bits:V.distbits},S=t8(k9,V.lens,V.nlen,V.ndist,V.distcode,0,V.work,b),V.distbits=b.bits,S){q.msg="invalid distances set",V.mode=L0;break}if(V.mode=i1,X===r1)break q;case i1:V.mode=a1;case a1:if(G>=6&&W>=258){if(q.next_out=J,q.avail_out=W,q.next_in=Y,q.avail_in=G,V.hold=Z,V.bits=H,ZJ(q,z),J=q.next_out,Q=q.output,W=q.avail_out,Y=q.next_in,K=q.input,G=q.avail_in,Z=V.hold,H=V.bits,V.mode===q6)V.back=-1;break}V.back=0;for(;;){if(B=V.lencode[Z&(1<>>24,O=B>>>16&255,N=B&65535,L<=H)break;if(G===0)break q;G--,Z+=K[Y++]<>R)],L=B>>>24,O=B>>>16&255,N=B&65535,R+L<=H)break;if(G===0)break q;G--,Z+=K[Y++]<>>=R,H-=R,V.back+=R}if(Z>>>=L,H-=L,V.back+=L,V.length=N,O===0){V.mode=Z9;break}if(O&32){V.back=-1,V.mode=q6;break}if(O&64){q.msg="invalid literal/length code",V.mode=L0;break}V.extra=O&15,V.mode=Q9;case Q9:if(V.extra){C=V.extra;while(H>>=V.extra,H-=V.extra,V.back+=V.extra}V.was=V.length,V.mode=Y9;case Y9:for(;;){if(B=V.distcode[Z&(1<>>24,O=B>>>16&255,N=B&65535,L<=H)break;if(G===0)break q;G--,Z+=K[Y++]<>R)],L=B>>>24,O=B>>>16&255,N=B&65535,R+L<=H)break;if(G===0)break q;G--,Z+=K[Y++]<>>=R,H-=R,V.back+=R}if(Z>>>=L,H-=L,V.back+=L,O&64){q.msg="invalid distance code",V.mode=L0;break}V.offset=N,V.extra=O&15,V.mode=J9;case J9:if(V.extra){C=V.extra;while(H>>=V.extra,H-=V.extra,V.back+=V.extra}if(V.offset>V.dmax){q.msg="invalid distance too far back",V.mode=L0;break}V.mode=G9;case G9:if(W===0)break q;if(k=z-W,V.offset>k){if(k=V.offset-k,k>V.whave){if(V.sane){q.msg="invalid distance too far back",V.mode=L0;break}}if(k>V.wnext)k-=V.wnext,M=V.wsize-k;else M=V.wnext-k;if(k>V.length)k=V.length;j=V.window}else j=Q,M=J-V.offset,k=V.length;if(k>W)k=W;W-=k,V.length-=k;do Q[J++]=j[M++];while(--k);if(V.length===0)V.mode=a1;break;case Z9:if(W===0)break q;Q[J++]=V.length,W--,V.mode=a1;break;case d4:if(V.wrap){while(H<32){if(G===0)break q;G--,Z|=K[Y++]<{O9.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var w9=g0((WW,A9)=>{function NJ(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}A9.exports=NJ});var S9=g0((q1)=>{var c5=R9(),e8=t2(),s1=g4(),N0=s4(),t4=b1(),SJ=x4(),yJ=w9(),N9=Object.prototype.toString;function X5(q){if(!(this instanceof X5))return new X5(q);this.options=e8.assign({chunkSize:16384,windowBits:0,to:""},q||{});var X=this.options;if(X.raw&&X.windowBits>=0&&X.windowBits<16){if(X.windowBits=-X.windowBits,X.windowBits===0)X.windowBits=-15}if(X.windowBits>=0&&X.windowBits<16&&!(q&&q.windowBits))X.windowBits+=32;if(X.windowBits>15&&X.windowBits<48){if((X.windowBits&15)===0)X.windowBits|=15}this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new SJ,this.strm.avail_out=0;var V=c5.inflateInit2(this.strm,X.windowBits);if(V!==N0.Z_OK)throw Error(t4[V]);if(this.header=new yJ,c5.inflateGetHeader(this.strm,this.header),X.dictionary){if(typeof X.dictionary==="string")X.dictionary=s1.string2buf(X.dictionary);else if(N9.call(X.dictionary)==="[object ArrayBuffer]")X.dictionary=new Uint8Array(X.dictionary);if(X.raw){if(V=c5.inflateSetDictionary(this.strm,X.dictionary),V!==N0.Z_OK)throw Error(t4[V])}}}X5.prototype.push=function(q,X){var V=this.strm,K=this.options.chunkSize,Q=this.options.dictionary,Y,J,G,W,Z,H=!1;if(this.ended)return!1;if(J=X===~~X?X:X===!0?N0.Z_FINISH:N0.Z_NO_FLUSH,typeof q==="string")V.input=s1.binstring2buf(q);else if(N9.call(q)==="[object ArrayBuffer]")V.input=new Uint8Array(q);else V.input=q;V.next_in=0,V.avail_in=V.input.length;do{if(V.avail_out===0)V.output=new e8.Buf8(K),V.next_out=0,V.avail_out=K;if(Y=c5.inflate(V,N0.Z_NO_FLUSH),Y===N0.Z_NEED_DICT&&Q)Y=c5.inflateSetDictionary(this.strm,Q);if(Y===N0.Z_BUF_ERROR&&H===!0)Y=N0.Z_OK,H=!1;if(Y!==N0.Z_STREAM_END&&Y!==N0.Z_OK)return this.onEnd(Y),this.ended=!0,!1;if(V.next_out){if(V.avail_out===0||Y===N0.Z_STREAM_END||V.avail_in===0&&(J===N0.Z_FINISH||J===N0.Z_SYNC_FLUSH))if(this.options.to==="string"){if(G=s1.utf8border(V.output,V.next_out),W=V.next_out-G,Z=s1.buf2string(V.output,G),V.next_out=W,V.avail_out=K-W,W)e8.arraySet(V.output,V.output,G,W,0);this.onData(Z)}else this.onData(e8.shrinkBuf(V.output,V.next_out))}if(V.avail_in===0&&V.avail_out===0)H=!0}while((V.avail_in>0||V.avail_out===0)&&Y!==N0.Z_STREAM_END);if(Y===N0.Z_STREAM_END)J=N0.Z_FINISH;if(J===N0.Z_FINISH)return Y=c5.inflateEnd(this.strm),this.onEnd(Y),this.ended=!0,Y===N0.Z_OK;if(J===N0.Z_SYNC_FLUSH)return this.onEnd(N0.Z_OK),V.avail_out=0,!0;return!0};X5.prototype.onData=function(q){this.chunks.push(q)};X5.prototype.onEnd=function(q){if(q===N0.Z_OK)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=e8.flattenChunks(this.chunks);this.chunks=[],this.err=q,this.msg=this.strm.msg};function e4(q,X){var V=new X5(X);if(V.push(q,!0),V.err)throw V.msg||t4[V.err];return V.result}function $J(q,X){return X=X||{},X.raw=!0,e4(q,X)}q1.Inflate=X5;q1.inflate=e4;q1.inflateRaw=$J;q1.ungzip=e4});var X1=g0((UW,$9)=>{var CJ=t2().assign,hJ=FV(),FJ=S9(),PJ=s4(),y9={};CJ(y9,hJ,FJ,PJ);$9.exports=y9});var zX=globalThis;if(typeof zX.global>"u")zX.global=globalThis;var C2=[],W2=[],lq="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(c6=0,MX=lq.length;c60)throw Error("Invalid string. Length must be a multiple of 4");var V=q.indexOf("=");if(V===-1)V=X;var K=V===X?0:4-V%4;return[V,K]}function VQ(q,X){return(q+X)*3/4-X}function KQ(q){var X,V=XQ(q),K=V[0],Q=V[1],Y=new Uint8Array(VQ(K,Q)),J=0,G=Q>0?K-4:K,W;for(W=0;W>16&255,Y[J++]=X>>8&255,Y[J++]=X&255;if(Q===2)X=W2[q.charCodeAt(W)]<<2|W2[q.charCodeAt(W+1)]>>4,Y[J++]=X&255;if(Q===1)X=W2[q.charCodeAt(W)]<<10|W2[q.charCodeAt(W+1)]<<4|W2[q.charCodeAt(W+2)]>>2,Y[J++]=X>>8&255,Y[J++]=X&255;return Y}function QQ(q){return C2[q>>18&63]+C2[q>>12&63]+C2[q>>6&63]+C2[q&63]}function YQ(q,X,V){var K,Q=[];for(var Y=X;YG?G:J+Y));if(K===1)X=q[V-1],Q.push(C2[X>>2]+C2[X<<4&63]+"==");else if(K===2)X=(q[V-2]<<8)+q[V-1],Q.push(C2[X>>10]+C2[X>>4&63]+C2[X<<2&63]+"=");return Q.join("")}function $1(q,X,V,K,Q){var Y,J,G=Q*8-K-1,W=(1<>1,H=-7,U=V?Q-1:0,z=V?-1:1,k=q[X+U];U+=z,Y=k&(1<<-H)-1,k>>=-H,H+=G;for(;H>0;Y=Y*256+q[X+U],U+=z,H-=8);J=Y&(1<<-H)-1,Y>>=-H,H+=K;for(;H>0;J=J*256+q[X+U],U+=z,H-=8);if(Y===0)Y=1-Z;else if(Y===W)return J?NaN:(k?-1:1)*(1/0);else J=J+Math.pow(2,K),Y=Y-Z;return(k?-1:1)*J*Math.pow(2,Y-K)}function BX(q,X,V,K,Q,Y){var J,G,W,Z=Y*8-Q-1,H=(1<>1,z=Q===23?Math.pow(2,-24)-Math.pow(2,-77):0,k=K?0:Y-1,M=K?1:-1,j=X<0||X===0&&1/X<0?1:0;if(X=Math.abs(X),isNaN(X)||X===1/0)G=isNaN(X)?1:0,J=H;else{if(J=Math.floor(Math.log(X)/Math.LN2),X*(W=Math.pow(2,-J))<1)J--,W*=2;if(J+U>=1)X+=z/W;else X+=z*Math.pow(2,1-U);if(X*W>=2)J++,W/=2;if(J+U>=H)G=0,J=H;else if(J+U>=1)G=(X*W-1)*Math.pow(2,Q),J=J+U;else G=X*Math.pow(2,U-1)*Math.pow(2,Q),J=0}for(;Q>=8;q[V+k]=G&255,k+=M,G/=256,Q-=8);J=J<0;q[V+k]=J&255,k+=M,J/=256,Z-=8);q[V+k-M]|=j*128}var IX=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null,JQ=50,_q=2147483647;var{btoa:$3,atob:C3,File:h3,Blob:F3}=globalThis;function a2(q){if(q>_q)throw RangeError('The value "'+q+'" is invalid for option "size"');let X=new Uint8Array(q);return Object.setPrototypeOf(X,y.prototype),X}function rq(q,X,V){return class extends V{constructor(){super();Object.defineProperty(this,"message",{value:X.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${q}]`,this.stack,delete this.name}get code(){return q}set code(K){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:K,writable:!0})}toString(){return`${this.name} [${q}]: ${this.message}`}}}var GQ=rq("ERR_BUFFER_OUT_OF_BOUNDS",function(q){if(q)return`${q} is outside of buffer bounds`;return"Attempt to access memory outside buffer bounds"},RangeError),ZQ=rq("ERR_INVALID_ARG_TYPE",function(q,X){return`The "${q}" argument must be of type number. Received type ${typeof X}`},TypeError),cq=rq("ERR_OUT_OF_RANGE",function(q,X,V){let K=`The value of "${q}" is out of range.`,Q=V;if(Number.isInteger(V)&&Math.abs(V)>4294967296)Q=LX(String(V));else if(typeof V==="bigint"){if(Q=String(V),V>BigInt(2)**BigInt(32)||V<-(BigInt(2)**BigInt(32)))Q=LX(Q);Q+="n"}return K+=` It must be ${X}. Received ${Q}`,K},RangeError);function y(q,X,V){if(typeof q==="number"){if(typeof X==="string")throw TypeError('The "string" argument must be of type string. Received type number');return iq(q)}return TX(q,X,V)}Object.defineProperty(y.prototype,"parent",{enumerable:!0,get:function(){if(!y.isBuffer(this))return;return this.buffer}});Object.defineProperty(y.prototype,"offset",{enumerable:!0,get:function(){if(!y.isBuffer(this))return;return this.byteOffset}});y.poolSize=8192;function TX(q,X,V){if(typeof q==="string")return HQ(q,X);if(ArrayBuffer.isView(q))return UQ(q);if(q==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof q);if(h2(q,ArrayBuffer)||q&&h2(q.buffer,ArrayBuffer))return dq(q,X,V);if(typeof SharedArrayBuffer<"u"&&(h2(q,SharedArrayBuffer)||q&&h2(q.buffer,SharedArrayBuffer)))return dq(q,X,V);if(typeof q==="number")throw TypeError('The "value" argument must not be of type number. Received type number');let K=q.valueOf&&q.valueOf();if(K!=null&&K!==q)return y.from(K,X,V);let Q=zQ(q);if(Q)return Q;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof q[Symbol.toPrimitive]==="function")return y.from(q[Symbol.toPrimitive]("string"),X,V);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof q)}y.from=function(q,X,V){return TX(q,X,V)};Object.setPrototypeOf(y.prototype,Uint8Array.prototype);Object.setPrototypeOf(y,Uint8Array);function vX(q){if(typeof q!=="number")throw TypeError('"size" argument must be of type number');else if(q<0)throw RangeError('The value "'+q+'" is invalid for option "size"')}function WQ(q,X,V){if(vX(q),q<=0)return a2(q);if(X!==void 0)return typeof V==="string"?a2(q).fill(X,V):a2(q).fill(X);return a2(q)}y.alloc=function(q,X,V){return WQ(q,X,V)};function iq(q){return vX(q),a2(q<0?0:aq(q)|0)}y.allocUnsafe=function(q){return iq(q)};y.allocUnsafeSlow=function(q){return iq(q)};function HQ(q,X){if(typeof X!=="string"||X==="")X="utf8";if(!y.isEncoding(X))throw TypeError("Unknown encoding: "+X);let V=RX(q,X)|0,K=a2(V),Q=K.write(q,X);if(Q!==V)K=K.slice(0,Q);return K}function pq(q){let X=q.length<0?0:aq(q.length)|0,V=a2(X);for(let K=0;K=_q)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+_q.toString(16)+" bytes");return q|0}y.isBuffer=function(q){return q!=null&&q._isBuffer===!0&&q!==y.prototype};y.compare=function(q,X){if(h2(q,Uint8Array))q=y.from(q,q.offset,q.byteLength);if(h2(X,Uint8Array))X=y.from(X,X.offset,X.byteLength);if(!y.isBuffer(q)||!y.isBuffer(X))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(q===X)return 0;let V=q.length,K=X.length;for(let Q=0,Y=Math.min(V,K);QK.length){if(!y.isBuffer(Y))Y=y.from(Y);Y.copy(K,Q)}else Uint8Array.prototype.set.call(K,Y,Q);else if(!y.isBuffer(Y))throw TypeError('"list" argument must be an Array of Buffers');else Y.copy(K,Q);Q+=Y.length}return K};function RX(q,X){if(y.isBuffer(q))return q.length;if(ArrayBuffer.isView(q)||h2(q,ArrayBuffer))return q.byteLength;if(typeof q!=="string")throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof q);let V=q.length,K=arguments.length>2&&arguments[2]===!0;if(!K&&V===0)return 0;let Q=!1;for(;;)switch(X){case"ascii":case"latin1":case"binary":return V;case"utf8":case"utf-8":return nq(q).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return V*2;case"hex":return V>>>1;case"base64":return hX(q).length;default:if(Q)return K?-1:nq(q).length;X=(""+X).toLowerCase(),Q=!0}}y.byteLength=RX;function MQ(q,X,V){let K=!1;if(X===void 0||X<0)X=0;if(X>this.length)return"";if(V===void 0||V>this.length)V=this.length;if(V<=0)return"";if(V>>>=0,X>>>=0,V<=X)return"";if(!q)q="utf8";while(!0)switch(q){case"hex":return OQ(this,X,V);case"utf8":case"utf-8":return AX(this,X,V);case"ascii":return vQ(this,X,V);case"latin1":case"binary":return RQ(this,X,V);case"base64":return BQ(this,X,V);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return AQ(this,X,V);default:if(K)throw TypeError("Unknown encoding: "+q);q=(q+"").toLowerCase(),K=!0}}y.prototype._isBuffer=!0;function p6(q,X,V){let K=q[X];q[X]=q[V],q[V]=K}y.prototype.swap16=function(){let q=this.length;if(q%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let X=0;XX)q+=" ... ";return""};if(IX)y.prototype[IX]=y.prototype.inspect;y.prototype.compare=function(q,X,V,K,Q){if(h2(q,Uint8Array))q=y.from(q,q.offset,q.byteLength);if(!y.isBuffer(q))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof q);if(X===void 0)X=0;if(V===void 0)V=q?q.length:0;if(K===void 0)K=0;if(Q===void 0)Q=this.length;if(X<0||V>q.length||K<0||Q>this.length)throw RangeError("out of range index");if(K>=Q&&X>=V)return 0;if(K>=Q)return-1;if(X>=V)return 1;if(X>>>=0,V>>>=0,K>>>=0,Q>>>=0,this===q)return 0;let Y=Q-K,J=V-X,G=Math.min(Y,J),W=this.slice(K,Q),Z=q.slice(X,V);for(let H=0;H2147483647)V=2147483647;else if(V<-2147483648)V=-2147483648;if(V=+V,Number.isNaN(V))V=Q?0:q.length-1;if(V<0)V=q.length+V;if(V>=q.length)if(Q)return-1;else V=q.length-1;else if(V<0)if(Q)V=0;else return-1;if(typeof X==="string")X=y.from(X,K);if(y.isBuffer(X)){if(X.length===0)return-1;return EX(q,X,V,K,Q)}else if(typeof X==="number"){if(X=X&255,typeof Uint8Array.prototype.indexOf==="function")if(Q)return Uint8Array.prototype.indexOf.call(q,X,V);else return Uint8Array.prototype.lastIndexOf.call(q,X,V);return EX(q,[X],V,K,Q)}throw TypeError("val must be string, number or Buffer")}function EX(q,X,V,K,Q){let Y=1,J=q.length,G=X.length;if(K!==void 0){if(K=String(K).toLowerCase(),K==="ucs2"||K==="ucs-2"||K==="utf16le"||K==="utf-16le"){if(q.length<2||X.length<2)return-1;Y=2,J/=2,G/=2,V/=2}}function W(H,U){if(Y===1)return H[U];else return H.readUInt16BE(U*Y)}let Z;if(Q){let H=-1;for(Z=V;ZJ)V=J-G;for(Z=V;Z>=0;Z--){let H=!0;for(let U=0;UQ)K=Q;let Y=X.length;if(K>Y/2)K=Y/2;let J;for(J=0;J>>0,isFinite(V)){if(V=V>>>0,K===void 0)K="utf8"}else K=V,V=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let Q=this.length-X;if(V===void 0||V>Q)V=Q;if(q.length>0&&(V<0||X<0)||X>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!K)K="utf8";let Y=!1;for(;;)switch(K){case"hex":return kQ(this,q,X,V);case"utf8":case"utf-8":return IQ(this,q,X,V);case"ascii":case"latin1":case"binary":return EQ(this,q,X,V);case"base64":return jQ(this,q,X,V);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return LQ(this,q,X,V);default:if(Y)throw TypeError("Unknown encoding: "+K);K=(""+K).toLowerCase(),Y=!0}};y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function BQ(q,X,V){if(X===0&&V===q.length)return kX(q);else return kX(q.slice(X,V))}function AX(q,X,V){V=Math.min(q.length,V);let K=[],Q=X;while(Q239?4:Y>223?3:Y>191?2:1;if(Q+G<=V){let W,Z,H,U;switch(G){case 1:if(Y<128)J=Y;break;case 2:if(W=q[Q+1],(W&192)===128){if(U=(Y&31)<<6|W&63,U>127)J=U}break;case 3:if(W=q[Q+1],Z=q[Q+2],(W&192)===128&&(Z&192)===128){if(U=(Y&15)<<12|(W&63)<<6|Z&63,U>2047&&(U<55296||U>57343))J=U}break;case 4:if(W=q[Q+1],Z=q[Q+2],H=q[Q+3],(W&192)===128&&(Z&192)===128&&(H&192)===128){if(U=(Y&15)<<18|(W&63)<<12|(Z&63)<<6|H&63,U>65535&&U<1114112)J=U}}}if(J===null)J=65533,G=1;else if(J>65535)J-=65536,K.push(J>>>10&1023|55296),J=56320|J&1023;K.push(J),Q+=G}return TQ(K)}var jX=4096;function TQ(q){let X=q.length;if(X<=jX)return String.fromCharCode.apply(String,q);let V="",K=0;while(KK)V=K;let Q="";for(let Y=X;YV)q=V;if(X<0){if(X+=V,X<0)X=0}else if(X>V)X=V;if(XV)throw RangeError("Trying to access beyond buffer length")}y.prototype.readUintLE=y.prototype.readUIntLE=function(q,X,V){if(q=q>>>0,X=X>>>0,!V)D0(q,X,this.length);let K=this[q],Q=1,Y=0;while(++Y>>0,X=X>>>0,!V)D0(q,X,this.length);let K=this[q+--X],Q=1;while(X>0&&(Q*=256))K+=this[q+--X]*Q;return K};y.prototype.readUint8=y.prototype.readUInt8=function(q,X){if(q=q>>>0,!X)D0(q,1,this.length);return this[q]};y.prototype.readUint16LE=y.prototype.readUInt16LE=function(q,X){if(q=q>>>0,!X)D0(q,2,this.length);return this[q]|this[q+1]<<8};y.prototype.readUint16BE=y.prototype.readUInt16BE=function(q,X){if(q=q>>>0,!X)D0(q,2,this.length);return this[q]<<8|this[q+1]};y.prototype.readUint32LE=y.prototype.readUInt32LE=function(q,X){if(q=q>>>0,!X)D0(q,4,this.length);return(this[q]|this[q+1]<<8|this[q+2]<<16)+this[q+3]*16777216};y.prototype.readUint32BE=y.prototype.readUInt32BE=function(q,X){if(q=q>>>0,!X)D0(q,4,this.length);return this[q]*16777216+(this[q+1]<<16|this[q+2]<<8|this[q+3])};y.prototype.readBigUInt64LE=M6(function(q){q=q>>>0,y5(q,"offset");let X=this[q],V=this[q+7];if(X===void 0||V===void 0)C8(q,this.length-8);let K=X+this[++q]*256+this[++q]*65536+this[++q]*16777216,Q=this[++q]+this[++q]*256+this[++q]*65536+V*16777216;return BigInt(K)+(BigInt(Q)<>>0,y5(q,"offset");let X=this[q],V=this[q+7];if(X===void 0||V===void 0)C8(q,this.length-8);let K=X*16777216+this[++q]*65536+this[++q]*256+this[++q],Q=this[++q]*16777216+this[++q]*65536+this[++q]*256+V;return(BigInt(K)<>>0,X=X>>>0,!V)D0(q,X,this.length);let K=this[q],Q=1,Y=0;while(++Y=Q)K-=Math.pow(2,8*X);return K};y.prototype.readIntBE=function(q,X,V){if(q=q>>>0,X=X>>>0,!V)D0(q,X,this.length);let K=X,Q=1,Y=this[q+--K];while(K>0&&(Q*=256))Y+=this[q+--K]*Q;if(Q*=128,Y>=Q)Y-=Math.pow(2,8*X);return Y};y.prototype.readInt8=function(q,X){if(q=q>>>0,!X)D0(q,1,this.length);if(!(this[q]&128))return this[q];return(255-this[q]+1)*-1};y.prototype.readInt16LE=function(q,X){if(q=q>>>0,!X)D0(q,2,this.length);let V=this[q]|this[q+1]<<8;return V&32768?V|4294901760:V};y.prototype.readInt16BE=function(q,X){if(q=q>>>0,!X)D0(q,2,this.length);let V=this[q+1]|this[q]<<8;return V&32768?V|4294901760:V};y.prototype.readInt32LE=function(q,X){if(q=q>>>0,!X)D0(q,4,this.length);return this[q]|this[q+1]<<8|this[q+2]<<16|this[q+3]<<24};y.prototype.readInt32BE=function(q,X){if(q=q>>>0,!X)D0(q,4,this.length);return this[q]<<24|this[q+1]<<16|this[q+2]<<8|this[q+3]};y.prototype.readBigInt64LE=M6(function(q){q=q>>>0,y5(q,"offset");let X=this[q],V=this[q+7];if(X===void 0||V===void 0)C8(q,this.length-8);let K=this[q+4]+this[q+5]*256+this[q+6]*65536+(V<<24);return(BigInt(K)<>>0,y5(q,"offset");let X=this[q],V=this[q+7];if(X===void 0||V===void 0)C8(q,this.length-8);let K=(X<<24)+this[++q]*65536+this[++q]*256+this[++q];return(BigInt(K)<>>0,!X)D0(q,4,this.length);return $1(this,q,!0,23,4)};y.prototype.readFloatBE=function(q,X){if(q=q>>>0,!X)D0(q,4,this.length);return $1(this,q,!1,23,4)};y.prototype.readDoubleLE=function(q,X){if(q=q>>>0,!X)D0(q,8,this.length);return $1(this,q,!0,52,8)};y.prototype.readDoubleBE=function(q,X){if(q=q>>>0,!X)D0(q,8,this.length);return $1(this,q,!1,52,8)};function s0(q,X,V,K,Q,Y){if(!y.isBuffer(q))throw TypeError('"buffer" argument must be a Buffer instance');if(X>Q||Xq.length)throw RangeError("Index out of range")}y.prototype.writeUintLE=y.prototype.writeUIntLE=function(q,X,V,K){if(q=+q,X=X>>>0,V=V>>>0,!K){let J=Math.pow(2,8*V)-1;s0(this,q,X,V,J,0)}let Q=1,Y=0;this[X]=q&255;while(++Y>>0,V=V>>>0,!K){let J=Math.pow(2,8*V)-1;s0(this,q,X,V,J,0)}let Q=V-1,Y=1;this[X+Q]=q&255;while(--Q>=0&&(Y*=256))this[X+Q]=q/Y&255;return X+V};y.prototype.writeUint8=y.prototype.writeUInt8=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,1,255,0);return this[X]=q&255,X+1};y.prototype.writeUint16LE=y.prototype.writeUInt16LE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,2,65535,0);return this[X]=q&255,this[X+1]=q>>>8,X+2};y.prototype.writeUint16BE=y.prototype.writeUInt16BE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,2,65535,0);return this[X]=q>>>8,this[X+1]=q&255,X+2};y.prototype.writeUint32LE=y.prototype.writeUInt32LE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,4,4294967295,0);return this[X+3]=q>>>24,this[X+2]=q>>>16,this[X+1]=q>>>8,this[X]=q&255,X+4};y.prototype.writeUint32BE=y.prototype.writeUInt32BE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,4,4294967295,0);return this[X]=q>>>24,this[X+1]=q>>>16,this[X+2]=q>>>8,this[X+3]=q&255,X+4};function wX(q,X,V,K,Q){CX(X,K,Q,q,V,7);let Y=Number(X&BigInt(4294967295));q[V++]=Y,Y=Y>>8,q[V++]=Y,Y=Y>>8,q[V++]=Y,Y=Y>>8,q[V++]=Y;let J=Number(X>>BigInt(32)&BigInt(4294967295));return q[V++]=J,J=J>>8,q[V++]=J,J=J>>8,q[V++]=J,J=J>>8,q[V++]=J,V}function NX(q,X,V,K,Q){CX(X,K,Q,q,V,7);let Y=Number(X&BigInt(4294967295));q[V+7]=Y,Y=Y>>8,q[V+6]=Y,Y=Y>>8,q[V+5]=Y,Y=Y>>8,q[V+4]=Y;let J=Number(X>>BigInt(32)&BigInt(4294967295));return q[V+3]=J,J=J>>8,q[V+2]=J,J=J>>8,q[V+1]=J,J=J>>8,q[V]=J,V+8}y.prototype.writeBigUInt64LE=M6(function(q,X=0){return wX(this,q,X,BigInt(0),BigInt("0xffffffffffffffff"))});y.prototype.writeBigUInt64BE=M6(function(q,X=0){return NX(this,q,X,BigInt(0),BigInt("0xffffffffffffffff"))});y.prototype.writeIntLE=function(q,X,V,K){if(q=+q,X=X>>>0,!K){let G=Math.pow(2,8*V-1);s0(this,q,X,V,G-1,-G)}let Q=0,Y=1,J=0;this[X]=q&255;while(++Q>0)-J&255}return X+V};y.prototype.writeIntBE=function(q,X,V,K){if(q=+q,X=X>>>0,!K){let G=Math.pow(2,8*V-1);s0(this,q,X,V,G-1,-G)}let Q=V-1,Y=1,J=0;this[X+Q]=q&255;while(--Q>=0&&(Y*=256)){if(q<0&&J===0&&this[X+Q+1]!==0)J=1;this[X+Q]=(q/Y>>0)-J&255}return X+V};y.prototype.writeInt8=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,1,127,-128);if(q<0)q=255+q+1;return this[X]=q&255,X+1};y.prototype.writeInt16LE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,2,32767,-32768);return this[X]=q&255,this[X+1]=q>>>8,X+2};y.prototype.writeInt16BE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,2,32767,-32768);return this[X]=q>>>8,this[X+1]=q&255,X+2};y.prototype.writeInt32LE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,4,2147483647,-2147483648);return this[X]=q&255,this[X+1]=q>>>8,this[X+2]=q>>>16,this[X+3]=q>>>24,X+4};y.prototype.writeInt32BE=function(q,X,V){if(q=+q,X=X>>>0,!V)s0(this,q,X,4,2147483647,-2147483648);if(q<0)q=4294967295+q+1;return this[X]=q>>>24,this[X+1]=q>>>16,this[X+2]=q>>>8,this[X+3]=q&255,X+4};y.prototype.writeBigInt64LE=M6(function(q,X=0){return wX(this,q,X,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});y.prototype.writeBigInt64BE=M6(function(q,X=0){return NX(this,q,X,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function SX(q,X,V,K,Q,Y){if(V+K>q.length)throw RangeError("Index out of range");if(V<0)throw RangeError("Index out of range")}function yX(q,X,V,K,Q){if(X=+X,V=V>>>0,!Q)SX(q,X,V,4,340282346638528860000000000000000000000,-340282346638528860000000000000000000000);return BX(q,X,V,K,23,4),V+4}y.prototype.writeFloatLE=function(q,X,V){return yX(this,q,X,!0,V)};y.prototype.writeFloatBE=function(q,X,V){return yX(this,q,X,!1,V)};function $X(q,X,V,K,Q){if(X=+X,V=V>>>0,!Q)SX(q,X,V,8,179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);return BX(q,X,V,K,52,8),V+8}y.prototype.writeDoubleLE=function(q,X,V){return $X(this,q,X,!0,V)};y.prototype.writeDoubleBE=function(q,X,V){return $X(this,q,X,!1,V)};y.prototype.copy=function(q,X,V,K){if(!y.isBuffer(q))throw TypeError("argument should be a Buffer");if(!V)V=0;if(!K&&K!==0)K=this.length;if(X>=q.length)X=q.length;if(!X)X=0;if(K>0&&K=this.length)throw RangeError("Index out of range");if(K<0)throw RangeError("sourceEnd out of bounds");if(K>this.length)K=this.length;if(q.length-X>>0,V=V===void 0?this.length:V>>>0,!q)q=0;let Q;if(typeof q==="number")for(Q=X;Q=K+4;V-=3)X=`_${q.slice(V-3,V)}${X}`;return`${q.slice(0,V)}${X}`}function wQ(q,X,V){if(y5(X,"offset"),q[X]===void 0||q[X+V]===void 0)C8(X,q.length-(V+1))}function CX(q,X,V,K,Q,Y){if(q>V||q3)if(X===0||X===BigInt(0))G=`>= 0${J} and < 2${J} ** ${(Y+1)*8}${J}`;else G=`>= -(2${J} ** ${(Y+1)*8-1}${J}) and < 2 ** ${(Y+1)*8-1}${J}`;else G=`>= ${X}${J} and <= ${V}${J}`;throw new cq("value",G,q)}wQ(K,Q,Y)}function y5(q,X){if(typeof q!=="number")throw new ZQ(X,"number",q)}function C8(q,X,V){if(Math.floor(q)!==q)throw y5(q,V),new cq(V||"offset","an integer",q);if(X<0)throw new GQ;throw new cq(V||"offset",`>= ${V?1:0} and <= ${X}`,q)}var NQ=/[^+/0-9A-Za-z-_]/g;function SQ(q){if(q=q.split("=")[0],q=q.trim().replace(NQ,""),q.length<2)return"";while(q.length%4!==0)q=q+"=";return q}function nq(q,X){X=X||1/0;let V,K=q.length,Q=null,Y=[];for(let J=0;J55295&&V<57344){if(!Q){if(V>56319){if((X-=3)>-1)Y.push(239,191,189);continue}else if(J+1===K){if((X-=3)>-1)Y.push(239,191,189);continue}Q=V;continue}if(V<56320){if((X-=3)>-1)Y.push(239,191,189);Q=V;continue}V=(Q-55296<<10|V-56320)+65536}else if(Q){if((X-=3)>-1)Y.push(239,191,189)}if(Q=null,V<128){if((X-=1)<0)break;Y.push(V)}else if(V<2048){if((X-=2)<0)break;Y.push(V>>6|192,V&63|128)}else if(V<65536){if((X-=3)<0)break;Y.push(V>>12|224,V>>6&63|128,V&63|128)}else if(V<1114112){if((X-=4)<0)break;Y.push(V>>18|240,V>>12&63|128,V>>6&63|128,V&63|128)}else throw Error("Invalid code point")}return Y}function yQ(q){let X=[];for(let V=0;V>8,Q=V%256,Y.push(Q),Y.push(K)}return Y}function hX(q){return KQ(SQ(q))}function C1(q,X,V,K){let Q;for(Q=0;Q=X.length||Q>=q.length)break;X[Q+V]=q[Q]}return Q}function h2(q,X){return q instanceof X||q!=null&&q.constructor!=null&&q.constructor.name!=null&&q.constructor.name===X.name}var CQ=function(){let q=Array(256);for(let X=0;X<16;++X){let V=X*16;for(let K=0;K<16;++K)q[V+K]="0123456789abcdef"[X]+"0123456789abcdef"[K]}return q}();function M6(q){return typeof BigInt>"u"?hQ:q}function hQ(){throw Error("BigInt not supported")}function oq(q){return()=>{throw Error(q+" is not implemented for node:buffer browser polyfill")}}var P3=oq("resolveObjectURL"),D3=oq("isUtf8");var u3=oq("transcode");var N3=$8(gX(),1);var UX={};qQ(UX,{waitForTick:()=>R2,values:()=>d5,utf8Encode:()=>mQ,utf16Encode:()=>E4,utf16Decode:()=>x8,typedArrayFor:()=>D8,translate:()=>c0,toUint8Array:()=>r6,toRadians:()=>O0,toHexStringOfMinLength:()=>D2,toHexString:()=>u2,toDegrees:()=>k1,toCodePoint:()=>K4,toCharCode:()=>s,sum:()=>z4,stroke:()=>B5,square:()=>lZ,sortedUniq:()=>U4,skewRadians:()=>k8,skewDegrees:()=>bZ,sizeInBytes:()=>P5,singleQuote:()=>t9,showText:()=>L1,setWordSpacing:()=>pZ,setTextRise:()=>nZ,setTextRenderingMode:()=>rZ,setTextMatrix:()=>FK,setStrokingRgbColor:()=>g7,setStrokingGrayscaleColor:()=>D7,setStrokingColor:()=>v5,setStrokingCmykColor:()=>b7,setLineWidth:()=>L5,setLineJoin:()=>fZ,setLineHeight:()=>F7,setLineCap:()=>I8,setGraphicsState:()=>i2,setFontAndSize:()=>T5,setFillingRgbColor:()=>u7,setFillingGrayscaleColor:()=>P7,setFillingColor:()=>E2,setFillingCmykColor:()=>x7,setDashPattern:()=>j5,setCharacterSqueeze:()=>dZ,setCharacterSpacing:()=>cZ,scale:()=>g6,rotateRectangle:()=>y7,rotateRadians:()=>x6,rotateInPlace:()=>j2,rotateDegrees:()=>M8,rotateAndSkewTextRadiansAndTranslate:()=>j8,rotateAndSkewTextDegreesAndTranslate:()=>iZ,rgb:()=>Y0,reverseArray:()=>I6,restoreDashPattern:()=>mZ,reduceRotation:()=>I2,rectanglesAreEqual:()=>n5,rectangle:()=>hK,range:()=>M4,radiansToDegrees:()=>CK,radians:()=>gZ,pushGraphicsState:()=>B0,popGraphicsState:()=>T0,pluckIndices:()=>k4,pdfDocEncodingDecode:()=>J1,parseDate:()=>P8,padStart:()=>e0,numberToString:()=>B4,normalizeAppearance:()=>G2,nextLine:()=>h7,newlineChars:()=>gQ,moveTo:()=>J2,moveText:()=>_Z,mergeUint8Arrays:()=>W4,mergeLines:()=>F1,mergeIntoTypedArray:()=>Z4,lowSurrogate:()=>u1,lineTo:()=>S0,lineSplit:()=>F8,layoutSinglelineText:()=>v8,layoutMultilineText:()=>uq,layoutCombedText:()=>KX,last:()=>n6,isWithinBMP:()=>j4,isType:()=>XK,isStandardFont:()=>e1,isNewlineChar:()=>Y4,highSurrogate:()=>D1,hasUtf16BOM:()=>b8,hasSurrogates:()=>L4,grayscale:()=>Sq,getType:()=>qK,findLastMatch:()=>F5,fillAndStroke:()=>j1,fill:()=>E1,escapedNewlineChars:()=>mX,escapeRegExp:()=>bX,error:()=>L6,endText:()=>T1,endPath:()=>Aq,endMarkedContent:()=>Nq,encodeToBase64:()=>X4,drawTextLines:()=>Fq,drawTextField:()=>Pq,drawText:()=>eZ,drawSvgPath:()=>d7,drawRectangle:()=>b6,drawRadioButton:()=>T8,drawPage:()=>c7,drawOptionList:()=>n7,drawObject:()=>L8,drawLinesOfText:()=>_7,drawLine:()=>p7,drawImage:()=>A1,drawEllipsePath:()=>xK,drawEllipse:()=>O1,drawCheckMark:()=>bK,drawCheckBox:()=>B8,drawButton:()=>hq,degreesToRadians:()=>H6,degrees:()=>p,defaultTextFieldAppearanceProvider:()=>GX,defaultRadioGroupAppearanceProvider:()=>YX,defaultOptionListAppearanceProvider:()=>WX,defaultDropdownAppearanceProvider:()=>ZX,defaultCheckBoxAppearanceProvider:()=>QX,defaultButtonAppearanceProvider:()=>JX,decodePDFRawStream:()=>V8,decodeFromBase64DataUri:()=>V4,decodeFromBase64:()=>q4,createValueErrorMsg:()=>e9,createTypeErrorMsg:()=>VK,createPDFAcroFields:()=>Z8,createPDFAcroField:()=>kq,copyStringIntoBuffer:()=>k0,concatTransformationMatrix:()=>I1,componentsToColor:()=>l0,colorToComponents:()=>$q,cmyk:()=>yq,closePath:()=>N2,clipEvenOdd:()=>xZ,clip:()=>Oq,cleanText:()=>k6,charSplit:()=>J4,charFromHexCode:()=>Q4,charFromCode:()=>t0,charAtIndex:()=>P1,canBeConvertedToUint8Array:()=>I4,bytesFor:()=>j6,byAscendingId:()=>H4,breakTextIntoLines:()=>G4,beginText:()=>B1,beginMarkedContent:()=>wq,backtick:()=>$0,assertRangeOrUndefined:()=>X2,assertRange:()=>b0,assertPositive:()=>X6,assertOrUndefined:()=>F,assertMultiple:()=>Y1,assertIsSubset:()=>V7,assertIsOneOfOrUndefined:()=>a0,assertIsOneOf:()=>M2,assertIs:()=>T,assertInteger:()=>K7,assertEachIs:()=>Q1,asPDFNumber:()=>f,asPDFName:()=>z8,asNumber:()=>t,arrayAsString:()=>u8,appendQuadraticCurve:()=>E8,appendBezierCurve:()=>p0,adjustDimsForRotation:()=>r2,addRandomSuffix:()=>uQ,ViewerPreferences:()=>W1,UnsupportedEncodingError:()=>Q7,UnrecognizedStreamTypeError:()=>J7,UnexpectedObjectTypeError:()=>w6,UnexpectedFieldTypeError:()=>z6,UnbalancedParenthesisError:()=>E7,TextRenderingMode:()=>C7,TextAlignment:()=>v0,StandardFonts:()=>N5,StandardFontValues:()=>o9,StandardFontEmbedder:()=>$6,StalledParserError:()=>j7,RotationTypes:()=>E5,RichTextFieldReadError:()=>e7,ReparseError:()=>Q5,RemovePageFromEmptyDocumentError:()=>o7,ReadingDirection:()=>U5,PrivateConstructorError:()=>K5,PrintScaling:()=>z5,PngEmbedder:()=>X8,ParseSpeeds:()=>w1,PageSizes:()=>HX,PageEmbeddingMismatchedContextError:()=>G7,PDFXRefStreamParser:()=>Lq,PDFWriter:()=>o5,PDFWidgetAnnotation:()=>M5,PDFTrailerDict:()=>Qq,PDFTrailer:()=>S6,PDFTextField:()=>w5,PDFString:()=>K0,PDFStreamWriter:()=>Jq,PDFStreamParsingError:()=>I7,PDFStream:()=>E0,PDFSignature:()=>O8,PDFRef:()=>a,PDFRawStream:()=>w2,PDFRadioGroup:()=>l6,PDFParsingError:()=>V6,PDFParser:()=>Bq,PDFPageTree:()=>H8,PDFPageLeaf:()=>_0,PDFPageEmbedder:()=>K8,PDFPage:()=>y0,PDFOptionList:()=>A5,PDFOperatorNames:()=>X0,PDFOperator:()=>e,PDFObjectStreamParser:()=>jq,PDFObjectStream:()=>a5,PDFObjectParsingError:()=>M7,PDFObjectParser:()=>U8,PDFObjectCopier:()=>Z1,PDFObject:()=>z0,PDFNumber:()=>x,PDFNull:()=>F0,PDFName:()=>I,PDFJavaScript:()=>xq,PDFInvalidObjectParsingError:()=>k7,PDFInvalidObject:()=>s5,PDFImage:()=>R5,PDFHexString:()=>g,PDFHeader:()=>_2,PDFForm:()=>gq,PDFFont:()=>A0,PDFFlateStream:()=>N6,PDFField:()=>d0,PDFEmbeddedPage:()=>R8,PDFDropdown:()=>O5,PDFDocument:()=>o0,PDFDict:()=>m,PDFCrossRefStream:()=>Yq,PDFCrossRefSection:()=>i5,PDFContext:()=>Z5,PDFContentStream:()=>p2,PDFCheckBox:()=>f6,PDFCatalog:()=>W8,PDFButton:()=>S5,PDFBool:()=>c2,PDFArrayIsNotRectangleError:()=>Z7,PDFArray:()=>i,PDFAnnotation:()=>Mq,PDFAcroText:()=>J6,PDFAcroTerminal:()=>K2,PDFAcroSignature:()=>F6,PDFAcroRadioButton:()=>Z6,PDFAcroPushButton:()=>G6,PDFAcroNonTerminal:()=>Y6,PDFAcroListBox:()=>W6,PDFAcroForm:()=>P6,PDFAcroField:()=>Y8,PDFAcroComboBox:()=>Q6,PDFAcroChoice:()=>G8,PDFAcroCheckBox:()=>K6,PDFAcroButton:()=>h6,NumberParsingError:()=>Vq,NonFullScreenPageMode:()=>H5,NoSuchFieldError:()=>s7,NextByteAssertionError:()=>z7,MultiSelectValueError:()=>W7,MissingTfOperatorError:()=>U7,MissingPageContentsEmbeddingError:()=>Y7,MissingPDFHeaderError:()=>L7,MissingOnValueCheckError:()=>X3,MissingKeywordError:()=>B7,MissingDAEntryError:()=>H7,MissingCatalogError:()=>qG,MethodNotImplementedError:()=>u0,LineJoinStyle:()=>$7,LineCapStyle:()=>u6,JpegEmbedder:()=>q8,InvalidTargetIndexError:()=>qq,InvalidPDFDateStringError:()=>G1,InvalidMaxLengthError:()=>VX,InvalidFieldNamePartError:()=>t7,InvalidAcroFieldValueError:()=>J5,IndexOutOfBoundsError:()=>Y5,ImageAlignment:()=>T2,ForeignPageError:()=>a7,FontkitNotRegisteredError:()=>i7,FileEmbedder:()=>Wq,FieldExistsAsNonTerminalError:()=>V3,FieldAlreadyExistsError:()=>Dq,ExceededMaxLengthError:()=>XX,EncryptedPDFError:()=>r7,Duplex:()=>Q8,CustomFontSubsetEmbedder:()=>Zq,CustomFontEmbedder:()=>C6,CorruptPageTreeError:()=>Xq,CombedTextLayoutError:()=>qX,ColorTypes:()=>U6,CharCodes:()=>E,Cache:()=>m0,BlendMode:()=>S2,AppearanceCharacteristics:()=>J8,AnnotationFlags:()=>I5,AcroTextFlags:()=>j0,AcroFieldFlags:()=>Y2,AcroChoiceFlags:()=>G0,AcroButtonFlags:()=>f0,AFRelationship:()=>t5});/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any @@ -14,22 +14,22 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */var eq=function(q,X){return eq=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(V,K){V.__proto__=K}||function(V,K){for(var Q in K)if(K.hasOwnProperty(Q))V[Q]=K[Q]},eq(q,X)};function A(q,X){eq(q,X);function V(){this.constructor=q}q.prototype=X===null?Object.create(X):(V.prototype=X.prototype,new V)}var o=function(){return o=Object.assign||function(X){for(var V,K=1,Q=arguments.length;K0&&Y[Y.length-1]))&&(Z[0]===6||Z[0]===2)){V=0;continue}if(Z[0]===3&&(!Y||Z[1]>Y[0]&&Z[1]>2],X+=h5[(q[K]&3)<<4|q[K+1]>>4],X+=h5[(q[K+1]&15)<<2|q[K+2]>>6],X+=h5[q[K+2]&63];if(V%3===2)X=X.substring(0,X.length-1)+"=";else if(V%3===1)X=X.substring(0,X.length-2)+"==";return X},q4=function(q){var X=q.length*0.75,V=q.length,K,Q=0,Y,J,G,W;if(q[q.length-1]==="="){if(X--,q[q.length-2]==="=")X--}var Z=new Uint8Array(X);for(K=0;K>4,Z[Q++]=(J&15)<<4|G>>2,Z[Q++]=(G&3)<<6|W&63;return Z},DQ=/^(data)?:?([\w\/\+]+)?;?(charset=[\w-]+|base64)?.*,/i,V4=function(q){var X=q.trim(),V=X.substring(0,100),K=V.match(DQ);if(!K)return q4(X);var Q=K[0],Y=X.substring(Q.length);return q4(Y)};var s=function(q){return q.charCodeAt(0)},K4=function(q){return q.codePointAt(0)},D2=function(q,X){return e0(q.toString(16),X,"0").toUpperCase()},u2=function(q){return D2(q,2)},t0=function(q){return String.fromCharCode(q)},Q4=function(q){return t0(parseInt(q,16))},e0=function(q,X,V){var K="";for(var Q=0,Y=X-q.length;Q=55296&&V<=56319&&q.length>Q){if(K=q.charCodeAt(Q),K>=56320&&K<=57343)Y=2}return[q.slice(X,X+Y),Y]},J4=function(q){var X=[];for(var V=0,K=q.length;VV)Z();J+=z,G+=k}}return Z(),W},bQ=/^D:(\d\d\d\d)(\d\d)?(\d\d)?(\d\d)?(\d\d)?(\d\d)?([+\-Z])?(\d\d)?'?(\d\d)?'?$/,P8=function(q){var X=q.match(bQ);if(!X)return;var V=X[1],K=X[2],Q=K===void 0?"01":K,Y=X[3],J=Y===void 0?"01":Y,G=X[4],W=G===void 0?"00":G,Z=X[5],H=Z===void 0?"00":Z,U=X[6],z=U===void 0?"00":U,k=X[7],M=k===void 0?"Z":k,j=X[8],B=j===void 0?"00":j,L=X[9],O=L===void 0?"00":L,N=M==="Z"?"Z":""+M+B+":"+O,R=new Date(V+"-"+Q+"-"+J+"T"+W+":"+H+":"+z+N);return R},F5=function(q,X){var V,K=0,Q;while(K>6&31|192,G=Y&63|128;V.push(J,G),K+=1}else if(Y<65536){var J=Y>>12&15|224,G=Y>>6&63|128,W=Y&63|128;V.push(J,G,W),K+=1}else if(Y<1114112){var J=Y>>18&7|240,G=Y>>12&63|128,W=Y>>6&63|128,Z=Y>>0&63|128;V.push(J,G,W,Z),K+=2}else throw Error("Invalid code point: 0x"+u2(Y))}return new Uint8Array(V)},E4=function(q,X){if(X===void 0)X=!0;var V=[];if(X)V.push(65279);for(var K=0,Q=q.length;K=0&&q<=65535},L4=function(q){return q>=65536&&q<=1114111},D1=function(q){return Math.floor((q-65536)/1024)+55296},u1=function(q){return(q-65536)%1024+56320},E6;(function(q){q.BigEndian="BigEndian",q.LittleEndian="LittleEndian"})(E6||(E6={}));var g8="�".codePointAt(0),x8=function(q,X){if(X===void 0)X=!0;if(q.length<=1)return String.fromCodePoint(g8);var V=X?lQ(q):E6.BigEndian,K=X?2:0,Q=[];while(q.length-K>=2){var Y=lX(q[K++],q[K++],V);if(fQ(Y))if(q.length-K<2)Q.push(g8);else{var J=lX(q[K++],q[K++],V);if(fX(J))Q.push(Y,J);else Q.push(g8)}else if(fX(Y))K+=2,Q.push(g8);else Q.push(Y)}if(K=55296&&q<=56319},fX=function(q){return q>=56320&&q<=57343},lX=function(q,X,V){if(V===E6.LittleEndian)return X<<8|q;if(V===E6.BigEndian)return q<<8|X;throw Error("Invalid byteOrder: "+V)},lQ=function(q){return _X(q)?E6.BigEndian:cX(q)?E6.LittleEndian:E6.BigEndian},_X=function(q){return q[0]===254&&q[1]===255},cX=function(q){return q[0]===255&&q[1]===254},b8=function(q){return _X(q)||cX(q)};var B4=function(q){var X=String(q);if(Math.abs(q)<1){var V=parseInt(q.toString().split("e-")[1]);if(V){var K=q<0;if(K)q*=-1;if(q*=Math.pow(10,V-1),X="0."+Array(V).join("0")+q.toString().substring(2),K)X="-"+X}}else{var V=parseInt(q.toString().split("+")[1]);if(V>20)V-=20,q/=Math.pow(10,V),X=q.toString()+Array(V+1).join("0")}return X},P5=function(q){return Math.ceil(q.toString(2).length/8)},j6=function(q){var X=new Uint8Array(P5(q));for(var V=1;V<=X.length;V++)X[V-1]=q>>(X.length-V)*8;return X};var L6=function(q){throw Error(q)};var h9=$8(X1(),1),C9="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",V1=new Uint8Array(256);for(p5=0;p5>4,Z[Q++]=(J&15)<<4|G>>2,Z[Q++]=(G&3)<<6|W&63;return Z},uJ=function(q){var X="";for(var V=0;VK)throw Error($0(X)+" must be at least "+V+" and at most "+K+", but was actually "+q)},X2=function(q,X,V,K){if(T(q,X,["number","undefined"]),typeof q==="number")b0(q,X,V,K)},Y1=function(q,X,V){if(T(q,X,["number"]),q%V!==0)throw Error($0(X)+" must be a multiple of "+V+", but was actually "+q)},K7=function(q,X){if(!Number.isInteger(q))throw Error($0(X)+" must be an integer, but was actually "+q)},X6=function(q,X){if(![1,0].includes(Math.sign(q)))throw Error($0(X)+" must be a positive number or 0, but was actually "+q)};var V0=new Uint16Array(256);for(r5=0;r5<256;r5++)V0[r5]=r5;var r5;V0[22]=s("\x17");V0[24]=s("˘");V0[25]=s("ˇ");V0[26]=s("ˆ");V0[27]=s("˙");V0[28]=s("˝");V0[29]=s("˛");V0[30]=s("˚");V0[31]=s("˜");V0[127]=s("�");V0[128]=s("•");V0[129]=s("†");V0[130]=s("‡");V0[131]=s("…");V0[132]=s("—");V0[133]=s("–");V0[134]=s("ƒ");V0[135]=s("⁄");V0[136]=s("‹");V0[137]=s("›");V0[138]=s("−");V0[139]=s("‰");V0[140]=s("„");V0[141]=s("“");V0[142]=s("”");V0[143]=s("‘");V0[144]=s("’");V0[145]=s("‚");V0[146]=s("™");V0[147]=s("fi");V0[148]=s("fl");V0[149]=s("Ł");V0[150]=s("Œ");V0[151]=s("Š");V0[152]=s("Ÿ");V0[153]=s("Ž");V0[154]=s("ı");V0[155]=s("ł");V0[156]=s("œ");V0[157]=s("š");V0[158]=s("ž");V0[159]=s("�");V0[160]=s("€");V0[173]=s("�");var J1=function(q){var X=Array(q.length);for(var V=0,K=q.length;V=E.ExclamationPoint&&q<=E.Tilde&&!Kq[q]},KK={},QK=new Map,ZG=function(q){A(X,q);function X(V,K){var Q=this;if(V!==KK)throw new K5("PDFName");Q=q.call(this)||this;var Y="/";for(var J=0,G=K.length;J=E.Zero&&Z<=E.Nine||Z>=E.a&&Z<=E.f||Z>=E.A&&Z<=E.F){if(K+=W,K.length===2||!(H>="0"&&H<="9"||H>="a"&&H<="f"||H>="A"&&H<="F"))Y(parseInt(K,16)),K=""}else Y(Z)}return new Uint8Array(V)},X.prototype.decodeText=function(){var V=this.asBytes();return String.fromCharCode.apply(String,Array.from(V))},X.prototype.asString=function(){return this.encodedName},X.prototype.value=function(){return this.encodedName},X.prototype.clone=function(){return this},X.prototype.toString=function(){return this.encodedName},X.prototype.sizeInBytes=function(){return this.encodedName.length},X.prototype.copyBytesInto=function(V,K){return K+=k0(this.encodedName,V,K),this.encodedName.length},X.of=function(V){var K=JG(V),Q=QK.get(K);if(!Q)Q=new X(KK,K),QK.set(K,Q);return Q},X.Length=X.of("Length"),X.FlateDecode=X.of("FlateDecode"),X.Resources=X.of("Resources"),X.Font=X.of("Font"),X.XObject=X.of("XObject"),X.ExtGState=X.of("ExtGState"),X.Contents=X.of("Contents"),X.Type=X.of("Type"),X.Parent=X.of("Parent"),X.MediaBox=X.of("MediaBox"),X.Page=X.of("Page"),X.Annots=X.of("Annots"),X.TrimBox=X.of("TrimBox"),X.ArtBox=X.of("ArtBox"),X.BleedBox=X.of("BleedBox"),X.CropBox=X.of("CropBox"),X.Rotate=X.of("Rotate"),X.Title=X.of("Title"),X.Author=X.of("Author"),X.Subject=X.of("Subject"),X.Creator=X.of("Creator"),X.Keywords=X.of("Keywords"),X.Producer=X.of("Producer"),X.CreationDate=X.of("CreationDate"),X.ModDate=X.of("ModDate"),X}(z0),I=ZG;var WG=function(q){A(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.prototype.asNull=function(){return null},X.prototype.clone=function(){return this},X.prototype.toString=function(){return"null"},X.prototype.sizeInBytes=function(){return 4},X.prototype.copyBytesInto=function(V,K){return V[K++]=E.n,V[K++]=E.u,V[K++]=E.l,V[K++]=E.l,4},X}(z0),F0=new WG;var HG=function(q){A(X,q);function X(V,K){var Q=q.call(this)||this;return Q.dict=V,Q.context=K,Q}return X.prototype.keys=function(){return Array.from(this.dict.keys())},X.prototype.values=function(){return Array.from(this.dict.values())},X.prototype.entries=function(){return Array.from(this.dict.entries())},X.prototype.set=function(V,K){this.dict.set(V,K)},X.prototype.get=function(V,K){if(K===void 0)K=!1;var Q=this.dict.get(V);if(Q===F0&&!K)return;return Q},X.prototype.has=function(V){var K=this.dict.get(V);return K!==void 0&&K!==F0},X.prototype.lookupMaybe=function(V){var K,Q=[];for(var Y=1;Y0&&Y[Y.length-1]))&&(Z[0]===6||Z[0]===2)){V=0;continue}if(Z[0]===3&&(!Y||Z[1]>Y[0]&&Z[1]>2],X+=h5[(q[K]&3)<<4|q[K+1]>>4],X+=h5[(q[K+1]&15)<<2|q[K+2]>>6],X+=h5[q[K+2]&63];if(V%3===2)X=X.substring(0,X.length-1)+"=";else if(V%3===1)X=X.substring(0,X.length-2)+"==";return X},q4=function(q){var X=q.length*0.75,V=q.length,K,Q=0,Y,J,G,W;if(q[q.length-1]==="="){if(X--,q[q.length-2]==="=")X--}var Z=new Uint8Array(X);for(K=0;K>4,Z[Q++]=(J&15)<<4|G>>2,Z[Q++]=(G&3)<<6|W&63;return Z},DQ=/^(data)?:?([\w\/\+]+)?;?(charset=[\w-]+|base64)?.*,/i,V4=function(q){var X=q.trim(),V=X.substring(0,100),K=V.match(DQ);if(!K)return q4(X);var Q=K[0],Y=X.substring(Q.length);return q4(Y)};var s=function(q){return q.charCodeAt(0)},K4=function(q){return q.codePointAt(0)},D2=function(q,X){return e0(q.toString(16),X,"0").toUpperCase()},u2=function(q){return D2(q,2)},t0=function(q){return String.fromCharCode(q)},Q4=function(q){return t0(parseInt(q,16))},e0=function(q,X,V){var K="";for(var Q=0,Y=X-q.length;Q=55296&&V<=56319&&q.length>Q){if(K=q.charCodeAt(Q),K>=56320&&K<=57343)Y=2}return[q.slice(X,X+Y),Y]},J4=function(q){var X=[];for(var V=0,K=q.length;VV)Z();J+=z,G+=k}}return Z(),W},bQ=/^D:(\d\d\d\d)(\d\d)?(\d\d)?(\d\d)?(\d\d)?(\d\d)?([+\-Z])?(\d\d)?'?(\d\d)?'?$/,P8=function(q){var X=q.match(bQ);if(!X)return;var V=X[1],K=X[2],Q=K===void 0?"01":K,Y=X[3],J=Y===void 0?"01":Y,G=X[4],W=G===void 0?"00":G,Z=X[5],H=Z===void 0?"00":Z,U=X[6],z=U===void 0?"00":U,k=X[7],M=k===void 0?"Z":k,j=X[8],B=j===void 0?"00":j,L=X[9],O=L===void 0?"00":L,N=M==="Z"?"Z":""+M+B+":"+O,R=new Date(V+"-"+Q+"-"+J+"T"+W+":"+H+":"+z+N);return R},F5=function(q,X){var V,K=0,Q;while(K>6&31|192,G=Y&63|128;V.push(J,G),K+=1}else if(Y<65536){var J=Y>>12&15|224,G=Y>>6&63|128,W=Y&63|128;V.push(J,G,W),K+=1}else if(Y<1114112){var J=Y>>18&7|240,G=Y>>12&63|128,W=Y>>6&63|128,Z=Y>>0&63|128;V.push(J,G,W,Z),K+=2}else throw Error("Invalid code point: 0x"+u2(Y))}return new Uint8Array(V)},E4=function(q,X){if(X===void 0)X=!0;var V=[];if(X)V.push(65279);for(var K=0,Q=q.length;K=0&&q<=65535},L4=function(q){return q>=65536&&q<=1114111},D1=function(q){return Math.floor((q-65536)/1024)+55296},u1=function(q){return(q-65536)%1024+56320},E6;(function(q){q.BigEndian="BigEndian",q.LittleEndian="LittleEndian"})(E6||(E6={}));var g8="�".codePointAt(0),x8=function(q,X){if(X===void 0)X=!0;if(q.length<=1)return String.fromCodePoint(g8);var V=X?lQ(q):E6.BigEndian,K=X?2:0,Q=[];while(q.length-K>=2){var Y=lX(q[K++],q[K++],V);if(fQ(Y))if(q.length-K<2)Q.push(g8);else{var J=lX(q[K++],q[K++],V);if(fX(J))Q.push(Y,J);else Q.push(g8)}else if(fX(Y))K+=2,Q.push(g8);else Q.push(Y)}if(K=55296&&q<=56319},fX=function(q){return q>=56320&&q<=57343},lX=function(q,X,V){if(V===E6.LittleEndian)return X<<8|q;if(V===E6.BigEndian)return q<<8|X;throw Error("Invalid byteOrder: "+V)},lQ=function(q){return _X(q)?E6.BigEndian:cX(q)?E6.LittleEndian:E6.BigEndian},_X=function(q){return q[0]===254&&q[1]===255},cX=function(q){return q[0]===255&&q[1]===254},b8=function(q){return _X(q)||cX(q)};var B4=function(q){var X=String(q);if(Math.abs(q)<1){var V=parseInt(q.toString().split("e-")[1]);if(V){var K=q<0;if(K)q*=-1;if(q*=Math.pow(10,V-1),X="0."+Array(V).join("0")+q.toString().substring(2),K)X="-"+X}}else{var V=parseInt(q.toString().split("+")[1]);if(V>20)V-=20,q/=Math.pow(10,V),X=q.toString()+Array(V+1).join("0")}return X},P5=function(q){return Math.ceil(q.toString(2).length/8)},j6=function(q){var X=new Uint8Array(P5(q));for(var V=1;V<=X.length;V++)X[V-1]=q>>(X.length-V)*8;return X};var L6=function(q){throw Error(q)};var h9=$8(X1(),1),C9="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",V1=new Uint8Array(256);for(p5=0;p5>4,Z[Q++]=(J&15)<<4|G>>2,Z[Q++]=(G&3)<<6|W&63;return Z},uJ=function(q){var X="";for(var V=0;VK)throw Error($0(X)+" must be at least "+V+" and at most "+K+", but was actually "+q)},X2=function(q,X,V,K){if(T(q,X,["number","undefined"]),typeof q==="number")b0(q,X,V,K)},Y1=function(q,X,V){if(T(q,X,["number"]),q%V!==0)throw Error($0(X)+" must be a multiple of "+V+", but was actually "+q)},K7=function(q,X){if(!Number.isInteger(q))throw Error($0(X)+" must be an integer, but was actually "+q)},X6=function(q,X){if(![1,0].includes(Math.sign(q)))throw Error($0(X)+" must be a positive number or 0, but was actually "+q)};var V0=new Uint16Array(256);for(r5=0;r5<256;r5++)V0[r5]=r5;var r5;V0[22]=s("\x17");V0[24]=s("˘");V0[25]=s("ˇ");V0[26]=s("ˆ");V0[27]=s("˙");V0[28]=s("˝");V0[29]=s("˛");V0[30]=s("˚");V0[31]=s("˜");V0[127]=s("�");V0[128]=s("•");V0[129]=s("†");V0[130]=s("‡");V0[131]=s("…");V0[132]=s("—");V0[133]=s("–");V0[134]=s("ƒ");V0[135]=s("⁄");V0[136]=s("‹");V0[137]=s("›");V0[138]=s("−");V0[139]=s("‰");V0[140]=s("„");V0[141]=s("“");V0[142]=s("”");V0[143]=s("‘");V0[144]=s("’");V0[145]=s("‚");V0[146]=s("™");V0[147]=s("fi");V0[148]=s("fl");V0[149]=s("Ł");V0[150]=s("Œ");V0[151]=s("Š");V0[152]=s("Ÿ");V0[153]=s("Ž");V0[154]=s("ı");V0[155]=s("ł");V0[156]=s("œ");V0[157]=s("š");V0[158]=s("ž");V0[159]=s("�");V0[160]=s("€");V0[173]=s("�");var J1=function(q){var X=Array(q.length);for(var V=0,K=q.length;V=E.ExclamationPoint&&q<=E.Tilde&&!Kq[q]},KK={},QK=new Map,ZG=function(q){w(X,q);function X(V,K){var Q=this;if(V!==KK)throw new K5("PDFName");Q=q.call(this)||this;var Y="/";for(var J=0,G=K.length;J=E.Zero&&Z<=E.Nine||Z>=E.a&&Z<=E.f||Z>=E.A&&Z<=E.F){if(K+=W,K.length===2||!(H>="0"&&H<="9"||H>="a"&&H<="f"||H>="A"&&H<="F"))Y(parseInt(K,16)),K=""}else Y(Z)}return new Uint8Array(V)},X.prototype.decodeText=function(){var V=this.asBytes();return String.fromCharCode.apply(String,Array.from(V))},X.prototype.asString=function(){return this.encodedName},X.prototype.value=function(){return this.encodedName},X.prototype.clone=function(){return this},X.prototype.toString=function(){return this.encodedName},X.prototype.sizeInBytes=function(){return this.encodedName.length},X.prototype.copyBytesInto=function(V,K){return K+=k0(this.encodedName,V,K),this.encodedName.length},X.of=function(V){var K=JG(V),Q=QK.get(K);if(!Q)Q=new X(KK,K),QK.set(K,Q);return Q},X.Length=X.of("Length"),X.FlateDecode=X.of("FlateDecode"),X.Resources=X.of("Resources"),X.Font=X.of("Font"),X.XObject=X.of("XObject"),X.ExtGState=X.of("ExtGState"),X.Contents=X.of("Contents"),X.Type=X.of("Type"),X.Parent=X.of("Parent"),X.MediaBox=X.of("MediaBox"),X.Page=X.of("Page"),X.Annots=X.of("Annots"),X.TrimBox=X.of("TrimBox"),X.ArtBox=X.of("ArtBox"),X.BleedBox=X.of("BleedBox"),X.CropBox=X.of("CropBox"),X.Rotate=X.of("Rotate"),X.Title=X.of("Title"),X.Author=X.of("Author"),X.Subject=X.of("Subject"),X.Creator=X.of("Creator"),X.Keywords=X.of("Keywords"),X.Producer=X.of("Producer"),X.CreationDate=X.of("CreationDate"),X.ModDate=X.of("ModDate"),X}(z0),I=ZG;var WG=function(q){w(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.prototype.asNull=function(){return null},X.prototype.clone=function(){return this},X.prototype.toString=function(){return"null"},X.prototype.sizeInBytes=function(){return 4},X.prototype.copyBytesInto=function(V,K){return V[K++]=E.n,V[K++]=E.u,V[K++]=E.l,V[K++]=E.l,4},X}(z0),F0=new WG;var HG=function(q){w(X,q);function X(V,K){var Q=q.call(this)||this;return Q.dict=V,Q.context=K,Q}return X.prototype.keys=function(){return Array.from(this.dict.keys())},X.prototype.values=function(){return Array.from(this.dict.values())},X.prototype.entries=function(){return Array.from(this.dict.entries())},X.prototype.set=function(V,K){this.dict.set(V,K)},X.prototype.get=function(V,K){if(K===void 0)K=!1;var Q=this.dict.get(V);if(Q===F0&&!K)return;return Q},X.prototype.has=function(V){var K=this.dict.get(V);return K!==void 0&&K!==F0},X.prototype.lookupMaybe=function(V){var K,Q=[];for(var Y=1;Ythis.largestObjectNumber)this.largestObjectNumber=X.objectNumber},q.prototype.nextRef=function(){return this.largestObjectNumber+=1,a.of(this.largestObjectNumber)},q.prototype.register=function(X){var V=this.nextRef();return this.assign(V,X),V},q.prototype.delete=function(X){return this.indirectObjects.delete(X)},q.prototype.lookupMaybe=function(X){var V=[];for(var K=1;Kthis.largestObjectNumber)this.largestObjectNumber=X.objectNumber},q.prototype.nextRef=function(){return this.largestObjectNumber+=1,a.of(this.largestObjectNumber)},q.prototype.register=function(X){var V=this.nextRef();return this.assign(V,X),V},q.prototype.delete=function(X){return this.indirectObjects.delete(X)},q.prototype.lookupMaybe=function(X){var V=[];for(var K=1;K1)this.subsections.push([X]),this.chunkIdx+=1,this.chunkLength=1;else V.push(X),this.chunkLength+=1},q.create=function(){return new q({ref:a.of(0,65535),offset:0,deleted:!0})},q.createEmpty=function(){return new q},q}(),i5=vG;var RG=function(){function q(X){this.lastXRefOffset=String(X)}return q.prototype.toString=function(){return`startxref `+this.lastXRefOffset+` %%EOF`},q.prototype.sizeInBytes=function(){return 16+this.lastXRefOffset.length},q.prototype.copyBytesInto=function(X,V){var K=V;return X[V++]=E.s,X[V++]=E.t,X[V++]=E.a,X[V++]=E.r,X[V++]=E.t,X[V++]=E.x,X[V++]=E.r,X[V++]=E.e,X[V++]=E.f,X[V++]=E.Newline,V+=k0(this.lastXRefOffset,X,V),X[V++]=E.Newline,X[V++]=E.Percent,X[V++]=E.Percent,X[V++]=E.E,X[V++]=E.O,X[V++]=E.F,V-K},q.forLastCrossRefSectionOffset=function(X){return new q(X)},q}(),S6=RG;var OG=function(){function q(X){this.dict=X}return q.prototype.toString=function(){return`trailer -`+this.dict.toString()},q.prototype.sizeInBytes=function(){return 8+this.dict.sizeInBytes()},q.prototype.copyBytesInto=function(X,V){var K=V;return X[V++]=E.t,X[V++]=E.r,X[V++]=E.a,X[V++]=E.i,X[V++]=E.l,X[V++]=E.e,X[V++]=E.r,X[V++]=E.Newline,V+=this.dict.copyBytesInto(X,V),V-K},q.of=function(X){return new q(X)},q}(),Qq=OG;var wG=function(q){A(X,q);function X(V,K,Q){if(Q===void 0)Q=!0;var Y=q.call(this,V.obj({}),Q)||this;return Y.objects=K,Y.offsets=Y.computeObjectOffsets(),Y.offsetsString=Y.computeOffsetsString(),Y.dict.set(I.of("Type"),I.of("ObjStm")),Y.dict.set(I.of("N"),x.of(Y.objects.length)),Y.dict.set(I.of("First"),x.of(Y.offsetsString.length)),Y}return X.prototype.getObjectsCount=function(){return this.objects.length},X.prototype.clone=function(V){return X.withContextAndObjects(V||this.dict.context,this.objects.slice(),this.encode)},X.prototype.getContentsString=function(){var V=this.offsetsString;for(var K=0,Q=this.objects.length;K1)J.push(G),J.push(H.ref.objectNumber),G=0;G+=1}return J.push(G),J},Y.computeEntryTuples=function(){var J=Array(Y.entries.length);for(var G=0,W=Y.entries.length;GG[0])G[0]=M;if(j>G[1])G[1]=j;if(B>G[2])G[2]=B}return G},Y.entries=K||[],Y.entryTuplesCache=m0.populatedBy(Y.computeEntryTuples),Y.maxByteWidthsCache=m0.populatedBy(Y.computeMaxEntryByteWidths),Y.indexCache=m0.populatedBy(Y.computeIndex),V.set(I.of("Type"),I.of("XRef")),Y}return X.prototype.addDeletedEntry=function(V,K){var Q=y6.Deleted;this.entries.push({type:Q,ref:V,nextFreeObjectNumber:K}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},X.prototype.addUncompressedEntry=function(V,K){var Q=y6.Uncompressed;this.entries.push({type:Q,ref:V,offset:K}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},X.prototype.addCompressedEntry=function(V,K,Q){var Y=y6.Compressed;this.entries.push({type:Y,ref:V,objectStreamRef:K,index:Q}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},X.prototype.clone=function(V){var K=this,Q=K.dict,Y=K.entries,J=K.encode;return X.of(Q.clone(V),Y.slice(),J)},X.prototype.getContentsString=function(){var V=this.entryTuplesCache.access(),K=this.maxByteWidthsCache.access(),Q="";for(var Y=0,J=V.length;Y=0;M--)Q+=(U[M]||0).toString(2);for(var M=K[1]-1;M>=0;M--)Q+=(z[M]||0).toString(2);for(var M=K[2]-1;M>=0;M--)Q+=(k[M]||0).toString(2)}return Q},X.prototype.getUnencodedContents=function(){var V=this.entryTuplesCache.access(),K=this.maxByteWidthsCache.access(),Q=new Uint8Array(this.getUnencodedContentsSize()),Y=0;for(var J=0,G=V.length;J=0;j--)Q[Y++]=z[j]||0;for(var j=K[1]-1;j>=0;j--)Q[Y++]=k[j]||0;for(var j=K[2]-1;j>=0;j--)Q[Y++]=M[j]||0}return Q},X.prototype.getUnencodedContentsSize=function(){var V=this.maxByteWidthsCache.access(),K=z4(V);return K*this.entries.length},X.prototype.updateDict=function(){q.prototype.updateDict.call(this);var V=this.maxByteWidthsCache.access(),K=this.indexCache.access(),Q=this.dict.context;this.dict.set(I.of("W"),Q.obj(V)),this.dict.set(I.of("Index"),Q.obj(K))},X.create=function(V,K){if(K===void 0)K=!0;var Q=new X(V,[],K);return Q.addDeletedEntry(a.of(0,65535),0),Q},X.of=function(V,K,Q){if(Q===void 0)Q=!0;return new X(V,K,Q)},X}(N6),Yq=SG;var yG=function(q){A(X,q);function X(V,K,Q,Y){var J=q.call(this,V,K)||this;return J.encodeStreams=Q,J.objectsPerStream=Y,J}return X.prototype.computeBufferSize=function(){return _(this,void 0,void 0,function(){var V,K,Q,Y,J,G,W,Z,M,j,H,L,U,z,B,k,M,j,B,L,O,N,R,v;return c(this,function(w){switch(w.label){case 0:V=this.context.largestObjectNumber+1,K=_2.forVersion(1,7),Q=K.sizeInBytes()+2,Y=Yq.create(this.createTrailerDict(),this.encodeStreams),J=[],G=[],W=[],Z=this.context.enumerateIndirectObjects(),M=0,j=Z.length,w.label=1;case 1:if(!(M"},X.prototype.sizeInBytes=function(){return this.value.length+2},X.prototype.copyBytesInto=function(V,K){return V[K++]=E.LessThan,K+=k0(this.value,V,K),V[K++]=E.GreaterThan,this.value.length+2},X.of=function(V){return new X(V)},X.fromText=function(V){var K=E4(V),Q="";for(var Y=0,J=K.length;Y1)J.push(G),J.push(H.ref.objectNumber),G=0;G+=1}return J.push(G),J},Y.computeEntryTuples=function(){var J=Array(Y.entries.length);for(var G=0,W=Y.entries.length;GG[0])G[0]=M;if(j>G[1])G[1]=j;if(B>G[2])G[2]=B}return G},Y.entries=K||[],Y.entryTuplesCache=m0.populatedBy(Y.computeEntryTuples),Y.maxByteWidthsCache=m0.populatedBy(Y.computeMaxEntryByteWidths),Y.indexCache=m0.populatedBy(Y.computeIndex),V.set(I.of("Type"),I.of("XRef")),Y}return X.prototype.addDeletedEntry=function(V,K){var Q=y6.Deleted;this.entries.push({type:Q,ref:V,nextFreeObjectNumber:K}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},X.prototype.addUncompressedEntry=function(V,K){var Q=y6.Uncompressed;this.entries.push({type:Q,ref:V,offset:K}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},X.prototype.addCompressedEntry=function(V,K,Q){var Y=y6.Compressed;this.entries.push({type:Y,ref:V,objectStreamRef:K,index:Q}),this.entryTuplesCache.invalidate(),this.maxByteWidthsCache.invalidate(),this.indexCache.invalidate(),this.contentsCache.invalidate()},X.prototype.clone=function(V){var K=this,Q=K.dict,Y=K.entries,J=K.encode;return X.of(Q.clone(V),Y.slice(),J)},X.prototype.getContentsString=function(){var V=this.entryTuplesCache.access(),K=this.maxByteWidthsCache.access(),Q="";for(var Y=0,J=V.length;Y=0;M--)Q+=(U[M]||0).toString(2);for(var M=K[1]-1;M>=0;M--)Q+=(z[M]||0).toString(2);for(var M=K[2]-1;M>=0;M--)Q+=(k[M]||0).toString(2)}return Q},X.prototype.getUnencodedContents=function(){var V=this.entryTuplesCache.access(),K=this.maxByteWidthsCache.access(),Q=new Uint8Array(this.getUnencodedContentsSize()),Y=0;for(var J=0,G=V.length;J=0;j--)Q[Y++]=z[j]||0;for(var j=K[1]-1;j>=0;j--)Q[Y++]=k[j]||0;for(var j=K[2]-1;j>=0;j--)Q[Y++]=M[j]||0}return Q},X.prototype.getUnencodedContentsSize=function(){var V=this.maxByteWidthsCache.access(),K=z4(V);return K*this.entries.length},X.prototype.updateDict=function(){q.prototype.updateDict.call(this);var V=this.maxByteWidthsCache.access(),K=this.indexCache.access(),Q=this.dict.context;this.dict.set(I.of("W"),Q.obj(V)),this.dict.set(I.of("Index"),Q.obj(K))},X.create=function(V,K){if(K===void 0)K=!0;var Q=new X(V,[],K);return Q.addDeletedEntry(a.of(0,65535),0),Q},X.of=function(V,K,Q){if(Q===void 0)Q=!0;return new X(V,K,Q)},X}(N6),Yq=SG;var yG=function(q){w(X,q);function X(V,K,Q,Y){var J=q.call(this,V,K)||this;return J.encodeStreams=Q,J.objectsPerStream=Y,J}return X.prototype.computeBufferSize=function(){return _(this,void 0,void 0,function(){var V,K,Q,Y,J,G,W,Z,M,j,H,L,U,z,B,k,M,j,B,L,O,N,R,v;return c(this,function(A){switch(A.label){case 0:V=this.context.largestObjectNumber+1,K=_2.forVersion(1,7),Q=K.sizeInBytes()+2,Y=Yq.create(this.createTrailerDict(),this.encodeStreams),J=[],G=[],W=[],Z=this.context.enumerateIndirectObjects(),M=0,j=Z.length,A.label=1;case 1:if(!(M"},X.prototype.sizeInBytes=function(){return this.value.length+2},X.prototype.copyBytesInto=function(V,K){return V[K++]=E.LessThan,K+=k0(this.value,V,K),V[K++]=E.GreaterThan,this.value.length+2},X.of=function(V){return new X(V)},X.fromText=function(V){var K=E4(V),Q="";for(var Y=0,J=K.length;Y"},Gq=function(q){return D2(q,4)},FG=function(q){if(j4(q))return Gq(q);if(L4(q)){var X=D1(q),V=u1(q);return""+Gq(X)+Gq(V)}var K=u2(q),Q="0x"+K+" is not a valid UTF-8 or UTF-16 codepoint.";throw Error(Q)};var PG=function(q){var X=0,V=function(K){X|=1<=E.Zero&&Z<=E.Seven){if(K+=W,K.length===3||!(H>="0"&&H<="7"))Y(parseInt(K,8)),K=""}else Y(Z)}return new Uint8Array(V)},X.prototype.decodeText=function(){var V=this.asBytes();if(b8(V))return x8(V);return J1(V)},X.prototype.decodeDate=function(){var V=this.decodeText(),K=P8(V);if(!K)throw new G1(V);return K},X.prototype.asString=function(){return this.value},X.prototype.clone=function(){return X.of(this.value)},X.prototype.toString=function(){return"("+this.value+")"},X.prototype.sizeInBytes=function(){return this.value.length+2},X.prototype.copyBytesInto=function(V,K){return V[K++]=E.LeftParen,K+=k0(this.value,V,K),V[K++]=E.RightParen,this.value.length+2},X.of=function(V){return new X(V)},X.fromDate=function(V){var K=e0(String(V.getUTCFullYear()),4,"0"),Q=e0(String(V.getUTCMonth()+1),2,"0"),Y=e0(String(V.getUTCDate()),2,"0"),J=e0(String(V.getUTCHours()),2,"0"),G=e0(String(V.getUTCMinutes()),2,"0"),W=e0(String(V.getUTCSeconds()),2,"0");return new X("D:"+K+Q+Y+J+G+W+"Z")},X}(z0),K0=DG;var uG=function(){function q(X,V,K,Q){var Y=this;this.allGlyphsInFontSortedById=function(){var J=Array(Y.font.characterSet.length);for(var G=0,W=J.length;G>3)]>>7-((M&7)<<0)&1,D=3*C;G[R]=v[D],G[R+1]=v[D+1],G[R+2]=v[D+2],G[R+3]=C<$?w[C]:255}}if(H==2)for(var S=0;S>2)]>>6-((M&3)<<1)&3,D=3*C;G[R]=v[D],G[R+1]=v[D+1],G[R+2]=v[D+2],G[R+3]=C<$?w[C]:255}}if(H==4)for(var S=0;S>1)]>>4-((M&1)<<2)&15,D=3*C;G[R]=v[D],G[R+1]=v[D+1],G[R+2]=v[D+2],G[R+3]=C<$?w[C]:255}}if(H==8)for(var M=0;M>>3)]>>>7-(r&7)&1),I0=u==L*255?0:255;W[J0+r]=I0<<24|u<<16|u<<8|u}else if(H==2)for(var r=0;r>>2)]>>>6-((r&3)<<1)&3),I0=u==L*85?0:255;W[J0+r]=I0<<24|u<<16|u<<8|u}else if(H==4)for(var r=0;r>>1)]>>>4-((r&1)<<2)&15),I0=u==L*17?0:255;W[J0+r]=I0<<24|u<<16|u<<8|u}else if(H==8)for(var r=0;r>>2<<3);while(Q==0){if(Q=B(X,z,1),Y=B(X,z+1,2),z+=3,Y==0){if((z&7)!=0)z+=8-(z&7);var S=(z>>>3)+4,h=X[S-4]|X[S-3]<<8;if($)V=q.H.W(V,U+h);V.set(new K(X.buffer,X.byteOffset+S,h),U),z=S+h<<3,U+=h;continue}if($)V=q.H.W(V,U+131072);if(Y==1)k=w.J,M=w.h,Z=511,H=31;if(Y==2){J=L(X,z,5)+257,G=L(X,z+5,5)+1,W=L(X,z+10,4)+4,z+=14;var b=z,C=1;for(var D=0;D<38;D+=2)w.Q[D]=0,w.Q[D+1]=0;for(var D=0;DC)C=l}z+=3*W,N(w.Q,C),R(w.Q,C,w.u),k=w.w,M=w.d,z=O(w.u,(1<>>4;if(r>>>8==0)V[U++]=r;else if(r==256)break;else{var I0=U+r-254;if(r>264){var n0=w.q[r-257];I0=U+(n0>>>3)+L(X,z,n0&7),z+=n0&7}var N8=M[v(X,z)&H];z+=N8&15;var S8=N8>>>4,y2=w.c[S8],Z2=(y2>>>4)+B(X,z,y2&15);z+=y2&15;while(U>>4;if(U<=15)J[Z]=U,Z++;else{var z=0,k=0;if(U==16)k=3+G(Q,Y,2),Y+=2,z=J[Z-1];else if(U==17)k=3+G(Q,Y,3),Y+=3;else if(U==18)k=11+G(Q,Y,7),Y+=7;var M=Z+k;while(Z>>1;while(JY)Y=W;J++}while(J>1,Z=X[G+1],H=W<<4|Z,U=V-Z,z=X[G]<>>15-V;K[M]=H,z++}}},q.H.l=function(X,V){var K=q.H.m.r,Q=15-V;for(var Y=0;Y>>Q}},q.H.M=function(X,V,K){K=K<<(V&7);var Q=V>>>3;X[Q]|=K,X[Q+1]|=K>>>8},q.H.I=function(X,V,K){K=K<<(V&7);var Q=V>>>3;X[Q]|=K,X[Q+1]|=K>>>8,X[Q+2]|=K>>>16},q.H.e=function(X,V,K){return(X[V>>>3]|X[(V>>>3)+1]<<8)>>>(V&7)&(1<>>3]|X[(V>>>3)+1]<<8|X[(V>>>3)+2]<<16)>>>(V&7)&(1<>>3]|X[(V>>>3)+1]<<8|X[(V>>>3)+2]<<16)>>>(V&7)},q.H.i=function(X,V){return(X[V>>>3]|X[(V>>>3)+1]<<8|X[(V>>>3)+2]<<16|X[(V>>>3)+3]<<24)>>>(V&7)},q.H.m=function(){var X=Uint16Array,V=Uint32Array;return{K:new X(16),j:new X(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new X(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new V(32),J:new X(512),_:[],h:new X(32),$:[],w:new X(32768),C:[],v:[],d:new X(32768),D:[],u:new X(512),Q:[],r:new X(32768),s:new V(286),Y:new V(30),a:new V(19),t:new V(15000),k:new X(65536),g:new X(32768)}}(),function(){var X=q.H.m,V=32768;for(var K=0;K>>1|(Q&1431655765)<<1,Q=(Q&3435973836)>>>2|(Q&858993459)<<2,Q=(Q&4042322160)>>>4|(Q&252645135)<<4,Q=(Q&4278255360)>>>8|(Q&16711935)<<8,X.r[K]=(Q>>>16|Q<<16)>>>17}function Y(J,G,W){while(G--!=0)J.push(0,W)}for(var K=0;K<32;K++)X.q[K]=X.S[K]<<3|X.T[K],X.c[K]=X.p[K]<<4|X.z[K];Y(X._,144,8),Y(X._,112,9),Y(X._,24,7),Y(X._,8,8),q.H.n(X._,9),q.H.A(X._,9,X.J),q.H.l(X._,9),Y(X.$,32,5),q.H.n(X.$,5),q.H.A(X.$,5,X.h),q.H.l(X.$,5),Y(X.Q,19,0),Y(X.C,286,0),Y(X.D,30,0),Y(X.v,320,0)}(),q.H.N}();P.decode._readInterlace=function(q,X){var{width:V,height:K}=X,Q=P.decode._getBPP(X),Y=Q>>3,J=Math.ceil(V*Q/8),G=new Uint8Array(K*J),W=0,Z=[0,0,4,0,2,0,1],H=[0,4,0,2,0,1,0],U=[8,8,8,4,4,2,2],z=[8,8,4,4,2,2,1],k=0;while(k<7){var M=U[k],j=z[k],B=0,L=0,O=Z[k];while(O>3];h=h>>7-(S&7)&1,G[w*J+($>>3)]|=h<<7-(($&7)<<0)}if(Q==2){var h=q[S>>3];h=h>>6-(S&7)&3,G[w*J+($>>2)]|=h<<6-(($&3)<<1)}if(Q==4){var h=q[S>>3];h=h>>4-(S&7)&15,G[w*J+($>>1)]|=h<<4-(($&1)<<2)}if(Q>=8){var b=w*J+$*Y;for(var C=0;C>3)+C]}S+=Q,$+=j}v++,w+=M}if(B*L!=0)W+=L*(1+R);k=k+1}return G};P.decode._getBPP=function(q){var X=[1,null,3,1,2,null,4][q.ctype];return X*q.depth};P.decode._filterZero=function(q,X,V,K,Q){var Y=P.decode._getBPP(X),J=Math.ceil(K*Y/8),G=P.decode._paeth;Y=Math.ceil(Y/8);var W=0,Z=1,H=q[V],U=0;if(H>1)q[V]=[0,0,1][H-2];if(H==3)for(U=Y;U>>1)&255;for(var z=0;z>>1);for(;U>>1)}else{for(;U>8&255,q[X+1]=V&255},readUint:function(q,X){return q[X]*16777216+(q[X+1]<<16|q[X+2]<<8|q[X+3])},writeUint:function(q,X,V){q[X]=V>>24&255,q[X+1]=V>>16&255,q[X+2]=V>>8&255,q[X+3]=V&255},readASCII:function(q,X,V){var K="";for(var Q=0;Q=0&&G>=0)U=k*X+M<<2,z=(G+k)*Q+J+M<<2;else U=(-G+k)*X-J+M<<2,z=k*Q+M<<2;if(W==0)K[z]=q[U],K[z+1]=q[U+1],K[z+2]=q[U+2],K[z+3]=q[U+3];else if(W==1){var j=q[U+3]*0.00392156862745098,B=q[U]*j,L=q[U+1]*j,O=q[U+2]*j,N=K[z+3]*0.00392156862745098,R=K[z]*N,v=K[z+1]*N,w=K[z+2]*N,$=1-j,S=j+N*$,h=S==0?0:1/S;K[z+3]=255*S,K[z+0]=(B+R*$)*h,K[z+1]=(L+v*$)*h,K[z+2]=(O+w*$)*h}else if(W==2){var j=q[U+3],B=q[U],L=q[U+1],O=q[U+2],N=K[z+3],R=K[z],v=K[z+1],w=K[z+2];if(j==N&&B==R&&L==v&&O==w)K[z]=0,K[z+1]=0,K[z+2]=0,K[z+3]=0;else K[z]=B,K[z+1]=L,K[z+2]=O,K[z+3]=j}else if(W==3){var j=q[U+3],B=q[U],L=q[U+1],O=q[U+2],N=K[z+3],R=K[z],v=K[z+1],w=K[z+2];if(j==N&&B==R&&L==v&&O==w)continue;if(j<220&&N>20)return!1}}return!0};P.encode=function(q,X,V,K,Q,Y,J){if(K==null)K=0;if(J==null)J=!1;var G=P.encode.compress(q,X,V,K,[!1,!1,!1,0,J]);return P.encode.compressPNG(G,-1),P.encode._main(G,X,V,Q,Y)};P.encodeLL=function(q,X,V,K,Q,Y,J,G){var W={ctype:0+(K==1?0:2)+(Q==0?0:4),depth:Y,frames:[]},Z=Date.now(),H=(K+Q)*Y,U=H*X;for(var z=0;z1,U=!1,z=33+(H?20:0);if(Q.sRGB!=null)z+=13;if(Q.pHYs!=null)z+=21;if(q.ctype==3){var k=q.plte.length;for(var M=0;M>>24!=255)U=!0;z+=8+k*3+4+(U?8+k*1+4:0)}for(var j=0;j>>8&255,$=R>>>16&255;L[Z+N+0]=v,L[Z+N+1]=w,L[Z+N+2]=$}if(Z+=k*3,J(L,Z,Y(L,Z-k*3-4,k*3+4)),Z+=4,U){J(L,Z,k),Z+=4,W(L,Z,"tRNS"),Z+=4;for(var M=0;M>>24&255;Z+=k,J(L,Z,Y(L,Z-k-4,k+4)),Z+=4}}var S=0;for(var j=0;j>2,D>>2));for(var k=0;kq0&&r==u[B-q0])J0[B]=J0[B-q0];else{var I0=N[r];if(I0==null){if(N[r]=I0=R.length,R.push(r),R.length>=300)break}J0[B]=I0}}}var n0=R.length;if(n0<=256&&Z==!1){if(n0<=2)U=1;else if(n0<=4)U=2;else if(n0<=16)U=4;else U=8;U=Math.max(U,W)}for(var k=0;k>1)]|=N1[y1+R0]<<4-(R0&1)*4;else if(U==2)for(var R0=0;R0>2)]|=N1[y1+R0]<<6-(R0&3)*2;else if(U==1)for(var R0=0;R0>3)]|=N1[y1+R0]<<7-(R0&7)*1}Z2=$2,H=3,bq=1}else if(L==!1&&O.length==1){var $2=new Uint8Array(q0*y2*3),pK=q0*y2;for(var B=0;B$)$=b;if(hS)S=h}}if($==-1)v=w=$=S=0;if(Q){if((v&1)==1)v--;if((w&1)==1)w--}var D=($-v+1)*(S-w+1);if(DB)B=R;if(vL)L=v}}if(B==-1)M=j=B=L=0;if(J){if((M&1)==1)M--;if((j&1)==1)j--}Y={x:M,y:j,width:B-M+1,height:L-j+1};var S=K[Q];if(S.rect=Y,S.blend=1,S.img=new Uint8Array(Y.width*Y.height*4),K[Q-1].dispose==0)P._copyTile(Z,X,V,S.img,Y.width,Y.height,-Y.x,-Y.y,0),P.encode._prepareDiff(z,X,V,S.img,Y);else P._copyTile(z,X,V,S.img,Y.width,Y.height,-Y.x,-Y.y,0)};P.encode._prepareDiff=function(q,X,V,K,Q){P._copyTile(q,X,V,K,Q.width,Q.height,-Q.x,-Q.y,2)};P.encode._filterZero=function(q,X,V,K,Q,Y,J){var G=[],W=[0,1,2,3,4];if(Y!=-1)W=[Y];else if(X*K>500000||V==1)W=[0];var Z;if(J)Z={level:0};var H=J&&UZIP!=null?UZIP:kK.default;for(var U=0;U>1)+256&255;if(Y==4)for(var Z=Q;Z>1)&255;for(var Z=Q;Z>1)&255}if(Y==4){for(var Z=0;Z>>1;else V=V>>>1;q[X]=V}return q}(),update:function(q,X,V,K){for(var Q=0;Q>>8;return q},crc:function(q,X,V){return P.crc.update(4294967295,q,X,V)^4294967295}};P.quantize=function(q,X){var V=new Uint8Array(q),K=V.slice(0),Q=new Uint32Array(K.buffer),Y=P.quantize.getKDtree(K,X),J=Y[0],G=Y[1],W=P.quantize.planeDst,Z=V,H=Q,U=Z.length,z=new Uint8Array(V.length>>2);for(var k=0;k>2]=O.ind,H[k>>2]=O.est.rgba}return{abuf:K.buffer,inds:z,plte:G}};P.quantize.getKDtree=function(q,X,V){if(V==null)V=0.0001;var K=new Uint32Array(q.buffer),Q={i0:0,i1:q.length,bst:null,est:null,tdst:0,left:null,right:null};Q.bst=P.quantize.stats(q,Q.i0,Q.i1),Q.est=P.quantize.estats(Q.bst);var Y=[Q];while(Y.lengthJ)J=Y[W].est.L,G=W;if(J=H||Z.i1<=H;if(U){Z.est.L=0;continue}var z={i0:Z.i0,i1:H,bst:null,est:null,tdst:0,left:null,right:null};z.bst=P.quantize.stats(q,z.i0,z.i1),z.est=P.quantize.estats(z.bst);var k={i0:H,i1:Z.i1,bst:null,est:null,tdst:0,left:null,right:null};k.bst={R:[],m:[],N:Z.bst.N-z.bst.N};for(var W=0;W<16;W++)k.bst.R[W]=Z.bst.R[W]-z.bst.R[W];for(var W=0;W<4;W++)k.bst.m[W]=Z.bst.m[W]-z.bst.m[W];k.est=P.quantize.estats(k.bst),Z.left=z,Z.right=k,Y[G]=z,Y.push(k)}Y.sort(function(M,j){return j.bst.N-M.bst.N});for(var W=0;W0)J=q.right,G=q.left;var W=P.quantize.getNearest(J,X,V,K,Q);if(W.tdst<=Y*Y)return W;var Z=P.quantize.getNearest(G,X,V,K,Q);return Z.tdstY)K-=4;if(V>=K)break;var W=X[V>>2];X[V>>2]=X[K>>2],X[K>>2]=W,V+=4,K-=4}while(J(q,V,Q)>Y)V-=4;return V+4};P.quantize.vecDot=function(q,X,V){return q[X]*V[0]+q[X+1]*V[1]+q[X+2]*V[2]+q[X+3]*V[3]};P.quantize.stats=function(q,X,V){var K=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Q=[0,0,0,0],Y=V-X>>2;for(var J=X;J>>0}};P.M4={multVec:function(q,X){return[q[0]*X[0]+q[1]*X[1]+q[2]*X[2]+q[3]*X[3],q[4]*X[0]+q[5]*X[1]+q[6]*X[2]+q[7]*X[3],q[8]*X[0]+q[9]*X[1]+q[10]*X[2]+q[11]*X[3],q[12]*X[0]+q[13]*X[1]+q[14]*X[2]+q[15]*X[3]]},dot:function(q,X){return q[0]*X[0]+q[1]*X[1]+q[2]*X[2]+q[3]*X[3]},sml:function(q,X){return[q*X[0],q*X[1],q*X[2],q*X[3]]}};P.encode.concatRGBA=function(q){var X=0;for(var V=0;V1)throw Error("Animated PNGs are not supported");var Q=new Uint8Array(K[0]),Y=lG(Q),J=Y.rgbChannel,G=Y.alphaChannel;this.rgbChannel=J;var W=G.some(function(Z){return Z<255});if(W)this.alphaChannel=G;this.type=fG(V.ctype),this.width=V.width,this.height=V.height,this.bitsPerComponent=8}return q.load=function(X){return new q(X)},q}();var _G=function(){function q(X){this.image=X,this.bitsPerComponent=X.bitsPerComponent,this.width=X.width,this.height=X.height,this.colorSpace="DeviceRGB"}return q.for=function(X){return _(this,void 0,void 0,function(){var V;return c(this,function(K){return V=IK.load(X),[2,new q(V)]})})},q.prototype.embedIntoContext=function(X,V){return _(this,void 0,void 0,function(){var K,Q;return c(this,function(Y){if(K=this.embedAlphaChannel(X),Q=X.flateStream(this.image.rgbChannel,{Type:"XObject",Subtype:"Image",BitsPerComponent:this.image.bitsPerComponent,Width:this.image.width,Height:this.image.height,ColorSpace:this.colorSpace,SMask:K}),V)return X.assign(V,Q),[2,V];else return[2,X.register(Q)];return[2]})})},q.prototype.embedAlphaChannel=function(X){if(!this.image.alphaChannel)return;var V=X.flateStream(this.image.alphaChannel,{Type:"XObject",Subtype:"Image",Height:this.image.height,Width:this.image.width,BitsPerComponent:this.image.bitsPerComponent,ColorSpace:"DeviceGray",Decode:[0,1]});return X.register(V)},q}(),X8=_G;var cG=function(){function q(X,V,K){this.bytes=X,this.start=V||0,this.pos=this.start,this.end=!!V&&!!K?V+K:this.bytes.length}return Object.defineProperty(q.prototype,"length",{get:function(){return this.end-this.start},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isEmpty",{get:function(){return this.length===0},enumerable:!1,configurable:!0}),q.prototype.getByte=function(){if(this.pos>=this.end)return-1;return this.bytes[this.pos++]},q.prototype.getUint16=function(){var X=this.getByte(),V=this.getByte();if(X===-1||V===-1)return-1;return(X<<8)+V},q.prototype.getInt32=function(){var X=this.getByte(),V=this.getByte(),K=this.getByte(),Q=this.getByte();return(X<<24)+(V<<16)+(K<<8)+Q},q.prototype.getBytes=function(X,V){if(V===void 0)V=!1;var K=this.bytes,Q=this.pos,Y=this.end;if(!X){var J=K.subarray(Q,Y);return V?new Uint8ClampedArray(J):J}else{var G=Q+X;if(G>Y)G=Y;this.pos=G;var J=K.subarray(Q,G);return V?new Uint8ClampedArray(J):J}},q.prototype.peekByte=function(){var X=this.getByte();return this.pos--,X},q.prototype.peekBytes=function(X,V){if(V===void 0)V=!1;var K=this.getBytes(X,V);return this.pos-=K.length,K},q.prototype.skip=function(X){if(!X)X=1;this.pos+=X},q.prototype.reset=function(){this.pos=this.start},q.prototype.moveStart=function(){this.start=this.pos},q.prototype.makeSubStream=function(X,V){return new q(this.bytes,X,V)},q.prototype.decode=function(){return this.bytes},q}(),Hq=cG;var pG=new Uint8Array(0),dG=function(){function q(X){if(this.pos=0,this.bufferLength=0,this.eof=!1,this.buffer=pG,this.minBufferLength=512,X)while(this.minBufferLengthY)K=Y}else{while(!this.eof)this.readBlock();K=this.bufferLength}this.pos=K;var J=this.buffer.subarray(Q,K);return V&&!(J instanceof Uint8ClampedArray)?new Uint8ClampedArray(J):J},q.prototype.peekByte=function(){var X=this.getByte();return this.pos--,X},q.prototype.peekBytes=function(X,V){if(V===void 0)V=!1;var K=this.getBytes(X,V);return this.pos-=K.length,K},q.prototype.skip=function(X){if(!X)X=1;this.pos+=X},q.prototype.reset=function(){this.pos=0},q.prototype.makeSubStream=function(X,V){var K=X+V;while(this.bufferLength<=K&&!this.eof)this.readBlock();return new Hq(this.buffer,X,V)},q.prototype.decode=function(){while(!this.eof)this.readBlock();return this.buffer.subarray(0,this.bufferLength)},q.prototype.readBlock=function(){throw new u0(this.constructor.name,"readBlock")},q.prototype.ensureBuffer=function(X){var V=this.buffer;if(X<=V.byteLength)return V;var K=this.minBufferLength;while(K=0;--Z)W[G+Z]=U&255,U>>=8}},X}(d2),jK=nG;var rG=function(q){A(X,q);function X(V,K){var Q=q.call(this,K)||this;if(Q.stream=V,Q.firstDigit=-1,K)K=0.5*K;return Q}return X.prototype.readBlock=function(){var V=8000,K=this.stream.getBytes(V);if(!K.length){this.eof=!0;return}var Q=K.length+1>>1,Y=this.ensureBuffer(this.bufferLength+Q),J=this.bufferLength,G=this.firstDigit;for(var W=0,Z=K.length;W=48&&H<=57)U=H&15;else if(H>=65&&H<=70||H>=97&&H<=102)U=(H&15)+9;else if(H===62){this.eof=!0;break}else continue;if(G<0)G=U;else Y[J++]=G<<4|U,G=-1}if(G>=0&&this.eof)Y[J++]=G<<4,G=-1;this.firstDigit=G,this.bufferLength=J},X}(d2),LK=rG;var BK=new Int32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),iG=new Int32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),aG=new Int32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),oG=[new Int32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,590000,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],sG=[new Int32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5],tG=function(q){A(X,q);function X(V,K){var Q=q.call(this,K)||this;Q.stream=V;var Y=V.getByte(),J=V.getByte();if(Y===-1||J===-1)throw Error("Invalid header in flate stream: "+Y+", "+J);if((Y&15)!==8)throw Error("Unknown compression method in flate stream: "+Y+", "+J);if(((Y<<8)+J)%31!==0)throw Error("Bad FCHECK in flate stream: "+Y+", "+J);if(J&32)throw Error("FDICT bit set in flate stream: "+Y+", "+J);return Q.codeSize=0,Q.codeBuf=0,Q}return X.prototype.readBlock=function(){var V,K,Q=this.stream,Y=this.getBits(3);if(Y&1)this.eof=!0;if(Y>>=1,Y===0){var J=void 0;if((J=Q.getByte())===-1)throw Error("Bad block header in flate stream");var G=J;if((J=Q.getByte())===-1)throw Error("Bad block header in flate stream");if(G|=J<<8,(J=Q.getByte())===-1)throw Error("Bad block header in flate stream");var W=J;if((J=Q.getByte())===-1)throw Error("Bad block header in flate stream");if(W|=J<<8,W!==(~G&65535)&&(G!==0||W!==0))throw Error("Bad uncompressed block length in flate stream");this.codeBuf=0,this.codeSize=0;var Z=this.bufferLength;V=this.ensureBuffer(Z+G);var H=Z+G;if(this.bufferLength=H,G===0){if(Q.peekByte()===-1)this.eof=!0}else for(var U=Z;U0)v[O++]=S}z=this.generateHuffmanTable(v.subarray(0,M)),k=this.generateHuffmanTable(v.subarray(M,R))}else throw Error("Unknown block type in flate stream");V=this.buffer;var C=V?V.length:0,D=this.bufferLength;while(!0){var l=this.getCode(z);if(l<256){if(D+1>=C)V=this.ensureBuffer(D+1),C=V.length;V[D++]=l;continue}if(l===256){this.bufferLength=D;return}l-=257,l=iG[l];var u=l>>16;if(u>0)u=this.getBits(u);if(K=(l&65535)+u,l=this.getCode(k),l=aG[l],u=l>>16,u>0)u=this.getBits(u);var q0=(l&65535)+u;if(D+K>=C)V=this.ensureBuffer(D+K),C=V.length;for(var J0=0;J0>V,this.codeSize=Q-=V,J},X.prototype.getCode=function(V){var K=this.stream,Q=V[0],Y=V[1],J=this.codeSize,G=this.codeBuf,W;while(J>16,U=Z&65535;if(H<1||J>H,this.codeSize=J-H,U},X.prototype.generateHuffmanTable=function(V){var K=V.length,Q=0,Y;for(Y=0;YQ)Q=V[Y];var J=1<>=1;for(Y=z;Y0;if(!v||v<256)B[0]=v,L=1;else if(v>=258)if(v=0;J--)B[J]=U[G],G=k[G]}else B[L++]=B[0];else if(v===256){M=9,H=258,L=0;continue}else{this.eof=!0,delete this.lzwState;break}if(w)k[H]=j,z[H]=z[j]+1,U[H]=B[0],H++,M=H+Z&H+Z-1?M:Math.min(Math.log(H+Z)/0.6931471805599453+1,12)|0;if(j=v,O+=L,K>>K&(1<0){var J=this.stream.getBytes(Y);K.set(J,Q),Q+=Y}}else{Y=257-Y;var G=V[1];K=this.ensureBuffer(Q+Y+1);for(var W=0;WK.size())throw new Y5(V,0,K.size());K.remove(V)}},X.prototype.normalizedEntries=function(){var V=this.Kids();if(!V)V=this.dict.context.obj([this.ref]),this.dict.set(I.of("Kids"),V);return{Kids:V}},X.fromDict=function(V,K){return new X(V,K)},X}(Y8),K2=UZ;var zZ=function(q){A(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.prototype.Opt=function(){return this.dict.lookupMaybe(I.of("Opt"),K0,g,i)},X.prototype.setOpt=function(V){this.dict.set(I.of("Opt"),this.dict.context.obj(V))},X.prototype.getExportValues=function(){var V=this.Opt();if(!V)return;if(V instanceof K0||V instanceof g)return[V];var K=[];for(var Q=0,Y=V.size();QK.size())throw new Y5(V,0,K.size());K.remove(V)}},X.prototype.normalizeExportValues=function(){var V,K,Q,Y,J=(V=this.getExportValues())!==null&&V!==void 0?V:[],G=[],W=this.getWidgets();for(var Z=0,H=W.length;Z1){if(!this.hasFlag(G0.MultiSelect))throw new W7;this.dict.set(I.of("V"),this.dict.context.obj(V))}this.updateSelectedIndices(V)},X.prototype.valuesAreValid=function(V){var K=this.getOptions(),Q=function(W,Z){var H=V[W].decodeText();if(!K.find(function(U){return H===(U.display||U.value).decodeText()}))return{value:!1}};for(var Y=0,J=V.length;Y1){var K=Array(V.length),Q=this.getOptions(),Y=function(W,Z){var H=V[W].decodeText();K[W]=Q.findIndex(function(U){return H===(U.display||U.value).decodeText()})};for(var J=0,G=V.length;J0){var G=J.lookup(0,K0,g),W=J.lookupMaybe(1,K0,g);K.push({value:G,display:W||G})}}}return K}return[]},X}(K2),G8=kZ;var IZ=function(q){A(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.fromDict=function(V,K){return new X(V,K)},X.create=function(V){var K=V.obj({FT:"Ch",Ff:G0.Combo,Kids:[]}),Q=V.register(K);return new X(K,Q)},X}(G8),Q6=IZ;var EZ=function(q){A(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.prototype.addField=function(V){var K=this.normalizedEntries().Kids;K===null||K===void 0||K.push(V)},X.prototype.normalizedEntries=function(){var V=this.Kids();if(!V)V=this.dict.context.obj([]),this.dict.set(I.of("Kids"),V);return{Kids:V}},X.fromDict=function(V,K){return new X(V,K)},X.create=function(V){var K=V.obj({}),Q=V.register(K);return new X(K,Q)},X}(Y8),Y6=EZ;var jZ=function(q){A(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.fromDict=function(V,K){return new X(V,K)},X}(K2),F6=jZ;var LZ=function(q){A(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.prototype.MaxLen=function(){var V=this.dict.lookup(I.of("MaxLen"));if(V instanceof x)return V;return},X.prototype.Q=function(){var V=this.dict.lookup(I.of("Q"));if(V instanceof x)return V;return},X.prototype.setMaxLength=function(V){this.dict.set(I.of("MaxLen"),x.of(V))},X.prototype.removeMaxLength=function(){this.dict.delete(I.of("MaxLen"))},X.prototype.getMaxLength=function(){var V;return(V=this.MaxLen())===null||V===void 0?void 0:V.asNumber()},X.prototype.setQuadding=function(V){this.dict.set(I.of("Q"),x.of(V))},X.prototype.getQuadding=function(){var V;return(V=this.Q())===null||V===void 0?void 0:V.asNumber()},X.prototype.setValue=function(V){this.dict.set(I.of("V"),V)},X.prototype.removeValue=function(){this.dict.delete(I.of("V"))},X.prototype.getValue=function(){var V=this.V();if(V instanceof K0||V instanceof g)return V;return},X.fromDict=function(V,K){return new X(V,K)},X.create=function(V){var K=V.obj({FT:"Tx",Kids:[]}),Q=V.register(K);return new X(K,Q)},X}(K2),J6=LZ;var BZ=function(q){A(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.fromDict=function(V,K){return new X(V,K)},X.create=function(V){var K=V.obj({FT:"Btn",Ff:f0.PushButton,Kids:[]}),Q=V.register(K);return new X(K,Q)},X}(h6),G6=BZ;var TZ=function(q){A(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.prototype.setValue=function(V){var K=this.getOnValues();if(!K.includes(V)&&V!==I.of("Off"))throw new J5;this.dict.set(I.of("V"),V);var Q=this.getWidgets();for(var Y=0,J=Q.length;YY)throw new qq(K,Y);var J=K;for(var G=0,W=Q.size();GJ)return H.insertLeafNode(V,J)||Z;else J-=H.Count().asNumber();if(H instanceof _0)J-=1}if(J===0){this.insertLeafKid(Q.size(),V);return}throw new Xq(K,"insertLeafNode")},X.prototype.removeLeafNode=function(V,K){if(K===void 0)K=!0;var Q=this.Kids(),Y=this.Count().asNumber();if(V>=Y)throw new qq(V,Y);var J=V;for(var G=0,W=Q.size();GJ){if(H.removeLeafNode(J,K),K&&H.Kids().size()===0)Q.remove(G);return}else J-=H.Count().asNumber();if(H instanceof _0)if(J===0){this.removeKid(G);return}else J-=1}throw new Xq(V,"removeLeafNode")},X.prototype.ascend=function(V){V(this);var K=this.Parent();if(K)K.ascend(V)},X.prototype.traverse=function(V){var K=this.Kids();for(var Q=0,Y=K.size();QNumber.MAX_SAFE_INTEGER)if(this.capNumbers){var Q="Parsed number that is too large for some PDF readers: "+X+", using Number.MAX_SAFE_INTEGER instead.";return console.warn(Q),Number.MAX_SAFE_INTEGER}else{var Q="Parsed number that is too large for some PDF readers: "+X+", not capping.";console.warn(Q)}return K},q.prototype.skipWhitespace=function(){while(!this.bytes.done()&&k2[this.bytes.peek()])this.bytes.next()},q.prototype.skipLine=function(){while(!this.bytes.done()){var X=this.bytes.peek();if(X===AK||X===NK)return;this.bytes.next()}},q.prototype.skipComment=function(){if(this.bytes.peek()!==E.Percent)return!1;while(!this.bytes.done()){var X=this.bytes.peek();if(X===AK||X===NK)return!0;this.bytes.next()}return!0},q.prototype.skipWhitespaceAndComments=function(){this.skipWhitespace();while(this.skipComment())this.skipWhitespace()},q.prototype.matchKeyword=function(X){var V=this.bytes.offset();for(var K=0,Q=X.length;K=this.length},q.prototype.offset=function(){return this.idx},q.prototype.slice=function(X,V){return this.bytes.slice(X,V)},q.prototype.position=function(){return{line:this.line,column:this.column,offset:this.idx}},q.of=function(X){return new q(X)},q.fromPDFRawStream=function(X){return q.of(V8(X).decode())},q}(),D6=CZ;var hZ=E.Space,U1=E.CarriageReturn,z1=E.Newline,M1=[E.s,E.t,E.r,E.e,E.a,E.m],Eq=[E.e,E.n,E.d,E.s,E.t,E.r,E.e,E.a,E.m],M0={header:[E.Percent,E.P,E.D,E.F,E.Dash],eof:[E.Percent,E.Percent,E.E,E.O,E.F],obj:[E.o,E.b,E.j],endobj:[E.e,E.n,E.d,E.o,E.b,E.j],xref:[E.x,E.r,E.e,E.f],trailer:[E.t,E.r,E.a,E.i,E.l,E.e,E.r],startxref:[E.s,E.t,E.a,E.r,E.t,E.x,E.r,E.e,E.f],true:[E.t,E.r,E.u,E.e],false:[E.f,E.a,E.l,E.s,E.e],null:[E.n,E.u,E.l,E.l],stream:M1,streamEOF1:Q0(M1,[hZ,U1,z1]),streamEOF2:Q0(M1,[U1,z1]),streamEOF3:Q0(M1,[U1]),streamEOF4:Q0(M1,[z1]),endstream:Eq,EOF1endstream:Q0([U1,z1],Eq),EOF2endstream:Q0([U1],Eq),EOF3endstream:Q0([z1],Eq)};var FZ=function(q){A(X,q);function X(V,K,Q){if(Q===void 0)Q=!1;var Y=q.call(this,V,Q)||this;return Y.context=K,Y}return X.prototype.parseObject=function(){if(this.skipWhitespaceAndComments(),this.matchKeyword(M0.true))return c2.True;if(this.matchKeyword(M0.false))return c2.False;if(this.matchKeyword(M0.null))return F0;var V=this.bytes.peek();if(V===E.LessThan&&this.bytes.peekAhead(1)===E.LessThan)return this.parseDictOrStream();if(V===E.LessThan)return this.parseHexString();if(V===E.LeftParen)return this.parseString();if(V===E.ForwardSlash)return this.parseName();if(V===E.LeftSquareBracket)return this.parseArray();if(H1[V])return this.parseNumberOrRef();throw new M7(this.bytes.position(),V)},X.prototype.parseNumberOrRef=function(){var V=this.parseRawNumber();this.skipWhitespaceAndComments();var K=this.bytes.offset();if(P0[this.bytes.peek()]){var Q=this.parseRawNumber();if(this.skipWhitespaceAndComments(),this.bytes.peek()===E.R)return this.bytes.assertNext(E.R),a.of(V,Q)}return this.bytes.moveTo(K),x.of(V)},X.prototype.parseHexString=function(){var V="";this.bytes.assertNext(E.LessThan);while(!this.bytes.done()&&this.bytes.peek()!==E.GreaterThan)V+=t0(this.bytes.next());return this.bytes.assertNext(E.GreaterThan),g.of(V)},X.prototype.parseString=function(){var V=0,K=!1,Q="";while(!this.bytes.done()){var Y=this.bytes.next();if(Q+=t0(Y),!K){if(Y===E.LeftParen)V+=1;if(Y===E.RightParen)V-=1}if(Y===E.BackSlash)K=!K;else if(K)K=!1;if(V===0)return K0.of(Q.substring(1,Q.length-1))}throw new E7(this.bytes.position())},X.prototype.parseName=function(){this.bytes.assertNext(E.ForwardSlash);var V="";while(!this.bytes.done()){var K=this.bytes.peek();if(k2[K]||V2[K])break;V+=t0(K),this.bytes.next()}return I.of(V)},X.prototype.parseArray=function(){this.bytes.assertNext(E.LeftSquareBracket),this.skipWhitespaceAndComments();var V=i.withContext(this.context);while(this.bytes.peek()!==E.RightSquareBracket){var K=this.parseObject();V.push(K),this.skipWhitespaceAndComments()}return this.bytes.assertNext(E.RightSquareBracket),V},X.prototype.parseDict=function(){this.bytes.assertNext(E.LessThan),this.bytes.assertNext(E.LessThan),this.skipWhitespaceAndComments();var V=new Map;while(!this.bytes.done()&&this.bytes.peek()!==E.GreaterThan&&this.bytes.peekAhead(1)!==E.GreaterThan){var K=this.parseName(),Q=this.parseObject();V.set(K,Q),this.skipWhitespaceAndComments()}this.skipWhitespaceAndComments(),this.bytes.assertNext(E.GreaterThan),this.bytes.assertNext(E.GreaterThan);var Y=V.get(I.of("Type"));if(Y===I.of("Catalog"))return W8.fromMapWithContext(V,this.context);else if(Y===I.of("Pages"))return H8.fromMapWithContext(V,this.context);else if(Y===I.of("Page"))return _0.fromMapWithContext(V,this.context);else return m.fromMapWithContext(V,this.context)},X.prototype.parseDictOrStream=function(){var V=this.bytes.position(),K=this.parseDict();if(this.skipWhitespaceAndComments(),!this.matchKeyword(M0.streamEOF1)&&!this.matchKeyword(M0.streamEOF2)&&!this.matchKeyword(M0.streamEOF3)&&!this.matchKeyword(M0.streamEOF4)&&!this.matchKeyword(M0.stream))return K;var Q=this.bytes.offset(),Y,J=K.get(I.of("Length"));if(J instanceof x){if(Y=Q+J.asNumber(),this.bytes.moveTo(Y),this.skipWhitespaceAndComments(),!this.matchKeyword(M0.endstream))this.bytes.moveTo(Q),Y=this.findEndOfStreamFallback(V)}else Y=this.findEndOfStreamFallback(V);var G=this.bytes.slice(Q,Y);return A2.of(K,G)},X.prototype.findEndOfStreamFallback=function(V){var K=1,Q=this.bytes.offset();while(!this.bytes.done()){if(Q=this.bytes.offset(),this.matchKeyword(M0.stream))K+=1;else if(this.matchKeyword(M0.EOF1endstream)||this.matchKeyword(M0.EOF2endstream)||this.matchKeyword(M0.EOF3endstream)||this.matchKeyword(M0.endstream))K-=1;else this.bytes.next();if(K===0)break}if(K!==0)throw new I7(V);return Q},X.forBytes=function(V,K,Q){return new X(D6.of(V),K,Q)},X.forByteStream=function(V,K,Q){if(Q===void 0)Q=!1;return new X(V,K,Q)},X}(SK),U8=FZ;var PZ=function(q){A(X,q);function X(V,K){var Q=q.call(this,D6.fromPDFRawStream(V),V.dict.context)||this,Y=V.dict;return Q.alreadyParsed=!1,Q.shouldWaitForTick=K||function(){return!1},Q.firstOffset=Y.lookup(I.of("First"),x).asNumber(),Q.objectCount=Y.lookup(I.of("N"),x).asNumber(),Q}return X.prototype.parseIntoContext=function(){return _(this,void 0,void 0,function(){var V,K,Q,Y,J,G,W,Z;return c(this,function(H){switch(H.label){case 0:if(this.alreadyParsed)throw new Q5("PDFObjectStreamParser","parseIntoContext");this.alreadyParsed=!0,V=this.parseOffsetsAndObjectNumbers(),K=0,Q=V.length,H.label=1;case 1:if(!(K=E.Space&&K<=E.Tilde;if(Q){if(this.matchKeyword(M0.xref)||this.matchKeyword(M0.trailer)||this.matchKeyword(M0.startxref)||this.matchIndirectObjectHeader()){this.bytes.moveTo(V);break}}this.bytes.next()}},X.prototype.skipBinaryHeaderComment=function(){this.skipWhitespaceAndComments();try{var V=this.bytes.offset();this.parseIndirectObjectHeader(),this.bytes.moveTo(V)}catch(K){this.bytes.next(),this.skipWhitespaceAndComments()}},X.forBytesWithOptions=function(V,K,Q,Y){return new X(V,K,Q,Y)},X}(U8),Bq=uZ;var n2=function(q){return 1<0)K[K.length]=+Q;V[V.length]={cmd:X,args:K},K=[],Q="",Y=!1}X=Z}else if([" ",","].includes(Z)||Z==="-"&&Q.length>0&&Q[Q.length-1]!=="e"||Z==="."&&Y){if(Q.length===0)continue;if(K.length===J){if(V[V.length]={cmd:X,args:K},K=[+Q],X==="M")X="L";if(X==="m")X="l"}else K[K.length]=+Q;Y=Z===".",Q=["-","."].includes(Z)?Z:""}else if(Q+=Z,Z===".")Y=!0}if(Q.length>0)if(K.length===J){if(V[V.length]={cmd:X,args:K},K=[+Q],X==="M")X="L";if(X==="m")X="l"}else K[K.length]=+Q;return V[V.length]={cmd:X,args:K},V},oZ=function(q){d=n=Z0=W0=v1=R1=0;var X=[];for(var V=0;V1)z=Math.sqrt(z),V*=z,K*=z;var k=U/V,M=H/V,j=-H/K,B=U/K,L=k*G+M*W,O=j*G+B*W,N=k*q+M*X,R=j*q+B*X,v=(N-L)*(N-L)+(R-O)*(R-O),w=1/v-0.25;if(w<0)w=0;var $=Math.sqrt(w);if(Y===Q)$=-$;var S=0.5*(L+N)-$*(R-O),h=0.5*(O+R)+$*(N-L),b=Math.atan2(O-h,L-S),C=Math.atan2(R-h,N-S),D=C-b;if(D<0&&Y===1)D+=2*Math.PI;else if(D>0&&Y===0)D-=2*Math.PI;var l=Math.ceil(Math.abs(D/(Math.PI*0.5+0.001))),u=[];for(var q0=0;q0q.length)return Q-1;var B=X.heightAtSize(Q),L=B+B*0.2,O=L*Y;if(O>Math.abs(V.height))return Q-1;Q+=1}return Q},K3=function(q,X,V,K){var Q=V.width/K,Y=V.height,J=mK,G=J4(q);while(JQ*0.75;if(U)return J-1}var z=X.heightAtSize(J,{descender:!1});if(z>Y)return J-1;J+=1}return J},Q3=function(q){for(var X=q.length;X>0;X--)if(/\s/.test(q[X]))return X;return},Y3=function(q,X,V,K){var Q,Y=q.length;while(Y>0){var J=q.substring(0,Y),G=V.encodeText(J),W=V.widthOfTextAtSize(J,K);if(Wz)z=$+v;if(M+G>k)k=M+G;Z.push({text:N,encoded:R,width:v,height:G,x:$,y:M}),L=w===null||w===void 0?void 0:w.trim()}}return{fontSize:K,lineHeight:W,lines:Z,bounds:{x:H,y:U,width:z-H,height:k-U}}},KX=function(q,X){var{fontSize:V,font:K,bounds:Q,cellCount:Y}=X,J=F1(k6(q));if(J.length>Y)throw new qX(J.length,Y);if(V===void 0||V===0)V=K3(J,K,Q,Y);var G=Q.width/Y,W=K.heightAtSize(V,{descender:!1}),Z=Q.y+(Q.height/2-W/2),H=[],U=Q.x,z=Q.y,k=Q.x+Q.width,M=Q.y+Q.height,j=0,B=0;while(jk)k=$+v;if(Z+W>M)M=Z+W;H.push({text:J,encoded:R,width:v,height:W,x:$,y:Z}),j+=1,B+=N}return{fontSize:V,cells:H,bounds:{x:U,y:z,width:k-U,height:M-z}}},v8=function(q,X){var{alignment:V,fontSize:K,font:Q,bounds:Y}=X,J=F1(k6(q));if(K===void 0||K===0)K=lK([J],Q,Y);var G=Q.encodeText(J),W=Q.widthOfTextAtSize(J,K),Z=Q.heightAtSize(K,{descender:!1}),H=V===v0.Left?Y.x:V===v0.Center?Y.x+Y.width/2-W/2:V===v0.Right?Y.x+Y.width-W:Y.x,U=Y.y+(Y.height/2-Z/2);return{fontSize:K,line:{text:J,encoded:G,width:W,height:Z,x:H,y:U},bounds:{x:H,y:U,width:W,height:Z}}};var G2=function(q){if("normal"in q)return q;return{normal:q}},J3=/\/([^\0\t\n\f\r\ ]+)[\0\t\n\f\r\ ]+(\d*\.\d+|\d+)[\0\t\n\f\r\ ]+Tf/,m6=function(q){var X,V,K=(X=q.getDefaultAppearance())!==null&&X!==void 0?X:"",Q=(V=F5(K,J3).match)!==null&&V!==void 0?V:[],Y=Number(Q[2]);return isFinite(Y)?Y:void 0},G3=/(\d*\.\d+|\d+)[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]+(g|rg|k)/,L2=function(q){var X,V=(X=q.getDefaultAppearance())!==null&&X!==void 0?X:"",K=F5(V,G3).match,Q=K!==null&&K!==void 0?K:[],Y=Q[1],J=Q[2],G=Q[3],W=Q[4],Z=Q[5];if(Z==="g"&&Y)return Sq(Number(Y));if(Z==="rg"&&Y&&J&&G)return Y0(Number(Y),Number(J),Number(G));if(Z==="k"&&Y&&J&&G&&W)return yq(Number(Y),Number(J),Number(G),Number(W));return},B2=function(q,X,V,K){var Q;if(K===void 0)K=0;var Y=[E2(X).toString(),T5((Q=V===null||V===void 0?void 0:V.name)!==null&&Q!==void 0?Q:"dummy__noop",K).toString()].join(` -`);q.setDefaultAppearance(Y)},QX=function(q,X){var V,K,Q,Y=L2(X),J=L2(q.acroField),G=X.getRectangle(),W=X.getAppearanceCharacteristics(),Z=X.getBorderStyle(),H=(V=Z===null||Z===void 0?void 0:Z.getWidth())!==null&&V!==void 0?V:0,U=I2(W===null||W===void 0?void 0:W.getRotation()),z=r2(G,U),k=z.width,M=z.height,j=j2(o(o({},G),{rotation:U})),B=Y0(0,0,0),L=(K=l0(W===null||W===void 0?void 0:W.getBorderColor()))!==null&&K!==void 0?K:B,O=l0(W===null||W===void 0?void 0:W.getBackgroundColor()),N=l0(W===null||W===void 0?void 0:W.getBackgroundColor(),0.8),R=(Q=Y!==null&&Y!==void 0?Y:J)!==null&&Q!==void 0?Q:B;if(Y)B2(X,R);else B2(q.acroField,R);var v={x:0+H/2,y:0+H/2,width:k-H,height:M-H,thickness:1.5,borderWidth:H,borderColor:L,markColor:R};return{normal:{on:Q0(j,B8(o(o({},v),{color:O,filled:!0}))),off:Q0(j,B8(o(o({},v),{color:O,filled:!1})))},down:{on:Q0(j,B8(o(o({},v),{color:N,filled:!0}))),off:Q0(j,B8(o(o({},v),{color:N,filled:!1})))}}},YX=function(q,X){var V,K,Q,Y=L2(X),J=L2(q.acroField),G=X.getRectangle(),W=X.getAppearanceCharacteristics(),Z=X.getBorderStyle(),H=(V=Z===null||Z===void 0?void 0:Z.getWidth())!==null&&V!==void 0?V:0,U=I2(W===null||W===void 0?void 0:W.getRotation()),z=r2(G,U),k=z.width,M=z.height,j=j2(o(o({},G),{rotation:U})),B=Y0(0,0,0),L=(K=l0(W===null||W===void 0?void 0:W.getBorderColor()))!==null&&K!==void 0?K:B,O=l0(W===null||W===void 0?void 0:W.getBackgroundColor()),N=l0(W===null||W===void 0?void 0:W.getBackgroundColor(),0.8),R=(Q=Y!==null&&Y!==void 0?Y:J)!==null&&Q!==void 0?Q:B;if(Y)B2(X,R);else B2(q.acroField,R);var v={x:k/2,y:M/2,width:k-H,height:M-H,borderWidth:H,borderColor:L,dotColor:R};return{normal:{on:Q0(j,T8(o(o({},v),{color:O,filled:!0}))),off:Q0(j,T8(o(o({},v),{color:O,filled:!1})))},down:{on:Q0(j,T8(o(o({},v),{color:N,filled:!0}))),off:Q0(j,T8(o(o({},v),{color:N,filled:!1})))}}},JX=function(q,X,V){var K,Q,Y,J,G,W=L2(X),Z=L2(q.acroField),H=m6(X),U=m6(q.acroField),z=X.getRectangle(),k=X.getAppearanceCharacteristics(),M=X.getBorderStyle(),j=k===null||k===void 0?void 0:k.getCaptions(),B=(K=j===null||j===void 0?void 0:j.normal)!==null&&K!==void 0?K:"",L=(Y=(Q=j===null||j===void 0?void 0:j.down)!==null&&Q!==void 0?Q:B)!==null&&Y!==void 0?Y:"",O=(J=M===null||M===void 0?void 0:M.getWidth())!==null&&J!==void 0?J:0,N=I2(k===null||k===void 0?void 0:k.getRotation()),R=r2(z,N),v=R.width,w=R.height,$=j2(o(o({},z),{rotation:N})),S=Y0(0,0,0),h=l0(k===null||k===void 0?void 0:k.getBorderColor()),b=l0(k===null||k===void 0?void 0:k.getBackgroundColor()),C=l0(k===null||k===void 0?void 0:k.getBackgroundColor(),0.8),D={x:O,y:O,width:v-O*2,height:w-O*2},l=v8(B,{alignment:v0.Center,fontSize:H!==null&&H!==void 0?H:U,font:V,bounds:D}),u=v8(L,{alignment:v0.Center,fontSize:H!==null&&H!==void 0?H:U,font:V,bounds:D}),q0=Math.min(l.fontSize,u.fontSize),J0=(G=W!==null&&W!==void 0?W:Z)!==null&&G!==void 0?G:S;if(W||H!==void 0)B2(X,J0,V,q0);else B2(q.acroField,J0,V,q0);var r={x:0+O/2,y:0+O/2,width:v-O,height:w-O,borderWidth:O,borderColor:h,textColor:J0,font:V.name,fontSize:q0};return{normal:Q0($,hq(o(o({},r),{color:b,textLines:[l.line]}))),down:Q0($,hq(o(o({},r),{color:C,textLines:[u.line]})))}},GX=function(q,X,V){var K,Q,Y,J,G=L2(X),W=L2(q.acroField),Z=m6(X),H=m6(q.acroField),U=X.getRectangle(),z=X.getAppearanceCharacteristics(),k=X.getBorderStyle(),M=(K=q.getText())!==null&&K!==void 0?K:"",j=(Q=k===null||k===void 0?void 0:k.getWidth())!==null&&Q!==void 0?Q:0,B=I2(z===null||z===void 0?void 0:z.getRotation()),L=r2(U,B),O=L.width,N=L.height,R=j2(o(o({},U),{rotation:B})),v=Y0(0,0,0),w=l0(z===null||z===void 0?void 0:z.getBorderColor()),$=l0(z===null||z===void 0?void 0:z.getBackgroundColor()),S,h,b=q.isCombed()?0:1,C={x:j+b,y:j+b,width:O-(j+b)*2,height:N-(j+b)*2};if(q.isMultiline()){var D=uq(M,{alignment:q.getAlignment(),fontSize:Z!==null&&Z!==void 0?Z:H,font:V,bounds:C});S=D.lines,h=D.fontSize}else if(q.isCombed()){var D=KX(M,{fontSize:Z!==null&&Z!==void 0?Z:H,font:V,bounds:C,cellCount:(Y=q.getMaxLength())!==null&&Y!==void 0?Y:0});S=D.cells,h=D.fontSize}else{var D=v8(M,{alignment:q.getAlignment(),fontSize:Z!==null&&Z!==void 0?Z:H,font:V,bounds:C});S=[D.line],h=D.fontSize}var l=(J=G!==null&&G!==void 0?G:W)!==null&&J!==void 0?J:v;if(G||Z!==void 0)B2(X,l,V,h);else B2(q.acroField,l,V,h);var u={x:0+j/2,y:0+j/2,width:O-j,height:N-j,borderWidth:j!==null&&j!==void 0?j:0,borderColor:w,textColor:l,font:V.name,fontSize:h,color:$,textLines:S,padding:b};return Q0(R,Pq(u))},ZX=function(q,X,V){var K,Q,Y,J=L2(X),G=L2(q.acroField),W=m6(X),Z=m6(q.acroField),H=X.getRectangle(),U=X.getAppearanceCharacteristics(),z=X.getBorderStyle(),k=(K=q.getSelected()[0])!==null&&K!==void 0?K:"",M=(Q=z===null||z===void 0?void 0:z.getWidth())!==null&&Q!==void 0?Q:0,j=I2(U===null||U===void 0?void 0:U.getRotation()),B=r2(H,j),L=B.width,O=B.height,N=j2(o(o({},H),{rotation:j})),R=Y0(0,0,0),v=l0(U===null||U===void 0?void 0:U.getBorderColor()),w=l0(U===null||U===void 0?void 0:U.getBackgroundColor()),$=1,S={x:M+$,y:M+$,width:L-(M+$)*2,height:O-(M+$)*2},h=v8(k,{alignment:v0.Left,fontSize:W!==null&&W!==void 0?W:Z,font:V,bounds:S}),b=h.line,C=h.fontSize,D=(Y=J!==null&&J!==void 0?J:G)!==null&&Y!==void 0?Y:R;if(J||W!==void 0)B2(X,D,V,C);else B2(q.acroField,D,V,C);var l={x:0+M/2,y:0+M/2,width:L-M,height:O-M,borderWidth:M!==null&&M!==void 0?M:0,borderColor:v,textColor:D,font:V.name,fontSize:C,color:w,textLines:[b],padding:$};return Q0(N,Pq(l))},WX=function(q,X,V){var K,Q,Y=L2(X),J=L2(q.acroField),G=m6(X),W=m6(q.acroField),Z=X.getRectangle(),H=X.getAppearanceCharacteristics(),U=X.getBorderStyle(),z=(K=U===null||U===void 0?void 0:U.getWidth())!==null&&K!==void 0?K:0,k=I2(H===null||H===void 0?void 0:H.getRotation()),M=r2(Z,k),j=M.width,B=M.height,L=j2(o(o({},Z),{rotation:k})),O=Y0(0,0,0),N=l0(H===null||H===void 0?void 0:H.getBorderColor()),R=l0(H===null||H===void 0?void 0:H.getBackgroundColor()),v=q.getOptions(),w=q.getSelected();if(q.isSorted())v.sort();var $="";for(var S=0,h=v.length;S1||Q.length===1&&K)this.enableMultiselect();var G=Array(Q.length);for(var W=0,Z=Q.length;W1||Q.length===1&&K)this.enableMultiselect();var J=Array(Q.length);for(var G=0,W=Q.length;GK)throw new XX(V.length,K,this.getName());if(this.markAsDirty(),this.disableRichFormatting(),V)this.acroField.setValue(g.fromText(V));else this.acroField.removeValue()},X.prototype.getAlignment=function(){var V=this.acroField.getQuadding();return V===0?v0.Left:V===1?v0.Center:V===2?v0.Right:v0.Left},X.prototype.setAlignment=function(V){M2(V,"alignment",v0),this.markAsDirty(),this.acroField.setQuadding(V)},X.prototype.getMaxLength=function(){return this.acroField.getMaxLength()},X.prototype.setMaxLength=function(V){if(X2(V,"maxLength",0,Number.MAX_SAFE_INTEGER),this.markAsDirty(),V===void 0)this.acroField.removeMaxLength();else{var K=this.getText();if(K&&K.length>V)throw new VX(K.length,V,this.getName());this.acroField.setMaxLength(V)}},X.prototype.removeMaxLength=function(){this.markAsDirty(),this.acroField.removeMaxLength()},X.prototype.setImage=function(V){var K=this.getAlignment(),Q=K===v0.Center?T2.Center:K===v0.Right?T2.Right:T2.Left,Y=this.acroField.getWidgets();for(var J=0,G=Y.length;J"u")globalThis.Buffer=y;if(typeof globalThis.process>"u")globalThis.process=N3;globalThis.__bundles=globalThis.__bundles||{};globalThis.__bundles["pdf-lib"]=UX;})(); +end`},HK=function(){var q=[];for(var X=0;X"},Gq=function(q){return D2(q,4)},FG=function(q){if(j4(q))return Gq(q);if(L4(q)){var X=D1(q),V=u1(q);return""+Gq(X)+Gq(V)}var K=u2(q),Q="0x"+K+" is not a valid UTF-8 or UTF-16 codepoint.";throw Error(Q)};var PG=function(q){var X=0,V=function(K){X|=1<=E.Zero&&Z<=E.Seven){if(K+=W,K.length===3||!(H>="0"&&H<="7"))Y(parseInt(K,8)),K=""}else Y(Z)}return new Uint8Array(V)},X.prototype.decodeText=function(){var V=this.asBytes();if(b8(V))return x8(V);return J1(V)},X.prototype.decodeDate=function(){var V=this.decodeText(),K=P8(V);if(!K)throw new G1(V);return K},X.prototype.asString=function(){return this.value},X.prototype.clone=function(){return X.of(this.value)},X.prototype.toString=function(){return"("+this.value+")"},X.prototype.sizeInBytes=function(){return this.value.length+2},X.prototype.copyBytesInto=function(V,K){return V[K++]=E.LeftParen,K+=k0(this.value,V,K),V[K++]=E.RightParen,this.value.length+2},X.of=function(V){return new X(V)},X.fromDate=function(V){var K=e0(String(V.getUTCFullYear()),4,"0"),Q=e0(String(V.getUTCMonth()+1),2,"0"),Y=e0(String(V.getUTCDate()),2,"0"),J=e0(String(V.getUTCHours()),2,"0"),G=e0(String(V.getUTCMinutes()),2,"0"),W=e0(String(V.getUTCSeconds()),2,"0");return new X("D:"+K+Q+Y+J+G+W+"Z")},X}(z0),K0=DG;var uG=function(){function q(X,V,K,Q){var Y=this;this.allGlyphsInFontSortedById=function(){var J=Array(Y.font.characterSet.length);for(var G=0,W=J.length;G>3)]>>7-((M&7)<<0)&1,D=3*C;G[R]=v[D],G[R+1]=v[D+1],G[R+2]=v[D+2],G[R+3]=C<$?A[C]:255}}if(H==2)for(var S=0;S>2)]>>6-((M&3)<<1)&3,D=3*C;G[R]=v[D],G[R+1]=v[D+1],G[R+2]=v[D+2],G[R+3]=C<$?A[C]:255}}if(H==4)for(var S=0;S>1)]>>4-((M&1)<<2)&15,D=3*C;G[R]=v[D],G[R+1]=v[D+1],G[R+2]=v[D+2],G[R+3]=C<$?A[C]:255}}if(H==8)for(var M=0;M>>3)]>>>7-(r&7)&1),I0=u==L*255?0:255;W[J0+r]=I0<<24|u<<16|u<<8|u}else if(H==2)for(var r=0;r>>2)]>>>6-((r&3)<<1)&3),I0=u==L*85?0:255;W[J0+r]=I0<<24|u<<16|u<<8|u}else if(H==4)for(var r=0;r>>1)]>>>4-((r&1)<<2)&15),I0=u==L*17?0:255;W[J0+r]=I0<<24|u<<16|u<<8|u}else if(H==8)for(var r=0;r>>2<<3);while(Q==0){if(Q=B(X,z,1),Y=B(X,z+1,2),z+=3,Y==0){if((z&7)!=0)z+=8-(z&7);var S=(z>>>3)+4,h=X[S-4]|X[S-3]<<8;if($)V=q.H.W(V,U+h);V.set(new K(X.buffer,X.byteOffset+S,h),U),z=S+h<<3,U+=h;continue}if($)V=q.H.W(V,U+131072);if(Y==1)k=A.J,M=A.h,Z=511,H=31;if(Y==2){J=L(X,z,5)+257,G=L(X,z+5,5)+1,W=L(X,z+10,4)+4,z+=14;var b=z,C=1;for(var D=0;D<38;D+=2)A.Q[D]=0,A.Q[D+1]=0;for(var D=0;DC)C=l}z+=3*W,N(A.Q,C),R(A.Q,C,A.u),k=A.w,M=A.d,z=O(A.u,(1<>>4;if(r>>>8==0)V[U++]=r;else if(r==256)break;else{var I0=U+r-254;if(r>264){var n0=A.q[r-257];I0=U+(n0>>>3)+L(X,z,n0&7),z+=n0&7}var N8=M[v(X,z)&H];z+=N8&15;var S8=N8>>>4,y2=A.c[S8],Z2=(y2>>>4)+B(X,z,y2&15);z+=y2&15;while(U>>4;if(U<=15)J[Z]=U,Z++;else{var z=0,k=0;if(U==16)k=3+G(Q,Y,2),Y+=2,z=J[Z-1];else if(U==17)k=3+G(Q,Y,3),Y+=3;else if(U==18)k=11+G(Q,Y,7),Y+=7;var M=Z+k;while(Z>>1;while(JY)Y=W;J++}while(J>1,Z=X[G+1],H=W<<4|Z,U=V-Z,z=X[G]<>>15-V;K[M]=H,z++}}},q.H.l=function(X,V){var K=q.H.m.r,Q=15-V;for(var Y=0;Y>>Q}},q.H.M=function(X,V,K){K=K<<(V&7);var Q=V>>>3;X[Q]|=K,X[Q+1]|=K>>>8},q.H.I=function(X,V,K){K=K<<(V&7);var Q=V>>>3;X[Q]|=K,X[Q+1]|=K>>>8,X[Q+2]|=K>>>16},q.H.e=function(X,V,K){return(X[V>>>3]|X[(V>>>3)+1]<<8)>>>(V&7)&(1<>>3]|X[(V>>>3)+1]<<8|X[(V>>>3)+2]<<16)>>>(V&7)&(1<>>3]|X[(V>>>3)+1]<<8|X[(V>>>3)+2]<<16)>>>(V&7)},q.H.i=function(X,V){return(X[V>>>3]|X[(V>>>3)+1]<<8|X[(V>>>3)+2]<<16|X[(V>>>3)+3]<<24)>>>(V&7)},q.H.m=function(){var X=Uint16Array,V=Uint32Array;return{K:new X(16),j:new X(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new X(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new V(32),J:new X(512),_:[],h:new X(32),$:[],w:new X(32768),C:[],v:[],d:new X(32768),D:[],u:new X(512),Q:[],r:new X(32768),s:new V(286),Y:new V(30),a:new V(19),t:new V(15000),k:new X(65536),g:new X(32768)}}(),function(){var X=q.H.m,V=32768;for(var K=0;K>>1|(Q&1431655765)<<1,Q=(Q&3435973836)>>>2|(Q&858993459)<<2,Q=(Q&4042322160)>>>4|(Q&252645135)<<4,Q=(Q&4278255360)>>>8|(Q&16711935)<<8,X.r[K]=(Q>>>16|Q<<16)>>>17}function Y(J,G,W){while(G--!=0)J.push(0,W)}for(var K=0;K<32;K++)X.q[K]=X.S[K]<<3|X.T[K],X.c[K]=X.p[K]<<4|X.z[K];Y(X._,144,8),Y(X._,112,9),Y(X._,24,7),Y(X._,8,8),q.H.n(X._,9),q.H.A(X._,9,X.J),q.H.l(X._,9),Y(X.$,32,5),q.H.n(X.$,5),q.H.A(X.$,5,X.h),q.H.l(X.$,5),Y(X.Q,19,0),Y(X.C,286,0),Y(X.D,30,0),Y(X.v,320,0)}(),q.H.N}();P.decode._readInterlace=function(q,X){var{width:V,height:K}=X,Q=P.decode._getBPP(X),Y=Q>>3,J=Math.ceil(V*Q/8),G=new Uint8Array(K*J),W=0,Z=[0,0,4,0,2,0,1],H=[0,4,0,2,0,1,0],U=[8,8,8,4,4,2,2],z=[8,8,4,4,2,2,1],k=0;while(k<7){var M=U[k],j=z[k],B=0,L=0,O=Z[k];while(O>3];h=h>>7-(S&7)&1,G[A*J+($>>3)]|=h<<7-(($&7)<<0)}if(Q==2){var h=q[S>>3];h=h>>6-(S&7)&3,G[A*J+($>>2)]|=h<<6-(($&3)<<1)}if(Q==4){var h=q[S>>3];h=h>>4-(S&7)&15,G[A*J+($>>1)]|=h<<4-(($&1)<<2)}if(Q>=8){var b=A*J+$*Y;for(var C=0;C>3)+C]}S+=Q,$+=j}v++,A+=M}if(B*L!=0)W+=L*(1+R);k=k+1}return G};P.decode._getBPP=function(q){var X=[1,null,3,1,2,null,4][q.ctype];return X*q.depth};P.decode._filterZero=function(q,X,V,K,Q){var Y=P.decode._getBPP(X),J=Math.ceil(K*Y/8),G=P.decode._paeth;Y=Math.ceil(Y/8);var W=0,Z=1,H=q[V],U=0;if(H>1)q[V]=[0,0,1][H-2];if(H==3)for(U=Y;U>>1)&255;for(var z=0;z>>1);for(;U>>1)}else{for(;U>8&255,q[X+1]=V&255},readUint:function(q,X){return q[X]*16777216+(q[X+1]<<16|q[X+2]<<8|q[X+3])},writeUint:function(q,X,V){q[X]=V>>24&255,q[X+1]=V>>16&255,q[X+2]=V>>8&255,q[X+3]=V&255},readASCII:function(q,X,V){var K="";for(var Q=0;Q=0&&G>=0)U=k*X+M<<2,z=(G+k)*Q+J+M<<2;else U=(-G+k)*X-J+M<<2,z=k*Q+M<<2;if(W==0)K[z]=q[U],K[z+1]=q[U+1],K[z+2]=q[U+2],K[z+3]=q[U+3];else if(W==1){var j=q[U+3]*0.00392156862745098,B=q[U]*j,L=q[U+1]*j,O=q[U+2]*j,N=K[z+3]*0.00392156862745098,R=K[z]*N,v=K[z+1]*N,A=K[z+2]*N,$=1-j,S=j+N*$,h=S==0?0:1/S;K[z+3]=255*S,K[z+0]=(B+R*$)*h,K[z+1]=(L+v*$)*h,K[z+2]=(O+A*$)*h}else if(W==2){var j=q[U+3],B=q[U],L=q[U+1],O=q[U+2],N=K[z+3],R=K[z],v=K[z+1],A=K[z+2];if(j==N&&B==R&&L==v&&O==A)K[z]=0,K[z+1]=0,K[z+2]=0,K[z+3]=0;else K[z]=B,K[z+1]=L,K[z+2]=O,K[z+3]=j}else if(W==3){var j=q[U+3],B=q[U],L=q[U+1],O=q[U+2],N=K[z+3],R=K[z],v=K[z+1],A=K[z+2];if(j==N&&B==R&&L==v&&O==A)continue;if(j<220&&N>20)return!1}}return!0};P.encode=function(q,X,V,K,Q,Y,J){if(K==null)K=0;if(J==null)J=!1;var G=P.encode.compress(q,X,V,K,[!1,!1,!1,0,J]);return P.encode.compressPNG(G,-1),P.encode._main(G,X,V,Q,Y)};P.encodeLL=function(q,X,V,K,Q,Y,J,G){var W={ctype:0+(K==1?0:2)+(Q==0?0:4),depth:Y,frames:[]},Z=Date.now(),H=(K+Q)*Y,U=H*X;for(var z=0;z1,U=!1,z=33+(H?20:0);if(Q.sRGB!=null)z+=13;if(Q.pHYs!=null)z+=21;if(q.ctype==3){var k=q.plte.length;for(var M=0;M>>24!=255)U=!0;z+=8+k*3+4+(U?8+k*1+4:0)}for(var j=0;j>>8&255,$=R>>>16&255;L[Z+N+0]=v,L[Z+N+1]=A,L[Z+N+2]=$}if(Z+=k*3,J(L,Z,Y(L,Z-k*3-4,k*3+4)),Z+=4,U){J(L,Z,k),Z+=4,W(L,Z,"tRNS"),Z+=4;for(var M=0;M>>24&255;Z+=k,J(L,Z,Y(L,Z-k-4,k+4)),Z+=4}}var S=0;for(var j=0;j>2,D>>2));for(var k=0;kq0&&r==u[B-q0])J0[B]=J0[B-q0];else{var I0=N[r];if(I0==null){if(N[r]=I0=R.length,R.push(r),R.length>=300)break}J0[B]=I0}}}var n0=R.length;if(n0<=256&&Z==!1){if(n0<=2)U=1;else if(n0<=4)U=2;else if(n0<=16)U=4;else U=8;U=Math.max(U,W)}for(var k=0;k>1)]|=N1[y1+R0]<<4-(R0&1)*4;else if(U==2)for(var R0=0;R0>2)]|=N1[y1+R0]<<6-(R0&3)*2;else if(U==1)for(var R0=0;R0>3)]|=N1[y1+R0]<<7-(R0&7)*1}Z2=$2,H=3,bq=1}else if(L==!1&&O.length==1){var $2=new Uint8Array(q0*y2*3),pK=q0*y2;for(var B=0;B$)$=b;if(hS)S=h}}if($==-1)v=A=$=S=0;if(Q){if((v&1)==1)v--;if((A&1)==1)A--}var D=($-v+1)*(S-A+1);if(DB)B=R;if(vL)L=v}}if(B==-1)M=j=B=L=0;if(J){if((M&1)==1)M--;if((j&1)==1)j--}Y={x:M,y:j,width:B-M+1,height:L-j+1};var S=K[Q];if(S.rect=Y,S.blend=1,S.img=new Uint8Array(Y.width*Y.height*4),K[Q-1].dispose==0)P._copyTile(Z,X,V,S.img,Y.width,Y.height,-Y.x,-Y.y,0),P.encode._prepareDiff(z,X,V,S.img,Y);else P._copyTile(z,X,V,S.img,Y.width,Y.height,-Y.x,-Y.y,0)};P.encode._prepareDiff=function(q,X,V,K,Q){P._copyTile(q,X,V,K,Q.width,Q.height,-Q.x,-Q.y,2)};P.encode._filterZero=function(q,X,V,K,Q,Y,J){var G=[],W=[0,1,2,3,4];if(Y!=-1)W=[Y];else if(X*K>500000||V==1)W=[0];var Z;if(J)Z={level:0};var H=J&&UZIP!=null?UZIP:kK.default;for(var U=0;U>1)+256&255;if(Y==4)for(var Z=Q;Z>1)&255;for(var Z=Q;Z>1)&255}if(Y==4){for(var Z=0;Z>>1;else V=V>>>1;q[X]=V}return q}(),update:function(q,X,V,K){for(var Q=0;Q>>8;return q},crc:function(q,X,V){return P.crc.update(4294967295,q,X,V)^4294967295}};P.quantize=function(q,X){var V=new Uint8Array(q),K=V.slice(0),Q=new Uint32Array(K.buffer),Y=P.quantize.getKDtree(K,X),J=Y[0],G=Y[1],W=P.quantize.planeDst,Z=V,H=Q,U=Z.length,z=new Uint8Array(V.length>>2);for(var k=0;k>2]=O.ind,H[k>>2]=O.est.rgba}return{abuf:K.buffer,inds:z,plte:G}};P.quantize.getKDtree=function(q,X,V){if(V==null)V=0.0001;var K=new Uint32Array(q.buffer),Q={i0:0,i1:q.length,bst:null,est:null,tdst:0,left:null,right:null};Q.bst=P.quantize.stats(q,Q.i0,Q.i1),Q.est=P.quantize.estats(Q.bst);var Y=[Q];while(Y.lengthJ)J=Y[W].est.L,G=W;if(J=H||Z.i1<=H;if(U){Z.est.L=0;continue}var z={i0:Z.i0,i1:H,bst:null,est:null,tdst:0,left:null,right:null};z.bst=P.quantize.stats(q,z.i0,z.i1),z.est=P.quantize.estats(z.bst);var k={i0:H,i1:Z.i1,bst:null,est:null,tdst:0,left:null,right:null};k.bst={R:[],m:[],N:Z.bst.N-z.bst.N};for(var W=0;W<16;W++)k.bst.R[W]=Z.bst.R[W]-z.bst.R[W];for(var W=0;W<4;W++)k.bst.m[W]=Z.bst.m[W]-z.bst.m[W];k.est=P.quantize.estats(k.bst),Z.left=z,Z.right=k,Y[G]=z,Y.push(k)}Y.sort(function(M,j){return j.bst.N-M.bst.N});for(var W=0;W0)J=q.right,G=q.left;var W=P.quantize.getNearest(J,X,V,K,Q);if(W.tdst<=Y*Y)return W;var Z=P.quantize.getNearest(G,X,V,K,Q);return Z.tdstY)K-=4;if(V>=K)break;var W=X[V>>2];X[V>>2]=X[K>>2],X[K>>2]=W,V+=4,K-=4}while(J(q,V,Q)>Y)V-=4;return V+4};P.quantize.vecDot=function(q,X,V){return q[X]*V[0]+q[X+1]*V[1]+q[X+2]*V[2]+q[X+3]*V[3]};P.quantize.stats=function(q,X,V){var K=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Q=[0,0,0,0],Y=V-X>>2;for(var J=X;J>>0}};P.M4={multVec:function(q,X){return[q[0]*X[0]+q[1]*X[1]+q[2]*X[2]+q[3]*X[3],q[4]*X[0]+q[5]*X[1]+q[6]*X[2]+q[7]*X[3],q[8]*X[0]+q[9]*X[1]+q[10]*X[2]+q[11]*X[3],q[12]*X[0]+q[13]*X[1]+q[14]*X[2]+q[15]*X[3]]},dot:function(q,X){return q[0]*X[0]+q[1]*X[1]+q[2]*X[2]+q[3]*X[3]},sml:function(q,X){return[q*X[0],q*X[1],q*X[2],q*X[3]]}};P.encode.concatRGBA=function(q){var X=0;for(var V=0;V1)throw Error("Animated PNGs are not supported");var Q=new Uint8Array(K[0]),Y=lG(Q),J=Y.rgbChannel,G=Y.alphaChannel;this.rgbChannel=J;var W=G.some(function(Z){return Z<255});if(W)this.alphaChannel=G;this.type=fG(V.ctype),this.width=V.width,this.height=V.height,this.bitsPerComponent=8}return q.load=function(X){return new q(X)},q}();var _G=function(){function q(X){this.image=X,this.bitsPerComponent=X.bitsPerComponent,this.width=X.width,this.height=X.height,this.colorSpace="DeviceRGB"}return q.for=function(X){return _(this,void 0,void 0,function(){var V;return c(this,function(K){return V=IK.load(X),[2,new q(V)]})})},q.prototype.embedIntoContext=function(X,V){return _(this,void 0,void 0,function(){var K,Q;return c(this,function(Y){if(K=this.embedAlphaChannel(X),Q=X.flateStream(this.image.rgbChannel,{Type:"XObject",Subtype:"Image",BitsPerComponent:this.image.bitsPerComponent,Width:this.image.width,Height:this.image.height,ColorSpace:this.colorSpace,SMask:K}),V)return X.assign(V,Q),[2,V];else return[2,X.register(Q)];return[2]})})},q.prototype.embedAlphaChannel=function(X){if(!this.image.alphaChannel)return;var V=X.flateStream(this.image.alphaChannel,{Type:"XObject",Subtype:"Image",Height:this.image.height,Width:this.image.width,BitsPerComponent:this.image.bitsPerComponent,ColorSpace:"DeviceGray",Decode:[0,1]});return X.register(V)},q}(),X8=_G;var cG=function(){function q(X,V,K){this.bytes=X,this.start=V||0,this.pos=this.start,this.end=!!V&&!!K?V+K:this.bytes.length}return Object.defineProperty(q.prototype,"length",{get:function(){return this.end-this.start},enumerable:!1,configurable:!0}),Object.defineProperty(q.prototype,"isEmpty",{get:function(){return this.length===0},enumerable:!1,configurable:!0}),q.prototype.getByte=function(){if(this.pos>=this.end)return-1;return this.bytes[this.pos++]},q.prototype.getUint16=function(){var X=this.getByte(),V=this.getByte();if(X===-1||V===-1)return-1;return(X<<8)+V},q.prototype.getInt32=function(){var X=this.getByte(),V=this.getByte(),K=this.getByte(),Q=this.getByte();return(X<<24)+(V<<16)+(K<<8)+Q},q.prototype.getBytes=function(X,V){if(V===void 0)V=!1;var K=this.bytes,Q=this.pos,Y=this.end;if(!X){var J=K.subarray(Q,Y);return V?new Uint8ClampedArray(J):J}else{var G=Q+X;if(G>Y)G=Y;this.pos=G;var J=K.subarray(Q,G);return V?new Uint8ClampedArray(J):J}},q.prototype.peekByte=function(){var X=this.getByte();return this.pos--,X},q.prototype.peekBytes=function(X,V){if(V===void 0)V=!1;var K=this.getBytes(X,V);return this.pos-=K.length,K},q.prototype.skip=function(X){if(!X)X=1;this.pos+=X},q.prototype.reset=function(){this.pos=this.start},q.prototype.moveStart=function(){this.start=this.pos},q.prototype.makeSubStream=function(X,V){return new q(this.bytes,X,V)},q.prototype.decode=function(){return this.bytes},q}(),Hq=cG;var pG=new Uint8Array(0),dG=function(){function q(X){if(this.pos=0,this.bufferLength=0,this.eof=!1,this.buffer=pG,this.minBufferLength=512,X)while(this.minBufferLengthY)K=Y}else{while(!this.eof)this.readBlock();K=this.bufferLength}this.pos=K;var J=this.buffer.subarray(Q,K);return V&&!(J instanceof Uint8ClampedArray)?new Uint8ClampedArray(J):J},q.prototype.peekByte=function(){var X=this.getByte();return this.pos--,X},q.prototype.peekBytes=function(X,V){if(V===void 0)V=!1;var K=this.getBytes(X,V);return this.pos-=K.length,K},q.prototype.skip=function(X){if(!X)X=1;this.pos+=X},q.prototype.reset=function(){this.pos=0},q.prototype.makeSubStream=function(X,V){var K=X+V;while(this.bufferLength<=K&&!this.eof)this.readBlock();return new Hq(this.buffer,X,V)},q.prototype.decode=function(){while(!this.eof)this.readBlock();return this.buffer.subarray(0,this.bufferLength)},q.prototype.readBlock=function(){throw new u0(this.constructor.name,"readBlock")},q.prototype.ensureBuffer=function(X){var V=this.buffer;if(X<=V.byteLength)return V;var K=this.minBufferLength;while(K=0;--Z)W[G+Z]=U&255,U>>=8}},X}(d2),jK=nG;var rG=function(q){w(X,q);function X(V,K){var Q=q.call(this,K)||this;if(Q.stream=V,Q.firstDigit=-1,K)K=0.5*K;return Q}return X.prototype.readBlock=function(){var V=8000,K=this.stream.getBytes(V);if(!K.length){this.eof=!0;return}var Q=K.length+1>>1,Y=this.ensureBuffer(this.bufferLength+Q),J=this.bufferLength,G=this.firstDigit;for(var W=0,Z=K.length;W=48&&H<=57)U=H&15;else if(H>=65&&H<=70||H>=97&&H<=102)U=(H&15)+9;else if(H===62){this.eof=!0;break}else continue;if(G<0)G=U;else Y[J++]=G<<4|U,G=-1}if(G>=0&&this.eof)Y[J++]=G<<4,G=-1;this.firstDigit=G,this.bufferLength=J},X}(d2),LK=rG;var BK=new Int32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),iG=new Int32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),aG=new Int32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),oG=[new Int32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,590000,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],sG=[new Int32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5],tG=function(q){w(X,q);function X(V,K){var Q=q.call(this,K)||this;Q.stream=V;var Y=V.getByte(),J=V.getByte();if(Y===-1||J===-1)throw Error("Invalid header in flate stream: "+Y+", "+J);if((Y&15)!==8)throw Error("Unknown compression method in flate stream: "+Y+", "+J);if(((Y<<8)+J)%31!==0)throw Error("Bad FCHECK in flate stream: "+Y+", "+J);if(J&32)throw Error("FDICT bit set in flate stream: "+Y+", "+J);return Q.codeSize=0,Q.codeBuf=0,Q}return X.prototype.readBlock=function(){var V,K,Q=this.stream,Y=this.getBits(3);if(Y&1)this.eof=!0;if(Y>>=1,Y===0){var J=void 0;if((J=Q.getByte())===-1)throw Error("Bad block header in flate stream");var G=J;if((J=Q.getByte())===-1)throw Error("Bad block header in flate stream");if(G|=J<<8,(J=Q.getByte())===-1)throw Error("Bad block header in flate stream");var W=J;if((J=Q.getByte())===-1)throw Error("Bad block header in flate stream");if(W|=J<<8,W!==(~G&65535)&&(G!==0||W!==0))throw Error("Bad uncompressed block length in flate stream");this.codeBuf=0,this.codeSize=0;var Z=this.bufferLength;V=this.ensureBuffer(Z+G);var H=Z+G;if(this.bufferLength=H,G===0){if(Q.peekByte()===-1)this.eof=!0}else for(var U=Z;U0)v[O++]=S}z=this.generateHuffmanTable(v.subarray(0,M)),k=this.generateHuffmanTable(v.subarray(M,R))}else throw Error("Unknown block type in flate stream");V=this.buffer;var C=V?V.length:0,D=this.bufferLength;while(!0){var l=this.getCode(z);if(l<256){if(D+1>=C)V=this.ensureBuffer(D+1),C=V.length;V[D++]=l;continue}if(l===256){this.bufferLength=D;return}l-=257,l=iG[l];var u=l>>16;if(u>0)u=this.getBits(u);if(K=(l&65535)+u,l=this.getCode(k),l=aG[l],u=l>>16,u>0)u=this.getBits(u);var q0=(l&65535)+u;if(D+K>=C)V=this.ensureBuffer(D+K),C=V.length;for(var J0=0;J0>V,this.codeSize=Q-=V,J},X.prototype.getCode=function(V){var K=this.stream,Q=V[0],Y=V[1],J=this.codeSize,G=this.codeBuf,W;while(J>16,U=Z&65535;if(H<1||J>H,this.codeSize=J-H,U},X.prototype.generateHuffmanTable=function(V){var K=V.length,Q=0,Y;for(Y=0;YQ)Q=V[Y];var J=1<>=1;for(Y=z;Y0;if(!v||v<256)B[0]=v,L=1;else if(v>=258)if(v=0;J--)B[J]=U[G],G=k[G]}else B[L++]=B[0];else if(v===256){M=9,H=258,L=0;continue}else{this.eof=!0,delete this.lzwState;break}if(A)k[H]=j,z[H]=z[j]+1,U[H]=B[0],H++,M=H+Z&H+Z-1?M:Math.min(Math.log(H+Z)/0.6931471805599453+1,12)|0;if(j=v,O+=L,K>>K&(1<0){var J=this.stream.getBytes(Y);K.set(J,Q),Q+=Y}}else{Y=257-Y;var G=V[1];K=this.ensureBuffer(Q+Y+1);for(var W=0;WK.size())throw new Y5(V,0,K.size());K.remove(V)}},X.prototype.normalizedEntries=function(){var V=this.Kids();if(!V)V=this.dict.context.obj([this.ref]),this.dict.set(I.of("Kids"),V);return{Kids:V}},X.fromDict=function(V,K){return new X(V,K)},X}(Y8),K2=UZ;var zZ=function(q){w(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.prototype.Opt=function(){return this.dict.lookupMaybe(I.of("Opt"),K0,g,i)},X.prototype.setOpt=function(V){this.dict.set(I.of("Opt"),this.dict.context.obj(V))},X.prototype.getExportValues=function(){var V=this.Opt();if(!V)return;if(V instanceof K0||V instanceof g)return[V];var K=[];for(var Q=0,Y=V.size();QK.size())throw new Y5(V,0,K.size());K.remove(V)}},X.prototype.normalizeExportValues=function(){var V,K,Q,Y,J=(V=this.getExportValues())!==null&&V!==void 0?V:[],G=[],W=this.getWidgets();for(var Z=0,H=W.length;Z1){if(!this.hasFlag(G0.MultiSelect))throw new W7;this.dict.set(I.of("V"),this.dict.context.obj(V))}this.updateSelectedIndices(V)},X.prototype.valuesAreValid=function(V){var K=this.getOptions(),Q=function(W,Z){var H=V[W].decodeText();if(!K.find(function(U){return H===(U.display||U.value).decodeText()}))return{value:!1}};for(var Y=0,J=V.length;Y1){var K=Array(V.length),Q=this.getOptions(),Y=function(W,Z){var H=V[W].decodeText();K[W]=Q.findIndex(function(U){return H===(U.display||U.value).decodeText()})};for(var J=0,G=V.length;J0){var G=J.lookup(0,K0,g),W=J.lookupMaybe(1,K0,g);K.push({value:G,display:W||G})}}}return K}return[]},X}(K2),G8=kZ;var IZ=function(q){w(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.fromDict=function(V,K){return new X(V,K)},X.create=function(V){var K=V.obj({FT:"Ch",Ff:G0.Combo,Kids:[]}),Q=V.register(K);return new X(K,Q)},X}(G8),Q6=IZ;var EZ=function(q){w(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.prototype.addField=function(V){var K=this.normalizedEntries().Kids;K===null||K===void 0||K.push(V)},X.prototype.normalizedEntries=function(){var V=this.Kids();if(!V)V=this.dict.context.obj([]),this.dict.set(I.of("Kids"),V);return{Kids:V}},X.fromDict=function(V,K){return new X(V,K)},X.create=function(V){var K=V.obj({}),Q=V.register(K);return new X(K,Q)},X}(Y8),Y6=EZ;var jZ=function(q){w(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.fromDict=function(V,K){return new X(V,K)},X}(K2),F6=jZ;var LZ=function(q){w(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.prototype.MaxLen=function(){var V=this.dict.lookup(I.of("MaxLen"));if(V instanceof x)return V;return},X.prototype.Q=function(){var V=this.dict.lookup(I.of("Q"));if(V instanceof x)return V;return},X.prototype.setMaxLength=function(V){this.dict.set(I.of("MaxLen"),x.of(V))},X.prototype.removeMaxLength=function(){this.dict.delete(I.of("MaxLen"))},X.prototype.getMaxLength=function(){var V;return(V=this.MaxLen())===null||V===void 0?void 0:V.asNumber()},X.prototype.setQuadding=function(V){this.dict.set(I.of("Q"),x.of(V))},X.prototype.getQuadding=function(){var V;return(V=this.Q())===null||V===void 0?void 0:V.asNumber()},X.prototype.setValue=function(V){this.dict.set(I.of("V"),V)},X.prototype.removeValue=function(){this.dict.delete(I.of("V"))},X.prototype.getValue=function(){var V=this.V();if(V instanceof K0||V instanceof g)return V;return},X.fromDict=function(V,K){return new X(V,K)},X.create=function(V){var K=V.obj({FT:"Tx",Kids:[]}),Q=V.register(K);return new X(K,Q)},X}(K2),J6=LZ;var BZ=function(q){w(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.fromDict=function(V,K){return new X(V,K)},X.create=function(V){var K=V.obj({FT:"Btn",Ff:f0.PushButton,Kids:[]}),Q=V.register(K);return new X(K,Q)},X}(h6),G6=BZ;var TZ=function(q){w(X,q);function X(){return q!==null&&q.apply(this,arguments)||this}return X.prototype.setValue=function(V){var K=this.getOnValues();if(!K.includes(V)&&V!==I.of("Off"))throw new J5;this.dict.set(I.of("V"),V);var Q=this.getWidgets();for(var Y=0,J=Q.length;YY)throw new qq(K,Y);var J=K;for(var G=0,W=Q.size();GJ)return H.insertLeafNode(V,J)||Z;else J-=H.Count().asNumber();if(H instanceof _0)J-=1}if(J===0){this.insertLeafKid(Q.size(),V);return}throw new Xq(K,"insertLeafNode")},X.prototype.removeLeafNode=function(V,K){if(K===void 0)K=!0;var Q=this.Kids(),Y=this.Count().asNumber();if(V>=Y)throw new qq(V,Y);var J=V;for(var G=0,W=Q.size();GJ){if(H.removeLeafNode(J,K),K&&H.Kids().size()===0)Q.remove(G);return}else J-=H.Count().asNumber();if(H instanceof _0)if(J===0){this.removeKid(G);return}else J-=1}throw new Xq(V,"removeLeafNode")},X.prototype.ascend=function(V){V(this);var K=this.Parent();if(K)K.ascend(V)},X.prototype.traverse=function(V){var K=this.Kids();for(var Q=0,Y=K.size();QNumber.MAX_SAFE_INTEGER)if(this.capNumbers){var Q="Parsed number that is too large for some PDF readers: "+X+", using Number.MAX_SAFE_INTEGER instead.";return console.warn(Q),Number.MAX_SAFE_INTEGER}else{var Q="Parsed number that is too large for some PDF readers: "+X+", not capping.";console.warn(Q)}return K},q.prototype.skipWhitespace=function(){while(!this.bytes.done()&&k2[this.bytes.peek()])this.bytes.next()},q.prototype.skipLine=function(){while(!this.bytes.done()){var X=this.bytes.peek();if(X===wK||X===NK)return;this.bytes.next()}},q.prototype.skipComment=function(){if(this.bytes.peek()!==E.Percent)return!1;while(!this.bytes.done()){var X=this.bytes.peek();if(X===wK||X===NK)return!0;this.bytes.next()}return!0},q.prototype.skipWhitespaceAndComments=function(){this.skipWhitespace();while(this.skipComment())this.skipWhitespace()},q.prototype.matchKeyword=function(X){var V=this.bytes.offset();for(var K=0,Q=X.length;K=this.length},q.prototype.offset=function(){return this.idx},q.prototype.slice=function(X,V){return this.bytes.slice(X,V)},q.prototype.position=function(){return{line:this.line,column:this.column,offset:this.idx}},q.of=function(X){return new q(X)},q.fromPDFRawStream=function(X){return q.of(V8(X).decode())},q}(),D6=CZ;var hZ=E.Space,U1=E.CarriageReturn,z1=E.Newline,M1=[E.s,E.t,E.r,E.e,E.a,E.m],Eq=[E.e,E.n,E.d,E.s,E.t,E.r,E.e,E.a,E.m],M0={header:[E.Percent,E.P,E.D,E.F,E.Dash],eof:[E.Percent,E.Percent,E.E,E.O,E.F],obj:[E.o,E.b,E.j],endobj:[E.e,E.n,E.d,E.o,E.b,E.j],xref:[E.x,E.r,E.e,E.f],trailer:[E.t,E.r,E.a,E.i,E.l,E.e,E.r],startxref:[E.s,E.t,E.a,E.r,E.t,E.x,E.r,E.e,E.f],true:[E.t,E.r,E.u,E.e],false:[E.f,E.a,E.l,E.s,E.e],null:[E.n,E.u,E.l,E.l],stream:M1,streamEOF1:Q0(M1,[hZ,U1,z1]),streamEOF2:Q0(M1,[U1,z1]),streamEOF3:Q0(M1,[U1]),streamEOF4:Q0(M1,[z1]),endstream:Eq,EOF1endstream:Q0([U1,z1],Eq),EOF2endstream:Q0([U1],Eq),EOF3endstream:Q0([z1],Eq)};var FZ=function(q){w(X,q);function X(V,K,Q){if(Q===void 0)Q=!1;var Y=q.call(this,V,Q)||this;return Y.context=K,Y}return X.prototype.parseObject=function(){if(this.skipWhitespaceAndComments(),this.matchKeyword(M0.true))return c2.True;if(this.matchKeyword(M0.false))return c2.False;if(this.matchKeyword(M0.null))return F0;var V=this.bytes.peek();if(V===E.LessThan&&this.bytes.peekAhead(1)===E.LessThan)return this.parseDictOrStream();if(V===E.LessThan)return this.parseHexString();if(V===E.LeftParen)return this.parseString();if(V===E.ForwardSlash)return this.parseName();if(V===E.LeftSquareBracket)return this.parseArray();if(H1[V])return this.parseNumberOrRef();throw new M7(this.bytes.position(),V)},X.prototype.parseNumberOrRef=function(){var V=this.parseRawNumber();this.skipWhitespaceAndComments();var K=this.bytes.offset();if(P0[this.bytes.peek()]){var Q=this.parseRawNumber();if(this.skipWhitespaceAndComments(),this.bytes.peek()===E.R)return this.bytes.assertNext(E.R),a.of(V,Q)}return this.bytes.moveTo(K),x.of(V)},X.prototype.parseHexString=function(){var V="";this.bytes.assertNext(E.LessThan);while(!this.bytes.done()&&this.bytes.peek()!==E.GreaterThan)V+=t0(this.bytes.next());return this.bytes.assertNext(E.GreaterThan),g.of(V)},X.prototype.parseString=function(){var V=0,K=!1,Q="";while(!this.bytes.done()){var Y=this.bytes.next();if(Q+=t0(Y),!K){if(Y===E.LeftParen)V+=1;if(Y===E.RightParen)V-=1}if(Y===E.BackSlash)K=!K;else if(K)K=!1;if(V===0)return K0.of(Q.substring(1,Q.length-1))}throw new E7(this.bytes.position())},X.prototype.parseName=function(){this.bytes.assertNext(E.ForwardSlash);var V="";while(!this.bytes.done()){var K=this.bytes.peek();if(k2[K]||V2[K])break;V+=t0(K),this.bytes.next()}return I.of(V)},X.prototype.parseArray=function(){this.bytes.assertNext(E.LeftSquareBracket),this.skipWhitespaceAndComments();var V=i.withContext(this.context);while(this.bytes.peek()!==E.RightSquareBracket){var K=this.parseObject();V.push(K),this.skipWhitespaceAndComments()}return this.bytes.assertNext(E.RightSquareBracket),V},X.prototype.parseDict=function(){this.bytes.assertNext(E.LessThan),this.bytes.assertNext(E.LessThan),this.skipWhitespaceAndComments();var V=new Map;while(!this.bytes.done()&&this.bytes.peek()!==E.GreaterThan&&this.bytes.peekAhead(1)!==E.GreaterThan){var K=this.parseName(),Q=this.parseObject();V.set(K,Q),this.skipWhitespaceAndComments()}this.skipWhitespaceAndComments(),this.bytes.assertNext(E.GreaterThan),this.bytes.assertNext(E.GreaterThan);var Y=V.get(I.of("Type"));if(Y===I.of("Catalog"))return W8.fromMapWithContext(V,this.context);else if(Y===I.of("Pages"))return H8.fromMapWithContext(V,this.context);else if(Y===I.of("Page"))return _0.fromMapWithContext(V,this.context);else return m.fromMapWithContext(V,this.context)},X.prototype.parseDictOrStream=function(){var V=this.bytes.position(),K=this.parseDict();if(this.skipWhitespaceAndComments(),!this.matchKeyword(M0.streamEOF1)&&!this.matchKeyword(M0.streamEOF2)&&!this.matchKeyword(M0.streamEOF3)&&!this.matchKeyword(M0.streamEOF4)&&!this.matchKeyword(M0.stream))return K;var Q=this.bytes.offset(),Y,J=K.get(I.of("Length"));if(J instanceof x){if(Y=Q+J.asNumber(),this.bytes.moveTo(Y),this.skipWhitespaceAndComments(),!this.matchKeyword(M0.endstream))this.bytes.moveTo(Q),Y=this.findEndOfStreamFallback(V)}else Y=this.findEndOfStreamFallback(V);var G=this.bytes.slice(Q,Y);return w2.of(K,G)},X.prototype.findEndOfStreamFallback=function(V){var K=1,Q=this.bytes.offset();while(!this.bytes.done()){if(Q=this.bytes.offset(),this.matchKeyword(M0.stream))K+=1;else if(this.matchKeyword(M0.EOF1endstream)||this.matchKeyword(M0.EOF2endstream)||this.matchKeyword(M0.EOF3endstream)||this.matchKeyword(M0.endstream))K-=1;else this.bytes.next();if(K===0)break}if(K!==0)throw new I7(V);return Q},X.forBytes=function(V,K,Q){return new X(D6.of(V),K,Q)},X.forByteStream=function(V,K,Q){if(Q===void 0)Q=!1;return new X(V,K,Q)},X}(SK),U8=FZ;var PZ=function(q){w(X,q);function X(V,K){var Q=q.call(this,D6.fromPDFRawStream(V),V.dict.context)||this,Y=V.dict;return Q.alreadyParsed=!1,Q.shouldWaitForTick=K||function(){return!1},Q.firstOffset=Y.lookup(I.of("First"),x).asNumber(),Q.objectCount=Y.lookup(I.of("N"),x).asNumber(),Q}return X.prototype.parseIntoContext=function(){return _(this,void 0,void 0,function(){var V,K,Q,Y,J,G,W,Z;return c(this,function(H){switch(H.label){case 0:if(this.alreadyParsed)throw new Q5("PDFObjectStreamParser","parseIntoContext");this.alreadyParsed=!0,V=this.parseOffsetsAndObjectNumbers(),K=0,Q=V.length,H.label=1;case 1:if(!(K=E.Space&&K<=E.Tilde;if(Q){if(this.matchKeyword(M0.xref)||this.matchKeyword(M0.trailer)||this.matchKeyword(M0.startxref)||this.matchIndirectObjectHeader()){this.bytes.moveTo(V);break}}this.bytes.next()}},X.prototype.skipBinaryHeaderComment=function(){this.skipWhitespaceAndComments();try{var V=this.bytes.offset();this.parseIndirectObjectHeader(),this.bytes.moveTo(V)}catch(K){this.bytes.next(),this.skipWhitespaceAndComments()}},X.forBytesWithOptions=function(V,K,Q,Y){return new X(V,K,Q,Y)},X}(U8),Bq=uZ;var n2=function(q){return 1<0)K[K.length]=+Q;V[V.length]={cmd:X,args:K},K=[],Q="",Y=!1}X=Z}else if([" ",","].includes(Z)||Z==="-"&&Q.length>0&&Q[Q.length-1]!=="e"||Z==="."&&Y){if(Q.length===0)continue;if(K.length===J){if(V[V.length]={cmd:X,args:K},K=[+Q],X==="M")X="L";if(X==="m")X="l"}else K[K.length]=+Q;Y=Z===".",Q=["-","."].includes(Z)?Z:""}else if(Q+=Z,Z===".")Y=!0}if(Q.length>0)if(K.length===J){if(V[V.length]={cmd:X,args:K},K=[+Q],X==="M")X="L";if(X==="m")X="l"}else K[K.length]=+Q;return V[V.length]={cmd:X,args:K},V},oZ=function(q){d=n=Z0=W0=v1=R1=0;var X=[];for(var V=0;V1)z=Math.sqrt(z),V*=z,K*=z;var k=U/V,M=H/V,j=-H/K,B=U/K,L=k*G+M*W,O=j*G+B*W,N=k*q+M*X,R=j*q+B*X,v=(N-L)*(N-L)+(R-O)*(R-O),A=1/v-0.25;if(A<0)A=0;var $=Math.sqrt(A);if(Y===Q)$=-$;var S=0.5*(L+N)-$*(R-O),h=0.5*(O+R)+$*(N-L),b=Math.atan2(O-h,L-S),C=Math.atan2(R-h,N-S),D=C-b;if(D<0&&Y===1)D+=2*Math.PI;else if(D>0&&Y===0)D-=2*Math.PI;var l=Math.ceil(Math.abs(D/(Math.PI*0.5+0.001))),u=[];for(var q0=0;q0q.length)return Q-1;var B=X.heightAtSize(Q),L=B+B*0.2,O=L*Y;if(O>Math.abs(V.height))return Q-1;Q+=1}return Q},K3=function(q,X,V,K){var Q=V.width/K,Y=V.height,J=mK,G=J4(q);while(JQ*0.75;if(U)return J-1}var z=X.heightAtSize(J,{descender:!1});if(z>Y)return J-1;J+=1}return J},Q3=function(q){for(var X=q.length;X>0;X--)if(/\s/.test(q[X]))return X;return},Y3=function(q,X,V,K){var Q,Y=q.length;while(Y>0){var J=q.substring(0,Y),G=V.encodeText(J),W=V.widthOfTextAtSize(J,K);if(Wz)z=$+v;if(M+G>k)k=M+G;Z.push({text:N,encoded:R,width:v,height:G,x:$,y:M}),L=A===null||A===void 0?void 0:A.trim()}}return{fontSize:K,lineHeight:W,lines:Z,bounds:{x:H,y:U,width:z-H,height:k-U}}},KX=function(q,X){var{fontSize:V,font:K,bounds:Q,cellCount:Y}=X,J=F1(k6(q));if(J.length>Y)throw new qX(J.length,Y);if(V===void 0||V===0)V=K3(J,K,Q,Y);var G=Q.width/Y,W=K.heightAtSize(V,{descender:!1}),Z=Q.y+(Q.height/2-W/2),H=[],U=Q.x,z=Q.y,k=Q.x+Q.width,M=Q.y+Q.height,j=0,B=0;while(jk)k=$+v;if(Z+W>M)M=Z+W;H.push({text:J,encoded:R,width:v,height:W,x:$,y:Z}),j+=1,B+=N}return{fontSize:V,cells:H,bounds:{x:U,y:z,width:k-U,height:M-z}}},v8=function(q,X){var{alignment:V,fontSize:K,font:Q,bounds:Y}=X,J=F1(k6(q));if(K===void 0||K===0)K=lK([J],Q,Y);var G=Q.encodeText(J),W=Q.widthOfTextAtSize(J,K),Z=Q.heightAtSize(K,{descender:!1}),H=V===v0.Left?Y.x:V===v0.Center?Y.x+Y.width/2-W/2:V===v0.Right?Y.x+Y.width-W:Y.x,U=Y.y+(Y.height/2-Z/2);return{fontSize:K,line:{text:J,encoded:G,width:W,height:Z,x:H,y:U},bounds:{x:H,y:U,width:W,height:Z}}};var G2=function(q){if("normal"in q)return q;return{normal:q}},J3=/\/([^\0\t\n\f\r\ ]+)[\0\t\n\f\r\ ]+(\d*\.\d+|\d+)[\0\t\n\f\r\ ]+Tf/,m6=function(q){var X,V,K=(X=q.getDefaultAppearance())!==null&&X!==void 0?X:"",Q=(V=F5(K,J3).match)!==null&&V!==void 0?V:[],Y=Number(Q[2]);return isFinite(Y)?Y:void 0},G3=/(\d*\.\d+|\d+)[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]*(\d*\.\d+|\d+)?[\0\t\n\f\r\ ]+(g|rg|k)/,L2=function(q){var X,V=(X=q.getDefaultAppearance())!==null&&X!==void 0?X:"",K=F5(V,G3).match,Q=K!==null&&K!==void 0?K:[],Y=Q[1],J=Q[2],G=Q[3],W=Q[4],Z=Q[5];if(Z==="g"&&Y)return Sq(Number(Y));if(Z==="rg"&&Y&&J&&G)return Y0(Number(Y),Number(J),Number(G));if(Z==="k"&&Y&&J&&G&&W)return yq(Number(Y),Number(J),Number(G),Number(W));return},B2=function(q,X,V,K){var Q;if(K===void 0)K=0;var Y=[E2(X).toString(),T5((Q=V===null||V===void 0?void 0:V.name)!==null&&Q!==void 0?Q:"dummy__noop",K).toString()].join(` +`);q.setDefaultAppearance(Y)},QX=function(q,X){var V,K,Q,Y=L2(X),J=L2(q.acroField),G=X.getRectangle(),W=X.getAppearanceCharacteristics(),Z=X.getBorderStyle(),H=(V=Z===null||Z===void 0?void 0:Z.getWidth())!==null&&V!==void 0?V:0,U=I2(W===null||W===void 0?void 0:W.getRotation()),z=r2(G,U),k=z.width,M=z.height,j=j2(o(o({},G),{rotation:U})),B=Y0(0,0,0),L=(K=l0(W===null||W===void 0?void 0:W.getBorderColor()))!==null&&K!==void 0?K:B,O=l0(W===null||W===void 0?void 0:W.getBackgroundColor()),N=l0(W===null||W===void 0?void 0:W.getBackgroundColor(),0.8),R=(Q=Y!==null&&Y!==void 0?Y:J)!==null&&Q!==void 0?Q:B;if(Y)B2(X,R);else B2(q.acroField,R);var v={x:0+H/2,y:0+H/2,width:k-H,height:M-H,thickness:1.5,borderWidth:H,borderColor:L,markColor:R};return{normal:{on:Q0(j,B8(o(o({},v),{color:O,filled:!0}))),off:Q0(j,B8(o(o({},v),{color:O,filled:!1})))},down:{on:Q0(j,B8(o(o({},v),{color:N,filled:!0}))),off:Q0(j,B8(o(o({},v),{color:N,filled:!1})))}}},YX=function(q,X){var V,K,Q,Y=L2(X),J=L2(q.acroField),G=X.getRectangle(),W=X.getAppearanceCharacteristics(),Z=X.getBorderStyle(),H=(V=Z===null||Z===void 0?void 0:Z.getWidth())!==null&&V!==void 0?V:0,U=I2(W===null||W===void 0?void 0:W.getRotation()),z=r2(G,U),k=z.width,M=z.height,j=j2(o(o({},G),{rotation:U})),B=Y0(0,0,0),L=(K=l0(W===null||W===void 0?void 0:W.getBorderColor()))!==null&&K!==void 0?K:B,O=l0(W===null||W===void 0?void 0:W.getBackgroundColor()),N=l0(W===null||W===void 0?void 0:W.getBackgroundColor(),0.8),R=(Q=Y!==null&&Y!==void 0?Y:J)!==null&&Q!==void 0?Q:B;if(Y)B2(X,R);else B2(q.acroField,R);var v={x:k/2,y:M/2,width:k-H,height:M-H,borderWidth:H,borderColor:L,dotColor:R};return{normal:{on:Q0(j,T8(o(o({},v),{color:O,filled:!0}))),off:Q0(j,T8(o(o({},v),{color:O,filled:!1})))},down:{on:Q0(j,T8(o(o({},v),{color:N,filled:!0}))),off:Q0(j,T8(o(o({},v),{color:N,filled:!1})))}}},JX=function(q,X,V){var K,Q,Y,J,G,W=L2(X),Z=L2(q.acroField),H=m6(X),U=m6(q.acroField),z=X.getRectangle(),k=X.getAppearanceCharacteristics(),M=X.getBorderStyle(),j=k===null||k===void 0?void 0:k.getCaptions(),B=(K=j===null||j===void 0?void 0:j.normal)!==null&&K!==void 0?K:"",L=(Y=(Q=j===null||j===void 0?void 0:j.down)!==null&&Q!==void 0?Q:B)!==null&&Y!==void 0?Y:"",O=(J=M===null||M===void 0?void 0:M.getWidth())!==null&&J!==void 0?J:0,N=I2(k===null||k===void 0?void 0:k.getRotation()),R=r2(z,N),v=R.width,A=R.height,$=j2(o(o({},z),{rotation:N})),S=Y0(0,0,0),h=l0(k===null||k===void 0?void 0:k.getBorderColor()),b=l0(k===null||k===void 0?void 0:k.getBackgroundColor()),C=l0(k===null||k===void 0?void 0:k.getBackgroundColor(),0.8),D={x:O,y:O,width:v-O*2,height:A-O*2},l=v8(B,{alignment:v0.Center,fontSize:H!==null&&H!==void 0?H:U,font:V,bounds:D}),u=v8(L,{alignment:v0.Center,fontSize:H!==null&&H!==void 0?H:U,font:V,bounds:D}),q0=Math.min(l.fontSize,u.fontSize),J0=(G=W!==null&&W!==void 0?W:Z)!==null&&G!==void 0?G:S;if(W||H!==void 0)B2(X,J0,V,q0);else B2(q.acroField,J0,V,q0);var r={x:0+O/2,y:0+O/2,width:v-O,height:A-O,borderWidth:O,borderColor:h,textColor:J0,font:V.name,fontSize:q0};return{normal:Q0($,hq(o(o({},r),{color:b,textLines:[l.line]}))),down:Q0($,hq(o(o({},r),{color:C,textLines:[u.line]})))}},GX=function(q,X,V){var K,Q,Y,J,G=L2(X),W=L2(q.acroField),Z=m6(X),H=m6(q.acroField),U=X.getRectangle(),z=X.getAppearanceCharacteristics(),k=X.getBorderStyle(),M=(K=q.getText())!==null&&K!==void 0?K:"",j=(Q=k===null||k===void 0?void 0:k.getWidth())!==null&&Q!==void 0?Q:0,B=I2(z===null||z===void 0?void 0:z.getRotation()),L=r2(U,B),O=L.width,N=L.height,R=j2(o(o({},U),{rotation:B})),v=Y0(0,0,0),A=l0(z===null||z===void 0?void 0:z.getBorderColor()),$=l0(z===null||z===void 0?void 0:z.getBackgroundColor()),S,h,b=q.isCombed()?0:1,C={x:j+b,y:j+b,width:O-(j+b)*2,height:N-(j+b)*2};if(q.isMultiline()){var D=uq(M,{alignment:q.getAlignment(),fontSize:Z!==null&&Z!==void 0?Z:H,font:V,bounds:C});S=D.lines,h=D.fontSize}else if(q.isCombed()){var D=KX(M,{fontSize:Z!==null&&Z!==void 0?Z:H,font:V,bounds:C,cellCount:(Y=q.getMaxLength())!==null&&Y!==void 0?Y:0});S=D.cells,h=D.fontSize}else{var D=v8(M,{alignment:q.getAlignment(),fontSize:Z!==null&&Z!==void 0?Z:H,font:V,bounds:C});S=[D.line],h=D.fontSize}var l=(J=G!==null&&G!==void 0?G:W)!==null&&J!==void 0?J:v;if(G||Z!==void 0)B2(X,l,V,h);else B2(q.acroField,l,V,h);var u={x:0+j/2,y:0+j/2,width:O-j,height:N-j,borderWidth:j!==null&&j!==void 0?j:0,borderColor:A,textColor:l,font:V.name,fontSize:h,color:$,textLines:S,padding:b};return Q0(R,Pq(u))},ZX=function(q,X,V){var K,Q,Y,J=L2(X),G=L2(q.acroField),W=m6(X),Z=m6(q.acroField),H=X.getRectangle(),U=X.getAppearanceCharacteristics(),z=X.getBorderStyle(),k=(K=q.getSelected()[0])!==null&&K!==void 0?K:"",M=(Q=z===null||z===void 0?void 0:z.getWidth())!==null&&Q!==void 0?Q:0,j=I2(U===null||U===void 0?void 0:U.getRotation()),B=r2(H,j),L=B.width,O=B.height,N=j2(o(o({},H),{rotation:j})),R=Y0(0,0,0),v=l0(U===null||U===void 0?void 0:U.getBorderColor()),A=l0(U===null||U===void 0?void 0:U.getBackgroundColor()),$=1,S={x:M+$,y:M+$,width:L-(M+$)*2,height:O-(M+$)*2},h=v8(k,{alignment:v0.Left,fontSize:W!==null&&W!==void 0?W:Z,font:V,bounds:S}),b=h.line,C=h.fontSize,D=(Y=J!==null&&J!==void 0?J:G)!==null&&Y!==void 0?Y:R;if(J||W!==void 0)B2(X,D,V,C);else B2(q.acroField,D,V,C);var l={x:0+M/2,y:0+M/2,width:L-M,height:O-M,borderWidth:M!==null&&M!==void 0?M:0,borderColor:v,textColor:D,font:V.name,fontSize:C,color:A,textLines:[b],padding:$};return Q0(N,Pq(l))},WX=function(q,X,V){var K,Q,Y=L2(X),J=L2(q.acroField),G=m6(X),W=m6(q.acroField),Z=X.getRectangle(),H=X.getAppearanceCharacteristics(),U=X.getBorderStyle(),z=(K=U===null||U===void 0?void 0:U.getWidth())!==null&&K!==void 0?K:0,k=I2(H===null||H===void 0?void 0:H.getRotation()),M=r2(Z,k),j=M.width,B=M.height,L=j2(o(o({},Z),{rotation:k})),O=Y0(0,0,0),N=l0(H===null||H===void 0?void 0:H.getBorderColor()),R=l0(H===null||H===void 0?void 0:H.getBackgroundColor()),v=q.getOptions(),A=q.getSelected();if(q.isSorted())v.sort();var $="";for(var S=0,h=v.length;S1||Q.length===1&&K)this.enableMultiselect();var G=Array(Q.length);for(var W=0,Z=Q.length;W1||Q.length===1&&K)this.enableMultiselect();var J=Array(Q.length);for(var G=0,W=Q.length;GK)throw new XX(V.length,K,this.getName());if(this.markAsDirty(),this.disableRichFormatting(),V)this.acroField.setValue(g.fromText(V));else this.acroField.removeValue()},X.prototype.getAlignment=function(){var V=this.acroField.getQuadding();return V===0?v0.Left:V===1?v0.Center:V===2?v0.Right:v0.Left},X.prototype.setAlignment=function(V){M2(V,"alignment",v0),this.markAsDirty(),this.acroField.setQuadding(V)},X.prototype.getMaxLength=function(){return this.acroField.getMaxLength()},X.prototype.setMaxLength=function(V){if(X2(V,"maxLength",0,Number.MAX_SAFE_INTEGER),this.markAsDirty(),V===void 0)this.acroField.removeMaxLength();else{var K=this.getText();if(K&&K.length>V)throw new VX(K.length,V,this.getName());this.acroField.setMaxLength(V)}},X.prototype.removeMaxLength=function(){this.markAsDirty(),this.acroField.removeMaxLength()},X.prototype.setImage=function(V){var K=this.getAlignment(),Q=K===v0.Center?T2.Center:K===v0.Right?T2.Right:T2.Left,Y=this.acroField.getWidgets();for(var J=0,G=Y.length;J"u")globalThis.Buffer=y;if(typeof globalThis.process>"u")globalThis.process=N3;globalThis.__bundles=globalThis.__bundles||{};globalThis.__bundles["pdf-lib"]=UX;})(); diff --git a/apps/sim/lib/table/__tests__/find-row-matches.test.ts b/apps/sim/lib/table/__tests__/find-row-matches.test.ts index d2857eb71c3..cbc1276888e 100644 --- a/apps/sim/lib/table/__tests__/find-row-matches.test.ts +++ b/apps/sim/lib/table/__tests__/find-row-matches.test.ts @@ -74,7 +74,7 @@ describe('findRowMatches', () => { }) it('maps rows to matches, coercing the bigint ordinal and renaming the column', async () => { - dbChainMockFns.execute.mockResolvedValueOnce([ + dbChainMockFns.execute.mockResolvedValue([ { ordinal: '2', id: 'r2', column_name: 'name' }, { ordinal: 5, id: 'r5', column_name: 'email' }, ]) @@ -92,14 +92,14 @@ describe('findRowMatches', () => { id: `r${i}`, column_name: 'name', })) - dbChainMockFns.execute.mockResolvedValueOnce(over) + dbChainMockFns.execute.mockResolvedValue(over) const result = await findRowMatches(TABLE, { q: 'a' }, 'req') expect(result.truncated).toBe(true) expect(result.matches).toHaveLength(1000) }) it('threads filter and sort through the SQL builders', async () => { - dbChainMockFns.execute.mockResolvedValueOnce([]) + dbChainMockFns.execute.mockResolvedValue([]) await findRowMatches( TABLE, { q: 'a', filter: { name: { $contains: 'a' } }, sort: { name: 'asc' } }, diff --git a/apps/sim/lib/table/backfill-runner.ts b/apps/sim/lib/table/backfill-runner.ts new file mode 100644 index 00000000000..cbaf6e640f2 --- /dev/null +++ b/apps/sim/lib/table/backfill-runner.ts @@ -0,0 +1,343 @@ +import { db } from '@sim/db' +import { tableRowExecutions, userTableRows, workflowExecutionLogs } from '@sim/db/schema' +import { createLogger } from '@sim/logger' +import { getErrorMessage } from '@sim/utils/errors' +import { generateId } from '@sim/utils/id' +import { and, asc, count, eq, gt, inArray } from 'drizzle-orm' +import { isTriggerDevEnabled } from '@/lib/core/config/feature-flags' +import { runDetached } from '@/lib/core/utils/background' +import { MATERIALIZE_CONCURRENCY, mapWithConcurrency } from '@/lib/core/utils/concurrency' +import { materializeExecutionData } from '@/lib/logs/execution/trace-store' +import { appendTableEvent } from '@/lib/table/events' +import { + batchUpdateRows, + getTableById, + markJobFailed, + markJobReady, + markTableJobRunning, + updateJobProgress, +} from '@/lib/table/service' +import type { + RowData, + TableBackfillJobPayload, + TableDefinition, + WorkflowGroupOutput, +} from '@/lib/table/types' +import { pluckByPath } from './pluck' + +const logger = createLogger('TableBackfillRunner') + +/** Completed-run count above which the backfill runs as a background job instead of inline. */ +const BACKFILL_ASYNC_THRESHOLD_ROWS = 500 + +/** Completed sidecar rows fetched (and their logs materialized) per page. */ +const BACKFILL_PAGE_SIZE = 200 + +/** Thrown when this worker loses the job (canceled / janitor-failed). */ +class JobSupersededError extends Error {} + +export interface TableBackfillPayload { + jobId: string + tableId: string + workspaceId: string + groupId: string + outputs: WorkflowGroupOutput[] + overwrite: boolean + /** User who triggered the schema change, for usage attribution on the row writes. */ + actorUserId?: string | null +} + +/** Minimal shape of a trace span we care about for backfill. */ +interface BackfillTraceSpan { + blockId?: string + output?: Record + children?: BackfillTraceSpan[] +} + +/** DFS the trace tree for the first span matching `blockId`. */ +function findSpanByBlockId( + spans: BackfillTraceSpan[] | undefined, + blockId: string +): BackfillTraceSpan | undefined { + if (!spans) return undefined + for (const span of spans) { + if (span.blockId === blockId) return span + const child = findSpanByBlockId(span.children, blockId) + if (child) return child + } + return undefined +} + +/** One keyset page of completed (rowId, executionId) pairs for the group, ordered by rowId. */ +async function selectCompletedExecPage( + tableId: string, + groupId: string, + afterRowId: string | undefined, + limit: number +): Promise> { + return db + .select({ + rowId: tableRowExecutions.rowId, + executionId: tableRowExecutions.executionId, + }) + .from(tableRowExecutions) + .where( + and( + eq(tableRowExecutions.tableId, tableId), + eq(tableRowExecutions.groupId, groupId), + eq(tableRowExecutions.status, 'completed'), + afterRowId ? gt(tableRowExecutions.rowId, afterRowId) : undefined + ) + ) + .orderBy(asc(tableRowExecutions.rowId)) + .limit(limit) +} + +/** + * Backfills one page of rows: pulls each target output's value out of the rows' saved trace + * spans (materialized from object storage with bounded concurrency) and writes it into row data. + * Returns the number of rows updated. + */ +async function processBackfillPage(opts: { + table: TableDefinition + outputs: WorkflowGroupOutput[] + overwrite: boolean + execs: Array<{ rowId: string; executionId: string | null }> + requestId: string + actorUserId?: string | null +}): Promise { + const { table, outputs, overwrite, execs, requestId, actorUserId } = opts + + const executionIdsByRow = new Map() + for (const e of execs) { + if (!e.executionId) continue + executionIdsByRow.set(e.rowId, e.executionId) + } + if (executionIdsByRow.size === 0) return 0 + + const rowRecords = await db + .select({ id: userTableRows.id, data: userTableRows.data }) + .from(userTableRows) + .where( + and( + eq(userTableRows.tableId, table.id), + inArray(userTableRows.id, Array.from(executionIdsByRow.keys())) + ) + ) + + const executionIds = Array.from(new Set(executionIdsByRow.values())) + const logs = await db + .select({ + executionId: workflowExecutionLogs.executionId, + workflowId: workflowExecutionLogs.workflowId, + workspaceId: workflowExecutionLogs.workspaceId, + executionData: workflowExecutionLogs.executionData, + }) + .from(workflowExecutionLogs) + .where(inArray(workflowExecutionLogs.executionId, executionIds)) + + const logByExecutionId = new Map() + // Heavy execution data may live in object storage; resolve pointers (bounded concurrency). + await mapWithConcurrency(logs, MATERIALIZE_CONCURRENCY, async (log) => { + const executionData = await materializeExecutionData( + log.executionData as Record | null, + { workspaceId: log.workspaceId, workflowId: log.workflowId, executionId: log.executionId } + ) + logByExecutionId.set( + log.executionId, + (executionData as { traceSpans?: BackfillTraceSpan[] }) ?? {} + ) + }) + + const updates: Array<{ rowId: string; data: RowData }> = [] + for (const r of rowRecords) { + const execId = executionIdsByRow.get(r.id) + if (!execId) continue + const log = logByExecutionId.get(execId) + if (!log) continue + + const dataPatch: RowData = {} + let mutated = false + for (const out of outputs) { + if (!overwrite && (r.data as RowData)[out.columnName] !== undefined) continue + const span = findSpanByBlockId(log.traceSpans, out.blockId) + if (!span?.output) continue + const picked = pluckByPath(span.output, out.path) + if (picked === undefined) continue + dataPatch[out.columnName] = picked as RowData[string] + mutated = true + } + if (!mutated) continue + updates.push({ rowId: r.id, data: dataPatch }) + } + + if (updates.length === 0) return 0 + + await batchUpdateRows( + { tableId: table.id, updates, workspaceId: table.workspaceId, actorUserId }, + table, + requestId + ) + return updates.length +} + +/** + * Background worker for large output-column backfills. Pages the group's completed executions + * (keyset by rowId), materializing logs and writing values page by page. Ownership-gated per + * page; retry-safe (re-plucking the same spans writes the same values, and `overwrite: false` + * passes skip already-filled cells). + */ +export async function runTableBackfill(payload: TableBackfillPayload): Promise { + const { jobId, tableId, groupId, outputs, overwrite, actorUserId } = payload + const requestId = generateId().slice(0, 8) + + try { + const table = await getTableById(tableId, { includeArchived: true }) + if (!table) throw new Error(`Backfill target table ${tableId} not found`) + + let processed = 0 + let updated = 0 + let afterRowId: string | undefined + + while (true) { + const owns = await updateJobProgress(tableId, processed, jobId) + if (!owns) throw new JobSupersededError() + + const execs = await selectCompletedExecPage(tableId, groupId, afterRowId, BACKFILL_PAGE_SIZE) + if (execs.length === 0) break + afterRowId = execs[execs.length - 1].rowId + + updated += await processBackfillPage({ + table, + outputs, + overwrite, + execs, + requestId, + actorUserId, + }) + processed += execs.length + } + + await updateJobProgress(tableId, processed, jobId) + const becameReady = await markJobReady(tableId, jobId) + if (becameReady) { + void appendTableEvent({ + kind: 'job', + type: 'backfill', + tableId, + jobId, + status: 'ready', + progress: updated, + }) + logger.info(`[${requestId}] Backfill complete`, { tableId, groupId, processed, updated }) + } else { + logger.info(`[${requestId}] Backfill finished but no longer owns the run`, { tableId, jobId }) + } + } catch (err) { + if (err instanceof JobSupersededError) { + logger.info(`[${requestId}] Backfill superseded/canceled; stopping`, { tableId, jobId }) + } else { + const message = getErrorMessage(err, 'Backfill failed') + logger.error(`[${requestId}] Backfill failed for table ${tableId}:`, err) + await markJobFailed(tableId, jobId, message).catch(() => {}) + void appendTableEvent({ + kind: 'job', + type: 'backfill', + tableId, + jobId, + status: 'failed', + error: message, + }) + } + } +} + +/** + * Hybrid entry the schema-change flows call after adding/remapping workflow outputs. Small + * tables (≤ {@link BACKFILL_ASYNC_THRESHOLD_ROWS} completed runs) backfill inline-awaited, so the + * response returns with row data already consistent — identical to the historical behavior. Above + * the threshold, the work runs as a `table_jobs`-tracked background job (trigger.dev when + * enabled). The job slot is shared with import/delete; if another job holds it, the backfill is + * skipped with a warning — mirroring the long-standing "a failed backfill never fails the schema + * change" posture (the data stays backfillable). + */ +export async function maybeBackfillGroupOutputs(opts: { + table: TableDefinition + groupId: string + outputs: WorkflowGroupOutput[] + overwrite: boolean + requestId: string + actorUserId?: string | null +}): Promise { + const { table, groupId, outputs, overwrite, requestId, actorUserId } = opts + if (outputs.length === 0) return + + const [{ count: completedCount }] = await db + .select({ count: count() }) + .from(tableRowExecutions) + .where( + and( + eq(tableRowExecutions.tableId, table.id), + eq(tableRowExecutions.groupId, groupId), + eq(tableRowExecutions.status, 'completed') + ) + ) + const total = Number(completedCount) + if (total === 0) return + + if (total <= BACKFILL_ASYNC_THRESHOLD_ROWS) { + // Inline: page without job machinery so memory stays bounded but the caller can await + // full consistency. + let afterRowId: string | undefined + while (true) { + const execs = await selectCompletedExecPage(table.id, groupId, afterRowId, BACKFILL_PAGE_SIZE) + if (execs.length === 0) break + afterRowId = execs[execs.length - 1].rowId + await processBackfillPage({ table, outputs, overwrite, execs, requestId, actorUserId }) + } + return + } + + const jobId = generateId() + const jobPayload: TableBackfillJobPayload = { groupId, outputs, overwrite } + const claimed = await markTableJobRunning(table.id, jobId, 'backfill', jobPayload) + if (!claimed) { + logger.warn( + `[${requestId}] Skipping backfill for table ${table.id} group ${groupId}: another job is running` + ) + return + } + + const payload: TableBackfillPayload = { + jobId, + tableId: table.id, + workspaceId: table.workspaceId, + groupId, + outputs, + overwrite, + actorUserId, + } + if (isTriggerDevEnabled) { + try { + const [{ tableBackfillTask }, { tasks }] = await Promise.all([ + import('@/background/table-backfill'), + import('@trigger.dev/sdk'), + ]) + await tasks.trigger('table-backfill', payload, { + tags: [`tableId:${table.id}`, `jobId:${jobId}`], + }) + } catch (error) { + // Release the claim so a ghost `running` job doesn't block imports/deletes. + // Swallowed (warn only): a failed backfill never fails the schema change — + // the data stays backfillable. + const { releaseJobClaim } = await import('./service') + await releaseJobClaim(table.id, jobId).catch(() => {}) + logger.warn( + `[${requestId}] Backfill dispatch failed for table ${table.id} group ${groupId}; skipping`, + { error: getErrorMessage(error) } + ) + } + } else { + runDetached('table-backfill', () => runTableBackfill(payload)) + } +} diff --git a/apps/sim/lib/table/constants.ts b/apps/sim/lib/table/constants.ts index 04084ed8217..985dce4bf43 100644 --- a/apps/sim/lib/table/constants.ts +++ b/apps/sim/lib/table/constants.ts @@ -26,6 +26,15 @@ export const TABLE_LIMITS = { MAX_BULK_OPERATION_SIZE: 1000, /** Maximum rows a single clipboard copy/cut serializes; beyond this the user is steered to Export. */ MAX_COPY_ROWS: 50000, + /** Rows selected + deleted per page in the async background delete-job loop. Each page is one + * transaction (chunked into DELETE_BATCH_SIZE statements inside it); the page is also the + * cancel/ownership-check granularity. */ + DELETE_PAGE_SIZE: 10000, + /** Row count above which an export runs as a background job instead of a synchronous stream. + * Matches the default per-table row cap, so non-enterprise tables keep instant downloads. */ + EXPORT_ASYNC_THRESHOLD_ROWS: 10000, + /** Cap on the exclusion set ("select all, minus these") sent to an async delete job. */ + MAX_EXCLUDE_ROW_IDS: 10000, } as const /** diff --git a/apps/sim/lib/table/delete-runner.test.ts b/apps/sim/lib/table/delete-runner.test.ts new file mode 100644 index 00000000000..85e956a8067 --- /dev/null +++ b/apps/sim/lib/table/delete-runner.test.ts @@ -0,0 +1,131 @@ +/** + * @vitest-environment node + */ +import { beforeEach, describe, expect, it, vi } from 'vitest' + +const { + mockGetTableById, + mockSelectRowIdPage, + mockDeletePageByIds, + mockUpdateJobProgress, + mockMarkJobReady, + mockMarkJobFailed, + mockAppendTableEvent, + mockBuildFilterClause, +} = vi.hoisted(() => ({ + mockGetTableById: vi.fn(), + mockSelectRowIdPage: vi.fn(), + mockDeletePageByIds: vi.fn(), + mockUpdateJobProgress: vi.fn(), + mockMarkJobReady: vi.fn(), + mockMarkJobFailed: vi.fn(), + mockAppendTableEvent: vi.fn(), + mockBuildFilterClause: vi.fn(), +})) + +vi.mock('@/lib/table/service', () => ({ + getTableById: mockGetTableById, + selectRowIdPage: mockSelectRowIdPage, + deletePageByIds: mockDeletePageByIds, + updateJobProgress: mockUpdateJobProgress, + markJobReady: mockMarkJobReady, + markJobFailed: mockMarkJobFailed, +})) +vi.mock('@/lib/table/events', () => ({ appendTableEvent: mockAppendTableEvent })) +vi.mock('@/lib/table/sql', () => ({ buildFilterClause: mockBuildFilterClause })) +vi.mock('@/lib/table/constants', () => ({ + TABLE_LIMITS: { DELETE_PAGE_SIZE: 2 }, + USER_TABLE_ROWS_SQL_NAME: 'user_table_rows', +})) + +import { runTableDelete } from '@/lib/table/delete-runner' + +const table = { id: 'tbl_1', workspaceId: 'ws_1', schema: { columns: [] } } +const cutoff = new Date('2026-06-05T00:00:00Z') + +function basePayload(overrides = {}) { + return { jobId: 'job_1', tableId: 'tbl_1', workspaceId: 'ws_1', cutoff, ...overrides } +} + +describe('runTableDelete', () => { + beforeEach(() => { + vi.clearAllMocks() + mockGetTableById.mockResolvedValue(table) + mockUpdateJobProgress.mockResolvedValue(true) + mockMarkJobReady.mockResolvedValue(true) + mockMarkJobFailed.mockResolvedValue(undefined) + mockDeletePageByIds.mockImplementation((_t, _w, ids: string[]) => Promise.resolve(ids.length)) + mockBuildFilterClause.mockReturnValue({}) + }) + + it('deletes every matching page then marks the job ready', async () => { + mockSelectRowIdPage + .mockResolvedValueOnce(['a', 'b']) + .mockResolvedValueOnce(['c']) + .mockResolvedValueOnce([]) + + await runTableDelete(basePayload({ filter: { status: 'old' } })) + + expect(mockDeletePageByIds).toHaveBeenNthCalledWith(1, 'tbl_1', 'ws_1', ['a', 'b']) + expect(mockDeletePageByIds).toHaveBeenNthCalledWith(2, 'tbl_1', 'ws_1', ['c']) + expect(mockMarkJobReady).toHaveBeenCalledWith('tbl_1', 'job_1') + expect(mockAppendTableEvent).toHaveBeenCalledWith( + expect.objectContaining({ kind: 'job', type: 'delete', status: 'ready', progress: 3 }) + ) + }) + + it('skips excluded rows but still advances the keyset cursor past them', async () => { + mockSelectRowIdPage.mockResolvedValueOnce(['keep', 'x']).mockResolvedValueOnce([]) + + await runTableDelete(basePayload({ excludeRowIds: ['keep'] })) + + expect(mockDeletePageByIds).toHaveBeenCalledTimes(1) + expect(mockDeletePageByIds).toHaveBeenCalledWith('tbl_1', 'ws_1', ['x']) + // Second page is queried after the last id of the first page (cursor advanced past 'keep'). + expect(mockSelectRowIdPage).toHaveBeenNthCalledWith( + 2, + expect.objectContaining({ afterId: 'x' }) + ) + expect(mockMarkJobReady).toHaveBeenCalled() + }) + + it('stops without marking ready when the ownership gate is lost (cancel/supersede)', async () => { + mockSelectRowIdPage.mockResolvedValue(['a', 'b']) + mockUpdateJobProgress.mockResolvedValueOnce(true).mockResolvedValueOnce(false) + + await runTableDelete(basePayload()) + + expect(mockDeletePageByIds).toHaveBeenCalledTimes(1) + expect(mockMarkJobReady).not.toHaveBeenCalled() + expect(mockMarkJobFailed).not.toHaveBeenCalled() + expect(mockAppendTableEvent).not.toHaveBeenCalledWith( + expect.objectContaining({ status: 'ready' }) + ) + }) + + it('marks the job failed and emits a failed event on error', async () => { + mockSelectRowIdPage.mockRejectedValue(new Error('boom')) + + await runTableDelete(basePayload()) + + expect(mockMarkJobFailed).toHaveBeenCalledWith('tbl_1', 'job_1', 'boom') + expect(mockAppendTableEvent).toHaveBeenCalledWith( + expect.objectContaining({ kind: 'job', type: 'delete', status: 'failed', error: 'boom' }) + ) + }) + + it('passes the cutoff and filter clause through to the page query', async () => { + mockSelectRowIdPage.mockResolvedValueOnce([]) + + await runTableDelete(basePayload({ filter: { status: 'old' } })) + + expect(mockBuildFilterClause).toHaveBeenCalledWith( + { status: 'old' }, + 'user_table_rows', + table.schema.columns + ) + expect(mockSelectRowIdPage).toHaveBeenCalledWith( + expect.objectContaining({ cutoff, filterClause: {}, limit: 2 }) + ) + }) +}) diff --git a/apps/sim/lib/table/delete-runner.ts b/apps/sim/lib/table/delete-runner.ts new file mode 100644 index 00000000000..840345c9f4f --- /dev/null +++ b/apps/sim/lib/table/delete-runner.ts @@ -0,0 +1,146 @@ +import { createLogger } from '@sim/logger' +import { getErrorMessage } from '@sim/utils/errors' +import { generateId } from '@sim/utils/id' +import type { Filter } from '@/lib/table' +import { TABLE_LIMITS, USER_TABLE_ROWS_SQL_NAME } from '@/lib/table/constants' +import { appendTableEvent } from '@/lib/table/events' +import { + deletePageByIds, + getTableById, + markJobFailed, + markJobReady, + selectRowIdPage, + updateJobProgress, +} from '@/lib/table/service' +import { buildFilterClause } from '@/lib/table/sql' + +const logger = createLogger('TableDeleteRunner') + +/** Emit a progress event / heartbeat at most every this many rows. */ +const PROGRESS_INTERVAL_ROWS = 5000 + +/** + * Thrown when this worker discovers it no longer owns the table's job (canceled, or the + * stale-job janitor marked it failed and a newer job took over). The worker stops deleting. + */ +class JobSupersededError extends Error {} + +export interface TableDeletePayload { + jobId: string + tableId: string + workspaceId: string + /** Optional filter narrowing which rows to delete; omitted = every row at/under the cutoff. */ + filter?: Filter + /** Rows to spare ("select all, minus these"). Bounded by `MAX_EXCLUDE_ROW_IDS`. */ + excludeRowIds?: string[] + /** Only rows created at/before this instant are deleted, so mid-job inserts survive. */ + cutoff: Date +} + +/** + * Background worker for large filtered row deletes. Runs detached on the web container (see the + * delete-async kickoff route). Deletes in keyset-paginated pages — `created_at <= cutoff` spares + * rows inserted while the job runs, and `excludeRowIds` spares specific rows (the + * "select all then deselect a few" case). Ownership-gated per page so a cancel/supersede stops + * it within one page; committed pages are never rolled back. Progress and the terminal state are + * surfaced via the table-events SSE stream. + */ +export async function runTableDelete(payload: TableDeletePayload): Promise { + const { jobId, tableId, workspaceId, filter, excludeRowIds, cutoff } = payload + const requestId = generateId().slice(0, 8) + + try { + const table = await getTableById(tableId, { includeArchived: true }) + if (!table) throw new Error(`Delete target table ${tableId} not found`) + + const filterClause = filter + ? buildFilterClause(filter, USER_TABLE_ROWS_SQL_NAME, table.schema.columns) + : undefined + const excluded = new Set(excludeRowIds ?? []) + + let processed = 0 + let lastReported = 0 + let afterId: string | undefined + + while (true) { + // Ownership gate before every page: once this run loses the table (cancel/supersede), + // updateJobProgress returns false and we stop before deleting further. + const owns = await updateJobProgress(tableId, processed, jobId) + if (!owns) throw new JobSupersededError() + + const page = await selectRowIdPage({ + tableId, + workspaceId, + cutoff, + filterClause, + afterId, + limit: TABLE_LIMITS.DELETE_PAGE_SIZE, + }) + if (page.length === 0) break + // Advance the keyset cursor past the whole page — excluded ids are skipped (not deleted), + // so the cursor must move even when nothing in the page is deletable. + afterId = page[page.length - 1] + + const toDelete = excluded.size > 0 ? page.filter((id) => !excluded.has(id)) : page + if (toDelete.length > 0) { + processed += await deletePageByIds(tableId, workspaceId, toDelete) + } + + if ( + processed - lastReported >= PROGRESS_INTERVAL_ROWS || + (lastReported === 0 && processed > 0) + ) { + lastReported = processed + void appendTableEvent({ + kind: 'job', + type: 'delete', + tableId, + jobId, + status: 'running', + progress: processed, + }) + } + } + + await updateJobProgress(tableId, processed, jobId) + // Only announce success if we still won the transition — a cancel/supersede at the very end + // makes this a no-op, and we must not emit a false `ready`. + const becameReady = await markJobReady(tableId, jobId) + if (becameReady) { + void appendTableEvent({ + kind: 'job', + type: 'delete', + tableId, + jobId, + status: 'ready', + progress: processed, + }) + logger.info(`[${requestId}] Delete complete`, { tableId, rows: processed }) + } else { + logger.info( + `[${requestId}] Delete finished but no longer owns the run (canceled/superseded)`, + { + tableId, + jobId, + } + ) + } + } catch (err) { + if (err instanceof JobSupersededError) { + logger.info(`[${requestId}] Delete superseded by a newer run; stopping`, { tableId, jobId }) + } else { + const message = getErrorMessage(err, 'Delete failed') + logger.error(`[${requestId}] Delete failed for table ${tableId}:`, err) + // Scoped to jobId — a no-op if a newer job has taken over. + await markJobFailed(tableId, jobId, message).catch(() => {}) + void appendTableEvent({ + kind: 'job', + type: 'delete', + tableId, + jobId, + status: 'failed', + error: message, + }) + } + } +} diff --git a/apps/sim/lib/table/dispatcher.ts b/apps/sim/lib/table/dispatcher.ts index 998b701363d..99593f4097c 100644 --- a/apps/sim/lib/table/dispatcher.ts +++ b/apps/sim/lib/table/dispatcher.ts @@ -3,12 +3,27 @@ import { tableRowExecutions, tableRunDispatches, userTableRows } from '@sim/db/s import { createLogger } from '@sim/logger' import { toError } from '@sim/utils/errors' import { generateId } from '@sim/utils/id' -import { and, asc, eq, gt, inArray, isNotNull, ne, or, type SQL, sql } from 'drizzle-orm' +import { + and, + asc, + eq, + gt, + inArray, + isNotNull, + ne, + notInArray, + or, + type SQL, + sql, +} from 'drizzle-orm' import { getJobQueue } from '@/lib/core/async-jobs/config' import { writeWorkflowGroupState } from '@/lib/table/cell-write' +import { USER_TABLE_ROWS_SQL_NAME } from '@/lib/table/constants' import { isExecCancelledAfter } from '@/lib/table/deps' import { appendTableEvent } from '@/lib/table/events' -import type { RowExecutionMetadata, RowExecutions, TableRow } from '@/lib/table/types' +import { type DbExecutor, withSeqscanOff } from '@/lib/table/planner' +import { buildFilterClause } from '@/lib/table/sql' +import type { Filter, RowExecutionMetadata, RowExecutions, TableRow } from '@/lib/table/types' import { buildEnqueueItems, buildPendingRuns, @@ -32,6 +47,11 @@ export type DispatchMode = 'all' | 'incomplete' | 'new' export interface DispatchScope { groupIds: string[] rowIds?: string[] + /** "Select all matching a filter" — run every row matching this filter (mutually exclusive with + * `rowIds`). Lets the action-bar Play/Refresh target a filtered view without materializing ids. */ + filter?: Filter + /** Select-all scope only: deselected rows the walk skips (mirrors the delete job's exclusion set). */ + excludeRowIds?: string[] } /** @@ -76,9 +96,11 @@ export async function bulkClearWorkflowGroupCells(input: { tableId: string groups: Array<{ id: string; outputs: Array<{ columnName: string }> }> rowIds?: string[] + /** Select-all scope: deselected rows whose outputs must NOT be wiped. */ + excludeRowIds?: string[] mode: DispatchMode }): Promise { - const { tableId, groups, rowIds, mode } = input + const { tableId, groups, rowIds, excludeRowIds, mode } = input if (groups.length === 0) return // `'new'` mode targets only rows with no prior attempt — nothing to clear. // Pre-existing outputs on any other row must not be wiped by an auto-fire. @@ -86,6 +108,7 @@ export async function bulkClearWorkflowGroupCells(input: { const groupIds = groups.map((g) => g.id) const rowScope = rowIds && rowIds.length > 0 ? rowIds : null + const excluded = !rowScope && excludeRowIds && excludeRowIds.length > 0 ? excludeRowIds : null if (mode === 'all') { // Run-all re-runs every targeted group: wipe all their output columns + @@ -98,6 +121,7 @@ export async function bulkClearWorkflowGroupCells(input: { for (const col of outputCols) dataExpr = sql`(${dataExpr}) - ${col}::text` const filters: SQL[] = [eq(userTableRows.tableId, tableId)] if (rowScope) filters.push(inArray(userTableRows.id, rowScope)) + if (excluded) filters.push(notInArray(userTableRows.id, excluded)) await db.transaction(async (trx) => { await trx @@ -109,6 +133,7 @@ export async function bulkClearWorkflowGroupCells(input: { inArray(tableRowExecutions.groupId, groupIds), ] if (rowScope) execFilters.push(inArray(tableRowExecutions.rowId, rowScope)) + if (excluded) execFilters.push(notInArray(tableRowExecutions.rowId, excluded)) await trx.delete(tableRowExecutions).where(and(...execFilters)) }) return @@ -131,6 +156,7 @@ export async function bulkClearWorkflowGroupCells(input: { )` const filters: SQL[] = [eq(userTableRows.tableId, tableId), reRunnable] if (rowScope) filters.push(inArray(userTableRows.id, rowScope)) + if (excluded) filters.push(notInArray(userTableRows.id, excluded)) let dataExpr: SQL = sql`coalesce(${userTableRows.data}, '{}'::jsonb)` for (const out of group.outputs) dataExpr = sql`(${dataExpr}) - ${out.columnName}::text` @@ -145,6 +171,7 @@ export async function bulkClearWorkflowGroupCells(input: { sql`${tableRowExecutions.status} IN ('error', 'cancelled')`, ] if (rowScope) execFilters.push(inArray(tableRowExecutions.rowId, rowScope)) + if (excluded) execFilters.push(notInArray(tableRowExecutions.rowId, excluded)) await trx.delete(tableRowExecutions).where(and(...execFilters)) } }) @@ -394,8 +421,24 @@ export async function dispatcherStep(dispatchId: string): Promise 0) { filters.push(inArray(userTableRows.id, dispatch.scope.rowIds)) + } else if (dispatch.scope.filter) { + // "Select all under a filter": walk only the matching rows. Same cursor/window mechanism — + // non-matching rows are simply never selected, like mode eligibility. + const filterClause = buildFilterClause( + dispatch.scope.filter, + USER_TABLE_ROWS_SQL_NAME, + table.schema.columns + ) + if (filterClause) { + filters.push(filterClause) + hasJsonbFilter = true + } + } + if (!dispatch.scope.rowIds?.length && dispatch.scope.excludeRowIds?.length) { + filters.push(notInArray(userTableRows.id, dispatch.scope.excludeRowIds)) } // `'new'` mode targets only rows whose targeted groups haven't been // attempted. Exclude a row only when EVERY targeted group already has a @@ -417,12 +460,18 @@ export async function dispatcherStep(dispatchId: string): Promise + executor + .select() + .from(userTableRows) + .where(and(...filters)) + .orderBy(asc(userTableRows.position)) + .limit(WINDOW_SIZE) + // Filtered scopes carry a jsonb predicate the planner can't estimate — left alone it + // seq-scans the whole shared relation per window; keep it on the tenant's position index. + const chunk = hasJsonbFilter + ? await withSeqscanOff(async (trx) => windowQuery(trx)) + : await windowQuery(db) if (chunk.length === 0) { await markDispatchComplete(dispatchId) @@ -699,15 +748,35 @@ export async function markDispatchCancelled(dispatchId: string): Promise { * UPDATE so the dispatcher's next iteration observes the cancel. Returns the * dispatches that were cancelled so the caller can emit per-dispatch SSE * events — without those the client's overlay would hang on "queued" until - * the next refresh. */ -export async function markActiveDispatchesCancelled(tableId: string): Promise { + * the next refresh. Pass `scopeFilter` to cancel only dispatches whose scope + * is that exact filter (a filtered "select all" Stop must not halt + * whole-table or differently-filtered runs). Pass `spareExcludedRowIds` + * (select-all-minus-deselections Stop) to spare row-scoped dispatches whose + * rows are ALL deselected — that work wasn't in the stopped selection. */ +export async function markActiveDispatchesCancelled( + tableId: string, + scopeFilter?: Filter, + spareExcludedRowIds?: string[] +): Promise { const cancelled = await db .update(tableRunDispatches) .set({ status: 'cancelled', cancelledAt: new Date() }) .where( and( eq(tableRunDispatches.tableId, tableId), - inArray(tableRunDispatches.status, [...ACTIVE_DISPATCH_STATUSES]) + inArray(tableRunDispatches.status, [...ACTIVE_DISPATCH_STATUSES]), + scopeFilter + ? sql`${tableRunDispatches.scope}->'filter' = ${JSON.stringify(scopeFilter)}::jsonb` + : undefined, + // coalesce(false): table-wide dispatches have no scope.rowIds (NULL <@ x + // is NULL) and must still cancel. + spareExcludedRowIds && spareExcludedRowIds.length > 0 + ? sql`NOT coalesce( + ${tableRunDispatches.scope}->'rowIds' <@ ${JSON.stringify(spareExcludedRowIds)}::jsonb + AND jsonb_array_length(${tableRunDispatches.scope}->'rowIds') > 0, + false + )` + : undefined ) ) .returning() diff --git a/apps/sim/lib/table/events.ts b/apps/sim/lib/table/events.ts index 24156409a16..86a6f7ec09d 100644 --- a/apps/sim/lib/table/events.ts +++ b/apps/sim/lib/table/events.ts @@ -114,15 +114,17 @@ export type TableEvent = limit?: { type: 'rows'; max: number } } | { - /** Async large-import progress. The background import worker emits - * `importing` ticks as batches commit, then a terminal `ready`/`failed`. - * The client reveals the (hidden) rows on `ready` and shows a failure - * badge on `failed`. See `apps/sim/lib/table/import-runner.ts`. */ - kind: 'import' + /** Async background-job progress. Import and delete workers emit `running` + * ticks as batches commit, then a terminal `ready`/`failed`/`canceled`. + * `type` discriminates the work. The client reveals hidden import rows on + * `ready`, and on a delete `failed`/`canceled` restores optimistically + * hidden rows. See `import-runner.ts` / `delete-runner.ts`. */ + kind: 'job' tableId: string - importId: string - status: 'importing' | 'ready' | 'failed' | 'canceled' - /** Rows committed so far (importing) or in total (ready). */ + jobId: string + type: 'import' | 'delete' | 'export' | 'backfill' + status: 'running' | 'ready' | 'failed' | 'canceled' + /** Rows processed so far (running) or in total (ready). */ progress?: number /** Byte-based completion percent (0–100) — exact and monotonic, for the determinate bar. */ percent?: number diff --git a/apps/sim/lib/table/export-format.ts b/apps/sim/lib/table/export-format.ts new file mode 100644 index 00000000000..3d5256b13fc --- /dev/null +++ b/apps/sim/lib/table/export-format.ts @@ -0,0 +1,41 @@ +/** + * Shared serialization for table exports — used by both the synchronous streaming export route + * (small tables) and the background export job worker (large tables), so the two paths produce + * byte-identical files. + */ + +export function sanitizeExportFilename(name: string): string { + const cleaned = name.replace(/[^a-zA-Z0-9_-]+/g, '_').replace(/^_+|_+$/g, '') + return cleaned || 'table' +} + +/** + * Prefixes a single quote to values starting with a spreadsheet formula trigger + * (`=`, `+`, `-`, `@`, tab, CR), neutralizing CSV injection in Excel/Sheets. + */ +export function neutralizeCsvFormula(value: string): string { + return /^[=+\-@\t\r]/.test(value) ? `'${value}` : value +} + +/** + * Serializes a cell for CSV. Only string cells are formula-neutralized; numbers, + * booleans, dates, and JSON objects can never form a trigger and pass through verbatim. + */ +export function formatCsvValue(value: unknown): string { + if (value === null || value === undefined) return '' + if (value instanceof Date) return value.toISOString() + if (typeof value === 'object') return JSON.stringify(value) + if (typeof value === 'string') return neutralizeCsvFormula(value) + return String(value) +} + +export function toCsvRow(values: string[]): string { + return values.map(escapeCsvField).join(',') +} + +function escapeCsvField(field: string): string { + if (/[",\n\r]/.test(field)) { + return `"${field.replace(/"/g, '""')}"` + } + return field +} diff --git a/apps/sim/lib/table/export-runner.test.ts b/apps/sim/lib/table/export-runner.test.ts new file mode 100644 index 00000000000..04ee5f84664 --- /dev/null +++ b/apps/sim/lib/table/export-runner.test.ts @@ -0,0 +1,131 @@ +/** + * @vitest-environment node + */ +import { beforeEach, describe, expect, it, vi } from 'vitest' + +const { + mockGetTableById, + mockSelectExportRowPage, + mockUpdateJobProgress, + mockMarkJobReady, + mockMarkJobFailed, + mockSetJobResultKey, + mockAppendTableEvent, + mockUploadFile, + mockDeleteFile, +} = vi.hoisted(() => ({ + mockGetTableById: vi.fn(), + mockSelectExportRowPage: vi.fn(), + mockUpdateJobProgress: vi.fn(), + mockMarkJobReady: vi.fn(), + mockMarkJobFailed: vi.fn(), + mockSetJobResultKey: vi.fn(), + mockAppendTableEvent: vi.fn(), + mockUploadFile: vi.fn(), + mockDeleteFile: vi.fn(), +})) + +vi.mock('@/lib/table/service', () => ({ + getTableById: mockGetTableById, + selectExportRowPage: mockSelectExportRowPage, + updateJobProgress: mockUpdateJobProgress, + markJobReady: mockMarkJobReady, + markJobFailed: mockMarkJobFailed, + setJobResultKey: mockSetJobResultKey, +})) +vi.mock('@/lib/table/events', () => ({ appendTableEvent: mockAppendTableEvent })) +vi.mock('@/lib/uploads/core/storage-service', () => ({ + uploadFile: mockUploadFile, + deleteFile: mockDeleteFile, +})) + +import { runTableExport } from '@/lib/table/export-runner' + +const table = { + id: 'tbl_1', + name: 'People', + workspaceId: 'ws_1', + schema: { columns: [{ id: 'col_name', name: 'name', type: 'string' }] }, +} + +const payload = { jobId: 'job_1', tableId: 'tbl_1', workspaceId: 'ws_1', format: 'csv' as const } + +describe('runTableExport', () => { + beforeEach(() => { + vi.clearAllMocks() + mockGetTableById.mockResolvedValue(table) + mockUpdateJobProgress.mockResolvedValue(true) + mockMarkJobReady.mockResolvedValue(true) + mockMarkJobFailed.mockResolvedValue(undefined) + mockSetJobResultKey.mockResolvedValue(undefined) + // Echo the requested key back like preserveKey-aware providers do; the runner must record + // THIS returned key, not its own constructed one. + mockUploadFile.mockImplementation((opts: { customKey: string }) => + Promise.resolve({ key: opts.customKey }) + ) + mockDeleteFile.mockResolvedValue(undefined) + mockSelectExportRowPage.mockResolvedValue([ + { id: 'r1', data: { col_name: 'Ada' }, position: 0 }, + ]) + }) + + it('pages rows, uploads the file, stamps the result key, and marks ready', async () => { + await runTableExport(payload) + + expect(mockUploadFile).toHaveBeenCalledTimes(1) + const upload = mockUploadFile.mock.calls[0][0] + expect(upload.customKey).toBe('workspace/ws_1/exports/tbl_1/job_1/People.csv') + expect(upload.preserveKey).toBe(true) + expect(upload.contentType).toContain('text/csv') + expect(upload.file.toString('utf8')).toBe('name\nAda\n') + + expect(mockSetJobResultKey).toHaveBeenCalledWith('tbl_1', 'job_1', upload.customKey) + expect(mockMarkJobReady).toHaveBeenCalledWith('tbl_1', 'job_1') + expect(mockAppendTableEvent).toHaveBeenCalledWith( + expect.objectContaining({ kind: 'job', type: 'export', status: 'ready', progress: 1 }) + ) + expect(mockDeleteFile).not.toHaveBeenCalled() + }) + + it('serializes JSON exports with display-name keys', async () => { + await runTableExport({ ...payload, format: 'json' }) + const upload = mockUploadFile.mock.calls[0][0] + expect(upload.customKey.endsWith('/People.json')).toBe(true) + expect(JSON.parse(upload.file.toString('utf8'))).toEqual([{ name: 'Ada' }]) + }) + + it('stops without uploading when the ownership gate is lost (cancel)', async () => { + mockUpdateJobProgress.mockResolvedValue(false) + + await runTableExport(payload) + + expect(mockUploadFile).not.toHaveBeenCalled() + expect(mockMarkJobReady).not.toHaveBeenCalled() + expect(mockMarkJobFailed).not.toHaveBeenCalled() + }) + + it('cleans up an orphaned upload when the job was canceled at the wire', async () => { + mockMarkJobReady.mockResolvedValue(false) + + await runTableExport(payload) + + expect(mockUploadFile).toHaveBeenCalledTimes(1) + expect(mockDeleteFile).toHaveBeenCalledWith( + expect.objectContaining({ key: expect.stringContaining('exports/tbl_1/job_1') }) + ) + expect(mockAppendTableEvent).not.toHaveBeenCalledWith( + expect.objectContaining({ status: 'ready' }) + ) + }) + + it('marks the job failed and emits a failed event on error', async () => { + mockSelectExportRowPage.mockRejectedValue(new Error('boom')) + + await runTableExport(payload) + + expect(mockMarkJobFailed).toHaveBeenCalledWith('tbl_1', 'job_1', 'boom') + expect(mockAppendTableEvent).toHaveBeenCalledWith( + expect.objectContaining({ kind: 'job', type: 'export', status: 'failed', error: 'boom' }) + ) + }) +}) diff --git a/apps/sim/lib/table/export-runner.ts b/apps/sim/lib/table/export-runner.ts new file mode 100644 index 00000000000..93cb201cffd --- /dev/null +++ b/apps/sim/lib/table/export-runner.ts @@ -0,0 +1,150 @@ +import { createLogger } from '@sim/logger' +import { getErrorMessage } from '@sim/utils/errors' +import { generateId } from '@sim/utils/id' +import { buildNameById, getColumnId, rowDataIdToName } from '@/lib/table/column-keys' +import { appendTableEvent } from '@/lib/table/events' +import { + formatCsvValue, + neutralizeCsvFormula, + sanitizeExportFilename, + toCsvRow, +} from '@/lib/table/export-format' +import { + getTableById, + markJobFailed, + markJobReady, + selectExportRowPage, + setJobResultKey, + updateJobProgress, +} from '@/lib/table/service' +import { deleteFile, uploadFile } from '@/lib/uploads/core/storage-service' + +const logger = createLogger('TableExportRunner') + +/** Rows per page while building the file. Internal caller — not bound by MAX_QUERY_LIMIT; rows + * are fetched without executions, so even wide rows stay a few MB per batch. */ +const EXPORT_BATCH_SIZE = 5000 + +/** Thrown when this worker loses the job (canceled / janitor-failed). */ +class JobSupersededError extends Error {} + +export interface TableExportPayload { + jobId: string + tableId: string + workspaceId: string + format: 'csv' | 'json' +} + +/** + * Background worker for large table exports. Pages rows via `queryRows` (so the delete-job + * visibility mask applies — an export taken mid-delete excludes the doomed rows), accumulates the + * serialized file, uploads it to workspace storage, and stamps the storage key onto the job's + * payload (`resultKey`). The client downloads via a presigned URL from the download route; the + * janitor deletes the file when the terminal job is pruned. Ownership-gated per batch, so a + * cancel stops it within one page. Retry-safe: a retried attempt regenerates the file from + * scratch and overwrites nothing (fresh key per attempt; failures clean up their partial upload). + */ +export async function runTableExport(payload: TableExportPayload): Promise { + const { jobId, tableId, workspaceId, format } = payload + const requestId = generateId().slice(0, 8) + let uploadedKey: string | null = null + + try { + const table = await getTableById(tableId, { includeArchived: true }) + if (!table) throw new Error(`Export target table ${tableId} not found`) + + const columns = table.schema.columns + // Stored row data is id-keyed; CSV headers and JSON keys are display names, so translate + // id → name on the way out (export is a name-friendly boundary). + const nameById = buildNameById(table.schema) + + const chunks: string[] = [] + if (format === 'csv') { + chunks.push(`${toCsvRow(columns.map((c) => neutralizeCsvFormula(c.name)))}\n`) + } else { + chunks.push('[') + } + + let exported = 0 + let firstJsonRow = true + let after: { position: number; id: string } | null = null + while (true) { + // Ownership gate before every page: a canceled job stops within one batch. + const owns = await updateJobProgress(tableId, exported, jobId) + if (!owns) throw new JobSupersededError() + + const page = await selectExportRowPage(table, after, EXPORT_BATCH_SIZE) + if (page.length === 0) break + + for (const row of page) { + if (format === 'csv') { + chunks.push(`${toCsvRow(columns.map((c) => formatCsvValue(row.data[getColumnId(c)])))}\n`) + } else { + const prefix = firstJsonRow ? '' : ',' + firstJsonRow = false + chunks.push(prefix + JSON.stringify(rowDataIdToName(row.data, nameById))) + } + } + + exported += page.length + const last = page[page.length - 1] + after = { position: last.position, id: last.id } + if (page.length < EXPORT_BATCH_SIZE) break + } + if (format === 'json') chunks.push(']') + + const fileName = `${sanitizeExportFilename(table.name)}.${format}` + const key = `workspace/${workspaceId}/exports/${tableId}/${jobId}/${fileName}` + // `preserveKey` keeps the custom key verbatim (without it the provider rewrites the key to a + // timestamped, path-stripped name), and the *returned* key is recorded as the source of truth + // either way — the download route presigns exactly what was written. + const uploaded = await uploadFile({ + file: Buffer.from(chunks.join(''), 'utf8'), + fileName, + contentType: format === 'csv' ? 'text/csv; charset=utf-8' : 'application/json', + context: 'workspace', + customKey: key, + preserveKey: true, + }) + uploadedKey = uploaded.key + await setJobResultKey(tableId, jobId, uploaded.key) + + await updateJobProgress(tableId, exported, jobId) + // Only announce success if we still won the transition (not canceled at the wire). + const becameReady = await markJobReady(tableId, jobId) + if (becameReady) { + void appendTableEvent({ + kind: 'job', + type: 'export', + tableId, + jobId, + status: 'ready', + progress: exported, + }) + logger.info(`[${requestId}] Export complete`, { tableId, rows: exported, format }) + } else { + // Canceled at the very end — the file is orphaned; remove it (janitor would otherwise + // only catch it via the pruned job's resultKey). + await deleteFile({ key: uploaded.key, context: 'workspace' }).catch(() => {}) + logger.info(`[${requestId}] Export finished but no longer owns the run`, { tableId, jobId }) + } + } catch (err) { + // A partial/orphaned upload from this attempt is useless — clean it up best-effort. + if (uploadedKey) await deleteFile({ key: uploadedKey, context: 'workspace' }).catch(() => {}) + if (err instanceof JobSupersededError) { + logger.info(`[${requestId}] Export superseded/canceled; stopping`, { tableId, jobId }) + } else { + const message = getErrorMessage(err, 'Export failed') + logger.error(`[${requestId}] Export failed for table ${tableId}:`, err) + await markJobFailed(tableId, jobId, message).catch(() => {}) + void appendTableEvent({ + kind: 'job', + type: 'export', + tableId, + jobId, + status: 'failed', + error: message, + }) + } + } +} diff --git a/apps/sim/lib/table/import-runner.ts b/apps/sim/lib/table/import-runner.ts index 64593044178..44a7d3ec693 100644 --- a/apps/sim/lib/table/import-runner.ts +++ b/apps/sim/lib/table/import-runner.ts @@ -24,12 +24,12 @@ import { bulkInsertImportBatch, deleteAllTableRows, getTableById, - markImportFailed, - markImportReady, + markJobFailed, + markJobReady, nextImportStartOrderKey, nextImportStartPosition, setTableSchemaForImport, - updateImportProgress, + updateJobProgress, } from '@/lib/table/service' import { deleteFile, downloadFileStream, headObject } from '@/lib/uploads/core/storage-service' import { normalizeColumn } from '@/app/api/table/utils' @@ -185,9 +185,9 @@ export async function runTableImport(payload: TableImportPayload): Promise const flush = async (rows: Record[]) => { if (rows.length === 0 || !schema || !headerToColumn) return // Ownership gate before every insert: once this run loses the table (cancel/supersede), - // updateImportProgress returns false and we stop before writing into a table a newer import + // updateJobProgress returns false and we stop before writing into a table a newer import // may own. Runs per batch (not just at the emit cadence) so we stop within one batch. - const owns = await updateImportProgress(tableId, inserted, importId) + const owns = await updateJobProgress(tableId, inserted, importId) if (!owns) throw new ImportSupersededError() const coerced = coerceRowsForTable(rows, schema, headerToColumn) const result = await bulkInsertImportBatch( @@ -214,10 +214,11 @@ export async function runTableImport(payload: TableImportPayload): Promise const percent = totalBytes > 0 ? Math.min(99, Math.round((bytesRead / totalBytes) * 100)) : undefined void appendTableEvent({ - kind: 'import', + kind: 'job', + type: 'import', tableId, - importId, - status: 'importing', + jobId: importId, + status: 'running', progress: inserted, percent, }) @@ -247,11 +248,12 @@ export async function runTableImport(payload: TableImportPayload): Promise if (sample.length === 0) { // No data rows — fail rather than report a successful empty import (matches the sync route). const message = 'CSV file has no data rows' - await markImportFailed(tableId, importId, message) + await markJobFailed(tableId, importId, message) void appendTableEvent({ - kind: 'import', + kind: 'job', + type: 'import', tableId, - importId, + jobId: importId, status: 'failed', error: message, }) @@ -277,15 +279,16 @@ export async function runTableImport(payload: TableImportPayload): Promise await flush(batch) } - await updateImportProgress(tableId, inserted, importId) + await updateJobProgress(tableId, inserted, importId) // Only announce success if we actually won the transition — a cancel/supersede that landed // right at the end makes this a no-op, and we must not emit a false `ready`. - const becameReady = await markImportReady(tableId, importId) + const becameReady = await markJobReady(tableId, importId) if (becameReady) { void appendTableEvent({ - kind: 'import', + kind: 'job', + type: 'import', tableId, - importId, + jobId: importId, status: 'ready', progress: inserted, percent: 100, @@ -323,8 +326,15 @@ export async function runTableImport(payload: TableImportPayload): Promise const message = getErrorMessage(err, 'Import failed') logger.error(`[${requestId}] Import failed for table ${tableId}:`, err) // Scoped to importId — a no-op if a newer import has taken over. - await markImportFailed(tableId, importId, message).catch(() => {}) - void appendTableEvent({ kind: 'import', tableId, importId, status: 'failed', error: message }) + await markJobFailed(tableId, importId, message).catch(() => {}) + void appendTableEvent({ + kind: 'job', + type: 'import', + tableId, + jobId: importId, + status: 'failed', + error: message, + }) captureServerEvent( userId, 'table_import_completed', diff --git a/apps/sim/lib/table/import.ts b/apps/sim/lib/table/import.ts index 1584c9826c6..a132ba96dd7 100644 --- a/apps/sim/lib/table/import.ts +++ b/apps/sim/lib/table/import.ts @@ -50,8 +50,13 @@ export type CsvColumnType = 'string' | 'number' | 'boolean' | 'date' | 'json' /** Number of CSV rows sampled when inferring column types for a new table. */ export const CSV_SCHEMA_SAMPLE_SIZE = 100 -/** Maximum rows inserted per `batchInsertRows` call during import. */ -export const CSV_MAX_BATCH_SIZE = 1000 +/** + * Maximum rows inserted per import batch. Each batch is one `INSERT … VALUES` statement, and + * Postgres caps bind parameters at 65,535 — at 9 params per row that's a hard ceiling of ~7,200 + * rows, so 5,000 keeps a margin while cutting per-batch overhead (validation, unique-constraint + * check, ownership heartbeat) 5× vs the old 1,000. + */ +export const CSV_MAX_BATCH_SIZE = 5000 /** Maximum CSV/TSV file size accepted by import routes (25 MB). */ export const CSV_MAX_FILE_SIZE_BYTES = 25 * 1024 * 1024 diff --git a/apps/sim/lib/table/planner.ts b/apps/sim/lib/table/planner.ts new file mode 100644 index 00000000000..848e2c2d6de --- /dev/null +++ b/apps/sim/lib/table/planner.ts @@ -0,0 +1,23 @@ +import { db } from '@sim/db' +import { sql } from 'drizzle-orm' + +export type DbExecutor = typeof db | DbTransaction +export type DbTransaction = Parameters[0]>[0] + +/** + * Runs `fn` with seq scans penalized (`SET LOCAL`, so the flag dies with the + * transaction). JSONB predicates and sort keys (`->>` extraction, `@>` + * containment, lateral `jsonb_each_text`) are opaque to the planner — it + * estimates a handful of matching rows and picks a parallel seq scan over the + * entire shared `user_table_rows` relation (every tenant's rows) instead of the + * tenant's own index. Measured on a 1M-row table inside a 12M-row relation: + * filtered count 12.7s → 1.0s, sorted page 9.7s → 0.76s, filtered bulk select + * 14.4s → tenant-bounded. The flag only penalizes the plan shape: if no index + * plan exists, the seq scan still runs. + */ +export async function withSeqscanOff(fn: (trx: DbTransaction) => Promise): Promise { + return db.transaction(async (trx) => { + await trx.execute(sql`SET LOCAL enable_seqscan = off`) + return fn(trx) + }) +} diff --git a/apps/sim/lib/table/service.ts b/apps/sim/lib/table/service.ts index 46dd031efcc..7d2757450d9 100644 --- a/apps/sim/lib/table/service.ts +++ b/apps/sim/lib/table/service.ts @@ -8,14 +8,9 @@ */ import { db } from '@sim/db' -import { - tableRowExecutions, - userTableDefinitions, - userTableRows, - workflowExecutionLogs, -} from '@sim/db/schema' +import { tableJobs, tableRowExecutions, userTableDefinitions, userTableRows } from '@sim/db/schema' import { createLogger } from '@sim/logger' -import { getPostgresErrorCode } from '@sim/utils/errors' +import { getPostgresErrorCode, toError } from '@sim/utils/errors' import { generateId } from '@sim/utils/id' import { and, @@ -28,16 +23,16 @@ import { inArray, isNull, lt, + lte, ne, + notInArray, or, type SQL, sql, } from 'drizzle-orm' import { isTablesFractionalOrderingEnabled } from '@/lib/core/config/feature-flags' -import { MATERIALIZE_CONCURRENCY, mapWithConcurrency } from '@/lib/core/utils/concurrency' import { generateRestoreName } from '@/lib/core/utils/restore-name' import type { DbOrTx } from '@/lib/db/types' -import { materializeExecutionData } from '@/lib/logs/execution/trace-store' import { columnMatchesRef, generateColumnId, @@ -49,6 +44,7 @@ import { COLUMN_TYPES, NAME_PATTERN, TABLE_LIMITS, USER_TABLE_ROWS_SQL_NAME } fr import { areGroupDepsSatisfied } from './deps' import { CSV_MAX_BATCH_SIZE } from './import' import { keyBetween, nKeysBetween } from './order-key' +import { type DbExecutor, type DbTransaction, withSeqscanOff } from './planner' import { buildFilterClause, buildSortClause, escapeLikePattern } from './sql' import { fireTableTrigger } from './trigger' import type { @@ -76,6 +72,9 @@ import type { RowExecutions, Sort, TableDefinition, + TableDeleteJobPayload, + TableExportJobPayload, + TableJobType, TableMetadata, TableRow, TableSchema, @@ -116,8 +115,6 @@ export class TableConflictError extends Error { export type TableScope = 'active' | 'archived' | 'all' -type DbTransaction = Parameters[0]>[0] - /** * Sets per-transaction Postgres timeouts via `SET LOCAL`. * @@ -253,6 +250,99 @@ function applyColumnOrderToSchema( return { ...schema, columns: ordered } } +/** Job fields projected onto a {@link TableDefinition}, derived from its latest `table_jobs` row. */ +interface DerivedJobFields { + jobStatus: TableDefinition['jobStatus'] + jobId: string | null + jobType: TableDefinition['jobType'] + jobError: string | null + jobRowsProcessed: number + /** + * Rows a running delete job still has to remove (its doomed estimate minus + * deletions so far). Internal to count adjustment — callers subtract it from + * the raw `row_count` so list/detail counts match the read path's delete + * mask (a mid-delete refresh must not resurrect the count). Not on the wire. + */ + pendingDeleteRemaining: number +} + +const EMPTY_JOB_FIELDS: DerivedJobFields = { + jobStatus: null, + jobId: null, + jobType: null, + jobError: null, + jobRowsProcessed: 0, + pendingDeleteRemaining: 0, +} + +function mapJobRow( + row: + | { + id: string + type: string + status: string + rowsProcessed: number + error: string | null + payload: unknown + } + | undefined +): DerivedJobFields { + if (!row) return EMPTY_JOB_FIELDS + const doomedCount = + row.type === 'delete' && row.status === 'running' + ? ((row.payload as TableDeleteJobPayload | null)?.doomedCount ?? 0) + : 0 + return { + jobStatus: row.status as TableDefinition['jobStatus'], + jobId: row.id, + jobType: row.type as TableDefinition['jobType'], + jobError: row.error, + jobRowsProcessed: row.rowsProcessed, + pendingDeleteRemaining: Math.max(0, doomedCount - row.rowsProcessed), + } +} + +const JOB_PROJECTION = { + id: tableJobs.id, + type: tableJobs.type, + status: tableJobs.status, + rowsProcessed: tableJobs.rowsProcessed, + error: tableJobs.error, + payload: tableJobs.payload, +} as const + +/** + * The latest job for one table (the running one if present, else the most recent terminal). + * Exports are excluded: they're read-only, run concurrently with other jobs, and have their own + * client surface — surfacing one here would clobber the import/delete/backfill status the tray + * and SSE consumer derive from these fields. + */ +async function latestJobForTable( + tableId: string, + executor: DbOrTx = db +): Promise { + const [row] = await executor + .select(JOB_PROJECTION) + .from(tableJobs) + .where(and(eq(tableJobs.tableId, tableId), ne(tableJobs.type, 'export'))) + .orderBy(desc(tableJobs.startedAt)) + .limit(1) + return mapJobRow(row) +} + +/** Latest non-export job per table for a batch of ids, via `DISTINCT ON (table_id)`. */ +async function latestJobsForTables(tableIds: string[]): Promise> { + const map = new Map() + if (tableIds.length === 0) return map + const rows = await db + .selectDistinctOn([tableJobs.tableId], { tableId: tableJobs.tableId, ...JOB_PROJECTION }) + .from(tableJobs) + .where(and(inArray(tableJobs.tableId, tableIds), ne(tableJobs.type, 'export'))) + .orderBy(tableJobs.tableId, desc(tableJobs.startedAt)) + for (const row of rows) map.set(row.tableId, mapJobRow(row)) + return map +} + export async function getTableById( tableId: string, options?: { includeArchived?: boolean; tx?: DbOrTx } @@ -273,11 +363,6 @@ export async function getTableById( createdAt: userTableDefinitions.createdAt, updatedAt: userTableDefinitions.updatedAt, rowCount: userTableDefinitions.rowCount, - importStatus: userTableDefinitions.importStatus, - importId: userTableDefinitions.importId, - importError: userTableDefinitions.importError, - importRowsProcessed: userTableDefinitions.importRowsProcessed, - importStartedAt: userTableDefinitions.importStartedAt, }) .from(userTableDefinitions) .where( @@ -291,24 +376,21 @@ export async function getTableById( const table = results[0] const metadata = (table.metadata as TableMetadata) ?? null + const { pendingDeleteRemaining, ...jobFields } = await latestJobForTable(tableId, executor) return { id: table.id, name: table.name, description: table.description, schema: applyColumnOrderToSchema(table.schema as TableSchema, metadata), metadata, - rowCount: table.rowCount, + rowCount: Math.max(0, table.rowCount - pendingDeleteRemaining), maxRows: table.maxRows, workspaceId: table.workspaceId, createdBy: table.createdBy, archivedAt: table.archivedAt, createdAt: table.createdAt, updatedAt: table.updatedAt, - importStatus: table.importStatus as TableDefinition['importStatus'], - importId: table.importId, - importError: table.importError, - importRowsProcessed: table.importRowsProcessed, - importStartedAt: table.importStartedAt, + ...jobFields, } } @@ -350,11 +432,6 @@ export async function listTables( createdAt: userTableDefinitions.createdAt, updatedAt: userTableDefinitions.updatedAt, rowCount: userTableDefinitions.rowCount, - importStatus: userTableDefinitions.importStatus, - importId: userTableDefinitions.importId, - importError: userTableDefinitions.importError, - importRowsProcessed: userTableDefinitions.importRowsProcessed, - importStartedAt: userTableDefinitions.importStartedAt, }) .from(userTableDefinitions) .where( @@ -372,26 +449,25 @@ export async function listTables( ) .orderBy(userTableDefinitions.createdAt) + const jobsByTable = await latestJobsForTables(tables.map((t) => t.id)) + return tables.map((t) => { const metadata = (t.metadata as TableMetadata) ?? null + const { pendingDeleteRemaining, ...jobFields } = jobsByTable.get(t.id) ?? EMPTY_JOB_FIELDS return { id: t.id, name: t.name, description: t.description, schema: applyColumnOrderToSchema(t.schema as TableSchema, metadata), metadata, - rowCount: t.rowCount, + rowCount: Math.max(0, t.rowCount - pendingDeleteRemaining), maxRows: t.maxRows, workspaceId: t.workspaceId, createdBy: t.createdBy, archivedAt: t.archivedAt, createdAt: t.createdAt, updatedAt: t.updatedAt, - importStatus: t.importStatus as TableDefinition['importStatus'], - importId: t.importId, - importError: t.importError, - importRowsProcessed: t.importRowsProcessed, - importStartedAt: t.importStartedAt, + ...jobFields, } }) } @@ -441,11 +517,14 @@ export async function createTable( archivedAt: null, createdAt: now, updatedAt: now, - importStatus: data.importStatus ?? null, - importId: data.importId ?? null, - importStartedAt: data.importStatus ? now : null, } + // Create-mode CSV import is born with a running job so its rows stay hidden until ready. + const initialJob = + data.jobStatus === 'running' && data.jobId + ? { id: data.jobId, type: data.jobType ?? 'import', startedAt: now } + : null + // Wrap count check, duplicate check, and insert in a transaction with FOR UPDATE // to prevent TOCTOU race on the table count limit try { @@ -485,6 +564,18 @@ export async function createTable( await trx.insert(userTableDefinitions).values(newTable) + if (initialJob) { + await trx.insert(tableJobs).values({ + id: initialJob.id, + tableId, + workspaceId: data.workspaceId, + type: initialJob.type, + status: 'running', + startedAt: initialJob.startedAt, + updatedAt: initialJob.startedAt, + }) + } + const initialRowCount = data.initialRowCount ?? 0 if (initialRowCount > 0) { const orderKeys = nKeysBetween(null, null, initialRowCount) @@ -526,10 +617,11 @@ export async function createTable( archivedAt: newTable.archivedAt, createdAt: newTable.createdAt, updatedAt: newTable.updatedAt, - importStatus: newTable.importStatus as TableDefinition['importStatus'], - importId: newTable.importId, - importRowsProcessed: 0, - importStartedAt: newTable.importStartedAt, + jobStatus: initialJob ? 'running' : null, + jobId: initialJob?.id ?? null, + jobType: initialJob?.type ?? null, + jobError: null, + jobRowsProcessed: 0, } } @@ -1485,8 +1577,11 @@ async function deleteOrderedRowsByIds(params: { tableId: string workspaceId: string rowIds: string[] + /** Skip the post-delete position recompaction (the paginated delete worker compacts once at + * the end instead of per page — per-page compaction is O(N) each, O(N²) over a full delete). */ + skipCompaction?: boolean }): Promise<{ id: string; position: number }[]> { - const { tableId, workspaceId, rowIds } = params + const { tableId, workspaceId, rowIds, skipCompaction = false } = params if (rowIds.length === 0) return [] return db.transaction(async (trx) => { await setTableTxTimeouts(trx, { statementMs: 60_000 }) @@ -1506,7 +1601,7 @@ async function deleteOrderedRowsByIds(params: { deleted.push(...rows) } // Fractional ordering: deletes leave order_key untouched, so no recompaction. - if (!isTablesFractionalOrderingEnabled && deleted.length > 0) { + if (!isTablesFractionalOrderingEnabled && !skipCompaction && deleted.length > 0) { const minDeletedPos = deleted.reduce( (min, r) => (r.position < min ? r.position : min), deleted[0].position @@ -1517,6 +1612,65 @@ async function deleteOrderedRowsByIds(params: { }) } +/** + * Selects one page of row ids to delete for the async delete-job worker: base scope plus a + * `created_at <= cutoff` floor (so rows inserted after the job started are never selected) and + * the caller's optional filter clause. Keyset paginated on `id` via `afterId` so excluded rows + * (which are skipped, not deleted) still advance the cursor — no OFFSET, no risk of looping on a + * fully-excluded page. + */ +export async function selectRowIdPage(params: { + tableId: string + workspaceId: string + cutoff: Date + filterClause?: SQL + afterId?: string + limit: number +}): Promise { + const { tableId, workspaceId, cutoff, filterClause, afterId, limit } = params + const selectPage = (executor: DbExecutor) => + executor + .select({ id: userTableRows.id }) + .from(userTableRows) + .where( + and( + eq(userTableRows.tableId, tableId), + eq(userTableRows.workspaceId, workspaceId), + lte(userTableRows.createdAt, cutoff), + afterId ? gt(userTableRows.id, afterId) : undefined, + filterClause + ) + ) + .orderBy(asc(userTableRows.id)) + .limit(limit) + // A jsonb filter is unestimatable, so the planner would seq-scan the whole shared relation + // per page (12.6s measured) — keep it on the tenant's (table_id, id) index. + const rows = filterClause + ? await withSeqscanOff(async (trx) => selectPage(trx)) + : await selectPage(db) + return rows.map((r) => r.id) +} + +/** + * Deletes one page of rows by id (the statement-level row_count trigger fires once). Skips legacy + * position compaction: under fractional ordering it's unnecessary (order keys are authoritative), + * and in the legacy path a bulk delete leaving `position` gaps is harmless — rows still order by + * position. (Compacting per page would be O(N²) over a full delete.) Returns the count deleted. + */ +export async function deletePageByIds( + tableId: string, + workspaceId: string, + rowIds: string[] +): Promise { + const deleted = await deleteOrderedRowsByIds({ + tableId, + workspaceId, + rowIds, + skipCompaction: true, + }) + return deleted.length +} + /** * Inserts a single row into a table. * @@ -1853,131 +2007,250 @@ export async function setTableSchemaForImport(tableId: string, schema: TableSche } /** - * Atomically claims a table for an async import. The `import_status != 'importing'` guard makes - * this the single concurrency gate: of two racing kickoffs only one row-update matches, so only - * one wins (no TOCTOU between a separate status check and this write). Returns whether it claimed - * the table — the caller returns 409 when it didn't. + * Atomically claims a table's single background-job slot by inserting a `running` row into + * `table_jobs`. The partial-unique index on `table_id WHERE status = 'running'` is the + * concurrency gate: a second insert while a job runs hits `ON CONFLICT DO NOTHING` and returns no + * row, so import and delete (and two imports) are mutually exclusive for free. Returns whether it + * claimed the slot; the caller returns 409 when it didn't. */ -export async function markTableImporting(tableId: string, importId: string): Promise { - const updated = await db - .update(userTableDefinitions) - .set({ - importStatus: 'importing', - importId, - importError: null, - importRowsProcessed: 0, - importStartedAt: new Date(), - updatedAt: new Date(), +export async function markTableJobRunning( + tableId: string, + jobId: string, + type: TableJobType, + /** Type-specific scope persisted to `table_jobs.payload` (e.g. {@link TableDeleteJobPayload}) + * so read paths can mask the job's effect while it runs. */ + payload?: unknown +): Promise { + // workspace_id is immutable; the atomic gate is the INSERT's conflict, not this read. + const [def] = await db + .select({ workspaceId: userTableDefinitions.workspaceId }) + .from(userTableDefinitions) + .where(eq(userTableDefinitions.id, tableId)) + .limit(1) + if (!def) return false + const inserted = await db + .insert(tableJobs) + .values({ + id: jobId, + tableId, + workspaceId: def.workspaceId, + type, + status: 'running', + payload: payload ?? null, }) - .where( - and( - eq(userTableDefinitions.id, tableId), - or( - isNull(userTableDefinitions.importStatus), - ne(userTableDefinitions.importStatus, 'importing') - ) - ) - ) - .returning({ id: userTableDefinitions.id }) - return updated.length > 0 + .onConflictDoNothing() + .returning({ id: tableJobs.id }) + return inserted.length > 0 } /** - * Releases a claim taken by {@link markTableImporting} for a synchronous import — clears the - * import state back to idle. Scoped to `importId` so it only clears its own claim, never a newer - * run that may have taken over. A sync route claims, writes, then releases here in a `finally`. + * Releases a claim taken by {@link markTableJobRunning} for a synchronous job — deletes the + * transient claim row. Scoped to `jobId` + still-running so it only clears its own claim, never a + * newer run. A sync route claims, writes, then releases here in a `finally`. */ -export async function releaseImportClaim(tableId: string, importId: string): Promise { +export async function releaseJobClaim(tableId: string, jobId: string): Promise { await db - .update(userTableDefinitions) - .set({ importStatus: null, importId: null, importStartedAt: null, updatedAt: new Date() }) + .delete(tableJobs) .where( - and( - eq(userTableDefinitions.id, tableId), - eq(userTableDefinitions.importId, importId), - eq(userTableDefinitions.importStatus, 'importing') - ) + and(eq(tableJobs.id, jobId), eq(tableJobs.tableId, tableId), eq(tableJobs.status, 'running')) ) } /** - * Records import progress (rows processed so far). Also bumps `updatedAt` so the - * stale-import janitor (`cleanup-stale-executions`) sees a live heartbeat and doesn't mark a - * still-running import as failed. + * Records job progress (rows processed so far) and bumps `updated_at` so the stale-job janitor + * (`cleanup-stale-executions`) sees a live heartbeat. * - * Scoped to `importId` AND `import_status = 'importing'`: a stale/superseded worker no longer - * matches (its write is a no-op), and once the import is terminal (e.g. canceled) the match fails - * too — so this returning `false` is also the worker's signal to stop. Returns whether this worker - * still owns an in-flight import. + * Scoped to `jobId` AND `status = 'running'`: a stale/superseded worker no longer matches (its + * write is a no-op), and once the job is terminal (e.g. canceled) the match fails too — so this + * returning `false` is the worker's signal to stop. Returns whether this worker still owns an + * in-flight job. */ -export async function updateImportProgress( +export async function updateJobProgress( tableId: string, rowsProcessed: number, - importId: string + jobId: string ): Promise { const updated = await db - .update(userTableDefinitions) - .set({ importRowsProcessed: rowsProcessed, updatedAt: new Date() }) + .update(tableJobs) + .set({ rowsProcessed, updatedAt: new Date() }) + .where(ownsActiveJob(tableId, jobId)) + .returning({ id: tableJobs.id }) + return updated.length > 0 +} + +/** + * One keyset page of rows for the export worker, ordered by `(position, id)`. Keyset (not + * OFFSET) keeps each page O(page) — offset paging re-scans every prior row per page, which is + * O(N²) across a large export. `(position, id)` is total (position exists on every row; id breaks + * ties) and served by the `(table_id, position)` index; under fractional ordering a manually + * reordered table may export in near-grid rather than exact grid order — the right trade for a + * bulk dump. The delete-job visibility mask applies, like every user-facing read. + */ +export async function selectExportRowPage( + table: TableDefinition, + after: { position: number; id: string } | null, + limit: number +): Promise> { + const deleteMask = await pendingDeleteMask(table) + const rows = await db + .select({ id: userTableRows.id, data: userTableRows.data, position: userTableRows.position }) + .from(userTableRows) .where( and( - eq(userTableDefinitions.id, tableId), - eq(userTableDefinitions.importId, importId), - eq(userTableDefinitions.importStatus, 'importing') + eq(userTableRows.tableId, table.id), + eq(userTableRows.workspaceId, table.workspaceId), + deleteMask, + after + ? sql`(${userTableRows.position}, ${userTableRows.id}) > (${after.position}, ${after.id})` + : undefined ) ) - .returning({ id: userTableDefinitions.id }) - return updated.length > 0 + .orderBy(asc(userTableRows.position), asc(userTableRows.id)) + .limit(limit) + return rows as Array<{ id: string; data: RowData; position: number }> +} + +/** How long a terminal export stays listable (and re-downloadable from the tray). */ +const EXPORT_JOB_VISIBILITY_MS = 10 * 60 * 1000 + +export interface WorkspaceExportJob { + jobId: string + tableId: string + tableName: string + status: string + rowsProcessed: number + format: 'csv' | 'json' + hasResult: boolean + error: string | null +} + +/** + * Export jobs the tray surfaces for a workspace: everything running, plus terminals from the last + * {@link EXPORT_JOB_VISIBILITY_MS} so a just-finished export stays re-downloadable. Exports live + * outside the table-level job derivation (which excludes them), so this is their read path. + */ +export async function listWorkspaceExportJobs(workspaceId: string): Promise { + const visibilityCutoff = new Date(Date.now() - EXPORT_JOB_VISIBILITY_MS) + const rows = await db + .select({ + jobId: tableJobs.id, + tableId: tableJobs.tableId, + tableName: userTableDefinitions.name, + status: tableJobs.status, + rowsProcessed: tableJobs.rowsProcessed, + payload: tableJobs.payload, + error: tableJobs.error, + }) + .from(tableJobs) + .innerJoin(userTableDefinitions, eq(userTableDefinitions.id, tableJobs.tableId)) + .where( + and( + eq(tableJobs.workspaceId, workspaceId), + eq(tableJobs.type, 'export'), + or(eq(tableJobs.status, 'running'), gt(tableJobs.updatedAt, visibilityCutoff)) + ) + ) + .orderBy(desc(tableJobs.startedAt)) + return rows.map((r) => { + const payload = r.payload as TableExportJobPayload | null + return { + jobId: r.jobId, + tableId: r.tableId, + tableName: r.tableName, + status: r.status, + rowsProcessed: r.rowsProcessed, + format: payload?.format ?? 'csv', + hasResult: Boolean(payload?.resultKey), + error: r.error, + } + }) +} + +/** Reads one job row (type/status/payload) scoped to its table. Null when absent. */ +export async function getTableJob( + tableId: string, + jobId: string +): Promise<{ id: string; type: string; status: string; payload: unknown } | null> { + const [job] = await db + .select({ + id: tableJobs.id, + type: tableJobs.type, + status: tableJobs.status, + payload: tableJobs.payload, + }) + .from(tableJobs) + .where(and(eq(tableJobs.id, jobId), eq(tableJobs.tableId, tableId))) + .limit(1) + return job ?? null +} + +/** + * Stamps an export job's generated-file storage key onto its payload (`{ resultKey }` merge). + * Scoped to the still-running job so a superseded attempt can't clobber a newer run's result. + * The download route reads it; the janitor deletes the file when the terminal job is pruned. + */ +export async function setJobResultKey( + tableId: string, + jobId: string, + resultKey: string +): Promise { + await db + .update(tableJobs) + .set({ + payload: sql`coalesce(${tableJobs.payload}, '{}'::jsonb) || jsonb_build_object('resultKey', ${resultKey}::text)`, + updatedAt: new Date(), + }) + .where(ownsActiveJob(tableId, jobId)) } -/** Shared WHERE for terminal transitions: this import run, and still in-flight (write-once). */ -function ownsActiveImport(tableId: string, importId: string) { +/** Shared WHERE for terminal transitions: this job run, and still in-flight (write-once). */ +function ownsActiveJob(tableId: string, jobId: string) { return and( - eq(userTableDefinitions.id, tableId), - eq(userTableDefinitions.importId, importId), - eq(userTableDefinitions.importStatus, 'importing') + eq(tableJobs.id, jobId), + eq(tableJobs.tableId, tableId), + eq(tableJobs.status, 'running') ) } /** - * Marks an import complete; rows become visible. No-op unless it's still this in-flight run. - * Returns whether it transitioned, so the worker only emits the `ready` event when it actually - * won (and not after a cancel / supersede). + * Marks a job complete. No-op unless it's still this in-flight run. Returns whether it + * transitioned, so the worker only emits the `ready` event when it actually won (and not after a + * cancel / supersede). */ -export async function markImportReady(tableId: string, importId: string): Promise { +export async function markJobReady(tableId: string, jobId: string): Promise { + const now = new Date() const updated = await db - .update(userTableDefinitions) - .set({ importStatus: 'ready', importError: null, updatedAt: new Date() }) - .where(ownsActiveImport(tableId, importId)) - .returning({ id: userTableDefinitions.id }) + .update(tableJobs) + .set({ status: 'ready', error: null, completedAt: now, updatedAt: now }) + .where(ownsActiveJob(tableId, jobId)) + .returning({ id: tableJobs.id }) return updated.length > 0 } /** - * Marks an import failed, leaving any already-committed rows in place. No-op unless it's still - * this in-flight run (so a stale worker can't clobber a newer import or a cancel). + * Marks a job failed, leaving any already-committed work in place. No-op unless it's still this + * in-flight run (so a stale worker can't clobber a newer job or a cancel). */ -export async function markImportFailed( - tableId: string, - importId: string, - error: string -): Promise { +export async function markJobFailed(tableId: string, jobId: string, error: string): Promise { + const now = new Date() await db - .update(userTableDefinitions) - .set({ importStatus: 'failed', importError: error.slice(0, 2000), updatedAt: new Date() }) - .where(ownsActiveImport(tableId, importId)) + .update(tableJobs) + .set({ status: 'failed', error: error.slice(0, 2000), completedAt: now, updatedAt: now }) + .where(ownsActiveJob(tableId, jobId)) } /** - * Marks an in-flight import canceled (user-initiated). No-op unless it's still importing. The - * worker's next ownership check then returns `false` and it stops; committed rows are left in - * place (no rollback). Returns whether a running import was actually canceled. + * Marks an in-flight job canceled (user-initiated). No-op unless it's still running. The + * worker's next ownership check then returns `false` and it stops; committed work is left in + * place (no rollback). Returns whether a running job was actually canceled. */ -export async function markImportCanceled(tableId: string, importId: string): Promise { +export async function markJobCanceled(tableId: string, jobId: string): Promise { + const now = new Date() const updated = await db - .update(userTableDefinitions) - .set({ importStatus: 'canceled', updatedAt: new Date() }) - .where(ownsActiveImport(tableId, importId)) - .returning({ id: userTableDefinitions.id }) + .update(tableJobs) + .set({ status: 'canceled', completedAt: now, updatedAt: now }) + .where(ownsActiveJob(tableId, jobId)) + .returning({ id: tableJobs.id }) return updated.length > 0 } @@ -2259,6 +2532,10 @@ export async function upsertRow( // trigger (migration 0198). The update path doesn't change row_count, so no check needed. const result = await db.transaction(async (trx) => { await setTableTxTimeouts(trx) + // The conflict lookups below match on `data->>key` — unestimatable, and an + // insert-path upsert (no existing match) can't exit early, so the planner + // would seq-scan the whole shared relation. See withSeqscanOff. + await trx.execute(sql`SET LOCAL enable_seqscan = off`) // Find existing row by single conflict target column const [existingRow] = await trx @@ -2448,10 +2725,15 @@ const FIND_MATCH_LIMIT = 1000 * reveal it). `filter`/`sort` mirror the active list view via * {@link buildRowOrderBySql}, keeping ordinals aligned. * - * Cost: sequential scan bounded by the `table_id` btree prefix — `ILIKE` over - * `jsonb_each_text` cannot use the JSONB GIN index. Acceptable for tables - * ≪1M rows; a `pg_trgm` GIN index on a text projection is the future - * accelerator if needed. + * Cost: one pass over the table's rows — `ILIKE` over `jsonb_each_text` cannot + * use the JSONB GIN index, and the ordinal's `row_number()` needs every row + * counted regardless. The planner can't estimate the lateral ILIKE (jsonb is + * opaque to it), so left alone it seq-scans the entire shared relation and + * disk-sorts the window input (measured 75s on a 1M-row table in a 12M-row + * relation). `SET LOCAL` planner flags keep it tenant-bounded; on the default + * order they additionally force the streaming `(table_id, order_key, id)` index + * walk where `row_number()` needs no sort at all (measured 2s). A `pg_trgm` GIN + * index on a text projection is the future accelerator if needed. */ export async function findRowMatches( table: TableDefinition, @@ -2464,9 +2746,13 @@ export async function findRowMatches( const columnIds = columns.map(getColumnId) if (columnIds.length === 0) return { matches: [], truncated: false } + // Same visibility rule as queryRows: don't surface rows a running delete job will remove. + const deleteMask = await pendingDeleteMask(table) + const baseConditions = and( eq(userTableRows.tableId, table.id), - eq(userTableRows.workspaceId, table.workspaceId) + eq(userTableRows.workspaceId, table.workspaceId), + deleteMask ) let whereClause: SQL | undefined = baseConditions if (options.filter && Object.keys(options.filter).length > 0) { @@ -2477,24 +2763,39 @@ export async function findRowMatches( const orderBySql = buildRowOrderBySql(options.sort, tableName, columns) const pattern = `%${escapeLikePattern(options.q)}%` - const result = await db.execute<{ - ordinal: string | number - id: string - column_name: string - }>(sql` - WITH ordered AS ( - SELECT id, data, row_number() OVER (ORDER BY ${orderBySql}) - 1 AS ordinal - FROM ${userTableRows} - WHERE ${whereClause} - ) - SELECT o.ordinal, o.id, kv.key AS column_name - FROM ordered o - CROSS JOIN LATERAL jsonb_each_text(o.data) kv - WHERE kv.value ILIKE ${pattern} - AND ${inArray(sql`kv.key`, columnIds)} - ORDER BY o.ordinal - LIMIT ${FIND_MATCH_LIMIT + 1} - `) + const result = await db.transaction(async (trx) => { + // Planner flags, not correctness: `enable_* = off` only penalizes a plan shape, so a + // genuinely required sort still runs. Seqscan off keeps the scan inside the tenant's rows + // (the lateral ILIKE is unestimatable, so the planner otherwise walks the whole shared + // relation). On the default order, the remaining flags steer to the already-sorted + // `(table_id, order_key, id)` index walk so the window function streams without a 100MB+ + // disk sort; a custom sort has no index to stream from, so those flags would only distort + // that plan. + await trx.execute(sql`SET LOCAL enable_seqscan = off`) + if (!options.sort) { + await trx.execute(sql`SET LOCAL enable_bitmapscan = off`) + await trx.execute(sql`SET LOCAL enable_sort = off`) + await trx.execute(sql`SET LOCAL max_parallel_workers_per_gather = 0`) + } + return trx.execute<{ + ordinal: string | number + id: string + column_name: string + }>(sql` + WITH ordered AS ( + SELECT id, data, row_number() OVER (ORDER BY ${orderBySql}) - 1 AS ordinal + FROM ${userTableRows} + WHERE ${whereClause} + ) + SELECT o.ordinal, o.id, kv.key AS column_name + FROM ordered o + CROSS JOIN LATERAL jsonb_each_text(o.data) kv + WHERE kv.value ILIKE ${pattern} + AND ${inArray(sql`kv.key`, columnIds)} + ORDER BY o.ordinal + LIMIT ${FIND_MATCH_LIMIT + 1} + `) + }) const all = Array.from(result) const truncated = all.length > FIND_MATCH_LIMIT @@ -2528,6 +2829,66 @@ export async function findRowMatches( * @param requestId - Request ID for logging * @returns Query result with rows and pagination info */ +/** + * Visibility mask for a running delete job: returns a clause keeping only rows the job will NOT + * delete, or `undefined` when no delete job is running. The job's persisted scope + * ({@link TableDeleteJobPayload}) defines the doomed set — `matches(filter) AND created_at <= + * cutoff AND id NOT IN excludeRowIds` — exactly what the worker's `selectRowIdPage` selects, so + * mid-job reads (refresh, other clients, exports) are consistent with the eventual result. The + * mask lifts automatically when the job leaves `running` (done, failed, or canceled). + * + * `(doomed) IS NOT TRUE` rather than `NOT (doomed)`: JSONB predicates evaluate to NULL on missing + * cells, and those rows are NOT selected for deletion (NULL ≠ TRUE) — they must stay visible. + */ +async function pendingDeleteMask(table: TableDefinition): Promise { + const [job] = await db + .select({ payload: tableJobs.payload }) + .from(tableJobs) + .where( + and( + eq(tableJobs.tableId, table.id), + eq(tableJobs.status, 'running'), + eq(tableJobs.type, 'delete') + ) + ) + .limit(1) + if (!job?.payload) return undefined + const scope = job.payload as TableDeleteJobPayload + + const doomedParts: SQL[] = [] + if (scope.filter && Object.keys(scope.filter).length > 0) { + try { + const clause = buildFilterClause(scope.filter, USER_TABLE_ROWS_SQL_NAME, table.schema.columns) + if (clause) doomedParts.push(clause) + } catch (error) { + // Schema drifted mid-job (column renamed/deleted). Showing doomed rows briefly beats + // failing every read; the worker resolves the same way on its next page. + logger.warn(`Skipping delete-job mask for table ${table.id}: stale filter`, { + error: toError(error).message, + }) + return undefined + } + } + if (scope.cutoff) doomedParts.push(lte(userTableRows.createdAt, new Date(scope.cutoff))) + if (scope.excludeRowIds && scope.excludeRowIds.length > 0) { + doomedParts.push(notInArray(userTableRows.id, scope.excludeRowIds)) + } + if (doomedParts.length === 0) return undefined + return sql`(${and(...doomedParts)}) IS NOT TRUE` +} + +/** + * `COUNT(*)` for a filtered view, kept inside the tenant's rows: measured + * 12.7s → 1.0s counting a rare ILIKE filter on a 1M-row table inside a 12M-row + * relation (see {@link withSeqscanOff} for why the planner gets this wrong). + */ +async function countRowsTenantBounded(whereClause: SQL | undefined): Promise { + return withSeqscanOff(async (trx) => { + const [result] = await trx.select({ count: count() }).from(userTableRows).where(whereClause) + return Number(result.count) + }) +} + export async function queryRows( table: TableDefinition, options: QueryOptions, @@ -2538,6 +2899,7 @@ export async function queryRows( sort, limit = TABLE_LIMITS.DEFAULT_QUERY_LIMIT, offset = 0, + after, includeTotal = true, withExecutions = true, } = options @@ -2545,9 +2907,14 @@ export async function queryRows( const tableName = USER_TABLE_ROWS_SQL_NAME const columns = table.schema.columns + // Hide rows a running delete job is about to remove — both the page and the count below share + // this clause, so totals stay consistent with the visible rows. + const deleteMask = await pendingDeleteMask(table) + const baseConditions = and( eq(userTableRows.tableId, table.id), - eq(userTableRows.workspaceId, table.workspaceId) + eq(userTableRows.workspaceId, table.workspaceId), + deleteMask ) let whereClause = baseConditions @@ -2558,24 +2925,48 @@ export async function queryRows( } } - const query = db - .select() - .from(userTableRows) - .where(whereClause ?? baseConditions) - .orderBy(buildRowOrderBySql(sort, tableName, columns)) + // Keyset page: seek past the cursor on the default `(order_key, id)` order instead of paying + // OFFSET's scan-and-discard of every prior row (O(N²) across a deep scroll / full drain). Only + // valid without a custom sort — the contract rejects `after` + `sort` together. The count below + // deliberately excludes the cursor: totals cover the whole view, not the remaining pages. + const pageWhere = + after && !sort + ? and( + whereClause, + sql`(${userTableRows.orderKey}, ${userTableRows.id}) > (${after.orderKey}, ${after.id})` + ) + : whereClause + + const buildPageQuery = (executor: DbExecutor) => { + const query = executor + .select() + .from(userTableRows) + .where(pageWhere ?? baseConditions) + .orderBy(buildRowOrderBySql(sort, tableName, columns)) + return after ? query.limit(limit) : query.limit(limit).offset(offset) + } // Count and page fetch are independent reads — run them concurrently so the - // `includeTotal` hot path doesn't pay two serial round-trips. - const rowsPromise = query.limit(limit).offset(offset) + // `includeTotal` hot path doesn't pay two serial round-trips. Filtered counts + // go through the tenant-bounded variant (see countRowsTenantBounded); the + // unfiltered count already plans an index-only scan on the table_id prefix. + // Custom column sorts order by `data->>'col'` — unestimatable, so left alone + // the planner seq-scans and sorts the whole shared relation on every page + // (9.7s measured on a 1M-row table; 0.76s tenant-bounded). Default-order + // pages already stream the `(table_id, order_key, id)` index. + const hasFilter = Boolean(filter && Object.keys(filter).length > 0) + const rowsPromise = sort ? withSeqscanOff(async (trx) => buildPageQuery(trx)) : buildPageQuery(db) const countPromise = includeTotal - ? db - .select({ count: count() }) - .from(userTableRows) - .where(whereClause ?? baseConditions) + ? hasFilter + ? countRowsTenantBounded(whereClause) + : db + .select({ count: count() }) + .from(userTableRows) + .where(whereClause ?? baseConditions) + .then((r) => Number(r[0].count)) : null - const [rows, countResult] = await Promise.all([rowsPromise, countPromise]) - const totalCount = countResult ? Number(countResult[0].count) : null + const [rows, totalCount] = await Promise.all([rowsPromise, countPromise]) const executionsByRow = withExecutions ? await loadExecutionsByRow( @@ -3113,16 +3504,18 @@ export async function updateRowsByFilter( eq(userTableRows.workspaceId, table.workspaceId) ) - let query = db - .select({ id: userTableRows.id, data: userTableRows.data }) - .from(userTableRows) - .where(and(baseConditions, filterClause)) - - if (data.limit) { - query = query.limit(data.limit) as typeof query - } - - const matchingRows = await query + // Tenant-bounded: the jsonb filter is unestimatable and otherwise sends the planner to a + // whole-shared-relation seq scan (14.4s measured on a 1M-row table). + const matchingRows = await withSeqscanOff(async (trx) => { + let query = trx + .select({ id: userTableRows.id, data: userTableRows.data }) + .from(userTableRows) + .where(and(baseConditions, filterClause)) + if (data.limit) { + query = query.limit(data.limit) as typeof query + } + return query + }) if (matchingRows.length === 0) { return { affectedCount: 0, affectedRowIds: [] } @@ -3454,16 +3847,17 @@ export async function deleteRowsByFilter( eq(userTableRows.workspaceId, table.workspaceId) ) - let query = db - .select({ id: userTableRows.id, position: userTableRows.position }) - .from(userTableRows) - .where(and(baseConditions, filterClause)) - - if (data.limit) { - query = query.limit(data.limit) as typeof query - } - - const matchingRows = await query + // Tenant-bounded for the same reason as updateRowsByFilter — see withSeqscanOff. + const matchingRows = await withSeqscanOff(async (trx) => { + let query = trx + .select({ id: userTableRows.id, position: userTableRows.position }) + .from(userTableRows) + .where(and(baseConditions, filterClause)) + if (data.limit) { + query = query.limit(data.limit) as typeof query + } + return query + }) if (matchingRows.length === 0) { return { affectedCount: 0, affectedRowIds: [] } @@ -4417,12 +4811,14 @@ export async function updateWorkflowGroup( // - remapped outputs (existing column re-pointed): overwrite, since the // new mapping is the source of truth and the user expects the cell to // refresh to the new output's value. - // Awaited so the response only returns once row data is consistent. A - // failed backfill is logged but doesn't fail the request — the schema - // change has already committed. + // Small tables backfill inline-awaited (response returns with consistent + // data); large ones run as a background job. A failed backfill is logged + // but doesn't fail the request — the schema change has already committed. + // Lazy import: backfill-runner closes a cycle back to this module. + const { maybeBackfillGroupOutputs } = await import('./backfill-runner') if (added.length > 0) { try { - await backfillGroupOutputsFromLogs({ + await maybeBackfillGroupOutputs({ table: updatedTable, groupId: data.groupId, outputs: added, @@ -4440,7 +4836,7 @@ export async function updateWorkflowGroup( if (remappedColumnIds.size > 0) { const remappedOutputs = newOutputs.filter((o) => remappedColumnIds.has(o.columnName)) try { - await backfillGroupOutputsFromLogs({ + await maybeBackfillGroupOutputs({ table: updatedTable, groupId: data.groupId, outputs: remappedOutputs, @@ -4698,8 +5094,11 @@ export async function addWorkflowGroupOutput( // Cheap compared to re-running the workflow on every row, which is what // an earlier version of this code did — that mistakenly fanned out N // workflow-group-cell jobs and burned compute the user didn't ask for. + // Small tables backfill inline; large ones run as a background job. + // Lazy import: backfill-runner closes a cycle back to this module. try { - await backfillGroupOutputsFromLogs({ + const { maybeBackfillGroupOutputs } = await import('./backfill-runner') + await maybeBackfillGroupOutputs({ table: updatedTable, groupId: data.groupId, outputs: [newOutput], @@ -4850,152 +5249,6 @@ export async function deleteWorkflowGroup( }) } -/** Minimal shape of a trace span we care about for backfill. */ -interface BackfillTraceSpan { - blockId?: string - output?: Record - children?: BackfillTraceSpan[] -} - -/** DFS the trace tree for the first span matching `blockId`. */ -function findSpanByBlockId( - spans: BackfillTraceSpan[] | undefined, - blockId: string -): BackfillTraceSpan | undefined { - if (!spans) return undefined - for (const span of spans) { - if (span.blockId === blockId) return span - const child = findSpanByBlockId(span.children, blockId) - if (child) return child - } - return undefined -} - -/** - * Walks completed group executions and pulls each target output's value out of - * the workflow's saved trace spans, writing it back into row data. Used in two - * spots: - * - * - **added** outputs (new columns added to an existing group): `overwrite` - * is false, so rows with a hand-edited value already in the column are - * left alone. - * - **remapped** outputs (existing column re-pointed at a different - * `(blockId, path)`): `overwrite` is true — the new mapping is the source - * of truth, and the user expects the column to refresh to the new - * output's value rather than retain the stale old one. - */ -async function backfillGroupOutputsFromLogs(opts: { - table: TableDefinition - groupId: string - outputs: WorkflowGroupOutput[] - overwrite: boolean - requestId: string - actorUserId?: string | null -}): Promise { - const { table, groupId, outputs, overwrite, requestId, actorUserId } = opts - if (outputs.length === 0) return - - const { pluckByPath } = await import('./pluck') - - // Find rows whose group execution completed and grab their executionId - // directly from the sidecar — hits the (table_id, group_id) index, no - // table scan over rowdata. - const completedExecs = await db - .select({ - rowId: tableRowExecutions.rowId, - executionId: tableRowExecutions.executionId, - }) - .from(tableRowExecutions) - .where( - and( - eq(tableRowExecutions.tableId, table.id), - eq(tableRowExecutions.groupId, groupId), - eq(tableRowExecutions.status, 'completed') - ) - ) - - const executionIdsByRow = new Map() - for (const e of completedExecs) { - if (!e.executionId) continue - executionIdsByRow.set(e.rowId, e.executionId) - } - if (executionIdsByRow.size === 0) return - - const rowRecords = await db - .select({ id: userTableRows.id, data: userTableRows.data }) - .from(userTableRows) - .where( - and( - eq(userTableRows.tableId, table.id), - inArray(userTableRows.id, Array.from(executionIdsByRow.keys())) - ) - ) - - const executionIds = Array.from(new Set(executionIdsByRow.values())) - const logs = await db - .select({ - executionId: workflowExecutionLogs.executionId, - workflowId: workflowExecutionLogs.workflowId, - workspaceId: workflowExecutionLogs.workspaceId, - executionData: workflowExecutionLogs.executionData, - }) - .from(workflowExecutionLogs) - .where(inArray(workflowExecutionLogs.executionId, executionIds)) - - const logByExecutionId = new Map() - // Heavy execution data may live in object storage; resolve pointers (bounded - // concurrency) so trace spans are available for table-column enrichment. - await mapWithConcurrency(logs, MATERIALIZE_CONCURRENCY, async (log) => { - const executionData = await materializeExecutionData( - log.executionData as Record | null, - { workspaceId: log.workspaceId, workflowId: log.workflowId, executionId: log.executionId } - ) - logByExecutionId.set( - log.executionId, - (executionData as { traceSpans?: BackfillTraceSpan[] }) ?? {} - ) - }) - - const updates: Array<{ rowId: string; data: RowData }> = [] - for (const r of rowRecords) { - const execId = executionIdsByRow.get(r.id) - if (!execId) continue - const log = logByExecutionId.get(execId) - if (!log) continue - - const dataPatch: RowData = {} - let mutated = false - for (const out of outputs) { - if (!overwrite && (r.data as RowData)[out.columnName] !== undefined) continue - const span = findSpanByBlockId(log.traceSpans, out.blockId) - if (!span?.output) continue - const picked = pluckByPath(span.output, out.path) - if (picked === undefined) continue - dataPatch[out.columnName] = picked as RowData[string] - mutated = true - } - if (!mutated) continue - updates.push({ rowId: r.id, data: dataPatch }) - } - - if (updates.length === 0) return - - await batchUpdateRows( - { - tableId: table.id, - updates, - workspaceId: table.workspaceId, - actorUserId, - }, - table, - requestId - ) - - logger.info( - `[${requestId}] Backfilled ${updates.length} row(s) for group "${groupId}" in table ${table.id} (${overwrite ? 'remapped' : 'added'})` - ) -} - /** * Checks if a value is compatible with a target column type. */ diff --git a/apps/sim/lib/table/types.ts b/apps/sim/lib/table/types.ts index df36bc8f465..aaa0760a3e3 100644 --- a/apps/sim/lib/table/types.ts +++ b/apps/sim/lib/table/types.ts @@ -191,8 +191,60 @@ export interface TableMetadata { pinnedColumns?: string[] } -/** Async-import lifecycle state for a table. NULL/undefined = normal (no async import). */ -export type TableImportStatus = 'importing' | 'ready' | 'failed' | 'canceled' +/** Async background-job lifecycle state for a table. NULL/undefined = idle (no job). */ +export type TableJobStatus = 'running' | 'ready' | 'failed' | 'canceled' + +/** + * Which kind of background job a `table_jobs` row tracks. `import`, `delete`, and `backfill` + * mutate row data and share the single-running-job gate; `export` is read-only and bypasses it + * (the partial-unique index excludes it), so an export can run alongside any other job. + */ +export type TableJobType = 'import' | 'delete' | 'export' | 'backfill' + +/** + * Persisted scope of a running delete job (`table_jobs.payload`). Defines the doomed row set — + * `matches(filter) AND created_at <= cutoff AND id NOT IN excludeRowIds` — so the rows read-path + * can mask those rows out while the job runs, making mid-job reads (refresh, other clients) + * consistent with the eventual result. + */ +export interface TableDeleteJobPayload { + filter?: Filter + excludeRowIds?: string[] + /** ISO timestamp; rows created after it are spared. */ + cutoff: string + /** Doomed-row estimate captured at kickoff — display-only: list/detail counts subtract the + * not-yet-deleted remainder (doomedCount - rows_processed) while the job runs. */ + doomedCount?: number +} + +/** + * Persisted scope of an export job (`table_jobs.payload`). `resultKey` is merged in by the worker + * on completion — the storage key of the generated file, served to the client via a presigned URL + * and deleted by the janitor when the terminal job is pruned. + */ +export interface TableExportJobPayload { + format: 'csv' | 'json' + resultKey?: string +} + +/** + * Keyset cursor for paginating a table's default row order, `(order_key, id)`. The grid's + * infinite scroll threads this instead of an OFFSET — offset paging re-scans every prior row per + * page (O(N²) to drain a table); the cursor makes each page an index seek on + * `(table_id, order_key, id)`. Only valid for the default order: sorted views fall back to offset. + */ +export interface TableRowsCursor { + orderKey: string + id: string +} + +/** Persisted scope of an output-column backfill job (`table_jobs.payload`). */ +export interface TableBackfillJobPayload { + groupId: string + outputs: WorkflowGroupOutput[] + /** Remaps overwrite existing cell values; added columns never clobber hand-edits. */ + overwrite: boolean +} export interface TableDefinition { id: string @@ -207,12 +259,15 @@ export interface TableDefinition { archivedAt?: Date | string | null createdAt: Date | string updatedAt: Date | string - /** Async-import state (see `apps/sim/lib/table/import-runner.ts`). */ - importStatus?: TableImportStatus | null - importId?: string | null - importError?: string | null - importRowsProcessed?: number - importStartedAt?: Date | string | null + /** + * Async background-job state, derived from the table's latest `table_jobs` row (running if any, + * else the most recent terminal). See `import-runner.ts` / `delete-runner.ts`. + */ + jobStatus?: TableJobStatus | null + jobId?: string | null + jobType?: TableJobType | null + jobError?: string | null + jobRowsProcessed?: number } /** Minimal table info for UI components. */ @@ -316,6 +371,9 @@ export interface QueryOptions { sort?: Sort limit?: number offset?: number + /** Keyset cursor for the default `(order_key, id)` order — see {@link TableRowsCursor}. + * Mutually exclusive with `sort` and `offset`; takes precedence over `offset` when set. */ + after?: TableRowsCursor /** * When true (default), runs a `COUNT(*)` and returns `totalCount` as a number. * Pass `false` to skip the count query (grid UI doesn't need it); `totalCount` @@ -355,10 +413,12 @@ export interface CreateTableData { maxTables?: number /** Number of empty rows to create with the table. Defaults to 0. */ initialRowCount?: number - /** When set, the table is created in this async-import state (rows hidden until ready). */ - importStatus?: TableImportStatus - /** Async-import id stamped on the table when `importStatus` is set. */ - importId?: string + /** When set, the table is created with this job already running (rows hidden until ready). */ + jobStatus?: TableJobStatus + /** Job kind, paired with `jobStatus` (create-mode import sets `'import'`). */ + jobType?: TableJobType + /** Async job id stamped on the table when `jobStatus` is set. */ + jobId?: string } export interface InsertRowData { diff --git a/apps/sim/lib/table/validation.ts b/apps/sim/lib/table/validation.ts index 72b077ecc55..fa3aacaf98b 100644 --- a/apps/sim/lib/table/validation.ts +++ b/apps/sim/lib/table/validation.ts @@ -4,10 +4,11 @@ import { db } from '@sim/db' import { userTableRows } from '@sim/db/schema' -import { and, eq, or, sql } from 'drizzle-orm' +import { and, eq, or, type SQL, sql } from 'drizzle-orm' import { NextResponse } from 'next/server' import { getColumnId } from './column-keys' import { COLUMN_TYPES, NAME_PATTERN, TABLE_LIMITS } from './constants' +import { withSeqscanOff } from './planner' import type { ColumnDefinition, JsonValue, RowData, TableSchema, ValidationResult } from './types' export type { ColumnDefinition, TableSchema, ValidationResult } @@ -425,7 +426,7 @@ export async function checkUniqueConstraintsDb( } // Build conditions for each unique column value - const conditions = [] + const conditions: Array<{ column: ColumnDefinition; value: unknown; sql: SQL }> = [] for (const column of uniqueColumns) { const key = getColumnId(column) @@ -456,27 +457,42 @@ export async function checkUniqueConstraintsDb( return { valid: true, errors: [] } } - // Query for each unique column separately to provide specific error messages - for (const condition of conditions) { - const baseCondition = and(eq(userTableRows.tableId, tableId), condition.sql) - - const whereClause = excludeRowId - ? and(baseCondition, sql`${userTableRows.id} != ${excludeRowId}`) - : baseCondition - - const conflictingRow = await executor - .select({ id: userTableRows.id, position: userTableRows.position }) - .from(userTableRows) - .where(whereClause) - .limit(1) - - if (conflictingRow.length > 0) { - errors.push( - `Column "${condition.column.name}" must be unique. Value "${condition.value}" already exists in row ${conflictingRow[0].position + 1}` - ) + // Query for each unique column separately to provide specific error messages. + // Tenant-bounded: `lower(data->>'col') = ...` is unestimatable, so the planner + // otherwise seq-scans the whole shared relation per check — 3.5s on every + // insert/edit when the value is unique (no early exit). With an external + // transaction the flag is set on it directly — opening our own transaction + // inside the caller's would be the nested pool checkout the migration- + // hardening work eliminated (self-deadlock under pool exhaustion). + const checkConditions = async (ex: UniqueCheckExecutor) => { + for (const condition of conditions) { + const baseCondition = and(eq(userTableRows.tableId, tableId), condition.sql) + + const whereClause = excludeRowId + ? and(baseCondition, sql`${userTableRows.id} != ${excludeRowId}`) + : baseCondition + + const conflictingRow = await ex + .select({ id: userTableRows.id, position: userTableRows.position }) + .from(userTableRows) + .where(whereClause) + .limit(1) + + if (conflictingRow.length > 0) { + errors.push( + `Column "${condition.column.name}" must be unique. Value "${condition.value}" already exists in row ${conflictingRow[0].position + 1}` + ) + } } } + if (executor === db) { + await withSeqscanOff(async (trx) => checkConditions(trx)) + } else { + await executor.execute(sql`SET LOCAL enable_seqscan = off`) + await checkConditions(executor) + } + return { valid: errors.length === 0, errors } } @@ -485,7 +501,7 @@ export async function checkUniqueConstraintsDb( * drizzle transaction (`trx`) satisfy this, letting callers run the lookup * inside an open transaction so it observes uncommitted prior-batch inserts. */ -type UniqueCheckExecutor = Pick +type UniqueCheckExecutor = Pick /** * Checks unique constraints for a batch of rows using targeted database queries. @@ -553,70 +569,84 @@ export async function checkBatchUniqueConstraintsDb( } } - // Now check against database for all unique values at once - for (const [columnId, { values, column }] of valuesByColumn) { - if (values.size === 0) continue + // Now check against database for all unique values at once. Tenant-bounded + // for the same reason as checkUniqueConstraintsDb: the lower(data->>...) + // predicates are unestimatable and otherwise trigger whole-relation seq + // scans. With an external transaction the flag is set on it directly (SET + // LOCAL dies at its commit; it only penalizes plan shape, and the statements + // that follow in those transactions are tenant-scoped writes). + const checkColumns = async (ex: UniqueCheckExecutor) => { + for (const [columnId, { values, column }] of valuesByColumn) { + if (values.size === 0) continue - if (!NAME_PATTERN.test(columnId)) { - throw new Error(`Invalid column id: ${columnId}`) - } - - const valueArray = Array.from(values) - const valueConditions = valueArray.map((normalizedValue) => { - // Check if the original values are strings (normalized values for strings are lowercase) - // We need to determine the type from the column definition or the first row that has this value - const isStringColumn = column.type === 'string' - - if (isStringColumn) { - return sql`lower(${userTableRows.data}->>${sql.raw(`'${columnId}'`)}) = ${normalizedValue}` + if (!NAME_PATTERN.test(columnId)) { + throw new Error(`Invalid column id: ${columnId}`) } - return sql`(${userTableRows.data}->${sql.raw(`'${columnId}'`)})::jsonb = ${normalizedValue}::jsonb` - }) - const conflictingRows = await executor - .select({ - id: userTableRows.id, - data: userTableRows.data, - position: userTableRows.position, + const valueArray = Array.from(values) + const valueConditions = valueArray.map((normalizedValue) => { + // Check if the original values are strings (normalized values for strings are lowercase) + // We need to determine the type from the column definition or the first row that has this value + const isStringColumn = column.type === 'string' + + if (isStringColumn) { + return sql`lower(${userTableRows.data}->>${sql.raw(`'${columnId}'`)}) = ${normalizedValue}` + } + return sql`(${userTableRows.data}->${sql.raw(`'${columnId}'`)})::jsonb = ${normalizedValue}::jsonb` }) - .from(userTableRows) - .where(and(eq(userTableRows.tableId, tableId), or(...valueConditions))) - .limit(valueArray.length) // We only need up to one conflict per value - - // Map conflicts back to batch rows - for (const conflict of conflictingRows) { - const conflictData = conflict.data as RowData - const conflictValue = conflictData[columnId] - const normalizedConflictValue = - typeof conflictValue === 'string' - ? conflictValue.toLowerCase() - : JSON.stringify(conflictValue) - - // Find which batch rows have this conflicting value - for (let i = 0; i < rows.length; i++) { - const rowValue = rows[i][columnId] - if (rowValue === null || rowValue === undefined) continue - - const normalizedRowValue = - typeof rowValue === 'string' ? rowValue.toLowerCase() : JSON.stringify(rowValue) - - if (normalizedRowValue === normalizedConflictValue) { - // Check if this row already has errors for this column - let rowError = rowErrors.find((e) => e.row === i) - if (!rowError) { - rowError = { row: i, errors: [] } - rowErrors.push(rowError) - } - const errorMsg = `Column "${column.name}" must be unique. Value "${rowValue}" already exists in row ${conflict.position + 1}` - if (!rowError.errors.includes(errorMsg)) { - rowError.errors.push(errorMsg) + const conflictingRows = await ex + .select({ + id: userTableRows.id, + data: userTableRows.data, + position: userTableRows.position, + }) + .from(userTableRows) + .where(and(eq(userTableRows.tableId, tableId), or(...valueConditions))) + .limit(valueArray.length) // We only need up to one conflict per value + + // Map conflicts back to batch rows + for (const conflict of conflictingRows) { + const conflictData = conflict.data as RowData + const conflictValue = conflictData[columnId] + const normalizedConflictValue = + typeof conflictValue === 'string' + ? conflictValue.toLowerCase() + : JSON.stringify(conflictValue) + + // Find which batch rows have this conflicting value + for (let i = 0; i < rows.length; i++) { + const rowValue = rows[i][columnId] + if (rowValue === null || rowValue === undefined) continue + + const normalizedRowValue = + typeof rowValue === 'string' ? rowValue.toLowerCase() : JSON.stringify(rowValue) + + if (normalizedRowValue === normalizedConflictValue) { + // Check if this row already has errors for this column + let rowError = rowErrors.find((e) => e.row === i) + if (!rowError) { + rowError = { row: i, errors: [] } + rowErrors.push(rowError) + } + + const errorMsg = `Column "${column.name}" must be unique. Value "${rowValue}" already exists in row ${conflict.position + 1}` + if (!rowError.errors.includes(errorMsg)) { + rowError.errors.push(errorMsg) + } } } } } } + if (executor === db) { + await withSeqscanOff(async (trx) => checkColumns(trx)) + } else { + await executor.execute(sql`SET LOCAL enable_seqscan = off`) + await checkColumns(executor) + } + // Sort errors by row index rowErrors.sort((a, b) => a.row - b.row) diff --git a/apps/sim/lib/table/workflow-columns.ts b/apps/sim/lib/table/workflow-columns.ts index ed5379fbe51..8adbe32a5eb 100644 --- a/apps/sim/lib/table/workflow-columns.ts +++ b/apps/sim/lib/table/workflow-columns.ts @@ -6,15 +6,20 @@ */ import { db } from '@sim/db' -import { pausedExecutions, tableRowExecutions, type userTableRows } from '@sim/db/schema' +import { + pausedExecutions, + tableRowExecutions, + userTableRows as userTableRowsTable, +} from '@sim/db/schema' import { createLogger } from '@sim/logger' import { toError } from '@sim/utils/errors' import { generateId } from '@sim/utils/id' -import { and, eq, inArray, sql } from 'drizzle-orm' +import { and, eq, inArray, notInArray, sql } from 'drizzle-orm' import type { EnqueueOptions } from '@/lib/core/async-jobs/types' import { isTriggerDevEnabled } from '@/lib/core/config/feature-flags' import { buildCancelledExecution } from '@/lib/table/cell-write' import type { + Filter, RowData, RowExecutionMetadata, RowExecutions, @@ -27,8 +32,10 @@ import type { const logger = createLogger('WorkflowGroupScheduler') import { getColumnId } from './column-keys' +import { USER_TABLE_ROWS_SQL_NAME } from './constants' import { areGroupDepsSatisfied, areOutputsFilled, isExecInFlight } from './deps' import type { DispatchLimit, DispatchMode } from './dispatcher' +import { buildFilterClause } from './sql' export { getUnmetGroupDeps, @@ -306,7 +313,7 @@ export async function cancelCellRunsByTags(tags: string[]): Promise { } export function toTableRow( - r: typeof userTableRows.$inferSelect, + r: typeof userTableRowsTable.$inferSelect, executions: RowExecutions = {} ): TableRow { return { @@ -350,12 +357,15 @@ export const TABLE_CONCURRENCY_LIMIT = 20 * whether the trigger.dev cancel reaches the worker before its terminal * write. Pass `groupIds` to restrict the cancel to a subset of groups on * the row (used by `updateRow` to cancel only the downstream groups whose - * deps just changed). + * deps just changed). Pass `filter` (table-wide form only) to cancel just + * the cells on rows matching it — a filtered "select all" must not stop + * work on rows outside its scope, so like the per-row form it leaves + * active dispatches running (their in-flight checks skip cancelled cells). */ export async function cancelWorkflowGroupRuns( tableId: string, rowId?: string, - options?: { groupIds?: string[] } + options?: { groupIds?: string[]; filter?: Filter; excludeRowIds?: string[] } ): Promise { const { getTableById, updateRow } = await import('@/lib/table/service') const { getJobQueue } = await import('@/lib/core/async-jobs/config') @@ -370,8 +380,11 @@ export async function cancelWorkflowGroupRuns( // Per-row cancel leaves the dispatcher alone — other rows in the same // dispatch keep running. Table-wide cancel must stop it, else the cursor // marches on and re-enqueues fresh cells past what we just cancelled. + // Filter-scoped cancel stops only dispatches with that exact filter scope + // (its own run); whole-table or differently-scoped dispatches keep running — + // their cells cancelled below are skipped via `cancelledAt > requestedAt`. if (!rowId) { - await markActiveDispatchesCancelled(tableId) + await markActiveDispatchesCancelled(tableId, options?.filter, options?.excludeRowIds) } const allGroups = table.schema.workflowGroups ?? [] @@ -422,6 +435,30 @@ export async function cancelWorkflowGroupRuns( ] if (rowId) { inFlightFilters.push(eq(tableRowExecutions.rowId, rowId)) + } else if (options?.excludeRowIds?.length) { + // Select-all minus deselections: the deselected rows' cells keep running. + inFlightFilters.push(notInArray(tableRowExecutions.rowId, options.excludeRowIds)) + } + if (!rowId && options?.filter) { + // Filter-scoped cancel: only cells on rows matching the filter. Semi-join + // against the tenant's rows — the in-flight sidecar set is small, so the + // jsonb predicate is evaluated on few rows. + const filterClause = buildFilterClause( + options.filter, + USER_TABLE_ROWS_SQL_NAME, + table.schema.columns + ) + if (filterClause) { + inFlightFilters.push( + inArray( + tableRowExecutions.rowId, + db + .select({ id: userTableRowsTable.id }) + .from(userTableRowsTable) + .where(and(eq(userTableRowsTable.tableId, tableId), filterClause)) + ) + ) + } } const inFlightRows = await db .select() @@ -587,6 +624,12 @@ export async function runWorkflowColumn(opts: { requestId: string groupIds?: string[] rowIds?: string[] + /** "Select all under a filter" — run every row matching this filter (mutually exclusive with + * `rowIds`). Threaded into the dispatch scope so the dispatcher walks only matching rows. */ + filter?: Filter + /** Select-all scope only: deselected rows — the dispatcher walk, eager clear, and pre-run + * cancel all skip them. */ + excludeRowIds?: string[] /** Optional cap on work before the dispatch completes (e.g. run only the * first N eligible rows). Null/omitted = process every row in scope. */ limit?: DispatchLimit | null @@ -599,7 +642,18 @@ export async function runWorkflowColumn(opts: { * account at billing time. */ triggeredByUserId?: string | null }): Promise<{ dispatchId: string | null }> { - const { tableId, workspaceId, mode, requestId, groupIds, rowIds, limit, triggeredByUserId } = opts + const { + tableId, + workspaceId, + mode, + requestId, + groupIds, + rowIds, + filter, + excludeRowIds, + limit, + triggeredByUserId, + } = opts const isManualRun = opts.isManualRun ?? true // Empty `rowIds` array means "scope explicitly empty" — auto-fire callers // (CSV import on zero matches, etc.) end up here. Skip the dispatch entirely @@ -641,7 +695,13 @@ export async function runWorkflowColumn(opts: { const cancelPriorRuns = isManualRun && (mode === 'all' || mode === 'incomplete') if (cancelPriorRuns) { if (!rowIds || rowIds.length === 0) { - await cancelWorkflowGroupRuns(tableId, undefined, { groupIds: targetGroupIds }) + // Filtered runs cancel only their own scope — a table-wide cancel here + // would stop unrelated work on rows outside the filter (or on deselected rows). + await cancelWorkflowGroupRuns(tableId, undefined, { + groupIds: targetGroupIds, + filter, + excludeRowIds, + }) } else { // Per-row cancel — sequential so we don't fan out N parallel // markActiveDispatchesCancelled calls (it's a no-op when rowId is set, @@ -659,11 +719,15 @@ export async function runWorkflowColumn(opts: { // rows in scope would blank far more than we re-run. `mode: 'all'` re-runs // completed cells without the clear anyway — the clear is only for instant // feedback, which the capped rows still get via the dispatcher's pre-stamp. - if (!limit) { + // Skip the eager clear for a filtered run: `bulkClearWorkflowGroupCells` keys by `rowIds`, and a + // filtered scope has none — clearing table-wide would blank rows that don't match the filter. The + // dispatcher's per-row pre-stamp still provides instant Pending feedback as it walks. + if (!limit && !filter) { await bulkClearWorkflowGroupCells({ tableId, groups: targetGroups.map((g) => ({ id: g.id, outputs: g.outputs })), rowIds, + excludeRowIds, mode, }) } @@ -680,6 +744,10 @@ export async function runWorkflowColumn(opts: { scope: { groupIds: targetGroupIds, ...(rowIds && rowIds.length > 0 ? { rowIds } : {}), + ...(filter ? { filter } : {}), + ...(excludeRowIds && excludeRowIds.length > 0 && !(rowIds && rowIds.length > 0) + ? { excludeRowIds } + : {}), }, limit, isManualRun, diff --git a/apps/sim/lib/uploads/core/setup.server.ts b/apps/sim/lib/uploads/core/setup.server.ts index 70a03f43976..500eae73c1a 100644 --- a/apps/sim/lib/uploads/core/setup.server.ts +++ b/apps/sim/lib/uploads/core/setup.server.ts @@ -12,8 +12,12 @@ import { const logger = createLogger('UploadsSetup') -const PROJECT_ROOT = path.resolve(process.cwd()) -export const UPLOAD_DIR_SERVER = join(PROJECT_ROOT, 'uploads') +// turbopackIgnore: an unscoped process.cwd() makes node-file-tracing sweep the whole +// project (including next.config.ts) into every route graph that reaches this module. +// Two routes doing so emit the swept config into same-named server chunks — when their +// contents diverge, the build dies with "Two or more assets … same output path". +const PROJECT_ROOT = path.resolve(/*turbopackIgnore: true*/ process.cwd()) +export const UPLOAD_DIR_SERVER = join(/*turbopackIgnore: true*/ PROJECT_ROOT, 'uploads') /** * Server-only function to ensure uploads directory exists diff --git a/apps/sim/stores/table/import-tray/store.ts b/apps/sim/stores/table/import-tray/store.ts index 66be5080894..174485acb61 100644 --- a/apps/sim/stores/table/import-tray/store.ts +++ b/apps/sim/stores/table/import-tray/store.ts @@ -25,6 +25,12 @@ interface ImportTrayState { notified: Record /** Ids (upload or table) canceled so callbacks/derivation don't resurrect them. */ canceledIds: Record + /** + * Server-listed rows the user dismissed (export jobIds). Unlike `notified` — an allow-list for + * table-derived terminals — export terminals are listed by the server for a visibility window, + * so dismissal needs a deny-list. + */ + dismissedIds: Record menuOpen: boolean startUpload: (upload: ImportUpload) => void @@ -34,6 +40,8 @@ interface ImportTrayState { notify: (tableId: string) => void /** Remove a terminal card (manual dismiss or auto-clear). */ dismiss: (tableId: string) => void + /** Hide a server-listed job row (export) for the rest of the session. */ + dismissJob: (jobId: string) => void /** Flag an id canceled and drop any optimistic upload for it. */ cancel: (id: string) => void isCanceled: (id: string) => boolean @@ -47,6 +55,7 @@ const initialState = { uploads: {} as Record, notified: {} as Record, canceledIds: {} as Record, + dismissedIds: {} as Record, menuOpen: false, } @@ -81,6 +90,9 @@ export const useImportTrayStore = create()( return { notified: rest } }), + dismissJob: (jobId) => + set((state) => ({ dismissedIds: { ...state.dismissedIds, [jobId]: true } })), + cancel: (id) => set((state) => { const { [id]: _removed, ...uploads } = state.uploads diff --git a/packages/db/migrations/0233_table_jobs_and_keyset.sql b/packages/db/migrations/0233_table_jobs_and_keyset.sql new file mode 100644 index 00000000000..33b2d8df6d4 --- /dev/null +++ b/packages/db/migrations/0233_table_jobs_and_keyset.sql @@ -0,0 +1,68 @@ +-- Replay-safety: this file ends in CONCURRENTLY index builds below an embedded COMMIT, +-- so a failure there replays the whole file — every statement here is idempotent. +CREATE TABLE IF NOT EXISTS "table_jobs" ( + "id" text PRIMARY KEY NOT NULL, + "table_id" text NOT NULL, + "workspace_id" text NOT NULL, + "type" text NOT NULL, + "status" text DEFAULT 'running' NOT NULL, + "payload" jsonb, + "rows_processed" integer DEFAULT 0 NOT NULL, + "error" text, + "started_at" timestamp DEFAULT now() NOT NULL, + "updated_at" timestamp DEFAULT now() NOT NULL, + "completed_at" timestamp +); +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "table_jobs" ADD CONSTRAINT "table_jobs_table_id_user_table_definitions_id_fk" FOREIGN KEY ("table_id") REFERENCES "public"."user_table_definitions"("id") ON DELETE cascade ON UPDATE no action; +EXCEPTION WHEN duplicate_object THEN null; +END $$;--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "table_jobs" ADD CONSTRAINT "table_jobs_workspace_id_workspace_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspace"("id") ON DELETE cascade ON UPDATE no action; +EXCEPTION WHEN duplicate_object THEN null; +END $$;--> statement-breakpoint +CREATE UNIQUE INDEX IF NOT EXISTS "table_jobs_one_active_per_table" ON "table_jobs" USING btree ("table_id") WHERE "table_jobs"."status" = 'running' AND "table_jobs"."type" <> 'export';--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "table_jobs_watchdog_idx" ON "table_jobs" USING btree ("status","updated_at");--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "table_jobs_table_started_idx" ON "table_jobs" USING btree ("table_id","started_at");--> statement-breakpoint +-- Migrate any existing import-job state off the definition columns into table_jobs. Each +-- definition has at most one import_status, so this yields at most one job per table and never +-- violates the partial-unique active-job index. The old in-flight literal 'importing' maps to +-- 'running'. NOTE (expand/contract): the import_* columns are NOT dropped here — the previous +-- app version still reads/writes them while this migration applies from CI. A later release +-- drops them once no deployed version references them. +INSERT INTO "table_jobs" ("id", "table_id", "workspace_id", "type", "status", "rows_processed", "error", "started_at", "updated_at", "completed_at") +SELECT + COALESCE("import_id", 'job_' || "id"), + "id", + "workspace_id", + 'import', + CASE WHEN "import_status" = 'importing' THEN 'running' ELSE "import_status" END, + COALESCE("import_rows_processed", 0), + "import_error", + COALESCE("import_started_at", now()), + now(), + CASE WHEN "import_status" IN ('ready', 'failed', 'canceled') THEN now() ELSE NULL END +FROM "user_table_definitions" +WHERE "import_status" IS NOT NULL +ON CONFLICT ("id") DO NOTHING;--> statement-breakpoint +-- All tenants' rows share this one relation, so the default autovacuum trigger (~20% of the whole +-- relation dead) lets a single tenant's mass delete leave their reads degraded for days. Vacuum at +-- ~2% churn instead; runs are frequent but cheap (the visibility map skips untouched pages). +ALTER TABLE "user_table_rows" SET (autovacuum_vacuum_scale_factor = 0.02, autovacuum_analyze_scale_factor = 0.01);--> statement-breakpoint +CREATE EXTENSION IF NOT EXISTS btree_gin;--> statement-breakpoint +-- user_table_rows is the write-hot shared relation: build its indexes CONCURRENTLY (runner +-- convention — plain CREATE INDEX write-blocks the whole relation for the build). +COMMIT;--> statement-breakpoint +SET lock_timeout = 0;--> statement-breakpoint +-- Keyset paging by id within one table (delete-job worker). Without it the planner walks the +-- global pkey in id order, discarding every other table's rows — O(all rows) per page. +CREATE INDEX CONCURRENTLY IF NOT EXISTS "user_table_rows_table_id_id_idx" ON "user_table_rows" USING btree ("table_id","id");--> statement-breakpoint +-- Tenant-scoped containment index: a plain GIN on data matches @> candidates across every tenant +-- sharing this relation (measured 1.07M candidates fetched for a 33k-row match). btree_gin lets +-- table_id lead the GIN so the intersection happens inside the index, and jsonb_path_ops indexes +-- whole key->value paths (single lookup, smaller index). Every @> query carries table_id, so the +-- old cross-tenant index is strictly redundant once this exists. +CREATE INDEX CONCURRENTLY IF NOT EXISTS "user_table_rows_tenant_data_gin_idx" ON "user_table_rows" USING gin ("table_id","data" jsonb_path_ops);--> statement-breakpoint +DROP INDEX CONCURRENTLY IF EXISTS "user_table_rows_data_gin_idx";--> statement-breakpoint +SET lock_timeout = '5s'; diff --git a/packages/db/migrations/meta/0233_snapshot.json b/packages/db/migrations/meta/0233_snapshot.json new file mode 100644 index 00000000000..d8a92810ac5 --- /dev/null +++ b/packages/db/migrations/meta/0233_snapshot.json @@ -0,0 +1,16429 @@ +{ + "id": "4fa1cade-ac70-4e8e-9f1c-e3ce66ffad36", + "prevId": "0c915827-34b3-4b7c-8e78-95d2ef1434a2", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.a2a_agent": { + "name": "a2a_agent", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'1.0.0'" + }, + "capabilities": { + "name": "capabilities", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "skills": { + "name": "skills", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'" + }, + "authentication": { + "name": "authentication", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "signatures": { + "name": "signatures", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'" + }, + "is_published": { + "name": "is_published", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "a2a_agent_workflow_id_idx": { + "name": "a2a_agent_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_agent_created_by_idx": { + "name": "a2a_agent_created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_agent_workspace_workflow_unique": { + "name": "a2a_agent_workspace_workflow_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"a2a_agent\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_agent_archived_at_idx": { + "name": "a2a_agent_archived_at_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_agent_workspace_archived_partial_idx": { + "name": "a2a_agent_workspace_archived_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"a2a_agent\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "a2a_agent_workspace_id_workspace_id_fk": { + "name": "a2a_agent_workspace_id_workspace_id_fk", + "tableFrom": "a2a_agent", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "a2a_agent_workflow_id_workflow_id_fk": { + "name": "a2a_agent_workflow_id_workflow_id_fk", + "tableFrom": "a2a_agent", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "a2a_agent_created_by_user_id_fk": { + "name": "a2a_agent_created_by_user_id_fk", + "tableFrom": "a2a_agent", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.a2a_push_notification_config": { + "name": "a2a_push_notification_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auth_schemes": { + "name": "auth_schemes", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'" + }, + "auth_credentials": { + "name": "auth_credentials", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "a2a_push_notification_config_task_unique": { + "name": "a2a_push_notification_config_task_unique", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "a2a_push_notification_config_task_id_a2a_task_id_fk": { + "name": "a2a_push_notification_config_task_id_a2a_task_id_fk", + "tableFrom": "a2a_push_notification_config", + "tableTo": "a2a_task", + "columnsFrom": ["task_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.a2a_task": { + "name": "a2a_task", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "a2a_task_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'submitted'" + }, + "messages": { + "name": "messages", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'" + }, + "artifacts": { + "name": "artifacts", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'" + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "a2a_task_agent_id_idx": { + "name": "a2a_task_agent_id_idx", + "columns": [ + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_task_session_id_idx": { + "name": "a2a_task_session_id_idx", + "columns": [ + { + "expression": "session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_task_status_idx": { + "name": "a2a_task_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_task_execution_id_idx": { + "name": "a2a_task_execution_id_idx", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_task_created_at_idx": { + "name": "a2a_task_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "a2a_task_agent_id_a2a_agent_id_fk": { + "name": "a2a_task_agent_id_a2a_agent_id_fk", + "tableFrom": "a2a_task", + "tableTo": "a2a_agent", + "columnsFrom": ["agent_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.academy_certificate": { + "name": "academy_certificate", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "course_id": { + "name": "course_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "academy_cert_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "certificate_number": { + "name": "certificate_number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "academy_certificate_user_id_idx": { + "name": "academy_certificate_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "academy_certificate_course_id_idx": { + "name": "academy_certificate_course_id_idx", + "columns": [ + { + "expression": "course_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "academy_certificate_user_course_unique": { + "name": "academy_certificate_user_course_unique", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "course_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "academy_certificate_number_idx": { + "name": "academy_certificate_number_idx", + "columns": [ + { + "expression": "certificate_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "academy_certificate_status_idx": { + "name": "academy_certificate_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "academy_certificate_user_id_user_id_fk": { + "name": "academy_certificate_user_id_user_id_fk", + "tableFrom": "academy_certificate", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "academy_certificate_certificate_number_unique": { + "name": "academy_certificate_certificate_number_unique", + "nullsNotDistinct": false, + "columns": ["certificate_number"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "account_user_id_idx": { + "name": "account_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_account_on_account_id_provider_id": { + "name": "idx_account_on_account_id_provider_id", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.api_key": { + "name": "api_key", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key_hash": { + "name": "key_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'personal'" + }, + "last_used": { + "name": "last_used", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "api_key_workspace_type_idx": { + "name": "api_key_workspace_type_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "api_key_user_type_idx": { + "name": "api_key_user_type_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "api_key_key_hash_idx": { + "name": "api_key_key_hash_idx", + "columns": [ + { + "expression": "key_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "api_key_user_id_user_id_fk": { + "name": "api_key_user_id_user_id_fk", + "tableFrom": "api_key", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_key_workspace_id_workspace_id_fk": { + "name": "api_key_workspace_id_workspace_id_fk", + "tableFrom": "api_key", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_key_created_by_user_id_fk": { + "name": "api_key_created_by_user_id_fk", + "tableFrom": "api_key", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "api_key_key_unique": { + "name": "api_key_key_unique", + "nullsNotDistinct": false, + "columns": ["key"] + } + }, + "policies": {}, + "checkConstraints": { + "workspace_type_check": { + "name": "workspace_type_check", + "value": "(type = 'workspace' AND workspace_id IS NOT NULL) OR (type = 'personal' AND workspace_id IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.async_jobs": { + "name": "async_jobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "run_at": { + "name": "run_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "max_attempts": { + "name": "max_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 3 + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "output": { + "name": "output", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "async_jobs_status_started_at_idx": { + "name": "async_jobs_status_started_at_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "async_jobs_status_completed_at_idx": { + "name": "async_jobs_status_completed_at_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "completed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "async_jobs_schedule_pending_run_at_idx": { + "name": "async_jobs_schedule_pending_run_at_idx", + "columns": [ + { + "expression": "run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"async_jobs\".\"type\" = 'schedule-execution' AND \"async_jobs\".\"status\" = 'pending'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "async_jobs_schedule_processing_started_at_idx": { + "name": "async_jobs_schedule_processing_started_at_idx", + "columns": [ + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"async_jobs\".\"type\" = 'schedule-execution' AND \"async_jobs\".\"status\" = 'processing'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_log": { + "name": "audit_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resource_type": { + "name": "resource_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resource_id": { + "name": "resource_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_name": { + "name": "actor_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_email": { + "name": "actor_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resource_name": { + "name": "resource_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "audit_log_workspace_created_idx": { + "name": "audit_log_workspace_created_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "audit_log_workspace_created_at_id_idx": { + "name": "audit_log_workspace_created_at_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date_trunc('milliseconds', \"created_at\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "audit_log_actor_created_idx": { + "name": "audit_log_actor_created_idx", + "columns": [ + { + "expression": "actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "audit_log_resource_idx": { + "name": "audit_log_resource_idx", + "columns": [ + { + "expression": "resource_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "resource_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "audit_log_action_idx": { + "name": "audit_log_action_idx", + "columns": [ + { + "expression": "action", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "audit_log_workspace_id_workspace_id_fk": { + "name": "audit_log_workspace_id_workspace_id_fk", + "tableFrom": "audit_log", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "audit_log_actor_id_user_id_fk": { + "name": "audit_log_actor_id_user_id_fk", + "tableFrom": "audit_log", + "tableTo": "user", + "columnsFrom": ["actor_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chat": { + "name": "chat", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "customizations": { + "name": "customizations", + "type": "json", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "auth_type": { + "name": "auth_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'public'" + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "allowed_emails": { + "name": "allowed_emails", + "type": "json", + "primaryKey": false, + "notNull": false, + "default": "'[]'" + }, + "output_configs": { + "name": "output_configs", + "type": "json", + "primaryKey": false, + "notNull": false, + "default": "'[]'" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "identifier_idx": { + "name": "identifier_idx", + "columns": [ + { + "expression": "identifier", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"chat\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "chat_archived_at_partial_idx": { + "name": "chat_archived_at_partial_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"chat\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_chat_on_workflow_id_archived_at": { + "name": "idx_chat_on_workflow_id_archived_at", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chat_workflow_id_workflow_id_fk": { + "name": "chat_workflow_id_workflow_id_fk", + "tableFrom": "chat", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chat_user_id_user_id_fk": { + "name": "chat_user_id_user_id_fk", + "tableFrom": "chat", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_async_tool_calls": { + "name": "copilot_async_tool_calls", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "checkpoint_id": { + "name": "checkpoint_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "tool_call_id": { + "name": "tool_call_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool_name": { + "name": "tool_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "args": { + "name": "args", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "status": { + "name": "status", + "type": "copilot_async_tool_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "result": { + "name": "result", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copilot_async_tool_calls_run_id_idx": { + "name": "copilot_async_tool_calls_run_id_idx", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_async_tool_calls_checkpoint_id_idx": { + "name": "copilot_async_tool_calls_checkpoint_id_idx", + "columns": [ + { + "expression": "checkpoint_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_async_tool_calls_tool_call_id_idx": { + "name": "copilot_async_tool_calls_tool_call_id_idx", + "columns": [ + { + "expression": "tool_call_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_async_tool_calls_status_idx": { + "name": "copilot_async_tool_calls_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_async_tool_calls_run_status_idx": { + "name": "copilot_async_tool_calls_run_status_idx", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_async_tool_calls_tool_call_id_unique": { + "name": "copilot_async_tool_calls_tool_call_id_unique", + "columns": [ + { + "expression": "tool_call_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_async_tool_calls_run_id_copilot_runs_id_fk": { + "name": "copilot_async_tool_calls_run_id_copilot_runs_id_fk", + "tableFrom": "copilot_async_tool_calls", + "tableTo": "copilot_runs", + "columnsFrom": ["run_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_async_tool_calls_checkpoint_id_copilot_run_checkpoints_id_fk": { + "name": "copilot_async_tool_calls_checkpoint_id_copilot_run_checkpoints_id_fk", + "tableFrom": "copilot_async_tool_calls", + "tableTo": "copilot_run_checkpoints", + "columnsFrom": ["checkpoint_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_chats": { + "name": "copilot_chats", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "chat_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'copilot'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'claude-3-7-sonnet-latest'" + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "preview_yaml": { + "name": "preview_yaml", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plan_artifact": { + "name": "plan_artifact", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "resources": { + "name": "resources", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "pinned": { + "name": "pinned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copilot_chats_user_id_idx": { + "name": "copilot_chats_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_chats_workflow_id_idx": { + "name": "copilot_chats_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_chats_user_workflow_idx": { + "name": "copilot_chats_user_workflow_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_chats_user_workspace_idx": { + "name": "copilot_chats_user_workspace_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_chats_created_at_idx": { + "name": "copilot_chats_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_chats_updated_at_idx": { + "name": "copilot_chats_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_chats_workspace_created_at_id_idx": { + "name": "copilot_chats_workspace_created_at_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date_trunc('milliseconds', \"created_at\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_chats_user_id_user_id_fk": { + "name": "copilot_chats_user_id_user_id_fk", + "tableFrom": "copilot_chats", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_chats_workflow_id_workflow_id_fk": { + "name": "copilot_chats_workflow_id_workflow_id_fk", + "tableFrom": "copilot_chats", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_chats_workspace_id_workspace_id_fk": { + "name": "copilot_chats_workspace_id_workspace_id_fk", + "tableFrom": "copilot_chats", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_feedback": { + "name": "copilot_feedback", + "schema": "", + "columns": { + "feedback_id": { + "name": "feedback_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_query": { + "name": "user_query", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_response": { + "name": "agent_response", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "is_positive": { + "name": "is_positive", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "feedback": { + "name": "feedback", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workflow_yaml": { + "name": "workflow_yaml", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copilot_feedback_user_id_idx": { + "name": "copilot_feedback_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_feedback_chat_id_idx": { + "name": "copilot_feedback_chat_id_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_feedback_user_chat_idx": { + "name": "copilot_feedback_user_chat_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_feedback_is_positive_idx": { + "name": "copilot_feedback_is_positive_idx", + "columns": [ + { + "expression": "is_positive", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_feedback_created_at_idx": { + "name": "copilot_feedback_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_feedback_user_id_user_id_fk": { + "name": "copilot_feedback_user_id_user_id_fk", + "tableFrom": "copilot_feedback", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_feedback_chat_id_copilot_chats_id_fk": { + "name": "copilot_feedback_chat_id_copilot_chats_id_fk", + "tableFrom": "copilot_feedback", + "tableTo": "copilot_chats", + "columnsFrom": ["chat_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_messages": { + "name": "copilot_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "stream_id": { + "name": "stream_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "parent_message_id": { + "name": "parent_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tokens_in": { + "name": "tokens_in", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "tokens_out": { + "name": "tokens_out", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "seq": { + "name": "seq", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copilot_messages_chat_message_unique": { + "name": "copilot_messages_chat_message_unique", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_messages_chat_created_at_idx": { + "name": "copilot_messages_chat_created_at_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"copilot_messages\".\"deleted_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_messages_chat_seq_idx": { + "name": "copilot_messages_chat_seq_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "seq", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"copilot_messages\".\"deleted_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_messages_chat_stream_idx": { + "name": "copilot_messages_chat_stream_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "stream_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"copilot_messages\".\"stream_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_messages_chat_id_copilot_chats_id_fk": { + "name": "copilot_messages_chat_id_copilot_chats_id_fk", + "tableFrom": "copilot_messages", + "tableTo": "copilot_chats", + "columnsFrom": ["chat_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_run_checkpoints": { + "name": "copilot_run_checkpoints", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "pending_tool_call_id": { + "name": "pending_tool_call_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "conversation_snapshot": { + "name": "conversation_snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "agent_state": { + "name": "agent_state", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "provider_request": { + "name": "provider_request", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copilot_run_checkpoints_run_id_idx": { + "name": "copilot_run_checkpoints_run_id_idx", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_run_checkpoints_pending_tool_call_id_idx": { + "name": "copilot_run_checkpoints_pending_tool_call_id_idx", + "columns": [ + { + "expression": "pending_tool_call_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_run_checkpoints_run_pending_tool_unique": { + "name": "copilot_run_checkpoints_run_pending_tool_unique", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "pending_tool_call_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_run_checkpoints_run_id_copilot_runs_id_fk": { + "name": "copilot_run_checkpoints_run_id_copilot_runs_id_fk", + "tableFrom": "copilot_run_checkpoints", + "tableTo": "copilot_runs", + "columnsFrom": ["run_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_runs": { + "name": "copilot_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_run_id": { + "name": "parent_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stream_id": { + "name": "stream_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent": { + "name": "agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "copilot_run_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "request_context": { + "name": "request_context", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "copilot_runs_execution_id_idx": { + "name": "copilot_runs_execution_id_idx", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_parent_run_id_idx": { + "name": "copilot_runs_parent_run_id_idx", + "columns": [ + { + "expression": "parent_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_chat_id_idx": { + "name": "copilot_runs_chat_id_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_user_id_idx": { + "name": "copilot_runs_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_workflow_id_idx": { + "name": "copilot_runs_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_workspace_id_idx": { + "name": "copilot_runs_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_status_idx": { + "name": "copilot_runs_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_chat_execution_idx": { + "name": "copilot_runs_chat_execution_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_execution_started_at_idx": { + "name": "copilot_runs_execution_started_at_idx", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_workspace_completed_at_id_idx": { + "name": "copilot_runs_workspace_completed_at_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date_trunc('milliseconds', \"completed_at\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_stream_id_unique": { + "name": "copilot_runs_stream_id_unique", + "columns": [ + { + "expression": "stream_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_runs_chat_id_copilot_chats_id_fk": { + "name": "copilot_runs_chat_id_copilot_chats_id_fk", + "tableFrom": "copilot_runs", + "tableTo": "copilot_chats", + "columnsFrom": ["chat_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_runs_user_id_user_id_fk": { + "name": "copilot_runs_user_id_user_id_fk", + "tableFrom": "copilot_runs", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_runs_workflow_id_workflow_id_fk": { + "name": "copilot_runs_workflow_id_workflow_id_fk", + "tableFrom": "copilot_runs", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_runs_workspace_id_workspace_id_fk": { + "name": "copilot_runs_workspace_id_workspace_id_fk", + "tableFrom": "copilot_runs", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_workflow_read_hashes": { + "name": "copilot_workflow_read_hashes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "hash": { + "name": "hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copilot_workflow_read_hashes_chat_id_idx": { + "name": "copilot_workflow_read_hashes_chat_id_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_workflow_read_hashes_workflow_id_idx": { + "name": "copilot_workflow_read_hashes_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_workflow_read_hashes_chat_workflow_unique": { + "name": "copilot_workflow_read_hashes_chat_workflow_unique", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_workflow_read_hashes_chat_id_copilot_chats_id_fk": { + "name": "copilot_workflow_read_hashes_chat_id_copilot_chats_id_fk", + "tableFrom": "copilot_workflow_read_hashes", + "tableTo": "copilot_chats", + "columnsFrom": ["chat_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_workflow_read_hashes_workflow_id_workflow_id_fk": { + "name": "copilot_workflow_read_hashes_workflow_id_workflow_id_fk", + "tableFrom": "copilot_workflow_read_hashes", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credential": { + "name": "credential", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "credential_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "env_key": { + "name": "env_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "env_owner_user_id": { + "name": "env_owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "encrypted_service_account_key": { + "name": "encrypted_service_account_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credential_workspace_id_idx": { + "name": "credential_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_type_idx": { + "name": "credential_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_provider_id_idx": { + "name": "credential_provider_id_idx", + "columns": [ + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_account_id_idx": { + "name": "credential_account_id_idx", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_env_owner_user_id_idx": { + "name": "credential_env_owner_user_id_idx", + "columns": [ + { + "expression": "env_owner_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_workspace_account_unique": { + "name": "credential_workspace_account_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "account_id IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_workspace_env_unique": { + "name": "credential_workspace_env_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "env_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "type = 'env_workspace'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_workspace_personal_env_unique": { + "name": "credential_workspace_personal_env_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "env_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "env_owner_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "type = 'env_personal'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credential_workspace_id_workspace_id_fk": { + "name": "credential_workspace_id_workspace_id_fk", + "tableFrom": "credential", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_account_id_account_id_fk": { + "name": "credential_account_id_account_id_fk", + "tableFrom": "credential", + "tableTo": "account", + "columnsFrom": ["account_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_env_owner_user_id_user_id_fk": { + "name": "credential_env_owner_user_id_user_id_fk", + "tableFrom": "credential", + "tableTo": "user", + "columnsFrom": ["env_owner_user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_created_by_user_id_fk": { + "name": "credential_created_by_user_id_fk", + "tableFrom": "credential", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credential_oauth_source_check": { + "name": "credential_oauth_source_check", + "value": "(type <> 'oauth') OR (account_id IS NOT NULL AND provider_id IS NOT NULL)" + }, + "credential_workspace_env_source_check": { + "name": "credential_workspace_env_source_check", + "value": "(type <> 'env_workspace') OR (env_key IS NOT NULL AND env_owner_user_id IS NULL)" + }, + "credential_personal_env_source_check": { + "name": "credential_personal_env_source_check", + "value": "(type <> 'env_personal') OR (env_key IS NOT NULL AND env_owner_user_id IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.credential_member": { + "name": "credential_member", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "credential_id": { + "name": "credential_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "credential_member_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "status": { + "name": "status", + "type": "credential_member_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "joined_at": { + "name": "joined_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credential_member_user_id_idx": { + "name": "credential_member_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_member_role_idx": { + "name": "credential_member_role_idx", + "columns": [ + { + "expression": "role", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_member_status_idx": { + "name": "credential_member_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_member_unique": { + "name": "credential_member_unique", + "columns": [ + { + "expression": "credential_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credential_member_credential_id_credential_id_fk": { + "name": "credential_member_credential_id_credential_id_fk", + "tableFrom": "credential_member", + "tableTo": "credential", + "columnsFrom": ["credential_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_member_user_id_user_id_fk": { + "name": "credential_member_user_id_user_id_fk", + "tableFrom": "credential_member", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_member_invited_by_user_id_fk": { + "name": "credential_member_invited_by_user_id_fk", + "tableFrom": "credential_member", + "tableTo": "user", + "columnsFrom": ["invited_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credential_set": { + "name": "credential_set", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credential_set_created_by_idx": { + "name": "credential_set_created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_set_org_name_unique": { + "name": "credential_set_org_name_unique", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_set_provider_id_idx": { + "name": "credential_set_provider_id_idx", + "columns": [ + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credential_set_organization_id_organization_id_fk": { + "name": "credential_set_organization_id_organization_id_fk", + "tableFrom": "credential_set", + "tableTo": "organization", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_set_created_by_user_id_fk": { + "name": "credential_set_created_by_user_id_fk", + "tableFrom": "credential_set", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credential_set_invitation": { + "name": "credential_set_invitation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "credential_set_id": { + "name": "credential_set_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "credential_set_invitation_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "accepted_at": { + "name": "accepted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "accepted_by_user_id": { + "name": "accepted_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credential_set_invitation_set_id_idx": { + "name": "credential_set_invitation_set_id_idx", + "columns": [ + { + "expression": "credential_set_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_set_invitation_token_idx": { + "name": "credential_set_invitation_token_idx", + "columns": [ + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_set_invitation_status_idx": { + "name": "credential_set_invitation_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_set_invitation_expires_at_idx": { + "name": "credential_set_invitation_expires_at_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credential_set_invitation_credential_set_id_credential_set_id_fk": { + "name": "credential_set_invitation_credential_set_id_credential_set_id_fk", + "tableFrom": "credential_set_invitation", + "tableTo": "credential_set", + "columnsFrom": ["credential_set_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_set_invitation_invited_by_user_id_fk": { + "name": "credential_set_invitation_invited_by_user_id_fk", + "tableFrom": "credential_set_invitation", + "tableTo": "user", + "columnsFrom": ["invited_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_set_invitation_accepted_by_user_id_user_id_fk": { + "name": "credential_set_invitation_accepted_by_user_id_user_id_fk", + "tableFrom": "credential_set_invitation", + "tableTo": "user", + "columnsFrom": ["accepted_by_user_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "credential_set_invitation_token_unique": { + "name": "credential_set_invitation_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credential_set_member": { + "name": "credential_set_member", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "credential_set_id": { + "name": "credential_set_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "credential_set_member_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "joined_at": { + "name": "joined_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credential_set_member_user_id_idx": { + "name": "credential_set_member_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_set_member_unique": { + "name": "credential_set_member_unique", + "columns": [ + { + "expression": "credential_set_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_set_member_status_idx": { + "name": "credential_set_member_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credential_set_member_credential_set_id_credential_set_id_fk": { + "name": "credential_set_member_credential_set_id_credential_set_id_fk", + "tableFrom": "credential_set_member", + "tableTo": "credential_set", + "columnsFrom": ["credential_set_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_set_member_user_id_user_id_fk": { + "name": "credential_set_member_user_id_user_id_fk", + "tableFrom": "credential_set_member", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_set_member_invited_by_user_id_fk": { + "name": "credential_set_member_invited_by_user_id_fk", + "tableFrom": "credential_set_member", + "tableTo": "user", + "columnsFrom": ["invited_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.custom_tools": { + "name": "custom_tools", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "schema": { + "name": "schema", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "custom_tools_workspace_id_idx": { + "name": "custom_tools_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "custom_tools_workspace_title_unique": { + "name": "custom_tools_workspace_title_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "title", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "custom_tools_workspace_id_workspace_id_fk": { + "name": "custom_tools_workspace_id_workspace_id_fk", + "tableFrom": "custom_tools", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "custom_tools_user_id_user_id_fk": { + "name": "custom_tools_user_id_user_id_fk", + "tableFrom": "custom_tools", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.data_drain_runs": { + "name": "data_drain_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "drain_id": { + "name": "drain_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "data_drain_run_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "data_drain_run_trigger", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "rows_exported": { + "name": "rows_exported", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "bytes_written": { + "name": "bytes_written", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cursor_before": { + "name": "cursor_before", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cursor_after": { + "name": "cursor_after", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "locators": { + "name": "locators", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + } + }, + "indexes": { + "data_drain_runs_drain_started_idx": { + "name": "data_drain_runs_drain_started_idx", + "columns": [ + { + "expression": "drain_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "data_drain_runs_drain_id_data_drains_id_fk": { + "name": "data_drain_runs_drain_id_data_drains_id_fk", + "tableFrom": "data_drain_runs", + "tableTo": "data_drains", + "columnsFrom": ["drain_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.data_drains": { + "name": "data_drains", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "data_drain_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "destination_type": { + "name": "destination_type", + "type": "data_drain_destination", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "destination_config": { + "name": "destination_config", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "destination_credentials": { + "name": "destination_credentials", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "schedule_cadence": { + "name": "schedule_cadence", + "type": "data_drain_cadence", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "cursor": { + "name": "cursor", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_run_at": { + "name": "last_run_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_success_at": { + "name": "last_success_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "data_drains_org_idx": { + "name": "data_drains_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "data_drains_due_idx": { + "name": "data_drains_due_idx", + "columns": [ + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "data_drains_org_name_unique": { + "name": "data_drains_org_name_unique", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "data_drains_organization_id_organization_id_fk": { + "name": "data_drains_organization_id_organization_id_fk", + "tableFrom": "data_drains", + "tableTo": "organization", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "data_drains_created_by_user_id_fk": { + "name": "data_drains_created_by_user_id_fk", + "tableFrom": "data_drains", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.docs_embeddings": { + "name": "docs_embeddings", + "schema": "", + "columns": { + "chunk_id": { + "name": "chunk_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "chunk_text": { + "name": "chunk_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_document": { + "name": "source_document", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_link": { + "name": "source_link", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "header_text": { + "name": "header_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "header_level": { + "name": "header_level", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token_count": { + "name": "token_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "embedding": { + "name": "embedding", + "type": "vector(1536)", + "primaryKey": false, + "notNull": true + }, + "embedding_model": { + "name": "embedding_model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'text-embedding-3-small'" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "chunk_text_tsv": { + "name": "chunk_text_tsv", + "type": "tsvector", + "primaryKey": false, + "notNull": false, + "generated": { + "as": "to_tsvector('english', \"docs_embeddings\".\"chunk_text\")", + "type": "stored" + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "docs_emb_source_document_idx": { + "name": "docs_emb_source_document_idx", + "columns": [ + { + "expression": "source_document", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "docs_emb_header_level_idx": { + "name": "docs_emb_header_level_idx", + "columns": [ + { + "expression": "header_level", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "docs_emb_source_header_idx": { + "name": "docs_emb_source_header_idx", + "columns": [ + { + "expression": "source_document", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "header_level", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "docs_emb_model_idx": { + "name": "docs_emb_model_idx", + "columns": [ + { + "expression": "embedding_model", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "docs_emb_created_at_idx": { + "name": "docs_emb_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "docs_embedding_vector_hnsw_idx": { + "name": "docs_embedding_vector_hnsw_idx", + "columns": [ + { + "expression": "embedding", + "isExpression": false, + "asc": true, + "nulls": "last", + "opclass": "vector_cosine_ops" + } + ], + "isUnique": false, + "concurrently": false, + "method": "hnsw", + "with": { + "m": 16, + "ef_construction": 64 + } + }, + "docs_emb_metadata_gin_idx": { + "name": "docs_emb_metadata_gin_idx", + "columns": [ + { + "expression": "metadata", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + }, + "docs_emb_chunk_text_fts_idx": { + "name": "docs_emb_chunk_text_fts_idx", + "columns": [ + { + "expression": "chunk_text_tsv", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "docs_embedding_not_null_check": { + "name": "docs_embedding_not_null_check", + "value": "\"embedding\" IS NOT NULL" + }, + "docs_header_level_check": { + "name": "docs_header_level_check", + "value": "\"header_level\" >= 1 AND \"header_level\" <= 6" + } + }, + "isRLSEnabled": false + }, + "public.document": { + "name": "document", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "knowledge_base_id": { + "name": "knowledge_base_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_url": { + "name": "file_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_size": { + "name": "file_size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chunk_count": { + "name": "chunk_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "token_count": { + "name": "token_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "character_count": { + "name": "character_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "processing_status": { + "name": "processing_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "processing_started_at": { + "name": "processing_started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "processing_completed_at": { + "name": "processing_completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "processing_error": { + "name": "processing_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "user_excluded": { + "name": "user_excluded", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "tag1": { + "name": "tag1", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag2": { + "name": "tag2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag3": { + "name": "tag3", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag4": { + "name": "tag4", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag5": { + "name": "tag5", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag6": { + "name": "tag6", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag7": { + "name": "tag7", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "number1": { + "name": "number1", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number2": { + "name": "number2", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number3": { + "name": "number3", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number4": { + "name": "number4", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number5": { + "name": "number5", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "date1": { + "name": "date1", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "date2": { + "name": "date2", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "boolean1": { + "name": "boolean1", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "boolean2": { + "name": "boolean2", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "boolean3": { + "name": "boolean3", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "connector_id": { + "name": "connector_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content_hash": { + "name": "content_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_url": { + "name": "source_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "uploaded_at": { + "name": "uploaded_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "doc_kb_id_idx": { + "name": "doc_kb_id_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_filename_idx": { + "name": "doc_filename_idx", + "columns": [ + { + "expression": "filename", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_processing_status_idx": { + "name": "doc_processing_status_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "processing_status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_connector_external_id_idx": { + "name": "doc_connector_external_id_idx", + "columns": [ + { + "expression": "connector_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"document\".\"deleted_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_connector_id_idx": { + "name": "doc_connector_id_idx", + "columns": [ + { + "expression": "connector_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_storage_key_idx": { + "name": "doc_storage_key_idx", + "columns": [ + { + "expression": "storage_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"document\".\"storage_key\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_archived_at_partial_idx": { + "name": "doc_archived_at_partial_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"document\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_deleted_at_partial_idx": { + "name": "doc_deleted_at_partial_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"document\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_tag1_idx": { + "name": "doc_tag1_idx", + "columns": [ + { + "expression": "tag1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_tag2_idx": { + "name": "doc_tag2_idx", + "columns": [ + { + "expression": "tag2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_tag3_idx": { + "name": "doc_tag3_idx", + "columns": [ + { + "expression": "tag3", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_tag4_idx": { + "name": "doc_tag4_idx", + "columns": [ + { + "expression": "tag4", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_tag5_idx": { + "name": "doc_tag5_idx", + "columns": [ + { + "expression": "tag5", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_tag6_idx": { + "name": "doc_tag6_idx", + "columns": [ + { + "expression": "tag6", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_tag7_idx": { + "name": "doc_tag7_idx", + "columns": [ + { + "expression": "tag7", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_number1_idx": { + "name": "doc_number1_idx", + "columns": [ + { + "expression": "number1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_number2_idx": { + "name": "doc_number2_idx", + "columns": [ + { + "expression": "number2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_number3_idx": { + "name": "doc_number3_idx", + "columns": [ + { + "expression": "number3", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_number4_idx": { + "name": "doc_number4_idx", + "columns": [ + { + "expression": "number4", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_number5_idx": { + "name": "doc_number5_idx", + "columns": [ + { + "expression": "number5", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_date1_idx": { + "name": "doc_date1_idx", + "columns": [ + { + "expression": "date1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_date2_idx": { + "name": "doc_date2_idx", + "columns": [ + { + "expression": "date2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_boolean1_idx": { + "name": "doc_boolean1_idx", + "columns": [ + { + "expression": "boolean1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_boolean2_idx": { + "name": "doc_boolean2_idx", + "columns": [ + { + "expression": "boolean2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_boolean3_idx": { + "name": "doc_boolean3_idx", + "columns": [ + { + "expression": "boolean3", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "document_knowledge_base_id_knowledge_base_id_fk": { + "name": "document_knowledge_base_id_knowledge_base_id_fk", + "tableFrom": "document", + "tableTo": "knowledge_base", + "columnsFrom": ["knowledge_base_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "document_connector_id_knowledge_connector_id_fk": { + "name": "document_connector_id_knowledge_connector_id_fk", + "tableFrom": "document", + "tableTo": "knowledge_connector", + "columnsFrom": ["connector_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "document_uploaded_by_user_id_fk": { + "name": "document_uploaded_by_user_id_fk", + "tableFrom": "document", + "tableTo": "user", + "columnsFrom": ["uploaded_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.embedding": { + "name": "embedding", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "knowledge_base_id": { + "name": "knowledge_base_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "document_id": { + "name": "document_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chunk_index": { + "name": "chunk_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "chunk_hash": { + "name": "chunk_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content_length": { + "name": "content_length", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token_count": { + "name": "token_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "embedding": { + "name": "embedding", + "type": "vector(1536)", + "primaryKey": false, + "notNull": false + }, + "embedding_model": { + "name": "embedding_model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'text-embedding-3-small'" + }, + "start_offset": { + "name": "start_offset", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "end_offset": { + "name": "end_offset", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag1": { + "name": "tag1", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag2": { + "name": "tag2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag3": { + "name": "tag3", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag4": { + "name": "tag4", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag5": { + "name": "tag5", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag6": { + "name": "tag6", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag7": { + "name": "tag7", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "number1": { + "name": "number1", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number2": { + "name": "number2", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number3": { + "name": "number3", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number4": { + "name": "number4", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number5": { + "name": "number5", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "date1": { + "name": "date1", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "date2": { + "name": "date2", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "boolean1": { + "name": "boolean1", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "boolean2": { + "name": "boolean2", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "boolean3": { + "name": "boolean3", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "content_tsv": { + "name": "content_tsv", + "type": "tsvector", + "primaryKey": false, + "notNull": false, + "generated": { + "as": "to_tsvector('english', \"embedding\".\"content\")", + "type": "stored" + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "emb_kb_id_idx": { + "name": "emb_kb_id_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_doc_id_idx": { + "name": "emb_doc_id_idx", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_doc_chunk_idx": { + "name": "emb_doc_chunk_idx", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "chunk_index", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_kb_model_idx": { + "name": "emb_kb_model_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "embedding_model", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_kb_enabled_idx": { + "name": "emb_kb_enabled_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_doc_enabled_idx": { + "name": "emb_doc_enabled_idx", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "embedding_vector_hnsw_idx": { + "name": "embedding_vector_hnsw_idx", + "columns": [ + { + "expression": "embedding", + "isExpression": false, + "asc": true, + "nulls": "last", + "opclass": "vector_cosine_ops" + } + ], + "isUnique": false, + "concurrently": false, + "method": "hnsw", + "with": { + "m": 16, + "ef_construction": 64 + } + }, + "emb_tag1_idx": { + "name": "emb_tag1_idx", + "columns": [ + { + "expression": "tag1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_tag2_idx": { + "name": "emb_tag2_idx", + "columns": [ + { + "expression": "tag2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_tag3_idx": { + "name": "emb_tag3_idx", + "columns": [ + { + "expression": "tag3", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_tag4_idx": { + "name": "emb_tag4_idx", + "columns": [ + { + "expression": "tag4", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_tag5_idx": { + "name": "emb_tag5_idx", + "columns": [ + { + "expression": "tag5", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_tag6_idx": { + "name": "emb_tag6_idx", + "columns": [ + { + "expression": "tag6", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_tag7_idx": { + "name": "emb_tag7_idx", + "columns": [ + { + "expression": "tag7", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_number1_idx": { + "name": "emb_number1_idx", + "columns": [ + { + "expression": "number1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_number2_idx": { + "name": "emb_number2_idx", + "columns": [ + { + "expression": "number2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_number3_idx": { + "name": "emb_number3_idx", + "columns": [ + { + "expression": "number3", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_number4_idx": { + "name": "emb_number4_idx", + "columns": [ + { + "expression": "number4", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_number5_idx": { + "name": "emb_number5_idx", + "columns": [ + { + "expression": "number5", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_date1_idx": { + "name": "emb_date1_idx", + "columns": [ + { + "expression": "date1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_date2_idx": { + "name": "emb_date2_idx", + "columns": [ + { + "expression": "date2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_boolean1_idx": { + "name": "emb_boolean1_idx", + "columns": [ + { + "expression": "boolean1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_boolean2_idx": { + "name": "emb_boolean2_idx", + "columns": [ + { + "expression": "boolean2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_boolean3_idx": { + "name": "emb_boolean3_idx", + "columns": [ + { + "expression": "boolean3", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_content_fts_idx": { + "name": "emb_content_fts_idx", + "columns": [ + { + "expression": "content_tsv", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + } + }, + "foreignKeys": { + "embedding_knowledge_base_id_knowledge_base_id_fk": { + "name": "embedding_knowledge_base_id_knowledge_base_id_fk", + "tableFrom": "embedding", + "tableTo": "knowledge_base", + "columnsFrom": ["knowledge_base_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "embedding_document_id_document_id_fk": { + "name": "embedding_document_id_document_id_fk", + "tableFrom": "embedding", + "tableTo": "document", + "columnsFrom": ["document_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "embedding_not_null_check": { + "name": "embedding_not_null_check", + "value": "\"embedding\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.environment": { + "name": "environment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "variables": { + "name": "variables", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "environment_user_id_user_id_fk": { + "name": "environment_user_id_user_id_fk", + "tableFrom": "environment", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "environment_user_id_unique": { + "name": "environment_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.execution_large_value_dependencies": { + "name": "execution_large_value_dependencies", + "schema": "", + "columns": { + "parent_key": { + "name": "parent_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "child_key": { + "name": "child_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "execution_large_value_dependencies_workspace_parent_key_idx": { + "name": "execution_large_value_dependencies_workspace_parent_key_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "parent_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "execution_large_value_dependencies_workspace_child_key_idx": { + "name": "execution_large_value_dependencies_workspace_child_key_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "child_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "execution_large_value_dependencies_workspace_id_workspace_id_fk": { + "name": "execution_large_value_dependencies_workspace_id_workspace_id_fk", + "tableFrom": "execution_large_value_dependencies", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "execution_large_value_dependencies_parent_key_child_key_pk": { + "name": "execution_large_value_dependencies_parent_key_child_key_pk", + "columns": ["parent_key", "child_key"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.execution_large_value_references": { + "name": "execution_large_value_references", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "execution_large_value_reference_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "execution_large_value_references_workspace_execution_source_idx": { + "name": "execution_large_value_references_workspace_execution_source_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "execution_large_value_references_workspace_id_workspace_id_fk": { + "name": "execution_large_value_references_workspace_id_workspace_id_fk", + "tableFrom": "execution_large_value_references", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "execution_large_value_references_workflow_id_workflow_id_fk": { + "name": "execution_large_value_references_workflow_id_workflow_id_fk", + "tableFrom": "execution_large_value_references", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "execution_large_value_references_key_execution_id_source_pk": { + "name": "execution_large_value_references_key_execution_id_source_pk", + "columns": ["key", "execution_id", "source"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.execution_large_values": { + "name": "execution_large_values", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_execution_id": { + "name": "owner_execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "execution_large_values_owner_execution_id_idx": { + "name": "execution_large_values_owner_execution_id_idx", + "columns": [ + { + "expression": "owner_execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "execution_large_values_cleanup_idx": { + "name": "execution_large_values_cleanup_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"execution_large_values\".\"deleted_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "execution_large_values_tombstone_cleanup_idx": { + "name": "execution_large_values_tombstone_cleanup_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"execution_large_values\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "execution_large_values_workspace_id_workspace_id_fk": { + "name": "execution_large_values_workspace_id_workspace_id_fk", + "tableFrom": "execution_large_values", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "execution_large_values_workflow_id_workflow_id_fk": { + "name": "execution_large_values_workflow_id_workflow_id_fk", + "tableFrom": "execution_large_values", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.idempotency_key": { + "name": "idempotency_key", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "result": { + "name": "result", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idempotency_key_created_at_idx": { + "name": "idempotency_key_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invitation": { + "name": "invitation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "invitation_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'organization'" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "inviter_id": { + "name": "inviter_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "membership_intent": { + "name": "membership_intent", + "type": "invitation_membership_intent", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'internal'" + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "invitation_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "invitation_email_idx": { + "name": "invitation_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invitation_organization_id_idx": { + "name": "invitation_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invitation_status_idx": { + "name": "invitation_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invitation_pending_email_org_unique": { + "name": "invitation_pending_email_org_unique", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"invitation\".\"status\" = 'pending' AND \"invitation\".\"organization_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invitation_inviter_id_user_id_fk": { + "name": "invitation_inviter_id_user_id_fk", + "tableFrom": "invitation", + "tableTo": "user", + "columnsFrom": ["inviter_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invitation_organization_id_organization_id_fk": { + "name": "invitation_organization_id_organization_id_fk", + "tableFrom": "invitation", + "tableTo": "organization", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "invitation_token_unique": { + "name": "invitation_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invitation_workspace_grant": { + "name": "invitation_workspace_grant", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "invitation_id": { + "name": "invitation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "permission": { + "name": "permission", + "type": "permission_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "invitation_workspace_grant_unique": { + "name": "invitation_workspace_grant_unique", + "columns": [ + { + "expression": "invitation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invitation_workspace_grant_workspace_id_idx": { + "name": "invitation_workspace_grant_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invitation_workspace_grant_invitation_id_invitation_id_fk": { + "name": "invitation_workspace_grant_invitation_id_invitation_id_fk", + "tableFrom": "invitation_workspace_grant", + "tableTo": "invitation", + "columnsFrom": ["invitation_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invitation_workspace_grant_workspace_id_workspace_id_fk": { + "name": "invitation_workspace_grant_workspace_id_workspace_id_fk", + "tableFrom": "invitation_workspace_grant", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.job_execution_logs": { + "name": "job_execution_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "schedule_id": { + "name": "schedule_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'running'" + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "total_duration_ms": { + "name": "total_duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "execution_data": { + "name": "execution_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "cost": { + "name": "cost", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "job_execution_logs_schedule_id_idx": { + "name": "job_execution_logs_schedule_id_idx", + "columns": [ + { + "expression": "schedule_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "job_execution_logs_workspace_started_at_idx": { + "name": "job_execution_logs_workspace_started_at_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "job_execution_logs_workspace_ended_at_id_idx": { + "name": "job_execution_logs_workspace_ended_at_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date_trunc('milliseconds', \"ended_at\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "job_execution_logs_execution_id_unique": { + "name": "job_execution_logs_execution_id_unique", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "job_execution_logs_trigger_idx": { + "name": "job_execution_logs_trigger_idx", + "columns": [ + { + "expression": "trigger", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "job_execution_logs_schedule_id_workflow_schedule_id_fk": { + "name": "job_execution_logs_schedule_id_workflow_schedule_id_fk", + "tableFrom": "job_execution_logs", + "tableTo": "workflow_schedule", + "columnsFrom": ["schedule_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "job_execution_logs_workspace_id_workspace_id_fk": { + "name": "job_execution_logs_workspace_id_workspace_id_fk", + "tableFrom": "job_execution_logs", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.knowledge_base": { + "name": "knowledge_base", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token_count": { + "name": "token_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "embedding_model": { + "name": "embedding_model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'text-embedding-3-small'" + }, + "embedding_dimension": { + "name": "embedding_dimension", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1536 + }, + "chunking_config": { + "name": "chunking_config", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'{\"maxSize\": 1024, \"minSize\": 1, \"overlap\": 200}'" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "kb_user_id_idx": { + "name": "kb_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kb_workspace_id_idx": { + "name": "kb_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kb_user_workspace_idx": { + "name": "kb_user_workspace_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kb_deleted_at_idx": { + "name": "kb_deleted_at_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kb_workspace_deleted_partial_idx": { + "name": "kb_workspace_deleted_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"knowledge_base\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "kb_workspace_name_active_unique": { + "name": "kb_workspace_name_active_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"knowledge_base\".\"deleted_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "knowledge_base_user_id_user_id_fk": { + "name": "knowledge_base_user_id_user_id_fk", + "tableFrom": "knowledge_base", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "knowledge_base_workspace_id_workspace_id_fk": { + "name": "knowledge_base_workspace_id_workspace_id_fk", + "tableFrom": "knowledge_base", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.knowledge_base_tag_definitions": { + "name": "knowledge_base_tag_definitions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "knowledge_base_id": { + "name": "knowledge_base_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tag_slot": { + "name": "tag_slot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "field_type": { + "name": "field_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'text'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "kb_tag_definitions_kb_slot_idx": { + "name": "kb_tag_definitions_kb_slot_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "tag_slot", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kb_tag_definitions_kb_display_name_idx": { + "name": "kb_tag_definitions_kb_display_name_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "display_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kb_tag_definitions_kb_id_idx": { + "name": "kb_tag_definitions_kb_id_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "knowledge_base_tag_definitions_knowledge_base_id_knowledge_base_id_fk": { + "name": "knowledge_base_tag_definitions_knowledge_base_id_knowledge_base_id_fk", + "tableFrom": "knowledge_base_tag_definitions", + "tableTo": "knowledge_base", + "columnsFrom": ["knowledge_base_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.knowledge_connector": { + "name": "knowledge_connector", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "knowledge_base_id": { + "name": "knowledge_base_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "connector_type": { + "name": "connector_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "credential_id": { + "name": "credential_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "encrypted_api_key": { + "name": "encrypted_api_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_config": { + "name": "source_config", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "sync_mode": { + "name": "sync_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'full'" + }, + "sync_interval_minutes": { + "name": "sync_interval_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1440 + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "last_sync_at": { + "name": "last_sync_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_sync_error": { + "name": "last_sync_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_sync_doc_count": { + "name": "last_sync_doc_count", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "next_sync_at": { + "name": "next_sync_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "kc_knowledge_base_id_idx": { + "name": "kc_knowledge_base_id_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kc_status_next_sync_idx": { + "name": "kc_status_next_sync_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_sync_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kc_archived_at_partial_idx": { + "name": "kc_archived_at_partial_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"knowledge_connector\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "kc_deleted_at_partial_idx": { + "name": "kc_deleted_at_partial_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"knowledge_connector\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "knowledge_connector_knowledge_base_id_knowledge_base_id_fk": { + "name": "knowledge_connector_knowledge_base_id_knowledge_base_id_fk", + "tableFrom": "knowledge_connector", + "tableTo": "knowledge_base", + "columnsFrom": ["knowledge_base_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.knowledge_connector_sync_log": { + "name": "knowledge_connector_sync_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "connector_id": { + "name": "connector_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "docs_added": { + "name": "docs_added", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "docs_updated": { + "name": "docs_updated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "docs_deleted": { + "name": "docs_deleted", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "docs_unchanged": { + "name": "docs_unchanged", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "docs_failed": { + "name": "docs_failed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "kcsl_connector_id_idx": { + "name": "kcsl_connector_id_idx", + "columns": [ + { + "expression": "connector_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "knowledge_connector_sync_log_connector_id_knowledge_connector_id_fk": { + "name": "knowledge_connector_sync_log_connector_id_knowledge_connector_id_fk", + "tableFrom": "knowledge_connector_sync_log", + "tableTo": "knowledge_connector", + "columnsFrom": ["connector_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mcp_server_oauth": { + "name": "mcp_server_oauth", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mcp_server_id": { + "name": "mcp_server_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_information": { + "name": "client_information", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tokens": { + "name": "tokens", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code_verifier": { + "name": "code_verifier", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state_created_at": { + "name": "state_created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_refreshed_at": { + "name": "last_refreshed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mcp_server_oauth_server_unique": { + "name": "mcp_server_oauth_server_unique", + "columns": [ + { + "expression": "mcp_server_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mcp_server_oauth_state_idx": { + "name": "mcp_server_oauth_state_idx", + "columns": [ + { + "expression": "state", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mcp_server_oauth_mcp_server_id_mcp_servers_id_fk": { + "name": "mcp_server_oauth_mcp_server_id_mcp_servers_id_fk", + "tableFrom": "mcp_server_oauth", + "tableTo": "mcp_servers", + "columnsFrom": ["mcp_server_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mcp_server_oauth_user_id_user_id_fk": { + "name": "mcp_server_oauth_user_id_user_id_fk", + "tableFrom": "mcp_server_oauth", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mcp_server_oauth_workspace_id_workspace_id_fk": { + "name": "mcp_server_oauth_workspace_id_workspace_id_fk", + "tableFrom": "mcp_server_oauth", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mcp_servers": { + "name": "mcp_servers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "transport": { + "name": "transport", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auth_type": { + "name": "auth_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'headers'" + }, + "oauth_client_id": { + "name": "oauth_client_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "oauth_client_secret": { + "name": "oauth_client_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "headers": { + "name": "headers", + "type": "json", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "timeout": { + "name": "timeout", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 30000 + }, + "retries": { + "name": "retries", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 3 + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "last_connected": { + "name": "last_connected", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "connection_status": { + "name": "connection_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'disconnected'" + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status_config": { + "name": "status_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "tool_count": { + "name": "tool_count", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "last_tools_refresh": { + "name": "last_tools_refresh", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "total_requests": { + "name": "total_requests", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "last_used": { + "name": "last_used", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mcp_servers_workspace_enabled_idx": { + "name": "mcp_servers_workspace_enabled_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mcp_servers_workspace_deleted_partial_idx": { + "name": "mcp_servers_workspace_deleted_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"mcp_servers\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mcp_servers_workspace_id_workspace_id_fk": { + "name": "mcp_servers_workspace_id_workspace_id_fk", + "tableFrom": "mcp_servers", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mcp_servers_created_by_user_id_fk": { + "name": "mcp_servers_created_by_user_id_fk", + "tableFrom": "mcp_servers", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.member": { + "name": "member", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "member_user_id_unique": { + "name": "member_user_id_unique", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "member_organization_id_idx": { + "name": "member_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "member_user_id_user_id_fk": { + "name": "member_user_id_user_id_fk", + "tableFrom": "member", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "member_organization_id_organization_id_fk": { + "name": "member_organization_id_organization_id_fk", + "tableFrom": "member", + "tableTo": "organization", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory": { + "name": "memory", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "memory_key_idx": { + "name": "memory_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "memory_workspace_idx": { + "name": "memory_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "memory_workspace_key_idx": { + "name": "memory_workspace_key_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "memory_workspace_deleted_partial_idx": { + "name": "memory_workspace_deleted_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"memory\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "memory_workspace_id_workspace_id_fk": { + "name": "memory_workspace_id_workspace_id_fk", + "tableFrom": "memory", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mothership_inbox_allowed_sender": { + "name": "mothership_inbox_allowed_sender", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inbox_sender_ws_email_idx": { + "name": "inbox_sender_ws_email_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mothership_inbox_allowed_sender_workspace_id_workspace_id_fk": { + "name": "mothership_inbox_allowed_sender_workspace_id_workspace_id_fk", + "tableFrom": "mothership_inbox_allowed_sender", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mothership_inbox_allowed_sender_added_by_user_id_fk": { + "name": "mothership_inbox_allowed_sender_added_by_user_id_fk", + "tableFrom": "mothership_inbox_allowed_sender", + "tableTo": "user", + "columnsFrom": ["added_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mothership_inbox_task": { + "name": "mothership_inbox_task", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_email": { + "name": "from_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body_preview": { + "name": "body_preview", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "body_text": { + "name": "body_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "body_html": { + "name": "body_html", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email_message_id": { + "name": "email_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "in_reply_to": { + "name": "in_reply_to", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "response_message_id": { + "name": "response_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agentmail_message_id": { + "name": "agentmail_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'received'" + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "trigger_job_id": { + "name": "trigger_job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result_summary": { + "name": "result_summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rejection_reason": { + "name": "rejection_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "has_attachments": { + "name": "has_attachments", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cc_recipients": { + "name": "cc_recipients", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "processing_started_at": { + "name": "processing_started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "inbox_task_ws_created_at_idx": { + "name": "inbox_task_ws_created_at_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inbox_task_ws_status_idx": { + "name": "inbox_task_ws_status_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inbox_task_response_msg_id_idx": { + "name": "inbox_task_response_msg_id_idx", + "columns": [ + { + "expression": "response_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inbox_task_email_msg_id_idx": { + "name": "inbox_task_email_msg_id_idx", + "columns": [ + { + "expression": "email_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mothership_inbox_task_workspace_id_workspace_id_fk": { + "name": "mothership_inbox_task_workspace_id_workspace_id_fk", + "tableFrom": "mothership_inbox_task", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mothership_inbox_task_chat_id_copilot_chats_id_fk": { + "name": "mothership_inbox_task_chat_id_copilot_chats_id_fk", + "tableFrom": "mothership_inbox_task", + "tableTo": "copilot_chats", + "columnsFrom": ["chat_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mothership_inbox_webhook": { + "name": "mothership_inbox_webhook", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "webhook_id": { + "name": "webhook_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "mothership_inbox_webhook_workspace_id_workspace_id_fk": { + "name": "mothership_inbox_webhook_workspace_id_workspace_id_fk", + "tableFrom": "mothership_inbox_webhook", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "mothership_inbox_webhook_workspace_id_unique": { + "name": "mothership_inbox_webhook_workspace_id_unique", + "nullsNotDistinct": false, + "columns": ["workspace_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mothership_settings": { + "name": "mothership_settings", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mcp_tool_refs": { + "name": "mcp_tool_refs", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "custom_tool_refs": { + "name": "custom_tool_refs", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "skill_refs": { + "name": "skill_refs", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mothership_settings_workspace_id_idx": { + "name": "mothership_settings_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mothership_settings_workspace_id_workspace_id_fk": { + "name": "mothership_settings_workspace_id_workspace_id_fk", + "tableFrom": "mothership_settings", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization": { + "name": "organization", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "logo": { + "name": "logo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "whitelabel_settings": { + "name": "whitelabel_settings", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "data_retention_settings": { + "name": "data_retention_settings", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "org_usage_limit": { + "name": "org_usage_limit", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "storage_used_bytes": { + "name": "storage_used_bytes", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "departed_member_usage": { + "name": "departed_member_usage", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "credit_balance": { + "name": "credit_balance", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization_member_usage_limit": { + "name": "organization_member_usage_limit", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "usage_limit": { + "name": "usage_limit", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "set_by": { + "name": "set_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "org_member_usage_limit_org_user_unique": { + "name": "org_member_usage_limit_org_user_unique", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "org_member_usage_limit_organization_id_idx": { + "name": "org_member_usage_limit_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_member_usage_limit_organization_id_organization_id_fk": { + "name": "organization_member_usage_limit_organization_id_organization_id_fk", + "tableFrom": "organization_member_usage_limit", + "tableTo": "organization", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_member_usage_limit_user_id_user_id_fk": { + "name": "organization_member_usage_limit_user_id_user_id_fk", + "tableFrom": "organization_member_usage_limit", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_member_usage_limit_set_by_user_id_fk": { + "name": "organization_member_usage_limit_set_by_user_id_fk", + "tableFrom": "organization_member_usage_limit", + "tableTo": "user", + "columnsFrom": ["set_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.outbox_event": { + "name": "outbox_event", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "max_attempts": { + "name": "max_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 10 + }, + "available_at": { + "name": "available_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "locked_at": { + "name": "locked_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "processed_at": { + "name": "processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "outbox_event_status_available_idx": { + "name": "outbox_event_status_available_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "available_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "outbox_event_locked_at_idx": { + "name": "outbox_event_locked_at_idx", + "columns": [ + { + "expression": "locked_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.paused_executions": { + "name": "paused_executions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "execution_snapshot": { + "name": "execution_snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "pause_points": { + "name": "pause_points", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "total_pause_count": { + "name": "total_pause_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "resumed_count": { + "name": "resumed_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'paused'" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "paused_at": { + "name": "paused_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "next_resume_at": { + "name": "next_resume_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "paused_executions_workflow_id_idx": { + "name": "paused_executions_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "paused_executions_status_idx": { + "name": "paused_executions_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "paused_executions_execution_id_unique": { + "name": "paused_executions_execution_id_unique", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "paused_executions_next_resume_at_idx": { + "name": "paused_executions_next_resume_at_idx", + "columns": [ + { + "expression": "next_resume_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "status = 'paused' AND next_resume_at IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "paused_executions_workflow_id_workflow_id_fk": { + "name": "paused_executions_workflow_id_workflow_id_fk", + "tableFrom": "paused_executions", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.pending_credential_draft": { + "name": "pending_credential_draft", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "credential_id": { + "name": "credential_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pending_draft_user_provider_ws": { + "name": "pending_draft_user_provider_ws", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pending_credential_draft_user_id_user_id_fk": { + "name": "pending_credential_draft_user_id_user_id_fk", + "tableFrom": "pending_credential_draft", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pending_credential_draft_workspace_id_workspace_id_fk": { + "name": "pending_credential_draft_workspace_id_workspace_id_fk", + "tableFrom": "pending_credential_draft", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pending_credential_draft_credential_id_credential_id_fk": { + "name": "pending_credential_draft_credential_id_credential_id_fk", + "tableFrom": "pending_credential_draft", + "tableTo": "credential", + "columnsFrom": ["credential_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.permission_group": { + "name": "permission_group", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "auto_add_new_members": { + "name": "auto_add_new_members", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "permission_group_created_by_idx": { + "name": "permission_group_created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permission_group_workspace_name_unique": { + "name": "permission_group_workspace_name_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permission_group_workspace_auto_add_unique": { + "name": "permission_group_workspace_auto_add_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "auto_add_new_members = true", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "permission_group_workspace_id_workspace_id_fk": { + "name": "permission_group_workspace_id_workspace_id_fk", + "tableFrom": "permission_group", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "permission_group_created_by_user_id_fk": { + "name": "permission_group_created_by_user_id_fk", + "tableFrom": "permission_group", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.permission_group_member": { + "name": "permission_group_member", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "permission_group_id": { + "name": "permission_group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "assigned_by": { + "name": "assigned_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "permission_group_member_group_id_idx": { + "name": "permission_group_member_group_id_idx", + "columns": [ + { + "expression": "permission_group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permission_group_member_group_user_unique": { + "name": "permission_group_member_group_user_unique", + "columns": [ + { + "expression": "permission_group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permission_group_member_workspace_user_unique": { + "name": "permission_group_member_workspace_user_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "permission_group_member_permission_group_id_permission_group_id_fk": { + "name": "permission_group_member_permission_group_id_permission_group_id_fk", + "tableFrom": "permission_group_member", + "tableTo": "permission_group", + "columnsFrom": ["permission_group_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "permission_group_member_workspace_id_workspace_id_fk": { + "name": "permission_group_member_workspace_id_workspace_id_fk", + "tableFrom": "permission_group_member", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "permission_group_member_user_id_user_id_fk": { + "name": "permission_group_member_user_id_user_id_fk", + "tableFrom": "permission_group_member", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "permission_group_member_assigned_by_user_id_fk": { + "name": "permission_group_member_assigned_by_user_id_fk", + "tableFrom": "permission_group_member", + "tableTo": "user", + "columnsFrom": ["assigned_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.permissions": { + "name": "permissions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "permission_type": { + "name": "permission_type", + "type": "permission_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "permissions_user_id_idx": { + "name": "permissions_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permissions_entity_idx": { + "name": "permissions_entity_idx", + "columns": [ + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permissions_user_entity_type_idx": { + "name": "permissions_user_entity_type_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permissions_user_entity_permission_idx": { + "name": "permissions_user_entity_permission_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "permission_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permissions_user_entity_idx": { + "name": "permissions_user_entity_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permissions_unique_constraint": { + "name": "permissions_unique_constraint", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "permissions_user_id_user_id_fk": { + "name": "permissions_user_id_user_id_fk", + "tableFrom": "permissions", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rate_limit_bucket": { + "name": "rate_limit_bucket", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "tokens": { + "name": "tokens", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "last_refill_at": { + "name": "last_refill_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.resume_queue": { + "name": "resume_queue", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "paused_execution_id": { + "name": "paused_execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_execution_id": { + "name": "parent_execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "new_execution_id": { + "name": "new_execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "context_id": { + "name": "context_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resume_input": { + "name": "resume_input", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "queued_at": { + "name": "queued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "claimed_at": { + "name": "claimed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "resume_queue_parent_status_idx": { + "name": "resume_queue_parent_status_idx", + "columns": [ + { + "expression": "parent_execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "queued_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "resume_queue_new_execution_idx": { + "name": "resume_queue_new_execution_idx", + "columns": [ + { + "expression": "new_execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "resume_queue_paused_execution_id_paused_executions_id_fk": { + "name": "resume_queue_paused_execution_id_paused_executions_id_fk", + "tableFrom": "resume_queue", + "tableTo": "paused_executions", + "columnsFrom": ["paused_execution_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active_organization_id": { + "name": "active_organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "impersonated_by": { + "name": "impersonated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "session_user_id_idx": { + "name": "session_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "session_token_idx": { + "name": "session_token_idx", + "columns": [ + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "session_active_organization_id_organization_id_fk": { + "name": "session_active_organization_id_organization_id_fk", + "tableFrom": "session", + "tableTo": "organization", + "columnsFrom": ["active_organization_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.settings": { + "name": "settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "theme": { + "name": "theme", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "auto_connect": { + "name": "auto_connect", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "telemetry_enabled": { + "name": "telemetry_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "email_preferences": { + "name": "email_preferences", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "billing_usage_notifications_enabled": { + "name": "billing_usage_notifications_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "show_training_controls": { + "name": "show_training_controls", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "super_user_mode_enabled": { + "name": "super_user_mode_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "mothership_environment": { + "name": "mothership_environment", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "error_notifications_enabled": { + "name": "error_notifications_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "snap_to_grid_size": { + "name": "snap_to_grid_size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "show_action_bar": { + "name": "show_action_bar", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "copilot_enabled_models": { + "name": "copilot_enabled_models", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "copilot_auto_allowed_tools": { + "name": "copilot_auto_allowed_tools", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'" + }, + "last_active_workspace_id": { + "name": "last_active_workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "settings_user_id_user_id_fk": { + "name": "settings_user_id_user_id_fk", + "tableFrom": "settings", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "settings_user_id_unique": { + "name": "settings_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sim_trigger_state": { + "name": "sim_trigger_state", + "schema": "", + "columns": { + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "block_id": { + "name": "block_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scope_key": { + "name": "scope_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "last_fired_at": { + "name": "last_fired_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "sim_trigger_state_workflow_id_workflow_id_fk": { + "name": "sim_trigger_state_workflow_id_workflow_id_fk", + "tableFrom": "sim_trigger_state", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sim_trigger_state_workflow_id_block_id_scope_key_pk": { + "name": "sim_trigger_state_workflow_id_block_id_scope_key_pk", + "columns": ["workflow_id", "block_id", "scope_key"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.skill": { + "name": "skill", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "skill_workspace_name_unique": { + "name": "skill_workspace_name_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "skill_workspace_id_workspace_id_fk": { + "name": "skill_workspace_id_workspace_id_fk", + "tableFrom": "skill", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "skill_user_id_user_id_fk": { + "name": "skill_user_id_user_id_fk", + "tableFrom": "skill", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sso_provider": { + "name": "sso_provider", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "issuer": { + "name": "issuer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "domain": { + "name": "domain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "oidc_config": { + "name": "oidc_config", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "saml_config": { + "name": "saml_config", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sso_provider_provider_id_idx": { + "name": "sso_provider_provider_id_idx", + "columns": [ + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sso_provider_domain_idx": { + "name": "sso_provider_domain_idx", + "columns": [ + { + "expression": "domain", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sso_provider_user_id_idx": { + "name": "sso_provider_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sso_provider_organization_id_idx": { + "name": "sso_provider_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sso_provider_user_id_user_id_fk": { + "name": "sso_provider_user_id_user_id_fk", + "tableFrom": "sso_provider", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sso_provider_organization_id_organization_id_fk": { + "name": "sso_provider_organization_id_organization_id_fk", + "tableFrom": "sso_provider", + "tableTo": "organization", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.subscription": { + "name": "subscription", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "period_start": { + "name": "period_start", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "period_end": { + "name": "period_end", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "cancel_at": { + "name": "cancel_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "trial_start": { + "name": "trial_start", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "trial_end": { + "name": "trial_end", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "billing_interval": { + "name": "billing_interval", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_schedule_id": { + "name": "stripe_schedule_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "json", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "subscription_reference_status_idx": { + "name": "subscription_reference_status_idx", + "columns": [ + { + "expression": "reference_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "check_enterprise_metadata": { + "name": "check_enterprise_metadata", + "value": "plan != 'enterprise' OR metadata IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.table_jobs": { + "name": "table_jobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "table_id": { + "name": "table_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'running'" + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "rows_processed": { + "name": "rows_processed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "table_jobs_one_active_per_table": { + "name": "table_jobs_one_active_per_table", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"table_jobs\".\"status\" = 'running' AND \"table_jobs\".\"type\" <> 'export'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "table_jobs_watchdog_idx": { + "name": "table_jobs_watchdog_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "table_jobs_table_started_idx": { + "name": "table_jobs_table_started_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "table_jobs_table_id_user_table_definitions_id_fk": { + "name": "table_jobs_table_id_user_table_definitions_id_fk", + "tableFrom": "table_jobs", + "tableTo": "user_table_definitions", + "columnsFrom": ["table_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "table_jobs_workspace_id_workspace_id_fk": { + "name": "table_jobs_workspace_id_workspace_id_fk", + "tableFrom": "table_jobs", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.table_row_executions": { + "name": "table_row_executions", + "schema": "", + "columns": { + "table_id": { + "name": "table_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "row_id": { + "name": "row_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "running_block_ids": { + "name": "running_block_ids", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "block_errors": { + "name": "block_errors", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "table_row_executions_table_status_idx": { + "name": "table_row_executions_table_status_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"table_row_executions\".\"status\" IN ('queued', 'running', 'pending')", + "concurrently": false, + "method": "btree", + "with": {} + }, + "table_row_executions_execution_id_idx": { + "name": "table_row_executions_execution_id_idx", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"table_row_executions\".\"execution_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "table_row_executions_table_group_idx": { + "name": "table_row_executions_table_group_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "table_row_executions_table_id_user_table_definitions_id_fk": { + "name": "table_row_executions_table_id_user_table_definitions_id_fk", + "tableFrom": "table_row_executions", + "tableTo": "user_table_definitions", + "columnsFrom": ["table_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "table_row_executions_row_id_user_table_rows_id_fk": { + "name": "table_row_executions_row_id_user_table_rows_id_fk", + "tableFrom": "table_row_executions", + "tableTo": "user_table_rows", + "columnsFrom": ["row_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "table_row_executions_row_id_group_id_pk": { + "name": "table_row_executions_row_id_group_id_pk", + "columns": ["row_id", "group_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.table_run_dispatches": { + "name": "table_run_dispatches", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "table_id": { + "name": "table_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scope": { + "name": "scope", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cursor": { + "name": "cursor", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "limit": { + "name": "limit", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "processed_count": { + "name": "processed_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "is_manual_run": { + "name": "is_manual_run", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "triggered_by_user_id": { + "name": "triggered_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "requested_at": { + "name": "requested_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "table_run_dispatches_active_idx": { + "name": "table_run_dispatches_active_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "table_run_dispatches_watchdog_idx": { + "name": "table_run_dispatches_watchdog_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "requested_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "table_run_dispatches_table_id_user_table_definitions_id_fk": { + "name": "table_run_dispatches_table_id_user_table_definitions_id_fk", + "tableFrom": "table_run_dispatches", + "tableTo": "user_table_definitions", + "columnsFrom": ["table_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "table_run_dispatches_workspace_id_workspace_id_fk": { + "name": "table_run_dispatches_workspace_id_workspace_id_fk", + "tableFrom": "table_run_dispatches", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "table_run_dispatches_triggered_by_user_id_user_id_fk": { + "name": "table_run_dispatches_triggered_by_user_id_user_id_fk", + "tableFrom": "table_run_dispatches", + "tableTo": "user", + "columnsFrom": ["triggered_by_user_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.usage_log": { + "name": "usage_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "usage_log_category", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "usage_log_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "cost": { + "name": "cost", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "event_key": { + "name": "event_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "billing_entity_type": { + "name": "billing_entity_type", + "type": "billing_entity_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "billing_entity_id": { + "name": "billing_entity_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "billing_period_start": { + "name": "billing_period_start", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "billing_period_end": { + "name": "billing_period_end", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "usage_log_user_created_at_idx": { + "name": "usage_log_user_created_at_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_log_source_idx": { + "name": "usage_log_source_idx", + "columns": [ + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_log_workspace_id_idx": { + "name": "usage_log_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_log_workflow_id_idx": { + "name": "usage_log_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_log_event_key_unique": { + "name": "usage_log_event_key_unique", + "columns": [ + { + "expression": "event_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"usage_log\".\"event_key\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_log_billing_entity_period_idx": { + "name": "usage_log_billing_entity_period_idx", + "columns": [ + { + "expression": "billing_entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "billing_entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "billing_period_start", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "billing_period_end", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"usage_log\".\"billing_entity_type\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_log_workspace_created_at_idx": { + "name": "usage_log_workspace_created_at_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_log_execution_id_idx": { + "name": "usage_log_execution_id_idx", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "usage_log_user_id_user_id_fk": { + "name": "usage_log_user_id_user_id_fk", + "tableFrom": "usage_log", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "usage_log_workspace_id_workspace_id_fk": { + "name": "usage_log_workspace_id_workspace_id_fk", + "tableFrom": "usage_log", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "usage_log_workflow_id_workflow_id_fk": { + "name": "usage_log_workflow_id_workflow_id_fk", + "tableFrom": "usage_log", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "usage_log_billing_scope_all_or_none": { + "name": "usage_log_billing_scope_all_or_none", + "value": "(\n (\"usage_log\".\"billing_entity_type\" IS NULL AND \"usage_log\".\"billing_entity_id\" IS NULL AND \"usage_log\".\"billing_period_start\" IS NULL AND \"usage_log\".\"billing_period_end\" IS NULL)\n OR\n (\"usage_log\".\"billing_entity_type\" IS NOT NULL AND \"usage_log\".\"billing_entity_id\" IS NOT NULL AND \"usage_log\".\"billing_period_start\" IS NOT NULL AND \"usage_log\".\"billing_period_end\" IS NOT NULL AND \"usage_log\".\"billing_period_start\" < \"usage_log\".\"billing_period_end\")\n )" + } + }, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "normalized_email": { + "name": "normalized_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'user'" + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ban_expires": { + "name": "ban_expires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + }, + "user_normalized_email_unique": { + "name": "user_normalized_email_unique", + "nullsNotDistinct": false, + "columns": ["normalized_email"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_stats": { + "name": "user_stats", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "total_manual_executions": { + "name": "total_manual_executions", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_api_calls": { + "name": "total_api_calls", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_webhook_triggers": { + "name": "total_webhook_triggers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_scheduled_executions": { + "name": "total_scheduled_executions", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_chat_executions": { + "name": "total_chat_executions", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_mcp_executions": { + "name": "total_mcp_executions", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_a2a_executions": { + "name": "total_a2a_executions", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_tokens_used": { + "name": "total_tokens_used", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_cost": { + "name": "total_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "current_usage_limit": { + "name": "current_usage_limit", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'5'" + }, + "usage_limit_updated_at": { + "name": "usage_limit_updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "current_period_cost": { + "name": "current_period_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "last_period_cost": { + "name": "last_period_cost", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'0'" + }, + "billed_overage_this_period": { + "name": "billed_overage_this_period", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "pro_period_cost_snapshot": { + "name": "pro_period_cost_snapshot", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'0'" + }, + "pro_period_cost_snapshot_at": { + "name": "pro_period_cost_snapshot_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "credit_balance": { + "name": "credit_balance", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "total_copilot_cost": { + "name": "total_copilot_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "current_period_copilot_cost": { + "name": "current_period_copilot_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "last_period_copilot_cost": { + "name": "last_period_copilot_cost", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'0'" + }, + "total_copilot_tokens": { + "name": "total_copilot_tokens", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_copilot_calls": { + "name": "total_copilot_calls", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_mcp_copilot_calls": { + "name": "total_mcp_copilot_calls", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_mcp_copilot_cost": { + "name": "total_mcp_copilot_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "current_period_mcp_copilot_cost": { + "name": "current_period_mcp_copilot_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "storage_used_bytes": { + "name": "storage_used_bytes", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_active": { + "name": "last_active", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "billing_blocked": { + "name": "billing_blocked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "billing_blocked_reason": { + "name": "billing_blocked_reason", + "type": "billing_blocked_reason", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "user_stats_user_id_user_id_fk": { + "name": "user_stats_user_id_user_id_fk", + "tableFrom": "user_stats", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_stats_user_id_unique": { + "name": "user_stats_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_table_definitions": { + "name": "user_table_definitions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "schema": { + "name": "schema", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "max_rows": { + "name": "max_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 10000 + }, + "row_count": { + "name": "row_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "user_table_def_workspace_id_idx": { + "name": "user_table_def_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_table_def_workspace_name_unique": { + "name": "user_table_def_workspace_name_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"user_table_definitions\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_table_def_archived_at_idx": { + "name": "user_table_def_archived_at_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_table_def_workspace_archived_partial_idx": { + "name": "user_table_def_workspace_archived_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"user_table_definitions\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_table_definitions_workspace_id_workspace_id_fk": { + "name": "user_table_definitions_workspace_id_workspace_id_fk", + "tableFrom": "user_table_definitions", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_table_definitions_created_by_user_id_fk": { + "name": "user_table_definitions_created_by_user_id_fk", + "tableFrom": "user_table_definitions", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_table_rows": { + "name": "user_table_rows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "table_id": { + "name": "table_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "order_key": { + "name": "order_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "user_table_rows_table_id_idx": { + "name": "user_table_rows_table_id_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_table_rows_tenant_data_gin_idx": { + "name": "user_table_rows_tenant_data_gin_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "\"data\" jsonb_path_ops", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + }, + "user_table_rows_workspace_table_idx": { + "name": "user_table_rows_workspace_table_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_table_rows_table_position_idx": { + "name": "user_table_rows_table_position_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "position", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_table_rows_table_order_key_idx": { + "name": "user_table_rows_table_order_key_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "order_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_table_rows_table_id_id_idx": { + "name": "user_table_rows_table_id_id_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_table_rows_table_id_user_table_definitions_id_fk": { + "name": "user_table_rows_table_id_user_table_definitions_id_fk", + "tableFrom": "user_table_rows", + "tableTo": "user_table_definitions", + "columnsFrom": ["table_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_table_rows_workspace_id_workspace_id_fk": { + "name": "user_table_rows_workspace_id_workspace_id_fk", + "tableFrom": "user_table_rows", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_table_rows_created_by_user_id_fk": { + "name": "user_table_rows_created_by_user_id_fk", + "tableFrom": "user_table_rows", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "verification_identifier_idx": { + "name": "verification_identifier_idx", + "columns": [ + { + "expression": "identifier", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "verification_expires_at_idx": { + "name": "verification_expires_at_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.waitlist": { + "name": "waitlist", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "waitlist_email_unique": { + "name": "waitlist_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.webhook": { + "name": "webhook", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "deployment_version_id": { + "name": "deployment_version_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "block_id": { + "name": "block_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_config": { + "name": "provider_config", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "failed_count": { + "name": "failed_count", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "last_failed_at": { + "name": "last_failed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "credential_set_id": { + "name": "credential_set_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "path_deployment_unique": { + "name": "path_deployment_unique", + "columns": [ + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deployment_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"webhook\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "webhook_workflow_deployment_idx": { + "name": "webhook_workflow_deployment_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deployment_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "webhook_credential_set_id_idx": { + "name": "webhook_credential_set_id_idx", + "columns": [ + { + "expression": "credential_set_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "webhook_archived_at_partial_idx": { + "name": "webhook_archived_at_partial_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"webhook\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_webhook_on_provider_is_active_workflow_id_deploym_bdeed5468": { + "name": "idx_webhook_on_provider_is_active_workflow_id_deploym_bdeed5468", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deployment_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_webhook_on_workflow_id_block_id_updated_at_desc": { + "name": "idx_webhook_on_workflow_id_block_id_updated_at_desc", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "block_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "webhook_workflow_id_workflow_id_fk": { + "name": "webhook_workflow_id_workflow_id_fk", + "tableFrom": "webhook", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "webhook_deployment_version_id_workflow_deployment_version_id_fk": { + "name": "webhook_deployment_version_id_workflow_deployment_version_id_fk", + "tableFrom": "webhook", + "tableTo": "workflow_deployment_version", + "columnsFrom": ["deployment_version_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "webhook_credential_set_id_credential_set_id_fk": { + "name": "webhook_credential_set_id_credential_set_id_fk", + "tableFrom": "webhook", + "tableTo": "credential_set", + "columnsFrom": ["credential_set_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow": { + "name": "workflow", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "folder_id": { + "name": "folder_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_synced": { + "name": "last_synced", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_deployed": { + "name": "is_deployed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "deployed_at": { + "name": "deployed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "is_public_api": { + "name": "is_public_api", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "run_count": { + "name": "run_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_run_at": { + "name": "last_run_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "variables": { + "name": "variables", + "type": "json", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "workflow_user_id_idx": { + "name": "workflow_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_workspace_id_idx": { + "name": "workflow_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_user_workspace_idx": { + "name": "workflow_user_workspace_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_workspace_folder_name_active_unique": { + "name": "workflow_workspace_folder_name_active_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "coalesce(\"folder_id\", '')", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"workflow\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_folder_sort_idx": { + "name": "workflow_folder_sort_idx", + "columns": [ + { + "expression": "folder_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sort_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_archived_at_idx": { + "name": "workflow_archived_at_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_workspace_archived_partial_idx": { + "name": "workflow_workspace_archived_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workflow\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_user_id_user_id_fk": { + "name": "workflow_user_id_user_id_fk", + "tableFrom": "workflow", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_workspace_id_workspace_id_fk": { + "name": "workflow_workspace_id_workspace_id_fk", + "tableFrom": "workflow", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_folder_id_workflow_folder_id_fk": { + "name": "workflow_folder_id_workflow_folder_id_fk", + "tableFrom": "workflow", + "tableTo": "workflow_folder", + "columnsFrom": ["folder_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_blocks": { + "name": "workflow_blocks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position_x": { + "name": "position_x", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "position_y": { + "name": "position_y", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "horizontal_handles": { + "name": "horizontal_handles", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_wide": { + "name": "is_wide", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "advanced_mode": { + "name": "advanced_mode", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "trigger_mode": { + "name": "trigger_mode", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "height": { + "name": "height", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "sub_blocks": { + "name": "sub_blocks", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "outputs": { + "name": "outputs", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_blocks_workflow_id_idx": { + "name": "workflow_blocks_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_blocks_type_idx": { + "name": "workflow_blocks_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_blocks_workflow_id_workflow_id_fk": { + "name": "workflow_blocks_workflow_id_workflow_id_fk", + "tableFrom": "workflow_blocks", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_checkpoints": { + "name": "workflow_checkpoints", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workflow_state": { + "name": "workflow_state", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_checkpoints_user_id_idx": { + "name": "workflow_checkpoints_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_checkpoints_workflow_id_idx": { + "name": "workflow_checkpoints_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_checkpoints_chat_id_idx": { + "name": "workflow_checkpoints_chat_id_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_checkpoints_message_id_idx": { + "name": "workflow_checkpoints_message_id_idx", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_checkpoints_user_workflow_idx": { + "name": "workflow_checkpoints_user_workflow_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_checkpoints_workflow_chat_idx": { + "name": "workflow_checkpoints_workflow_chat_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_checkpoints_created_at_idx": { + "name": "workflow_checkpoints_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_checkpoints_chat_created_at_idx": { + "name": "workflow_checkpoints_chat_created_at_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_checkpoints_user_id_user_id_fk": { + "name": "workflow_checkpoints_user_id_user_id_fk", + "tableFrom": "workflow_checkpoints", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_checkpoints_workflow_id_workflow_id_fk": { + "name": "workflow_checkpoints_workflow_id_workflow_id_fk", + "tableFrom": "workflow_checkpoints", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_checkpoints_chat_id_copilot_chats_id_fk": { + "name": "workflow_checkpoints_chat_id_copilot_chats_id_fk", + "tableFrom": "workflow_checkpoints", + "tableTo": "copilot_chats", + "columnsFrom": ["chat_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_deployment_version": { + "name": "workflow_deployment_version", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "workflow_deployment_version_workflow_version_unique": { + "name": "workflow_deployment_version_workflow_version_unique", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_deployment_version_workflow_active_idx": { + "name": "workflow_deployment_version_workflow_active_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_deployment_version_created_at_idx": { + "name": "workflow_deployment_version_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_deployment_version_workflow_id_workflow_id_fk": { + "name": "workflow_deployment_version_workflow_id_workflow_id_fk", + "tableFrom": "workflow_deployment_version", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_edges": { + "name": "workflow_edges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_block_id": { + "name": "source_block_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_block_id": { + "name": "target_block_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_handle": { + "name": "source_handle", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "target_handle": { + "name": "target_handle", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_edges_workflow_id_idx": { + "name": "workflow_edges_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_edges_workflow_source_idx": { + "name": "workflow_edges_workflow_source_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_block_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_edges_workflow_target_idx": { + "name": "workflow_edges_workflow_target_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "target_block_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_edges_workflow_id_workflow_id_fk": { + "name": "workflow_edges_workflow_id_workflow_id_fk", + "tableFrom": "workflow_edges", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_edges_source_block_id_workflow_blocks_id_fk": { + "name": "workflow_edges_source_block_id_workflow_blocks_id_fk", + "tableFrom": "workflow_edges", + "tableTo": "workflow_blocks", + "columnsFrom": ["source_block_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_edges_target_block_id_workflow_blocks_id_fk": { + "name": "workflow_edges_target_block_id_workflow_blocks_id_fk", + "tableFrom": "workflow_edges", + "tableTo": "workflow_blocks", + "columnsFrom": ["target_block_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_execution_logs": { + "name": "workflow_execution_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state_snapshot_id": { + "name": "state_snapshot_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "deployment_version_id": { + "name": "deployment_version_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'running'" + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "total_duration_ms": { + "name": "total_duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "execution_data": { + "name": "execution_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "cost": { + "name": "cost", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "cost_total": { + "name": "cost_total", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "models_used": { + "name": "models_used", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "files": { + "name": "files", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_execution_logs_workflow_id_idx": { + "name": "workflow_execution_logs_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_state_snapshot_id_idx": { + "name": "workflow_execution_logs_state_snapshot_id_idx", + "columns": [ + { + "expression": "state_snapshot_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_deployment_version_id_idx": { + "name": "workflow_execution_logs_deployment_version_id_idx", + "columns": [ + { + "expression": "deployment_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_trigger_idx": { + "name": "workflow_execution_logs_trigger_idx", + "columns": [ + { + "expression": "trigger", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_level_idx": { + "name": "workflow_execution_logs_level_idx", + "columns": [ + { + "expression": "level", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_started_at_idx": { + "name": "workflow_execution_logs_started_at_idx", + "columns": [ + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_execution_id_unique": { + "name": "workflow_execution_logs_execution_id_unique", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_workflow_started_at_idx": { + "name": "workflow_execution_logs_workflow_started_at_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_workspace_started_at_idx": { + "name": "workflow_execution_logs_workspace_started_at_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_workspace_cost_total_idx": { + "name": "workflow_execution_logs_workspace_cost_total_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "cost_total", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_models_used_idx": { + "name": "workflow_execution_logs_models_used_idx", + "columns": [ + { + "expression": "models_used", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + }, + "workflow_execution_logs_workspace_ended_at_id_idx": { + "name": "workflow_execution_logs_workspace_ended_at_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date_trunc('milliseconds', \"ended_at\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_running_started_at_idx": { + "name": "workflow_execution_logs_running_started_at_idx", + "columns": [ + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "status = 'running'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_execution_logs_workflow_id_workflow_id_fk": { + "name": "workflow_execution_logs_workflow_id_workflow_id_fk", + "tableFrom": "workflow_execution_logs", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "workflow_execution_logs_workspace_id_workspace_id_fk": { + "name": "workflow_execution_logs_workspace_id_workspace_id_fk", + "tableFrom": "workflow_execution_logs", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_execution_logs_state_snapshot_id_workflow_execution_snapshots_id_fk": { + "name": "workflow_execution_logs_state_snapshot_id_workflow_execution_snapshots_id_fk", + "tableFrom": "workflow_execution_logs", + "tableTo": "workflow_execution_snapshots", + "columnsFrom": ["state_snapshot_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "workflow_execution_logs_deployment_version_id_workflow_deployment_version_id_fk": { + "name": "workflow_execution_logs_deployment_version_id_workflow_deployment_version_id_fk", + "tableFrom": "workflow_execution_logs", + "tableTo": "workflow_deployment_version", + "columnsFrom": ["deployment_version_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_execution_snapshots": { + "name": "workflow_execution_snapshots", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state_hash": { + "name": "state_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state_data": { + "name": "state_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_snapshots_workflow_id_idx": { + "name": "workflow_snapshots_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_snapshots_hash_idx": { + "name": "workflow_snapshots_hash_idx", + "columns": [ + { + "expression": "state_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_snapshots_workflow_hash_idx": { + "name": "workflow_snapshots_workflow_hash_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "state_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_snapshots_created_at_idx": { + "name": "workflow_snapshots_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_execution_snapshots_workflow_id_workflow_id_fk": { + "name": "workflow_execution_snapshots_workflow_id_workflow_id_fk", + "tableFrom": "workflow_execution_snapshots", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_folder": { + "name": "workflow_folder", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'#6B7280'" + }, + "is_expanded": { + "name": "is_expanded", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "workflow_folder_user_idx": { + "name": "workflow_folder_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_folder_workspace_parent_idx": { + "name": "workflow_folder_workspace_parent_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_folder_parent_sort_idx": { + "name": "workflow_folder_parent_sort_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sort_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_folder_archived_at_idx": { + "name": "workflow_folder_archived_at_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_folder_workspace_archived_partial_idx": { + "name": "workflow_folder_workspace_archived_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workflow_folder\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_folder_user_id_user_id_fk": { + "name": "workflow_folder_user_id_user_id_fk", + "tableFrom": "workflow_folder", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_folder_workspace_id_workspace_id_fk": { + "name": "workflow_folder_workspace_id_workspace_id_fk", + "tableFrom": "workflow_folder", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_mcp_server": { + "name": "workflow_mcp_server", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_public": { + "name": "is_public", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_mcp_server_workspace_id_idx": { + "name": "workflow_mcp_server_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_mcp_server_created_by_idx": { + "name": "workflow_mcp_server_created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_mcp_server_deleted_at_idx": { + "name": "workflow_mcp_server_deleted_at_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_mcp_server_workspace_deleted_partial_idx": { + "name": "workflow_mcp_server_workspace_deleted_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workflow_mcp_server\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_mcp_server_workspace_id_workspace_id_fk": { + "name": "workflow_mcp_server_workspace_id_workspace_id_fk", + "tableFrom": "workflow_mcp_server", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_mcp_server_created_by_user_id_fk": { + "name": "workflow_mcp_server_created_by_user_id_fk", + "tableFrom": "workflow_mcp_server", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_mcp_tool": { + "name": "workflow_mcp_tool", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "server_id": { + "name": "server_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool_name": { + "name": "tool_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool_description": { + "name": "tool_description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "parameter_schema": { + "name": "parameter_schema", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_mcp_tool_server_id_idx": { + "name": "workflow_mcp_tool_server_id_idx", + "columns": [ + { + "expression": "server_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_mcp_tool_workflow_id_idx": { + "name": "workflow_mcp_tool_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_mcp_tool_server_workflow_unique": { + "name": "workflow_mcp_tool_server_workflow_unique", + "columns": [ + { + "expression": "server_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"workflow_mcp_tool\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_mcp_tool_archived_at_partial_idx": { + "name": "workflow_mcp_tool_archived_at_partial_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workflow_mcp_tool\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_mcp_tool_server_id_workflow_mcp_server_id_fk": { + "name": "workflow_mcp_tool_server_id_workflow_mcp_server_id_fk", + "tableFrom": "workflow_mcp_tool", + "tableTo": "workflow_mcp_server", + "columnsFrom": ["server_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_mcp_tool_workflow_id_workflow_id_fk": { + "name": "workflow_mcp_tool_workflow_id_workflow_id_fk", + "tableFrom": "workflow_mcp_tool", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_schedule": { + "name": "workflow_schedule", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deployment_version_id": { + "name": "deployment_version_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "block_id": { + "name": "block_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cron_expression": { + "name": "cron_expression", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_run_at": { + "name": "next_run_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_ran_at": { + "name": "last_ran_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_queued_at": { + "name": "last_queued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "trigger_type": { + "name": "trigger_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'UTC'" + }, + "failed_count": { + "name": "failed_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "infra_retry_count": { + "name": "infra_retry_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "last_failed_at": { + "name": "last_failed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "source_type": { + "name": "source_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'workflow'" + }, + "job_title": { + "name": "job_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lifecycle": { + "name": "lifecycle", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'persistent'" + }, + "success_condition": { + "name": "success_condition", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "max_runs": { + "name": "max_runs", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "run_count": { + "name": "run_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "source_chat_id": { + "name": "source_chat_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_task_name": { + "name": "source_task_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_user_id": { + "name": "source_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_workspace_id": { + "name": "source_workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "job_history": { + "name": "job_history", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_schedule_workflow_block_deployment_unique": { + "name": "workflow_schedule_workflow_block_deployment_unique", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "block_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deployment_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"workflow_schedule\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_schedule_workflow_deployment_idx": { + "name": "workflow_schedule_workflow_deployment_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deployment_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_schedule_archived_at_partial_idx": { + "name": "workflow_schedule_archived_at_partial_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workflow_schedule\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_workflow_schedule_on_source_workspace_id_source_t_c07f3bba6": { + "name": "idx_workflow_schedule_on_source_workspace_id_source_t_c07f3bba6", + "columns": [ + { + "expression": "source_workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_schedule_due_workflow_idx": { + "name": "workflow_schedule_due_workflow_idx", + "columns": [ + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_queued_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deployment_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workflow_schedule\".\"archived_at\" IS NULL AND \"workflow_schedule\".\"status\" NOT IN ('disabled', 'completed') AND (\"workflow_schedule\".\"source_type\" = 'workflow' OR \"workflow_schedule\".\"source_type\" IS NULL)", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_schedule_due_job_idx": { + "name": "workflow_schedule_due_job_idx", + "columns": [ + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_queued_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workflow_schedule\".\"archived_at\" IS NULL AND \"workflow_schedule\".\"status\" NOT IN ('disabled', 'completed') AND \"workflow_schedule\".\"source_type\" = 'job'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_schedule_workflow_id_workflow_id_fk": { + "name": "workflow_schedule_workflow_id_workflow_id_fk", + "tableFrom": "workflow_schedule", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_schedule_deployment_version_id_workflow_deployment_version_id_fk": { + "name": "workflow_schedule_deployment_version_id_workflow_deployment_version_id_fk", + "tableFrom": "workflow_schedule", + "tableTo": "workflow_deployment_version", + "columnsFrom": ["deployment_version_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_schedule_source_user_id_user_id_fk": { + "name": "workflow_schedule_source_user_id_user_id_fk", + "tableFrom": "workflow_schedule", + "tableTo": "user", + "columnsFrom": ["source_user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_schedule_source_workspace_id_workspace_id_fk": { + "name": "workflow_schedule_source_workspace_id_workspace_id_fk", + "tableFrom": "workflow_schedule", + "tableTo": "workspace", + "columnsFrom": ["source_workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_subflows": { + "name": "workflow_subflows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_subflows_workflow_id_idx": { + "name": "workflow_subflows_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_subflows_workflow_type_idx": { + "name": "workflow_subflows_workflow_type_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_subflows_workflow_id_workflow_id_fk": { + "name": "workflow_subflows_workflow_id_workflow_id_fk", + "tableFrom": "workflow_subflows", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace": { + "name": "workspace", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'#33C482'" + }, + "logo_url": { + "name": "logo_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workspace_mode": { + "name": "workspace_mode", + "type": "workspace_mode", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'grandfathered_shared'" + }, + "billed_account_user_id": { + "name": "billed_account_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "allow_personal_api_keys": { + "name": "allow_personal_api_keys", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "inbox_enabled": { + "name": "inbox_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "inbox_address": { + "name": "inbox_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "inbox_provider_id": { + "name": "inbox_provider_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_owner_id_idx": { + "name": "workspace_owner_id_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_organization_id_idx": { + "name": "workspace_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_mode_idx": { + "name": "workspace_mode_idx", + "columns": [ + { + "expression": "workspace_mode", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_owner_id_user_id_fk": { + "name": "workspace_owner_id_user_id_fk", + "tableFrom": "workspace", + "tableTo": "user", + "columnsFrom": ["owner_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_organization_id_organization_id_fk": { + "name": "workspace_organization_id_organization_id_fk", + "tableFrom": "workspace", + "tableTo": "organization", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "workspace_billed_account_user_id_user_id_fk": { + "name": "workspace_billed_account_user_id_user_id_fk", + "tableFrom": "workspace", + "tableTo": "user", + "columnsFrom": ["billed_account_user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_byok_keys": { + "name": "workspace_byok_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encrypted_api_key": { + "name": "encrypted_api_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_byok_workspace_provider_idx": { + "name": "workspace_byok_workspace_provider_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_byok_workspace_idx": { + "name": "workspace_byok_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_byok_keys_workspace_id_workspace_id_fk": { + "name": "workspace_byok_keys_workspace_id_workspace_id_fk", + "tableFrom": "workspace_byok_keys", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_byok_keys_created_by_user_id_fk": { + "name": "workspace_byok_keys_created_by_user_id_fk", + "tableFrom": "workspace_byok_keys", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_environment": { + "name": "workspace_environment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "variables": { + "name": "variables", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_environment_workspace_unique": { + "name": "workspace_environment_workspace_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_environment_workspace_id_workspace_id_fk": { + "name": "workspace_environment_workspace_id_workspace_id_fk", + "tableFrom": "workspace_environment", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_file": { + "name": "workspace_file", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "uploaded_at": { + "name": "uploaded_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_file_workspace_id_idx": { + "name": "workspace_file_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_file_key_idx": { + "name": "workspace_file_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_file_deleted_at_idx": { + "name": "workspace_file_deleted_at_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_file_workspace_deleted_partial_idx": { + "name": "workspace_file_workspace_deleted_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workspace_file\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_file_workspace_id_workspace_id_fk": { + "name": "workspace_file_workspace_id_workspace_id_fk", + "tableFrom": "workspace_file", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_file_uploaded_by_user_id_fk": { + "name": "workspace_file_uploaded_by_user_id_fk", + "tableFrom": "workspace_file", + "tableTo": "user", + "columnsFrom": ["uploaded_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "workspace_file_key_unique": { + "name": "workspace_file_key_unique", + "nullsNotDistinct": false, + "columns": ["key"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_file_folders": { + "name": "workspace_file_folders", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_file_folders_workspace_parent_idx": { + "name": "workspace_file_folders_workspace_parent_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_file_folders_parent_sort_idx": { + "name": "workspace_file_folders_parent_sort_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sort_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_file_folders_deleted_at_idx": { + "name": "workspace_file_folders_deleted_at_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_file_folders_workspace_deleted_partial_idx": { + "name": "workspace_file_folders_workspace_deleted_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workspace_file_folders\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_file_folders_workspace_parent_name_active_unique": { + "name": "workspace_file_folders_workspace_parent_name_active_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "coalesce(\"parent_id\", '')", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"workspace_file_folders\".\"deleted_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_file_folders_user_id_user_id_fk": { + "name": "workspace_file_folders_user_id_user_id_fk", + "tableFrom": "workspace_file_folders", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_file_folders_workspace_id_workspace_id_fk": { + "name": "workspace_file_folders_workspace_id_workspace_id_fk", + "tableFrom": "workspace_file_folders", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_file_folders_parent_id_workspace_file_folders_id_fk": { + "name": "workspace_file_folders_parent_id_workspace_file_folders_id_fk", + "tableFrom": "workspace_file_folders", + "tableTo": "workspace_file_folders", + "columnsFrom": ["parent_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_files": { + "name": "workspace_files", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "folder_id": { + "name": "folder_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "context": { + "name": "context", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "original_name": { + "name": "original_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "uploaded_at": { + "name": "uploaded_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_files_key_active_unique": { + "name": "workspace_files_key_active_unique", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"workspace_files\".\"deleted_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_workspace_folder_name_active_unique": { + "name": "workspace_files_workspace_folder_name_active_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "coalesce(\"folder_id\", '')", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "original_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"workspace_files\".\"deleted_at\" IS NULL AND \"workspace_files\".\"context\" = 'workspace' AND \"workspace_files\".\"workspace_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_chat_display_name_unique": { + "name": "workspace_files_chat_display_name_unique", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "display_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"workspace_files\".\"context\" = 'mothership' AND \"workspace_files\".\"chat_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_key_idx": { + "name": "workspace_files_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_user_id_idx": { + "name": "workspace_files_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_workspace_id_idx": { + "name": "workspace_files_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_folder_id_idx": { + "name": "workspace_files_folder_id_idx", + "columns": [ + { + "expression": "folder_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_context_idx": { + "name": "workspace_files_context_idx", + "columns": [ + { + "expression": "context", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_chat_id_idx": { + "name": "workspace_files_chat_id_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_deleted_at_idx": { + "name": "workspace_files_deleted_at_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_workspace_deleted_partial_idx": { + "name": "workspace_files_workspace_deleted_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workspace_files\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_files_user_id_user_id_fk": { + "name": "workspace_files_user_id_user_id_fk", + "tableFrom": "workspace_files", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_files_workspace_id_workspace_id_fk": { + "name": "workspace_files_workspace_id_workspace_id_fk", + "tableFrom": "workspace_files", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_files_folder_id_workspace_file_folders_id_fk": { + "name": "workspace_files_folder_id_workspace_file_folders_id_fk", + "tableFrom": "workspace_files", + "tableTo": "workspace_file_folders", + "columnsFrom": ["folder_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "workspace_files_chat_id_copilot_chats_id_fk": { + "name": "workspace_files_chat_id_copilot_chats_id_fk", + "tableFrom": "workspace_files", + "tableTo": "copilot_chats", + "columnsFrom": ["chat_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.a2a_task_status": { + "name": "a2a_task_status", + "schema": "public", + "values": [ + "submitted", + "working", + "input-required", + "completed", + "failed", + "canceled", + "rejected", + "auth-required", + "unknown" + ] + }, + "public.academy_cert_status": { + "name": "academy_cert_status", + "schema": "public", + "values": ["active", "revoked", "expired"] + }, + "public.billing_blocked_reason": { + "name": "billing_blocked_reason", + "schema": "public", + "values": ["payment_failed", "dispute"] + }, + "public.billing_entity_type": { + "name": "billing_entity_type", + "schema": "public", + "values": ["user", "organization"] + }, + "public.chat_type": { + "name": "chat_type", + "schema": "public", + "values": ["mothership", "copilot"] + }, + "public.copilot_async_tool_status": { + "name": "copilot_async_tool_status", + "schema": "public", + "values": ["pending", "running", "completed", "failed", "cancelled", "delivered"] + }, + "public.copilot_run_status": { + "name": "copilot_run_status", + "schema": "public", + "values": ["active", "paused_waiting_for_tool", "resuming", "complete", "error", "cancelled"] + }, + "public.credential_member_role": { + "name": "credential_member_role", + "schema": "public", + "values": ["admin", "member"] + }, + "public.credential_member_status": { + "name": "credential_member_status", + "schema": "public", + "values": ["active", "pending", "revoked"] + }, + "public.credential_set_invitation_status": { + "name": "credential_set_invitation_status", + "schema": "public", + "values": ["pending", "accepted", "expired", "cancelled"] + }, + "public.credential_set_member_status": { + "name": "credential_set_member_status", + "schema": "public", + "values": ["active", "pending", "revoked"] + }, + "public.credential_type": { + "name": "credential_type", + "schema": "public", + "values": ["oauth", "env_workspace", "env_personal", "service_account"] + }, + "public.data_drain_cadence": { + "name": "data_drain_cadence", + "schema": "public", + "values": ["hourly", "daily"] + }, + "public.data_drain_destination": { + "name": "data_drain_destination", + "schema": "public", + "values": ["s3", "gcs", "azure_blob", "datadog", "bigquery", "snowflake", "webhook"] + }, + "public.data_drain_run_status": { + "name": "data_drain_run_status", + "schema": "public", + "values": ["running", "success", "failed"] + }, + "public.data_drain_run_trigger": { + "name": "data_drain_run_trigger", + "schema": "public", + "values": ["cron", "manual"] + }, + "public.data_drain_source": { + "name": "data_drain_source", + "schema": "public", + "values": ["workflow_logs", "job_logs", "audit_logs", "copilot_chats", "copilot_runs"] + }, + "public.execution_large_value_reference_source": { + "name": "execution_large_value_reference_source", + "schema": "public", + "values": ["execution_log", "paused_snapshot"] + }, + "public.invitation_kind": { + "name": "invitation_kind", + "schema": "public", + "values": ["organization", "workspace"] + }, + "public.invitation_membership_intent": { + "name": "invitation_membership_intent", + "schema": "public", + "values": ["internal", "external"] + }, + "public.invitation_status": { + "name": "invitation_status", + "schema": "public", + "values": ["pending", "accepted", "rejected", "cancelled", "expired"] + }, + "public.permission_type": { + "name": "permission_type", + "schema": "public", + "values": ["admin", "write", "read"] + }, + "public.usage_log_category": { + "name": "usage_log_category", + "schema": "public", + "values": ["model", "fixed", "tool"] + }, + "public.usage_log_source": { + "name": "usage_log_source", + "schema": "public", + "values": [ + "workflow", + "wand", + "copilot", + "workspace-chat", + "mcp_copilot", + "mothership_block", + "knowledge-base", + "voice-input", + "enrichment" + ] + }, + "public.workspace_mode": { + "name": "workspace_mode", + "schema": "public", + "values": ["personal", "organization", "grandfathered_shared"] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/packages/db/migrations/meta/_journal.json b/packages/db/migrations/meta/_journal.json index 7f5c6f1257c..56fb1dbedf1 100644 --- a/packages/db/migrations/meta/_journal.json +++ b/packages/db/migrations/meta/_journal.json @@ -1625,6 +1625,13 @@ "when": 1781146236134, "tag": "0232_byok_multiple_keys", "breakpoints": true + }, + { + "idx": 233, + "version": "7", + "when": 1781227386156, + "tag": "0233_table_jobs_and_keyset", + "breakpoints": true } ] } diff --git a/packages/db/schema.ts b/packages/db/schema.ts index 9ed28825f53..818d2a93e67 100644 --- a/packages/db/schema.ts +++ b/packages/db/schema.ts @@ -3103,16 +3103,6 @@ export const userTableDefinitions = pgTable( maxRows: integer('max_rows').notNull().default(10000), rowCount: integer('row_count').notNull().default(0), archivedAt: timestamp('archived_at'), - /** - * Async-import state. NULL = a normal table (never imported in the background). - * `'importing'` hides rows until the load completes; `'ready'` reveals them; - * `'failed'` surfaces a partial import. See `apps/sim/lib/table/import-runner.ts`. - */ - importStatus: text('import_status'), - importId: text('import_id'), - importError: text('import_error'), - importRowsProcessed: integer('import_rows_processed').notNull().default(0), - importStartedAt: timestamp('import_started_at'), createdBy: text('created_by') .notNull() .references(() => user.id, { onDelete: 'cascade' }), @@ -3163,7 +3153,20 @@ export const userTableRows = pgTable( }, (table) => ({ tableIdIdx: index('user_table_rows_table_id_idx').on(table.tableId), - dataGinIdx: index('user_table_rows_data_gin_idx').using('gin', table.data), + /** + * Tenant-scoped containment index (requires the `btree_gin` extension, + * created in migration 0232). A plain GIN on `data` matches `@>` candidates + * across every tenant sharing this relation — a hot value in someone else's + * table inflates everyone's scans (measured 1.07M candidates fetched for a + * 33k-row match). Leading with `table_id` intersects inside the index, and + * `jsonb_path_ops` indexes only containment paths: rare-equality probe + * 326ms → 17ms, and the index is smaller than the one it replaces. + */ + dataGinIdx: index('user_table_rows_tenant_data_gin_idx').using( + 'gin', + table.tableId, + sql`${table.data} jsonb_path_ops` + ), workspaceTableIdx: index('user_table_rows_workspace_table_idx').on( table.workspaceId, table.tableId @@ -3174,6 +3177,56 @@ export const userTableRows = pgTable( table.orderKey, table.id ), + /** + * Keyset pagination by id within one table (the delete-job worker's page walk). Without it + * the planner scans the global pkey in id order, filtering out every other table's rows — + * O(all rows) per page. + */ + tableIdIdIdx: index('user_table_rows_table_id_id_idx').on(table.tableId, table.id), + }) +) + +/** + * Background data-mutation jobs on a user table (CSV import, bulk filtered delete). One row per + * job. A detached worker streams progress into `rows_processed` and flips `status` to a terminal + * state; cancel flips `status` to `'canceled'` and the worker bails at its next ownership check. + * + * The partial-unique index on `table_id WHERE status = 'running'` is the concurrency gate: at most + * one running job per table, so a second import, or an import + delete, can't write into the same + * table at once. Distinct from `table_run_dispatches` — that fans workflow runs across rows via + * trigger.dev; this mutates row data directly. + */ +export const tableJobs = pgTable( + 'table_jobs', + { + id: text('id').primaryKey(), + tableId: text('table_id') + .notNull() + .references(() => userTableDefinitions.id, { onDelete: 'cascade' }), + workspaceId: text('workspace_id') + .notNull() + .references(() => workspace.id, { onDelete: 'cascade' }), + /** `'import'` | `'delete'`. */ + type: text('type').notNull(), + /** `'running'` → `'ready'` | `'failed'` | `'canceled'`. */ + status: text('status').notNull().default('running'), + /** Type-specific descriptor (e.g. delete filter/exclusions). Nullable; reserved for future + * resumability — today's workers carry their payload in-process via `runDetached`. */ + payload: jsonb('payload'), + rowsProcessed: integer('rows_processed').notNull().default(0), + error: text('error'), + startedAt: timestamp('started_at').notNull().defaultNow(), + updatedAt: timestamp('updated_at').notNull().defaultNow(), + completedAt: timestamp('completed_at'), + }, + (table) => ({ + /** One running write-job (import/delete/backfill) per table. Exports are read-only and + * excluded, so they can run alongside any other job. */ + oneActivePerTable: uniqueIndex('table_jobs_one_active_per_table') + .on(table.tableId) + .where(sql`${table.status} = 'running' AND ${table.type} <> 'export'`), + watchdogIdx: index('table_jobs_watchdog_idx').on(table.status, table.updatedAt), + tableStartedIdx: index('table_jobs_table_started_idx').on(table.tableId, table.startedAt), }) ) diff --git a/packages/testing/src/mocks/schema.mock.ts b/packages/testing/src/mocks/schema.mock.ts index ec12dc2d26f..adcb85d331a 100644 --- a/packages/testing/src/mocks/schema.mock.ts +++ b/packages/testing/src/mocks/schema.mock.ts @@ -1106,6 +1106,19 @@ export const schemaMock = { updatedAt: 'updatedAt', createdBy: 'createdBy', }, + tableJobs: { + id: 'id', + tableId: 'tableId', + workspaceId: 'workspaceId', + type: 'type', + status: 'status', + payload: 'payload', + rowsProcessed: 'rowsProcessed', + error: 'error', + startedAt: 'startedAt', + updatedAt: 'updatedAt', + completedAt: 'completedAt', + }, tableRowExecutions: { tableId: 'tableId', rowId: 'rowId', diff --git a/scripts/check-api-validation-contracts.ts b/scripts/check-api-validation-contracts.ts index 645b41e592d..8c37af6b5c0 100644 --- a/scripts/check-api-validation-contracts.ts +++ b/scripts/check-api-validation-contracts.ts @@ -9,8 +9,8 @@ const QUERY_HOOKS_DIR = path.join(ROOT, 'apps/sim/hooks/queries') const SELECTOR_HOOKS_DIR = path.join(ROOT, 'apps/sim/hooks/selectors') const BASELINE = { - totalRoutes: 812, - zodRoutes: 812, + totalRoutes: 816, + zodRoutes: 816, nonZodRoutes: 0, } as const From 2c75a4ac04880177c3579bb61ae86c5da8cc4fb1 Mon Sep 17 00:00:00 2001 From: Theodore Li Date: Fri, 12 Jun 2026 10:18:15 -0700 Subject: [PATCH 2/5] fix(tables): per-batch delete-job commits, real trigger.dev retries, post-index ANALYZE guard (#4997) * fix(tables): per-batch delete-job commits, real trigger.dev retries, post-index ANALYZE guard * fix(tables): resume job progress across retries, rethrow root cause for clean failure messages --- .../api/table/[tableId]/delete-async/route.ts | 6 +- apps/sim/background/table-delete.ts | 19 +- apps/sim/lib/table/constants.ts | 6 +- apps/sim/lib/table/delete-runner.test.ts | 91 +- apps/sim/lib/table/delete-runner.ts | 75 +- apps/sim/lib/table/service.ts | 60 +- .../0234_analyze_user_table_rows.sql | 9 + .../db/migrations/meta/0234_snapshot.json | 16429 ++++++++++++++++ packages/db/migrations/meta/_journal.json | 7 + 9 files changed, 16651 insertions(+), 51 deletions(-) create mode 100644 packages/db/migrations/0234_analyze_user_table_rows.sql create mode 100644 packages/db/migrations/meta/0234_snapshot.json diff --git a/apps/sim/app/api/table/[tableId]/delete-async/route.ts b/apps/sim/app/api/table/[tableId]/delete-async/route.ts index a322167dc89..7dcd8c37676 100644 --- a/apps/sim/app/api/table/[tableId]/delete-async/route.ts +++ b/apps/sim/app/api/table/[tableId]/delete-async/route.ts @@ -8,7 +8,7 @@ import { isTriggerDevEnabled } from '@/lib/core/config/feature-flags' import { runDetached } from '@/lib/core/utils/background' import { generateRequestId } from '@/lib/core/utils/request' import { withRouteHandler } from '@/lib/core/utils/with-route-handler' -import { runTableDelete } from '@/lib/table/delete-runner' +import { markTableDeleteFailed, runTableDelete } from '@/lib/table/delete-runner' import { markTableJobRunning, releaseJobClaim } from '@/lib/table/service' import type { TableDeleteJobPayload } from '@/lib/table/types' import { accessError, checkAccess, tableFilterError } from '@/app/api/table/utils' @@ -110,6 +110,10 @@ export const POST = withRouteHandler(async (request: NextRequest, { params }: Ro filter, excludeRowIds, cutoff, + }).catch(async (error) => { + // No retry machinery on the detached path — fail the job immediately. + await markTableDeleteFailed(tableId, jobId, error) + throw error }) ) } diff --git a/apps/sim/background/table-delete.ts b/apps/sim/background/table-delete.ts index 464e963fd49..f3ddb8e378c 100644 --- a/apps/sim/background/table-delete.ts +++ b/apps/sim/background/table-delete.ts @@ -1,5 +1,9 @@ import { task } from '@trigger.dev/sdk' -import { runTableDelete, type TableDeletePayload } from '@/lib/table/delete-runner' +import { + markTableDeleteFailed, + runTableDelete, + type TableDeletePayload, +} from '@/lib/table/delete-runner' /** * `TableDeletePayload` with the cutoff as an ISO string — task payloads cross a JSON boundary, so @@ -10,10 +14,12 @@ export interface TableDeleteTaskPayload extends Omit { await runTableDelete({ ...payload, cutoff: new Date(payload.cutoff) }) }, + onFailure: async ({ payload, error }) => { + await markTableDeleteFailed(payload.tableId, payload.jobId, error) + }, }) diff --git a/apps/sim/lib/table/constants.ts b/apps/sim/lib/table/constants.ts index 985dce4bf43..0a276f68a41 100644 --- a/apps/sim/lib/table/constants.ts +++ b/apps/sim/lib/table/constants.ts @@ -26,9 +26,9 @@ export const TABLE_LIMITS = { MAX_BULK_OPERATION_SIZE: 1000, /** Maximum rows a single clipboard copy/cut serializes; beyond this the user is steered to Export. */ MAX_COPY_ROWS: 50000, - /** Rows selected + deleted per page in the async background delete-job loop. Each page is one - * transaction (chunked into DELETE_BATCH_SIZE statements inside it); the page is also the - * cancel/ownership-check granularity. */ + /** Rows selected + deleted per page in the async background delete-job loop. Each + * DELETE_BATCH_SIZE chunk inside the page commits in its own transaction; the page is the + * keyset-select and cancel/ownership-check granularity. */ DELETE_PAGE_SIZE: 10000, /** Row count above which an export runs as a background job instead of a synchronous stream. * Matches the default per-table row cap, so non-enterprise tables keep instant downloads. */ diff --git a/apps/sim/lib/table/delete-runner.test.ts b/apps/sim/lib/table/delete-runner.test.ts index 85e956a8067..1259e76aa85 100644 --- a/apps/sim/lib/table/delete-runner.test.ts +++ b/apps/sim/lib/table/delete-runner.test.ts @@ -5,6 +5,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' const { mockGetTableById, + mockGetJobProgress, mockSelectRowIdPage, mockDeletePageByIds, mockUpdateJobProgress, @@ -14,6 +15,7 @@ const { mockBuildFilterClause, } = vi.hoisted(() => ({ mockGetTableById: vi.fn(), + mockGetJobProgress: vi.fn(), mockSelectRowIdPage: vi.fn(), mockDeletePageByIds: vi.fn(), mockUpdateJobProgress: vi.fn(), @@ -25,6 +27,7 @@ const { vi.mock('@/lib/table/service', () => ({ getTableById: mockGetTableById, + getJobProgress: mockGetJobProgress, selectRowIdPage: mockSelectRowIdPage, deletePageByIds: mockDeletePageByIds, updateJobProgress: mockUpdateJobProgress, @@ -38,7 +41,7 @@ vi.mock('@/lib/table/constants', () => ({ USER_TABLE_ROWS_SQL_NAME: 'user_table_rows', })) -import { runTableDelete } from '@/lib/table/delete-runner' +import { markTableDeleteFailed, runTableDelete } from '@/lib/table/delete-runner' const table = { id: 'tbl_1', workspaceId: 'ws_1', schema: { columns: [] } } const cutoff = new Date('2026-06-05T00:00:00Z') @@ -51,6 +54,7 @@ describe('runTableDelete', () => { beforeEach(() => { vi.clearAllMocks() mockGetTableById.mockResolvedValue(table) + mockGetJobProgress.mockResolvedValue(0) mockUpdateJobProgress.mockResolvedValue(true) mockMarkJobReady.mockResolvedValue(true) mockMarkJobFailed.mockResolvedValue(undefined) @@ -103,17 +107,57 @@ describe('runTableDelete', () => { ) }) - it('marks the job failed and emits a failed event on error', async () => { + it('rethrows unexpected errors without failing the job (caller retries decide)', async () => { mockSelectRowIdPage.mockRejectedValue(new Error('boom')) + await expect(runTableDelete(basePayload())).rejects.toThrow('boom') + + expect(mockMarkJobFailed).not.toHaveBeenCalled() + expect(mockAppendTableEvent).not.toHaveBeenCalledWith( + expect.objectContaining({ status: 'failed' }) + ) + }) + + it('returns quietly when superseded mid-run without failing the job', async () => { + mockSelectRowIdPage.mockResolvedValue(['a', 'b']) + mockUpdateJobProgress.mockResolvedValueOnce(true).mockResolvedValueOnce(false) + + await expect(runTableDelete(basePayload())).resolves.toBeUndefined() + + expect(mockMarkJobFailed).not.toHaveBeenCalled() + }) + + it('rethrows the root cause so the clean message survives serialization', async () => { + const cause = new Error('canceling statement due to statement timeout') + mockSelectRowIdPage.mockRejectedValue(new Error('Failed query: delete ...', { cause })) + + await expect(runTableDelete(basePayload())).rejects.toThrow( + 'canceling statement due to statement timeout' + ) + }) + + it('resumes cumulative progress on retry instead of resetting to zero', async () => { + mockGetJobProgress.mockResolvedValue(7) + mockSelectRowIdPage.mockResolvedValueOnce(['a', 'b']).mockResolvedValueOnce([]) + await runTableDelete(basePayload()) - expect(mockMarkJobFailed).toHaveBeenCalledWith('tbl_1', 'job_1', 'boom') + expect(mockUpdateJobProgress).toHaveBeenNthCalledWith(1, 'tbl_1', 7, 'job_1') expect(mockAppendTableEvent).toHaveBeenCalledWith( - expect.objectContaining({ kind: 'job', type: 'delete', status: 'failed', error: 'boom' }) + expect.objectContaining({ status: 'ready', progress: 9 }) ) }) + it('stops at the seed read when the job is no longer owned', async () => { + mockGetJobProgress.mockResolvedValue(null) + + await expect(runTableDelete(basePayload())).resolves.toBeUndefined() + + expect(mockSelectRowIdPage).not.toHaveBeenCalled() + expect(mockDeletePageByIds).not.toHaveBeenCalled() + expect(mockMarkJobFailed).not.toHaveBeenCalled() + }) + it('passes the cutoff and filter clause through to the page query', async () => { mockSelectRowIdPage.mockResolvedValueOnce([]) @@ -129,3 +173,42 @@ describe('runTableDelete', () => { ) }) }) + +describe('markTableDeleteFailed', () => { + beforeEach(() => { + vi.clearAllMocks() + mockMarkJobFailed.mockResolvedValue(undefined) + }) + + it('marks the job failed and emits the failed event', async () => { + await markTableDeleteFailed('tbl_1', 'job_1', new Error('boom')) + + expect(mockMarkJobFailed).toHaveBeenCalledWith('tbl_1', 'job_1', 'boom') + expect(mockAppendTableEvent).toHaveBeenCalledWith( + expect.objectContaining({ kind: 'job', type: 'delete', status: 'failed', error: 'boom' }) + ) + }) + + it('prefers the error cause over a verbose wrapper message', async () => { + const cause = new Error('canceling statement due to statement timeout') + const wrapper = new Error(`Failed query: delete from x where id in (${'$1,'.repeat(5000)})`, { + cause, + }) + + await markTableDeleteFailed('tbl_1', 'job_1', wrapper) + + expect(mockMarkJobFailed).toHaveBeenCalledWith( + 'tbl_1', + 'job_1', + 'canceling statement due to statement timeout' + ) + }) + + it('truncates oversized messages', async () => { + await markTableDeleteFailed('tbl_1', 'job_1', new Error('x'.repeat(2000))) + + const [, , message] = mockMarkJobFailed.mock.calls[0] + expect(message).toHaveLength(503) + expect(message.endsWith('...')).toBe(true) + }) +}) diff --git a/apps/sim/lib/table/delete-runner.ts b/apps/sim/lib/table/delete-runner.ts index 840345c9f4f..0065b60ba5a 100644 --- a/apps/sim/lib/table/delete-runner.ts +++ b/apps/sim/lib/table/delete-runner.ts @@ -1,11 +1,13 @@ import { createLogger } from '@sim/logger' -import { getErrorMessage } from '@sim/utils/errors' +import { getErrorMessage, toError } from '@sim/utils/errors' import { generateId } from '@sim/utils/id' +import { truncate } from '@sim/utils/string' import type { Filter } from '@/lib/table' import { TABLE_LIMITS, USER_TABLE_ROWS_SQL_NAME } from '@/lib/table/constants' import { appendTableEvent } from '@/lib/table/events' import { deletePageByIds, + getJobProgress, getTableById, markJobFailed, markJobReady, @@ -38,12 +40,17 @@ export interface TableDeletePayload { } /** - * Background worker for large filtered row deletes. Runs detached on the web container (see the - * delete-async kickoff route). Deletes in keyset-paginated pages — `created_at <= cutoff` spares - * rows inserted while the job runs, and `excludeRowIds` spares specific rows (the - * "select all then deselect a few" case). Ownership-gated per page so a cancel/supersede stops - * it within one page; committed pages are never rolled back. Progress and the terminal state are - * surfaced via the table-events SSE stream. + * Background worker for large filtered row deletes (trigger.dev task, or detached on the web + * container when trigger.dev is disabled — see the delete-async kickoff route). Deletes in + * keyset-paginated pages — `created_at <= cutoff` spares rows inserted while the job runs, and + * `excludeRowIds` spares specific rows (the "select all then deselect a few" case). + * Ownership-gated per page so a cancel/supersede stops it within one page; committed batches are + * never rolled back. Progress and the terminal state are surfaced via the table-events SSE + * stream. + * + * Unexpected errors are rethrown so the caller's retry machinery sees them — the caller marks + * the job failed via `markTableDeleteFailed` once it gives up. A superseded run (cancel, or a + * newer job took the table) returns quietly. */ export async function runTableDelete(payload: TableDeletePayload): Promise { const { jobId, tableId, workspaceId, filter, excludeRowIds, cutoff } = payload @@ -58,8 +65,14 @@ export async function runTableDelete(payload: TableDeletePayload): Promise : undefined const excluded = new Set(excludeRowIds ?? []) - let processed = 0 - let lastReported = 0 + // Resume the persisted count: a retried attempt's earlier batches are already committed, + // so starting at zero would overwrite cumulative progress with this attempt's smaller + // number. Doubles as the initial ownership gate. + const resumed = await getJobProgress(tableId, jobId) + if (resumed === null) throw new JobSupersededError() + + let processed = resumed + let lastReported = resumed let afterId: string | undefined while (true) { @@ -128,19 +141,37 @@ export async function runTableDelete(payload: TableDeletePayload): Promise } catch (err) { if (err instanceof JobSupersededError) { logger.info(`[${requestId}] Delete superseded by a newer run; stopping`, { tableId, jobId }) - } else { - const message = getErrorMessage(err, 'Delete failed') - logger.error(`[${requestId}] Delete failed for table ${tableId}:`, err) - // Scoped to jobId — a no-op if a newer job has taken over. - await markJobFailed(tableId, jobId, message).catch(() => {}) - void appendTableEvent({ - kind: 'job', - type: 'delete', - tableId, - jobId, - status: 'failed', - error: message, - }) + return } + // Rethrow the root cause, not the wrapper: drizzle query errors embed the full SQL + params + // list (tens of KB for a batch delete) in `message`, and `cause` does not survive + // trigger.dev's serialization between the failed `run` and `onFailure` — the clean message + // must already be the thrown error's own `message`. + const cause = toError(err).cause + const error = cause ? toError(cause) : toError(err) + logger.error(`[${requestId}] Delete failed for table ${tableId}:`, error) + throw error } } + +/** + * Marks the delete job failed and emits the failed SSE event. Called once the caller gives up on + * the run: the trigger.dev task's `onFailure` (after retries are exhausted) or the detached + * web-container fallback (no retries). Scoped to jobId — a no-op if a newer job has taken over. + */ +export async function markTableDeleteFailed( + tableId: string, + jobId: string, + error: unknown +): Promise { + const message = truncate(getErrorMessage(toError(error).cause ?? error, 'Delete failed'), 500) + await markJobFailed(tableId, jobId, message).catch(() => {}) + void appendTableEvent({ + kind: 'job', + type: 'delete', + tableId, + jobId, + status: 'failed', + error: message, + }) +} diff --git a/apps/sim/lib/table/service.ts b/apps/sim/lib/table/service.ts index 7d2757450d9..2c526fa9b2d 100644 --- a/apps/sim/lib/table/service.ts +++ b/apps/sim/lib/table/service.ts @@ -1577,11 +1577,8 @@ async function deleteOrderedRowsByIds(params: { tableId: string workspaceId: string rowIds: string[] - /** Skip the post-delete position recompaction (the paginated delete worker compacts once at - * the end instead of per page — per-page compaction is O(N) each, O(N²) over a full delete). */ - skipCompaction?: boolean }): Promise<{ id: string; position: number }[]> { - const { tableId, workspaceId, rowIds, skipCompaction = false } = params + const { tableId, workspaceId, rowIds } = params if (rowIds.length === 0) return [] return db.transaction(async (trx) => { await setTableTxTimeouts(trx, { statementMs: 60_000 }) @@ -1601,7 +1598,7 @@ async function deleteOrderedRowsByIds(params: { deleted.push(...rows) } // Fractional ordering: deletes leave order_key untouched, so no recompaction. - if (!isTablesFractionalOrderingEnabled && !skipCompaction && deleted.length > 0) { + if (!isTablesFractionalOrderingEnabled && deleted.length > 0) { const minDeletedPos = deleted.reduce( (min, r) => (r.position < min ? r.position : min), deleted[0].position @@ -1652,23 +1649,39 @@ export async function selectRowIdPage(params: { } /** - * Deletes one page of rows by id (the statement-level row_count trigger fires once). Skips legacy - * position compaction: under fractional ordering it's unnecessary (order keys are authoritative), - * and in the legacy path a bulk delete leaving `position` gaps is harmless — rows still order by - * position. (Compacting per page would be O(N²) over a full delete.) Returns the count deleted. + * Deletes one page of rows for the async delete-job worker, committing each `DELETE_BATCH_SIZE` + * chunk in its own short transaction. One statement per transaction bounds how long the + * statement-level row_count trigger's lock on the definition row is held (a page-wide transaction + * held it for the entire page, starving concurrent inserts and overrunning `statement_timeout`), + * and a mid-page failure loses at most one uncommitted batch — the keyset walker (or a task + * retry) re-walks whatever remains. Skips legacy position compaction: under fractional ordering + * it's unnecessary, and in the legacy path `position` gaps are harmless — rows still order by + * position. Returns the count deleted. */ export async function deletePageByIds( tableId: string, workspaceId: string, rowIds: string[] ): Promise { - const deleted = await deleteOrderedRowsByIds({ - tableId, - workspaceId, - rowIds, - skipCompaction: true, - }) - return deleted.length + let deleted = 0 + for (let i = 0; i < rowIds.length; i += TABLE_LIMITS.DELETE_BATCH_SIZE) { + const batch = rowIds.slice(i, i + TABLE_LIMITS.DELETE_BATCH_SIZE) + const rows = await db.transaction(async (trx) => { + await setTableTxTimeouts(trx, { statementMs: 60_000 }) + return trx + .delete(userTableRows) + .where( + and( + eq(userTableRows.tableId, tableId), + eq(userTableRows.workspaceId, workspaceId), + inArray(userTableRows.id, batch) + ) + ) + .returning({ id: userTableRows.id }) + }) + deleted += rows.length + } + return deleted } /** @@ -2078,6 +2091,21 @@ export async function updateJobProgress( return updated.length > 0 } +/** + * Reads the persisted progress of an in-flight job this worker still owns (`null` when the job + * was canceled/superseded). A retried run seeds its counter from this so progress stays + * cumulative — earlier attempts' batches are already committed, and restarting from zero would + * clobber `rows_processed` (and every count derived from it) with the retry's smaller number. + */ +export async function getJobProgress(tableId: string, jobId: string): Promise { + const [job] = await db + .select({ rowsProcessed: tableJobs.rowsProcessed }) + .from(tableJobs) + .where(ownsActiveJob(tableId, jobId)) + .limit(1) + return job ? job.rowsProcessed : null +} + /** * One keyset page of rows for the export worker, ordered by `(position, id)`. Keyset (not * OFFSET) keeps each page O(page) — offset paging re-scans every prior row per page, which is diff --git a/packages/db/migrations/0234_analyze_user_table_rows.sql b/packages/db/migrations/0234_analyze_user_table_rows.sql new file mode 100644 index 00000000000..4d14dd00e7c --- /dev/null +++ b/packages/db/migrations/0234_analyze_user_table_rows.sql @@ -0,0 +1,9 @@ +-- Guard for the reltuples corruption hit on staging (2026-06-12): the CREATE INDEX +-- CONCURRENTLY builds in 0233 left pg_class.reltuples = Infinity on user_table_rows +-- (PG 18.4, build ran under concurrent write churn). Infinity reltuples makes every +-- plan on the relation cost NaN and simultaneously disables autovacuum's self-repair — +-- its trigger threshold is base + scale_factor * reltuples = Infinity, so no churn can +-- ever trip an autoanalyze. ANALYZE rewrites reltuples from a fresh sample, restoring +-- sane plans and re-arming autovacuum. Cheap (~7s at 7M rows) and idempotent, so it is +-- safe on databases that never hit the corruption. +ANALYZE user_table_rows; diff --git a/packages/db/migrations/meta/0234_snapshot.json b/packages/db/migrations/meta/0234_snapshot.json new file mode 100644 index 00000000000..117b827b0d9 --- /dev/null +++ b/packages/db/migrations/meta/0234_snapshot.json @@ -0,0 +1,16429 @@ +{ + "id": "1b5c6d3b-c583-4283-a19d-3ebb59757c63", + "prevId": "4fa1cade-ac70-4e8e-9f1c-e3ce66ffad36", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.a2a_agent": { + "name": "a2a_agent", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'1.0.0'" + }, + "capabilities": { + "name": "capabilities", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "skills": { + "name": "skills", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'" + }, + "authentication": { + "name": "authentication", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "signatures": { + "name": "signatures", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'" + }, + "is_published": { + "name": "is_published", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "a2a_agent_workflow_id_idx": { + "name": "a2a_agent_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_agent_created_by_idx": { + "name": "a2a_agent_created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_agent_workspace_workflow_unique": { + "name": "a2a_agent_workspace_workflow_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"a2a_agent\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_agent_archived_at_idx": { + "name": "a2a_agent_archived_at_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_agent_workspace_archived_partial_idx": { + "name": "a2a_agent_workspace_archived_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"a2a_agent\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "a2a_agent_workspace_id_workspace_id_fk": { + "name": "a2a_agent_workspace_id_workspace_id_fk", + "tableFrom": "a2a_agent", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "a2a_agent_workflow_id_workflow_id_fk": { + "name": "a2a_agent_workflow_id_workflow_id_fk", + "tableFrom": "a2a_agent", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "a2a_agent_created_by_user_id_fk": { + "name": "a2a_agent_created_by_user_id_fk", + "tableFrom": "a2a_agent", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.a2a_push_notification_config": { + "name": "a2a_push_notification_config", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auth_schemes": { + "name": "auth_schemes", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'" + }, + "auth_credentials": { + "name": "auth_credentials", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "a2a_push_notification_config_task_unique": { + "name": "a2a_push_notification_config_task_unique", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "a2a_push_notification_config_task_id_a2a_task_id_fk": { + "name": "a2a_push_notification_config_task_id_a2a_task_id_fk", + "tableFrom": "a2a_push_notification_config", + "tableTo": "a2a_task", + "columnsFrom": ["task_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.a2a_task": { + "name": "a2a_task", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "a2a_task_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'submitted'" + }, + "messages": { + "name": "messages", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'" + }, + "artifacts": { + "name": "artifacts", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'" + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "a2a_task_agent_id_idx": { + "name": "a2a_task_agent_id_idx", + "columns": [ + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_task_session_id_idx": { + "name": "a2a_task_session_id_idx", + "columns": [ + { + "expression": "session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_task_status_idx": { + "name": "a2a_task_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_task_execution_id_idx": { + "name": "a2a_task_execution_id_idx", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "a2a_task_created_at_idx": { + "name": "a2a_task_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "a2a_task_agent_id_a2a_agent_id_fk": { + "name": "a2a_task_agent_id_a2a_agent_id_fk", + "tableFrom": "a2a_task", + "tableTo": "a2a_agent", + "columnsFrom": ["agent_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.academy_certificate": { + "name": "academy_certificate", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "course_id": { + "name": "course_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "academy_cert_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "issued_at": { + "name": "issued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "certificate_number": { + "name": "certificate_number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "academy_certificate_user_id_idx": { + "name": "academy_certificate_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "academy_certificate_course_id_idx": { + "name": "academy_certificate_course_id_idx", + "columns": [ + { + "expression": "course_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "academy_certificate_user_course_unique": { + "name": "academy_certificate_user_course_unique", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "course_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "academy_certificate_number_idx": { + "name": "academy_certificate_number_idx", + "columns": [ + { + "expression": "certificate_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "academy_certificate_status_idx": { + "name": "academy_certificate_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "academy_certificate_user_id_user_id_fk": { + "name": "academy_certificate_user_id_user_id_fk", + "tableFrom": "academy_certificate", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "academy_certificate_certificate_number_unique": { + "name": "academy_certificate_certificate_number_unique", + "nullsNotDistinct": false, + "columns": ["certificate_number"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "account_user_id_idx": { + "name": "account_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_account_on_account_id_provider_id": { + "name": "idx_account_on_account_id_provider_id", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.api_key": { + "name": "api_key", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key_hash": { + "name": "key_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'personal'" + }, + "last_used": { + "name": "last_used", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "api_key_workspace_type_idx": { + "name": "api_key_workspace_type_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "api_key_user_type_idx": { + "name": "api_key_user_type_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "api_key_key_hash_idx": { + "name": "api_key_key_hash_idx", + "columns": [ + { + "expression": "key_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "api_key_user_id_user_id_fk": { + "name": "api_key_user_id_user_id_fk", + "tableFrom": "api_key", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_key_workspace_id_workspace_id_fk": { + "name": "api_key_workspace_id_workspace_id_fk", + "tableFrom": "api_key", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "api_key_created_by_user_id_fk": { + "name": "api_key_created_by_user_id_fk", + "tableFrom": "api_key", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "api_key_key_unique": { + "name": "api_key_key_unique", + "nullsNotDistinct": false, + "columns": ["key"] + } + }, + "policies": {}, + "checkConstraints": { + "workspace_type_check": { + "name": "workspace_type_check", + "value": "(type = 'workspace' AND workspace_id IS NOT NULL) OR (type = 'personal' AND workspace_id IS NULL)" + } + }, + "isRLSEnabled": false + }, + "public.async_jobs": { + "name": "async_jobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "run_at": { + "name": "run_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "max_attempts": { + "name": "max_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 3 + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "output": { + "name": "output", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "async_jobs_status_started_at_idx": { + "name": "async_jobs_status_started_at_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "async_jobs_status_completed_at_idx": { + "name": "async_jobs_status_completed_at_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "completed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "async_jobs_schedule_pending_run_at_idx": { + "name": "async_jobs_schedule_pending_run_at_idx", + "columns": [ + { + "expression": "run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"async_jobs\".\"type\" = 'schedule-execution' AND \"async_jobs\".\"status\" = 'pending'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "async_jobs_schedule_processing_started_at_idx": { + "name": "async_jobs_schedule_processing_started_at_idx", + "columns": [ + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"async_jobs\".\"type\" = 'schedule-execution' AND \"async_jobs\".\"status\" = 'processing'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_log": { + "name": "audit_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_id": { + "name": "actor_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resource_type": { + "name": "resource_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resource_id": { + "name": "resource_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_name": { + "name": "actor_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_email": { + "name": "actor_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resource_name": { + "name": "resource_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "audit_log_workspace_created_idx": { + "name": "audit_log_workspace_created_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "audit_log_workspace_created_at_id_idx": { + "name": "audit_log_workspace_created_at_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date_trunc('milliseconds', \"created_at\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "audit_log_actor_created_idx": { + "name": "audit_log_actor_created_idx", + "columns": [ + { + "expression": "actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "audit_log_resource_idx": { + "name": "audit_log_resource_idx", + "columns": [ + { + "expression": "resource_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "resource_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "audit_log_action_idx": { + "name": "audit_log_action_idx", + "columns": [ + { + "expression": "action", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "audit_log_workspace_id_workspace_id_fk": { + "name": "audit_log_workspace_id_workspace_id_fk", + "tableFrom": "audit_log", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "audit_log_actor_id_user_id_fk": { + "name": "audit_log_actor_id_user_id_fk", + "tableFrom": "audit_log", + "tableTo": "user", + "columnsFrom": ["actor_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chat": { + "name": "chat", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "customizations": { + "name": "customizations", + "type": "json", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "auth_type": { + "name": "auth_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'public'" + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "allowed_emails": { + "name": "allowed_emails", + "type": "json", + "primaryKey": false, + "notNull": false, + "default": "'[]'" + }, + "output_configs": { + "name": "output_configs", + "type": "json", + "primaryKey": false, + "notNull": false, + "default": "'[]'" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "identifier_idx": { + "name": "identifier_idx", + "columns": [ + { + "expression": "identifier", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"chat\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "chat_archived_at_partial_idx": { + "name": "chat_archived_at_partial_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"chat\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_chat_on_workflow_id_archived_at": { + "name": "idx_chat_on_workflow_id_archived_at", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "chat_workflow_id_workflow_id_fk": { + "name": "chat_workflow_id_workflow_id_fk", + "tableFrom": "chat", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chat_user_id_user_id_fk": { + "name": "chat_user_id_user_id_fk", + "tableFrom": "chat", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_async_tool_calls": { + "name": "copilot_async_tool_calls", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "checkpoint_id": { + "name": "checkpoint_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "tool_call_id": { + "name": "tool_call_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool_name": { + "name": "tool_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "args": { + "name": "args", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "status": { + "name": "status", + "type": "copilot_async_tool_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "result": { + "name": "result", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copilot_async_tool_calls_run_id_idx": { + "name": "copilot_async_tool_calls_run_id_idx", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_async_tool_calls_checkpoint_id_idx": { + "name": "copilot_async_tool_calls_checkpoint_id_idx", + "columns": [ + { + "expression": "checkpoint_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_async_tool_calls_tool_call_id_idx": { + "name": "copilot_async_tool_calls_tool_call_id_idx", + "columns": [ + { + "expression": "tool_call_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_async_tool_calls_status_idx": { + "name": "copilot_async_tool_calls_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_async_tool_calls_run_status_idx": { + "name": "copilot_async_tool_calls_run_status_idx", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_async_tool_calls_tool_call_id_unique": { + "name": "copilot_async_tool_calls_tool_call_id_unique", + "columns": [ + { + "expression": "tool_call_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_async_tool_calls_run_id_copilot_runs_id_fk": { + "name": "copilot_async_tool_calls_run_id_copilot_runs_id_fk", + "tableFrom": "copilot_async_tool_calls", + "tableTo": "copilot_runs", + "columnsFrom": ["run_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_async_tool_calls_checkpoint_id_copilot_run_checkpoints_id_fk": { + "name": "copilot_async_tool_calls_checkpoint_id_copilot_run_checkpoints_id_fk", + "tableFrom": "copilot_async_tool_calls", + "tableTo": "copilot_run_checkpoints", + "columnsFrom": ["checkpoint_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_chats": { + "name": "copilot_chats", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "chat_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'copilot'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'claude-3-7-sonnet-latest'" + }, + "conversation_id": { + "name": "conversation_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "preview_yaml": { + "name": "preview_yaml", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plan_artifact": { + "name": "plan_artifact", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "resources": { + "name": "resources", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "pinned": { + "name": "pinned", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copilot_chats_user_id_idx": { + "name": "copilot_chats_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_chats_workflow_id_idx": { + "name": "copilot_chats_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_chats_user_workflow_idx": { + "name": "copilot_chats_user_workflow_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_chats_user_workspace_idx": { + "name": "copilot_chats_user_workspace_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_chats_created_at_idx": { + "name": "copilot_chats_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_chats_updated_at_idx": { + "name": "copilot_chats_updated_at_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_chats_workspace_created_at_id_idx": { + "name": "copilot_chats_workspace_created_at_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date_trunc('milliseconds', \"created_at\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_chats_user_id_user_id_fk": { + "name": "copilot_chats_user_id_user_id_fk", + "tableFrom": "copilot_chats", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_chats_workflow_id_workflow_id_fk": { + "name": "copilot_chats_workflow_id_workflow_id_fk", + "tableFrom": "copilot_chats", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_chats_workspace_id_workspace_id_fk": { + "name": "copilot_chats_workspace_id_workspace_id_fk", + "tableFrom": "copilot_chats", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_feedback": { + "name": "copilot_feedback", + "schema": "", + "columns": { + "feedback_id": { + "name": "feedback_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_query": { + "name": "user_query", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_response": { + "name": "agent_response", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "is_positive": { + "name": "is_positive", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "feedback": { + "name": "feedback", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workflow_yaml": { + "name": "workflow_yaml", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copilot_feedback_user_id_idx": { + "name": "copilot_feedback_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_feedback_chat_id_idx": { + "name": "copilot_feedback_chat_id_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_feedback_user_chat_idx": { + "name": "copilot_feedback_user_chat_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_feedback_is_positive_idx": { + "name": "copilot_feedback_is_positive_idx", + "columns": [ + { + "expression": "is_positive", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_feedback_created_at_idx": { + "name": "copilot_feedback_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_feedback_user_id_user_id_fk": { + "name": "copilot_feedback_user_id_user_id_fk", + "tableFrom": "copilot_feedback", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_feedback_chat_id_copilot_chats_id_fk": { + "name": "copilot_feedback_chat_id_copilot_chats_id_fk", + "tableFrom": "copilot_feedback", + "tableTo": "copilot_chats", + "columnsFrom": ["chat_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_messages": { + "name": "copilot_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "stream_id": { + "name": "stream_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "parent_message_id": { + "name": "parent_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tokens_in": { + "name": "tokens_in", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "tokens_out": { + "name": "tokens_out", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "seq": { + "name": "seq", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copilot_messages_chat_message_unique": { + "name": "copilot_messages_chat_message_unique", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_messages_chat_created_at_idx": { + "name": "copilot_messages_chat_created_at_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"copilot_messages\".\"deleted_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_messages_chat_seq_idx": { + "name": "copilot_messages_chat_seq_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "seq", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"copilot_messages\".\"deleted_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_messages_chat_stream_idx": { + "name": "copilot_messages_chat_stream_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "stream_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"copilot_messages\".\"stream_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_messages_chat_id_copilot_chats_id_fk": { + "name": "copilot_messages_chat_id_copilot_chats_id_fk", + "tableFrom": "copilot_messages", + "tableTo": "copilot_chats", + "columnsFrom": ["chat_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_run_checkpoints": { + "name": "copilot_run_checkpoints", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "pending_tool_call_id": { + "name": "pending_tool_call_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "conversation_snapshot": { + "name": "conversation_snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "agent_state": { + "name": "agent_state", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "provider_request": { + "name": "provider_request", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copilot_run_checkpoints_run_id_idx": { + "name": "copilot_run_checkpoints_run_id_idx", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_run_checkpoints_pending_tool_call_id_idx": { + "name": "copilot_run_checkpoints_pending_tool_call_id_idx", + "columns": [ + { + "expression": "pending_tool_call_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_run_checkpoints_run_pending_tool_unique": { + "name": "copilot_run_checkpoints_run_pending_tool_unique", + "columns": [ + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "pending_tool_call_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_run_checkpoints_run_id_copilot_runs_id_fk": { + "name": "copilot_run_checkpoints_run_id_copilot_runs_id_fk", + "tableFrom": "copilot_run_checkpoints", + "tableTo": "copilot_runs", + "columnsFrom": ["run_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_runs": { + "name": "copilot_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_run_id": { + "name": "parent_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stream_id": { + "name": "stream_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent": { + "name": "agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "copilot_run_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "request_context": { + "name": "request_context", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "copilot_runs_execution_id_idx": { + "name": "copilot_runs_execution_id_idx", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_parent_run_id_idx": { + "name": "copilot_runs_parent_run_id_idx", + "columns": [ + { + "expression": "parent_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_chat_id_idx": { + "name": "copilot_runs_chat_id_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_user_id_idx": { + "name": "copilot_runs_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_workflow_id_idx": { + "name": "copilot_runs_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_workspace_id_idx": { + "name": "copilot_runs_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_status_idx": { + "name": "copilot_runs_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_chat_execution_idx": { + "name": "copilot_runs_chat_execution_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_execution_started_at_idx": { + "name": "copilot_runs_execution_started_at_idx", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_workspace_completed_at_id_idx": { + "name": "copilot_runs_workspace_completed_at_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date_trunc('milliseconds', \"completed_at\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_runs_stream_id_unique": { + "name": "copilot_runs_stream_id_unique", + "columns": [ + { + "expression": "stream_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_runs_chat_id_copilot_chats_id_fk": { + "name": "copilot_runs_chat_id_copilot_chats_id_fk", + "tableFrom": "copilot_runs", + "tableTo": "copilot_chats", + "columnsFrom": ["chat_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_runs_user_id_user_id_fk": { + "name": "copilot_runs_user_id_user_id_fk", + "tableFrom": "copilot_runs", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_runs_workflow_id_workflow_id_fk": { + "name": "copilot_runs_workflow_id_workflow_id_fk", + "tableFrom": "copilot_runs", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_runs_workspace_id_workspace_id_fk": { + "name": "copilot_runs_workspace_id_workspace_id_fk", + "tableFrom": "copilot_runs", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.copilot_workflow_read_hashes": { + "name": "copilot_workflow_read_hashes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "hash": { + "name": "hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "copilot_workflow_read_hashes_chat_id_idx": { + "name": "copilot_workflow_read_hashes_chat_id_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_workflow_read_hashes_workflow_id_idx": { + "name": "copilot_workflow_read_hashes_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "copilot_workflow_read_hashes_chat_workflow_unique": { + "name": "copilot_workflow_read_hashes_chat_workflow_unique", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "copilot_workflow_read_hashes_chat_id_copilot_chats_id_fk": { + "name": "copilot_workflow_read_hashes_chat_id_copilot_chats_id_fk", + "tableFrom": "copilot_workflow_read_hashes", + "tableTo": "copilot_chats", + "columnsFrom": ["chat_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "copilot_workflow_read_hashes_workflow_id_workflow_id_fk": { + "name": "copilot_workflow_read_hashes_workflow_id_workflow_id_fk", + "tableFrom": "copilot_workflow_read_hashes", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credential": { + "name": "credential", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "credential_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "env_key": { + "name": "env_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "env_owner_user_id": { + "name": "env_owner_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "encrypted_service_account_key": { + "name": "encrypted_service_account_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credential_workspace_id_idx": { + "name": "credential_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_type_idx": { + "name": "credential_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_provider_id_idx": { + "name": "credential_provider_id_idx", + "columns": [ + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_account_id_idx": { + "name": "credential_account_id_idx", + "columns": [ + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_env_owner_user_id_idx": { + "name": "credential_env_owner_user_id_idx", + "columns": [ + { + "expression": "env_owner_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_workspace_account_unique": { + "name": "credential_workspace_account_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "account_id IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_workspace_env_unique": { + "name": "credential_workspace_env_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "env_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "type = 'env_workspace'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_workspace_personal_env_unique": { + "name": "credential_workspace_personal_env_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "env_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "env_owner_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "type = 'env_personal'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credential_workspace_id_workspace_id_fk": { + "name": "credential_workspace_id_workspace_id_fk", + "tableFrom": "credential", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_account_id_account_id_fk": { + "name": "credential_account_id_account_id_fk", + "tableFrom": "credential", + "tableTo": "account", + "columnsFrom": ["account_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_env_owner_user_id_user_id_fk": { + "name": "credential_env_owner_user_id_user_id_fk", + "tableFrom": "credential", + "tableTo": "user", + "columnsFrom": ["env_owner_user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_created_by_user_id_fk": { + "name": "credential_created_by_user_id_fk", + "tableFrom": "credential", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "credential_oauth_source_check": { + "name": "credential_oauth_source_check", + "value": "(type <> 'oauth') OR (account_id IS NOT NULL AND provider_id IS NOT NULL)" + }, + "credential_workspace_env_source_check": { + "name": "credential_workspace_env_source_check", + "value": "(type <> 'env_workspace') OR (env_key IS NOT NULL AND env_owner_user_id IS NULL)" + }, + "credential_personal_env_source_check": { + "name": "credential_personal_env_source_check", + "value": "(type <> 'env_personal') OR (env_key IS NOT NULL AND env_owner_user_id IS NOT NULL)" + } + }, + "isRLSEnabled": false + }, + "public.credential_member": { + "name": "credential_member", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "credential_id": { + "name": "credential_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "credential_member_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "status": { + "name": "status", + "type": "credential_member_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "joined_at": { + "name": "joined_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credential_member_user_id_idx": { + "name": "credential_member_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_member_role_idx": { + "name": "credential_member_role_idx", + "columns": [ + { + "expression": "role", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_member_status_idx": { + "name": "credential_member_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_member_unique": { + "name": "credential_member_unique", + "columns": [ + { + "expression": "credential_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credential_member_credential_id_credential_id_fk": { + "name": "credential_member_credential_id_credential_id_fk", + "tableFrom": "credential_member", + "tableTo": "credential", + "columnsFrom": ["credential_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_member_user_id_user_id_fk": { + "name": "credential_member_user_id_user_id_fk", + "tableFrom": "credential_member", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_member_invited_by_user_id_fk": { + "name": "credential_member_invited_by_user_id_fk", + "tableFrom": "credential_member", + "tableTo": "user", + "columnsFrom": ["invited_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credential_set": { + "name": "credential_set", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credential_set_created_by_idx": { + "name": "credential_set_created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_set_org_name_unique": { + "name": "credential_set_org_name_unique", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_set_provider_id_idx": { + "name": "credential_set_provider_id_idx", + "columns": [ + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credential_set_organization_id_organization_id_fk": { + "name": "credential_set_organization_id_organization_id_fk", + "tableFrom": "credential_set", + "tableTo": "organization", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_set_created_by_user_id_fk": { + "name": "credential_set_created_by_user_id_fk", + "tableFrom": "credential_set", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credential_set_invitation": { + "name": "credential_set_invitation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "credential_set_id": { + "name": "credential_set_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "credential_set_invitation_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "accepted_at": { + "name": "accepted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "accepted_by_user_id": { + "name": "accepted_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credential_set_invitation_set_id_idx": { + "name": "credential_set_invitation_set_id_idx", + "columns": [ + { + "expression": "credential_set_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_set_invitation_token_idx": { + "name": "credential_set_invitation_token_idx", + "columns": [ + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_set_invitation_status_idx": { + "name": "credential_set_invitation_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_set_invitation_expires_at_idx": { + "name": "credential_set_invitation_expires_at_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credential_set_invitation_credential_set_id_credential_set_id_fk": { + "name": "credential_set_invitation_credential_set_id_credential_set_id_fk", + "tableFrom": "credential_set_invitation", + "tableTo": "credential_set", + "columnsFrom": ["credential_set_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_set_invitation_invited_by_user_id_fk": { + "name": "credential_set_invitation_invited_by_user_id_fk", + "tableFrom": "credential_set_invitation", + "tableTo": "user", + "columnsFrom": ["invited_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_set_invitation_accepted_by_user_id_user_id_fk": { + "name": "credential_set_invitation_accepted_by_user_id_user_id_fk", + "tableFrom": "credential_set_invitation", + "tableTo": "user", + "columnsFrom": ["accepted_by_user_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "credential_set_invitation_token_unique": { + "name": "credential_set_invitation_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.credential_set_member": { + "name": "credential_set_member", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "credential_set_id": { + "name": "credential_set_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "credential_set_member_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "joined_at": { + "name": "joined_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "credential_set_member_user_id_idx": { + "name": "credential_set_member_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_set_member_unique": { + "name": "credential_set_member_unique", + "columns": [ + { + "expression": "credential_set_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "credential_set_member_status_idx": { + "name": "credential_set_member_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "credential_set_member_credential_set_id_credential_set_id_fk": { + "name": "credential_set_member_credential_set_id_credential_set_id_fk", + "tableFrom": "credential_set_member", + "tableTo": "credential_set", + "columnsFrom": ["credential_set_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_set_member_user_id_user_id_fk": { + "name": "credential_set_member_user_id_user_id_fk", + "tableFrom": "credential_set_member", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "credential_set_member_invited_by_user_id_fk": { + "name": "credential_set_member_invited_by_user_id_fk", + "tableFrom": "credential_set_member", + "tableTo": "user", + "columnsFrom": ["invited_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.custom_tools": { + "name": "custom_tools", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "schema": { + "name": "schema", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "custom_tools_workspace_id_idx": { + "name": "custom_tools_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "custom_tools_workspace_title_unique": { + "name": "custom_tools_workspace_title_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "title", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "custom_tools_workspace_id_workspace_id_fk": { + "name": "custom_tools_workspace_id_workspace_id_fk", + "tableFrom": "custom_tools", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "custom_tools_user_id_user_id_fk": { + "name": "custom_tools_user_id_user_id_fk", + "tableFrom": "custom_tools", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.data_drain_runs": { + "name": "data_drain_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "drain_id": { + "name": "drain_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "data_drain_run_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "data_drain_run_trigger", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "rows_exported": { + "name": "rows_exported", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "bytes_written": { + "name": "bytes_written", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "cursor_before": { + "name": "cursor_before", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cursor_after": { + "name": "cursor_after", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "locators": { + "name": "locators", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + } + }, + "indexes": { + "data_drain_runs_drain_started_idx": { + "name": "data_drain_runs_drain_started_idx", + "columns": [ + { + "expression": "drain_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "data_drain_runs_drain_id_data_drains_id_fk": { + "name": "data_drain_runs_drain_id_data_drains_id_fk", + "tableFrom": "data_drain_runs", + "tableTo": "data_drains", + "columnsFrom": ["drain_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.data_drains": { + "name": "data_drains", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "data_drain_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "destination_type": { + "name": "destination_type", + "type": "data_drain_destination", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "destination_config": { + "name": "destination_config", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "destination_credentials": { + "name": "destination_credentials", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "schedule_cadence": { + "name": "schedule_cadence", + "type": "data_drain_cadence", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "cursor": { + "name": "cursor", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_run_at": { + "name": "last_run_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_success_at": { + "name": "last_success_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "data_drains_org_idx": { + "name": "data_drains_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "data_drains_due_idx": { + "name": "data_drains_due_idx", + "columns": [ + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "data_drains_org_name_unique": { + "name": "data_drains_org_name_unique", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "data_drains_organization_id_organization_id_fk": { + "name": "data_drains_organization_id_organization_id_fk", + "tableFrom": "data_drains", + "tableTo": "organization", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "data_drains_created_by_user_id_fk": { + "name": "data_drains_created_by_user_id_fk", + "tableFrom": "data_drains", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.docs_embeddings": { + "name": "docs_embeddings", + "schema": "", + "columns": { + "chunk_id": { + "name": "chunk_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "chunk_text": { + "name": "chunk_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_document": { + "name": "source_document", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_link": { + "name": "source_link", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "header_text": { + "name": "header_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "header_level": { + "name": "header_level", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token_count": { + "name": "token_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "embedding": { + "name": "embedding", + "type": "vector(1536)", + "primaryKey": false, + "notNull": true + }, + "embedding_model": { + "name": "embedding_model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'text-embedding-3-small'" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "chunk_text_tsv": { + "name": "chunk_text_tsv", + "type": "tsvector", + "primaryKey": false, + "notNull": false, + "generated": { + "as": "to_tsvector('english', \"docs_embeddings\".\"chunk_text\")", + "type": "stored" + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "docs_emb_source_document_idx": { + "name": "docs_emb_source_document_idx", + "columns": [ + { + "expression": "source_document", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "docs_emb_header_level_idx": { + "name": "docs_emb_header_level_idx", + "columns": [ + { + "expression": "header_level", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "docs_emb_source_header_idx": { + "name": "docs_emb_source_header_idx", + "columns": [ + { + "expression": "source_document", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "header_level", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "docs_emb_model_idx": { + "name": "docs_emb_model_idx", + "columns": [ + { + "expression": "embedding_model", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "docs_emb_created_at_idx": { + "name": "docs_emb_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "docs_embedding_vector_hnsw_idx": { + "name": "docs_embedding_vector_hnsw_idx", + "columns": [ + { + "expression": "embedding", + "isExpression": false, + "asc": true, + "nulls": "last", + "opclass": "vector_cosine_ops" + } + ], + "isUnique": false, + "concurrently": false, + "method": "hnsw", + "with": { + "m": 16, + "ef_construction": 64 + } + }, + "docs_emb_metadata_gin_idx": { + "name": "docs_emb_metadata_gin_idx", + "columns": [ + { + "expression": "metadata", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + }, + "docs_emb_chunk_text_fts_idx": { + "name": "docs_emb_chunk_text_fts_idx", + "columns": [ + { + "expression": "chunk_text_tsv", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "docs_embedding_not_null_check": { + "name": "docs_embedding_not_null_check", + "value": "\"embedding\" IS NOT NULL" + }, + "docs_header_level_check": { + "name": "docs_header_level_check", + "value": "\"header_level\" >= 1 AND \"header_level\" <= 6" + } + }, + "isRLSEnabled": false + }, + "public.document": { + "name": "document", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "knowledge_base_id": { + "name": "knowledge_base_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_url": { + "name": "file_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "file_size": { + "name": "file_size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chunk_count": { + "name": "chunk_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "token_count": { + "name": "token_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "character_count": { + "name": "character_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "processing_status": { + "name": "processing_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "processing_started_at": { + "name": "processing_started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "processing_completed_at": { + "name": "processing_completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "processing_error": { + "name": "processing_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "user_excluded": { + "name": "user_excluded", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "tag1": { + "name": "tag1", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag2": { + "name": "tag2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag3": { + "name": "tag3", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag4": { + "name": "tag4", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag5": { + "name": "tag5", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag6": { + "name": "tag6", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag7": { + "name": "tag7", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "number1": { + "name": "number1", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number2": { + "name": "number2", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number3": { + "name": "number3", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number4": { + "name": "number4", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number5": { + "name": "number5", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "date1": { + "name": "date1", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "date2": { + "name": "date2", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "boolean1": { + "name": "boolean1", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "boolean2": { + "name": "boolean2", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "boolean3": { + "name": "boolean3", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "connector_id": { + "name": "connector_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content_hash": { + "name": "content_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_url": { + "name": "source_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "uploaded_at": { + "name": "uploaded_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "doc_kb_id_idx": { + "name": "doc_kb_id_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_filename_idx": { + "name": "doc_filename_idx", + "columns": [ + { + "expression": "filename", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_processing_status_idx": { + "name": "doc_processing_status_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "processing_status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_connector_external_id_idx": { + "name": "doc_connector_external_id_idx", + "columns": [ + { + "expression": "connector_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"document\".\"deleted_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_connector_id_idx": { + "name": "doc_connector_id_idx", + "columns": [ + { + "expression": "connector_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_storage_key_idx": { + "name": "doc_storage_key_idx", + "columns": [ + { + "expression": "storage_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"document\".\"storage_key\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_archived_at_partial_idx": { + "name": "doc_archived_at_partial_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"document\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_deleted_at_partial_idx": { + "name": "doc_deleted_at_partial_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"document\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_tag1_idx": { + "name": "doc_tag1_idx", + "columns": [ + { + "expression": "tag1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_tag2_idx": { + "name": "doc_tag2_idx", + "columns": [ + { + "expression": "tag2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_tag3_idx": { + "name": "doc_tag3_idx", + "columns": [ + { + "expression": "tag3", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_tag4_idx": { + "name": "doc_tag4_idx", + "columns": [ + { + "expression": "tag4", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_tag5_idx": { + "name": "doc_tag5_idx", + "columns": [ + { + "expression": "tag5", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_tag6_idx": { + "name": "doc_tag6_idx", + "columns": [ + { + "expression": "tag6", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_tag7_idx": { + "name": "doc_tag7_idx", + "columns": [ + { + "expression": "tag7", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_number1_idx": { + "name": "doc_number1_idx", + "columns": [ + { + "expression": "number1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_number2_idx": { + "name": "doc_number2_idx", + "columns": [ + { + "expression": "number2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_number3_idx": { + "name": "doc_number3_idx", + "columns": [ + { + "expression": "number3", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_number4_idx": { + "name": "doc_number4_idx", + "columns": [ + { + "expression": "number4", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_number5_idx": { + "name": "doc_number5_idx", + "columns": [ + { + "expression": "number5", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_date1_idx": { + "name": "doc_date1_idx", + "columns": [ + { + "expression": "date1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_date2_idx": { + "name": "doc_date2_idx", + "columns": [ + { + "expression": "date2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_boolean1_idx": { + "name": "doc_boolean1_idx", + "columns": [ + { + "expression": "boolean1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_boolean2_idx": { + "name": "doc_boolean2_idx", + "columns": [ + { + "expression": "boolean2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "doc_boolean3_idx": { + "name": "doc_boolean3_idx", + "columns": [ + { + "expression": "boolean3", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "document_knowledge_base_id_knowledge_base_id_fk": { + "name": "document_knowledge_base_id_knowledge_base_id_fk", + "tableFrom": "document", + "tableTo": "knowledge_base", + "columnsFrom": ["knowledge_base_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "document_connector_id_knowledge_connector_id_fk": { + "name": "document_connector_id_knowledge_connector_id_fk", + "tableFrom": "document", + "tableTo": "knowledge_connector", + "columnsFrom": ["connector_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "document_uploaded_by_user_id_fk": { + "name": "document_uploaded_by_user_id_fk", + "tableFrom": "document", + "tableTo": "user", + "columnsFrom": ["uploaded_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.embedding": { + "name": "embedding", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "knowledge_base_id": { + "name": "knowledge_base_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "document_id": { + "name": "document_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chunk_index": { + "name": "chunk_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "chunk_hash": { + "name": "chunk_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content_length": { + "name": "content_length", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token_count": { + "name": "token_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "embedding": { + "name": "embedding", + "type": "vector(1536)", + "primaryKey": false, + "notNull": false + }, + "embedding_model": { + "name": "embedding_model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'text-embedding-3-small'" + }, + "start_offset": { + "name": "start_offset", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "end_offset": { + "name": "end_offset", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tag1": { + "name": "tag1", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag2": { + "name": "tag2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag3": { + "name": "tag3", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag4": { + "name": "tag4", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag5": { + "name": "tag5", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag6": { + "name": "tag6", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tag7": { + "name": "tag7", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "number1": { + "name": "number1", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number2": { + "name": "number2", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number3": { + "name": "number3", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number4": { + "name": "number4", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "number5": { + "name": "number5", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "date1": { + "name": "date1", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "date2": { + "name": "date2", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "boolean1": { + "name": "boolean1", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "boolean2": { + "name": "boolean2", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "boolean3": { + "name": "boolean3", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "content_tsv": { + "name": "content_tsv", + "type": "tsvector", + "primaryKey": false, + "notNull": false, + "generated": { + "as": "to_tsvector('english', \"embedding\".\"content\")", + "type": "stored" + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "emb_kb_id_idx": { + "name": "emb_kb_id_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_doc_id_idx": { + "name": "emb_doc_id_idx", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_doc_chunk_idx": { + "name": "emb_doc_chunk_idx", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "chunk_index", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_kb_model_idx": { + "name": "emb_kb_model_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "embedding_model", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_kb_enabled_idx": { + "name": "emb_kb_enabled_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_doc_enabled_idx": { + "name": "emb_doc_enabled_idx", + "columns": [ + { + "expression": "document_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "embedding_vector_hnsw_idx": { + "name": "embedding_vector_hnsw_idx", + "columns": [ + { + "expression": "embedding", + "isExpression": false, + "asc": true, + "nulls": "last", + "opclass": "vector_cosine_ops" + } + ], + "isUnique": false, + "concurrently": false, + "method": "hnsw", + "with": { + "m": 16, + "ef_construction": 64 + } + }, + "emb_tag1_idx": { + "name": "emb_tag1_idx", + "columns": [ + { + "expression": "tag1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_tag2_idx": { + "name": "emb_tag2_idx", + "columns": [ + { + "expression": "tag2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_tag3_idx": { + "name": "emb_tag3_idx", + "columns": [ + { + "expression": "tag3", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_tag4_idx": { + "name": "emb_tag4_idx", + "columns": [ + { + "expression": "tag4", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_tag5_idx": { + "name": "emb_tag5_idx", + "columns": [ + { + "expression": "tag5", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_tag6_idx": { + "name": "emb_tag6_idx", + "columns": [ + { + "expression": "tag6", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_tag7_idx": { + "name": "emb_tag7_idx", + "columns": [ + { + "expression": "tag7", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_number1_idx": { + "name": "emb_number1_idx", + "columns": [ + { + "expression": "number1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_number2_idx": { + "name": "emb_number2_idx", + "columns": [ + { + "expression": "number2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_number3_idx": { + "name": "emb_number3_idx", + "columns": [ + { + "expression": "number3", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_number4_idx": { + "name": "emb_number4_idx", + "columns": [ + { + "expression": "number4", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_number5_idx": { + "name": "emb_number5_idx", + "columns": [ + { + "expression": "number5", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_date1_idx": { + "name": "emb_date1_idx", + "columns": [ + { + "expression": "date1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_date2_idx": { + "name": "emb_date2_idx", + "columns": [ + { + "expression": "date2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_boolean1_idx": { + "name": "emb_boolean1_idx", + "columns": [ + { + "expression": "boolean1", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_boolean2_idx": { + "name": "emb_boolean2_idx", + "columns": [ + { + "expression": "boolean2", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_boolean3_idx": { + "name": "emb_boolean3_idx", + "columns": [ + { + "expression": "boolean3", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "emb_content_fts_idx": { + "name": "emb_content_fts_idx", + "columns": [ + { + "expression": "content_tsv", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + } + }, + "foreignKeys": { + "embedding_knowledge_base_id_knowledge_base_id_fk": { + "name": "embedding_knowledge_base_id_knowledge_base_id_fk", + "tableFrom": "embedding", + "tableTo": "knowledge_base", + "columnsFrom": ["knowledge_base_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "embedding_document_id_document_id_fk": { + "name": "embedding_document_id_document_id_fk", + "tableFrom": "embedding", + "tableTo": "document", + "columnsFrom": ["document_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "embedding_not_null_check": { + "name": "embedding_not_null_check", + "value": "\"embedding\" IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.environment": { + "name": "environment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "variables": { + "name": "variables", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "environment_user_id_user_id_fk": { + "name": "environment_user_id_user_id_fk", + "tableFrom": "environment", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "environment_user_id_unique": { + "name": "environment_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.execution_large_value_dependencies": { + "name": "execution_large_value_dependencies", + "schema": "", + "columns": { + "parent_key": { + "name": "parent_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "child_key": { + "name": "child_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "execution_large_value_dependencies_workspace_parent_key_idx": { + "name": "execution_large_value_dependencies_workspace_parent_key_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "parent_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "execution_large_value_dependencies_workspace_child_key_idx": { + "name": "execution_large_value_dependencies_workspace_child_key_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "child_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "execution_large_value_dependencies_workspace_id_workspace_id_fk": { + "name": "execution_large_value_dependencies_workspace_id_workspace_id_fk", + "tableFrom": "execution_large_value_dependencies", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "execution_large_value_dependencies_parent_key_child_key_pk": { + "name": "execution_large_value_dependencies_parent_key_child_key_pk", + "columns": ["parent_key", "child_key"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.execution_large_value_references": { + "name": "execution_large_value_references", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "execution_large_value_reference_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "execution_large_value_references_workspace_execution_source_idx": { + "name": "execution_large_value_references_workspace_execution_source_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "execution_large_value_references_workspace_id_workspace_id_fk": { + "name": "execution_large_value_references_workspace_id_workspace_id_fk", + "tableFrom": "execution_large_value_references", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "execution_large_value_references_workflow_id_workflow_id_fk": { + "name": "execution_large_value_references_workflow_id_workflow_id_fk", + "tableFrom": "execution_large_value_references", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "execution_large_value_references_key_execution_id_source_pk": { + "name": "execution_large_value_references_key_execution_id_source_pk", + "columns": ["key", "execution_id", "source"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.execution_large_values": { + "name": "execution_large_values", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_execution_id": { + "name": "owner_execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "execution_large_values_owner_execution_id_idx": { + "name": "execution_large_values_owner_execution_id_idx", + "columns": [ + { + "expression": "owner_execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "execution_large_values_cleanup_idx": { + "name": "execution_large_values_cleanup_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"execution_large_values\".\"deleted_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "execution_large_values_tombstone_cleanup_idx": { + "name": "execution_large_values_tombstone_cleanup_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"execution_large_values\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "execution_large_values_workspace_id_workspace_id_fk": { + "name": "execution_large_values_workspace_id_workspace_id_fk", + "tableFrom": "execution_large_values", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "execution_large_values_workflow_id_workflow_id_fk": { + "name": "execution_large_values_workflow_id_workflow_id_fk", + "tableFrom": "execution_large_values", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.idempotency_key": { + "name": "idempotency_key", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "result": { + "name": "result", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "idempotency_key_created_at_idx": { + "name": "idempotency_key_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invitation": { + "name": "invitation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "invitation_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'organization'" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "inviter_id": { + "name": "inviter_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "membership_intent": { + "name": "membership_intent", + "type": "invitation_membership_intent", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'internal'" + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "invitation_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "invitation_email_idx": { + "name": "invitation_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invitation_organization_id_idx": { + "name": "invitation_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invitation_status_idx": { + "name": "invitation_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invitation_pending_email_org_unique": { + "name": "invitation_pending_email_org_unique", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"invitation\".\"status\" = 'pending' AND \"invitation\".\"organization_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invitation_inviter_id_user_id_fk": { + "name": "invitation_inviter_id_user_id_fk", + "tableFrom": "invitation", + "tableTo": "user", + "columnsFrom": ["inviter_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invitation_organization_id_organization_id_fk": { + "name": "invitation_organization_id_organization_id_fk", + "tableFrom": "invitation", + "tableTo": "organization", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "invitation_token_unique": { + "name": "invitation_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.invitation_workspace_grant": { + "name": "invitation_workspace_grant", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "invitation_id": { + "name": "invitation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "permission": { + "name": "permission", + "type": "permission_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "invitation_workspace_grant_unique": { + "name": "invitation_workspace_grant_unique", + "columns": [ + { + "expression": "invitation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "invitation_workspace_grant_workspace_id_idx": { + "name": "invitation_workspace_grant_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "invitation_workspace_grant_invitation_id_invitation_id_fk": { + "name": "invitation_workspace_grant_invitation_id_invitation_id_fk", + "tableFrom": "invitation_workspace_grant", + "tableTo": "invitation", + "columnsFrom": ["invitation_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "invitation_workspace_grant_workspace_id_workspace_id_fk": { + "name": "invitation_workspace_grant_workspace_id_workspace_id_fk", + "tableFrom": "invitation_workspace_grant", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.job_execution_logs": { + "name": "job_execution_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "schedule_id": { + "name": "schedule_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'running'" + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "total_duration_ms": { + "name": "total_duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "execution_data": { + "name": "execution_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "cost": { + "name": "cost", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "job_execution_logs_schedule_id_idx": { + "name": "job_execution_logs_schedule_id_idx", + "columns": [ + { + "expression": "schedule_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "job_execution_logs_workspace_started_at_idx": { + "name": "job_execution_logs_workspace_started_at_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "job_execution_logs_workspace_ended_at_id_idx": { + "name": "job_execution_logs_workspace_ended_at_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date_trunc('milliseconds', \"ended_at\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "job_execution_logs_execution_id_unique": { + "name": "job_execution_logs_execution_id_unique", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "job_execution_logs_trigger_idx": { + "name": "job_execution_logs_trigger_idx", + "columns": [ + { + "expression": "trigger", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "job_execution_logs_schedule_id_workflow_schedule_id_fk": { + "name": "job_execution_logs_schedule_id_workflow_schedule_id_fk", + "tableFrom": "job_execution_logs", + "tableTo": "workflow_schedule", + "columnsFrom": ["schedule_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "job_execution_logs_workspace_id_workspace_id_fk": { + "name": "job_execution_logs_workspace_id_workspace_id_fk", + "tableFrom": "job_execution_logs", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.knowledge_base": { + "name": "knowledge_base", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token_count": { + "name": "token_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "embedding_model": { + "name": "embedding_model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'text-embedding-3-small'" + }, + "embedding_dimension": { + "name": "embedding_dimension", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1536 + }, + "chunking_config": { + "name": "chunking_config", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'{\"maxSize\": 1024, \"minSize\": 1, \"overlap\": 200}'" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "kb_user_id_idx": { + "name": "kb_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kb_workspace_id_idx": { + "name": "kb_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kb_user_workspace_idx": { + "name": "kb_user_workspace_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kb_deleted_at_idx": { + "name": "kb_deleted_at_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kb_workspace_deleted_partial_idx": { + "name": "kb_workspace_deleted_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"knowledge_base\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "kb_workspace_name_active_unique": { + "name": "kb_workspace_name_active_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"knowledge_base\".\"deleted_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "knowledge_base_user_id_user_id_fk": { + "name": "knowledge_base_user_id_user_id_fk", + "tableFrom": "knowledge_base", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "knowledge_base_workspace_id_workspace_id_fk": { + "name": "knowledge_base_workspace_id_workspace_id_fk", + "tableFrom": "knowledge_base", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.knowledge_base_tag_definitions": { + "name": "knowledge_base_tag_definitions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "knowledge_base_id": { + "name": "knowledge_base_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tag_slot": { + "name": "tag_slot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "field_type": { + "name": "field_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'text'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "kb_tag_definitions_kb_slot_idx": { + "name": "kb_tag_definitions_kb_slot_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "tag_slot", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kb_tag_definitions_kb_display_name_idx": { + "name": "kb_tag_definitions_kb_display_name_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "display_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kb_tag_definitions_kb_id_idx": { + "name": "kb_tag_definitions_kb_id_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "knowledge_base_tag_definitions_knowledge_base_id_knowledge_base_id_fk": { + "name": "knowledge_base_tag_definitions_knowledge_base_id_knowledge_base_id_fk", + "tableFrom": "knowledge_base_tag_definitions", + "tableTo": "knowledge_base", + "columnsFrom": ["knowledge_base_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.knowledge_connector": { + "name": "knowledge_connector", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "knowledge_base_id": { + "name": "knowledge_base_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "connector_type": { + "name": "connector_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "credential_id": { + "name": "credential_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "encrypted_api_key": { + "name": "encrypted_api_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_config": { + "name": "source_config", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "sync_mode": { + "name": "sync_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'full'" + }, + "sync_interval_minutes": { + "name": "sync_interval_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1440 + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "last_sync_at": { + "name": "last_sync_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_sync_error": { + "name": "last_sync_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_sync_doc_count": { + "name": "last_sync_doc_count", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "next_sync_at": { + "name": "next_sync_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "consecutive_failures": { + "name": "consecutive_failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "kc_knowledge_base_id_idx": { + "name": "kc_knowledge_base_id_idx", + "columns": [ + { + "expression": "knowledge_base_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kc_status_next_sync_idx": { + "name": "kc_status_next_sync_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_sync_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "kc_archived_at_partial_idx": { + "name": "kc_archived_at_partial_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"knowledge_connector\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "kc_deleted_at_partial_idx": { + "name": "kc_deleted_at_partial_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"knowledge_connector\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "knowledge_connector_knowledge_base_id_knowledge_base_id_fk": { + "name": "knowledge_connector_knowledge_base_id_knowledge_base_id_fk", + "tableFrom": "knowledge_connector", + "tableTo": "knowledge_base", + "columnsFrom": ["knowledge_base_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.knowledge_connector_sync_log": { + "name": "knowledge_connector_sync_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "connector_id": { + "name": "connector_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "docs_added": { + "name": "docs_added", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "docs_updated": { + "name": "docs_updated", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "docs_deleted": { + "name": "docs_deleted", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "docs_unchanged": { + "name": "docs_unchanged", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "docs_failed": { + "name": "docs_failed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "kcsl_connector_id_idx": { + "name": "kcsl_connector_id_idx", + "columns": [ + { + "expression": "connector_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "knowledge_connector_sync_log_connector_id_knowledge_connector_id_fk": { + "name": "knowledge_connector_sync_log_connector_id_knowledge_connector_id_fk", + "tableFrom": "knowledge_connector_sync_log", + "tableTo": "knowledge_connector", + "columnsFrom": ["connector_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mcp_server_oauth": { + "name": "mcp_server_oauth", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mcp_server_id": { + "name": "mcp_server_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_information": { + "name": "client_information", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tokens": { + "name": "tokens", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code_verifier": { + "name": "code_verifier", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state_created_at": { + "name": "state_created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_refreshed_at": { + "name": "last_refreshed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mcp_server_oauth_server_unique": { + "name": "mcp_server_oauth_server_unique", + "columns": [ + { + "expression": "mcp_server_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mcp_server_oauth_state_idx": { + "name": "mcp_server_oauth_state_idx", + "columns": [ + { + "expression": "state", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mcp_server_oauth_mcp_server_id_mcp_servers_id_fk": { + "name": "mcp_server_oauth_mcp_server_id_mcp_servers_id_fk", + "tableFrom": "mcp_server_oauth", + "tableTo": "mcp_servers", + "columnsFrom": ["mcp_server_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mcp_server_oauth_user_id_user_id_fk": { + "name": "mcp_server_oauth_user_id_user_id_fk", + "tableFrom": "mcp_server_oauth", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "mcp_server_oauth_workspace_id_workspace_id_fk": { + "name": "mcp_server_oauth_workspace_id_workspace_id_fk", + "tableFrom": "mcp_server_oauth", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mcp_servers": { + "name": "mcp_servers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "transport": { + "name": "transport", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "auth_type": { + "name": "auth_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'headers'" + }, + "oauth_client_id": { + "name": "oauth_client_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "oauth_client_secret": { + "name": "oauth_client_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "headers": { + "name": "headers", + "type": "json", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "timeout": { + "name": "timeout", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 30000 + }, + "retries": { + "name": "retries", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 3 + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "last_connected": { + "name": "last_connected", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "connection_status": { + "name": "connection_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'disconnected'" + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status_config": { + "name": "status_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "tool_count": { + "name": "tool_count", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "last_tools_refresh": { + "name": "last_tools_refresh", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "total_requests": { + "name": "total_requests", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "last_used": { + "name": "last_used", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mcp_servers_workspace_enabled_idx": { + "name": "mcp_servers_workspace_enabled_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mcp_servers_workspace_deleted_partial_idx": { + "name": "mcp_servers_workspace_deleted_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"mcp_servers\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mcp_servers_workspace_id_workspace_id_fk": { + "name": "mcp_servers_workspace_id_workspace_id_fk", + "tableFrom": "mcp_servers", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mcp_servers_created_by_user_id_fk": { + "name": "mcp_servers_created_by_user_id_fk", + "tableFrom": "mcp_servers", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.member": { + "name": "member", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "member_user_id_unique": { + "name": "member_user_id_unique", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "member_organization_id_idx": { + "name": "member_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "member_user_id_user_id_fk": { + "name": "member_user_id_user_id_fk", + "tableFrom": "member", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "member_organization_id_organization_id_fk": { + "name": "member_organization_id_organization_id_fk", + "tableFrom": "member", + "tableTo": "organization", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory": { + "name": "memory", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "memory_key_idx": { + "name": "memory_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "memory_workspace_idx": { + "name": "memory_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "memory_workspace_key_idx": { + "name": "memory_workspace_key_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "memory_workspace_deleted_partial_idx": { + "name": "memory_workspace_deleted_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"memory\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "memory_workspace_id_workspace_id_fk": { + "name": "memory_workspace_id_workspace_id_fk", + "tableFrom": "memory", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mothership_inbox_allowed_sender": { + "name": "mothership_inbox_allowed_sender", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "inbox_sender_ws_email_idx": { + "name": "inbox_sender_ws_email_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mothership_inbox_allowed_sender_workspace_id_workspace_id_fk": { + "name": "mothership_inbox_allowed_sender_workspace_id_workspace_id_fk", + "tableFrom": "mothership_inbox_allowed_sender", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mothership_inbox_allowed_sender_added_by_user_id_fk": { + "name": "mothership_inbox_allowed_sender_added_by_user_id_fk", + "tableFrom": "mothership_inbox_allowed_sender", + "tableTo": "user", + "columnsFrom": ["added_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mothership_inbox_task": { + "name": "mothership_inbox_task", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_email": { + "name": "from_email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body_preview": { + "name": "body_preview", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "body_text": { + "name": "body_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "body_html": { + "name": "body_html", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email_message_id": { + "name": "email_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "in_reply_to": { + "name": "in_reply_to", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "response_message_id": { + "name": "response_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agentmail_message_id": { + "name": "agentmail_message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'received'" + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "trigger_job_id": { + "name": "trigger_job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result_summary": { + "name": "result_summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rejection_reason": { + "name": "rejection_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "has_attachments": { + "name": "has_attachments", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cc_recipients": { + "name": "cc_recipients", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "processing_started_at": { + "name": "processing_started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "inbox_task_ws_created_at_idx": { + "name": "inbox_task_ws_created_at_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inbox_task_ws_status_idx": { + "name": "inbox_task_ws_status_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inbox_task_response_msg_id_idx": { + "name": "inbox_task_response_msg_id_idx", + "columns": [ + { + "expression": "response_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "inbox_task_email_msg_id_idx": { + "name": "inbox_task_email_msg_id_idx", + "columns": [ + { + "expression": "email_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mothership_inbox_task_workspace_id_workspace_id_fk": { + "name": "mothership_inbox_task_workspace_id_workspace_id_fk", + "tableFrom": "mothership_inbox_task", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "mothership_inbox_task_chat_id_copilot_chats_id_fk": { + "name": "mothership_inbox_task_chat_id_copilot_chats_id_fk", + "tableFrom": "mothership_inbox_task", + "tableTo": "copilot_chats", + "columnsFrom": ["chat_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mothership_inbox_webhook": { + "name": "mothership_inbox_webhook", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "webhook_id": { + "name": "webhook_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "mothership_inbox_webhook_workspace_id_workspace_id_fk": { + "name": "mothership_inbox_webhook_workspace_id_workspace_id_fk", + "tableFrom": "mothership_inbox_webhook", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "mothership_inbox_webhook_workspace_id_unique": { + "name": "mothership_inbox_webhook_workspace_id_unique", + "nullsNotDistinct": false, + "columns": ["workspace_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mothership_settings": { + "name": "mothership_settings", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mcp_tool_refs": { + "name": "mcp_tool_refs", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "custom_tool_refs": { + "name": "custom_tool_refs", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "skill_refs": { + "name": "skill_refs", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mothership_settings_workspace_id_idx": { + "name": "mothership_settings_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mothership_settings_workspace_id_workspace_id_fk": { + "name": "mothership_settings_workspace_id_workspace_id_fk", + "tableFrom": "mothership_settings", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization": { + "name": "organization", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "logo": { + "name": "logo", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "whitelabel_settings": { + "name": "whitelabel_settings", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "data_retention_settings": { + "name": "data_retention_settings", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "org_usage_limit": { + "name": "org_usage_limit", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "storage_used_bytes": { + "name": "storage_used_bytes", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "departed_member_usage": { + "name": "departed_member_usage", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "credit_balance": { + "name": "credit_balance", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization_member_usage_limit": { + "name": "organization_member_usage_limit", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "usage_limit": { + "name": "usage_limit", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "set_by": { + "name": "set_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "org_member_usage_limit_org_user_unique": { + "name": "org_member_usage_limit_org_user_unique", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "org_member_usage_limit_organization_id_idx": { + "name": "org_member_usage_limit_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_member_usage_limit_organization_id_organization_id_fk": { + "name": "organization_member_usage_limit_organization_id_organization_id_fk", + "tableFrom": "organization_member_usage_limit", + "tableTo": "organization", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_member_usage_limit_user_id_user_id_fk": { + "name": "organization_member_usage_limit_user_id_user_id_fk", + "tableFrom": "organization_member_usage_limit", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_member_usage_limit_set_by_user_id_fk": { + "name": "organization_member_usage_limit_set_by_user_id_fk", + "tableFrom": "organization_member_usage_limit", + "tableTo": "user", + "columnsFrom": ["set_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.outbox_event": { + "name": "outbox_event", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "max_attempts": { + "name": "max_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 10 + }, + "available_at": { + "name": "available_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "locked_at": { + "name": "locked_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "processed_at": { + "name": "processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "outbox_event_status_available_idx": { + "name": "outbox_event_status_available_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "available_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "outbox_event_locked_at_idx": { + "name": "outbox_event_locked_at_idx", + "columns": [ + { + "expression": "locked_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.paused_executions": { + "name": "paused_executions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "execution_snapshot": { + "name": "execution_snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "pause_points": { + "name": "pause_points", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "total_pause_count": { + "name": "total_pause_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "resumed_count": { + "name": "resumed_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'paused'" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "paused_at": { + "name": "paused_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "next_resume_at": { + "name": "next_resume_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "paused_executions_workflow_id_idx": { + "name": "paused_executions_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "paused_executions_status_idx": { + "name": "paused_executions_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "paused_executions_execution_id_unique": { + "name": "paused_executions_execution_id_unique", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "paused_executions_next_resume_at_idx": { + "name": "paused_executions_next_resume_at_idx", + "columns": [ + { + "expression": "next_resume_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "status = 'paused' AND next_resume_at IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "paused_executions_workflow_id_workflow_id_fk": { + "name": "paused_executions_workflow_id_workflow_id_fk", + "tableFrom": "paused_executions", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.pending_credential_draft": { + "name": "pending_credential_draft", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "credential_id": { + "name": "credential_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "pending_draft_user_provider_ws": { + "name": "pending_draft_user_provider_ws", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pending_credential_draft_user_id_user_id_fk": { + "name": "pending_credential_draft_user_id_user_id_fk", + "tableFrom": "pending_credential_draft", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pending_credential_draft_workspace_id_workspace_id_fk": { + "name": "pending_credential_draft_workspace_id_workspace_id_fk", + "tableFrom": "pending_credential_draft", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "pending_credential_draft_credential_id_credential_id_fk": { + "name": "pending_credential_draft_credential_id_credential_id_fk", + "tableFrom": "pending_credential_draft", + "tableTo": "credential", + "columnsFrom": ["credential_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.permission_group": { + "name": "permission_group", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "auto_add_new_members": { + "name": "auto_add_new_members", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "permission_group_created_by_idx": { + "name": "permission_group_created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permission_group_workspace_name_unique": { + "name": "permission_group_workspace_name_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permission_group_workspace_auto_add_unique": { + "name": "permission_group_workspace_auto_add_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "auto_add_new_members = true", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "permission_group_workspace_id_workspace_id_fk": { + "name": "permission_group_workspace_id_workspace_id_fk", + "tableFrom": "permission_group", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "permission_group_created_by_user_id_fk": { + "name": "permission_group_created_by_user_id_fk", + "tableFrom": "permission_group", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.permission_group_member": { + "name": "permission_group_member", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "permission_group_id": { + "name": "permission_group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "assigned_by": { + "name": "assigned_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "assigned_at": { + "name": "assigned_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "permission_group_member_group_id_idx": { + "name": "permission_group_member_group_id_idx", + "columns": [ + { + "expression": "permission_group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permission_group_member_group_user_unique": { + "name": "permission_group_member_group_user_unique", + "columns": [ + { + "expression": "permission_group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permission_group_member_workspace_user_unique": { + "name": "permission_group_member_workspace_user_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "permission_group_member_permission_group_id_permission_group_id_fk": { + "name": "permission_group_member_permission_group_id_permission_group_id_fk", + "tableFrom": "permission_group_member", + "tableTo": "permission_group", + "columnsFrom": ["permission_group_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "permission_group_member_workspace_id_workspace_id_fk": { + "name": "permission_group_member_workspace_id_workspace_id_fk", + "tableFrom": "permission_group_member", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "permission_group_member_user_id_user_id_fk": { + "name": "permission_group_member_user_id_user_id_fk", + "tableFrom": "permission_group_member", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "permission_group_member_assigned_by_user_id_fk": { + "name": "permission_group_member_assigned_by_user_id_fk", + "tableFrom": "permission_group_member", + "tableTo": "user", + "columnsFrom": ["assigned_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.permissions": { + "name": "permissions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "entity_id": { + "name": "entity_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "permission_type": { + "name": "permission_type", + "type": "permission_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "permissions_user_id_idx": { + "name": "permissions_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permissions_entity_idx": { + "name": "permissions_entity_idx", + "columns": [ + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permissions_user_entity_type_idx": { + "name": "permissions_user_entity_type_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permissions_user_entity_permission_idx": { + "name": "permissions_user_entity_permission_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "permission_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permissions_user_entity_idx": { + "name": "permissions_user_entity_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "permissions_unique_constraint": { + "name": "permissions_unique_constraint", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "permissions_user_id_user_id_fk": { + "name": "permissions_user_id_user_id_fk", + "tableFrom": "permissions", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.rate_limit_bucket": { + "name": "rate_limit_bucket", + "schema": "", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "tokens": { + "name": "tokens", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "last_refill_at": { + "name": "last_refill_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.resume_queue": { + "name": "resume_queue", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "paused_execution_id": { + "name": "paused_execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_execution_id": { + "name": "parent_execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "new_execution_id": { + "name": "new_execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "context_id": { + "name": "context_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resume_input": { + "name": "resume_input", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "queued_at": { + "name": "queued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "claimed_at": { + "name": "claimed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "resume_queue_parent_status_idx": { + "name": "resume_queue_parent_status_idx", + "columns": [ + { + "expression": "parent_execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "queued_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "resume_queue_new_execution_idx": { + "name": "resume_queue_new_execution_idx", + "columns": [ + { + "expression": "new_execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "resume_queue_paused_execution_id_paused_executions_id_fk": { + "name": "resume_queue_paused_execution_id_paused_executions_id_fk", + "tableFrom": "resume_queue", + "tableTo": "paused_executions", + "columnsFrom": ["paused_execution_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active_organization_id": { + "name": "active_organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "impersonated_by": { + "name": "impersonated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "session_user_id_idx": { + "name": "session_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "session_token_idx": { + "name": "session_token_idx", + "columns": [ + { + "expression": "token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "session_active_organization_id_organization_id_fk": { + "name": "session_active_organization_id_organization_id_fk", + "tableFrom": "session", + "tableTo": "organization", + "columnsFrom": ["active_organization_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.settings": { + "name": "settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "theme": { + "name": "theme", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'system'" + }, + "auto_connect": { + "name": "auto_connect", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "telemetry_enabled": { + "name": "telemetry_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "email_preferences": { + "name": "email_preferences", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "billing_usage_notifications_enabled": { + "name": "billing_usage_notifications_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "show_training_controls": { + "name": "show_training_controls", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "super_user_mode_enabled": { + "name": "super_user_mode_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "mothership_environment": { + "name": "mothership_environment", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "error_notifications_enabled": { + "name": "error_notifications_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "snap_to_grid_size": { + "name": "snap_to_grid_size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "show_action_bar": { + "name": "show_action_bar", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "copilot_enabled_models": { + "name": "copilot_enabled_models", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "copilot_auto_allowed_tools": { + "name": "copilot_auto_allowed_tools", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'" + }, + "last_active_workspace_id": { + "name": "last_active_workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "settings_user_id_user_id_fk": { + "name": "settings_user_id_user_id_fk", + "tableFrom": "settings", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "settings_user_id_unique": { + "name": "settings_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sim_trigger_state": { + "name": "sim_trigger_state", + "schema": "", + "columns": { + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "block_id": { + "name": "block_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scope_key": { + "name": "scope_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "last_fired_at": { + "name": "last_fired_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "sim_trigger_state_workflow_id_workflow_id_fk": { + "name": "sim_trigger_state_workflow_id_workflow_id_fk", + "tableFrom": "sim_trigger_state", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "sim_trigger_state_workflow_id_block_id_scope_key_pk": { + "name": "sim_trigger_state_workflow_id_block_id_scope_key_pk", + "columns": ["workflow_id", "block_id", "scope_key"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.skill": { + "name": "skill", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "skill_workspace_name_unique": { + "name": "skill_workspace_name_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "skill_workspace_id_workspace_id_fk": { + "name": "skill_workspace_id_workspace_id_fk", + "tableFrom": "skill", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "skill_user_id_user_id_fk": { + "name": "skill_user_id_user_id_fk", + "tableFrom": "skill", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sso_provider": { + "name": "sso_provider", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "issuer": { + "name": "issuer", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "domain": { + "name": "domain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "oidc_config": { + "name": "oidc_config", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "saml_config": { + "name": "saml_config", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sso_provider_provider_id_idx": { + "name": "sso_provider_provider_id_idx", + "columns": [ + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sso_provider_domain_idx": { + "name": "sso_provider_domain_idx", + "columns": [ + { + "expression": "domain", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sso_provider_user_id_idx": { + "name": "sso_provider_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sso_provider_organization_id_idx": { + "name": "sso_provider_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sso_provider_user_id_user_id_fk": { + "name": "sso_provider_user_id_user_id_fk", + "tableFrom": "sso_provider", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sso_provider_organization_id_organization_id_fk": { + "name": "sso_provider_organization_id_organization_id_fk", + "tableFrom": "sso_provider", + "tableTo": "organization", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.subscription": { + "name": "subscription", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reference_id": { + "name": "reference_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "period_start": { + "name": "period_start", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "period_end": { + "name": "period_end", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "cancel_at": { + "name": "cancel_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "canceled_at": { + "name": "canceled_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "trial_start": { + "name": "trial_start", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "trial_end": { + "name": "trial_end", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "billing_interval": { + "name": "billing_interval", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_schedule_id": { + "name": "stripe_schedule_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "json", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "subscription_reference_status_idx": { + "name": "subscription_reference_status_idx", + "columns": [ + { + "expression": "reference_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "check_enterprise_metadata": { + "name": "check_enterprise_metadata", + "value": "plan != 'enterprise' OR metadata IS NOT NULL" + } + }, + "isRLSEnabled": false + }, + "public.table_jobs": { + "name": "table_jobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "table_id": { + "name": "table_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'running'" + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "rows_processed": { + "name": "rows_processed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "table_jobs_one_active_per_table": { + "name": "table_jobs_one_active_per_table", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"table_jobs\".\"status\" = 'running' AND \"table_jobs\".\"type\" <> 'export'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "table_jobs_watchdog_idx": { + "name": "table_jobs_watchdog_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "table_jobs_table_started_idx": { + "name": "table_jobs_table_started_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "table_jobs_table_id_user_table_definitions_id_fk": { + "name": "table_jobs_table_id_user_table_definitions_id_fk", + "tableFrom": "table_jobs", + "tableTo": "user_table_definitions", + "columnsFrom": ["table_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "table_jobs_workspace_id_workspace_id_fk": { + "name": "table_jobs_workspace_id_workspace_id_fk", + "tableFrom": "table_jobs", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.table_row_executions": { + "name": "table_row_executions", + "schema": "", + "columns": { + "table_id": { + "name": "table_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "row_id": { + "name": "row_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "job_id": { + "name": "job_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "running_block_ids": { + "name": "running_block_ids", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "block_errors": { + "name": "block_errors", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "table_row_executions_table_status_idx": { + "name": "table_row_executions_table_status_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"table_row_executions\".\"status\" IN ('queued', 'running', 'pending')", + "concurrently": false, + "method": "btree", + "with": {} + }, + "table_row_executions_execution_id_idx": { + "name": "table_row_executions_execution_id_idx", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"table_row_executions\".\"execution_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "table_row_executions_table_group_idx": { + "name": "table_row_executions_table_group_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "table_row_executions_table_id_user_table_definitions_id_fk": { + "name": "table_row_executions_table_id_user_table_definitions_id_fk", + "tableFrom": "table_row_executions", + "tableTo": "user_table_definitions", + "columnsFrom": ["table_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "table_row_executions_row_id_user_table_rows_id_fk": { + "name": "table_row_executions_row_id_user_table_rows_id_fk", + "tableFrom": "table_row_executions", + "tableTo": "user_table_rows", + "columnsFrom": ["row_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "table_row_executions_row_id_group_id_pk": { + "name": "table_row_executions_row_id_group_id_pk", + "columns": ["row_id", "group_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.table_run_dispatches": { + "name": "table_run_dispatches", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "table_id": { + "name": "table_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scope": { + "name": "scope", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "cursor": { + "name": "cursor", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "limit": { + "name": "limit", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "processed_count": { + "name": "processed_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "is_manual_run": { + "name": "is_manual_run", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "triggered_by_user_id": { + "name": "triggered_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "requested_at": { + "name": "requested_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "cancelled_at": { + "name": "cancelled_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "table_run_dispatches_active_idx": { + "name": "table_run_dispatches_active_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "table_run_dispatches_watchdog_idx": { + "name": "table_run_dispatches_watchdog_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "requested_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "table_run_dispatches_table_id_user_table_definitions_id_fk": { + "name": "table_run_dispatches_table_id_user_table_definitions_id_fk", + "tableFrom": "table_run_dispatches", + "tableTo": "user_table_definitions", + "columnsFrom": ["table_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "table_run_dispatches_workspace_id_workspace_id_fk": { + "name": "table_run_dispatches_workspace_id_workspace_id_fk", + "tableFrom": "table_run_dispatches", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "table_run_dispatches_triggered_by_user_id_user_id_fk": { + "name": "table_run_dispatches_triggered_by_user_id_user_id_fk", + "tableFrom": "table_run_dispatches", + "tableTo": "user", + "columnsFrom": ["triggered_by_user_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.usage_log": { + "name": "usage_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "usage_log_category", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "usage_log_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "cost": { + "name": "cost", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "event_key": { + "name": "event_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "billing_entity_type": { + "name": "billing_entity_type", + "type": "billing_entity_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "billing_entity_id": { + "name": "billing_entity_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "billing_period_start": { + "name": "billing_period_start", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "billing_period_end": { + "name": "billing_period_end", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "usage_log_user_created_at_idx": { + "name": "usage_log_user_created_at_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_log_source_idx": { + "name": "usage_log_source_idx", + "columns": [ + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_log_workspace_id_idx": { + "name": "usage_log_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_log_workflow_id_idx": { + "name": "usage_log_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_log_event_key_unique": { + "name": "usage_log_event_key_unique", + "columns": [ + { + "expression": "event_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"usage_log\".\"event_key\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_log_billing_entity_period_idx": { + "name": "usage_log_billing_entity_period_idx", + "columns": [ + { + "expression": "billing_entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "billing_entity_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "billing_period_start", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "billing_period_end", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"usage_log\".\"billing_entity_type\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_log_workspace_created_at_idx": { + "name": "usage_log_workspace_created_at_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "usage_log_execution_id_idx": { + "name": "usage_log_execution_id_idx", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "usage_log_user_id_user_id_fk": { + "name": "usage_log_user_id_user_id_fk", + "tableFrom": "usage_log", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "usage_log_workspace_id_workspace_id_fk": { + "name": "usage_log_workspace_id_workspace_id_fk", + "tableFrom": "usage_log", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "usage_log_workflow_id_workflow_id_fk": { + "name": "usage_log_workflow_id_workflow_id_fk", + "tableFrom": "usage_log", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "usage_log_billing_scope_all_or_none": { + "name": "usage_log_billing_scope_all_or_none", + "value": "(\n (\"usage_log\".\"billing_entity_type\" IS NULL AND \"usage_log\".\"billing_entity_id\" IS NULL AND \"usage_log\".\"billing_period_start\" IS NULL AND \"usage_log\".\"billing_period_end\" IS NULL)\n OR\n (\"usage_log\".\"billing_entity_type\" IS NOT NULL AND \"usage_log\".\"billing_entity_id\" IS NOT NULL AND \"usage_log\".\"billing_period_start\" IS NOT NULL AND \"usage_log\".\"billing_period_end\" IS NOT NULL AND \"usage_log\".\"billing_period_start\" < \"usage_log\".\"billing_period_end\")\n )" + } + }, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "normalized_email": { + "name": "normalized_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'user'" + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ban_expires": { + "name": "ban_expires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + }, + "user_normalized_email_unique": { + "name": "user_normalized_email_unique", + "nullsNotDistinct": false, + "columns": ["normalized_email"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_stats": { + "name": "user_stats", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "total_manual_executions": { + "name": "total_manual_executions", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_api_calls": { + "name": "total_api_calls", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_webhook_triggers": { + "name": "total_webhook_triggers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_scheduled_executions": { + "name": "total_scheduled_executions", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_chat_executions": { + "name": "total_chat_executions", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_mcp_executions": { + "name": "total_mcp_executions", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_a2a_executions": { + "name": "total_a2a_executions", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_tokens_used": { + "name": "total_tokens_used", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_cost": { + "name": "total_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "current_usage_limit": { + "name": "current_usage_limit", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'5'" + }, + "usage_limit_updated_at": { + "name": "usage_limit_updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "current_period_cost": { + "name": "current_period_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "last_period_cost": { + "name": "last_period_cost", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'0'" + }, + "billed_overage_this_period": { + "name": "billed_overage_this_period", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "pro_period_cost_snapshot": { + "name": "pro_period_cost_snapshot", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'0'" + }, + "pro_period_cost_snapshot_at": { + "name": "pro_period_cost_snapshot_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "credit_balance": { + "name": "credit_balance", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "total_copilot_cost": { + "name": "total_copilot_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "current_period_copilot_cost": { + "name": "current_period_copilot_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "last_period_copilot_cost": { + "name": "last_period_copilot_cost", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'0'" + }, + "total_copilot_tokens": { + "name": "total_copilot_tokens", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_copilot_calls": { + "name": "total_copilot_calls", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_mcp_copilot_calls": { + "name": "total_mcp_copilot_calls", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "total_mcp_copilot_cost": { + "name": "total_mcp_copilot_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "current_period_mcp_copilot_cost": { + "name": "current_period_mcp_copilot_cost", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "storage_used_bytes": { + "name": "storage_used_bytes", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_active": { + "name": "last_active", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "billing_blocked": { + "name": "billing_blocked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "billing_blocked_reason": { + "name": "billing_blocked_reason", + "type": "billing_blocked_reason", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "user_stats_user_id_user_id_fk": { + "name": "user_stats_user_id_user_id_fk", + "tableFrom": "user_stats", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_stats_user_id_unique": { + "name": "user_stats_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_table_definitions": { + "name": "user_table_definitions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "schema": { + "name": "schema", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "max_rows": { + "name": "max_rows", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 10000 + }, + "row_count": { + "name": "row_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "user_table_def_workspace_id_idx": { + "name": "user_table_def_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_table_def_workspace_name_unique": { + "name": "user_table_def_workspace_name_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"user_table_definitions\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_table_def_archived_at_idx": { + "name": "user_table_def_archived_at_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_table_def_workspace_archived_partial_idx": { + "name": "user_table_def_workspace_archived_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"user_table_definitions\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_table_definitions_workspace_id_workspace_id_fk": { + "name": "user_table_definitions_workspace_id_workspace_id_fk", + "tableFrom": "user_table_definitions", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_table_definitions_created_by_user_id_fk": { + "name": "user_table_definitions_created_by_user_id_fk", + "tableFrom": "user_table_definitions", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_table_rows": { + "name": "user_table_rows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "table_id": { + "name": "table_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "order_key": { + "name": "order_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "user_table_rows_table_id_idx": { + "name": "user_table_rows_table_id_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_table_rows_tenant_data_gin_idx": { + "name": "user_table_rows_tenant_data_gin_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "\"data\" jsonb_path_ops", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + }, + "user_table_rows_workspace_table_idx": { + "name": "user_table_rows_workspace_table_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_table_rows_table_position_idx": { + "name": "user_table_rows_table_position_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "position", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_table_rows_table_order_key_idx": { + "name": "user_table_rows_table_order_key_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "order_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_table_rows_table_id_id_idx": { + "name": "user_table_rows_table_id_id_idx", + "columns": [ + { + "expression": "table_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_table_rows_table_id_user_table_definitions_id_fk": { + "name": "user_table_rows_table_id_user_table_definitions_id_fk", + "tableFrom": "user_table_rows", + "tableTo": "user_table_definitions", + "columnsFrom": ["table_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_table_rows_workspace_id_workspace_id_fk": { + "name": "user_table_rows_workspace_id_workspace_id_fk", + "tableFrom": "user_table_rows", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_table_rows_created_by_user_id_fk": { + "name": "user_table_rows_created_by_user_id_fk", + "tableFrom": "user_table_rows", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "verification_identifier_idx": { + "name": "verification_identifier_idx", + "columns": [ + { + "expression": "identifier", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "verification_expires_at_idx": { + "name": "verification_expires_at_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.waitlist": { + "name": "waitlist", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "waitlist_email_unique": { + "name": "waitlist_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.webhook": { + "name": "webhook", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "deployment_version_id": { + "name": "deployment_version_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "block_id": { + "name": "block_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_config": { + "name": "provider_config", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "failed_count": { + "name": "failed_count", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "last_failed_at": { + "name": "last_failed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "credential_set_id": { + "name": "credential_set_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "path_deployment_unique": { + "name": "path_deployment_unique", + "columns": [ + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deployment_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"webhook\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "webhook_workflow_deployment_idx": { + "name": "webhook_workflow_deployment_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deployment_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "webhook_credential_set_id_idx": { + "name": "webhook_credential_set_id_idx", + "columns": [ + { + "expression": "credential_set_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "webhook_archived_at_partial_idx": { + "name": "webhook_archived_at_partial_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"webhook\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_webhook_on_provider_is_active_workflow_id_deploym_bdeed5468": { + "name": "idx_webhook_on_provider_is_active_workflow_id_deploym_bdeed5468", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deployment_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_webhook_on_workflow_id_block_id_updated_at_desc": { + "name": "idx_webhook_on_workflow_id_block_id_updated_at_desc", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "block_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "webhook_workflow_id_workflow_id_fk": { + "name": "webhook_workflow_id_workflow_id_fk", + "tableFrom": "webhook", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "webhook_deployment_version_id_workflow_deployment_version_id_fk": { + "name": "webhook_deployment_version_id_workflow_deployment_version_id_fk", + "tableFrom": "webhook", + "tableTo": "workflow_deployment_version", + "columnsFrom": ["deployment_version_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "webhook_credential_set_id_credential_set_id_fk": { + "name": "webhook_credential_set_id_credential_set_id_fk", + "tableFrom": "webhook", + "tableTo": "credential_set", + "columnsFrom": ["credential_set_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow": { + "name": "workflow", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "folder_id": { + "name": "folder_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_synced": { + "name": "last_synced", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "is_deployed": { + "name": "is_deployed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "deployed_at": { + "name": "deployed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "is_public_api": { + "name": "is_public_api", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "run_count": { + "name": "run_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_run_at": { + "name": "last_run_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "variables": { + "name": "variables", + "type": "json", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "workflow_user_id_idx": { + "name": "workflow_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_workspace_id_idx": { + "name": "workflow_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_user_workspace_idx": { + "name": "workflow_user_workspace_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_workspace_folder_name_active_unique": { + "name": "workflow_workspace_folder_name_active_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "coalesce(\"folder_id\", '')", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"workflow\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_folder_sort_idx": { + "name": "workflow_folder_sort_idx", + "columns": [ + { + "expression": "folder_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sort_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_archived_at_idx": { + "name": "workflow_archived_at_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_workspace_archived_partial_idx": { + "name": "workflow_workspace_archived_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workflow\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_user_id_user_id_fk": { + "name": "workflow_user_id_user_id_fk", + "tableFrom": "workflow", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_workspace_id_workspace_id_fk": { + "name": "workflow_workspace_id_workspace_id_fk", + "tableFrom": "workflow", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_folder_id_workflow_folder_id_fk": { + "name": "workflow_folder_id_workflow_folder_id_fk", + "tableFrom": "workflow", + "tableTo": "workflow_folder", + "columnsFrom": ["folder_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_blocks": { + "name": "workflow_blocks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "position_x": { + "name": "position_x", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "position_y": { + "name": "position_y", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "horizontal_handles": { + "name": "horizontal_handles", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_wide": { + "name": "is_wide", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "advanced_mode": { + "name": "advanced_mode", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "trigger_mode": { + "name": "trigger_mode", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "height": { + "name": "height", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "sub_blocks": { + "name": "sub_blocks", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "outputs": { + "name": "outputs", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_blocks_workflow_id_idx": { + "name": "workflow_blocks_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_blocks_type_idx": { + "name": "workflow_blocks_type_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_blocks_workflow_id_workflow_id_fk": { + "name": "workflow_blocks_workflow_id_workflow_id_fk", + "tableFrom": "workflow_blocks", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_checkpoints": { + "name": "workflow_checkpoints", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workflow_state": { + "name": "workflow_state", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_checkpoints_user_id_idx": { + "name": "workflow_checkpoints_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_checkpoints_workflow_id_idx": { + "name": "workflow_checkpoints_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_checkpoints_chat_id_idx": { + "name": "workflow_checkpoints_chat_id_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_checkpoints_message_id_idx": { + "name": "workflow_checkpoints_message_id_idx", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_checkpoints_user_workflow_idx": { + "name": "workflow_checkpoints_user_workflow_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_checkpoints_workflow_chat_idx": { + "name": "workflow_checkpoints_workflow_chat_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_checkpoints_created_at_idx": { + "name": "workflow_checkpoints_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_checkpoints_chat_created_at_idx": { + "name": "workflow_checkpoints_chat_created_at_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_checkpoints_user_id_user_id_fk": { + "name": "workflow_checkpoints_user_id_user_id_fk", + "tableFrom": "workflow_checkpoints", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_checkpoints_workflow_id_workflow_id_fk": { + "name": "workflow_checkpoints_workflow_id_workflow_id_fk", + "tableFrom": "workflow_checkpoints", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_checkpoints_chat_id_copilot_chats_id_fk": { + "name": "workflow_checkpoints_chat_id_copilot_chats_id_fk", + "tableFrom": "workflow_checkpoints", + "tableTo": "copilot_chats", + "columnsFrom": ["chat_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_deployment_version": { + "name": "workflow_deployment_version", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "workflow_deployment_version_workflow_version_unique": { + "name": "workflow_deployment_version_workflow_version_unique", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_deployment_version_workflow_active_idx": { + "name": "workflow_deployment_version_workflow_active_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "is_active", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_deployment_version_created_at_idx": { + "name": "workflow_deployment_version_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_deployment_version_workflow_id_workflow_id_fk": { + "name": "workflow_deployment_version_workflow_id_workflow_id_fk", + "tableFrom": "workflow_deployment_version", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_edges": { + "name": "workflow_edges", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_block_id": { + "name": "source_block_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_block_id": { + "name": "target_block_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_handle": { + "name": "source_handle", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "target_handle": { + "name": "target_handle", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_edges_workflow_id_idx": { + "name": "workflow_edges_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_edges_workflow_source_idx": { + "name": "workflow_edges_workflow_source_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_block_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_edges_workflow_target_idx": { + "name": "workflow_edges_workflow_target_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "target_block_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_edges_workflow_id_workflow_id_fk": { + "name": "workflow_edges_workflow_id_workflow_id_fk", + "tableFrom": "workflow_edges", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_edges_source_block_id_workflow_blocks_id_fk": { + "name": "workflow_edges_source_block_id_workflow_blocks_id_fk", + "tableFrom": "workflow_edges", + "tableTo": "workflow_blocks", + "columnsFrom": ["source_block_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_edges_target_block_id_workflow_blocks_id_fk": { + "name": "workflow_edges_target_block_id_workflow_blocks_id_fk", + "tableFrom": "workflow_edges", + "tableTo": "workflow_blocks", + "columnsFrom": ["target_block_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_execution_logs": { + "name": "workflow_execution_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "execution_id": { + "name": "execution_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state_snapshot_id": { + "name": "state_snapshot_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "deployment_version_id": { + "name": "deployment_version_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'running'" + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "total_duration_ms": { + "name": "total_duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "execution_data": { + "name": "execution_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "cost": { + "name": "cost", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "cost_total": { + "name": "cost_total", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "models_used": { + "name": "models_used", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "files": { + "name": "files", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_execution_logs_workflow_id_idx": { + "name": "workflow_execution_logs_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_state_snapshot_id_idx": { + "name": "workflow_execution_logs_state_snapshot_id_idx", + "columns": [ + { + "expression": "state_snapshot_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_deployment_version_id_idx": { + "name": "workflow_execution_logs_deployment_version_id_idx", + "columns": [ + { + "expression": "deployment_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_trigger_idx": { + "name": "workflow_execution_logs_trigger_idx", + "columns": [ + { + "expression": "trigger", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_level_idx": { + "name": "workflow_execution_logs_level_idx", + "columns": [ + { + "expression": "level", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_started_at_idx": { + "name": "workflow_execution_logs_started_at_idx", + "columns": [ + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_execution_id_unique": { + "name": "workflow_execution_logs_execution_id_unique", + "columns": [ + { + "expression": "execution_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_workflow_started_at_idx": { + "name": "workflow_execution_logs_workflow_started_at_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_workspace_started_at_idx": { + "name": "workflow_execution_logs_workspace_started_at_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_workspace_cost_total_idx": { + "name": "workflow_execution_logs_workspace_cost_total_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "cost_total", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_models_used_idx": { + "name": "workflow_execution_logs_models_used_idx", + "columns": [ + { + "expression": "models_used", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + }, + "workflow_execution_logs_workspace_ended_at_id_idx": { + "name": "workflow_execution_logs_workspace_ended_at_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "date_trunc('milliseconds', \"ended_at\")", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_execution_logs_running_started_at_idx": { + "name": "workflow_execution_logs_running_started_at_idx", + "columns": [ + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "status = 'running'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_execution_logs_workflow_id_workflow_id_fk": { + "name": "workflow_execution_logs_workflow_id_workflow_id_fk", + "tableFrom": "workflow_execution_logs", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "workflow_execution_logs_workspace_id_workspace_id_fk": { + "name": "workflow_execution_logs_workspace_id_workspace_id_fk", + "tableFrom": "workflow_execution_logs", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_execution_logs_state_snapshot_id_workflow_execution_snapshots_id_fk": { + "name": "workflow_execution_logs_state_snapshot_id_workflow_execution_snapshots_id_fk", + "tableFrom": "workflow_execution_logs", + "tableTo": "workflow_execution_snapshots", + "columnsFrom": ["state_snapshot_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + }, + "workflow_execution_logs_deployment_version_id_workflow_deployment_version_id_fk": { + "name": "workflow_execution_logs_deployment_version_id_workflow_deployment_version_id_fk", + "tableFrom": "workflow_execution_logs", + "tableTo": "workflow_deployment_version", + "columnsFrom": ["deployment_version_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_execution_snapshots": { + "name": "workflow_execution_snapshots", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state_hash": { + "name": "state_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state_data": { + "name": "state_data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_snapshots_workflow_id_idx": { + "name": "workflow_snapshots_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_snapshots_hash_idx": { + "name": "workflow_snapshots_hash_idx", + "columns": [ + { + "expression": "state_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_snapshots_workflow_hash_idx": { + "name": "workflow_snapshots_workflow_hash_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "state_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_snapshots_created_at_idx": { + "name": "workflow_snapshots_created_at_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_execution_snapshots_workflow_id_workflow_id_fk": { + "name": "workflow_execution_snapshots_workflow_id_workflow_id_fk", + "tableFrom": "workflow_execution_snapshots", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_folder": { + "name": "workflow_folder", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'#6B7280'" + }, + "is_expanded": { + "name": "is_expanded", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "workflow_folder_user_idx": { + "name": "workflow_folder_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_folder_workspace_parent_idx": { + "name": "workflow_folder_workspace_parent_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_folder_parent_sort_idx": { + "name": "workflow_folder_parent_sort_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sort_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_folder_archived_at_idx": { + "name": "workflow_folder_archived_at_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_folder_workspace_archived_partial_idx": { + "name": "workflow_folder_workspace_archived_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workflow_folder\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_folder_user_id_user_id_fk": { + "name": "workflow_folder_user_id_user_id_fk", + "tableFrom": "workflow_folder", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_folder_workspace_id_workspace_id_fk": { + "name": "workflow_folder_workspace_id_workspace_id_fk", + "tableFrom": "workflow_folder", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_mcp_server": { + "name": "workflow_mcp_server", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_public": { + "name": "is_public", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_mcp_server_workspace_id_idx": { + "name": "workflow_mcp_server_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_mcp_server_created_by_idx": { + "name": "workflow_mcp_server_created_by_idx", + "columns": [ + { + "expression": "created_by", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_mcp_server_deleted_at_idx": { + "name": "workflow_mcp_server_deleted_at_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_mcp_server_workspace_deleted_partial_idx": { + "name": "workflow_mcp_server_workspace_deleted_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workflow_mcp_server\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_mcp_server_workspace_id_workspace_id_fk": { + "name": "workflow_mcp_server_workspace_id_workspace_id_fk", + "tableFrom": "workflow_mcp_server", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_mcp_server_created_by_user_id_fk": { + "name": "workflow_mcp_server_created_by_user_id_fk", + "tableFrom": "workflow_mcp_server", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_mcp_tool": { + "name": "workflow_mcp_tool", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "server_id": { + "name": "server_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool_name": { + "name": "tool_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool_description": { + "name": "tool_description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "parameter_schema": { + "name": "parameter_schema", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_mcp_tool_server_id_idx": { + "name": "workflow_mcp_tool_server_id_idx", + "columns": [ + { + "expression": "server_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_mcp_tool_workflow_id_idx": { + "name": "workflow_mcp_tool_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_mcp_tool_server_workflow_unique": { + "name": "workflow_mcp_tool_server_workflow_unique", + "columns": [ + { + "expression": "server_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"workflow_mcp_tool\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_mcp_tool_archived_at_partial_idx": { + "name": "workflow_mcp_tool_archived_at_partial_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workflow_mcp_tool\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_mcp_tool_server_id_workflow_mcp_server_id_fk": { + "name": "workflow_mcp_tool_server_id_workflow_mcp_server_id_fk", + "tableFrom": "workflow_mcp_tool", + "tableTo": "workflow_mcp_server", + "columnsFrom": ["server_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_mcp_tool_workflow_id_workflow_id_fk": { + "name": "workflow_mcp_tool_workflow_id_workflow_id_fk", + "tableFrom": "workflow_mcp_tool", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_schedule": { + "name": "workflow_schedule", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deployment_version_id": { + "name": "deployment_version_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "block_id": { + "name": "block_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cron_expression": { + "name": "cron_expression", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_run_at": { + "name": "next_run_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_ran_at": { + "name": "last_ran_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_queued_at": { + "name": "last_queued_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "trigger_type": { + "name": "trigger_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'UTC'" + }, + "failed_count": { + "name": "failed_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "infra_retry_count": { + "name": "infra_retry_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "last_failed_at": { + "name": "last_failed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "source_type": { + "name": "source_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'workflow'" + }, + "job_title": { + "name": "job_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lifecycle": { + "name": "lifecycle", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'persistent'" + }, + "success_condition": { + "name": "success_condition", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "max_runs": { + "name": "max_runs", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "run_count": { + "name": "run_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "source_chat_id": { + "name": "source_chat_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_task_name": { + "name": "source_task_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_user_id": { + "name": "source_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_workspace_id": { + "name": "source_workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "job_history": { + "name": "job_history", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_schedule_workflow_block_deployment_unique": { + "name": "workflow_schedule_workflow_block_deployment_unique", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "block_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deployment_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"workflow_schedule\".\"archived_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_schedule_workflow_deployment_idx": { + "name": "workflow_schedule_workflow_deployment_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deployment_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_schedule_archived_at_partial_idx": { + "name": "workflow_schedule_archived_at_partial_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workflow_schedule\".\"archived_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "idx_workflow_schedule_on_source_workspace_id_source_t_c07f3bba6": { + "name": "idx_workflow_schedule_on_source_workspace_id_source_t_c07f3bba6", + "columns": [ + { + "expression": "source_workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_schedule_due_workflow_idx": { + "name": "workflow_schedule_due_workflow_idx", + "columns": [ + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_queued_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deployment_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workflow_schedule\".\"archived_at\" IS NULL AND \"workflow_schedule\".\"status\" NOT IN ('disabled', 'completed') AND (\"workflow_schedule\".\"source_type\" = 'workflow' OR \"workflow_schedule\".\"source_type\" IS NULL)", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_schedule_due_job_idx": { + "name": "workflow_schedule_due_job_idx", + "columns": [ + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_queued_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workflow_schedule\".\"archived_at\" IS NULL AND \"workflow_schedule\".\"status\" NOT IN ('disabled', 'completed') AND \"workflow_schedule\".\"source_type\" = 'job'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_schedule_workflow_id_workflow_id_fk": { + "name": "workflow_schedule_workflow_id_workflow_id_fk", + "tableFrom": "workflow_schedule", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_schedule_deployment_version_id_workflow_deployment_version_id_fk": { + "name": "workflow_schedule_deployment_version_id_workflow_deployment_version_id_fk", + "tableFrom": "workflow_schedule", + "tableTo": "workflow_deployment_version", + "columnsFrom": ["deployment_version_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_schedule_source_user_id_user_id_fk": { + "name": "workflow_schedule_source_user_id_user_id_fk", + "tableFrom": "workflow_schedule", + "tableTo": "user", + "columnsFrom": ["source_user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workflow_schedule_source_workspace_id_workspace_id_fk": { + "name": "workflow_schedule_source_workspace_id_workspace_id_fk", + "tableFrom": "workflow_schedule", + "tableTo": "workspace", + "columnsFrom": ["source_workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_subflows": { + "name": "workflow_subflows", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workflow_id": { + "name": "workflow_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_subflows_workflow_id_idx": { + "name": "workflow_subflows_workflow_id_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workflow_subflows_workflow_type_idx": { + "name": "workflow_subflows_workflow_type_idx", + "columns": [ + { + "expression": "workflow_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_subflows_workflow_id_workflow_id_fk": { + "name": "workflow_subflows_workflow_id_workflow_id_fk", + "tableFrom": "workflow_subflows", + "tableTo": "workflow", + "columnsFrom": ["workflow_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace": { + "name": "workspace", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'#33C482'" + }, + "logo_url": { + "name": "logo_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "workspace_mode": { + "name": "workspace_mode", + "type": "workspace_mode", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'grandfathered_shared'" + }, + "billed_account_user_id": { + "name": "billed_account_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "allow_personal_api_keys": { + "name": "allow_personal_api_keys", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "inbox_enabled": { + "name": "inbox_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "inbox_address": { + "name": "inbox_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "inbox_provider_id": { + "name": "inbox_provider_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_owner_id_idx": { + "name": "workspace_owner_id_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_organization_id_idx": { + "name": "workspace_organization_id_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_mode_idx": { + "name": "workspace_mode_idx", + "columns": [ + { + "expression": "workspace_mode", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_owner_id_user_id_fk": { + "name": "workspace_owner_id_user_id_fk", + "tableFrom": "workspace", + "tableTo": "user", + "columnsFrom": ["owner_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_organization_id_organization_id_fk": { + "name": "workspace_organization_id_organization_id_fk", + "tableFrom": "workspace", + "tableTo": "organization", + "columnsFrom": ["organization_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "workspace_billed_account_user_id_user_id_fk": { + "name": "workspace_billed_account_user_id_user_id_fk", + "tableFrom": "workspace", + "tableTo": "user", + "columnsFrom": ["billed_account_user_id"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_byok_keys": { + "name": "workspace_byok_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encrypted_api_key": { + "name": "encrypted_api_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_byok_workspace_provider_idx": { + "name": "workspace_byok_workspace_provider_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_byok_workspace_idx": { + "name": "workspace_byok_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_byok_keys_workspace_id_workspace_id_fk": { + "name": "workspace_byok_keys_workspace_id_workspace_id_fk", + "tableFrom": "workspace_byok_keys", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_byok_keys_created_by_user_id_fk": { + "name": "workspace_byok_keys_created_by_user_id_fk", + "tableFrom": "workspace_byok_keys", + "tableTo": "user", + "columnsFrom": ["created_by"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_environment": { + "name": "workspace_environment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "variables": { + "name": "variables", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_environment_workspace_unique": { + "name": "workspace_environment_workspace_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_environment_workspace_id_workspace_id_fk": { + "name": "workspace_environment_workspace_id_workspace_id_fk", + "tableFrom": "workspace_environment", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_file": { + "name": "workspace_file", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "uploaded_at": { + "name": "uploaded_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_file_workspace_id_idx": { + "name": "workspace_file_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_file_key_idx": { + "name": "workspace_file_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_file_deleted_at_idx": { + "name": "workspace_file_deleted_at_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_file_workspace_deleted_partial_idx": { + "name": "workspace_file_workspace_deleted_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workspace_file\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_file_workspace_id_workspace_id_fk": { + "name": "workspace_file_workspace_id_workspace_id_fk", + "tableFrom": "workspace_file", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_file_uploaded_by_user_id_fk": { + "name": "workspace_file_uploaded_by_user_id_fk", + "tableFrom": "workspace_file", + "tableTo": "user", + "columnsFrom": ["uploaded_by"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "workspace_file_key_unique": { + "name": "workspace_file_key_unique", + "nullsNotDistinct": false, + "columns": ["key"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_file_folders": { + "name": "workspace_file_folders", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_file_folders_workspace_parent_idx": { + "name": "workspace_file_folders_workspace_parent_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_file_folders_parent_sort_idx": { + "name": "workspace_file_folders_parent_sort_idx", + "columns": [ + { + "expression": "parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sort_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_file_folders_deleted_at_idx": { + "name": "workspace_file_folders_deleted_at_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_file_folders_workspace_deleted_partial_idx": { + "name": "workspace_file_folders_workspace_deleted_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workspace_file_folders\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_file_folders_workspace_parent_name_active_unique": { + "name": "workspace_file_folders_workspace_parent_name_active_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "coalesce(\"parent_id\", '')", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"workspace_file_folders\".\"deleted_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_file_folders_user_id_user_id_fk": { + "name": "workspace_file_folders_user_id_user_id_fk", + "tableFrom": "workspace_file_folders", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_file_folders_workspace_id_workspace_id_fk": { + "name": "workspace_file_folders_workspace_id_workspace_id_fk", + "tableFrom": "workspace_file_folders", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_file_folders_parent_id_workspace_file_folders_id_fk": { + "name": "workspace_file_folders_parent_id_workspace_file_folders_id_fk", + "tableFrom": "workspace_file_folders", + "tableTo": "workspace_file_folders", + "columnsFrom": ["parent_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_files": { + "name": "workspace_files", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "folder_id": { + "name": "folder_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "context": { + "name": "context", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "original_name": { + "name": "original_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "uploaded_at": { + "name": "uploaded_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_files_key_active_unique": { + "name": "workspace_files_key_active_unique", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"workspace_files\".\"deleted_at\" IS NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_workspace_folder_name_active_unique": { + "name": "workspace_files_workspace_folder_name_active_unique", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "coalesce(\"folder_id\", '')", + "asc": true, + "isExpression": true, + "nulls": "last" + }, + { + "expression": "original_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"workspace_files\".\"deleted_at\" IS NULL AND \"workspace_files\".\"context\" = 'workspace' AND \"workspace_files\".\"workspace_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_chat_display_name_unique": { + "name": "workspace_files_chat_display_name_unique", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "display_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"workspace_files\".\"context\" = 'mothership' AND \"workspace_files\".\"chat_id\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_key_idx": { + "name": "workspace_files_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_user_id_idx": { + "name": "workspace_files_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_workspace_id_idx": { + "name": "workspace_files_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_folder_id_idx": { + "name": "workspace_files_folder_id_idx", + "columns": [ + { + "expression": "folder_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_context_idx": { + "name": "workspace_files_context_idx", + "columns": [ + { + "expression": "context", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_chat_id_idx": { + "name": "workspace_files_chat_id_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_deleted_at_idx": { + "name": "workspace_files_deleted_at_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_files_workspace_deleted_partial_idx": { + "name": "workspace_files_workspace_deleted_partial_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"workspace_files\".\"deleted_at\" IS NOT NULL", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_files_user_id_user_id_fk": { + "name": "workspace_files_user_id_user_id_fk", + "tableFrom": "workspace_files", + "tableTo": "user", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_files_workspace_id_workspace_id_fk": { + "name": "workspace_files_workspace_id_workspace_id_fk", + "tableFrom": "workspace_files", + "tableTo": "workspace", + "columnsFrom": ["workspace_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_files_folder_id_workspace_file_folders_id_fk": { + "name": "workspace_files_folder_id_workspace_file_folders_id_fk", + "tableFrom": "workspace_files", + "tableTo": "workspace_file_folders", + "columnsFrom": ["folder_id"], + "columnsTo": ["id"], + "onDelete": "set null", + "onUpdate": "no action" + }, + "workspace_files_chat_id_copilot_chats_id_fk": { + "name": "workspace_files_chat_id_copilot_chats_id_fk", + "tableFrom": "workspace_files", + "tableTo": "copilot_chats", + "columnsFrom": ["chat_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.a2a_task_status": { + "name": "a2a_task_status", + "schema": "public", + "values": [ + "submitted", + "working", + "input-required", + "completed", + "failed", + "canceled", + "rejected", + "auth-required", + "unknown" + ] + }, + "public.academy_cert_status": { + "name": "academy_cert_status", + "schema": "public", + "values": ["active", "revoked", "expired"] + }, + "public.billing_blocked_reason": { + "name": "billing_blocked_reason", + "schema": "public", + "values": ["payment_failed", "dispute"] + }, + "public.billing_entity_type": { + "name": "billing_entity_type", + "schema": "public", + "values": ["user", "organization"] + }, + "public.chat_type": { + "name": "chat_type", + "schema": "public", + "values": ["mothership", "copilot"] + }, + "public.copilot_async_tool_status": { + "name": "copilot_async_tool_status", + "schema": "public", + "values": ["pending", "running", "completed", "failed", "cancelled", "delivered"] + }, + "public.copilot_run_status": { + "name": "copilot_run_status", + "schema": "public", + "values": ["active", "paused_waiting_for_tool", "resuming", "complete", "error", "cancelled"] + }, + "public.credential_member_role": { + "name": "credential_member_role", + "schema": "public", + "values": ["admin", "member"] + }, + "public.credential_member_status": { + "name": "credential_member_status", + "schema": "public", + "values": ["active", "pending", "revoked"] + }, + "public.credential_set_invitation_status": { + "name": "credential_set_invitation_status", + "schema": "public", + "values": ["pending", "accepted", "expired", "cancelled"] + }, + "public.credential_set_member_status": { + "name": "credential_set_member_status", + "schema": "public", + "values": ["active", "pending", "revoked"] + }, + "public.credential_type": { + "name": "credential_type", + "schema": "public", + "values": ["oauth", "env_workspace", "env_personal", "service_account"] + }, + "public.data_drain_cadence": { + "name": "data_drain_cadence", + "schema": "public", + "values": ["hourly", "daily"] + }, + "public.data_drain_destination": { + "name": "data_drain_destination", + "schema": "public", + "values": ["s3", "gcs", "azure_blob", "datadog", "bigquery", "snowflake", "webhook"] + }, + "public.data_drain_run_status": { + "name": "data_drain_run_status", + "schema": "public", + "values": ["running", "success", "failed"] + }, + "public.data_drain_run_trigger": { + "name": "data_drain_run_trigger", + "schema": "public", + "values": ["cron", "manual"] + }, + "public.data_drain_source": { + "name": "data_drain_source", + "schema": "public", + "values": ["workflow_logs", "job_logs", "audit_logs", "copilot_chats", "copilot_runs"] + }, + "public.execution_large_value_reference_source": { + "name": "execution_large_value_reference_source", + "schema": "public", + "values": ["execution_log", "paused_snapshot"] + }, + "public.invitation_kind": { + "name": "invitation_kind", + "schema": "public", + "values": ["organization", "workspace"] + }, + "public.invitation_membership_intent": { + "name": "invitation_membership_intent", + "schema": "public", + "values": ["internal", "external"] + }, + "public.invitation_status": { + "name": "invitation_status", + "schema": "public", + "values": ["pending", "accepted", "rejected", "cancelled", "expired"] + }, + "public.permission_type": { + "name": "permission_type", + "schema": "public", + "values": ["admin", "write", "read"] + }, + "public.usage_log_category": { + "name": "usage_log_category", + "schema": "public", + "values": ["model", "fixed", "tool"] + }, + "public.usage_log_source": { + "name": "usage_log_source", + "schema": "public", + "values": [ + "workflow", + "wand", + "copilot", + "workspace-chat", + "mcp_copilot", + "mothership_block", + "knowledge-base", + "voice-input", + "enrichment" + ] + }, + "public.workspace_mode": { + "name": "workspace_mode", + "schema": "public", + "values": ["personal", "organization", "grandfathered_shared"] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/packages/db/migrations/meta/_journal.json b/packages/db/migrations/meta/_journal.json index 56fb1dbedf1..3be5f2aa0b8 100644 --- a/packages/db/migrations/meta/_journal.json +++ b/packages/db/migrations/meta/_journal.json @@ -1632,6 +1632,13 @@ "when": 1781227386156, "tag": "0233_table_jobs_and_keyset", "breakpoints": true + }, + { + "idx": 234, + "version": "7", + "when": 1781277096869, + "tag": "0234_analyze_user_table_rows", + "breakpoints": true } ] } From e2523e0fb546f4fe3acc99b350242bf4acd45653 Mon Sep 17 00:00:00 2001 From: Waleed Date: Fri, 12 Jun 2026 10:29:58 -0700 Subject: [PATCH 3/5] improvement(tables): migrate inputs to emcn chip components and clean up tables feature (#4995) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * improvement(tables): migrate inputs to emcn chip components and clean up tables feature * fix(tables): address review feedback — stale filter column label, shared FieldError in enrichment config * improvement(tables): scope create-table callback to stable mutateAsync --- .../column-config-sidebar.tsx | 33 +++-- .../enrichments-sidebar/enrichment-config.tsx | 18 ++- .../enrichments-sidebar.tsx | 39 +++--- .../tables/[tableId]/components/index.ts | 1 + .../components/sidebar-fields/index.ts | 1 + .../sidebar-fields/sidebar-fields.tsx | 30 +++++ .../table-action-bar/table-action-bar.tsx | 108 ++++++++-------- .../components/table-filter/table-filter.tsx | 95 ++++++-------- .../cells/expanded-cell-popover.tsx | 122 +++++++++++------- .../components/table-grid/table-find.tsx | 6 +- .../workflow-sidebar/run-settings-section.tsx | 2 +- .../workflow-sidebar/workflow-sidebar.tsx | 27 ++-- .../[workspaceId]/tables/[tableId]/table.tsx | 18 ++- .../workspace/[workspaceId]/tables/tables.tsx | 29 +++-- apps/sim/hooks/queries/tables.ts | 42 +----- 15 files changed, 291 insertions(+), 280 deletions(-) create mode 100644 apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/sidebar-fields/index.ts create mode 100644 apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/sidebar-fields/sidebar-fields.tsx diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/column-config-sidebar/column-config-sidebar.tsx b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/column-config-sidebar/column-config-sidebar.tsx index 12aa2fdf5c8..e433cfa5a6c 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/column-config-sidebar/column-config-sidebar.tsx +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/column-config-sidebar/column-config-sidebar.tsx @@ -1,13 +1,24 @@ 'use client' -import type React from 'react' import { useState } from 'react' import { toError } from '@sim/utils/errors' -import { X } from 'lucide-react' -import { Button, ChipCombobox, FieldDivider, Input, Label, Switch, toast } from '@/components/emcn' +import { + Button, + ChipCombobox, + ChipInput, + FieldDivider, + Label, + Switch, + toast, +} from '@/components/emcn' +import { X } from '@/components/emcn/icons' import { findValidationIssue, isValidationError } from '@/lib/api/client/errors' import { cn } from '@/lib/core/utils/cn' import type { ColumnDefinition } from '@/lib/table' +import { + FieldError, + RequiredLabel, +} from '@/app/workspace/[workspaceId]/tables/[tableId]/components/sidebar-fields' import { useAddTableColumn, useUpdateColumn } from '@/hooks/queries/tables' import { PLAIN_COLUMN_TYPE_OPTIONS } from './column-types' @@ -169,7 +180,7 @@ function ColumnConfigBody({
Column name - { @@ -178,6 +189,7 @@ function ColumnConfigBody({ }} spellCheck={false} autoComplete='off' + error={Boolean((showValidation && !trimmedName) || nameError)} aria-invalid={(showValidation && !trimmedName) || nameError ? true : undefined} /> {showValidation && !trimmedName && } @@ -228,16 +240,3 @@ function ColumnConfigBody({
) } - -function RequiredLabel({ htmlFor, children }: { htmlFor?: string; children: React.ReactNode }) { - return ( - - ) -} - -function FieldError({ message }: { message: string }) { - return

{message}

-} diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/enrichments-sidebar/enrichment-config.tsx b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/enrichments-sidebar/enrichment-config.tsx index 3c30675fa3f..2a73836215d 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/enrichments-sidebar/enrichment-config.tsx +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/enrichments-sidebar/enrichment-config.tsx @@ -7,18 +7,18 @@ import { Badge, Button, ChipCombobox, + ChipInput, CollapsibleCard, FieldDivider, - Input, Label, Switch, toast, } from '@/components/emcn' import { ArrowLeft, X } from '@/components/emcn/icons' import type { AddWorkflowGroupBodyInput } from '@/lib/api/contracts/tables' -import { cn } from '@/lib/core/utils/cn' import type { ColumnDefinition, WorkflowGroup, WorkflowGroupOutput } from '@/lib/table' import { deriveOutputColumnName } from '@/lib/table/column-naming' +import { FieldError } from '@/app/workspace/[workspaceId]/tables/[tableId]/components/sidebar-fields' import type { EnrichmentConfig as EnrichmentDef } from '@/enrichments/types' import { useAddWorkflowGroup, @@ -280,12 +280,10 @@ export function EnrichmentConfig({ onChange={(columnName: string) => setInputMappings((prev) => ({ ...prev, [input.id]: columnName })) } - error={ - showValidation && input.required && !inputMappings[input.id] - ? 'Required' - : null - } /> + {showValidation && input.required && !inputMappings[input.id] && ( + + )} ))}
@@ -317,16 +315,16 @@ export function EnrichmentConfig({ } > - setOutputNames((prev) => ({ ...prev, [output.id]: e.target.value })) } spellCheck={false} autoComplete='off' - className={cn(outErr && 'border-[var(--text-error)]')} + error={Boolean(outErr)} /> - {outErr &&

{outErr}

} + {outErr && } ) })} diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/enrichments-sidebar/enrichments-sidebar.tsx b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/enrichments-sidebar/enrichments-sidebar.tsx index a2575b4b43f..01b016b4cef 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/enrichments-sidebar/enrichments-sidebar.tsx +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/enrichments-sidebar/enrichments-sidebar.tsx @@ -1,7 +1,7 @@ 'use client' import { useState } from 'react' -import { Input } from '@/components/emcn' +import { Button, ChipInput } from '@/components/emcn' import { Search, X } from '@/components/emcn/icons' import { cn } from '@/lib/core/utils/cn' import type { ColumnDefinition, WorkflowGroup } from '@/lib/table' @@ -74,14 +74,15 @@ function EnrichmentsSidebarBody({

Enrichment

- +

@@ -119,28 +120,26 @@ function EnrichmentsSidebarBody({

Enrichments

- +
-
- - setQuery(e.target.value)} - placeholder='Search' - spellCheck={false} - autoComplete='off' - className='pl-7' - /> -
+ setQuery(e.target.value)} + placeholder='Search' + spellCheck={false} + autoComplete='off' + />
diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/index.ts b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/index.ts index 34b5f41f5fa..02d4710b130 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/index.ts +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/index.ts @@ -4,6 +4,7 @@ export * from './enrichments-sidebar' export * from './new-column-dropdown' export * from './row-modal' export * from './run-status-control' +export * from './sidebar-fields' export * from './table-action-bar' export * from './table-filter' export * from './table-grid' diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/sidebar-fields/index.ts b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/sidebar-fields/index.ts new file mode 100644 index 00000000000..b8175522f14 --- /dev/null +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/sidebar-fields/index.ts @@ -0,0 +1 @@ +export { FieldError, RequiredLabel } from './sidebar-fields' diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/sidebar-fields/sidebar-fields.tsx b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/sidebar-fields/sidebar-fields.tsx new file mode 100644 index 00000000000..d08ad20bbfc --- /dev/null +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/sidebar-fields/sidebar-fields.tsx @@ -0,0 +1,30 @@ +'use client' + +import type React from 'react' +import { Label } from '@/components/emcn' + +/** + * Field label with a trailing required marker, matching the sidebar field + * rhythm shared by the column-config and workflow sidebars. + */ +export function RequiredLabel({ + htmlFor, + children, +}: { + htmlFor?: string + children: React.ReactNode +}) { + return ( + + ) +} + +/** + * Inline validation error rendered under a sidebar field. + */ +export function FieldError({ message }: { message: string }) { + return

{message}

+} diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-action-bar/table-action-bar.tsx b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-action-bar/table-action-bar.tsx index c29a140d29c..eff97d3e890 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-action-bar/table-action-bar.tsx +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-action-bar/table-action-bar.tsx @@ -1,5 +1,6 @@ 'use client' +import type React from 'react' import { AnimatePresence, domAnimation, LazyMotion, m } from 'framer-motion' import { Button, Tooltip } from '@/components/emcn' import { Eye, PlayOutline, RefreshCw, Square } from '@/components/emcn/icons' @@ -98,71 +99,35 @@ export function TableActionBar({
{showPlay && ( - - - - - {playLabel} - + + + )} {showRefresh && ( - - - - - {refreshLabel} - + + + )} {runningCount > 0 && ( - - - - - {stopLabel} - + + + )} {onViewExecution && ( - - - - - View execution - + + + )}
@@ -172,3 +137,34 @@ export function TableActionBar({ ) } + +interface ActionIconButtonProps { + /** Tooltip text, also used as the button's accessible label. */ + label: string + onClick: () => void + disabled: boolean + children: React.ReactNode +} + +/** + * Tooltip-wrapped icon button sharing the action bar's brand-hover chrome, + * so the chrome string lives in one place. + */ +function ActionIconButton({ label, onClick, disabled, children }: ActionIconButtonProps) { + return ( + + + + + {label} + + ) +} diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-filter/table-filter.tsx b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-filter/table-filter.tsx index 7b0737f6fd1..9d9800bffe3 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-filter/table-filter.tsx +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-filter/table-filter.tsx @@ -2,24 +2,13 @@ import { memo, useCallback, useMemo, useRef, useState } from 'react' import { generateShortId } from '@sim/utils/id' -import { X } from 'lucide-react' -import { - Button, - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from '@/components/emcn' -import { ChevronDown, Plus } from '@/components/emcn/icons' +import { Button, ChipDropdown, ChipInput } from '@/components/emcn' +import { Plus, X } from '@/components/emcn/icons' import type { ColumnDefinition, Filter, FilterRule } from '@/lib/table' import { getColumnId } from '@/lib/table/column-keys' import { COMPARISON_OPERATORS, VALUELESS_OPERATORS } from '@/lib/table/query-builder/constants' import { filterRulesToFilter, filterToRules } from '@/lib/table/query-builder/converters' -const OPERATOR_LABELS = Object.fromEntries( - COMPARISON_OPERATORS.map((op) => [op.value, op.label]) -) as Record - interface TableFilterProps { columns: ColumnDefinition[] filter: Filter | null @@ -150,6 +139,14 @@ const FilterRuleRow = memo(function FilterRuleRow({ onApply, onToggleLogical, }: FilterRuleRowProps) { + // Keep a stale column id selectable/visible (e.g. after the column was + // removed) instead of falling back to the placeholder while the rule still + // filters on it. + const columnOptions = + rule.column && !columns.some((col) => col.value === rule.column) + ? [...columns, { value: rule.column, label: rule.column }] + : columns + return (
{isFirst ? ( @@ -163,67 +160,49 @@ const FilterRuleRow = memo(function FilterRuleRow({ )} - - - - - - {columns.map((col) => ( - onUpdate(rule.id, 'column', col.value)} - > - {col.label} - - ))} - - - - - - - - - {COMPARISON_OPERATORS.map((op) => ( - onUpdate(rule.id, 'operator', op.value)} - > - {op.label} - - ))} - - + onUpdate(rule.id, 'column', value)} + placeholder='Column' + align='start' + matchTriggerWidth={false} + className='min-w-[100px]' + /> + + onUpdate(rule.id, 'operator', value)} + placeholder='Operator' + align='start' + matchTriggerWidth={false} + className='min-w-[90px]' + /> {VALUELESS_OPERATORS.has(rule.operator) ? (
) : ( - onUpdate(rule.id, 'value', e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') onApply() }} placeholder='Enter a value' - className='h-[30px] flex-1 rounded-lg border border-[var(--border-1)] bg-[var(--surface-5)] px-2 text-[var(--text-secondary)] text-xs outline-none placeholder:text-[var(--text-subtle)] dark:bg-[var(--surface-4)]' + className='flex-1' /> )} - +
) }) diff --git a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/cells/expanded-cell-popover.tsx b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/cells/expanded-cell-popover.tsx index f499a41633e..d610d99bc60 100644 --- a/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/cells/expanded-cell-popover.tsx +++ b/apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/cells/expanded-cell-popover.tsx @@ -40,7 +40,6 @@ export function ExpandedCellPopover({ const rootRef = useRef(null) const textareaRef = useRef(null) const [rect, setRect] = useState<{ top: number; left: number; width: number } | null>(null) - const [draftValue, setDraftValue] = useState('') const target = useMemo(() => { if (!expandedCell) return null @@ -75,7 +74,6 @@ export function ExpandedCellPopover({ setRect(null) return } - setDraftValue(isEditable ? formatValueForInput(target.value, target.column.type) : '') const selector = `[data-table-scroll] [data-row-id="${target.row.id}"][data-col="${target.colIndex}"]` const el = document.querySelector(selector) if (!el) { @@ -86,7 +84,7 @@ export function ExpandedCellPopover({ setRect({ top: r.top, left: r.left, width: r.width }) // Focus textarea on open so typing works immediately. requestAnimationFrame(() => textareaRef.current?.focus()) - }, [expandedCell, target, isEditable]) + }, [expandedCell, target]) const onCloseEvent = useEffectEvent(onClose) @@ -136,23 +134,6 @@ export function ExpandedCellPopover({ ? Math.max(VIEWPORT_PAD, window.innerHeight - EXPANDED_CELL_HEIGHT - VIEWPORT_PAD) : rect.top - const handleSave = () => { - if (!isEditable) return - // `displayToStorage` only normalizes dates — it returns null for anything else. - // Fall back to the raw draft for non-date columns, matching the inline editor. - const raw = displayToStorage(draftValue) ?? draftValue - const cleaned = cleanCellValue(raw, target.column) - onSave(target.row.id, target.column.key, cleaned, 'blur') - onClose() - } - - const handleTextareaKeyDown = (e: React.KeyboardEvent) => { - if (e.key === 'Enter' && !e.shiftKey) { - e.preventDefault() - handleSave() - } - } - return (
{isEditable ? ( - <> -