Files
claude-mem/plugin/scripts/mcp-server.cjs
Alex Newman f21ea97c39 refactor: decompose monolith into modular architecture with comprehensive test suite (#538)
* fix: prevent memory_session_id from equaling content_session_id

The bug: memory_session_id was initialized to contentSessionId as a
"placeholder for FK purposes". This caused the SDK resume logic to
inject memory agent messages into the USER's Claude Code transcript,
corrupting their conversation history.

Root cause:
- SessionStore.createSDKSession initialized memory_session_id = contentSessionId
- SDKAgent checked memorySessionId !== contentSessionId but this check
  only worked if the session was fetched fresh from DB

The fix:
- SessionStore: Initialize memory_session_id as NULL, not contentSessionId
- SDKAgent: Simple truthy check !!session.memorySessionId (NULL = fresh start)
- Database migration: Ran UPDATE to set memory_session_id = NULL for 1807
  existing sessions that had the bug

Also adds [ALIGNMENT] logging across the session lifecycle to help debug
session continuity issues:
- Hook entry: contentSessionId + promptNumber
- DB lookup: contentSessionId → memorySessionId mapping proof
- Resume decision: shows which memorySessionId will be used for resume
- Capture: logs when memorySessionId is captured from first SDK response

UI: Added "Alignment" quick filter button in LogsModal to show only
alignment logs for debugging session continuity.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: improve error handling in worker-service.ts

- Fix GENERIC_CATCH anti-patterns by logging full error objects instead of just messages
- Add [ANTI-PATTERN IGNORED] markers for legitimate cases (cleanup, hot paths)
- Simplify error handling comments to be more concise
- Improve httpShutdown() error discrimination for ECONNREFUSED
- Reduce LARGE_TRY_BLOCK issues in initialization code

Part of anti-pattern cleanup plan (132 total issues)

* refactor: improve error logging in SearchManager.ts

- Pass full error objects to logger instead of just error.message
- Fixes PARTIAL_ERROR_LOGGING anti-patterns (10 instances)
- Better debugging visibility when Chroma queries fail

Part of anti-pattern cleanup (133 remaining)

* refactor: improve error logging across SessionStore and mcp-server

- SessionStore.ts: Fix error logging in column rename utility
- mcp-server.ts: Log full error objects instead of just error.message
- Improve error handling in Worker API calls and tool execution

Part of anti-pattern cleanup (133 remaining)

* Refactor hooks to streamline error handling and loading states

- Simplified error handling in useContextPreview by removing try-catch and directly checking response status.
- Refactored usePagination to eliminate try-catch, improving readability and maintaining error handling through response checks.
- Cleaned up useSSE by removing unnecessary try-catch around JSON parsing, ensuring clarity in message handling.
- Enhanced useSettings by streamlining the saving process, removing try-catch, and directly checking the result for success.

* refactor: add error handling back to SearchManager Chroma calls

- Wrap queryChroma calls in try-catch to prevent generator crashes
- Log Chroma errors as warnings and fall back gracefully
- Fixes generator failures when Chroma has issues
- Part of anti-pattern cleanup recovery

* feat: Add generator failure investigation report and observation duplication regression report

- Created a comprehensive investigation report detailing the root cause of generator failures during anti-pattern cleanup, including the impact, investigation process, and implemented fixes.
- Documented the critical regression causing observation duplication due to race conditions in the SDK agent, outlining symptoms, root cause analysis, and proposed fixes.

* fix: address PR #528 review comments - atomic cleanup and detector improvements

This commit addresses critical review feedback from PR #528:

## 1. Atomic Message Cleanup (Fix Race Condition)

**Problem**: SessionRoutes.ts generator error handler had race condition
- Queried messages then marked failed in loop
- If crash during loop → partial marking → inconsistent state

**Solution**:
- Added `markSessionMessagesFailed()` to PendingMessageStore.ts
- Single atomic UPDATE statement replaces loop
- Follows existing pattern from `resetProcessingToPending()`

**Files**:
- src/services/sqlite/PendingMessageStore.ts (new method)
- src/services/worker/http/routes/SessionRoutes.ts (use new method)

## 2. Anti-Pattern Detector Improvements

**Problem**: Detector didn't recognize logger.failure() method
- Lines 212 & 335 already included "failure"
- Lines 112-113 (PARTIAL_ERROR_LOGGING detection) did not

**Solution**: Updated regex patterns to include "failure" for consistency

**Files**:
- scripts/anti-pattern-test/detect-error-handling-antipatterns.ts

## 3. Documentation

**PR Comment**: Added clarification on memory_session_id fix location
- Points to SessionStore.ts:1155
- Explains why NULL initialization prevents message injection bug

## Review Response

Addresses "Must Address Before Merge" items from review:
 Clarified memory_session_id bug fix location (via PR comment)
 Made generator error handler message cleanup atomic
 Deferred comprehensive test suite to follow-up PR (keeps PR focused)

## Testing

- Build passes with no errors
- Anti-pattern detector runs successfully
- Atomic cleanup follows proven pattern from existing methods

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix: FOREIGN KEY constraint and missing failed_at_epoch column

Two critical bugs fixed:

1. Missing failed_at_epoch column in pending_messages table
   - Added migration 20 to create the column
   - Fixes error when trying to mark messages as failed

2. FOREIGN KEY constraint failed when storing observations
   - All three agents (SDK, Gemini, OpenRouter) were passing
     session.contentSessionId instead of session.memorySessionId
   - storeObservationsAndMarkComplete expects memorySessionId
   - Added null check and clear error message

However, observations still not saving - see investigation report.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* Refactor hook input parsing to improve error handling

- Added a nested try-catch block in new-hook.ts, save-hook.ts, and summary-hook.ts to handle JSON parsing errors more gracefully.
- Replaced direct error throwing with logging of the error details using logger.error.
- Ensured that the process exits cleanly after handling input in all three hooks.

* docs: add monolith refactor report with system breakdown

Comprehensive analysis of codebase identifying:
- 14 files over 500 lines requiring refactoring
- 3 critical monoliths (SessionStore, SearchManager, worker-service)
- 80% code duplication across agent files
- 5-phase refactoring roadmap with domain-based architecture

* docs: update monolith report post session-logging merge

- SessionStore grew to 2,011 lines (49 methods) - highest priority
- SearchManager reduced to 1,778 lines (improved)
- Agent files reduced by ~45 lines combined
- Added trend indicators and post-merge observations
- Core refactoring proposal remains valid

* refactor(sqlite): decompose SessionStore into modular architecture

Extract the 2011-line SessionStore.ts monolith into focused, single-responsibility
modules following grep-optimized progressive disclosure pattern:

New module structure:
- sessions/ - Session creation and retrieval (create.ts, get.ts, types.ts)
- observations/ - Observation storage and queries (store.ts, get.ts, recent.ts, files.ts, types.ts)
- summaries/ - Summary storage and queries (store.ts, get.ts, recent.ts, types.ts)
- prompts/ - User prompt management (store.ts, get.ts, types.ts)
- timeline/ - Cross-entity timeline queries (queries.ts)
- import/ - Bulk import operations (bulk.ts)
- migrations/ - Database migrations (runner.ts)

New coordinator files:
- Database.ts - ClaudeMemDatabase class with re-exports
- transactions.ts - Atomic cross-entity transactions
- Named re-export facades (Sessions.ts, Observations.ts, etc.)

Key design decisions:
- All functions take `db: Database` as first parameter (functional style)
- Named re-exports instead of index.ts for grep-friendliness
- SessionStore retained as backward-compatible wrapper
- Target file size: 50-150 lines (60% compliance)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor(agents): extract shared logic into modular architecture

Consolidate duplicate code across SDKAgent, GeminiAgent, and OpenRouterAgent
into focused utility modules. Total reduction: 500 lines (29%).

New modules in src/services/worker/agents/:
- ResponseProcessor.ts: Atomic DB transactions, Chroma sync, SSE broadcast
- ObservationBroadcaster.ts: SSE event formatting and dispatch
- SessionCleanupHelper.ts: Session state cleanup and stuck message reset
- FallbackErrorHandler.ts: Provider error detection for fallback logic
- types.ts: Shared interfaces (WorkerRef, SSE payloads, StorageResult)

Bug fix: SDKAgent was incorrectly using obs.files instead of obs.files_read
and hardcoding files_modified to empty array.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor(search): extract search strategies into modular architecture

Decompose SearchManager into focused strategy pattern with:
- SearchOrchestrator: Coordinates strategy selection and fallback
- ChromaSearchStrategy: Vector semantic search via ChromaDB
- SQLiteSearchStrategy: Filter-only queries for date/project/type
- HybridSearchStrategy: Metadata filtering + semantic ranking
- ResultFormatter: Markdown table formatting for results
- TimelineBuilder: Chronological timeline construction
- Filter modules: DateFilter, ProjectFilter, TypeFilter

SearchManager now delegates to new infrastructure while maintaining
full backward compatibility with existing public API.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor(context): decompose context-generator into modular architecture

Extract 660-line monolith into focused components:
- ContextBuilder: Main orchestrator (~160 lines)
- ContextConfigLoader: Configuration loading
- TokenCalculator: Token budget calculations
- ObservationCompiler: Data retrieval and query building
- MarkdownFormatter/ColorFormatter: Output formatting
- Section renderers: Header, Timeline, Summary, Footer

Maintains full backward compatibility - context-generator.ts now
delegates to new ContextBuilder while preserving public API.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor(worker): decompose worker-service into modular infrastructure

Split 2000+ line monolith into focused modules:

Infrastructure:
- ProcessManager: PID files, signal handlers, child process cleanup
- HealthMonitor: Port checks, health polling, version matching
- GracefulShutdown: Coordinated cleanup on exit

Server:
- Server: Express app setup, core routes, route registration
- Middleware: Re-exports from existing middleware
- ErrorHandler: Centralized error handling with AppError class

Integrations:
- CursorHooksInstaller: Full Cursor IDE integration (registry, hooks, MCP)

WorkerService now acts as thin coordinator wiring all components together.
Maintains full backward compatibility with existing public API.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Refactor session queue processing and database interactions

- Implement claim-and-delete pattern in SessionQueueProcessor to simplify message handling and eliminate duplicate processing.
- Update PendingMessageStore to support atomic claim-and-delete operations, removing the need for intermediate processing states.
- Introduce storeObservations method in SessionStore for simplified observation and summary storage without message tracking.
- Remove deprecated methods and clean up session state management in worker agents.
- Adjust response processing to accommodate new storage patterns, ensuring atomic transactions for observations and summaries.
- Remove unnecessary reset logic for stuck messages due to the new queue handling approach.

* Add duplicate observation cleanup script

Script to clean up duplicate observations created by the batching bug
where observations were stored once per message ID instead of once per
observation. Includes safety checks to always keep at least one copy.

Usage:
  bun scripts/cleanup-duplicates.ts           # Dry run
  bun scripts/cleanup-duplicates.ts --execute # Delete duplicates
  bun scripts/cleanup-duplicates.ts --aggressive # Ignore time window

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(sqlite): add comprehensive test suite for SQLite repositories

Add 44 tests across 5 test files covering:
- Sessions: CRUD operations and schema validation
- Observations: creation, retrieval, filtering, and ordering
- Prompts: persistence and association with observations
- Summaries: generation tracking and session linkage
- Transactions: context management and rollback behavior

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(worker): add comprehensive test suites for worker agent modules

Add test coverage for response-processor, observation-broadcaster,
session-cleanup-helper, and fallback-error-handler agents. Fix type
import issues across search module (use `import type` for type-only
imports) and update worker-service main module detection for ESM/CJS
compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(search): add comprehensive test suites for search module

Add test coverage for the refactored search architecture:
- SearchOrchestrator: query coordination and caching
- ResultFormatter: pagination, sorting, and field mapping
- SQLiteSearchStrategy: database search operations
- ChromaSearchStrategy: vector similarity search
- HybridSearchStrategy: combined search with score fusion

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(context): add comprehensive test suites for context-generator modules

Add test coverage for the modular context-generator architecture:
- context-builder.test.ts: Tests for context building and result assembly
- observation-compiler.test.ts: Tests for observation compilation with privacy tags
- token-calculator.test.ts: Tests for token budget calculations
- formatters/markdown-formatter.test.ts: Tests for markdown output formatting

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(infrastructure): add comprehensive test suites for worker infrastructure modules

Add test coverage for graceful-shutdown, health-monitor, and process-manager
modules extracted during the worker-service refactoring. All 32 tests pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(server): add comprehensive test suites for server modules

Add test coverage for Express server infrastructure:
- error-handler.test.ts: Tests error handling middleware including
  validation errors, database errors, and async error handling
- server.test.ts: Tests server initialization, middleware configuration,
  and route mounting for all API endpoints

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore(package): add test scripts for modular test suites

Add npm run scripts to simplify running tests:
- test: run all tests
- test:sqlite, test:agents, test:search, test:context, test:infra, test:server

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* build assets

* feat(tests): add detailed failure analysis reports for session ID refactor, validation, and store tests

- Created reports for session ID refactor test failures, highlighting 8 failures due to design mismatches.
- Added session ID usage validation report detailing 10 failures caused by outdated assumptions in tests.
- Documented session store test failures, focusing on foreign key constraint violations in 2 tests.
- Compiled a comprehensive test suite report summarizing overall test results, including 28 failing tests across various categories.

* fix(tests): align session ID tests with NULL-based initialization

Update test expectations to match implementation where memory_session_id
starts as NULL (not equal to contentSessionId) per architecture decision
that memory_session_id must NEVER equal contentSessionId.

Changes:
- session_id_refactor.test.ts: expect NULL initial state, add updateMemorySessionId() calls
- session_id_usage_validation.test.ts: update placeholder detection to check !== null
- session_store.test.ts: add updateMemorySessionId() before storeObservation/storeSummary

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(tests): update GeminiAgent tests with correct field names and mocks

- Rename deprecated fields: claudeSessionId → contentSessionId,
  sdkSessionId → memorySessionId, pendingProcessingIds → pendingMessages
- Add missing required ActiveSession fields
- Add storeObservations mock (plural) for ResponseProcessor compatibility
- Fix settings mock to use correct CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED key
- Add await to rejects.toThrow assertion

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(tests): add logger imports and fix coverage test exclusions

Phase 3 of test suite fixes:
- Add logger imports to 34 high-priority source files (SQLite, worker, context)
- Exclude CLI-facing files from console.log check (worker-service.ts,
  integrations/*Installer.ts) as they use console.log intentionally for
  interactive user output

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: update SESSION_ID_ARCHITECTURE for NULL-based initialization

Update documentation to reflect that memory_session_id starts as NULL,
not as a placeholder equal to contentSessionId. This matches the
implementation decision that memory_session_id must NEVER equal
contentSessionId to prevent injecting memory messages into user transcripts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore(deps): update esbuild and MCP SDK

- esbuild: 0.25.12 → 0.27.2 (fixes minifyIdentifiers issue)
- @modelcontextprotocol/sdk: 1.20.1 → 1.25.1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* build assets and updates

* chore: remove bun.lock and add to gitignore

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 23:58:41 -05:00

78 lines
332 KiB
JavaScript
Executable File

#!/usr/bin/env node
"use strict";var Oy=Object.create;var bs=Object.defineProperty;var jy=Object.getOwnPropertyDescriptor;var Ny=Object.getOwnPropertyNames;var Dy=Object.getPrototypeOf,Ry=Object.prototype.hasOwnProperty;var S=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),vn=(e,t)=>{for(var r in t)bs(e,r,{get:t[r],enumerable:!0})},Zy=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ny(t))!Ry.call(e,o)&&o!==r&&bs(e,o,{get:()=>t[o],enumerable:!(n=jy(t,o))||n.enumerable});return e};var ni=(e,t,r)=>(r=e!=null?Oy(Dy(e)):{},Zy(t||!e||!e.__esModule?bs(r,"default",{value:e,enumerable:!0}):r,e));var To=S(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.regexpCode=te.getEsmExportName=te.getProperty=te.safeStringify=te.stringify=te.strConcat=te.addCodeArg=te.str=te._=te.nil=te._Code=te.Name=te.IDENTIFIER=te._CodeOrName=void 0;var Io=class{};te._CodeOrName=Io;te.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var mr=class extends Io{constructor(t){if(super(),!te.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};te.Name=mr;var tt=class extends Io{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof mr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};te._Code=tt;te.nil=new tt("");function jg(e,...t){let r=[e[0]],n=0;for(;n<t.length;)vd(r,t[n]),r.push(e[++n]);return new tt(r)}te._=jg;var gd=new tt("+");function Ng(e,...t){let r=[Eo(e[0])],n=0;for(;n<t.length;)r.push(gd),vd(r,t[n]),r.push(gd,Eo(e[++n]));return TS(r),new tt(r)}te.str=Ng;function vd(e,t){t instanceof tt?e.push(...t._items):t instanceof mr?e.push(t):e.push(jS(t))}te.addCodeArg=vd;function TS(e){let t=1;for(;t<e.length-1;){if(e[t]===gd){let r=PS(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function PS(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof mr||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof mr))return`"${e}${t.slice(1)}`}function OS(e,t){return t.emptyStr()?e:e.emptyStr()?t:Ng`${e}${t}`}te.strConcat=OS;function jS(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Eo(Array.isArray(e)?e.join(","):e)}function NS(e){return new tt(Eo(e))}te.stringify=NS;function Eo(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}te.safeStringify=Eo;function DS(e){return typeof e=="string"&&te.IDENTIFIER.test(e)?new tt(`.${e}`):jg`[${e}]`}te.getProperty=DS;function RS(e){if(typeof e=="string"&&te.IDENTIFIER.test(e))return new tt(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}te.getEsmExportName=RS;function ZS(e){return new tt(e.toString())}te.regexpCode=ZS});var $d=S(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.ValueScope=Le.ValueScopeName=Le.Scope=Le.varKinds=Le.UsedValueState=void 0;var Me=To(),_d=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Ea;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Ea||(Le.UsedValueState=Ea={}));Le.varKinds={const:new Me.Name("const"),let:new Me.Name("let"),var:new Me.Name("var")};var Ta=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Me.Name?t:this.name(t)}name(t){return new Me.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Le.Scope=Ta;var Pa=class extends Me.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Me._)`.${new Me.Name(r)}[${n}]`}};Le.ValueScopeName=Pa;var AS=(0,Me._)`\n`,yd=class extends Ta{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?AS:Me.nil}}get(){return this._scope}name(t){return new Pa(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:i}=o,a=(n=r.key)!==null&&n!==void 0?n:r.ref,s=this._values[i];if(s){let l=s.get(a);if(l)return l}else s=this._values[i]=new Map;s.set(a,o);let c=this._scope[i]||(this._scope[i]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:i,itemIndex:u}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Me._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let i=Me.nil;for(let a in t){let s=t[a];if(!s)continue;let c=n[a]=n[a]||new Map;s.forEach(u=>{if(c.has(u))return;c.set(u,Ea.Started);let l=r(u);if(l){let d=this.opts.es5?Le.varKinds.var:Le.varKinds.const;i=(0,Me._)`${i}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))i=(0,Me._)`${i}${l}${this.opts._n}`;else throw new _d(u);c.set(u,Ea.Completed)})}return i}};Le.ValueScope=yd});var K=S(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.or=G.and=G.not=G.CodeGen=G.operators=G.varKinds=G.ValueScopeName=G.ValueScope=G.Scope=G.Name=G.regexpCode=G.stringify=G.getProperty=G.nil=G.strConcat=G.str=G._=void 0;var Q=To(),dt=$d(),Xt=To();Object.defineProperty(G,"_",{enumerable:!0,get:function(){return Xt._}});Object.defineProperty(G,"str",{enumerable:!0,get:function(){return Xt.str}});Object.defineProperty(G,"strConcat",{enumerable:!0,get:function(){return Xt.strConcat}});Object.defineProperty(G,"nil",{enumerable:!0,get:function(){return Xt.nil}});Object.defineProperty(G,"getProperty",{enumerable:!0,get:function(){return Xt.getProperty}});Object.defineProperty(G,"stringify",{enumerable:!0,get:function(){return Xt.stringify}});Object.defineProperty(G,"regexpCode",{enumerable:!0,get:function(){return Xt.regexpCode}});Object.defineProperty(G,"Name",{enumerable:!0,get:function(){return Xt.Name}});var Da=$d();Object.defineProperty(G,"Scope",{enumerable:!0,get:function(){return Da.Scope}});Object.defineProperty(G,"ValueScope",{enumerable:!0,get:function(){return Da.ValueScope}});Object.defineProperty(G,"ValueScopeName",{enumerable:!0,get:function(){return Da.ValueScopeName}});Object.defineProperty(G,"varKinds",{enumerable:!0,get:function(){return Da.varKinds}});G.operators={GT:new Q._Code(">"),GTE:new Q._Code(">="),LT:new Q._Code("<"),LTE:new Q._Code("<="),EQ:new Q._Code("==="),NEQ:new Q._Code("!=="),NOT:new Q._Code("!"),OR:new Q._Code("||"),AND:new Q._Code("&&"),ADD:new Q._Code("+")};var Rt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},bd=class extends Rt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?dt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=en(this.rhs,t,r)),this}get names(){return this.rhs instanceof Q._CodeOrName?this.rhs.names:{}}},Oa=class extends Rt{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof Q.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=en(this.rhs,t,r),this}get names(){let t=this.lhs instanceof Q.Name?{}:{...this.lhs.names};return Na(t,this.rhs)}},xd=class extends Oa{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},kd=class extends Rt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},Sd=class extends Rt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},wd=class extends Rt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},zd=class extends Rt{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=en(this.code,t,r),this}get names(){return this.code instanceof Q._CodeOrName?this.code.names:{}}},Po=class extends Rt{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let i=n[o];i.optimizeNames(t,r)||(US(t,i.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>vr(t,r.names),{})}},Zt=class extends Po{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},Id=class extends Po{},Qr=class extends Zt{};Qr.kind="else";var hr=class e extends Zt{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Qr(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Dg(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=en(this.condition,t,r),this}get names(){let t=super.names;return Na(t,this.condition),this.else&&vr(t,this.else.names),t}};hr.kind="if";var gr=class extends Zt{};gr.kind="for";var Ed=class extends gr{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=en(this.iteration,t,r),this}get names(){return vr(super.names,this.iteration.names)}},Td=class extends gr{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?dt.varKinds.var:this.varKind,{name:n,from:o,to:i}=this;return`for(${r} ${n}=${o}; ${n}<${i}; ${n}++)`+super.render(t)}get names(){let t=Na(super.names,this.from);return Na(t,this.to)}},ja=class extends gr{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=en(this.iterable,t,r),this}get names(){return vr(super.names,this.iterable.names)}},Oo=class extends Zt{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};Oo.kind="func";var jo=class extends Po{render(t){return"return "+super.render(t)}};jo.kind="return";var Pd=class extends Zt{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&vr(t,this.catch.names),this.finally&&vr(t,this.finally.names),t}},No=class extends Zt{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};No.kind="catch";var Do=class extends Zt{render(t){return"finally"+super.render(t)}};Do.kind="finally";var Od=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
`:""},this._extScope=t,this._scope=new dt.Scope({parent:t}),this._nodes=[new Id]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let i=this._scope.toName(r);return n!==void 0&&o&&(this._constants[i.str]=n),this._leafNode(new bd(t,i,n)),i}const(t,r,n){return this._def(dt.varKinds.const,t,r,n)}let(t,r,n){return this._def(dt.varKinds.let,t,r,n)}var(t,r,n){return this._def(dt.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Oa(t,r,n))}add(t,r){return this._leafNode(new xd(t,G.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==Q.nil&&this._leafNode(new zd(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,Q.addCodeArg)(r,o));return r.push("}"),new Q._Code(r)}if(t,r,n){if(this._blockNode(new hr(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new hr(t))}else(){return this._elseNode(new Qr)}endIf(){return this._endBlockNode(hr,Qr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Ed(t),r)}forRange(t,r,n,o,i=this.opts.es5?dt.varKinds.var:dt.varKinds.let){let a=this._scope.toName(t);return this._for(new Td(i,a,r,n),()=>o(a))}forOf(t,r,n,o=dt.varKinds.const){let i=this._scope.toName(t);if(this.opts.es5){let a=r instanceof Q.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,Q._)`${a}.length`,s=>{this.var(i,(0,Q._)`${a}[${s}]`),n(i)})}return this._for(new ja("of",o,i,r),()=>n(i))}forIn(t,r,n,o=this.opts.es5?dt.varKinds.var:dt.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,Q._)`Object.keys(${r})`,n);let i=this._scope.toName(t);return this._for(new ja("in",o,i,r),()=>n(i))}endFor(){return this._endBlockNode(gr)}label(t){return this._leafNode(new kd(t))}break(t){return this._leafNode(new Sd(t))}return(t){let r=new jo;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(jo)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Pd;if(this._blockNode(o),this.code(t),r){let i=this.name("e");this._currNode=o.catch=new No(i),r(i)}return n&&(this._currNode=o.finally=new Do,this.code(n)),this._endBlockNode(No,Do)}throw(t){return this._leafNode(new wd(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=Q.nil,n,o){return this._blockNode(new Oo(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Oo)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof hr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};G.CodeGen=Od;function vr(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Na(e,t){return t instanceof Q._CodeOrName?vr(e,t.names):e}function en(e,t,r){if(e instanceof Q.Name)return n(e);if(!o(e))return e;return new Q._Code(e._items.reduce((i,a)=>(a instanceof Q.Name&&(a=n(a)),a instanceof Q._Code?i.push(...a._items):i.push(a),i),[]));function n(i){let a=r[i.str];return a===void 0||t[i.str]!==1?i:(delete t[i.str],a)}function o(i){return i instanceof Q._Code&&i._items.some(a=>a instanceof Q.Name&&t[a.str]===1&&r[a.str]!==void 0)}}function US(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Dg(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,Q._)`!${jd(e)}`}G.not=Dg;var CS=Rg(G.operators.AND);function MS(...e){return e.reduce(CS)}G.and=MS;var LS=Rg(G.operators.OR);function qS(...e){return e.reduce(LS)}G.or=qS;function Rg(e){return(t,r)=>t===Q.nil?r:r===Q.nil?t:(0,Q._)`${jd(t)} ${e} ${jd(r)}`}function jd(e){return e instanceof Q.Name?e:(0,Q._)`(${e})`}});var re=S(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.checkStrictMode=B.getErrorPath=B.Type=B.useFunc=B.setEvaluated=B.evaluatedPropsToName=B.mergeEvaluated=B.eachItem=B.unescapeJsonPointer=B.escapeJsonPointer=B.escapeFragment=B.unescapeFragment=B.schemaRefOrVal=B.schemaHasRulesButRef=B.schemaHasRules=B.checkUnknownRules=B.alwaysValidSchema=B.toHash=void 0;var le=K(),FS=To();function VS(e){let t={};for(let r of e)t[r]=!0;return t}B.toHash=VS;function JS(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Ug(e,t),!Cg(t,e.self.RULES.all))}B.alwaysValidSchema=JS;function Ug(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let i in t)o[i]||qg(e,`unknown keyword: "${i}"`)}B.checkUnknownRules=Ug;function Cg(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}B.schemaHasRules=Cg;function KS(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}B.schemaHasRulesButRef=KS;function WS({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,le._)`${r}`}return(0,le._)`${e}${t}${(0,le.getProperty)(n)}`}B.schemaRefOrVal=WS;function GS(e){return Mg(decodeURIComponent(e))}B.unescapeFragment=GS;function HS(e){return encodeURIComponent(Dd(e))}B.escapeFragment=HS;function Dd(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}B.escapeJsonPointer=Dd;function Mg(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}B.unescapeJsonPointer=Mg;function BS(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}B.eachItem=BS;function Zg({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,i,a,s)=>{let c=a===void 0?i:a instanceof le.Name?(i instanceof le.Name?e(o,i,a):t(o,i,a),a):i instanceof le.Name?(t(o,a,i),i):r(i,a);return s===le.Name&&!(c instanceof le.Name)?n(o,c):c}}B.mergeEvaluated={props:Zg({mergeNames:(e,t,r)=>e.if((0,le._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,le._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,le._)`${r} || {}`).code((0,le._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,le._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,le._)`${r} || {}`),Rd(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Lg}),items:Zg({mergeNames:(e,t,r)=>e.if((0,le._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,le._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,le._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,le._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Lg(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,le._)`{}`);return t!==void 0&&Rd(e,r,t),r}B.evaluatedPropsToName=Lg;function Rd(e,t,r){Object.keys(r).forEach(n=>e.assign((0,le._)`${t}${(0,le.getProperty)(n)}`,!0))}B.setEvaluated=Rd;var Ag={};function XS(e,t){return e.scopeValue("func",{ref:t,code:Ag[t.code]||(Ag[t.code]=new FS._Code(t.code))})}B.useFunc=XS;var Nd;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Nd||(B.Type=Nd={}));function YS(e,t,r){if(e instanceof le.Name){let n=t===Nd.Num;return r?n?(0,le._)`"[" + ${e} + "]"`:(0,le._)`"['" + ${e} + "']"`:n?(0,le._)`"/" + ${e}`:(0,le._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,le.getProperty)(e).toString():"/"+Dd(e)}B.getErrorPath=YS;function qg(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}B.checkStrictMode=qg});var At=S(Zd=>{"use strict";Object.defineProperty(Zd,"__esModule",{value:!0});var Te=K(),QS={data:new Te.Name("data"),valCxt:new Te.Name("valCxt"),instancePath:new Te.Name("instancePath"),parentData:new Te.Name("parentData"),parentDataProperty:new Te.Name("parentDataProperty"),rootData:new Te.Name("rootData"),dynamicAnchors:new Te.Name("dynamicAnchors"),vErrors:new Te.Name("vErrors"),errors:new Te.Name("errors"),this:new Te.Name("this"),self:new Te.Name("self"),scope:new Te.Name("scope"),json:new Te.Name("json"),jsonPos:new Te.Name("jsonPos"),jsonLen:new Te.Name("jsonLen"),jsonPart:new Te.Name("jsonPart")};Zd.default=QS});var Ro=S(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.extendErrors=Pe.resetErrorsCount=Pe.reportExtraError=Pe.reportError=Pe.keyword$DataError=Pe.keywordError=void 0;var ee=K(),Ra=re(),Ae=At();Pe.keywordError={message:({keyword:e})=>(0,ee.str)`must pass "${e}" keyword validation`};Pe.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,ee.str)`"${e}" keyword must be ${t} ($data)`:(0,ee.str)`"${e}" keyword is invalid ($data)`};function ew(e,t=Pe.keywordError,r,n){let{it:o}=e,{gen:i,compositeRule:a,allErrors:s}=o,c=Jg(e,t,r);n??(a||s)?Fg(i,c):Vg(o,(0,ee._)`[${c}]`)}Pe.reportError=ew;function tw(e,t=Pe.keywordError,r){let{it:n}=e,{gen:o,compositeRule:i,allErrors:a}=n,s=Jg(e,t,r);Fg(o,s),i||a||Vg(n,Ae.default.vErrors)}Pe.reportExtraError=tw;function rw(e,t){e.assign(Ae.default.errors,t),e.if((0,ee._)`${Ae.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,ee._)`${Ae.default.vErrors}.length`,t),()=>e.assign(Ae.default.vErrors,null)))}Pe.resetErrorsCount=rw;function nw({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:i}){if(o===void 0)throw new Error("ajv implementation error");let a=e.name("err");e.forRange("i",o,Ae.default.errors,s=>{e.const(a,(0,ee._)`${Ae.default.vErrors}[${s}]`),e.if((0,ee._)`${a}.instancePath === undefined`,()=>e.assign((0,ee._)`${a}.instancePath`,(0,ee.strConcat)(Ae.default.instancePath,i.errorPath))),e.assign((0,ee._)`${a}.schemaPath`,(0,ee.str)`${i.errSchemaPath}/${t}`),i.opts.verbose&&(e.assign((0,ee._)`${a}.schema`,r),e.assign((0,ee._)`${a}.data`,n))})}Pe.extendErrors=nw;function Fg(e,t){let r=e.const("err",t);e.if((0,ee._)`${Ae.default.vErrors} === null`,()=>e.assign(Ae.default.vErrors,(0,ee._)`[${r}]`),(0,ee._)`${Ae.default.vErrors}.push(${r})`),e.code((0,ee._)`${Ae.default.errors}++`)}function Vg(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,ee._)`new ${e.ValidationError}(${t})`):(r.assign((0,ee._)`${n}.errors`,t),r.return(!1))}var _r={keyword:new ee.Name("keyword"),schemaPath:new ee.Name("schemaPath"),params:new ee.Name("params"),propertyName:new ee.Name("propertyName"),message:new ee.Name("message"),schema:new ee.Name("schema"),parentSchema:new ee.Name("parentSchema")};function Jg(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,ee._)`{}`:ow(e,t,r)}function ow(e,t,r={}){let{gen:n,it:o}=e,i=[iw(o,r),aw(e,r)];return sw(e,t,i),n.object(...i)}function iw({errorPath:e},{instancePath:t}){let r=t?(0,ee.str)`${e}${(0,Ra.getErrorPath)(t,Ra.Type.Str)}`:e;return[Ae.default.instancePath,(0,ee.strConcat)(Ae.default.instancePath,r)]}function aw({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,ee.str)`${t}/${e}`;return r&&(o=(0,ee.str)`${o}${(0,Ra.getErrorPath)(r,Ra.Type.Str)}`),[_r.schemaPath,o]}function sw(e,{params:t,message:r},n){let{keyword:o,data:i,schemaValue:a,it:s}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=s;n.push([_r.keyword,o],[_r.params,typeof t=="function"?t(e):t||(0,ee._)`{}`]),c.messages&&n.push([_r.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([_r.schema,a],[_r.parentSchema,(0,ee._)`${l}${d}`],[Ae.default.data,i]),u&&n.push([_r.propertyName,u])}});var Wg=S(tn=>{"use strict";Object.defineProperty(tn,"__esModule",{value:!0});tn.boolOrEmptySchema=tn.topBoolOrEmptySchema=void 0;var cw=Ro(),uw=K(),lw=At(),dw={message:"boolean schema is false"};function pw(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Kg(e,!1):typeof r=="object"&&r.$async===!0?t.return(lw.default.data):(t.assign((0,uw._)`${n}.errors`,null),t.return(!0))}tn.topBoolOrEmptySchema=pw;function fw(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Kg(e)):r.var(t,!0)}tn.boolOrEmptySchema=fw;function Kg(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,cw.reportError)(o,dw,void 0,t)}});var Ad=S(rn=>{"use strict";Object.defineProperty(rn,"__esModule",{value:!0});rn.getRules=rn.isJSONType=void 0;var mw=["string","number","integer","boolean","null","object","array"],hw=new Set(mw);function gw(e){return typeof e=="string"&&hw.has(e)}rn.isJSONType=gw;function vw(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}rn.getRules=vw});var Ud=S(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.shouldUseRule=Yt.shouldUseGroup=Yt.schemaHasRulesForType=void 0;function _w({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Gg(e,n)}Yt.schemaHasRulesForType=_w;function Gg(e,t){return t.rules.some(r=>Hg(e,r))}Yt.shouldUseGroup=Gg;function Hg(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Yt.shouldUseRule=Hg});var Zo=S(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Oe.reportTypeError=Oe.checkDataTypes=Oe.checkDataType=Oe.coerceAndCheckDataType=Oe.getJSONTypes=Oe.getSchemaTypes=Oe.DataType=void 0;var yw=Ad(),$w=Ud(),bw=Ro(),F=K(),Bg=re(),nn;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(nn||(Oe.DataType=nn={}));function xw(e){let t=Xg(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}Oe.getSchemaTypes=xw;function Xg(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(yw.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Oe.getJSONTypes=Xg;function kw(e,t){let{gen:r,data:n,opts:o}=e,i=Sw(t,o.coerceTypes),a=t.length>0&&!(i.length===0&&t.length===1&&(0,$w.schemaHasRulesForType)(e,t[0]));if(a){let s=Md(t,n,o.strictNumbers,nn.Wrong);r.if(s,()=>{i.length?ww(e,t,i):Ld(e)})}return a}Oe.coerceAndCheckDataType=kw;var Yg=new Set(["string","number","integer","boolean","null"]);function Sw(e,t){return t?e.filter(r=>Yg.has(r)||t==="array"&&r==="array"):[]}function ww(e,t,r){let{gen:n,data:o,opts:i}=e,a=n.let("dataType",(0,F._)`typeof ${o}`),s=n.let("coerced",(0,F._)`undefined`);i.coerceTypes==="array"&&n.if((0,F._)`${a} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,F._)`${o}[0]`).assign(a,(0,F._)`typeof ${o}`).if(Md(t,o,i.strictNumbers),()=>n.assign(s,o))),n.if((0,F._)`${s} !== undefined`);for(let u of r)(Yg.has(u)||u==="array"&&i.coerceTypes==="array")&&c(u);n.else(),Ld(e),n.endIf(),n.if((0,F._)`${s} !== undefined`,()=>{n.assign(o,s),zw(e,s)});function c(u){switch(u){case"string":n.elseIf((0,F._)`${a} == "number" || ${a} == "boolean"`).assign(s,(0,F._)`"" + ${o}`).elseIf((0,F._)`${o} === null`).assign(s,(0,F._)`""`);return;case"number":n.elseIf((0,F._)`${a} == "boolean" || ${o} === null
|| (${a} == "string" && ${o} && ${o} == +${o})`).assign(s,(0,F._)`+${o}`);return;case"integer":n.elseIf((0,F._)`${a} === "boolean" || ${o} === null
|| (${a} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(s,(0,F._)`+${o}`);return;case"boolean":n.elseIf((0,F._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(s,!1).elseIf((0,F._)`${o} === "true" || ${o} === 1`).assign(s,!0);return;case"null":n.elseIf((0,F._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(s,null);return;case"array":n.elseIf((0,F._)`${a} === "string" || ${a} === "number"
|| ${a} === "boolean" || ${o} === null`).assign(s,(0,F._)`[${o}]`)}}}function zw({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,F._)`${t} !== undefined`,()=>e.assign((0,F._)`${t}[${r}]`,n))}function Cd(e,t,r,n=nn.Correct){let o=n===nn.Correct?F.operators.EQ:F.operators.NEQ,i;switch(e){case"null":return(0,F._)`${t} ${o} null`;case"array":i=(0,F._)`Array.isArray(${t})`;break;case"object":i=(0,F._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":i=a((0,F._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":i=a();break;default:return(0,F._)`typeof ${t} ${o} ${e}`}return n===nn.Correct?i:(0,F.not)(i);function a(s=F.nil){return(0,F.and)((0,F._)`typeof ${t} == "number"`,s,r?(0,F._)`isFinite(${t})`:F.nil)}}Oe.checkDataType=Cd;function Md(e,t,r,n){if(e.length===1)return Cd(e[0],t,r,n);let o,i=(0,Bg.toHash)(e);if(i.array&&i.object){let a=(0,F._)`typeof ${t} != "object"`;o=i.null?a:(0,F._)`!${t} || ${a}`,delete i.null,delete i.array,delete i.object}else o=F.nil;i.number&&delete i.integer;for(let a in i)o=(0,F.and)(o,Cd(a,t,r,n));return o}Oe.checkDataTypes=Md;var Iw={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,F._)`{type: ${e}}`:(0,F._)`{type: ${t}}`};function Ld(e){let t=Ew(e);(0,bw.reportError)(t,Iw)}Oe.reportTypeError=Ld;function Ew(e){let{gen:t,data:r,schema:n}=e,o=(0,Bg.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var ev=S(Za=>{"use strict";Object.defineProperty(Za,"__esModule",{value:!0});Za.assignDefaults=void 0;var on=K(),Tw=re();function Pw(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)Qg(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,i)=>Qg(e,i,o.default))}Za.assignDefaults=Pw;function Qg(e,t,r){let{gen:n,compositeRule:o,data:i,opts:a}=e;if(r===void 0)return;let s=(0,on._)`${i}${(0,on.getProperty)(t)}`;if(o){(0,Tw.checkStrictMode)(e,`default is ignored for: ${s}`);return}let c=(0,on._)`${s} === undefined`;a.useDefaults==="empty"&&(c=(0,on._)`${c} || ${s} === null || ${s} === ""`),n.if(c,(0,on._)`${s} = ${(0,on.stringify)(r)}`)}});var rt=S(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});ae.validateUnion=ae.validateArray=ae.usePattern=ae.callValidateCode=ae.schemaProperties=ae.allSchemaProperties=ae.noPropertyInData=ae.propertyInData=ae.isOwnProperty=ae.hasPropFunc=ae.reportMissingProp=ae.checkMissingProp=ae.checkReportMissingProp=void 0;var me=K(),qd=re(),Qt=At(),Ow=re();function jw(e,t){let{gen:r,data:n,it:o}=e;r.if(Vd(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,me._)`${t}`},!0),e.error()})}ae.checkReportMissingProp=jw;function Nw({gen:e,data:t,it:{opts:r}},n,o){return(0,me.or)(...n.map(i=>(0,me.and)(Vd(e,t,i,r.ownProperties),(0,me._)`${o} = ${i}`)))}ae.checkMissingProp=Nw;function Dw(e,t){e.setParams({missingProperty:t},!0),e.error()}ae.reportMissingProp=Dw;function tv(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,me._)`Object.prototype.hasOwnProperty`})}ae.hasPropFunc=tv;function Fd(e,t,r){return(0,me._)`${tv(e)}.call(${t}, ${r})`}ae.isOwnProperty=Fd;function Rw(e,t,r,n){let o=(0,me._)`${t}${(0,me.getProperty)(r)} !== undefined`;return n?(0,me._)`${o} && ${Fd(e,t,r)}`:o}ae.propertyInData=Rw;function Vd(e,t,r,n){let o=(0,me._)`${t}${(0,me.getProperty)(r)} === undefined`;return n?(0,me.or)(o,(0,me.not)(Fd(e,t,r))):o}ae.noPropertyInData=Vd;function rv(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}ae.allSchemaProperties=rv;function Zw(e,t){return rv(t).filter(r=>!(0,qd.alwaysValidSchema)(e,t[r]))}ae.schemaProperties=Zw;function Aw({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:i},it:a},s,c,u){let l=u?(0,me._)`${e}, ${t}, ${n}${o}`:t,d=[[Qt.default.instancePath,(0,me.strConcat)(Qt.default.instancePath,i)],[Qt.default.parentData,a.parentData],[Qt.default.parentDataProperty,a.parentDataProperty],[Qt.default.rootData,Qt.default.rootData]];a.opts.dynamicRef&&d.push([Qt.default.dynamicAnchors,Qt.default.dynamicAnchors]);let m=(0,me._)`${l}, ${r.object(...d)}`;return c!==me.nil?(0,me._)`${s}.call(${c}, ${m})`:(0,me._)`${s}(${m})`}ae.callValidateCode=Aw;var Uw=(0,me._)`new RegExp`;function Cw({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,i=o(r,n);return e.scopeValue("pattern",{key:i.toString(),ref:i,code:(0,me._)`${o.code==="new RegExp"?Uw:(0,Ow.useFunc)(e,o)}(${r}, ${n})`})}ae.usePattern=Cw;function Mw(e){let{gen:t,data:r,keyword:n,it:o}=e,i=t.name("valid");if(o.allErrors){let s=t.let("valid",!0);return a(()=>t.assign(s,!1)),s}return t.var(i,!0),a(()=>t.break()),i;function a(s){let c=t.const("len",(0,me._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:qd.Type.Num},i),t.if((0,me.not)(i),s)})}}ae.validateArray=Mw;function Lw(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,qd.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let a=t.let("valid",!1),s=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},s);t.assign(a,(0,me._)`${a} || ${s}`),e.mergeValidEvaluated(l,s)||t.if((0,me.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}ae.validateUnion=Lw});var iv=S(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.validateKeywordUsage=yt.validSchemaType=yt.funcKeywordCode=yt.macroKeywordCode=void 0;var Ue=K(),yr=At(),qw=rt(),Fw=Ro();function Vw(e,t){let{gen:r,keyword:n,schema:o,parentSchema:i,it:a}=e,s=t.macro.call(a.self,o,i,a),c=ov(r,n,s);a.opts.validateSchema!==!1&&a.self.validateSchema(s,!0);let u=r.name("valid");e.subschema({schema:s,schemaPath:Ue.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}yt.macroKeywordCode=Vw;function Jw(e,t){var r;let{gen:n,keyword:o,schema:i,parentSchema:a,$data:s,it:c}=e;Ww(c,t);let u=!s&&t.compile?t.compile.call(c.self,i,a,c):t.validate,l=ov(n,o,u),d=n.let("valid");e.block$data(d,m),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function m(){if(t.errors===!1)v(),t.modifying&&nv(e),$(()=>e.error());else{let x=t.async?f():g();t.modifying&&nv(e),$(()=>Kw(e,x))}}function f(){let x=n.let("ruleErrs",null);return n.try(()=>v((0,Ue._)`await `),O=>n.assign(d,!1).if((0,Ue._)`${O} instanceof ${c.ValidationError}`,()=>n.assign(x,(0,Ue._)`${O}.errors`),()=>n.throw(O))),x}function g(){let x=(0,Ue._)`${l}.errors`;return n.assign(x,null),v(Ue.nil),x}function v(x=t.async?(0,Ue._)`await `:Ue.nil){let O=c.opts.passContext?yr.default.this:yr.default.self,I=!("compile"in t&&!s||t.schema===!1);n.assign(d,(0,Ue._)`${x}${(0,qw.callValidateCode)(e,l,O,I)}`,t.modifying)}function $(x){var O;n.if((0,Ue.not)((O=t.valid)!==null&&O!==void 0?O:d),x)}}yt.funcKeywordCode=Jw;function nv(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Ue._)`${n.parentData}[${n.parentDataProperty}]`))}function Kw(e,t){let{gen:r}=e;r.if((0,Ue._)`Array.isArray(${t})`,()=>{r.assign(yr.default.vErrors,(0,Ue._)`${yr.default.vErrors} === null ? ${t} : ${yr.default.vErrors}.concat(${t})`).assign(yr.default.errors,(0,Ue._)`${yr.default.vErrors}.length`),(0,Fw.extendErrors)(e)},()=>e.error())}function Ww({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function ov(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Ue.stringify)(r)})}function Gw(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}yt.validSchemaType=Gw;function Hw({schema:e,opts:t,self:r,errSchemaPath:n},o,i){if(Array.isArray(o.keyword)?!o.keyword.includes(i):o.keyword!==i)throw new Error("ajv implementation error");let a=o.dependencies;if(a?.some(s=>!Object.prototype.hasOwnProperty.call(e,s)))throw new Error(`parent schema must have dependencies of ${i}: ${a.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[i])){let c=`keyword "${i}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}yt.validateKeywordUsage=Hw});var sv=S(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});er.extendSubschemaMode=er.extendSubschemaData=er.getSubschema=void 0;var $t=K(),av=re();function Bw(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:i,topSchemaRef:a}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let s=e.schema[t];return r===void 0?{schema:s,schemaPath:(0,$t._)`${e.schemaPath}${(0,$t.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:s[r],schemaPath:(0,$t._)`${e.schemaPath}${(0,$t.getProperty)(t)}${(0,$t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,av.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||i===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:a,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')}er.getSubschema=Bw;function Xw(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:i,propertyName:a}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:s}=t;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=t,m=s.let("data",(0,$t._)`${t.data}${(0,$t.getProperty)(r)}`,!0);c(m),e.errorPath=(0,$t.str)`${u}${(0,av.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,$t._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof $t.Name?o:s.let("data",o,!0);c(u),a!==void 0&&(e.propertyName=a)}i&&(e.dataTypes=i);function c(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}}er.extendSubschemaData=Xw;function Yw(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:i}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),i!==void 0&&(e.allErrors=i),e.jtdDiscriminator=t,e.jtdMetadata=r}er.extendSubschemaMode=Yw});var Jd=S((dA,cv)=>{"use strict";cv.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,i;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(i=Object.keys(t),n=i.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,i[o]))return!1;for(o=n;o--!==0;){var a=i[o];if(!e(t[a],r[a]))return!1}return!0}return t!==t&&r!==r}});var lv=S((pA,uv)=>{"use strict";var tr=uv.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Aa(t,n,o,e,"",e)};tr.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};tr.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};tr.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};tr.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Aa(e,t,r,n,o,i,a,s,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,i,a,s,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in tr.arrayKeywords)for(var m=0;m<d.length;m++)Aa(e,t,r,d[m],o+"/"+l+"/"+m,i,o,l,n,m)}else if(l in tr.propsKeywords){if(d&&typeof d=="object")for(var f in d)Aa(e,t,r,d[f],o+"/"+l+"/"+Qw(f),i,o,l,n,f)}else(l in tr.keywords||e.allKeys&&!(l in tr.skipKeywords))&&Aa(e,t,r,d,o+"/"+l,i,o,l,n)}r(n,o,i,a,s,c,u)}}function Qw(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var Ao=S(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.getSchemaRefs=qe.resolveUrl=qe.normalizeId=qe._getFullPath=qe.getFullPath=qe.inlineRef=void 0;var e0=re(),t0=Jd(),r0=lv(),n0=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function o0(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Kd(e):t?dv(e)<=t:!1}qe.inlineRef=o0;var i0=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Kd(e){for(let t in e){if(i0.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Kd)||typeof r=="object"&&Kd(r))return!0}return!1}function dv(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!n0.has(r)&&(typeof e[r]=="object"&&(0,e0.eachItem)(e[r],n=>t+=dv(n)),t===1/0))return 1/0}return t}function pv(e,t="",r){r!==!1&&(t=an(t));let n=e.parse(t);return fv(e,n)}qe.getFullPath=pv;function fv(e,t){return e.serialize(t).split("#")[0]+"#"}qe._getFullPath=fv;var a0=/#\/?$/;function an(e){return e?e.replace(a0,""):""}qe.normalizeId=an;function s0(e,t,r){return r=an(r),e.resolve(t,r)}qe.resolveUrl=s0;var c0=/^[a-z_][-a-z0-9._]*$/i;function u0(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=an(e[r]||t),i={"":o},a=pv(n,o,!1),s={},c=new Set;return r0(e,{allKeys:!0},(d,m,f,g)=>{if(g===void 0)return;let v=a+m,$=i[g];typeof d[r]=="string"&&($=x.call(this,d[r])),O.call(this,d.$anchor),O.call(this,d.$dynamicAnchor),i[m]=$;function x(I){let U=this.opts.uriResolver.resolve;if(I=an($?U($,I):I),c.has(I))throw l(I);c.add(I);let j=this.refs[I];return typeof j=="string"&&(j=this.refs[j]),typeof j=="object"?u(d,j.schema,I):I!==an(v)&&(I[0]==="#"?(u(d,s[I],I),s[I]=d):this.refs[I]=v),I}function O(I){if(typeof I=="string"){if(!c0.test(I))throw new Error(`invalid anchor "${I}"`);x.call(this,`#${I}`)}}}),s;function u(d,m,f){if(m!==void 0&&!t0(d,m))throw l(f)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}qe.getSchemaRefs=u0});var Mo=S(rr=>{"use strict";Object.defineProperty(rr,"__esModule",{value:!0});rr.getData=rr.KeywordCxt=rr.validateFunctionCode=void 0;var _v=Wg(),mv=Zo(),Gd=Ud(),Ua=Zo(),l0=ev(),Co=iv(),Wd=sv(),P=K(),C=At(),d0=Ao(),Ut=re(),Uo=Ro();function p0(e){if(bv(e)&&(xv(e),$v(e))){h0(e);return}yv(e,()=>(0,_v.topBoolOrEmptySchema)(e))}rr.validateFunctionCode=p0;function yv({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},i){o.code.es5?e.func(t,(0,P._)`${C.default.data}, ${C.default.valCxt}`,n.$async,()=>{e.code((0,P._)`"use strict"; ${hv(r,o)}`),m0(e,o),e.code(i)}):e.func(t,(0,P._)`${C.default.data}, ${f0(o)}`,n.$async,()=>e.code(hv(r,o)).code(i))}function f0(e){return(0,P._)`{${C.default.instancePath}="", ${C.default.parentData}, ${C.default.parentDataProperty}, ${C.default.rootData}=${C.default.data}${e.dynamicRef?(0,P._)`, ${C.default.dynamicAnchors}={}`:P.nil}}={}`}function m0(e,t){e.if(C.default.valCxt,()=>{e.var(C.default.instancePath,(0,P._)`${C.default.valCxt}.${C.default.instancePath}`),e.var(C.default.parentData,(0,P._)`${C.default.valCxt}.${C.default.parentData}`),e.var(C.default.parentDataProperty,(0,P._)`${C.default.valCxt}.${C.default.parentDataProperty}`),e.var(C.default.rootData,(0,P._)`${C.default.valCxt}.${C.default.rootData}`),t.dynamicRef&&e.var(C.default.dynamicAnchors,(0,P._)`${C.default.valCxt}.${C.default.dynamicAnchors}`)},()=>{e.var(C.default.instancePath,(0,P._)`""`),e.var(C.default.parentData,(0,P._)`undefined`),e.var(C.default.parentDataProperty,(0,P._)`undefined`),e.var(C.default.rootData,C.default.data),t.dynamicRef&&e.var(C.default.dynamicAnchors,(0,P._)`{}`)})}function h0(e){let{schema:t,opts:r,gen:n}=e;yv(e,()=>{r.$comment&&t.$comment&&Sv(e),$0(e),n.let(C.default.vErrors,null),n.let(C.default.errors,0),r.unevaluated&&g0(e),kv(e),k0(e)})}function g0(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,P._)`${r}.evaluated`),t.if((0,P._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,P._)`${e.evaluated}.props`,(0,P._)`undefined`)),t.if((0,P._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,P._)`${e.evaluated}.items`,(0,P._)`undefined`))}function hv(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,P._)`/*# sourceURL=${r} */`:P.nil}function v0(e,t){if(bv(e)&&(xv(e),$v(e))){_0(e,t);return}(0,_v.boolOrEmptySchema)(e,t)}function $v({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function bv(e){return typeof e.schema!="boolean"}function _0(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&Sv(e),b0(e),x0(e);let i=n.const("_errs",C.default.errors);kv(e,i),n.var(t,(0,P._)`${i} === ${C.default.errors}`)}function xv(e){(0,Ut.checkUnknownRules)(e),y0(e)}function kv(e,t){if(e.opts.jtd)return gv(e,[],!1,t);let r=(0,mv.getSchemaTypes)(e.schema),n=(0,mv.coerceAndCheckDataType)(e,r);gv(e,r,!n,t)}function y0(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Ut.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function $0(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Ut.checkStrictMode)(e,"default is ignored in the schema root")}function b0(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,d0.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function x0(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Sv({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let i=r.$comment;if(o.$comment===!0)e.code((0,P._)`${C.default.self}.logger.log(${i})`);else if(typeof o.$comment=="function"){let a=(0,P.str)`${n}/$comment`,s=e.scopeValue("root",{ref:t.root});e.code((0,P._)`${C.default.self}.opts.$comment(${i}, ${a}, ${s}.schema)`)}}function k0(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:i}=e;r.$async?t.if((0,P._)`${C.default.errors} === 0`,()=>t.return(C.default.data),()=>t.throw((0,P._)`new ${o}(${C.default.vErrors})`)):(t.assign((0,P._)`${n}.errors`,C.default.vErrors),i.unevaluated&&S0(e),t.return((0,P._)`${C.default.errors} === 0`))}function S0({gen:e,evaluated:t,props:r,items:n}){r instanceof P.Name&&e.assign((0,P._)`${t}.props`,r),n instanceof P.Name&&e.assign((0,P._)`${t}.items`,n)}function gv(e,t,r,n){let{gen:o,schema:i,data:a,allErrors:s,opts:c,self:u}=e,{RULES:l}=u;if(i.$ref&&(c.ignoreKeywordsWithRef||!(0,Ut.schemaHasRulesButRef)(i,l))){o.block(()=>zv(e,"$ref",l.all.$ref.definition));return}c.jtd||w0(e,t),o.block(()=>{for(let m of l.rules)d(m);d(l.post)});function d(m){(0,Gd.shouldUseGroup)(i,m)&&(m.type?(o.if((0,Ua.checkDataType)(m.type,a,c.strictNumbers)),vv(e,m),t.length===1&&t[0]===m.type&&r&&(o.else(),(0,Ua.reportTypeError)(e)),o.endIf()):vv(e,m),s||o.if((0,P._)`${C.default.errors} === ${n||0}`))}}function vv(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,l0.assignDefaults)(e,t.type),r.block(()=>{for(let i of t.rules)(0,Gd.shouldUseRule)(n,i)&&zv(e,i.keyword,i.definition,t.type)})}function w0(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(z0(e,t),e.opts.allowUnionTypes||I0(e,t),E0(e,e.dataTypes))}function z0(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{wv(e.dataTypes,r)||Hd(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),P0(e,t)}}function I0(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Hd(e,"use allowUnionTypes to allow union type keyword")}function E0(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Gd.shouldUseRule)(e.schema,o)){let{type:i}=o.definition;i.length&&!i.some(a=>T0(t,a))&&Hd(e,`missing type "${i.join(",")}" for keyword "${n}"`)}}}function T0(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function wv(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function P0(e,t){let r=[];for(let n of e.dataTypes)wv(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Hd(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Ut.checkStrictMode)(e,t,e.opts.strictTypes)}var Ca=class{constructor(t,r,n){if((0,Co.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Ut.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",Iv(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Co.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",C.default.errors))}result(t,r,n){this.failResult((0,P.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,P.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,P._)`${r} !== undefined && (${(0,P.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?Uo.reportExtraError:Uo.reportError)(this,this.def.error,r)}$dataError(){(0,Uo.reportError)(this,this.def.$dataError||Uo.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Uo.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=P.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=P.nil,r=P.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:i,def:a}=this;n.if((0,P.or)((0,P._)`${o} === undefined`,r)),t!==P.nil&&n.assign(t,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==P.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:i}=this;return(0,P.or)(a(),s());function a(){if(n.length){if(!(r instanceof P.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,P._)`${(0,Ua.checkDataTypes)(c,r,i.opts.strictNumbers,Ua.DataType.Wrong)}`}return P.nil}function s(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,P._)`!${c}(${r})`}return P.nil}}subschema(t,r){let n=(0,Wd.getSubschema)(this.it,t);(0,Wd.extendSubschemaData)(n,this.it,t),(0,Wd.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return v0(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Ut.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Ut.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,P.Name)),!0}};rr.KeywordCxt=Ca;function zv(e,t,r,n){let o=new Ca(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Co.funcKeywordCode)(o,r):"macro"in r?(0,Co.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Co.funcKeywordCode)(o,r)}var O0=/^\/(?:[^~]|~0|~1)*$/,j0=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Iv(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,i;if(e==="")return C.default.rootData;if(e[0]==="/"){if(!O0.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,i=C.default.rootData}else{let u=j0.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=t)throw new Error(c("property/index",l));return n[t-l]}if(l>t)throw new Error(c("data",l));if(i=r[t-l],!o)return i}let a=i,s=o.split("/");for(let u of s)u&&(i=(0,P._)`${i}${(0,P.getProperty)((0,Ut.unescapeJsonPointer)(u))}`,a=(0,P._)`${a} && ${i}`);return a;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}rr.getData=Iv});var Ma=S(Xd=>{"use strict";Object.defineProperty(Xd,"__esModule",{value:!0});var Bd=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};Xd.default=Bd});var Lo=S(ep=>{"use strict";Object.defineProperty(ep,"__esModule",{value:!0});var Yd=Ao(),Qd=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Yd.resolveUrl)(t,r,n),this.missingSchema=(0,Yd.normalizeId)((0,Yd.getFullPath)(t,this.missingRef))}};ep.default=Qd});var qa=S(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.resolveSchema=nt.getCompilingSchema=nt.resolveRef=nt.compileSchema=nt.SchemaEnv=void 0;var pt=K(),N0=Ma(),$r=At(),ft=Ao(),Ev=re(),D0=Mo(),sn=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,ft.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};nt.SchemaEnv=sn;function rp(e){let t=Tv.call(this,e);if(t)return t;let r=(0,ft.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:i}=this.opts,a=new pt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:i}),s;e.$async&&(s=a.scopeValue("Error",{ref:N0.default,code:(0,pt._)`require("ajv/dist/runtime/validation_error").default`}));let c=a.scopeName("validate");e.validateName=c;let u={gen:a,allErrors:this.opts.allErrors,data:$r.default.data,parentData:$r.default.parentData,parentDataProperty:$r.default.parentDataProperty,dataNames:[$r.default.data],dataPathArr:[pt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,pt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:s,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:pt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,pt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,D0.validateFunctionCode)(u),a.optimize(this.opts.code.optimize);let d=a.toString();l=`${a.scopeRefs($r.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let f=new Function(`${$r.default.self}`,`${$r.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:f}),f.errors=null,f.schema=e.schema,f.schemaEnv=e,e.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:c,validateCode:d,scopeValues:a._values}),this.opts.unevaluated){let{props:g,items:v}=u;f.evaluated={props:g instanceof pt.Name?void 0:g,items:v instanceof pt.Name?void 0:v,dynamicProps:g instanceof pt.Name,dynamicItems:v instanceof pt.Name},f.source&&(f.source.evaluated=(0,pt.stringify)(f.evaluated))}return e.validate=f,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}nt.compileSchema=rp;function R0(e,t,r){var n;r=(0,ft.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let i=U0.call(this,e,r);if(i===void 0){let a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:s}=this.opts;a&&(i=new sn({schema:a,schemaId:s,root:e,baseId:t}))}if(i!==void 0)return e.refs[r]=Z0.call(this,i)}nt.resolveRef=R0;function Z0(e){return(0,ft.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:rp.call(this,e)}function Tv(e){for(let t of this._compilations)if(A0(t,e))return t}nt.getCompilingSchema=Tv;function A0(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function U0(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||La.call(this,e,t)}function La(e,t){let r=this.opts.uriResolver.parse(t),n=(0,ft._getFullPath)(this.opts.uriResolver,r),o=(0,ft.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return tp.call(this,r,e);let i=(0,ft.normalizeId)(n),a=this.refs[i]||this.schemas[i];if(typeof a=="string"){let s=La.call(this,e,a);return typeof s?.schema!="object"?void 0:tp.call(this,r,s)}if(typeof a?.schema=="object"){if(a.validate||rp.call(this,a),i===(0,ft.normalizeId)(t)){let{schema:s}=a,{schemaId:c}=this.opts,u=s[c];return u&&(o=(0,ft.resolveUrl)(this.opts.uriResolver,o,u)),new sn({schema:s,schemaId:c,root:e,baseId:o})}return tp.call(this,r,a)}}nt.resolveSchema=La;var C0=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function tp(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let s of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,Ev.unescapeFragment)(s)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!C0.has(s)&&u&&(t=(0,ft.resolveUrl)(this.opts.uriResolver,t,u))}let i;if(typeof r!="boolean"&&r.$ref&&!(0,Ev.schemaHasRulesButRef)(r,this.RULES)){let s=(0,ft.resolveUrl)(this.opts.uriResolver,t,r.$ref);i=La.call(this,n,s)}let{schemaId:a}=this.opts;if(i=i||new sn({schema:r,schemaId:a,root:n,baseId:t}),i.schema!==i.root.schema)return i}});var Pv=S((_A,M0)=>{M0.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var op=S((yA,Dv)=>{"use strict";var L0=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),jv=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function np(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var q0=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Ov(e){return e.length=0,!0}function F0(e,t,r){if(e.length){let n=np(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function V0(e){let t=0,r={error:!1,address:"",zone:""},n=[],o=[],i=!1,a=!1,s=F0;for(let c=0;c<e.length;c++){let u=e[c];if(!(u==="["||u==="]"))if(u===":"){if(i===!0&&(a=!0),!s(o,n,r))break;if(++t>7){r.error=!0;break}c>0&&e[c-1]===":"&&(i=!0),n.push(":");continue}else if(u==="%"){if(!s(o,n,r))break;s=Ov}else{o.push(u);continue}}return o.length&&(s===Ov?r.zone=o.join(""):a?n.push(o.join("")):n.push(np(o))),r.address=n.join(""),r}function Nv(e){if(J0(e,":")<2)return{host:e,isIPV6:!1};let t=V0(e);if(t.error)return{host:e,isIPV6:!1};{let r=t.address,n=t.address;return t.zone&&(r+="%"+t.zone,n+="%25"+t.zone),{host:r,isIPV6:!0,escapedHost:n}}}function J0(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function K0(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(o===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}function W0(e,t){let r=t!==!0?escape:unescape;return e.scheme!==void 0&&(e.scheme=r(e.scheme)),e.userinfo!==void 0&&(e.userinfo=r(e.userinfo)),e.host!==void 0&&(e.host=r(e.host)),e.path!==void 0&&(e.path=r(e.path)),e.query!==void 0&&(e.query=r(e.query)),e.fragment!==void 0&&(e.fragment=r(e.fragment)),e}function G0(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!jv(r)){let n=Nv(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=e.host}t.push(r)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}Dv.exports={nonSimpleDomain:q0,recomposeAuthority:G0,normalizeComponentEncoding:W0,removeDotSegments:K0,isIPv4:jv,isUUID:L0,normalizeIPv6:Nv,stringArrayToHexStripped:np}});var Cv=S(($A,Uv)=>{"use strict";var{isUUID:H0}=op(),B0=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,X0=["http","https","ws","wss","urn","urn:uuid"];function Y0(e){return X0.indexOf(e)!==-1}function ip(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function Rv(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Zv(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function Q0(e){return e.secure=ip(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function ez(e){if((e.port===(ip(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let[t,r]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=r,e.resourceName=void 0}return e.fragment=void 0,e}function tz(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(B0);if(r){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,i=ap(o);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function rz(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,i=ap(o);i&&(e=i.serialize(e,t));let a=e,s=e.nss;return a.path=`${n||t.nid}:${s}`,t.skipEscape=!0,a}function nz(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!H0(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function oz(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Av={scheme:"http",domainHost:!0,parse:Rv,serialize:Zv},iz={scheme:"https",domainHost:Av.domainHost,parse:Rv,serialize:Zv},Fa={scheme:"ws",domainHost:!0,parse:Q0,serialize:ez},az={scheme:"wss",domainHost:Fa.domainHost,parse:Fa.parse,serialize:Fa.serialize},sz={scheme:"urn",parse:tz,serialize:rz,skipNormalize:!0},cz={scheme:"urn:uuid",parse:nz,serialize:oz,skipNormalize:!0},Va={http:Av,https:iz,ws:Fa,wss:az,urn:sz,"urn:uuid":cz};Object.setPrototypeOf(Va,null);function ap(e){return e&&(Va[e]||Va[e.toLowerCase()])||void 0}Uv.exports={wsIsSecure:ip,SCHEMES:Va,isValidSchemeName:Y0,getSchemeHandler:ap}});var qv=S((bA,Ka)=>{"use strict";var{normalizeIPv6:uz,removeDotSegments:qo,recomposeAuthority:lz,normalizeComponentEncoding:Ja,isIPv4:dz,nonSimpleDomain:pz}=op(),{SCHEMES:fz,getSchemeHandler:Mv}=Cv();function mz(e,t){return typeof e=="string"?e=bt(Ct(e,t),t):typeof e=="object"&&(e=Ct(bt(e,t),t)),e}function hz(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=Lv(Ct(e,n),Ct(t,n),n,!0);return n.skipEscape=!0,bt(o,n)}function Lv(e,t,r,n){let o={};return n||(e=Ct(bt(e,r),r),t=Ct(bt(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=qo(t.path||""),o.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=qo(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=qo(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=qo(o.path)),o.query=t.query):(o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function gz(e,t,r){return typeof e=="string"?(e=unescape(e),e=bt(Ja(Ct(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=bt(Ja(e,!0),{...r,skipEscape:!0})),typeof t=="string"?(t=unescape(t),t=bt(Ja(Ct(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=bt(Ja(t,!0),{...r,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()}function bt(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[],i=Mv(n.scheme||r.scheme);i&&i.serialize&&i.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let a=lz(r);if(a!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(a),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let s=r.path;!n.absolutePath&&(!i||!i.absolutePath)&&(s=qo(s)),a===void 0&&s[0]==="/"&&s[1]==="/"&&(s="/%2F"+s.slice(2)),o.push(s)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var vz=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Ct(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let i=e.match(vz);if(i){if(n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5]),n.host)if(dz(n.host)===!1){let c=uz(n.host);n.host=c.host.toLowerCase(),o=c.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let a=Mv(r.scheme||n.scheme);if(!r.unicodeSupport&&(!a||!a.unicodeSupport)&&n.host&&(r.domainHost||a&&a.domainHost)&&o===!1&&pz(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(s){n.error=n.error||"Host's domain name can not be converted to ASCII: "+s}(!a||a&&!a.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),a&&a.parse&&a.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var sp={SCHEMES:fz,normalize:mz,resolve:hz,resolveComponent:Lv,equal:gz,serialize:bt,parse:Ct};Ka.exports=sp;Ka.exports.default=sp;Ka.exports.fastUri=sp});var Vv=S(cp=>{"use strict";Object.defineProperty(cp,"__esModule",{value:!0});var Fv=qv();Fv.code='require("ajv/dist/runtime/uri").default';cp.default=Fv});var Yv=S(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.CodeGen=Se.Name=Se.nil=Se.stringify=Se.str=Se._=Se.KeywordCxt=void 0;var _z=Mo();Object.defineProperty(Se,"KeywordCxt",{enumerable:!0,get:function(){return _z.KeywordCxt}});var cn=K();Object.defineProperty(Se,"_",{enumerable:!0,get:function(){return cn._}});Object.defineProperty(Se,"str",{enumerable:!0,get:function(){return cn.str}});Object.defineProperty(Se,"stringify",{enumerable:!0,get:function(){return cn.stringify}});Object.defineProperty(Se,"nil",{enumerable:!0,get:function(){return cn.nil}});Object.defineProperty(Se,"Name",{enumerable:!0,get:function(){return cn.Name}});Object.defineProperty(Se,"CodeGen",{enumerable:!0,get:function(){return cn.CodeGen}});var yz=Ma(),Hv=Lo(),$z=Ad(),Fo=qa(),bz=K(),Vo=Ao(),Wa=Zo(),lp=re(),Jv=Pv(),xz=Vv(),Bv=(e,t)=>new RegExp(e,t);Bv.code="new RegExp";var kz=["removeAdditional","useDefaults","coerceTypes"],Sz=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),wz={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},zz={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Kv=200;function Iz(e){var t,r,n,o,i,a,s,c,u,l,d,m,f,g,v,$,x,O,I,U,j,it,at,_s,ys;let gn=e.strict,$s=(t=e.code)===null||t===void 0?void 0:t.optimize,pf=$s===!0||$s===void 0?1:$s||0,ff=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Bv,Py=(o=e.uriResolver)!==null&&o!==void 0?o:xz.default;return{strictSchema:(a=(i=e.strictSchema)!==null&&i!==void 0?i:gn)!==null&&a!==void 0?a:!0,strictNumbers:(c=(s=e.strictNumbers)!==null&&s!==void 0?s:gn)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:gn)!==null&&l!==void 0?l:"log",strictTuples:(m=(d=e.strictTuples)!==null&&d!==void 0?d:gn)!==null&&m!==void 0?m:"log",strictRequired:(g=(f=e.strictRequired)!==null&&f!==void 0?f:gn)!==null&&g!==void 0?g:!1,code:e.code?{...e.code,optimize:pf,regExp:ff}:{optimize:pf,regExp:ff},loopRequired:(v=e.loopRequired)!==null&&v!==void 0?v:Kv,loopEnum:($=e.loopEnum)!==null&&$!==void 0?$:Kv,meta:(x=e.meta)!==null&&x!==void 0?x:!0,messages:(O=e.messages)!==null&&O!==void 0?O:!0,inlineRefs:(I=e.inlineRefs)!==null&&I!==void 0?I:!0,schemaId:(U=e.schemaId)!==null&&U!==void 0?U:"$id",addUsedSchema:(j=e.addUsedSchema)!==null&&j!==void 0?j:!0,validateSchema:(it=e.validateSchema)!==null&&it!==void 0?it:!0,validateFormats:(at=e.validateFormats)!==null&&at!==void 0?at:!0,unicodeRegExp:(_s=e.unicodeRegExp)!==null&&_s!==void 0?_s:!0,int32range:(ys=e.int32range)!==null&&ys!==void 0?ys:!0,uriResolver:Py}}var Jo=class{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...Iz(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new bz.ValueScope({scope:{},prefixes:Sz,es5:r,lines:n}),this.logger=Nz(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,$z.getRules)(),Wv.call(this,wz,t,"NOT SUPPORTED"),Wv.call(this,zz,t,"DEPRECATED","warn"),this._metaOpts=Oz.call(this),t.formats&&Tz.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&Pz.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),Ez.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=Jv;n==="id"&&(o={...Jv},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,t,r);async function o(l,d){await i.call(this,l.$schema);let m=this._addSchema(l,d);return m.validate||a.call(this,m)}async function i(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function a(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof Hv.default))throw d;return s.call(this,d),await c.call(this,d.missingSchema),a.call(this,l)}}function s({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await i.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let a of t)this.addSchema(a,void 0,n,o);return this}let i;if(typeof t=="object"){let{schemaId:a}=this.opts;if(i=t[a],i!==void 0&&typeof i!="string")throw new Error(`schema ${a} must be string`)}return r=(0,Vo.normalizeId)(r||i),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,t);if(!o&&r){let i="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(i);else throw new Error(i)}return o}getSchema(t){let r;for(;typeof(r=Gv.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new Fo.SchemaEnv({schema:{},schemaId:n});if(r=Fo.resolveSchema.call(this,o,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=Gv.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,Vo.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(Rz.call(this,n,r),!r)return(0,lp.eachItem)(n,i=>up.call(this,i)),this;Az.call(this,r);let o={...r,type:(0,Wa.getJSONTypes)(r.type),schemaType:(0,Wa.getJSONTypes)(r.schemaType)};return(0,lp.eachItem)(n,o.type.length===0?i=>up.call(this,i,o):i=>o.type.forEach(a=>up.call(this,i,o,a))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let o=n.rules.findIndex(i=>i.keyword===t);o>=0&&n.rules.splice(o,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,i)=>o+r+i)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let i=o.split("/").slice(1),a=t;for(let s of i)a=a[s];for(let s in n){let c=n[s];if(typeof c!="object")continue;let{$data:u}=c.definition,l=a[s];u&&l&&(a[s]=Xv(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof t=="object")a=t[s];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(t);if(c!==void 0)return c;n=(0,Vo.normalizeId)(a||n);let u=Vo.getSchemaRefs.call(this,t,n);return c=new Fo.SchemaEnv({schema:t,schemaId:s,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),i&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(t,!0),c}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):Fo.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{Fo.compileSchema.call(this,t)}finally{this.opts=r}}};Jo.ValidationError=yz.default;Jo.MissingRefError=Hv.default;Se.default=Jo;function Wv(e,t,r,n="error"){for(let o in e){let i=o;i in t&&this.logger[n](`${r}: option ${o}. ${e[i]}`)}}function Gv(e){return e=(0,Vo.normalizeId)(e),this.schemas[e]||this.refs[e]}function Ez(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function Tz(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function Pz(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function Oz(){let e={...this.opts};for(let t of kz)delete e[t];return e}var jz={log(){},warn(){},error(){}};function Nz(e){if(e===!1)return jz;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var Dz=/^[a-z_$][a-z0-9_$:-]*$/i;function Rz(e,t){let{RULES:r}=this;if((0,lp.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Dz.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function up(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:i}=this,a=o?i.post:i.rules.find(({type:c})=>c===r);if(a||(a={type:r,rules:[]},i.rules.push(a)),i.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,Wa.getJSONTypes)(t.type),schemaType:(0,Wa.getJSONTypes)(t.schemaType)}};t.before?Zz.call(this,a,s,t.before):a.rules.push(s),i.all[e]=s,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function Zz(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function Az(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=Xv(t)),e.validateSchema=this.compile(t,!0))}var Uz={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Xv(e){return{anyOf:[e,Uz]}}});var Qv=S(dp=>{"use strict";Object.defineProperty(dp,"__esModule",{value:!0});var Cz={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};dp.default=Cz});var n_=S(br=>{"use strict";Object.defineProperty(br,"__esModule",{value:!0});br.callRef=br.getValidate=void 0;var Mz=Lo(),e_=rt(),Fe=K(),un=At(),t_=qa(),Ga=re(),Lz={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:i,validateName:a,opts:s,self:c}=n,{root:u}=i;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=t_.resolveRef.call(c,u,o,r);if(l===void 0)throw new Mz.default(n.opts.uriResolver,o,r);if(l instanceof t_.SchemaEnv)return m(l);return f(l);function d(){if(i===u)return Ha(e,a,i,i.$async);let g=t.scopeValue("root",{ref:u});return Ha(e,(0,Fe._)`${g}.validate`,u,u.$async)}function m(g){let v=r_(e,g);Ha(e,v,g,g.$async)}function f(g){let v=t.scopeValue("schema",s.code.source===!0?{ref:g,code:(0,Fe.stringify)(g)}:{ref:g}),$=t.name("valid"),x=e.subschema({schema:g,dataTypes:[],schemaPath:Fe.nil,topSchemaRef:v,errSchemaPath:r},$);e.mergeEvaluated(x),e.ok($)}}};function r_(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Fe._)`${r.scopeValue("wrapper",{ref:t})}.validate`}br.getValidate=r_;function Ha(e,t,r,n){let{gen:o,it:i}=e,{allErrors:a,schemaEnv:s,opts:c}=i,u=c.passContext?un.default.this:Fe.nil;n?l():d();function l(){if(!s.$async)throw new Error("async schema referenced by sync schema");let g=o.let("valid");o.try(()=>{o.code((0,Fe._)`await ${(0,e_.callValidateCode)(e,t,u)}`),f(t),a||o.assign(g,!0)},v=>{o.if((0,Fe._)`!(${v} instanceof ${i.ValidationError})`,()=>o.throw(v)),m(v),a||o.assign(g,!1)}),e.ok(g)}function d(){e.result((0,e_.callValidateCode)(e,t,u),()=>f(t),()=>m(t))}function m(g){let v=(0,Fe._)`${g}.errors`;o.assign(un.default.vErrors,(0,Fe._)`${un.default.vErrors} === null ? ${v} : ${un.default.vErrors}.concat(${v})`),o.assign(un.default.errors,(0,Fe._)`${un.default.vErrors}.length`)}function f(g){var v;if(!i.opts.unevaluated)return;let $=(v=r?.validate)===null||v===void 0?void 0:v.evaluated;if(i.props!==!0)if($&&!$.dynamicProps)$.props!==void 0&&(i.props=Ga.mergeEvaluated.props(o,$.props,i.props));else{let x=o.var("props",(0,Fe._)`${g}.evaluated.props`);i.props=Ga.mergeEvaluated.props(o,x,i.props,Fe.Name)}if(i.items!==!0)if($&&!$.dynamicItems)$.items!==void 0&&(i.items=Ga.mergeEvaluated.items(o,$.items,i.items));else{let x=o.var("items",(0,Fe._)`${g}.evaluated.items`);i.items=Ga.mergeEvaluated.items(o,x,i.items,Fe.Name)}}}br.callRef=Ha;br.default=Lz});var o_=S(pp=>{"use strict";Object.defineProperty(pp,"__esModule",{value:!0});var qz=Qv(),Fz=n_(),Vz=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",qz.default,Fz.default];pp.default=Vz});var i_=S(fp=>{"use strict";Object.defineProperty(fp,"__esModule",{value:!0});var Ba=K(),nr=Ba.operators,Xa={maximum:{okStr:"<=",ok:nr.LTE,fail:nr.GT},minimum:{okStr:">=",ok:nr.GTE,fail:nr.LT},exclusiveMaximum:{okStr:"<",ok:nr.LT,fail:nr.GTE},exclusiveMinimum:{okStr:">",ok:nr.GT,fail:nr.LTE}},Jz={message:({keyword:e,schemaCode:t})=>(0,Ba.str)`must be ${Xa[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Ba._)`{comparison: ${Xa[e].okStr}, limit: ${t}}`},Kz={keyword:Object.keys(Xa),type:"number",schemaType:"number",$data:!0,error:Jz,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,Ba._)`${r} ${Xa[t].fail} ${n} || isNaN(${r})`)}};fp.default=Kz});var a_=S(mp=>{"use strict";Object.defineProperty(mp,"__esModule",{value:!0});var Ko=K(),Wz={message:({schemaCode:e})=>(0,Ko.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,Ko._)`{multipleOf: ${e}}`},Gz={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Wz,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,i=o.opts.multipleOfPrecision,a=t.let("res"),s=i?(0,Ko._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${i}`:(0,Ko._)`${a} !== parseInt(${a})`;e.fail$data((0,Ko._)`(${n} === 0 || (${a} = ${r}/${n}, ${s}))`)}};mp.default=Gz});var c_=S(hp=>{"use strict";Object.defineProperty(hp,"__esModule",{value:!0});function s_(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}hp.default=s_;s_.code='require("ajv/dist/runtime/ucs2length").default'});var u_=S(gp=>{"use strict";Object.defineProperty(gp,"__esModule",{value:!0});var xr=K(),Hz=re(),Bz=c_(),Xz={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,xr.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,xr._)`{limit: ${e}}`},Yz={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Xz,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,i=t==="maxLength"?xr.operators.GT:xr.operators.LT,a=o.opts.unicode===!1?(0,xr._)`${r}.length`:(0,xr._)`${(0,Hz.useFunc)(e.gen,Bz.default)}(${r})`;e.fail$data((0,xr._)`${a} ${i} ${n}`)}};gp.default=Yz});var l_=S(vp=>{"use strict";Object.defineProperty(vp,"__esModule",{value:!0});var Qz=rt(),Ya=K(),eI={message:({schemaCode:e})=>(0,Ya.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Ya._)`{pattern: ${e}}`},tI={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:eI,code(e){let{data:t,$data:r,schema:n,schemaCode:o,it:i}=e,a=i.opts.unicodeRegExp?"u":"",s=r?(0,Ya._)`(new RegExp(${o}, ${a}))`:(0,Qz.usePattern)(e,n);e.fail$data((0,Ya._)`!${s}.test(${t})`)}};vp.default=tI});var d_=S(_p=>{"use strict";Object.defineProperty(_p,"__esModule",{value:!0});var Wo=K(),rI={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,Wo.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,Wo._)`{limit: ${e}}`},nI={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:rI,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?Wo.operators.GT:Wo.operators.LT;e.fail$data((0,Wo._)`Object.keys(${r}).length ${o} ${n}`)}};_p.default=nI});var p_=S(yp=>{"use strict";Object.defineProperty(yp,"__esModule",{value:!0});var Go=rt(),Ho=K(),oI=re(),iI={message:({params:{missingProperty:e}})=>(0,Ho.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Ho._)`{missingProperty: ${e}}`},aI={keyword:"required",type:"object",schemaType:"array",$data:!0,error:iI,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:i,it:a}=e,{opts:s}=a;if(!i&&r.length===0)return;let c=r.length>=s.loopRequired;if(a.allErrors?u():l(),s.strictRequired){let f=e.parentSchema.properties,{definedProperties:g}=e.it;for(let v of r)if(f?.[v]===void 0&&!g.has(v)){let $=a.schemaEnv.baseId+a.errSchemaPath,x=`required property "${v}" is not defined at "${$}" (strictRequired)`;(0,oI.checkStrictMode)(a,x,a.opts.strictRequired)}}function u(){if(c||i)e.block$data(Ho.nil,d);else for(let f of r)(0,Go.checkReportMissingProp)(e,f)}function l(){let f=t.let("missing");if(c||i){let g=t.let("valid",!0);e.block$data(g,()=>m(f,g)),e.ok(g)}else t.if((0,Go.checkMissingProp)(e,r,f)),(0,Go.reportMissingProp)(e,f),t.else()}function d(){t.forOf("prop",n,f=>{e.setParams({missingProperty:f}),t.if((0,Go.noPropertyInData)(t,o,f,s.ownProperties),()=>e.error())})}function m(f,g){e.setParams({missingProperty:f}),t.forOf(f,n,()=>{t.assign(g,(0,Go.propertyInData)(t,o,f,s.ownProperties)),t.if((0,Ho.not)(g),()=>{e.error(),t.break()})},Ho.nil)}}};yp.default=aI});var f_=S($p=>{"use strict";Object.defineProperty($p,"__esModule",{value:!0});var Bo=K(),sI={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,Bo.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,Bo._)`{limit: ${e}}`},cI={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:sI,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?Bo.operators.GT:Bo.operators.LT;e.fail$data((0,Bo._)`${r}.length ${o} ${n}`)}};$p.default=cI});var Qa=S(bp=>{"use strict";Object.defineProperty(bp,"__esModule",{value:!0});var m_=Jd();m_.code='require("ajv/dist/runtime/equal").default';bp.default=m_});var h_=S(kp=>{"use strict";Object.defineProperty(kp,"__esModule",{value:!0});var xp=Zo(),we=K(),uI=re(),lI=Qa(),dI={message:({params:{i:e,j:t}})=>(0,we.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,we._)`{i: ${e}, j: ${t}}`},pI={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:dI,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:i,schemaCode:a,it:s}=e;if(!n&&!o)return;let c=t.let("valid"),u=i.items?(0,xp.getSchemaTypes)(i.items):[];e.block$data(c,l,(0,we._)`${a} === false`),e.ok(c);function l(){let g=t.let("i",(0,we._)`${r}.length`),v=t.let("j");e.setParams({i:g,j:v}),t.assign(c,!0),t.if((0,we._)`${g} > 1`,()=>(d()?m:f)(g,v))}function d(){return u.length>0&&!u.some(g=>g==="object"||g==="array")}function m(g,v){let $=t.name("item"),x=(0,xp.checkDataTypes)(u,$,s.opts.strictNumbers,xp.DataType.Wrong),O=t.const("indices",(0,we._)`{}`);t.for((0,we._)`;${g}--;`,()=>{t.let($,(0,we._)`${r}[${g}]`),t.if(x,(0,we._)`continue`),u.length>1&&t.if((0,we._)`typeof ${$} == "string"`,(0,we._)`${$} += "_"`),t.if((0,we._)`typeof ${O}[${$}] == "number"`,()=>{t.assign(v,(0,we._)`${O}[${$}]`),e.error(),t.assign(c,!1).break()}).code((0,we._)`${O}[${$}] = ${g}`)})}function f(g,v){let $=(0,uI.useFunc)(t,lI.default),x=t.name("outer");t.label(x).for((0,we._)`;${g}--;`,()=>t.for((0,we._)`${v} = ${g}; ${v}--;`,()=>t.if((0,we._)`${$}(${r}[${g}], ${r}[${v}])`,()=>{e.error(),t.assign(c,!1).break(x)})))}}};kp.default=pI});var g_=S(wp=>{"use strict";Object.defineProperty(wp,"__esModule",{value:!0});var Sp=K(),fI=re(),mI=Qa(),hI={message:"must be equal to constant",params:({schemaCode:e})=>(0,Sp._)`{allowedValue: ${e}}`},gI={keyword:"const",$data:!0,error:hI,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:i}=e;n||i&&typeof i=="object"?e.fail$data((0,Sp._)`!${(0,fI.useFunc)(t,mI.default)}(${r}, ${o})`):e.fail((0,Sp._)`${i} !== ${r}`)}};wp.default=gI});var v_=S(zp=>{"use strict";Object.defineProperty(zp,"__esModule",{value:!0});var Xo=K(),vI=re(),_I=Qa(),yI={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Xo._)`{allowedValues: ${e}}`},$I={keyword:"enum",schemaType:"array",$data:!0,error:yI,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:i,it:a}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let s=o.length>=a.opts.loopEnum,c,u=()=>c??(c=(0,vI.useFunc)(t,_I.default)),l;if(s||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let f=t.const("vSchema",i);l=(0,Xo.or)(...o.map((g,v)=>m(f,v)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",i,f=>t.if((0,Xo._)`${u()}(${r}, ${f})`,()=>t.assign(l,!0).break()))}function m(f,g){let v=o[g];return typeof v=="object"&&v!==null?(0,Xo._)`${u()}(${r}, ${f}[${g}])`:(0,Xo._)`${r} === ${v}`}}};zp.default=$I});var __=S(Ip=>{"use strict";Object.defineProperty(Ip,"__esModule",{value:!0});var bI=i_(),xI=a_(),kI=u_(),SI=l_(),wI=d_(),zI=p_(),II=f_(),EI=h_(),TI=g_(),PI=v_(),OI=[bI.default,xI.default,kI.default,SI.default,wI.default,zI.default,II.default,EI.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},TI.default,PI.default];Ip.default=OI});var Tp=S(Yo=>{"use strict";Object.defineProperty(Yo,"__esModule",{value:!0});Yo.validateAdditionalItems=void 0;var kr=K(),Ep=re(),jI={message:({params:{len:e}})=>(0,kr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,kr._)`{limit: ${e}}`},NI={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:jI,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Ep.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}y_(e,n)}};function y_(e,t){let{gen:r,schema:n,data:o,keyword:i,it:a}=e;a.items=!0;let s=r.const("len",(0,kr._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,kr._)`${s} <= ${t.length}`);else if(typeof n=="object"&&!(0,Ep.alwaysValidSchema)(a,n)){let u=r.var("valid",(0,kr._)`${s} <= ${t.length}`);r.if((0,kr.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,s,l=>{e.subschema({keyword:i,dataProp:l,dataPropType:Ep.Type.Num},u),a.allErrors||r.if((0,kr.not)(u),()=>r.break())})}}Yo.validateAdditionalItems=y_;Yo.default=NI});var Pp=S(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});Qo.validateTuple=void 0;var $_=K(),es=re(),DI=rt(),RI={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return b_(e,"additionalItems",t);r.items=!0,!(0,es.alwaysValidSchema)(r,t)&&e.ok((0,DI.validateArray)(e))}};function b_(e,t,r=e.schema){let{gen:n,parentSchema:o,data:i,keyword:a,it:s}=e;l(o),s.opts.unevaluated&&r.length&&s.items!==!0&&(s.items=es.mergeEvaluated.items(n,r.length,s.items));let c=n.name("valid"),u=n.const("len",(0,$_._)`${i}.length`);r.forEach((d,m)=>{(0,es.alwaysValidSchema)(s,d)||(n.if((0,$_._)`${u} > ${m}`,()=>e.subschema({keyword:a,schemaProp:m,dataProp:m},c)),e.ok(c))});function l(d){let{opts:m,errSchemaPath:f}=s,g=r.length,v=g===d.minItems&&(g===d.maxItems||d[t]===!1);if(m.strictTuples&&!v){let $=`"${a}" is ${g}-tuple, but minItems or maxItems/${t} are not specified or different at path "${f}"`;(0,es.checkStrictMode)(s,$,m.strictTuples)}}}Qo.validateTuple=b_;Qo.default=RI});var x_=S(Op=>{"use strict";Object.defineProperty(Op,"__esModule",{value:!0});var ZI=Pp(),AI={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,ZI.validateTuple)(e,"items")};Op.default=AI});var S_=S(jp=>{"use strict";Object.defineProperty(jp,"__esModule",{value:!0});var k_=K(),UI=re(),CI=rt(),MI=Tp(),LI={message:({params:{len:e}})=>(0,k_.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,k_._)`{limit: ${e}}`},qI={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:LI,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,UI.alwaysValidSchema)(n,t)&&(o?(0,MI.validateAdditionalItems)(e,o):e.ok((0,CI.validateArray)(e)))}};jp.default=qI});var w_=S(Np=>{"use strict";Object.defineProperty(Np,"__esModule",{value:!0});var ot=K(),ts=re(),FI={message:({params:{min:e,max:t}})=>t===void 0?(0,ot.str)`must contain at least ${e} valid item(s)`:(0,ot.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,ot._)`{minContains: ${e}}`:(0,ot._)`{minContains: ${e}, maxContains: ${t}}`},VI={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:FI,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:i}=e,a,s,{minContains:c,maxContains:u}=n;i.opts.next?(a=c===void 0?1:c,s=u):a=1;let l=t.const("len",(0,ot._)`${o}.length`);if(e.setParams({min:a,max:s}),s===void 0&&a===0){(0,ts.checkStrictMode)(i,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(s!==void 0&&a>s){(0,ts.checkStrictMode)(i,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,ts.alwaysValidSchema)(i,r)){let v=(0,ot._)`${l} >= ${a}`;s!==void 0&&(v=(0,ot._)`${v} && ${l} <= ${s}`),e.pass(v);return}i.items=!0;let d=t.name("valid");s===void 0&&a===1?f(d,()=>t.if(d,()=>t.break())):a===0?(t.let(d,!0),s!==void 0&&t.if((0,ot._)`${o}.length > 0`,m)):(t.let(d,!1),m()),e.result(d,()=>e.reset());function m(){let v=t.name("_valid"),$=t.let("count",0);f(v,()=>t.if(v,()=>g($)))}function f(v,$){t.forRange("i",0,l,x=>{e.subschema({keyword:"contains",dataProp:x,dataPropType:ts.Type.Num,compositeRule:!0},v),$()})}function g(v){t.code((0,ot._)`${v}++`),s===void 0?t.if((0,ot._)`${v} >= ${a}`,()=>t.assign(d,!0).break()):(t.if((0,ot._)`${v} > ${s}`,()=>t.assign(d,!1).break()),a===1?t.assign(d,!0):t.if((0,ot._)`${v} >= ${a}`,()=>t.assign(d,!0)))}}};Np.default=VI});var E_=S(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.validateSchemaDeps=xt.validatePropertyDeps=xt.error=void 0;var Dp=K(),JI=re(),ei=rt();xt.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,Dp.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,Dp._)`{property: ${e},
missingProperty: ${n},
depsCount: ${t},
deps: ${r}}`};var KI={keyword:"dependencies",type:"object",schemaType:"object",error:xt.error,code(e){let[t,r]=WI(e);z_(e,t),I_(e,r)}};function WI({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}function z_(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let i=r.let("missing");for(let a in t){let s=t[a];if(s.length===0)continue;let c=(0,ei.propertyInData)(r,n,a,o.opts.ownProperties);e.setParams({property:a,depsCount:s.length,deps:s.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of s)(0,ei.checkReportMissingProp)(e,u)}):(r.if((0,Dp._)`${c} && (${(0,ei.checkMissingProp)(e,s,i)})`),(0,ei.reportMissingProp)(e,i),r.else())}}xt.validatePropertyDeps=z_;function I_(e,t=e.schema){let{gen:r,data:n,keyword:o,it:i}=e,a=r.name("valid");for(let s in t)(0,JI.alwaysValidSchema)(i,t[s])||(r.if((0,ei.propertyInData)(r,n,s,i.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:s},a);e.mergeValidEvaluated(c,a)},()=>r.var(a,!0)),e.ok(a))}xt.validateSchemaDeps=I_;xt.default=KI});var P_=S(Rp=>{"use strict";Object.defineProperty(Rp,"__esModule",{value:!0});var T_=K(),GI=re(),HI={message:"property name must be valid",params:({params:e})=>(0,T_._)`{propertyName: ${e.propertyName}}`},BI={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:HI,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,GI.alwaysValidSchema)(o,r))return;let i=t.name("valid");t.forIn("key",n,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:!0},i),t.if((0,T_.not)(i),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(i)}};Rp.default=BI});var Ap=S(Zp=>{"use strict";Object.defineProperty(Zp,"__esModule",{value:!0});var rs=rt(),mt=K(),XI=At(),ns=re(),YI={message:"must NOT have additional properties",params:({params:e})=>(0,mt._)`{additionalProperty: ${e.additionalProperty}}`},QI={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:YI,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:i,it:a}=e;if(!i)throw new Error("ajv implementation error");let{allErrors:s,opts:c}=a;if(a.props=!0,c.removeAdditional!=="all"&&(0,ns.alwaysValidSchema)(a,r))return;let u=(0,rs.allSchemaProperties)(n.properties),l=(0,rs.allSchemaProperties)(n.patternProperties);d(),e.ok((0,mt._)`${i} === ${XI.default.errors}`);function d(){t.forIn("key",o,$=>{!u.length&&!l.length?g($):t.if(m($),()=>g($))})}function m($){let x;if(u.length>8){let O=(0,ns.schemaRefOrVal)(a,n.properties,"properties");x=(0,rs.isOwnProperty)(t,O,$)}else u.length?x=(0,mt.or)(...u.map(O=>(0,mt._)`${$} === ${O}`)):x=mt.nil;return l.length&&(x=(0,mt.or)(x,...l.map(O=>(0,mt._)`${(0,rs.usePattern)(e,O)}.test(${$})`))),(0,mt.not)(x)}function f($){t.code((0,mt._)`delete ${o}[${$}]`)}function g($){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f($);return}if(r===!1){e.setParams({additionalProperty:$}),e.error(),s||t.break();return}if(typeof r=="object"&&!(0,ns.alwaysValidSchema)(a,r)){let x=t.name("valid");c.removeAdditional==="failing"?(v($,x,!1),t.if((0,mt.not)(x),()=>{e.reset(),f($)})):(v($,x),s||t.if((0,mt.not)(x),()=>t.break()))}}function v($,x,O){let I={keyword:"additionalProperties",dataProp:$,dataPropType:ns.Type.Str};O===!1&&Object.assign(I,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(I,x)}}};Zp.default=QI});var N_=S(Cp=>{"use strict";Object.defineProperty(Cp,"__esModule",{value:!0});var eE=Mo(),O_=rt(),Up=re(),j_=Ap(),tE={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:i}=e;i.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&j_.default.code(new eE.KeywordCxt(i,j_.default,"additionalProperties"));let a=(0,O_.allSchemaProperties)(r);for(let d of a)i.definedProperties.add(d);i.opts.unevaluated&&a.length&&i.props!==!0&&(i.props=Up.mergeEvaluated.props(t,(0,Up.toHash)(a),i.props));let s=a.filter(d=>!(0,Up.alwaysValidSchema)(i,r[d]));if(s.length===0)return;let c=t.name("valid");for(let d of s)u(d)?l(d):(t.if((0,O_.propertyInData)(t,o,d,i.opts.ownProperties)),l(d),i.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return i.opts.useDefaults&&!i.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Cp.default=tE});var A_=S(Mp=>{"use strict";Object.defineProperty(Mp,"__esModule",{value:!0});var D_=rt(),os=K(),R_=re(),Z_=re(),rE={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:i}=e,{opts:a}=i,s=(0,D_.allSchemaProperties)(r),c=s.filter(v=>(0,R_.alwaysValidSchema)(i,r[v]));if(s.length===0||c.length===s.length&&(!i.opts.unevaluated||i.props===!0))return;let u=a.strictSchema&&!a.allowMatchingProperties&&o.properties,l=t.name("valid");i.props!==!0&&!(i.props instanceof os.Name)&&(i.props=(0,Z_.evaluatedPropsToName)(t,i.props));let{props:d}=i;m();function m(){for(let v of s)u&&f(v),i.allErrors?g(v):(t.var(l,!0),g(v),t.if(l))}function f(v){for(let $ in u)new RegExp(v).test($)&&(0,R_.checkStrictMode)(i,`property ${$} matches pattern ${v} (use allowMatchingProperties)`)}function g(v){t.forIn("key",n,$=>{t.if((0,os._)`${(0,D_.usePattern)(e,v)}.test(${$})`,()=>{let x=c.includes(v);x||e.subschema({keyword:"patternProperties",schemaProp:v,dataProp:$,dataPropType:Z_.Type.Str},l),i.opts.unevaluated&&d!==!0?t.assign((0,os._)`${d}[${$}]`,!0):!x&&!i.allErrors&&t.if((0,os.not)(l),()=>t.break())})})}}};Mp.default=rE});var U_=S(Lp=>{"use strict";Object.defineProperty(Lp,"__esModule",{value:!0});var nE=re(),oE={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,nE.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Lp.default=oE});var C_=S(qp=>{"use strict";Object.defineProperty(qp,"__esModule",{value:!0});var iE=rt(),aE={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:iE.validateUnion,error:{message:"must match a schema in anyOf"}};qp.default=aE});var M_=S(Fp=>{"use strict";Object.defineProperty(Fp,"__esModule",{value:!0});var is=K(),sE=re(),cE={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,is._)`{passingSchemas: ${e.passing}}`},uE={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:cE,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let i=r,a=t.let("valid",!1),s=t.let("passing",null),c=t.name("_valid");e.setParams({passing:s}),t.block(u),e.result(a,()=>e.reset(),()=>e.error(!0));function u(){i.forEach((l,d)=>{let m;(0,sE.alwaysValidSchema)(o,l)?t.var(c,!0):m=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,is._)`${c} && ${a}`).assign(a,!1).assign(s,(0,is._)`[${s}, ${d}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(s,d),m&&e.mergeEvaluated(m,is.Name)})})}}};Fp.default=uE});var L_=S(Vp=>{"use strict";Object.defineProperty(Vp,"__esModule",{value:!0});var lE=re(),dE={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((i,a)=>{if((0,lE.alwaysValidSchema)(n,i))return;let s=e.subschema({keyword:"allOf",schemaProp:a},o);e.ok(o),e.mergeEvaluated(s)})}};Vp.default=dE});var V_=S(Jp=>{"use strict";Object.defineProperty(Jp,"__esModule",{value:!0});var as=K(),F_=re(),pE={message:({params:e})=>(0,as.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,as._)`{failingKeyword: ${e.ifClause}}`},fE={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:pE,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,F_.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=q_(n,"then"),i=q_(n,"else");if(!o&&!i)return;let a=t.let("valid",!0),s=t.name("_valid");if(c(),e.reset(),o&&i){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(s,u("then",l),u("else",l))}else o?t.if(s,u("then")):t.if((0,as.not)(s),u("else"));e.pass(a,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},s);e.mergeEvaluated(l)}function u(l,d){return()=>{let m=e.subschema({keyword:l},s);t.assign(a,s),e.mergeValidEvaluated(m,a),d?t.assign(d,(0,as._)`${l}`):e.setParams({ifClause:l})}}}};function q_(e,t){let r=e.schema[t];return r!==void 0&&!(0,F_.alwaysValidSchema)(e,r)}Jp.default=fE});var J_=S(Kp=>{"use strict";Object.defineProperty(Kp,"__esModule",{value:!0});var mE=re(),hE={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,mE.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Kp.default=hE});var K_=S(Wp=>{"use strict";Object.defineProperty(Wp,"__esModule",{value:!0});var gE=Tp(),vE=x_(),_E=Pp(),yE=S_(),$E=w_(),bE=E_(),xE=P_(),kE=Ap(),SE=N_(),wE=A_(),zE=U_(),IE=C_(),EE=M_(),TE=L_(),PE=V_(),OE=J_();function jE(e=!1){let t=[zE.default,IE.default,EE.default,TE.default,PE.default,OE.default,xE.default,kE.default,bE.default,SE.default,wE.default];return e?t.push(vE.default,yE.default):t.push(gE.default,_E.default),t.push($E.default),t}Wp.default=jE});var W_=S(Gp=>{"use strict";Object.defineProperty(Gp,"__esModule",{value:!0});var ve=K(),NE={message:({schemaCode:e})=>(0,ve.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,ve._)`{format: ${e}}`},DE={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:NE,code(e,t){let{gen:r,data:n,$data:o,schema:i,schemaCode:a,it:s}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=s;if(!c.validateFormats)return;o?m():f();function m(){let g=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),v=r.const("fDef",(0,ve._)`${g}[${a}]`),$=r.let("fType"),x=r.let("format");r.if((0,ve._)`typeof ${v} == "object" && !(${v} instanceof RegExp)`,()=>r.assign($,(0,ve._)`${v}.type || "string"`).assign(x,(0,ve._)`${v}.validate`),()=>r.assign($,(0,ve._)`"string"`).assign(x,v)),e.fail$data((0,ve.or)(O(),I()));function O(){return c.strictSchema===!1?ve.nil:(0,ve._)`${a} && !${x}`}function I(){let U=l.$async?(0,ve._)`(${v}.async ? await ${x}(${n}) : ${x}(${n}))`:(0,ve._)`${x}(${n})`,j=(0,ve._)`(typeof ${x} == "function" ? ${U} : ${x}.test(${n}))`;return(0,ve._)`${x} && ${x} !== true && ${$} === ${t} && !${j}`}}function f(){let g=d.formats[i];if(!g){O();return}if(g===!0)return;let[v,$,x]=I(g);v===t&&e.pass(U());function O(){if(c.strictSchema===!1){d.logger.warn(j());return}throw new Error(j());function j(){return`unknown format "${i}" ignored in schema at path "${u}"`}}function I(j){let it=j instanceof RegExp?(0,ve.regexpCode)(j):c.code.formats?(0,ve._)`${c.code.formats}${(0,ve.getProperty)(i)}`:void 0,at=r.scopeValue("formats",{key:i,ref:j,code:it});return typeof j=="object"&&!(j instanceof RegExp)?[j.type||"string",j.validate,(0,ve._)`${at}.validate`]:["string",j,at]}function U(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ve._)`await ${x}(${n})`}return typeof $=="function"?(0,ve._)`${x}(${n})`:(0,ve._)`${x}.test(${n})`}}}};Gp.default=DE});var G_=S(Hp=>{"use strict";Object.defineProperty(Hp,"__esModule",{value:!0});var RE=W_(),ZE=[RE.default];Hp.default=ZE});var H_=S(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});ln.contentVocabulary=ln.metadataVocabulary=void 0;ln.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ln.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var X_=S(Bp=>{"use strict";Object.defineProperty(Bp,"__esModule",{value:!0});var AE=o_(),UE=__(),CE=K_(),ME=G_(),B_=H_(),LE=[AE.default,UE.default,(0,CE.default)(),ME.default,B_.metadataVocabulary,B_.contentVocabulary];Bp.default=LE});var Q_=S(ss=>{"use strict";Object.defineProperty(ss,"__esModule",{value:!0});ss.DiscrError=void 0;var Y_;(function(e){e.Tag="tag",e.Mapping="mapping"})(Y_||(ss.DiscrError=Y_={}))});var ty=S(Yp=>{"use strict";Object.defineProperty(Yp,"__esModule",{value:!0});var dn=K(),Xp=Q_(),ey=qa(),qE=Lo(),FE=re(),VE={message:({params:{discrError:e,tagName:t}})=>e===Xp.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,dn._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},JE={keyword:"discriminator",type:"object",schemaType:"object",error:VE,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:i}=e,{oneOf:a}=o;if(!i.opts.discriminator)throw new Error("discriminator: requires discriminator option");let s=n.propertyName;if(typeof s!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",(0,dn._)`${r}${(0,dn.getProperty)(s)}`);t.if((0,dn._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:Xp.DiscrError.Tag,tag:u,tagName:s})),e.ok(c);function l(){let f=m();t.if(!1);for(let g in f)t.elseIf((0,dn._)`${u} === ${g}`),t.assign(c,d(f[g]));t.else(),e.error(!1,{discrError:Xp.DiscrError.Mapping,tag:u,tagName:s}),t.endIf()}function d(f){let g=t.name("valid"),v=e.subschema({keyword:"oneOf",schemaProp:f},g);return e.mergeEvaluated(v,dn.Name),g}function m(){var f;let g={},v=x(o),$=!0;for(let U=0;U<a.length;U++){let j=a[U];if(j?.$ref&&!(0,FE.schemaHasRulesButRef)(j,i.self.RULES)){let at=j.$ref;if(j=ey.resolveRef.call(i.self,i.schemaEnv.root,i.baseId,at),j instanceof ey.SchemaEnv&&(j=j.schema),j===void 0)throw new qE.default(i.opts.uriResolver,i.baseId,at)}let it=(f=j?.properties)===null||f===void 0?void 0:f[s];if(typeof it!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${s}"`);$=$&&(v||x(j)),O(it,U)}if(!$)throw new Error(`discriminator: "${s}" must be required`);return g;function x({required:U}){return Array.isArray(U)&&U.includes(s)}function O(U,j){if(U.const)I(U.const,j);else if(U.enum)for(let it of U.enum)I(it,j);else throw new Error(`discriminator: "properties/${s}" must have "const" or "enum"`)}function I(U,j){if(typeof U!="string"||U in g)throw new Error(`discriminator: "${s}" values must be unique strings`);g[U]=j}}}};Yp.default=JE});var ry=S((uU,KE)=>{KE.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var ef=S((he,Qp)=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.MissingRefError=he.ValidationError=he.CodeGen=he.Name=he.nil=he.stringify=he.str=he._=he.KeywordCxt=he.Ajv=void 0;var WE=Yv(),GE=X_(),HE=ty(),ny=ry(),BE=["/properties"],cs="http://json-schema.org/draft-07/schema",pn=class extends WE.default{_addVocabularies(){super._addVocabularies(),GE.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(HE.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(ny,BE):ny;this.addMetaSchema(t,cs,!1),this.refs["http://json-schema.org/schema"]=cs}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(cs)?cs:void 0)}};he.Ajv=pn;Qp.exports=he=pn;Qp.exports.Ajv=pn;Object.defineProperty(he,"__esModule",{value:!0});he.default=pn;var XE=Mo();Object.defineProperty(he,"KeywordCxt",{enumerable:!0,get:function(){return XE.KeywordCxt}});var fn=K();Object.defineProperty(he,"_",{enumerable:!0,get:function(){return fn._}});Object.defineProperty(he,"str",{enumerable:!0,get:function(){return fn.str}});Object.defineProperty(he,"stringify",{enumerable:!0,get:function(){return fn.stringify}});Object.defineProperty(he,"nil",{enumerable:!0,get:function(){return fn.nil}});Object.defineProperty(he,"Name",{enumerable:!0,get:function(){return fn.Name}});Object.defineProperty(he,"CodeGen",{enumerable:!0,get:function(){return fn.CodeGen}});var YE=Ma();Object.defineProperty(he,"ValidationError",{enumerable:!0,get:function(){return YE.default}});var QE=Lo();Object.defineProperty(he,"MissingRefError",{enumerable:!0,get:function(){return QE.default}})});var dy=S(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.formatNames=St.fastFormats=St.fullFormats=void 0;function kt(e,t){return{validate:e,compare:t}}St.fullFormats={date:kt(sy,of),time:kt(rf(!0),af),"date-time":kt(oy(!0),uy),"iso-time":kt(rf(),cy),"iso-date-time":kt(oy(),ly),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:iT,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:pT,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:aT,int32:{type:"number",validate:uT},int64:{type:"number",validate:lT},float:{type:"number",validate:ay},double:{type:"number",validate:ay},password:!0,binary:!0};St.fastFormats={...St.fullFormats,date:kt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,of),time:kt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,af),"date-time":kt(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uy),"iso-time":kt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,cy),"iso-date-time":kt(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,ly),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};St.formatNames=Object.keys(St.fullFormats);function eT(e){return e%4===0&&(e%100!==0||e%400===0)}var tT=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,rT=[0,31,28,31,30,31,30,31,31,30,31,30,31];function sy(e){let t=tT.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&eT(r)?29:rT[n])}function of(e,t){if(e&&t)return e>t?1:e<t?-1:0}var tf=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function rf(e){return function(r){let n=tf.exec(r);if(!n)return!1;let o=+n[1],i=+n[2],a=+n[3],s=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||e&&!s)return!1;if(o<=23&&i<=59&&a<60)return!0;let d=i-l*c,m=o-u*c-(d<0?1:0);return(m===23||m===-1)&&(d===59||d===-1)&&a<61}}function af(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function cy(e,t){if(!(e&&t))return;let r=tf.exec(e),n=tf.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var nf=/t|\s/i;function oy(e){let t=rf(e);return function(n){let o=n.split(nf);return o.length===2&&sy(o[0])&&t(o[1])}}function uy(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function ly(e,t){if(!(e&&t))return;let[r,n]=e.split(nf),[o,i]=t.split(nf),a=of(r,o);if(a!==void 0)return a||af(n,i)}var nT=/\/|:/,oT=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function iT(e){return nT.test(e)&&oT.test(e)}var iy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function aT(e){return iy.lastIndex=0,iy.test(e)}var sT=-(2**31),cT=2**31-1;function uT(e){return Number.isInteger(e)&&e<=cT&&e>=sT}function lT(e){return Number.isInteger(e)}function ay(){return!0}var dT=/[^\\]\\Z/;function pT(e){if(dT.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var py=S(mn=>{"use strict";Object.defineProperty(mn,"__esModule",{value:!0});mn.formatLimitDefinition=void 0;var fT=ef(),ht=K(),or=ht.operators,us={formatMaximum:{okStr:"<=",ok:or.LTE,fail:or.GT},formatMinimum:{okStr:">=",ok:or.GTE,fail:or.LT},formatExclusiveMaximum:{okStr:"<",ok:or.LT,fail:or.GTE},formatExclusiveMinimum:{okStr:">",ok:or.GT,fail:or.LTE}},mT={message:({keyword:e,schemaCode:t})=>(0,ht.str)`should be ${us[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ht._)`{comparison: ${us[e].okStr}, limit: ${t}}`};mn.formatLimitDefinition={keyword:Object.keys(us),type:"string",schemaType:"string",$data:!0,error:mT,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:i}=e,{opts:a,self:s}=i;if(!a.validateFormats)return;let c=new fT.KeywordCxt(i,s.RULES.all.format.definition,"format");c.$data?u():l();function u(){let m=t.scopeValue("formats",{ref:s.formats,code:a.code.formats}),f=t.const("fmt",(0,ht._)`${m}[${c.schemaCode}]`);e.fail$data((0,ht.or)((0,ht._)`typeof ${f} != "object"`,(0,ht._)`${f} instanceof RegExp`,(0,ht._)`typeof ${f}.compare != "function"`,d(f)))}function l(){let m=c.schema,f=s.formats[m];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${o}": format "${m}" does not define "compare" function`);let g=t.scopeValue("formats",{key:m,ref:f,code:a.code.formats?(0,ht._)`${a.code.formats}${(0,ht.getProperty)(m)}`:void 0});e.fail$data(d(g))}function d(m){return(0,ht._)`${m}.compare(${r}, ${n}) ${us[o].fail} 0`}},dependencies:["format"]};var hT=e=>(e.addKeyword(mn.formatLimitDefinition),e);mn.default=hT});var gy=S((ti,hy)=>{"use strict";Object.defineProperty(ti,"__esModule",{value:!0});var hn=dy(),gT=py(),sf=K(),fy=new sf.Name("fullFormats"),vT=new sf.Name("fastFormats"),cf=(e,t={keywords:!0})=>{if(Array.isArray(t))return my(e,t,hn.fullFormats,fy),e;let[r,n]=t.mode==="fast"?[hn.fastFormats,vT]:[hn.fullFormats,fy],o=t.formats||hn.formatNames;return my(e,o,r,n),t.keywords&&(0,gT.default)(e),e};cf.get=(e,t="full")=>{let n=(t==="fast"?hn.fastFormats:hn.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function my(e,t,r,n){var o,i;(o=(i=e.opts.code).formats)!==null&&o!==void 0||(i.formats=(0,sf._)`require("ajv-formats/dist/formats").${n}`);for(let a of t)e.addFormat(a,r[a])}hy.exports=ti=cf;Object.defineProperty(ti,"__esModule",{value:!0});ti.default=cf});var Sr=require("fs"),gf=require("path"),vf=require("os");var mf="bugfix,feature,refactor,discovery,decision,change",hf="how-it-works,why-it-exists,what-changed,problem-solution,gotcha,pattern,trade-off";var st=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-sonnet-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_PROVIDER:"claude",CLAUDE_MEM_GEMINI_API_KEY:"",CLAUDE_MEM_GEMINI_MODEL:"gemini-2.5-flash-lite",CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED:"true",CLAUDE_MEM_OPENROUTER_API_KEY:"",CLAUDE_MEM_OPENROUTER_MODEL:"xiaomi/mimo-v2-flash:free",CLAUDE_MEM_OPENROUTER_SITE_URL:"",CLAUDE_MEM_OPENROUTER_APP_NAME:"claude-mem",CLAUDE_MEM_OPENROUTER_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_OPENROUTER_MAX_TOKENS:"100000",CLAUDE_MEM_DATA_DIR:(0,gf.join)((0,vf.homedir)(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_MODE:"code",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:mf,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:hf,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let r=this.get(t);return parseInt(r,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){try{if(!(0,Sr.existsSync)(t))return this.getAllDefaults();let r=(0,Sr.readFileSync)(t,"utf-8"),n=JSON.parse(r),o=n;if(n.env&&typeof n.env=="object"){o=n.env;try{(0,Sr.writeFileSync)(t,JSON.stringify(o,null,2),"utf-8"),ge.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(a){ge.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},a)}}let i={...this.DEFAULTS};for(let a of Object.keys(this.DEFAULTS))o[a]!==void 0&&(i[a]=o[a]);return i}catch(r){return ge.warn("SETTINGS","Failed to load settings, using defaults",{settingsPath:t},r),this.getAllDefaults()}}};var wr=require("fs"),oi=require("path"),xs=(i=>(i[i.DEBUG=0]="DEBUG",i[i.INFO=1]="INFO",i[i.WARN=2]="WARN",i[i.ERROR=3]="ERROR",i[i.SILENT=4]="SILENT",i))(xs||{}),ks=class{level=null;useColor;logFilePath=null;constructor(){this.useColor=process.stdout.isTTY??!1,this.initializeLogFile()}initializeLogFile(){try{let t=st.get("CLAUDE_MEM_DATA_DIR"),r=(0,oi.join)(t,"logs");(0,wr.existsSync)(r)||(0,wr.mkdirSync)(r,{recursive:!0});let n=new Date().toISOString().split("T")[0];this.logFilePath=(0,oi.join)(r,`claude-mem-${n}.log`)}catch(t){console.error("[LOGGER] Failed to initialize log file:",t),this.logFilePath=null}}getLevel(){if(this.level===null)try{let t=st.get("CLAUDE_MEM_DATA_DIR"),r=(0,oi.join)(t,"settings.json"),o=st.loadFromFile(r).CLAUDE_MEM_LOG_LEVEL.toUpperCase();this.level=xs[o]??1}catch(t){console.error("[LOGGER] Failed to load settings, using INFO level:",t),this.level=1}return this.level}correlationId(t,r){return`obs-${t}-${r}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message}
${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let r=Object.keys(t);return r.length===0?"{}":r.length<=3?JSON.stringify(t):`{${r.length} keys: ${r.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,r){if(!r)return t;let n=typeof r=="string"?JSON.parse(r):r;if(t==="Bash"&&n.command)return`${t}(${n.command})`;if(n.file_path)return`${t}(${n.file_path})`;if(n.notebook_path)return`${t}(${n.notebook_path})`;if(t==="Glob"&&n.pattern)return`${t}(${n.pattern})`;if(t==="Grep"&&n.pattern)return`${t}(${n.pattern})`;if(n.url)return`${t}(${n.url})`;if(n.query)return`${t}(${n.query})`;if(t==="Task"){if(n.subagent_type)return`${t}(${n.subagent_type})`;if(n.description)return`${t}(${n.description})`}return t==="Skill"&&n.skill?`${t}(${n.skill})`:t==="LSP"&&n.operation?`${t}(${n.operation})`:t}formatTimestamp(t){let r=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),i=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),s=String(t.getSeconds()).padStart(2,"0"),c=String(t.getMilliseconds()).padStart(3,"0");return`${r}-${n}-${o} ${i}:${a}:${s}.${c}`}log(t,r,n,o,i){if(t<this.getLevel())return;let a=this.formatTimestamp(new Date),s=xs[t].padEnd(5),c=r.padEnd(6),u="";o?.correlationId?u=`[${o.correlationId}] `:o?.sessionId&&(u=`[session-${o.sessionId}] `);let l="";i!=null&&(i instanceof Error?l=this.getLevel()===0?`
${i.message}
${i.stack}`:` ${i.message}`:this.getLevel()===0&&typeof i=="object"?l=`
`+JSON.stringify(i,null,2):l=" "+this.formatData(i));let d="";if(o){let{sessionId:f,memorySessionId:g,correlationId:v,...$}=o;Object.keys($).length>0&&(d=` {${Object.entries($).map(([O,I])=>`${O}=${I}`).join(", ")}}`)}let m=`[${a}] [${s}] [${c}] ${u}${n}${d}${l}`;if(this.logFilePath)try{(0,wr.appendFileSync)(this.logFilePath,m+`
`,"utf8")}catch(f){process.stderr.write(`[LOGGER] Failed to write to log file: ${f}
`)}else process.stderr.write(m+`
`)}debug(t,r,n,o){this.log(0,t,r,n,o)}info(t,r,n,o){this.log(1,t,r,n,o)}warn(t,r,n,o){this.log(2,t,r,n,o)}error(t,r,n,o){this.log(3,t,r,n,o)}dataIn(t,r,n,o){this.info(t,`\u2192 ${r}`,n,o)}dataOut(t,r,n,o){this.info(t,`\u2190 ${r}`,n,o)}success(t,r,n,o){this.info(t,`\u2713 ${r}`,n,o)}failure(t,r,n,o){this.error(t,`\u2717 ${r}`,n,o)}timing(t,r,n,o){this.info(t,`\u23F1 ${r}`,o,{duration:`${n}ms`})}happyPathError(t,r,n,o,i=""){let u=((new Error().stack||"").split(`
`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),l=u?`${u[1].split("/").pop()}:${u[2]}`:"unknown",d={...n,location:l};return this.warn(t,`[HAPPY-PATH] ${r}`,d,o),i}},ge=new ks;var X;(function(e){e.assertEqual=o=>{};function t(o){}e.assertIs=t;function r(o){throw new Error}e.assertNever=r,e.arrayToEnum=o=>{let i={};for(let a of o)i[a]=a;return i},e.getValidEnumValues=o=>{let i=e.objectKeys(o).filter(s=>typeof o[o[s]]!="number"),a={};for(let s of i)a[s]=o[s];return e.objectValues(a)},e.objectValues=o=>e.objectKeys(o).map(function(i){return o[i]}),e.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let i=[];for(let a in o)Object.prototype.hasOwnProperty.call(o,a)&&i.push(a);return i},e.find=(o,i)=>{for(let a of o)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,i=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=n,e.jsonStringifyReplacer=(o,i)=>typeof i=="bigint"?i.toString():i})(X||(X={}));var _f;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(_f||(_f={}));var w=X.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),wt=e=>{switch(typeof e){case"undefined":return w.undefined;case"string":return w.string;case"number":return Number.isNaN(e)?w.nan:w.number;case"boolean":return w.boolean;case"function":return w.function;case"bigint":return w.bigint;case"symbol":return w.symbol;case"object":return Array.isArray(e)?w.array:e===null?w.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?w.promise:typeof Map<"u"&&e instanceof Map?w.map:typeof Set<"u"&&e instanceof Set?w.set:typeof Date<"u"&&e instanceof Date?w.date:w.object;default:return w.unknown}};var _=X.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);var Ve=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(i){return i.message},n={_errors:[]},o=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let s=n,c=0;for(;c<a.path.length;){let u=a.path[c];c===a.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(r(a))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return o(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,X.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r=Object.create(null),n=[];for(let o of this.issues)if(o.path.length>0){let i=o.path[0];r[i]=r[i]||[],r[i].push(t(o))}else n.push(t(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Ve.create=e=>new Ve(e);var Ay=(e,t)=>{let r;switch(e.code){case _.invalid_type:e.received===w.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case _.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,X.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:r=`Unrecognized key(s) in object: ${X.joinValues(e.keys,", ")}`;break;case _.invalid_union:r="Invalid input";break;case _.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${X.joinValues(e.options)}`;break;case _.invalid_enum_value:r=`Invalid enum value. Expected ${X.joinValues(e.options)}, received '${e.received}'`;break;case _.invalid_arguments:r="Invalid function arguments";break;case _.invalid_return_type:r="Invalid function return type";break;case _.invalid_date:r="Invalid date";break;case _.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:X.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case _.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case _.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case _.custom:r="Invalid input";break;case _.invalid_intersection_types:r="Intersection results could not be merged";break;case _.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case _.not_finite:r="Number must be finite";break;default:r=t.defaultError,X.assertNever(e)}return{message:r}},Mt=Ay;var Uy=Mt;function _n(){return Uy}var ii=e=>{let{data:t,path:r,errorMaps:n,issueData:o}=e,i=[...r,...o.path||[]],a={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let s="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)s=u(a,{data:t,defaultError:s}).message;return{...o,path:i,message:s}};function b(e,t){let r=_n(),n=ii({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Mt?void 0:Mt].filter(o=>!!o)});e.common.issues.push(n)}var ze=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let o of r){if(o.status==="aborted")return Z;o.status==="dirty"&&t.dirty(),n.push(o.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let o of r){let i=await o.key,a=await o.value;n.push({key:i,value:a})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let o of r){let{key:i,value:a}=o;if(i.status==="aborted"||a.status==="aborted")return Z;i.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(n[i.value]=a.value)}return{status:t.value,value:n}}},Z=Object.freeze({status:"aborted"}),zr=e=>({status:"dirty",value:e}),je=e=>({status:"valid",value:e}),Ss=e=>e.status==="aborted",ws=e=>e.status==="dirty",ir=e=>e.status==="valid",yn=e=>typeof Promise<"u"&&e instanceof Promise;var E;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(E||(E={}));var Be=class{constructor(t,r,n,o){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},yf=(e,t)=>{if(ir(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Ve(e.common.issues);return this._error=r,this._error}}};function L(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:o}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(a,s)=>{let{message:c}=e;return a.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??n??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:o}}var W=class{get description(){return this._def.description}_getType(t){return wt(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:wt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ze,ctx:{common:t.parent.common,data:t.data,parsedType:wt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(yn(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:wt(t)},o=this._parseSync({data:t,path:n.path,parent:n});return yf(n,o)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:wt(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return ir(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>ir(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:wt(t)},o=this._parse({data:t,path:n.path,parent:n}),i=await(yn(o)?o:Promise.resolve(o));return yf(n,i)}refine(t,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,i)=>{let a=t(o),s=()=>i.addIssue({code:_.custom,...n(o)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(t,r){return this._refinement((n,o)=>t(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(t){return new ut({schema:this,typeName:N.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return ct.create(this,this._def)}nullable(){return Et.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return qt.create(this)}promise(){return ar.create(this,this._def)}or(t){return Or.create([this,t],this._def)}and(t){return jr.create(this,t,this._def)}transform(t){return new ut({...L(this._def),schema:this,typeName:N.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new Ar({...L(this._def),innerType:this,defaultValue:r,typeName:N.ZodDefault})}brand(){return new ai({typeName:N.ZodBranded,type:this,...L(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new Ur({...L(this._def),innerType:this,catchValue:r,typeName:N.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return si.create(this,t)}readonly(){return Cr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Cy=/^c[^\s-]{8,}$/i,My=/^[0-9a-z]+$/,Ly=/^[0-9A-HJKMNP-TV-Z]{26}$/i,qy=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Fy=/^[a-z0-9_-]{21}$/i,Vy=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Jy=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ky=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Wy="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",zs,Gy=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Hy=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,By=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Xy=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Yy=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Qy=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,$f="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",e$=new RegExp(`^${$f}$`);function bf(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function t$(e){return new RegExp(`^${bf(e)}$`)}function r$(e){let t=`${$f}T${bf(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function n$(e,t){return!!((t==="v4"||!t)&&Gy.test(e)||(t==="v6"||!t)&&By.test(e))}function o$(e,t){if(!Vy.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}function i$(e,t){return!!((t==="v4"||!t)&&Hy.test(e)||(t==="v6"||!t)&&Xy.test(e))}var Er=class e extends W{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==w.string){let i=this._getOrReturnCtx(t);return b(i,{code:_.invalid_type,expected:w.string,received:i.parsedType}),Z}let n=new ze,o;for(let i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(o=this._getOrReturnCtx(t,o),b(o,{code:_.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")t.data.length>i.value&&(o=this._getOrReturnCtx(t,o),b(o,{code:_.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let a=t.data.length>i.value,s=t.data.length<i.value;(a||s)&&(o=this._getOrReturnCtx(t,o),a?b(o,{code:_.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&b(o,{code:_.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Ky.test(t.data)||(o=this._getOrReturnCtx(t,o),b(o,{validation:"email",code:_.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")zs||(zs=new RegExp(Wy,"u")),zs.test(t.data)||(o=this._getOrReturnCtx(t,o),b(o,{validation:"emoji",code:_.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")qy.test(t.data)||(o=this._getOrReturnCtx(t,o),b(o,{validation:"uuid",code:_.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Fy.test(t.data)||(o=this._getOrReturnCtx(t,o),b(o,{validation:"nanoid",code:_.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")Cy.test(t.data)||(o=this._getOrReturnCtx(t,o),b(o,{validation:"cuid",code:_.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")My.test(t.data)||(o=this._getOrReturnCtx(t,o),b(o,{validation:"cuid2",code:_.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Ly.test(t.data)||(o=this._getOrReturnCtx(t,o),b(o,{validation:"ulid",code:_.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),b(o,{validation:"url",code:_.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),b(o,{validation:"regex",code:_.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(o=this._getOrReturnCtx(t,o),b(o,{code:_.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(o=this._getOrReturnCtx(t,o),b(o,{code:_.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(o=this._getOrReturnCtx(t,o),b(o,{code:_.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?r$(i).test(t.data)||(o=this._getOrReturnCtx(t,o),b(o,{code:_.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?e$.test(t.data)||(o=this._getOrReturnCtx(t,o),b(o,{code:_.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?t$(i).test(t.data)||(o=this._getOrReturnCtx(t,o),b(o,{code:_.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Jy.test(t.data)||(o=this._getOrReturnCtx(t,o),b(o,{validation:"duration",code:_.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?n$(t.data,i.version)||(o=this._getOrReturnCtx(t,o),b(o,{validation:"ip",code:_.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?o$(t.data,i.alg)||(o=this._getOrReturnCtx(t,o),b(o,{validation:"jwt",code:_.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?i$(t.data,i.version)||(o=this._getOrReturnCtx(t,o),b(o,{validation:"cidr",code:_.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?Yy.test(t.data)||(o=this._getOrReturnCtx(t,o),b(o,{validation:"base64",code:_.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?Qy.test(t.data)||(o=this._getOrReturnCtx(t,o),b(o,{validation:"base64url",code:_.invalid_string,message:i.message}),n.dirty()):X.assertNever(i);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(o=>t.test(o),{validation:r,code:_.invalid_string,...E.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...E.errToObj(t)})}url(t){return this._addCheck({kind:"url",...E.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...E.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...E.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...E.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...E.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...E.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...E.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...E.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...E.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...E.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...E.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...E.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...E.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...E.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...E.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...E.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...E.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...E.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...E.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...E.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...E.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...E.errToObj(r)})}nonempty(t){return this.min(1,E.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Er.create=e=>new Er({checks:[],typeName:N.ZodString,coerce:e?.coerce??!1,...L(e)});function a$(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,i=Number.parseInt(e.toFixed(o).replace(".","")),a=Number.parseInt(t.toFixed(o).replace(".",""));return i%a/10**o}var $n=class e extends W{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==w.number){let i=this._getOrReturnCtx(t);return b(i,{code:_.invalid_type,expected:w.number,received:i.parsedType}),Z}let n,o=new ze;for(let i of this._def.checks)i.kind==="int"?X.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),b(n,{code:_.invalid_type,expected:"integer",received:"float",message:i.message}),o.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(n=this._getOrReturnCtx(t,n),b(n,{code:_.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(n=this._getOrReturnCtx(t,n),b(n,{code:_.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?a$(t.data,i.value)!==0&&(n=this._getOrReturnCtx(t,n),b(n,{code:_.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),b(n,{code:_.not_finite,message:i.message}),o.dirty()):X.assertNever(i);return{status:o.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,E.toString(r))}gt(t,r){return this.setLimit("min",t,!1,E.toString(r))}lte(t,r){return this.setLimit("max",t,!0,E.toString(r))}lt(t,r){return this.setLimit("max",t,!1,E.toString(r))}setLimit(t,r,n,o){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:E.toString(o)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:E.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:E.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:E.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:E.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:E.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:E.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:E.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:E.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:E.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&X.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};$n.create=e=>new $n({checks:[],typeName:N.ZodNumber,coerce:e?.coerce||!1,...L(e)});var bn=class e extends W{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==w.bigint)return this._getInvalidInput(t);let n,o=new ze;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(n=this._getOrReturnCtx(t,n),b(n,{code:_.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(n=this._getOrReturnCtx(t,n),b(n,{code:_.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),b(n,{code:_.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):X.assertNever(i);return{status:o.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return b(r,{code:_.invalid_type,expected:w.bigint,received:r.parsedType}),Z}gte(t,r){return this.setLimit("min",t,!0,E.toString(r))}gt(t,r){return this.setLimit("min",t,!1,E.toString(r))}lte(t,r){return this.setLimit("max",t,!0,E.toString(r))}lt(t,r){return this.setLimit("max",t,!1,E.toString(r))}setLimit(t,r,n,o){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:E.toString(o)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:E.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:E.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:E.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:E.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:E.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};bn.create=e=>new bn({checks:[],typeName:N.ZodBigInt,coerce:e?.coerce??!1,...L(e)});var xn=class extends W{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==w.boolean){let n=this._getOrReturnCtx(t);return b(n,{code:_.invalid_type,expected:w.boolean,received:n.parsedType}),Z}return je(t.data)}};xn.create=e=>new xn({typeName:N.ZodBoolean,coerce:e?.coerce||!1,...L(e)});var kn=class e extends W{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==w.date){let i=this._getOrReturnCtx(t);return b(i,{code:_.invalid_type,expected:w.date,received:i.parsedType}),Z}if(Number.isNaN(t.data.getTime())){let i=this._getOrReturnCtx(t);return b(i,{code:_.invalid_date}),Z}let n=new ze,o;for(let i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(o=this._getOrReturnCtx(t,o),b(o,{code:_.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(o=this._getOrReturnCtx(t,o),b(o,{code:_.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):X.assertNever(i);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:E.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:E.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};kn.create=e=>new kn({checks:[],coerce:e?.coerce||!1,typeName:N.ZodDate,...L(e)});var Sn=class extends W{_parse(t){if(this._getType(t)!==w.symbol){let n=this._getOrReturnCtx(t);return b(n,{code:_.invalid_type,expected:w.symbol,received:n.parsedType}),Z}return je(t.data)}};Sn.create=e=>new Sn({typeName:N.ZodSymbol,...L(e)});var Tr=class extends W{_parse(t){if(this._getType(t)!==w.undefined){let n=this._getOrReturnCtx(t);return b(n,{code:_.invalid_type,expected:w.undefined,received:n.parsedType}),Z}return je(t.data)}};Tr.create=e=>new Tr({typeName:N.ZodUndefined,...L(e)});var Pr=class extends W{_parse(t){if(this._getType(t)!==w.null){let n=this._getOrReturnCtx(t);return b(n,{code:_.invalid_type,expected:w.null,received:n.parsedType}),Z}return je(t.data)}};Pr.create=e=>new Pr({typeName:N.ZodNull,...L(e)});var wn=class extends W{constructor(){super(...arguments),this._any=!0}_parse(t){return je(t.data)}};wn.create=e=>new wn({typeName:N.ZodAny,...L(e)});var Lt=class extends W{constructor(){super(...arguments),this._unknown=!0}_parse(t){return je(t.data)}};Lt.create=e=>new Lt({typeName:N.ZodUnknown,...L(e)});var gt=class extends W{_parse(t){let r=this._getOrReturnCtx(t);return b(r,{code:_.invalid_type,expected:w.never,received:r.parsedType}),Z}};gt.create=e=>new gt({typeName:N.ZodNever,...L(e)});var zn=class extends W{_parse(t){if(this._getType(t)!==w.undefined){let n=this._getOrReturnCtx(t);return b(n,{code:_.invalid_type,expected:w.void,received:n.parsedType}),Z}return je(t.data)}};zn.create=e=>new zn({typeName:N.ZodVoid,...L(e)});var qt=class e extends W{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),o=this._def;if(r.parsedType!==w.array)return b(r,{code:_.invalid_type,expected:w.array,received:r.parsedType}),Z;if(o.exactLength!==null){let a=r.data.length>o.exactLength.value,s=r.data.length<o.exactLength.value;(a||s)&&(b(r,{code:a?_.too_big:_.too_small,minimum:s?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(b(r,{code:_.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(b(r,{code:_.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,s)=>o.type._parseAsync(new Be(r,a,r.path,s)))).then(a=>ze.mergeArray(n,a));let i=[...r.data].map((a,s)=>o.type._parseSync(new Be(r,a,r.path,s)));return ze.mergeArray(n,i)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:E.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:E.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:E.toString(r)}})}nonempty(t){return this.min(1,t)}};qt.create=(e,t)=>new qt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:N.ZodArray,...L(t)});function Ir(e){if(e instanceof Je){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=ct.create(Ir(n))}return new Je({...e._def,shape:()=>t})}else return e instanceof qt?new qt({...e._def,type:Ir(e.element)}):e instanceof ct?ct.create(Ir(e.unwrap())):e instanceof Et?Et.create(Ir(e.unwrap())):e instanceof It?It.create(e.items.map(t=>Ir(t))):e}var Je=class e extends W{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=X.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==w.object){let u=this._getOrReturnCtx(t);return b(u,{code:_.invalid_type,expected:w.object,received:u.parsedType}),Z}let{status:n,ctx:o}=this._processInputParams(t),{shape:i,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof gt&&this._def.unknownKeys==="strip"))for(let u in o.data)a.includes(u)||s.push(u);let c=[];for(let u of a){let l=i[u],d=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Be(o,d,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof gt){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of s)c.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")s.length>0&&(b(o,{code:_.unrecognized_keys,keys:s}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of s){let d=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Be(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,m=await l.value;u.push({key:d,value:m,alwaysSet:l.alwaysSet})}return u}).then(u=>ze.mergeObjectSync(n,u)):ze.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(t){return E.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:E.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:N.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of X.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of X.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return Ir(this)}partial(t){let r={};for(let n of X.objectKeys(this.shape)){let o=this.shape[n];t&&!t[n]?r[n]=o:r[n]=o.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of X.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof ct;)i=i._def.innerType;r[n]=i}return new e({...this._def,shape:()=>r})}keyof(){return xf(X.objectKeys(this.shape))}};Je.create=(e,t)=>new Je({shape:()=>e,unknownKeys:"strip",catchall:gt.create(),typeName:N.ZodObject,...L(t)});Je.strictCreate=(e,t)=>new Je({shape:()=>e,unknownKeys:"strict",catchall:gt.create(),typeName:N.ZodObject,...L(t)});Je.lazycreate=(e,t)=>new Je({shape:e,unknownKeys:"strip",catchall:gt.create(),typeName:N.ZodObject,...L(t)});var Or=class extends W{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function o(i){for(let s of i)if(s.result.status==="valid")return s.result;for(let s of i)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(s=>new Ve(s.ctx.common.issues));return b(r,{code:_.invalid_union,unionErrors:a}),Z}if(r.common.async)return Promise.all(n.map(async i=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(o);{let i,a=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let s=a.map(c=>new Ve(c));return b(r,{code:_.invalid_union,unionErrors:s}),Z}}get options(){return this._def.options}};Or.create=(e,t)=>new Or({options:e,typeName:N.ZodUnion,...L(t)});var zt=e=>e instanceof Nr?zt(e.schema):e instanceof ut?zt(e.innerType()):e instanceof Dr?[e.value]:e instanceof Rr?e.options:e instanceof Zr?X.objectValues(e.enum):e instanceof Ar?zt(e._def.innerType):e instanceof Tr?[void 0]:e instanceof Pr?[null]:e instanceof ct?[void 0,...zt(e.unwrap())]:e instanceof Et?[null,...zt(e.unwrap())]:e instanceof ai||e instanceof Cr?zt(e.unwrap()):e instanceof Ur?zt(e._def.innerType):[],Is=class e extends W{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==w.object)return b(r,{code:_.invalid_type,expected:w.object,received:r.parsedType}),Z;let n=this.discriminator,o=r.data[n],i=this.optionsMap.get(o);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(b(r,{code:_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Z)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let o=new Map;for(let i of r){let a=zt(i.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of a){if(o.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);o.set(s,i)}}return new e({typeName:N.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:o,...L(n)})}};function Es(e,t){let r=wt(e),n=wt(t);if(e===t)return{valid:!0,data:e};if(r===w.object&&n===w.object){let o=X.objectKeys(t),i=X.objectKeys(e).filter(s=>o.indexOf(s)!==-1),a={...e,...t};for(let s of i){let c=Es(e[s],t[s]);if(!c.valid)return{valid:!1};a[s]=c.data}return{valid:!0,data:a}}else if(r===w.array&&n===w.array){if(e.length!==t.length)return{valid:!1};let o=[];for(let i=0;i<e.length;i++){let a=e[i],s=t[i],c=Es(a,s);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===w.date&&n===w.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var jr=class extends W{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),o=(i,a)=>{if(Ss(i)||Ss(a))return Z;let s=Es(i.value,a.value);return s.valid?((ws(i)||ws(a))&&r.dirty(),{status:r.value,value:s.data}):(b(n,{code:_.invalid_intersection_types}),Z)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>o(i,a)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};jr.create=(e,t,r)=>new jr({left:e,right:t,typeName:N.ZodIntersection,...L(r)});var It=class e extends W{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==w.array)return b(n,{code:_.invalid_type,expected:w.array,received:n.parsedType}),Z;if(n.data.length<this._def.items.length)return b(n,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Z;!this._def.rest&&n.data.length>this._def.items.length&&(b(n,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((a,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new Be(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>ze.mergeArray(r,a)):ze.mergeArray(r,i)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};It.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new It({items:e,typeName:N.ZodTuple,rest:null,...L(t)})};var Ts=class e extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==w.object)return b(n,{code:_.invalid_type,expected:w.object,received:n.parsedType}),Z;let o=[],i=this._def.keyType,a=this._def.valueType;for(let s in n.data)o.push({key:i._parse(new Be(n,s,n.path,s)),value:a._parse(new Be(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?ze.mergeObjectAsync(r,o):ze.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof W?new e({keyType:t,valueType:r,typeName:N.ZodRecord,...L(n)}):new e({keyType:Er.create(),valueType:t,typeName:N.ZodRecord,...L(r)})}},In=class extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==w.map)return b(n,{code:_.invalid_type,expected:w.map,received:n.parsedType}),Z;let o=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([s,c],u)=>({key:o._parse(new Be(n,s,n.path,[u,"key"])),value:i._parse(new Be(n,c,n.path,[u,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of a){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return Z;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let c of a){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return Z;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}}}};In.create=(e,t,r)=>new In({valueType:t,keyType:e,typeName:N.ZodMap,...L(r)});var En=class e extends W{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==w.set)return b(n,{code:_.invalid_type,expected:w.set,received:n.parsedType}),Z;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(b(n,{code:_.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(b(n,{code:_.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let i=this._def.valueType;function a(c){let u=new Set;for(let l of c){if(l.status==="aborted")return Z;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let s=[...n.data.values()].map((c,u)=>i._parse(new Be(n,c,n.path,u)));return n.common.async?Promise.all(s).then(c=>a(c)):a(s)}min(t,r){return new e({...this._def,minSize:{value:t,message:E.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:E.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};En.create=(e,t)=>new En({valueType:e,minSize:null,maxSize:null,typeName:N.ZodSet,...L(t)});var Ps=class e extends W{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==w.function)return b(r,{code:_.invalid_type,expected:w.function,received:r.parsedType}),Z;function n(s,c){return ii({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,_n(),Mt].filter(u=>!!u),issueData:{code:_.invalid_arguments,argumentsError:c}})}function o(s,c){return ii({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,_n(),Mt].filter(u=>!!u),issueData:{code:_.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof ar){let s=this;return je(async function(...c){let u=new Ve([]),l=await s._def.args.parseAsync(c,i).catch(f=>{throw u.addIssue(n(c,f)),u}),d=await Reflect.apply(a,this,l);return await s._def.returns._def.type.parseAsync(d,i).catch(f=>{throw u.addIssue(o(d,f)),u})})}else{let s=this;return je(function(...c){let u=s._def.args.safeParse(c,i);if(!u.success)throw new Ve([n(c,u.error)]);let l=Reflect.apply(a,this,u.data),d=s._def.returns.safeParse(l,i);if(!d.success)throw new Ve([o(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:It.create(t).rest(Lt.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||It.create([]).rest(Lt.create()),returns:r||Lt.create(),typeName:N.ZodFunction,...L(n)})}},Nr=class extends W{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Nr.create=(e,t)=>new Nr({getter:e,typeName:N.ZodLazy,...L(t)});var Dr=class extends W{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return b(r,{received:r.data,code:_.invalid_literal,expected:this._def.value}),Z}return{status:"valid",value:t.data}}get value(){return this._def.value}};Dr.create=(e,t)=>new Dr({value:e,typeName:N.ZodLiteral,...L(t)});function xf(e,t){return new Rr({values:e,typeName:N.ZodEnum,...L(t)})}var Rr=class e extends W{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return b(r,{expected:X.joinValues(n),received:r.parsedType,code:_.invalid_type}),Z}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return b(r,{received:r.data,code:_.invalid_enum_value,options:n}),Z}return je(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};Rr.create=xf;var Zr=class extends W{_parse(t){let r=X.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==w.string&&n.parsedType!==w.number){let o=X.objectValues(r);return b(n,{expected:X.joinValues(o),received:n.parsedType,code:_.invalid_type}),Z}if(this._cache||(this._cache=new Set(X.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let o=X.objectValues(r);return b(n,{received:n.data,code:_.invalid_enum_value,options:o}),Z}return je(t.data)}get enum(){return this._def.values}};Zr.create=(e,t)=>new Zr({values:e,typeName:N.ZodNativeEnum,...L(t)});var ar=class extends W{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==w.promise&&r.common.async===!1)return b(r,{code:_.invalid_type,expected:w.promise,received:r.parsedType}),Z;let n=r.parsedType===w.promise?r.data:Promise.resolve(r.data);return je(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};ar.create=(e,t)=>new ar({type:e,typeName:N.ZodPromise,...L(t)});var ut=class extends W{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===N.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),o=this._def.effect||null,i={addIssue:a=>{b(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),o.type==="preprocess"){let a=o.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async s=>{if(r.value==="aborted")return Z;let c=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return c.status==="aborted"?Z:c.status==="dirty"?zr(c.value):r.value==="dirty"?zr(c.value):c});{if(r.value==="aborted")return Z;let s=this._def.schema._parseSync({data:a,path:n.path,parent:n});return s.status==="aborted"?Z:s.status==="dirty"?zr(s.value):r.value==="dirty"?zr(s.value):s}}if(o.type==="refinement"){let a=s=>{let c=o.refinement(s,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?Z:(s.status==="dirty"&&r.dirty(),a(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?Z:(s.status==="dirty"&&r.dirty(),a(s.value).then(()=>({status:r.value,value:s.value}))))}if(o.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ir(a))return Z;let s=o.transform(a.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>ir(a)?Promise.resolve(o.transform(a.value,i)).then(s=>({status:r.value,value:s})):Z);X.assertNever(o)}};ut.create=(e,t,r)=>new ut({schema:e,typeName:N.ZodEffects,effect:t,...L(r)});ut.createWithPreprocess=(e,t,r)=>new ut({schema:t,effect:{type:"preprocess",transform:e},typeName:N.ZodEffects,...L(r)});var ct=class extends W{_parse(t){return this._getType(t)===w.undefined?je(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};ct.create=(e,t)=>new ct({innerType:e,typeName:N.ZodOptional,...L(t)});var Et=class extends W{_parse(t){return this._getType(t)===w.null?je(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Et.create=(e,t)=>new Et({innerType:e,typeName:N.ZodNullable,...L(t)});var Ar=class extends W{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===w.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Ar.create=(e,t)=>new Ar({innerType:e,typeName:N.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...L(t)});var Ur=class extends W{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return yn(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ve(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ve(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Ur.create=(e,t)=>new Ur({innerType:e,typeName:N.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...L(t)});var Tn=class extends W{_parse(t){if(this._getType(t)!==w.nan){let n=this._getOrReturnCtx(t);return b(n,{code:_.invalid_type,expected:w.nan,received:n.parsedType}),Z}return{status:"valid",value:t.data}}};Tn.create=e=>new Tn({typeName:N.ZodNaN,...L(e)});var ai=class extends W{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},si=class e extends W{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Z:i.status==="dirty"?(r.dirty(),zr(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Z:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:N.ZodPipeline})}},Cr=class extends W{_parse(t){let r=this._def.innerType._parse(t),n=o=>(ir(o)&&(o.value=Object.freeze(o.value)),o);return yn(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};Cr.create=(e,t)=>new Cr({innerType:e,typeName:N.ZodReadonly,...L(t)});var HT={object:Je.lazycreate},N;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(N||(N={}));var BT=Er.create,XT=$n.create,YT=Tn.create,QT=bn.create,eP=xn.create,tP=kn.create,rP=Sn.create,nP=Tr.create,oP=Pr.create,iP=wn.create,aP=Lt.create,sP=gt.create,cP=zn.create,uP=qt.create,s$=Je.create,lP=Je.strictCreate,dP=Or.create,pP=Is.create,fP=jr.create,mP=It.create,hP=Ts.create,gP=In.create,vP=En.create,_P=Ps.create,yP=Nr.create,$P=Dr.create,bP=Rr.create,xP=Zr.create,kP=ar.create,SP=ut.create,wP=ct.create,zP=Et.create,IP=ut.createWithPreprocess,EP=si.create;var kf=Object.freeze({status:"aborted"});function p(e,t,r){function n(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);let u=a.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let m=l[d];m in s||(s[m]=u[m].bind(s))}}let o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(s){var c;let u=r?.Parent?new i:this;n(u,s),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var vt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},sr=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},ci={};function ye(e){return e&&Object.assign(ci,e),ci}var y={};vn(y,{BIGINT_FORMAT_RANGES:()=>Cs,Class:()=>js,NUMBER_FORMAT_RANGES:()=>Us,aborted:()=>Kt,allowsEval:()=>Rs,assert:()=>m$,assertEqual:()=>l$,assertIs:()=>p$,assertNever:()=>f$,assertNotEqual:()=>d$,assignProp:()=>Vt,base64ToUint8Array:()=>zf,base64urlToUint8Array:()=>O$,cached:()=>Lr,captureStackTrace:()=>li,cleanEnum:()=>P$,cleanRegex:()=>jn,clone:()=>Ne,cloneDef:()=>g$,createTransparentProxy:()=>x$,defineLazy:()=>V,esc:()=>ui,escapeRegex:()=>Xe,extend:()=>w$,finalizeIssue:()=>Ce,floatSafeRemainder:()=>Ns,getElementAtPath:()=>v$,getEnumValues:()=>On,getLengthableOrigin:()=>Rn,getParsedType:()=>b$,getSizableOrigin:()=>Dn,hexToUint8Array:()=>N$,isObject:()=>cr,isPlainObject:()=>Jt,issue:()=>qr,joinValues:()=>D,jsonStringifyReplacer:()=>Mr,merge:()=>I$,mergeDefs:()=>Tt,normalizeParams:()=>k,nullish:()=>Ft,numKeys:()=>$$,objectClone:()=>h$,omit:()=>S$,optionalKeys:()=>As,parsedType:()=>A,partial:()=>E$,pick:()=>k$,prefixIssues:()=>Ke,primitiveTypes:()=>Zs,promiseAllObject:()=>_$,propertyKeyTypes:()=>Nn,randomString:()=>y$,required:()=>T$,safeExtend:()=>z$,shallowClone:()=>wf,slugify:()=>Ds,stringifyPrimitive:()=>R,uint8ArrayToBase64:()=>If,uint8ArrayToBase64url:()=>j$,uint8ArrayToHex:()=>D$,unwrapMessage:()=>Pn});function l$(e){return e}function d$(e){return e}function p$(e){}function f$(e){throw new Error("Unexpected value in exhaustive check")}function m$(e){}function On(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function D(e,t="|"){return e.map(r=>R(r)).join(t)}function Mr(e,t){return typeof t=="bigint"?t.toString():t}function Lr(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Ft(e){return e==null}function jn(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Ns(e,t){let r=(e.toString().split(".")[1]||"").length,n=t.toString(),o=(n.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(n)){let c=n.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}let i=r>o?r:o,a=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return a%s/10**i}var Sf=Symbol("evaluating");function V(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Sf)return n===void 0&&(n=Sf,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function h$(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Vt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Tt(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function g$(e){return Tt(e._zod.def)}function v$(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function _$(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[i];return o})}function y$(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function ui(e){return JSON.stringify(e)}function Ds(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var li="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function cr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Rs=Lr(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Jt(e){if(cr(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(cr(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function wf(e){return Jt(e)?{...e}:Array.isArray(e)?[...e]:e}function $$(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var b$=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Nn=new Set(["string","number","symbol"]),Zs=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Xe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ne(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function k(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function x$(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,i){return t??(t=e()),Reflect.set(t,n,o,i)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function R(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function As(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Us={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Cs={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function k$(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=Tt(e._zod.def,{get shape(){let a={};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(a[s]=r.shape[s])}return Vt(this,"shape",a),a},checks:[]});return Ne(e,i)}function S$(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=Tt(e._zod.def,{get shape(){let a={...e._zod.def.shape};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete a[s]}return Vt(this,"shape",a),a},checks:[]});return Ne(e,i)}function w$(e,t){if(!Jt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let i=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=Tt(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Vt(this,"shape",i),i}});return Ne(e,o)}function z$(e,t){if(!Jt(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=Tt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Vt(this,"shape",n),n}});return Ne(e,r)}function I$(e,t){let r=Tt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Vt(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return Ne(e,r)}function E$(e,t,r){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let a=Tt(t._zod.def,{get shape(){let s=t._zod.def.shape,c={...s};if(r)for(let u in r){if(!(u in s))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:s[u]}):s[u])}else for(let u in s)c[u]=e?new e({type:"optional",innerType:s[u]}):s[u];return Vt(this,"shape",c),c},checks:[]});return Ne(t,a)}function T$(e,t,r){let n=Tt(t._zod.def,{get shape(){let o=t._zod.def.shape,i={...o};if(r)for(let a in r){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=new e({type:"nonoptional",innerType:o[a]}))}else for(let a in o)i[a]=new e({type:"nonoptional",innerType:o[a]});return Vt(this,"shape",i),i}});return Ne(t,n)}function Kt(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Ke(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Pn(e){return typeof e=="string"?e:e?.message}function Ce(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let o=Pn(e.inst?._zod.def?.error?.(e))??Pn(t?.error?.(e))??Pn(r.customError?.(e))??Pn(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function Dn(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Rn(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function A(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function qr(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function P$(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function zf(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function If(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function O$(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return zf(t+r)}function j$(e){return If(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function N$(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function D$(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var js=class{constructor(...t){}};var Ef=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Mr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},di=p("$ZodError",Ef),Zn=p("$ZodError",Ef,{Parent:Error});function pi(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function fi(e,t=r=>r.message){let r={_errors:[]},n=o=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)r._errors.push(t(i));else{let a=r,s=0;for(;s<i.path.length;){let c=i.path[s];s===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(i))):a[c]=a[c]||{_errors:[]},a=a[c],s++}}};return n(e),r}var An=e=>(t,r,n,o)=>{let i=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new vt;if(a.issues.length){let s=new(o?.Err??e)(a.issues.map(c=>Ce(c,i,ye())));throw li(s,o?.callee),s}return a.value},Un=An(Zn),Cn=e=>async(t,r,n,o)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let s=new(o?.Err??e)(a.issues.map(c=>Ce(c,i,ye())));throw li(s,o?.callee),s}return a.value},Mn=Cn(Zn),Ln=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new vt;return i.issues.length?{success:!1,error:new(e??di)(i.issues.map(a=>Ce(a,o,ye())))}:{success:!0,data:i.value}},Fr=Ln(Zn),qn=e=>async(t,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>Ce(a,o,ye())))}:{success:!0,data:i.value}},Fn=qn(Zn),Tf=e=>(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return An(e)(t,r,o)};var Pf=e=>(t,r,n)=>An(e)(t,r,n);var Of=e=>async(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Cn(e)(t,r,o)};var jf=e=>async(t,r,n)=>Cn(e)(t,r,n);var Nf=e=>(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ln(e)(t,r,o)};var Df=e=>(t,r,n)=>Ln(e)(t,r,n);var Rf=e=>async(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return qn(e)(t,r,o)};var Zf=e=>async(t,r,n)=>qn(e)(t,r,n);var Ye={};vn(Ye,{base64:()=>tc,base64url:()=>mi,bigint:()=>sc,boolean:()=>uc,browserEmail:()=>F$,cidrv4:()=>Qs,cidrv6:()=>ec,cuid:()=>Ms,cuid2:()=>Ls,date:()=>nc,datetime:()=>ic,domain:()=>K$,duration:()=>Ks,e164:()=>rc,email:()=>Gs,emoji:()=>Hs,extendedDuration:()=>Z$,guid:()=>Ws,hex:()=>W$,hostname:()=>J$,html5Email:()=>M$,idnEmail:()=>q$,integer:()=>cc,ipv4:()=>Bs,ipv6:()=>Xs,ksuid:()=>Vs,lowercase:()=>pc,mac:()=>Ys,md5_base64:()=>H$,md5_base64url:()=>B$,md5_hex:()=>G$,nanoid:()=>Js,null:()=>lc,number:()=>hi,rfc5322Email:()=>L$,sha1_base64:()=>Y$,sha1_base64url:()=>Q$,sha1_hex:()=>X$,sha256_base64:()=>tb,sha256_base64url:()=>rb,sha256_hex:()=>eb,sha384_base64:()=>ob,sha384_base64url:()=>ib,sha384_hex:()=>nb,sha512_base64:()=>sb,sha512_base64url:()=>cb,sha512_hex:()=>ab,string:()=>ac,time:()=>oc,ulid:()=>qs,undefined:()=>dc,unicodeEmail:()=>Af,uppercase:()=>fc,uuid:()=>ur,uuid4:()=>A$,uuid6:()=>U$,uuid7:()=>C$,xid:()=>Fs});var Ms=/^[cC][^\s-]{8,}$/,Ls=/^[0-9a-z]+$/,qs=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Fs=/^[0-9a-vA-V]{20}$/,Vs=/^[A-Za-z0-9]{27}$/,Js=/^[a-zA-Z0-9_-]{21}$/,Ks=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Z$=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ws=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ur=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,A$=ur(4),U$=ur(6),C$=ur(7),Gs=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,M$=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,L$=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,Af=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,q$=Af,F$=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,V$="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Hs(){return new RegExp(V$,"u")}var Bs=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Xs=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Ys=e=>{let t=Xe(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Qs=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ec=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,tc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,mi=/^[A-Za-z0-9_-]*$/,J$=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,K$=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,rc=/^\+[1-9]\d{6,14}$/,Uf="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",nc=new RegExp(`^${Uf}$`);function Cf(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function oc(e){return new RegExp(`^${Cf(e)}$`)}function ic(e){let t=Cf({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Uf}T(?:${n})$`)}var ac=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},sc=/^-?\d+n?$/,cc=/^-?\d+$/,hi=/^-?\d+(?:\.\d+)?$/,uc=/^(?:true|false)$/i,lc=/^null$/i;var dc=/^undefined$/i;var pc=/^[^A-Z]*$/,fc=/^[^a-z]*$/,W$=/^[0-9a-fA-F]*$/;function Vn(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Jn(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var G$=/^[0-9a-fA-F]{32}$/,H$=Vn(22,"=="),B$=Jn(22),X$=/^[0-9a-fA-F]{40}$/,Y$=Vn(27,"="),Q$=Jn(27),eb=/^[0-9a-fA-F]{64}$/,tb=Vn(43,"="),rb=Jn(43),nb=/^[0-9a-fA-F]{96}$/,ob=Vn(64,""),ib=Jn(64),ab=/^[0-9a-fA-F]{128}$/,sb=Vn(86,"=="),cb=Jn(86);var se=p("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Lf={number:"number",bigint:"bigint",object:"date"},mc=p("$ZodCheckLessThan",(e,t)=>{se.init(e,t);let r=Lf[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hc=p("$ZodCheckGreaterThan",(e,t)=>{se.init(e,t);let r=Lf[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),qf=p("$ZodCheckMultipleOf",(e,t)=>{se.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Ns(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Ff=p("$ZodCheckNumberFormat",(e,t)=>{se.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,i]=Us[t.format];e._zod.onattach.push(a=>{let s=a._zod.bag;s.format=t.format,s.minimum=o,s.maximum=i,r&&(s.pattern=cc)}),e._zod.check=a=>{let s=a.value;if(r){if(!Number.isInteger(s)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}s<o&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Vf=p("$ZodCheckBigIntFormat",(e,t)=>{se.init(e,t);let[r,n]=Cs[t.format];e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,i.minimum=r,i.maximum=n}),e._zod.check=o=>{let i=o.value;i<r&&o.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),i>n&&o.issues.push({origin:"bigint",input:i,code:"too_big",maximum:n,inclusive:!0,inst:e,continue:!t.abort})}}),Jf=p("$ZodCheckMaxSize",(e,t)=>{var r;se.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Ft(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;o.size<=t.maximum||n.issues.push({origin:Dn(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Kf=p("$ZodCheckMinSize",(e,t)=>{var r;se.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Ft(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;o.size>=t.minimum||n.issues.push({origin:Dn(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Wf=p("$ZodCheckSizeEquals",(e,t)=>{var r;se.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Ft(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.size,o.maximum=t.size,o.size=t.size}),e._zod.check=n=>{let o=n.value,i=o.size;if(i===t.size)return;let a=i>t.size;n.issues.push({origin:Dn(o),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Gf=p("$ZodCheckMaxLength",(e,t)=>{var r;se.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Ft(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;if(o.length<=t.maximum)return;let a=Rn(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Hf=p("$ZodCheckMinLength",(e,t)=>{var r;se.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Ft(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;if(o.length>=t.minimum)return;let a=Rn(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Bf=p("$ZodCheckLengthEquals",(e,t)=>{var r;se.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Ft(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{let o=n.value,i=o.length;if(i===t.length)return;let a=Rn(o),s=i>t.length;n.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Kn=p("$ZodCheckStringFormat",(e,t)=>{var r,n;se.init(e,t),e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Xf=p("$ZodCheckRegex",(e,t)=>{Kn.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Yf=p("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=pc),Kn.init(e,t)}),Qf=p("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=fc),Kn.init(e,t)}),em=p("$ZodCheckIncludes",(e,t)=>{se.init(e,t);let r=Xe(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{let i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),tm=p("$ZodCheckStartsWith",(e,t)=>{se.init(e,t);let r=new RegExp(`^${Xe(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),rm=p("$ZodCheckEndsWith",(e,t)=>{se.init(e,t);let r=new RegExp(`.*${Xe(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});function Mf(e,t,r){e.issues.length&&t.issues.push(...Ke(r,e.issues))}var nm=p("$ZodCheckProperty",(e,t)=>{se.init(e,t),e._zod.check=r=>{let n=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(o=>Mf(o,r,t.property));Mf(n,r,t.property)}}),om=p("$ZodCheckMimeType",(e,t)=>{se.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(n=>{n._zod.bag.mime=t.mime}),e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}}),im=p("$ZodCheckOverwrite",(e,t)=>{se.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var gi=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
`).filter(a=>a),o=Math.min(...n.map(a=>a.length-a.trimStart().length)),i=n.map(a=>a.slice(o)).map(a=>" ".repeat(this.indent*2)+a);for(let a of i)this.content.push(a)}compile(){let t=Function,r=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...r,o.join(`
`))}};var sm={major:4,minor:3,patch:4};var M=p("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=sm;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(a,s,c)=>{let u=Kt(a),l;for(let d of s){if(d._zod.def.when){if(!d._zod.def.when(a))continue}else if(u)continue;let m=a.issues.length,f=d._zod.check(a);if(f instanceof Promise&&c?.async===!1)throw new vt;if(l||f instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await f,a.issues.length!==m&&(u||(u=Kt(a,m)))});else{if(a.issues.length===m)continue;u||(u=Kt(a,m))}}return l?l.then(()=>a):a},i=(a,s,c)=>{if(Kt(a))return a.aborted=!0,a;let u=o(s,n,c);if(u instanceof Promise){if(c.async===!1)throw new vt;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(l=>i(l,a,s)):i(u,a,s)}let c=e._zod.parse(a,s);if(c instanceof Promise){if(s.async===!1)throw new vt;return c.then(u=>o(u,n,s))}return o(c,n,s)}}V(e,"~standard",()=>({validate:o=>{try{let i=Fr(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return Fn(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),lr=p("$ZodString",(e,t)=>{M.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ac(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),oe=p("$ZodStringFormat",(e,t)=>{Kn.init(e,t),lr.init(e,t)}),vc=p("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ws),oe.init(e,t)}),_c=p("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ur(n))}else t.pattern??(t.pattern=ur());oe.init(e,t)}),yc=p("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Gs),oe.init(e,t)}),$c=p("$ZodURL",(e,t)=>{oe.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),bc=p("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Hs()),oe.init(e,t)}),xc=p("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Js),oe.init(e,t)}),kc=p("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Ms),oe.init(e,t)}),Sc=p("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ls),oe.init(e,t)}),wc=p("$ZodULID",(e,t)=>{t.pattern??(t.pattern=qs),oe.init(e,t)}),zc=p("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Fs),oe.init(e,t)}),Ic=p("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Vs),oe.init(e,t)}),Ec=p("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ic(t)),oe.init(e,t)}),Tc=p("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=nc),oe.init(e,t)}),Pc=p("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=oc(t)),oe.init(e,t)}),Oc=p("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ks),oe.init(e,t)}),jc=p("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Bs),oe.init(e,t),e._zod.bag.format="ipv4"}),Nc=p("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Xs),oe.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Dc=p("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=Ys(t.delimiter)),oe.init(e,t),e._zod.bag.format="mac"}),Rc=p("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Qs),oe.init(e,t)}),Zc=p("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ec),oe.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[o,i]=n;if(!i)throw new Error;let a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function ym(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ac=p("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=tc),oe.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{ym(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function ub(e){if(!mi.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return ym(r)}var Uc=p("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=mi),oe.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{ub(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Cc=p("$ZodE164",(e,t)=>{t.pattern??(t.pattern=rc),oe.init(e,t)});function lb(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var Mc=p("$ZodJWT",(e,t)=>{oe.init(e,t),e._zod.check=r=>{lb(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Lc=p("$ZodCustomStringFormat",(e,t)=>{oe.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),xi=p("$ZodNumber",(e,t)=>{M.init(e,t),e._zod.pattern=e._zod.bag.pattern??hi,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),qc=p("$ZodNumberFormat",(e,t)=>{Ff.init(e,t),xi.init(e,t)}),Wn=p("$ZodBoolean",(e,t)=>{M.init(e,t),e._zod.pattern=uc,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),ki=p("$ZodBigInt",(e,t)=>{M.init(e,t),e._zod.pattern=sc,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),Fc=p("$ZodBigIntFormat",(e,t)=>{Vf.init(e,t),ki.init(e,t)}),Vc=p("$ZodSymbol",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return typeof o=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:o,inst:e}),r}}),Jc=p("$ZodUndefined",(e,t)=>{M.init(e,t),e._zod.pattern=dc,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(r,n)=>{let o=r.value;return typeof o>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),r}}),Kc=p("$ZodNull",(e,t)=>{M.init(e,t),e._zod.pattern=lc,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}}),Wc=p("$ZodAny",(e,t)=>{M.init(e,t),e._zod.parse=r=>r}),Gc=p("$ZodUnknown",(e,t)=>{M.init(e,t),e._zod.parse=r=>r}),Hc=p("$ZodNever",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),Bc=p("$ZodVoid",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return typeof o>"u"||r.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),r}}),Xc=p("$ZodDate",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let o=r.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),r}});function cm(e,t,r){e.issues.length&&t.issues.push(...Ke(r,e.issues)),t.value[r]=e.value}var Yc=p("$ZodArray",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let i=[];for(let a=0;a<o.length;a++){let s=o[a],c=t.element._zod.run({value:s,issues:[]},n);c instanceof Promise?i.push(c.then(u=>cm(u,r,a))):cm(c,r,a)}return i.length?Promise.all(i).then(()=>r):r}});function bi(e,t,r,n,o){if(e.issues.length){if(o&&!(r in n))return;t.issues.push(...Ke(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function $m(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=As(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function bm(e,t,r,n,o,i){let a=[],s=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optout==="optional";for(let d in t){if(s.has(d))continue;if(u==="never"){a.push(d);continue}let m=c.run({value:t[d],issues:[]},n);m instanceof Promise?e.push(m.then(f=>bi(f,r,d,t,l))):bi(m,r,d,t,l)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}var xm=p("$ZodObject",(e,t)=>{if(M.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let s=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...s};return Object.defineProperty(t,"shape",{value:c}),c}})}let n=Lr(()=>$m(t));V(e._zod,"propValues",()=>{let s=t.shape,c={};for(let u in s){let l=s[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let d of l.values)c[u].add(d)}}return c});let o=cr,i=t.catchall,a;e._zod.parse=(s,c)=>{a??(a=n.value);let u=s.value;if(!o(u))return s.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),s;s.value={};let l=[],d=a.shape;for(let m of a.keys){let f=d[m],g=f._zod.optout==="optional",v=f._zod.run({value:u[m],issues:[]},c);v instanceof Promise?l.push(v.then($=>bi($,s,m,u,g))):bi(v,s,m,u,g)}return i?bm(l,u,s,c,n.value,e):l.length?Promise.all(l).then(()=>s):s}}),km=p("$ZodObjectJIT",(e,t)=>{xm.init(e,t);let r=e._zod.parse,n=Lr(()=>$m(t)),o=m=>{let f=new gi(["shape","payload","ctx"]),g=n.value,v=I=>{let U=ui(I);return`shape[${U}]._zod.run({ value: input[${U}], issues: [] }, ctx)`};f.write("const input = payload.value;");let $=Object.create(null),x=0;for(let I of g.keys)$[I]=`key_${x++}`;f.write("const newResult = {};");for(let I of g.keys){let U=$[I],j=ui(I),at=m[I]?._zod?.optout==="optional";f.write(`const ${U} = ${v(I)};`),at?f.write(`
if (${U}.issues.length) {
if (${j} in input) {
payload.issues = payload.issues.concat(${U}.issues.map(iss => ({
...iss,
path: iss.path ? [${j}, ...iss.path] : [${j}]
})));
}
}
if (${U}.value === undefined) {
if (${j} in input) {
newResult[${j}] = undefined;
}
} else {
newResult[${j}] = ${U}.value;
}
`):f.write(`
if (${U}.issues.length) {
payload.issues = payload.issues.concat(${U}.issues.map(iss => ({
...iss,
path: iss.path ? [${j}, ...iss.path] : [${j}]
})));
}
if (${U}.value === undefined) {
if (${j} in input) {
newResult[${j}] = undefined;
}
} else {
newResult[${j}] = ${U}.value;
}
`)}f.write("payload.value = newResult;"),f.write("return payload;");let O=f.compile();return(I,U)=>O(m,I,U)},i,a=cr,s=!ci.jitless,u=s&&Rs.value,l=t.catchall,d;e._zod.parse=(m,f)=>{d??(d=n.value);let g=m.value;return a(g)?s&&u&&f?.async===!1&&f.jitless!==!0?(i||(i=o(t.shape)),m=i(m,f),l?bm([],g,m,f,d,e):m):r(m,f):(m.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),m)}});function um(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!Kt(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(a=>Ce(a,n,ye())))}),t)}var Gn=p("$ZodUnion",(e,t)=>{M.init(e,t),V(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),V(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),V(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),V(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){let o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>jn(i.source)).join("|")})$`)}});let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(r)return n(o,i);let a=!1,s=[];for(let c of t.options){let u=c._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)s.push(u),a=!0;else{if(u.issues.length===0)return u;s.push(u)}}return a?Promise.all(s).then(c=>um(c,o,e,i)):um(s,o,e,i)}});function lm(e,t,r,n){let o=e.filter(i=>i.issues.length===0);return o.length===1?(t.value=o[0].value,t):(o.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(a=>Ce(a,n,ye())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}var Qc=p("$ZodXor",(e,t)=>{Gn.init(e,t),t.inclusive=!1;let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(r)return n(o,i);let a=!1,s=[];for(let c of t.options){let u=c._zod.run({value:o.value,issues:[]},i);u instanceof Promise?(s.push(u),a=!0):s.push(u)}return a?Promise.all(s).then(c=>lm(c,o,e,i)):lm(s,o,e,i)}}),eu=p("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Gn.init(e,t);let r=e._zod.parse;V(e._zod,"propValues",()=>{let o={};for(let i of t.options){let a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[s,c]of Object.entries(a)){o[s]||(o[s]=new Set);for(let u of c)o[s].add(u)}}return o});let n=Lr(()=>{let o=t.options,i=new Map;for(let a of o){let s=a._zod.propValues?.[t.discriminator];if(!s||s.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let c of s){if(i.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,a)}}return i});e._zod.parse=(o,i)=>{let a=o.value;if(!cr(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;let s=n.value.get(a?.[t.discriminator]);return s?s._zod.run(o,i):t.unionFallback?r(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),o)}}),tu=p("$ZodIntersection",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,i=t.left._zod.run({value:o,issues:[]},n),a=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([c,u])=>dm(r,c,u)):dm(r,i,a)}});function gc(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Jt(e)&&Jt(t)){let r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),o={...e,...t};for(let i of n){let a=gc(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],i=t[n],a=gc(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function dm(e,t,r){let n=new Map,o;for(let s of t.issues)if(s.code==="unrecognized_keys"){o??(o=s);for(let c of s.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(s);for(let s of r.issues)if(s.code==="unrecognized_keys")for(let c of s.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(s);let i=[...n].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(i.length&&o&&e.issues.push({...o,keys:i}),Kt(e))return e;let a=gc(t.value,r.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var Si=p("$ZodTuple",(e,t)=>{M.init(e,t);let r=t.items;e._zod.parse=(n,o)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=[];let a=[],s=[...r].reverse().findIndex(l=>l._zod.optin!=="optional"),c=s===-1?0:r.length-s;if(!t.rest){let l=i.length>r.length,d=i.length<c-1;if(l||d)return n.issues.push({...l?{code:"too_big",maximum:r.length,inclusive:!0}:{code:"too_small",minimum:r.length},input:i,inst:e,origin:"array"}),n}let u=-1;for(let l of r){if(u++,u>=i.length&&u>=c)continue;let d=l._zod.run({value:i[u],issues:[]},o);d instanceof Promise?a.push(d.then(m=>vi(m,n,u))):vi(d,n,u)}if(t.rest){let l=i.slice(r.length);for(let d of l){u++;let m=t.rest._zod.run({value:d,issues:[]},o);m instanceof Promise?a.push(m.then(f=>vi(f,n,u))):vi(m,n,u)}}return a.length?Promise.all(a).then(()=>n):n}});function vi(e,t,r){e.issues.length&&t.issues.push(...Ke(r,e.issues)),t.value[r]=e.value}var ru=p("$ZodRecord",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Jt(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;let i=[],a=t.keyType._zod.values;if(a){r.value={};let s=new Set;for(let u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){s.add(typeof u=="number"?u.toString():u);let l=t.valueType._zod.run({value:o[u],issues:[]},n);l instanceof Promise?i.push(l.then(d=>{d.issues.length&&r.issues.push(...Ke(u,d.issues)),r.value[u]=d.value})):(l.issues.length&&r.issues.push(...Ke(u,l.issues)),r.value[u]=l.value)}let c;for(let u in o)s.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{r.value={};for(let s of Reflect.ownKeys(o)){if(s==="__proto__")continue;let c=t.keyType._zod.run({value:s,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&hi.test(s)&&c.issues.length&&c.issues.some(d=>d.code==="invalid_type"&&d.expected==="number")){let d=t.keyType._zod.run({value:Number(s),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){t.mode==="loose"?r.value[s]=o[s]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>Ce(d,n,ye())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:o[s],issues:[]},n);l instanceof Promise?i.push(l.then(d=>{d.issues.length&&r.issues.push(...Ke(s,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...Ke(s,l.issues)),r.value[c.value]=l.value)}}return i.length?Promise.all(i).then(()=>r):r}}),nu=p("$ZodMap",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!(o instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:o,inst:e}),r;let i=[];r.value=new Map;for(let[a,s]of o){let c=t.keyType._zod.run({value:a,issues:[]},n),u=t.valueType._zod.run({value:s,issues:[]},n);c instanceof Promise||u instanceof Promise?i.push(Promise.all([c,u]).then(([l,d])=>{pm(l,d,r,a,o,e,n)})):pm(c,u,r,a,o,e,n)}return i.length?Promise.all(i).then(()=>r):r}});function pm(e,t,r,n,o,i,a){e.issues.length&&(Nn.has(typeof n)?r.issues.push(...Ke(n,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:o,inst:i,issues:e.issues.map(s=>Ce(s,a,ye()))})),t.issues.length&&(Nn.has(typeof n)?r.issues.push(...Ke(n,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:o,inst:i,key:n,issues:t.issues.map(s=>Ce(s,a,ye()))})),r.value.set(e.value,t.value)}var ou=p("$ZodSet",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!(o instanceof Set))return r.issues.push({input:o,inst:e,expected:"set",code:"invalid_type"}),r;let i=[];r.value=new Set;for(let a of o){let s=t.valueType._zod.run({value:a,issues:[]},n);s instanceof Promise?i.push(s.then(c=>fm(c,r))):fm(s,r)}return i.length?Promise.all(i).then(()=>r):r}});function fm(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var iu=p("$ZodEnum",(e,t)=>{M.init(e,t);let r=On(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>Nn.has(typeof o)).map(o=>typeof o=="string"?Xe(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{let a=o.value;return n.has(a)||o.issues.push({code:"invalid_value",values:r,input:a,inst:e}),o}}),au=p("$ZodLiteral",(e,t)=>{if(M.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?Xe(n):n?Xe(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,o)=>{let i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}}),su=p("$ZodFile",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return o instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:o,inst:e}),r}}),cu=p("$ZodTransform",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new sr(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(r.value=a,r));if(o instanceof Promise)throw new vt;return r.value=o,r}});function mm(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var wi=p("$ZodOptional",(e,t)=>{M.init(e,t),e._zod.optin="optional",e._zod.optout="optional",V(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),V(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${jn(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>mm(i,r.value)):mm(o,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),uu=p("$ZodExactOptional",(e,t)=>{wi.init(e,t),V(e._zod,"values",()=>t.innerType._zod.values),V(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),lu=p("$ZodNullable",(e,t)=>{M.init(e,t),V(e._zod,"optin",()=>t.innerType._zod.optin),V(e._zod,"optout",()=>t.innerType._zod.optout),V(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${jn(r.source)}|null)$`):void 0}),V(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),du=p("$ZodDefault",(e,t)=>{M.init(e,t),e._zod.optin="optional",V(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>hm(i,t)):hm(o,t)}});function hm(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var pu=p("$ZodPrefault",(e,t)=>{M.init(e,t),e._zod.optin="optional",V(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),fu=p("$ZodNonOptional",(e,t)=>{M.init(e,t),V(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>gm(i,e)):gm(o,e)}});function gm(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var mu=p("$ZodSuccess",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new sr("ZodSuccess");let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.issues.length===0,r)):(r.value=o.issues.length===0,r)}}),hu=p("$ZodCatch",(e,t)=>{M.init(e,t),V(e._zod,"optin",()=>t.innerType._zod.optin),V(e._zod,"optout",()=>t.innerType._zod.optout),V(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(a=>Ce(a,n,ye()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(i=>Ce(i,n,ye()))},input:r.value}),r.issues=[]),r)}}),gu=p("$ZodNaN",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),vu=p("$ZodPipe",(e,t)=>{M.init(e,t),V(e._zod,"values",()=>t.in._zod.values),V(e._zod,"optin",()=>t.in._zod.optin),V(e._zod,"optout",()=>t.out._zod.optout),V(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let i=t.out._zod.run(r,n);return i instanceof Promise?i.then(a=>_i(a,t.in,n)):_i(i,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(i=>_i(i,t.out,n)):_i(o,t.out,n)}});function _i(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Hn=p("$ZodCodec",(e,t)=>{M.init(e,t),V(e._zod,"values",()=>t.in._zod.values),V(e._zod,"optin",()=>t.in._zod.optin),V(e._zod,"optout",()=>t.out._zod.optout),V(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if((n.direction||"forward")==="forward"){let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(a=>yi(a,t,n)):yi(i,t,n)}else{let i=t.out._zod.run(r,n);return i instanceof Promise?i.then(a=>yi(a,t,n)):yi(i,t,n)}}});function yi(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let o=t.transform(e.value,e);return o instanceof Promise?o.then(i=>$i(e,i,t.out,r)):$i(e,o,t.out,r)}else{let o=t.reverseTransform(e.value,e);return o instanceof Promise?o.then(i=>$i(e,i,t.in,r)):$i(e,o,t.in,r)}}function $i(e,t,r,n){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},n)}var _u=p("$ZodReadonly",(e,t)=>{M.init(e,t),V(e._zod,"propValues",()=>t.innerType._zod.propValues),V(e._zod,"values",()=>t.innerType._zod.values),V(e._zod,"optin",()=>t.innerType?._zod?.optin),V(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(vm):vm(o)}});function vm(e){return e.value=Object.freeze(e.value),e}var yu=p("$ZodTemplateLiteral",(e,t)=>{M.init(e,t);let r=[];for(let n of t.parts)if(typeof n=="object"&&n!==null){if(!n._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...n._zod.traits].shift()}`);let o=n._zod.pattern instanceof RegExp?n._zod.pattern.source:n._zod.pattern;if(!o)throw new Error(`Invalid template literal part: ${n._zod.traits}`);let i=o.startsWith("^")?1:0,a=o.endsWith("$")?o.length-1:o.length;r.push(o.slice(i,a))}else if(n===null||Zs.has(typeof n))r.push(Xe(`${n}`));else throw new Error(`Invalid template literal part: ${n}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(n,o)=>typeof n.value!="string"?(n.issues.push({input:n.value,inst:e,expected:"string",code:"invalid_type"}),n):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n)}),$u=p("$ZodFunction",(e,t)=>(M.init(e,t),e._def=t,e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...n){let o=e._def.input?Un(e._def.input,n):n,i=Reflect.apply(r,this,o);return e._def.output?Un(e._def.output,i):i}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...n){let o=e._def.input?await Mn(e._def.input,n):n,i=await Reflect.apply(r,this,o);return e._def.output?await Mn(e._def.output,i):i}},e._zod.parse=(r,n)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{let n=e.constructor;return Array.isArray(r[0])?new n({type:"function",input:new Si({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new n({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let n=e.constructor;return new n({type:"function",input:e._def.input,output:r})},e)),bu=p("$ZodPromise",(e,t)=>{M.init(e,t),e._zod.parse=(r,n)=>Promise.resolve(r.value).then(o=>t.innerType._zod.run({value:o,issues:[]},n))}),xu=p("$ZodLazy",(e,t)=>{M.init(e,t),V(e._zod,"innerType",()=>t.getter()),V(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),V(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),V(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),V(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),ku=p("$ZodCustom",(e,t)=>{se.init(e,t),M.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(i=>_m(i,r,n,e));_m(o,r,n,e)}});function _m(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(qr(o))}}var pb=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(o){return e[o]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return o=>{switch(o.code){case"invalid_type":{let i=n[o.expected]??o.expected,a=A(o.input),s=n[a]??a;return`Invalid input: expected ${i}, received ${s}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${R(o.values[0])}`:`Invalid option: expected one of ${D(o.values,"|")}`;case"too_big":{let i=o.inclusive?"<=":"<",a=t(o.origin);return a?`Too big: expected ${o.origin??"value"} to have ${i}${o.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${i}${o.maximum.toString()}`}case"too_small":{let i=o.inclusive?">=":">",a=t(o.origin);return a?`Too small: expected ${o.origin} to have ${i}${o.minimum.toString()} ${a.unit}`:`Too small: expected ${o.origin} to be ${i}${o.minimum.toString()}`}case"invalid_format":{let i=o;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${D(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function Su(){return{localeError:pb()}}var Sm;var zu=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Iu(){return new zu}(Sm=globalThis).__zod_globalRegistry??(Sm.__zod_globalRegistry=Iu());var De=globalThis.__zod_globalRegistry;function Eu(e,t){return new e({type:"string",...k(t)})}function zi(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...k(t)})}function Bn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...k(t)})}function Ii(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...k(t)})}function Ei(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...k(t)})}function Ti(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...k(t)})}function Pi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...k(t)})}function Xn(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...k(t)})}function Oi(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...k(t)})}function ji(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...k(t)})}function Ni(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...k(t)})}function Di(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...k(t)})}function Ri(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...k(t)})}function Zi(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...k(t)})}function Ai(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...k(t)})}function Ui(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...k(t)})}function Ci(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...k(t)})}function Tu(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...k(t)})}function Mi(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...k(t)})}function Li(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...k(t)})}function qi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...k(t)})}function Fi(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...k(t)})}function Vi(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...k(t)})}function Ji(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...k(t)})}function Pu(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...k(t)})}function Ou(e,t){return new e({type:"string",format:"date",check:"string_format",...k(t)})}function ju(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...k(t)})}function Nu(e,t){return new e({type:"string",format:"duration",check:"string_format",...k(t)})}function Du(e,t){return new e({type:"number",checks:[],...k(t)})}function Ru(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...k(t)})}function Zu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...k(t)})}function Au(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...k(t)})}function Uu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...k(t)})}function Cu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...k(t)})}function Mu(e,t){return new e({type:"boolean",...k(t)})}function Lu(e,t){return new e({type:"bigint",...k(t)})}function qu(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...k(t)})}function Fu(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...k(t)})}function Vu(e,t){return new e({type:"symbol",...k(t)})}function Ju(e,t){return new e({type:"undefined",...k(t)})}function Ku(e,t){return new e({type:"null",...k(t)})}function Wu(e){return new e({type:"any"})}function Gu(e){return new e({type:"unknown"})}function Hu(e,t){return new e({type:"never",...k(t)})}function Bu(e,t){return new e({type:"void",...k(t)})}function Xu(e,t){return new e({type:"date",...k(t)})}function Yu(e,t){return new e({type:"nan",...k(t)})}function Pt(e,t){return new mc({check:"less_than",...k(t),value:e,inclusive:!1})}function We(e,t){return new mc({check:"less_than",...k(t),value:e,inclusive:!0})}function Ot(e,t){return new hc({check:"greater_than",...k(t),value:e,inclusive:!1})}function Re(e,t){return new hc({check:"greater_than",...k(t),value:e,inclusive:!0})}function Qu(e){return Ot(0,e)}function el(e){return Pt(0,e)}function tl(e){return We(0,e)}function rl(e){return Re(0,e)}function dr(e,t){return new qf({check:"multiple_of",...k(t),value:e})}function pr(e,t){return new Jf({check:"max_size",...k(t),maximum:e})}function jt(e,t){return new Kf({check:"min_size",...k(t),minimum:e})}function Vr(e,t){return new Wf({check:"size_equals",...k(t),size:e})}function Jr(e,t){return new Gf({check:"max_length",...k(t),maximum:e})}function Wt(e,t){return new Hf({check:"min_length",...k(t),minimum:e})}function Kr(e,t){return new Bf({check:"length_equals",...k(t),length:e})}function Yn(e,t){return new Xf({check:"string_format",format:"regex",...k(t),pattern:e})}function Qn(e){return new Yf({check:"string_format",format:"lowercase",...k(e)})}function eo(e){return new Qf({check:"string_format",format:"uppercase",...k(e)})}function to(e,t){return new em({check:"string_format",format:"includes",...k(t),includes:e})}function ro(e,t){return new tm({check:"string_format",format:"starts_with",...k(t),prefix:e})}function no(e,t){return new rm({check:"string_format",format:"ends_with",...k(t),suffix:e})}function nl(e,t,r){return new nm({check:"property",property:e,schema:t,...k(r)})}function oo(e,t){return new om({check:"mime_type",mime:e,...k(t)})}function _t(e){return new im({check:"overwrite",tx:e})}function io(e){return _t(t=>t.normalize(e))}function ao(){return _t(e=>e.trim())}function so(){return _t(e=>e.toLowerCase())}function co(){return _t(e=>e.toUpperCase())}function Ki(){return _t(e=>Ds(e))}function wm(e,t,r){return new e({type:"array",element:t,...k(r)})}function ol(e,t){return new e({type:"file",...k(t)})}function il(e,t,r){let n=k(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function al(e,t,r){return new e({type:"custom",check:"custom",fn:t,...k(r)})}function sl(e){let t=gb(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(qr(n,r.value,t._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(qr(o))}},e(r.value,r)));return t}function gb(e,t){let r=new se({check:"custom",...k(t)});return r._zod.check=e,r}function cl(e){let t=new se({check:"describe"});return t._zod.onattach=[r=>{let n=De.get(r)??{};De.add(r,{...n,description:e})}],t._zod.check=()=>{},t}function ul(e){let t=new se({check:"meta"});return t._zod.onattach=[r=>{let n=De.get(r)??{};De.add(r,{...n,...e})}],t._zod.check=()=>{},t}function ll(e,t){let r=k(t),n=r.truthy??["true","1","yes","on","y","enabled"],o=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(n=n.map(f=>typeof f=="string"?f.toLowerCase():f),o=o.map(f=>typeof f=="string"?f.toLowerCase():f));let i=new Set(n),a=new Set(o),s=e.Codec??Hn,c=e.Boolean??Wn,u=e.String??lr,l=new u({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),m=new s({type:"pipe",in:l,out:d,transform:((f,g)=>{let v=f;return r.case!=="sensitive"&&(v=v.toLowerCase()),i.has(v)?!0:a.has(v)?!1:(g.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...a],input:g.value,inst:m,continue:!1}),{})}),reverseTransform:((f,g)=>f===!0?n[0]||"true":o[0]||"false"),error:r.error});return m}function Wr(e,t,r,n={}){let o=k(n),i={...k(n),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...o};return r instanceof RegExp&&(i.pattern=r),new e(i)}function Wi(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??De,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function de(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a);let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,l);else{let m=a.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,m,l)}let d=e._zod.parent;d&&(a.ref||(a.ref=d),de(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),t.io==="input"&&Ze(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Gi(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let a of e.seen.entries()){let s=e.metadataRegistry.get(a[0])?.id;if(s){let c=n.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(s,a[0])}}let o=a=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(a[0])?.id,m=e.external.uri??(g=>g);if(d)return{ref:m(d)};let f=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=f,{defId:f,ref:`${m("__shared")}#/${s}/${f}`}}if(a[1]===r)return{ref:"#"};let u=`#/${s}/`,l=a[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},i=a=>{if(a[1].schema.$ref)return;let s=a[1],{ref:c,defId:u}=o(a);s.def={...s.schema},u&&(s.defId=u);let l=s.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){i(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(t!==a[0]&&u){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(s.cycle){i(a);continue}if(s.count>1&&e.reused==="ref"){i(a);continue}}}function Hi(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let s=e.seen.get(a);if(s.ref===null)return;let c=s.def??s.schema,u={...c},l=s.ref;if(s.ref=null,l){n(l);let m=e.seen.get(l),f=m.schema;if(f.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(f)):Object.assign(c,f),Object.assign(c,u),a._zod.parent===l)for(let v in c)v==="$ref"||v==="allOf"||v in u||delete c[v];if(f.$ref)for(let v in c)v==="$ref"||v==="allOf"||v in m.def&&JSON.stringify(c[v])===JSON.stringify(m.def[v])&&delete c[v]}let d=a._zod.parent;if(d&&d!==l){n(d);let m=e.seen.get(d);if(m?.schema.$ref&&(c.$ref=m.schema.$ref,m.def))for(let f in c)f==="$ref"||f==="allOf"||f in m.def&&JSON.stringify(c[f])===JSON.stringify(m.def[f])&&delete c[f]}e.override({zodSchema:a,jsonSchema:c,path:s.path??[]})};for(let a of[...e.seen.entries()].reverse())n(a[0]);let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,r.def??r.schema);let i=e.external?.defs??{};for(let a of e.seen.entries()){let s=a[1];s.def&&s.defId&&(i[s.defId]=s.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:uo(t,"input",e.processors),output:uo(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ze(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Ze(n.element,r);if(n.type==="set")return Ze(n.valueType,r);if(n.type==="lazy")return Ze(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Ze(n.innerType,r);if(n.type==="intersection")return Ze(n.left,r)||Ze(n.right,r);if(n.type==="record"||n.type==="map")return Ze(n.keyType,r)||Ze(n.valueType,r);if(n.type==="pipe")return Ze(n.in,r)||Ze(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Ze(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Ze(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Ze(o,r))return!0;return!!(n.rest&&Ze(n.rest,r))}return!1}var zm=(e,t={})=>r=>{let n=Wi({...r,processors:t});return de(e,n),Gi(n,e),Hi(n,e)},uo=(e,t,r={})=>n=>{let{libraryOptions:o,target:i}=n??{},a=Wi({...o??{},target:i,io:t,processors:r});return de(e,a),Gi(a,e),Hi(a,e)};var vb={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Im=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:i,maximum:a,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),s&&(o.format=vb[s]??s,o.format===""&&delete o.format,s==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},Em=(e,t,r,n)=>{let o=r,{minimum:i,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof s=="string"&&s.includes("int")?o.type="integer":o.type="number",typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l),typeof i=="number"&&(o.minimum=i,typeof l=="number"&&t.target!=="draft-04"&&(l>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof a=="number"&&(o.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},Tm=(e,t,r,n)=>{r.type="boolean"},Pm=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},Om=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},jm=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},Nm=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},Dm=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Rm=(e,t,r,n)=>{r.not={}},Zm=(e,t,r,n)=>{},Am=(e,t,r,n)=>{},Um=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Cm=(e,t,r,n)=>{let o=e._zod.def,i=On(o.entries);i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},Mm=(e,t,r,n)=>{let o=e._zod.def,i=[];for(let a of o.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){let a=i[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),i.every(a=>typeof a=="boolean")&&(r.type="boolean"),i.every(a=>a===null)&&(r.type="null"),r.enum=i},Lm=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},qm=(e,t,r,n)=>{let o=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},Fm=(e,t,r,n)=>{let o=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:c}=e._zod.bag;a!==void 0&&(i.minLength=a),s!==void 0&&(i.maxLength=s),c?c.length===1?(i.contentMediaType=c[0],Object.assign(o,i)):(Object.assign(o,i),o.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(o,i)},Vm=(e,t,r,n)=>{r.type="boolean"},Jm=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Km=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Wm=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Gm=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Hm=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Bm=(e,t,r,n)=>{let o=r,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof s=="number"&&(o.maxItems=s),o.type="array",o.items=de(i.element,t,{...n,path:[...n.path,"items"]})},Xm=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object",o.properties={};let a=i.shape;for(let u in a)o.properties[u]=de(a[u],t,{...n,path:[...n.path,"properties",u]});let s=new Set(Object.keys(a)),c=new Set([...s].filter(u=>{let l=i.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=de(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},dl=(e,t,r,n)=>{let o=e._zod.def,i=o.inclusive===!1,a=o.options.map((s,c)=>de(s,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=a:r.anyOf=a},Ym=(e,t,r,n)=>{let o=e._zod.def,i=de(o.left,t,{...n,path:[...n.path,"allOf",0]}),a=de(o.right,t,{...n,path:[...n.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]];r.allOf=c},Qm=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((m,f)=>de(m,t,{...n,path:[...n.path,a,f]})),u=i.rest?de(i.rest,t,{...n,path:[...n.path,s,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;t.target==="draft-2020-12"?(o.prefixItems=c,u&&(o.items=u)):t.target==="openapi-3.0"?(o.items={anyOf:c},u&&o.items.anyOf.push(u),o.minItems=c.length,u||(o.maxItems=c.length)):(o.items=c,u&&(o.additionalItems=u));let{minimum:l,maximum:d}=e._zod.bag;typeof l=="number"&&(o.minItems=l),typeof d=="number"&&(o.maxItems=d)},eh=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object";let a=i.keyType,c=a._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){let l=de(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of c)o.patternProperties[d.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=de(i.keyType,t,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=de(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]});let u=a._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l)}},th=(e,t,r,n)=>{let o=e._zod.def,i=de(o.innerType,t,n),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},rh=(e,t,r,n)=>{let o=e._zod.def;de(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},nh=(e,t,r,n)=>{let o=e._zod.def;de(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},oh=(e,t,r,n)=>{let o=e._zod.def;de(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},ih=(e,t,r,n)=>{let o=e._zod.def;de(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},ah=(e,t,r,n)=>{let o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;de(i,t,n);let a=t.seen.get(e);a.ref=i},sh=(e,t,r,n)=>{let o=e._zod.def;de(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0},ch=(e,t,r,n)=>{let o=e._zod.def;de(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},pl=(e,t,r,n)=>{let o=e._zod.def;de(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},uh=(e,t,r,n)=>{let o=e._zod.innerType;de(o,t,n);let i=t.seen.get(e);i.ref=o};function Gr(e){return!!e._zod}function Gt(e,t){return Gr(e)?Fr(e,t):e.safeParse(t)}function Bi(e){if(!e)return;let t;if(Gr(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function fh(e){if(Gr(e)){let i=e._zod?.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}var lo={};vn(lo,{ZodAny:()=>Oh,ZodArray:()=>Rh,ZodBase64:()=>Zl,ZodBase64URL:()=>Al,ZodBigInt:()=>ia,ZodBigIntFormat:()=>Ml,ZodBoolean:()=>oa,ZodCIDRv4:()=>Dl,ZodCIDRv6:()=>Rl,ZodCUID:()=>Il,ZodCUID2:()=>El,ZodCatch:()=>tg,ZodCodec:()=>Wl,ZodCustom:()=>la,ZodCustomStringFormat:()=>fo,ZodDate:()=>ql,ZodDefault:()=>Hh,ZodDiscriminatedUnion:()=>Ah,ZodE164:()=>Ul,ZodEmail:()=>Sl,ZodEmoji:()=>wl,ZodEnum:()=>po,ZodExactOptional:()=>Kh,ZodFile:()=>Vh,ZodFunction:()=>lg,ZodGUID:()=>Yi,ZodIPv4:()=>jl,ZodIPv6:()=>Nl,ZodIntersection:()=>Uh,ZodJWT:()=>Cl,ZodKSUID:()=>Ol,ZodLazy:()=>sg,ZodLiteral:()=>Fh,ZodMAC:()=>Ih,ZodMap:()=>Lh,ZodNaN:()=>ng,ZodNanoID:()=>zl,ZodNever:()=>Nh,ZodNonOptional:()=>Jl,ZodNull:()=>Ph,ZodNullable:()=>Gh,ZodNumber:()=>na,ZodNumberFormat:()=>Hr,ZodObject:()=>aa,ZodOptional:()=>Vl,ZodPipe:()=>Kl,ZodPrefault:()=>Xh,ZodPromise:()=>ug,ZodReadonly:()=>og,ZodRecord:()=>ua,ZodSet:()=>qh,ZodString:()=>ta,ZodStringFormat:()=>ce,ZodSuccess:()=>eg,ZodSymbol:()=>Eh,ZodTemplateLiteral:()=>ag,ZodTransform:()=>Jh,ZodTuple:()=>Ch,ZodType:()=>q,ZodULID:()=>Tl,ZodURL:()=>ra,ZodUUID:()=>Nt,ZodUndefined:()=>Th,ZodUnion:()=>sa,ZodUnknown:()=>jh,ZodVoid:()=>Dh,ZodXID:()=>Pl,ZodXor:()=>Zh,_ZodString:()=>kl,_default:()=>Bh,_function:()=>Rx,any:()=>vx,array:()=>H,base64:()=>ex,base64url:()=>tx,bigint:()=>px,boolean:()=>_e,catch:()=>rg,check:()=>Zx,cidrv4:()=>Yb,cidrv6:()=>Qb,codec:()=>jx,cuid:()=>Vb,cuid2:()=>Jb,custom:()=>Gl,date:()=>yx,describe:()=>Ax,discriminatedUnion:()=>ca,e164:()=>rx,email:()=>Db,emoji:()=>qb,enum:()=>Ee,exactOptional:()=>Wh,file:()=>Ex,float32:()=>cx,float64:()=>ux,function:()=>Rx,guid:()=>Rb,hash:()=>sx,hex:()=>ax,hostname:()=>ix,httpUrl:()=>Lb,instanceof:()=>Cx,int:()=>xl,int32:()=>lx,int64:()=>fx,intersection:()=>ho,ipv4:()=>Hb,ipv6:()=>Xb,json:()=>Lx,jwt:()=>nx,keyof:()=>$x,ksuid:()=>Gb,lazy:()=>cg,literal:()=>T,looseObject:()=>Ie,looseRecord:()=>Sx,mac:()=>Bb,map:()=>wx,meta:()=>Ux,nan:()=>Ox,nanoid:()=>Fb,nativeEnum:()=>Ix,never:()=>Ll,nonoptional:()=>Qh,null:()=>mo,nullable:()=>Qi,nullish:()=>Tx,number:()=>ne,object:()=>z,optional:()=>fe,partialRecord:()=>kx,pipe:()=>ea,prefault:()=>Yh,preprocess:()=>da,promise:()=>Dx,readonly:()=>ig,record:()=>pe,refine:()=>dg,set:()=>zx,strictObject:()=>bx,string:()=>h,stringFormat:()=>ox,stringbool:()=>Mx,success:()=>Px,superRefine:()=>pg,symbol:()=>hx,templateLiteral:()=>Nx,transform:()=>Fl,tuple:()=>Mh,uint32:()=>dx,uint64:()=>mx,ulid:()=>Kb,undefined:()=>gx,union:()=>ie,unknown:()=>ue,url:()=>Mb,uuid:()=>Zb,uuidv4:()=>Ab,uuidv6:()=>Ub,uuidv7:()=>Cb,void:()=>_x,xid:()=>Wb,xor:()=>xx});var Xi={};vn(Xi,{endsWith:()=>no,gt:()=>Ot,gte:()=>Re,includes:()=>to,length:()=>Kr,lowercase:()=>Qn,lt:()=>Pt,lte:()=>We,maxLength:()=>Jr,maxSize:()=>pr,mime:()=>oo,minLength:()=>Wt,minSize:()=>jt,multipleOf:()=>dr,negative:()=>el,nonnegative:()=>rl,nonpositive:()=>tl,normalize:()=>io,overwrite:()=>_t,positive:()=>Qu,property:()=>nl,regex:()=>Yn,size:()=>Vr,slugify:()=>Ki,startsWith:()=>ro,toLowerCase:()=>so,toUpperCase:()=>co,trim:()=>ao,uppercase:()=>eo});var fr={};vn(fr,{ZodISODate:()=>gl,ZodISODateTime:()=>ml,ZodISODuration:()=>$l,ZodISOTime:()=>_l,date:()=>vl,datetime:()=>hl,duration:()=>bl,time:()=>yl});var ml=p("ZodISODateTime",(e,t)=>{Ec.init(e,t),ce.init(e,t)});function hl(e){return Pu(ml,e)}var gl=p("ZodISODate",(e,t)=>{Tc.init(e,t),ce.init(e,t)});function vl(e){return Ou(gl,e)}var _l=p("ZodISOTime",(e,t)=>{Pc.init(e,t),ce.init(e,t)});function yl(e){return ju(_l,e)}var $l=p("ZodISODuration",(e,t)=>{Oc.init(e,t),ce.init(e,t)});function bl(e){return Nu($l,e)}var mh=(e,t)=>{di.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>fi(e,r)},flatten:{value:r=>pi(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,Mr,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,Mr,2)}},isEmpty:{get(){return e.issues.length===0}}})},ND=p("ZodError",mh),Ge=p("ZodError",mh,{Parent:Error});var hh=An(Ge),gh=Cn(Ge),vh=Ln(Ge),_h=qn(Ge),yh=Tf(Ge),$h=Pf(Ge),bh=Of(Ge),xh=jf(Ge),kh=Nf(Ge),Sh=Df(Ge),wh=Rf(Ge),zh=Zf(Ge);var q=p("ZodType",(e,t)=>(M.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:uo(e,"input"),output:uo(e,"output")}}),e.toJSONSchema=zm(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(y.mergeDefs(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>Ne(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>hh(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>vh(e,r,n),e.parseAsync=async(r,n)=>gh(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>_h(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>yh(e,r,n),e.decode=(r,n)=>$h(e,r,n),e.encodeAsync=async(r,n)=>bh(e,r,n),e.decodeAsync=async(r,n)=>xh(e,r,n),e.safeEncode=(r,n)=>kh(e,r,n),e.safeDecode=(r,n)=>Sh(e,r,n),e.safeEncodeAsync=async(r,n)=>wh(e,r,n),e.safeDecodeAsync=async(r,n)=>zh(e,r,n),e.refine=(r,n)=>e.check(dg(r,n)),e.superRefine=r=>e.check(pg(r)),e.overwrite=r=>e.check(_t(r)),e.optional=()=>fe(e),e.exactOptional=()=>Wh(e),e.nullable=()=>Qi(e),e.nullish=()=>fe(Qi(e)),e.nonoptional=r=>Qh(e,r),e.array=()=>H(e),e.or=r=>ie([e,r]),e.and=r=>ho(e,r),e.transform=r=>ea(e,Fl(r)),e.default=r=>Bh(e,r),e.prefault=r=>Yh(e,r),e.catch=r=>rg(e,r),e.pipe=r=>ea(e,r),e.readonly=()=>ig(e),e.describe=r=>{let n=e.clone();return De.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return De.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return De.get(e);let n=e.clone();return De.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),kl=p("_ZodString",(e,t)=>{lr.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Im(e,n,o,i);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(Yn(...n)),e.includes=(...n)=>e.check(to(...n)),e.startsWith=(...n)=>e.check(ro(...n)),e.endsWith=(...n)=>e.check(no(...n)),e.min=(...n)=>e.check(Wt(...n)),e.max=(...n)=>e.check(Jr(...n)),e.length=(...n)=>e.check(Kr(...n)),e.nonempty=(...n)=>e.check(Wt(1,...n)),e.lowercase=n=>e.check(Qn(n)),e.uppercase=n=>e.check(eo(n)),e.trim=()=>e.check(ao()),e.normalize=(...n)=>e.check(io(...n)),e.toLowerCase=()=>e.check(so()),e.toUpperCase=()=>e.check(co()),e.slugify=()=>e.check(Ki())}),ta=p("ZodString",(e,t)=>{lr.init(e,t),kl.init(e,t),e.email=r=>e.check(zi(Sl,r)),e.url=r=>e.check(Xn(ra,r)),e.jwt=r=>e.check(Ji(Cl,r)),e.emoji=r=>e.check(Oi(wl,r)),e.guid=r=>e.check(Bn(Yi,r)),e.uuid=r=>e.check(Ii(Nt,r)),e.uuidv4=r=>e.check(Ei(Nt,r)),e.uuidv6=r=>e.check(Ti(Nt,r)),e.uuidv7=r=>e.check(Pi(Nt,r)),e.nanoid=r=>e.check(ji(zl,r)),e.guid=r=>e.check(Bn(Yi,r)),e.cuid=r=>e.check(Ni(Il,r)),e.cuid2=r=>e.check(Di(El,r)),e.ulid=r=>e.check(Ri(Tl,r)),e.base64=r=>e.check(qi(Zl,r)),e.base64url=r=>e.check(Fi(Al,r)),e.xid=r=>e.check(Zi(Pl,r)),e.ksuid=r=>e.check(Ai(Ol,r)),e.ipv4=r=>e.check(Ui(jl,r)),e.ipv6=r=>e.check(Ci(Nl,r)),e.cidrv4=r=>e.check(Mi(Dl,r)),e.cidrv6=r=>e.check(Li(Rl,r)),e.e164=r=>e.check(Vi(Ul,r)),e.datetime=r=>e.check(hl(r)),e.date=r=>e.check(vl(r)),e.time=r=>e.check(yl(r)),e.duration=r=>e.check(bl(r))});function h(e){return Eu(ta,e)}var ce=p("ZodStringFormat",(e,t)=>{oe.init(e,t),kl.init(e,t)}),Sl=p("ZodEmail",(e,t)=>{yc.init(e,t),ce.init(e,t)});function Db(e){return zi(Sl,e)}var Yi=p("ZodGUID",(e,t)=>{vc.init(e,t),ce.init(e,t)});function Rb(e){return Bn(Yi,e)}var Nt=p("ZodUUID",(e,t)=>{_c.init(e,t),ce.init(e,t)});function Zb(e){return Ii(Nt,e)}function Ab(e){return Ei(Nt,e)}function Ub(e){return Ti(Nt,e)}function Cb(e){return Pi(Nt,e)}var ra=p("ZodURL",(e,t)=>{$c.init(e,t),ce.init(e,t)});function Mb(e){return Xn(ra,e)}function Lb(e){return Xn(ra,{protocol:/^https?$/,hostname:Ye.domain,...y.normalizeParams(e)})}var wl=p("ZodEmoji",(e,t)=>{bc.init(e,t),ce.init(e,t)});function qb(e){return Oi(wl,e)}var zl=p("ZodNanoID",(e,t)=>{xc.init(e,t),ce.init(e,t)});function Fb(e){return ji(zl,e)}var Il=p("ZodCUID",(e,t)=>{kc.init(e,t),ce.init(e,t)});function Vb(e){return Ni(Il,e)}var El=p("ZodCUID2",(e,t)=>{Sc.init(e,t),ce.init(e,t)});function Jb(e){return Di(El,e)}var Tl=p("ZodULID",(e,t)=>{wc.init(e,t),ce.init(e,t)});function Kb(e){return Ri(Tl,e)}var Pl=p("ZodXID",(e,t)=>{zc.init(e,t),ce.init(e,t)});function Wb(e){return Zi(Pl,e)}var Ol=p("ZodKSUID",(e,t)=>{Ic.init(e,t),ce.init(e,t)});function Gb(e){return Ai(Ol,e)}var jl=p("ZodIPv4",(e,t)=>{jc.init(e,t),ce.init(e,t)});function Hb(e){return Ui(jl,e)}var Ih=p("ZodMAC",(e,t)=>{Dc.init(e,t),ce.init(e,t)});function Bb(e){return Tu(Ih,e)}var Nl=p("ZodIPv6",(e,t)=>{Nc.init(e,t),ce.init(e,t)});function Xb(e){return Ci(Nl,e)}var Dl=p("ZodCIDRv4",(e,t)=>{Rc.init(e,t),ce.init(e,t)});function Yb(e){return Mi(Dl,e)}var Rl=p("ZodCIDRv6",(e,t)=>{Zc.init(e,t),ce.init(e,t)});function Qb(e){return Li(Rl,e)}var Zl=p("ZodBase64",(e,t)=>{Ac.init(e,t),ce.init(e,t)});function ex(e){return qi(Zl,e)}var Al=p("ZodBase64URL",(e,t)=>{Uc.init(e,t),ce.init(e,t)});function tx(e){return Fi(Al,e)}var Ul=p("ZodE164",(e,t)=>{Cc.init(e,t),ce.init(e,t)});function rx(e){return Vi(Ul,e)}var Cl=p("ZodJWT",(e,t)=>{Mc.init(e,t),ce.init(e,t)});function nx(e){return Ji(Cl,e)}var fo=p("ZodCustomStringFormat",(e,t)=>{Lc.init(e,t),ce.init(e,t)});function ox(e,t,r={}){return Wr(fo,e,t,r)}function ix(e){return Wr(fo,"hostname",Ye.hostname,e)}function ax(e){return Wr(fo,"hex",Ye.hex,e)}function sx(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,o=Ye[n];if(!o)throw new Error(`Unrecognized hash format: ${n}`);return Wr(fo,n,o,t)}var na=p("ZodNumber",(e,t)=>{xi.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Em(e,n,o,i),e.gt=(n,o)=>e.check(Ot(n,o)),e.gte=(n,o)=>e.check(Re(n,o)),e.min=(n,o)=>e.check(Re(n,o)),e.lt=(n,o)=>e.check(Pt(n,o)),e.lte=(n,o)=>e.check(We(n,o)),e.max=(n,o)=>e.check(We(n,o)),e.int=n=>e.check(xl(n)),e.safe=n=>e.check(xl(n)),e.positive=n=>e.check(Ot(0,n)),e.nonnegative=n=>e.check(Re(0,n)),e.negative=n=>e.check(Pt(0,n)),e.nonpositive=n=>e.check(We(0,n)),e.multipleOf=(n,o)=>e.check(dr(n,o)),e.step=(n,o)=>e.check(dr(n,o)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function ne(e){return Du(na,e)}var Hr=p("ZodNumberFormat",(e,t)=>{qc.init(e,t),na.init(e,t)});function xl(e){return Ru(Hr,e)}function cx(e){return Zu(Hr,e)}function ux(e){return Au(Hr,e)}function lx(e){return Uu(Hr,e)}function dx(e){return Cu(Hr,e)}var oa=p("ZodBoolean",(e,t)=>{Wn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Tm(e,r,n,o)});function _e(e){return Mu(oa,e)}var ia=p("ZodBigInt",(e,t)=>{ki.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Pm(e,n,o,i),e.gte=(n,o)=>e.check(Re(n,o)),e.min=(n,o)=>e.check(Re(n,o)),e.gt=(n,o)=>e.check(Ot(n,o)),e.gte=(n,o)=>e.check(Re(n,o)),e.min=(n,o)=>e.check(Re(n,o)),e.lt=(n,o)=>e.check(Pt(n,o)),e.lte=(n,o)=>e.check(We(n,o)),e.max=(n,o)=>e.check(We(n,o)),e.positive=n=>e.check(Ot(BigInt(0),n)),e.negative=n=>e.check(Pt(BigInt(0),n)),e.nonpositive=n=>e.check(We(BigInt(0),n)),e.nonnegative=n=>e.check(Re(BigInt(0),n)),e.multipleOf=(n,o)=>e.check(dr(n,o));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function px(e){return Lu(ia,e)}var Ml=p("ZodBigIntFormat",(e,t)=>{Fc.init(e,t),ia.init(e,t)});function fx(e){return qu(Ml,e)}function mx(e){return Fu(Ml,e)}var Eh=p("ZodSymbol",(e,t)=>{Vc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Om(e,r,n,o)});function hx(e){return Vu(Eh,e)}var Th=p("ZodUndefined",(e,t)=>{Jc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Nm(e,r,n,o)});function gx(e){return Ju(Th,e)}var Ph=p("ZodNull",(e,t)=>{Kc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>jm(e,r,n,o)});function mo(e){return Ku(Ph,e)}var Oh=p("ZodAny",(e,t)=>{Wc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zm(e,r,n,o)});function vx(){return Wu(Oh)}var jh=p("ZodUnknown",(e,t)=>{Gc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Am(e,r,n,o)});function ue(){return Gu(jh)}var Nh=p("ZodNever",(e,t)=>{Hc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Rm(e,r,n,o)});function Ll(e){return Hu(Nh,e)}var Dh=p("ZodVoid",(e,t)=>{Bc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Dm(e,r,n,o)});function _x(e){return Bu(Dh,e)}var ql=p("ZodDate",(e,t)=>{Xc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Um(e,n,o,i),e.min=(n,o)=>e.check(Re(n,o)),e.max=(n,o)=>e.check(We(n,o));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function yx(e){return Xu(ql,e)}var Rh=p("ZodArray",(e,t)=>{Yc.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bm(e,r,n,o),e.element=t.element,e.min=(r,n)=>e.check(Wt(r,n)),e.nonempty=r=>e.check(Wt(1,r)),e.max=(r,n)=>e.check(Jr(r,n)),e.length=(r,n)=>e.check(Kr(r,n)),e.unwrap=()=>e.element});function H(e,t){return wm(Rh,e,t)}function $x(e){let t=e._zod.def.shape;return Ee(Object.keys(t))}var aa=p("ZodObject",(e,t)=>{km.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xm(e,r,n,o),y.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Ee(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:ue()}),e.loose=()=>e.clone({...e._zod.def,catchall:ue()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ll()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>y.extend(e,r),e.safeExtend=r=>y.safeExtend(e,r),e.merge=r=>y.merge(e,r),e.pick=r=>y.pick(e,r),e.omit=r=>y.omit(e,r),e.partial=(...r)=>y.partial(Vl,e,r[0]),e.required=(...r)=>y.required(Jl,e,r[0])});function z(e,t){let r={type:"object",shape:e??{},...y.normalizeParams(t)};return new aa(r)}function bx(e,t){return new aa({type:"object",shape:e,catchall:Ll(),...y.normalizeParams(t)})}function Ie(e,t){return new aa({type:"object",shape:e,catchall:ue(),...y.normalizeParams(t)})}var sa=p("ZodUnion",(e,t)=>{Gn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dl(e,r,n,o),e.options=t.options});function ie(e,t){return new sa({type:"union",options:e,...y.normalizeParams(t)})}var Zh=p("ZodXor",(e,t)=>{sa.init(e,t),Qc.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dl(e,r,n,o),e.options=t.options});function xx(e,t){return new Zh({type:"union",options:e,inclusive:!1,...y.normalizeParams(t)})}var Ah=p("ZodDiscriminatedUnion",(e,t)=>{sa.init(e,t),eu.init(e,t)});function ca(e,t,r){return new Ah({type:"union",options:t,discriminator:e,...y.normalizeParams(r)})}var Uh=p("ZodIntersection",(e,t)=>{tu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ym(e,r,n,o)});function ho(e,t){return new Uh({type:"intersection",left:e,right:t})}var Ch=p("ZodTuple",(e,t)=>{Si.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qm(e,r,n,o),e.rest=r=>e.clone({...e._zod.def,rest:r})});function Mh(e,t,r){let n=t instanceof M,o=n?r:t,i=n?t:null;return new Ch({type:"tuple",items:e,rest:i,...y.normalizeParams(o)})}var ua=p("ZodRecord",(e,t)=>{ru.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>eh(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function pe(e,t,r){return new ua({type:"record",keyType:e,valueType:t,...y.normalizeParams(r)})}function kx(e,t,r){let n=Ne(e);return n._zod.values=void 0,new ua({type:"record",keyType:n,valueType:t,...y.normalizeParams(r)})}function Sx(e,t,r){return new ua({type:"record",keyType:e,valueType:t,mode:"loose",...y.normalizeParams(r)})}var Lh=p("ZodMap",(e,t)=>{nu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gm(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(jt(...r)),e.nonempty=r=>e.check(jt(1,r)),e.max=(...r)=>e.check(pr(...r)),e.size=(...r)=>e.check(Vr(...r))});function wx(e,t,r){return new Lh({type:"map",keyType:e,valueType:t,...y.normalizeParams(r)})}var qh=p("ZodSet",(e,t)=>{ou.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hm(e,r,n,o),e.min=(...r)=>e.check(jt(...r)),e.nonempty=r=>e.check(jt(1,r)),e.max=(...r)=>e.check(pr(...r)),e.size=(...r)=>e.check(Vr(...r))});function zx(e,t){return new qh({type:"set",valueType:e,...y.normalizeParams(t)})}var po=p("ZodEnum",(e,t)=>{iu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Cm(e,n,o,i),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let i={};for(let a of n)if(r.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new po({...t,checks:[],...y.normalizeParams(o),entries:i})},e.exclude=(n,o)=>{let i={...t.entries};for(let a of n)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new po({...t,checks:[],...y.normalizeParams(o),entries:i})}});function Ee(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new po({type:"enum",entries:r,...y.normalizeParams(t)})}function Ix(e,t){return new po({type:"enum",entries:e,...y.normalizeParams(t)})}var Fh=p("ZodLiteral",(e,t)=>{au.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Mm(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function T(e,t){return new Fh({type:"literal",values:Array.isArray(e)?e:[e],...y.normalizeParams(t)})}var Vh=p("ZodFile",(e,t)=>{su.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Fm(e,r,n,o),e.min=(r,n)=>e.check(jt(r,n)),e.max=(r,n)=>e.check(pr(r,n)),e.mime=(r,n)=>e.check(oo(Array.isArray(r)?r:[r],n))});function Ex(e){return ol(Vh,e)}var Jh=p("ZodTransform",(e,t)=>{cu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wm(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new sr(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(y.issue(i,r.value,t));else{let a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push(y.issue(a))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(i=>(r.value=i,r)):(r.value=o,r)}});function Fl(e){return new Jh({type:"transform",transform:e})}var Vl=p("ZodOptional",(e,t)=>{wi.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function fe(e){return new Vl({type:"optional",innerType:e})}var Kh=p("ZodExactOptional",(e,t)=>{uu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Wh(e){return new Kh({type:"optional",innerType:e})}var Gh=p("ZodNullable",(e,t)=>{lu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>th(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Qi(e){return new Gh({type:"nullable",innerType:e})}function Tx(e){return fe(Qi(e))}var Hh=p("ZodDefault",(e,t)=>{du.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Bh(e,t){return new Hh({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():y.shallowClone(t)}})}var Xh=p("ZodPrefault",(e,t)=>{pu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>oh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Yh(e,t){return new Xh({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():y.shallowClone(t)}})}var Jl=p("ZodNonOptional",(e,t)=>{fu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Qh(e,t){return new Jl({type:"nonoptional",innerType:e,...y.normalizeParams(t)})}var eg=p("ZodSuccess",(e,t)=>{mu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Px(e){return new eg({type:"success",innerType:e})}var tg=p("ZodCatch",(e,t)=>{hu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ih(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function rg(e,t){return new tg({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var ng=p("ZodNaN",(e,t)=>{gu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Lm(e,r,n,o)});function Ox(e){return Yu(ng,e)}var Kl=p("ZodPipe",(e,t)=>{vu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ah(e,r,n,o),e.in=t.in,e.out=t.out});function ea(e,t){return new Kl({type:"pipe",in:e,out:t})}var Wl=p("ZodCodec",(e,t)=>{Kl.init(e,t),Hn.init(e,t)});function jx(e,t,r){return new Wl({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}var og=p("ZodReadonly",(e,t)=>{_u.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ig(e){return new og({type:"readonly",innerType:e})}var ag=p("ZodTemplateLiteral",(e,t)=>{yu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qm(e,r,n,o)});function Nx(e,t){return new ag({type:"template_literal",parts:e,...y.normalizeParams(t)})}var sg=p("ZodLazy",(e,t)=>{xu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>uh(e,r,n,o),e.unwrap=()=>e._zod.def.getter()});function cg(e){return new sg({type:"lazy",getter:e})}var ug=p("ZodPromise",(e,t)=>{bu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ch(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Dx(e){return new ug({type:"promise",innerType:e})}var lg=p("ZodFunction",(e,t)=>{$u.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Km(e,r,n,o)});function Rx(e){return new lg({type:"function",input:Array.isArray(e?.input)?Mh(e?.input):e?.input??H(ue()),output:e?.output??ue()})}var la=p("ZodCustom",(e,t)=>{ku.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jm(e,r,n,o)});function Zx(e){let t=new se({check:"custom"});return t._zod.check=e,t}function Gl(e,t){return il(la,e??(()=>!0),t)}function dg(e,t={}){return al(la,e,t)}function pg(e){return sl(e)}var Ax=cl,Ux=ul;function Cx(e,t={}){let r=new la({type:"custom",check:"custom",fn:n=>n instanceof e,abort:!0,...y.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Mx=(...e)=>ll({Codec:Wl,Boolean:oa,String:ta},...e);function Lx(e){let t=cg(()=>ie([h(e),ne(),_e(),mo(),H(t),pe(h(),t)]));return t}function da(e,t){return ea(Fl(e),t)}var fg;fg||(fg={});var LD={...lo,...Xi,iso:fr};ye(Su());var Bl="2025-11-25";var mg=[Bl,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Ht="io.modelcontextprotocol/related-task",fa="2.0",$e=Gl(e=>e!==null&&(typeof e=="object"||typeof e=="function")),hg=ie([h(),ne().int()]),gg=h(),a4=Ie({ttl:ie([ne(),mo()]).optional(),pollInterval:ne().optional()}),Jx=z({ttl:ne().optional()}),Kx=z({taskId:h()}),Xl=Ie({progressToken:hg.optional(),[Ht]:Kx.optional()}),He=z({_meta:Xl.optional()}),go=He.extend({task:Jx.optional()}),vg=e=>go.safeParse(e).success,be=z({method:h(),params:He.loose().optional()}),Qe=z({_meta:Xl.optional()}),et=z({method:h(),params:Qe.loose().optional()}),xe=Ie({_meta:Xl.optional()}),ma=ie([h(),ne().int()]),_g=z({jsonrpc:T(fa),id:ma,...be.shape}).strict(),Yl=e=>_g.safeParse(e).success,yg=z({jsonrpc:T(fa),...et.shape}).strict(),$g=e=>yg.safeParse(e).success,Ql=z({jsonrpc:T(fa),id:ma,result:xe}).strict(),vo=e=>Ql.safeParse(e).success;var Y;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(Y||(Y={}));var ed=z({jsonrpc:T(fa),id:ma.optional(),error:z({code:ne().int(),message:h(),data:ue().optional()})}).strict();var bg=e=>ed.safeParse(e).success;var xg=ie([_g,yg,Ql,ed]),s4=ie([Ql,ed]),ha=xe.strict(),Wx=Qe.extend({requestId:ma.optional(),reason:h().optional()}),ga=et.extend({method:T("notifications/cancelled"),params:Wx}),Gx=z({src:h(),mimeType:h().optional(),sizes:H(h()).optional(),theme:Ee(["light","dark"]).optional()}),_o=z({icons:H(Gx).optional()}),Br=z({name:h(),title:h().optional()}),kg=Br.extend({...Br.shape,..._o.shape,version:h(),websiteUrl:h().optional(),description:h().optional()}),Hx=ho(z({applyDefaults:_e().optional()}),pe(h(),ue())),Bx=da(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ho(z({form:Hx.optional(),url:$e.optional()}),pe(h(),ue()).optional())),Xx=Ie({list:$e.optional(),cancel:$e.optional(),requests:Ie({sampling:Ie({createMessage:$e.optional()}).optional(),elicitation:Ie({create:$e.optional()}).optional()}).optional()}),Yx=Ie({list:$e.optional(),cancel:$e.optional(),requests:Ie({tools:Ie({call:$e.optional()}).optional()}).optional()}),Qx=z({experimental:pe(h(),$e).optional(),sampling:z({context:$e.optional(),tools:$e.optional()}).optional(),elicitation:Bx.optional(),roots:z({listChanged:_e().optional()}).optional(),tasks:Xx.optional()}),ek=He.extend({protocolVersion:h(),capabilities:Qx,clientInfo:kg}),td=be.extend({method:T("initialize"),params:ek});var tk=z({experimental:pe(h(),$e).optional(),logging:$e.optional(),completions:$e.optional(),prompts:z({listChanged:_e().optional()}).optional(),resources:z({subscribe:_e().optional(),listChanged:_e().optional()}).optional(),tools:z({listChanged:_e().optional()}).optional(),tasks:Yx.optional()}),rk=xe.extend({protocolVersion:h(),capabilities:tk,serverInfo:kg,instructions:h().optional()}),rd=et.extend({method:T("notifications/initialized"),params:Qe.optional()});var va=be.extend({method:T("ping"),params:He.optional()}),nk=z({progress:ne(),total:fe(ne()),message:fe(h())}),ok=z({...Qe.shape,...nk.shape,progressToken:hg}),_a=et.extend({method:T("notifications/progress"),params:ok}),ik=He.extend({cursor:gg.optional()}),yo=be.extend({params:ik.optional()}),$o=xe.extend({nextCursor:gg.optional()}),ak=Ee(["working","input_required","completed","failed","cancelled"]),bo=z({taskId:h(),status:ak,ttl:ie([ne(),mo()]),createdAt:h(),lastUpdatedAt:h(),pollInterval:fe(ne()),statusMessage:fe(h())}),Xr=xe.extend({task:bo}),sk=Qe.merge(bo),xo=et.extend({method:T("notifications/tasks/status"),params:sk}),ya=be.extend({method:T("tasks/get"),params:He.extend({taskId:h()})}),$a=xe.merge(bo),ba=be.extend({method:T("tasks/result"),params:He.extend({taskId:h()})}),c4=xe.loose(),xa=yo.extend({method:T("tasks/list")}),ka=$o.extend({tasks:H(bo)}),Sa=be.extend({method:T("tasks/cancel"),params:He.extend({taskId:h()})}),Sg=xe.merge(bo),wg=z({uri:h(),mimeType:fe(h()),_meta:pe(h(),ue()).optional()}),zg=wg.extend({text:h()}),nd=h().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Ig=wg.extend({blob:nd}),ko=Ee(["user","assistant"]),Yr=z({audience:H(ko).optional(),priority:ne().min(0).max(1).optional(),lastModified:fr.datetime({offset:!0}).optional()}),Eg=z({...Br.shape,..._o.shape,uri:h(),description:fe(h()),mimeType:fe(h()),annotations:Yr.optional(),_meta:fe(Ie({}))}),ck=z({...Br.shape,..._o.shape,uriTemplate:h(),description:fe(h()),mimeType:fe(h()),annotations:Yr.optional(),_meta:fe(Ie({}))}),uk=yo.extend({method:T("resources/list")}),lk=$o.extend({resources:H(Eg)}),dk=yo.extend({method:T("resources/templates/list")}),pk=$o.extend({resourceTemplates:H(ck)}),od=He.extend({uri:h()}),fk=od,mk=be.extend({method:T("resources/read"),params:fk}),hk=xe.extend({contents:H(ie([zg,Ig]))}),gk=et.extend({method:T("notifications/resources/list_changed"),params:Qe.optional()}),vk=od,_k=be.extend({method:T("resources/subscribe"),params:vk}),yk=od,$k=be.extend({method:T("resources/unsubscribe"),params:yk}),bk=Qe.extend({uri:h()}),xk=et.extend({method:T("notifications/resources/updated"),params:bk}),kk=z({name:h(),description:fe(h()),required:fe(_e())}),Sk=z({...Br.shape,..._o.shape,description:fe(h()),arguments:fe(H(kk)),_meta:fe(Ie({}))}),wk=yo.extend({method:T("prompts/list")}),zk=$o.extend({prompts:H(Sk)}),Ik=He.extend({name:h(),arguments:pe(h(),h()).optional()}),Ek=be.extend({method:T("prompts/get"),params:Ik}),id=z({type:T("text"),text:h(),annotations:Yr.optional(),_meta:pe(h(),ue()).optional()}),ad=z({type:T("image"),data:nd,mimeType:h(),annotations:Yr.optional(),_meta:pe(h(),ue()).optional()}),sd=z({type:T("audio"),data:nd,mimeType:h(),annotations:Yr.optional(),_meta:pe(h(),ue()).optional()}),Tk=z({type:T("tool_use"),name:h(),id:h(),input:pe(h(),ue()),_meta:pe(h(),ue()).optional()}),Pk=z({type:T("resource"),resource:ie([zg,Ig]),annotations:Yr.optional(),_meta:pe(h(),ue()).optional()}),Ok=Eg.extend({type:T("resource_link")}),cd=ie([id,ad,sd,Ok,Pk]),jk=z({role:ko,content:cd}),Nk=xe.extend({description:h().optional(),messages:H(jk)}),Dk=et.extend({method:T("notifications/prompts/list_changed"),params:Qe.optional()}),Rk=z({title:h().optional(),readOnlyHint:_e().optional(),destructiveHint:_e().optional(),idempotentHint:_e().optional(),openWorldHint:_e().optional()}),Zk=z({taskSupport:Ee(["required","optional","forbidden"]).optional()}),Tg=z({...Br.shape,..._o.shape,description:h().optional(),inputSchema:z({type:T("object"),properties:pe(h(),$e).optional(),required:H(h()).optional()}).catchall(ue()),outputSchema:z({type:T("object"),properties:pe(h(),$e).optional(),required:H(h()).optional()}).catchall(ue()).optional(),annotations:Rk.optional(),execution:Zk.optional(),_meta:pe(h(),ue()).optional()}),ud=yo.extend({method:T("tools/list")}),Ak=$o.extend({tools:H(Tg)}),wa=xe.extend({content:H(cd).default([]),structuredContent:pe(h(),ue()).optional(),isError:_e().optional()}),u4=wa.or(xe.extend({toolResult:ue()})),Uk=go.extend({name:h(),arguments:pe(h(),ue()).optional()}),So=be.extend({method:T("tools/call"),params:Uk}),Ck=et.extend({method:T("notifications/tools/list_changed"),params:Qe.optional()}),l4=z({autoRefresh:_e().default(!0),debounceMs:ne().int().nonnegative().default(300)}),wo=Ee(["debug","info","notice","warning","error","critical","alert","emergency"]),Mk=He.extend({level:wo}),ld=be.extend({method:T("logging/setLevel"),params:Mk}),Lk=Qe.extend({level:wo,logger:h().optional(),data:ue()}),qk=et.extend({method:T("notifications/message"),params:Lk}),Fk=z({name:h().optional()}),Vk=z({hints:H(Fk).optional(),costPriority:ne().min(0).max(1).optional(),speedPriority:ne().min(0).max(1).optional(),intelligencePriority:ne().min(0).max(1).optional()}),Jk=z({mode:Ee(["auto","required","none"]).optional()}),Kk=z({type:T("tool_result"),toolUseId:h().describe("The unique identifier for the corresponding tool call."),content:H(cd).default([]),structuredContent:z({}).loose().optional(),isError:_e().optional(),_meta:pe(h(),ue()).optional()}),Wk=ca("type",[id,ad,sd]),pa=ca("type",[id,ad,sd,Tk,Kk]),Gk=z({role:ko,content:ie([pa,H(pa)]),_meta:pe(h(),ue()).optional()}),Hk=go.extend({messages:H(Gk),modelPreferences:Vk.optional(),systemPrompt:h().optional(),includeContext:Ee(["none","thisServer","allServers"]).optional(),temperature:ne().optional(),maxTokens:ne().int(),stopSequences:H(h()).optional(),metadata:$e.optional(),tools:H(Tg).optional(),toolChoice:Jk.optional()}),Bk=be.extend({method:T("sampling/createMessage"),params:Hk}),dd=xe.extend({model:h(),stopReason:fe(Ee(["endTurn","stopSequence","maxTokens"]).or(h())),role:ko,content:Wk}),pd=xe.extend({model:h(),stopReason:fe(Ee(["endTurn","stopSequence","maxTokens","toolUse"]).or(h())),role:ko,content:ie([pa,H(pa)])}),Xk=z({type:T("boolean"),title:h().optional(),description:h().optional(),default:_e().optional()}),Yk=z({type:T("string"),title:h().optional(),description:h().optional(),minLength:ne().optional(),maxLength:ne().optional(),format:Ee(["email","uri","date","date-time"]).optional(),default:h().optional()}),Qk=z({type:Ee(["number","integer"]),title:h().optional(),description:h().optional(),minimum:ne().optional(),maximum:ne().optional(),default:ne().optional()}),eS=z({type:T("string"),title:h().optional(),description:h().optional(),enum:H(h()),default:h().optional()}),tS=z({type:T("string"),title:h().optional(),description:h().optional(),oneOf:H(z({const:h(),title:h()})),default:h().optional()}),rS=z({type:T("string"),title:h().optional(),description:h().optional(),enum:H(h()),enumNames:H(h()).optional(),default:h().optional()}),nS=ie([eS,tS]),oS=z({type:T("array"),title:h().optional(),description:h().optional(),minItems:ne().optional(),maxItems:ne().optional(),items:z({type:T("string"),enum:H(h())}),default:H(h()).optional()}),iS=z({type:T("array"),title:h().optional(),description:h().optional(),minItems:ne().optional(),maxItems:ne().optional(),items:z({anyOf:H(z({const:h(),title:h()}))}),default:H(h()).optional()}),aS=ie([oS,iS]),sS=ie([rS,nS,aS]),cS=ie([sS,Xk,Yk,Qk]),uS=go.extend({mode:T("form").optional(),message:h(),requestedSchema:z({type:T("object"),properties:pe(h(),cS),required:H(h()).optional()})}),lS=go.extend({mode:T("url"),message:h(),elicitationId:h(),url:h().url()}),dS=ie([uS,lS]),pS=be.extend({method:T("elicitation/create"),params:dS}),fS=Qe.extend({elicitationId:h()}),mS=et.extend({method:T("notifications/elicitation/complete"),params:fS}),za=xe.extend({action:Ee(["accept","decline","cancel"]),content:da(e=>e===null?void 0:e,pe(h(),ie([h(),ne(),_e(),H(h())])).optional())}),hS=z({type:T("ref/resource"),uri:h()});var gS=z({type:T("ref/prompt"),name:h()}),vS=He.extend({ref:ie([gS,hS]),argument:z({name:h(),value:h()}),context:z({arguments:pe(h(),h()).optional()}).optional()}),_S=be.extend({method:T("completion/complete"),params:vS});var yS=xe.extend({completion:Ie({values:H(h()).max(100),total:fe(ne().int()),hasMore:fe(_e())})}),$S=z({uri:h().startsWith("file://"),name:h().optional(),_meta:pe(h(),ue()).optional()}),bS=be.extend({method:T("roots/list"),params:He.optional()}),fd=xe.extend({roots:H($S)}),xS=et.extend({method:T("notifications/roots/list_changed"),params:Qe.optional()}),d4=ie([va,td,_S,ld,Ek,wk,uk,dk,mk,_k,$k,So,ud,ya,ba,xa,Sa]),p4=ie([ga,_a,rd,xS,xo]),f4=ie([ha,dd,pd,za,fd,$a,ka,Xr]),m4=ie([va,Bk,pS,bS,ya,ba,xa,Sa]),h4=ie([ga,_a,qk,xk,gk,Ck,Dk,xo,mS]),g4=ie([ha,rk,yS,Nk,zk,lk,pk,hk,wa,Ak,$a,ka,Xr]),J=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===Y.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Hl(o.elicitations,r)}return new e(t,r,n)}},Hl=class extends J{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(Y.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function Bt(e){return e==="completed"||e==="failed"||e==="cancelled"}var B4=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function md(e){let r=Bi(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=fh(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function hd(e,t){let r=Gt(e,t);if(!r.success)throw r.error;return r.data}var ES=6e4,Ia=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(ga,r=>{this._oncancel(r)}),this.setNotificationHandler(_a,r=>{this._onprogress(r)}),this.setRequestHandler(va,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ya,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new J(Y.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(ba,async(r,n)=>{let o=async()=>{let i=r.params.taskId;if(this._taskMessageQueue){let s;for(;s=await this._taskMessageQueue.dequeue(i,n.sessionId);){if(s.type==="response"||s.type==="error"){let c=s.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),s.type==="response")l(c);else{let d=c,m=new J(d.error.code,d.error.message,d.error.data);l(m)}else{let d=s.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(s.message,{relatedRequestId:n.requestId})}}let a=await this._taskStore.getTask(i,n.sessionId);if(!a)throw new J(Y.InvalidParams,`Task not found: ${i}`);if(!Bt(a.status))return await this._waitForTaskUpdate(i,n.signal),await o();if(Bt(a.status)){let s=await this._taskStore.getTaskResult(i,n.sessionId);return this._clearTaskQueue(i),{...s,_meta:{...s._meta,[Ht]:{taskId:i}}}}return await o()};return await o()}),this.setRequestHandler(xa,async(r,n)=>{try{let{tasks:o,nextCursor:i}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:i,_meta:{}}}catch(o){throw new J(Y.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Sa,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new J(Y.InvalidParams,`Task not found: ${r.params.taskId}`);if(Bt(o.status))throw new J(Y.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new J(Y.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...i}}catch(o){throw o instanceof J?o:new J(Y.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,i=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),J.fromError(Y.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=i=>{n?.(i),this._onerror(i)};let o=this._transport?.onmessage;this._transport.onmessage=(i,a)=>{o?.(i,a),vo(i)||bg(i)?this._onresponse(i):Yl(i)?this._onrequest(i,a):$g(i)?this._onnotification(i):this._onerror(new Error(`Unknown message type: ${JSON.stringify(i)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();let r=J.fromError(Y.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,i=t.params?._meta?.[Ht]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:Y.MethodNotFound,message:"Method not found"}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);let s=vg(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:a.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{let d={relatedRequestId:t.id};i&&(d.relatedTask={taskId:i}),await this.notification(l,d)},sendRequest:async(l,d,m)=>{let f={...m,relatedRequestId:t.id};i&&!f.relatedTask&&(f.relatedTask={taskId:i});let g=f.relatedTask?.taskId??i;return g&&c&&await c.updateTaskStatus(g,"input_required"),await this.request(l,d,f)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:i,taskStore:c,taskRequestedTtl:s?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{s&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async l=>{if(a.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(a.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:Y.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),i=this._progressHandlers.get(o);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let a=this._responseHandlers.get(o),s=this._timeoutInfo.get(o);if(s&&a&&s.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),a(c);return}i(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),vo(t))n(t);else{let a=new J(t.error.code,t.error.message,t.error.data);n(a)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let i=!1;if(vo(t)&&t.result&&typeof t.result=="object"){let a=t.result;if(a.task&&typeof a.task=="object"){let s=a.task;typeof s.taskId=="string"&&(i=!0,this._taskProgressTokens.set(s.taskId,r))}}if(i||this._progressHandlers.delete(r),vo(t))o(t);else{let a=J.fromError(t.error.code,t.error.message,t.error.data);o(a)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(a){yield{type:"error",error:a instanceof J?a:new J(Y.InternalError,String(a))}}return}let i;try{let a=await this.request(t,Xr,n);if(a.task)i=a.task.taskId,yield{type:"taskCreated",task:a.task};else throw new J(Y.InternalError,"Task creation did not return a task");for(;;){let s=await this.getTask({taskId:i},n);if(yield{type:"taskStatus",task:s},Bt(s.status)){s.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:i},r,n)}:s.status==="failed"?yield{type:"error",error:new J(Y.InternalError,`Task ${i} failed`)}:s.status==="cancelled"&&(yield{type:"error",error:new J(Y.InternalError,`Task ${i} was cancelled`)});return}if(s.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:i},r,n)};return}let c=s.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(a){yield{type:"error",error:a instanceof J?a:new J(Y.InternalError,String(a))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:i,onresumptiontoken:a,task:s,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=O=>{l(O)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),s&&this.assertTaskCapability(t.method)}catch(O){d(O);return}n?.signal?.throwIfAborted();let m=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:m};n?.onprogress&&(this._progressHandlers.set(m,n.onprogress),f.params={...t.params,_meta:{...t.params?._meta||{},progressToken:m}}),s&&(f.params={...f.params,task:s}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[Ht]:c}});let g=O=>{this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(O)}},{relatedRequestId:o,resumptionToken:i,onresumptiontoken:a}).catch(U=>this._onerror(new Error(`Failed to send cancellation: ${U}`)));let I=O instanceof J?O:new J(Y.RequestTimeout,String(O));l(I)};this._responseHandlers.set(m,O=>{if(!n?.signal?.aborted){if(O instanceof Error)return l(O);try{let I=Gt(r,O.result);I.success?u(I.data):l(I.error)}catch(I){l(I)}}}),n?.signal?.addEventListener("abort",()=>{g(n?.signal?.reason)});let v=n?.timeout??ES,$=()=>g(J.fromError(Y.RequestTimeout,"Request timed out",{timeout:v}));this._setupTimeout(m,v,n?.maxTotalTimeout,$,n?.resetTimeoutOnProgress??!1);let x=c?.taskId;if(x){let O=I=>{let U=this._responseHandlers.get(m);U?U(I):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,O),this._enqueueTaskMessage(x,{type:"request",message:f,timestamp:Date.now()}).catch(I=>{this._cleanupTimeout(m),l(I)})}else this._transport.send(f,{relatedRequestId:o,resumptionToken:i,onresumptiontoken:a}).catch(O=>{this._cleanupTimeout(m),l(O)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},$a,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},ka,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Sg,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let s={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Ht]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:s,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let s={...t,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[Ht]:r.relatedTask}}}),this._transport?.send(s,r).catch(c=>this._onerror(c))});return}let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Ht]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(t,r){let n=md(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,i)=>{let a=hd(t,o);return Promise.resolve(r(a,i))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=md(t);this._notificationHandlers.set(n,o=>{let i=hd(t,o);return Promise.resolve(r(i))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&Yl(o.message)){let i=o.message.id,a=this._requestResolvers.get(i);a?(a(new J(Y.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(i)):this._onerror(new Error(`Resolver missing for request ${i} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(t);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,i)=>{if(r.aborted){i(new J(Y.InvalidRequest,"Request cancelled"));return}let a=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(a),i(new J(Y.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let i=await n.getTask(o,r);if(!i)throw new J(Y.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(o,i,a)=>{await n.storeTaskResult(o,i,a,r);let s=await n.getTask(o,r);if(s){let c=xo.parse({method:"notifications/tasks/status",params:s});await this.notification(c),Bt(s.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,i,a)=>{let s=await n.getTask(o,r);if(!s)throw new J(Y.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Bt(s.status))throw new J(Y.InvalidParams,`Cannot update task "${o}" from terminal status "${s.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,i,a,r);let c=await n.getTask(o,r);if(c){let u=xo.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Bt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Pg(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Og(e,t){let r={...e};for(let n in t){let o=n,i=t[o];if(i===void 0)continue;let a=r[o];Pg(a)&&Pg(i)?r[o]={...a,...i}:r[o]=i}return r}var vy=ni(ef(),1),_y=ni(gy(),1);function _T(){let e=new vy.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,_y.default)(e),e}var ls=class{constructor(t){this._ajv=t??_T()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var ds=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function yy(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function $y(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var ps=class extends Ia{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(wo.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let i=this._loggingLevels.get(o);return i?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(i):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new ls,this.setRequestHandler(td,n=>this._oninitialize(n)),this.setNotificationHandler(rd,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(ld,async(n,o)=>{let i=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:a}=n.params,s=wo.safeParse(a);return s.success&&this._loggingLevels.set(i,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new ds(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Og(this._capabilities,t)}setRequestHandler(t,r){let o=Bi(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let i;if(Gr(o)){let s=o;i=s._zod?.def?.value??s.value}else{let s=o;i=s._def?.value??s.value}if(typeof i!="string")throw new Error("Schema method literal must be a string");if(i==="tools/call"){let s=async(c,u)=>{let l=Gt(So,c);if(!l.success){let g=l.error instanceof Error?l.error.message:String(l.error);throw new J(Y.InvalidParams,`Invalid tools/call request: ${g}`)}let{params:d}=l.data,m=await Promise.resolve(r(c,u));if(d.task){let g=Gt(Xr,m);if(!g.success){let v=g.error instanceof Error?g.error.message:String(g.error);throw new J(Y.InvalidParams,`Invalid task creation result: ${v}`)}return g.data}let f=Gt(wa,m);if(!f.success){let g=f.error instanceof Error?f.error.message:String(f.error);throw new J(Y.InvalidParams,`Invalid tools/call result: ${g}`)}return f.data};return super.setRequestHandler(t,s)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){$y(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&yy(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:mg.includes(r)?r:Bl,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},ha)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],i=o.some(u=>u.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,s=a?Array.isArray(a.content)?a.content:[a.content]:[],c=s.some(u=>u.type==="tool_use");if(i){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(s.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},pd,r):this.request({method:"sampling/createMessage",params:t},dd,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},za,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},i=await this.request({method:"elicitation/create",params:o},za,r);if(i.action==="accept"&&i.content&&o.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(o.requestedSchema)(i.content);if(!s.valid)throw new J(Y.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(a){throw a instanceof J?a:new J(Y.InternalError,`Error validating elicitation response: ${a instanceof Error?a.message:String(a)}`)}return i}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},fd,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var uf=ni(require("node:process"),1);var fs=class{append(t){this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),yT(r)}clear(){this._buffer=void 0}};function yT(e){return xg.parse(JSON.parse(e))}function by(e){return JSON.stringify(e)+`
`}var ms=class{constructor(t=uf.default.stdin,r=uf.default.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new fs,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=by(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var vs=ni(require("path"),1),ky=require("os");var lf={DEFAULT:3e5,HEALTH_CHECK:3e4,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:300,PRE_RESTART_SETTLE_DELAY:2e3,WINDOWS_MULTIPLIER:1.5};function xy(e){return process.platform==="win32"?Math.round(e*lf.WINDOWS_MULTIPLIER):e}var NU=vs.default.join((0,ky.homedir)(),".claude","plugins","marketplaces","thedotmack"),DU=xy(lf.HEALTH_CHECK),hs=null,gs=null;function Sy(){if(hs!==null)return hs;let e=vs.default.join(st.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=st.loadFromFile(e);return hs=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),hs}function wy(){if(gs!==null)return gs;let e=vs.default.join(st.get("CLAUDE_MEM_DATA_DIR"),"settings.json");return gs=st.loadFromFile(e).CLAUDE_MEM_WORKER_HOST,gs}console.log=(...e)=>{ge.error("CONSOLE","Intercepted console output (MCP protocol protection)",void 0,{args:e})};var $T=Sy(),bT=wy(),ri=`http://${bT}:${$T}`,zy={search:"/api/search",timeline:"/api/timeline"};async function Iy(e,t){ge.debug("SYSTEM","\u2192 Worker API",void 0,{endpoint:e,params:t});try{let r=new URLSearchParams;for(let[a,s]of Object.entries(t))s!=null&&r.append(a,String(s));let n=`${ri}${e}?${r}`,o=await fetch(n);if(!o.ok){let a=await o.text();throw new Error(`Worker API error (${o.status}): ${a}`)}let i=await o.json();return ge.debug("SYSTEM","\u2190 Worker API success",void 0,{endpoint:e}),i}catch(r){return ge.error("SYSTEM","\u2190 Worker API error",{endpoint:e},r),{content:[{type:"text",text:`Error calling Worker API: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}}async function xT(e,t){ge.debug("HTTP","Worker API request (POST)",void 0,{endpoint:e});try{let r=`${ri}${e}`,n=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){let i=await n.text();throw new Error(`Worker API error (${n.status}): ${i}`)}let o=await n.json();return ge.debug("HTTP","Worker API success (POST)",void 0,{endpoint:e}),{content:[{type:"text",text:JSON.stringify(o,null,2)}]}}catch(r){return ge.error("HTTP","Worker API error (POST)",{endpoint:e},r),{content:[{type:"text",text:`Error calling Worker API: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}}async function kT(){try{return(await fetch(`${ri}/api/health`)).ok}catch(e){return ge.debug("SYSTEM","Worker health check failed",{},e),!1}}var Ey=[{name:"__IMPORTANT",description:`3-LAYER WORKFLOW (ALWAYS FOLLOW):
1. search(query) \u2192 Get index with IDs (~50-100 tokens/result)
2. timeline(anchor=ID) \u2192 Get context around interesting results
3. get_observations([IDs]) \u2192 Fetch full details ONLY for filtered IDs
NEVER fetch full details without filtering first. 10x token savings.`,inputSchema:{type:"object",properties:{}},handler:async()=>({content:[{type:"text",text:`# Memory Search Workflow
**3-Layer Pattern (ALWAYS follow this):**
1. **Search** - Get index of results with IDs
\`search(query="...", limit=20, project="...")\`
Returns: Table with IDs, titles, dates (~50-100 tokens/result)
2. **Timeline** - Get context around interesting results
\`timeline(anchor=<ID>, depth_before=3, depth_after=3)\`
Returns: Chronological context showing what was happening
3. **Fetch** - Get full details ONLY for relevant IDs
\`get_observations(ids=[...])\` # ALWAYS batch for 2+ items
Returns: Complete details (~500-1000 tokens/result)
**Why:** 10x token savings. Never fetch full details without filtering first.`}]})},{name:"search",description:"Step 1: Search memory. Returns index with IDs. Params: query, limit, project, type, obs_type, dateStart, dateEnd, offset, orderBy",inputSchema:{type:"object",properties:{},additionalProperties:!0},handler:async e=>{let t=zy.search;return await Iy(t,e)}},{name:"timeline",description:"Step 2: Get context around results. Params: anchor (observation ID) OR query (finds anchor automatically), depth_before, depth_after, project",inputSchema:{type:"object",properties:{},additionalProperties:!0},handler:async e=>{let t=zy.timeline;return await Iy(t,e)}},{name:"get_observations",description:"Step 3: Fetch full details for filtered IDs. Params: ids (array of observation IDs, required), orderBy, limit, project",inputSchema:{type:"object",properties:{ids:{type:"array",items:{type:"number"},description:"Array of observation IDs to fetch (required)"}},required:["ids"],additionalProperties:!0},handler:async e=>await xT("/api/observations/batch",e)}],df=new ps({name:"mcp-search-server",version:"1.0.0"},{capabilities:{tools:{}}});df.setRequestHandler(ud,async()=>({tools:Ey.map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema}))}));df.setRequestHandler(So,async e=>{let t=Ey.find(r=>r.name===e.params.name);if(!t)throw new Error(`Unknown tool: ${e.params.name}`);try{return await t.handler(e.params.arguments||{})}catch(r){return ge.error("SYSTEM","Tool execution failed",{tool:e.params.name},r),{content:[{type:"text",text:`Tool execution failed: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}});async function Ty(){ge.info("SYSTEM","MCP server shutting down"),process.exit(0)}process.on("SIGTERM",Ty);process.on("SIGINT",Ty);async function ST(){let e=new ms;await df.connect(e),ge.info("SYSTEM","Claude-mem search server started"),setTimeout(async()=>{await kT()?ge.info("SYSTEM","Worker available",void 0,{workerUrl:ri}):(ge.warn("SYSTEM","Worker not available",void 0,{workerUrl:ri}),ge.warn("SYSTEM","Tools will fail until Worker is started"),ge.warn("SYSTEM","Start Worker with: npm run worker:restart"))},0)}ST().catch(e=>{ge.error("SYSTEM","Fatal error",void 0,e),process.exit(1)});