@fugood/bricks-cli 2.24.0-beta.4 → 2.24.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -654,7 +654,7 @@ import{createRequire as e}from"node:module";const t=e(import.meta.url);import*as
654
654
  || ${s} === "boolean" || ${r} === null`).assign(p,o._`[${r}]`)}}n.else(),f(e),n.endIf(),n.if(o._`${p} !== undefined`,()=>{n.assign(r,p),function({gen:e,parentData:t,parentDataProperty:a},n){e.if(o._`${t} !== undefined`,()=>e.assign(o._`${t}[${a}]`,n))}(e,p)})}(e,t,s):f(e)})}return l};const d=new Set(["string","number","integer","boolean","null"]);function u(e,t,a,n=p.Correct){const r=n===p.Correct?o.operators.EQ:o.operators.NEQ;let i;switch(e){case"null":return o._`${t} ${r} null`;case"array":i=o._`Array.isArray(${t})`;break;case"object":i=o._`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":i=s(o._`!(${t} % 1) && !isNaN(${t})`);break;case"number":i=s();break;default:return o._`typeof ${t} ${r} ${e}`}return n===p.Correct?i:(0,o.not)(i);function s(e=o.nil){return(0,o.and)(o._`typeof ${t} == "number"`,e,a?o._`isFinite(${t})`:o.nil)}}function c(e,t,a,n){if(1===e.length)return u(e[0],t,a,n);let r;const i=(0,s.toHash)(e);if(i.array&&i.object){const e=o._`typeof ${t} != "object"`;r=i.null?e:o._`!${t} || ${e}`,delete i.null,delete i.array,delete i.object}else r=o.nil;i.number&&delete i.integer;for(const e in i)r=(0,o.and)(r,u(e,t,a,n));return r}t.checkDataType=u,t.checkDataTypes=c;const m={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>"string"==typeof e?o._`{type: ${e}}`:o._`{type: ${t}}`};function f(e){const t=function(e){const{gen:t,data:a,schema:n}=e,r=(0,s.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:a,schema:n.type,schemaCode:r,schemaValue:r,parentSchema:n,params:{},it:e}}(e);(0,i.reportError)(t,m)}t.reportTypeError=f},9005:e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},9011:(e,t,a)=>{var n=a(8250);function r(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var a=function(){var n=arguments,r=t?t.apply(this,n):n[0],i=a.cache;if(i.has(r))return i.get(r);var o=e.apply(this,n);return a.cache=i.set(r,o)||i,o};return a.cache=new(r.Cache||n),a}r.Cache=n,e.exports=r},9041:e=>{e.exports=JSON.parse('{"name":"GeneratorReranker","brickDescription":{"default":"Reranker (GGML)","en-us":"Local rerank based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp) \\n\\n ## Notice \\n - The device RAM must be larger than 8GB \\n - iOS: Recommended use M1+ / A17+ chip device. Supported GPU acceleration by Metal. \\n - macOS: Recommended use M1+ chip device. Supported GPU acceleration by Metal. \\n - Android: Recommended use Android 13+ system. \\n - Supported GPU acceleration by OpenCL, currently only for Qualcomm Adreno 700+ GPUs, other GPUs are not supported. \\n - Supported Hexagon NPU for Qualcomm Snapdragon 8 Gen 2+ GPUs. \\n - Linux / Windows \\n - Supported GPU acceleration, you can choose `vulkan` or `cuda` backend in Accel Variant property \\n - Supported Hexagon NPU for Qualcomm Dragonwing IQ9 series+ (Linux)","zh-tw":"基於 GGML 和 [llama.cpp](https://github.com/ggerganov/llama.cpp) 的本地重排序 \\n\\n ## 注意事項 \\n - 設備 RAM 必須大於 8GB \\n - iOS: 建議使用 M1+ / A17+ 晶片的設備。支援 GPU 加速 by Metal. \\n - macOS: 建議使用 M1+ 晶片的設備。支援 GPU 加速 by Metal. \\n - Android: 建議使用 Android 13+ 系統。 \\n - 支援透過 OpenCL 進行 GPU 加速,目前僅支援 Qualcomm Adreno 700+ 的 GPU,其他 GPU 不支援。 \\n - 支援 Qualcomm Snapdragon 8 Gen 2+ 的 Hexagon NPU。 \\n - Linux / Windows \\n - 支援 GPU 加速,您可以在 Accel Variant 屬性中選擇 `vulkan` 或 `cuda` 後端 \\n - 支援 Qualcomm Dragonwing IQ9 系列+ 的 Hexagon NPU (Linux)","ja-jp":"GGML と [llama.cpp](https://github.com/ggerganov/llama.cpp) をベースにしたローカルリランキング \\n\\n ## 注意事項 \\n - デバイスの RAM は 8GB 以上である必要があります \\n - iOS: M1+ / A17+ チップのデバイスを推奨。Metal による GPU 加速をサポート。 \\n - macOS: M1+ チップのデバイスを推奨。Metal による GPU 加速をサポート。 \\n - Android: Android 13+ システムを推奨。 \\n - OpenCL による GPU 加速をサポート、現在 Qualcomm Adreno 700+ の GPU のみサポート、他の GPU はサポートされていません。 \\n - Qualcomm Snapdragon 8 Gen 2+ の Hexagon NPU をサポート。 \\n - Linux / Windows \\n - GPU 加速をサポート、Accel Variant プロパティで `vulkan` または `cuda` バックエンドを選択できます \\n - Qualcomm Dragonwing IQ9 シリーズ+ の Hexagon NPU をサポート (Linux)"},"brickDisplayName":"Reranker (GGML)","brickTip":{"default":""},"brickMeta":{"preview":true,"scriptMember":true},"brickPreviewIcon":{"type":"font-awesome-6pro","name":"ranking-star"},"propTypes":{"init":{"type":"bool"},"modelUrl":{"type":"string"},"modelHash":{"type":"string"},"modelHashType":{"type":"oneOf","content":["md5","sha256","sha1"],"forcePropertyBank":false},"contextSize":{"type":"number"},"batchSize":{"type":"number"},"uBatchSize":{"type":"number"},"accelVariant":{"type":"oneOf","content":["default","vulkan","cuda","snapdragon"],"forcePropertyBank":false},"devices":{"type":"arrayOf","content":{"type":"string"},"forcePropertyBank":false},"mainGpu":{"type":"number"},"gpuLayers":{"type":"number"},"maxThreads":{"type":"number"},"useMlock":{"type":"bool"},"useMmap":{"type":"bool"},"query":{"type":"string"},"documents":{"type":"arrayOf","content":{"type":"string"},"forcePropertyBank":false},"normalize":{"type":"oneOfType","content":[{"type":"number"},{"type":"bool"}],"forcePropertyBank":false},"topK":{"type":"number"}},"brickPropDescriptions":{"init":{"default":"","en-us":"Initialize the Reranker context on generator initialization","zh-tw":"在生成器初始化時初始化重排序上下文","ja-jp":"ジェネレーター初期化時にリランカーコンテキストを初期化する"},"modelUrl":{"default":"Model Configuration","en-us":"The URL or path of reranker model (GGUF format)","zh-tw":"重排序模型的 URL 或路径(GGUF 格式)","ja-jp":"リランカーモデルのURLまたはパス(GGUF形式)"},"modelHash":{"default":"","en-us":"Hash of reranker model","zh-tw":"重排序模型的哈希值","ja-jp":"リランカーモデルのハッシュ"},"modelHashType":{"default":"","en-us":"Hash type of reranker model","zh-tw":"重排序模型的哈希类型","ja-jp":"リランカーモデルのハッシュタイプ"},"contextSize":{"default":"Context Parameters","en-us":"Context size (0 ~ 4096) (Default to 512)","zh-tw":"上下文大小(0 ~ 4096)(默认为 512)","ja-jp":"コンテキストサイズ(0 ~ 4096)(デフォルト:512)"},"batchSize":{"default":"","en-us":"Logical batch size for processing (default: 512)","zh-tw":"处理的逻辑批次大小(默认:512)","ja-jp":"処理のための論理バッチサイズ(デフォルト:512)"},"uBatchSize":{"default":"","en-us":"Physical maximum batch size (default: 512)","zh-tw":"物理最大批次大小(默认:512)","ja-jp":"物理的な最大バッチサイズ(デフォルト:512)"},"accelVariant":{"default":"Hardware Acceleration","en-us":"GGML accelerator variant (Only for desktop) \\n `default` - CPU / Metal (macOS) \\n `vulkan` - Use Vulkan \\n `cuda` - Use CUDA \\n `snapdragon` - Use OpenCL/Hexagon of Qualcomm Snapdragon","zh-tw":"加速器變體 (僅適用於桌面版) \\n `default` - 使用 CPU / Metal (macOS) \\n `vulkan` - 使用 Vulkan \\n `cuda` - 使用 CUDA \\n `snapdragon` - 使用 OpenCL/Hexagon of Qualcomm Snapdragon","ja-jp":"アクセラレータのバリアント(デスクトップのみ) \\n `default` - CPU / Metal (macOS) \\n `vulkan` - Vulkan を使用 \\n `cuda` - CUDA を使用 \\n `snapdragon` - OpenCL/Hexagon of Qualcomm Snapdragon を使用"},"devices":{"default":"","en-us":"Devices. For example: \\n \\n Metal or CPU for iOS/tvOS/MacOS \\n OpenCL or CPU for Android \\n - Add `HTP0`, `HTP1`, `...` for OpenCL/Hexagon devices (Use HTP* for all HTP devices) \\n For Desktop, you may want to include/exclude GPUs","zh-tw":"裝置。例如: \\n \\n iOS/tvOS/MacOS 使用 Metal 或 CPU \\n Android 使用 OpenCL、CPU \\n - 對於 OpenCL/Hexagon 裝置可新增 `HTP0`、`HTP1`、`...`(使用 HTP* 代表所有 HTP 裝置) \\n 對於桌面版,您可能想要包含/排除 GPU","ja-jp":"デバイス。例: \\n \\n iOS/tvOS/MacOS の場合:Metal また CPU \\n Android の場合:OpenCL、CPU \\n - OpenCL/Hexagon デバイスの場合、`HTP0`、`HTP1`、`...` を追加します(すべての HTP デバイスには HTP* を使用) \\n デスクトップの場合、GPU を含める/除外することができます"},"mainGpu":{"default":"","en-us":"Main GPU index (default: 0)","zh-tw":"主 GPU 索引(默认:0)","ja-jp":"メインGPUインデックス(デフォルト:0)"},"gpuLayers":{"default":"","en-us":"Number of layers to store in VRAM (default: 0)","zh-tw":"存储在 VRAM 中的层数(默认:0)","ja-jp":"VRAMに格納するレイヤー数(デフォルト:0)"},"maxThreads":{"default":"","en-us":"Maximum number of threads to use (default: auto)","zh-tw":"使用的最大线程数(默认:自动)","ja-jp":"使用する最大スレッド数(デフォルト:自動)"},"useMlock":{"default":"Memory Settings","en-us":"Use mlock to keep model in memory (default: true)","zh-tw":"使用 mlock 将模型保持在内存中(默认:true)","ja-jp":"モデルをメモリに保持するためにmlockを使用(デフォルト:true)"},"useMmap":{"default":"","en-us":"Use mmap for model loading (default: true)","zh-tw":"使用 mmap 加载模型(默认:true)","ja-jp":"モデル読み込みにmmapを使用(デフォルト:true)"},"query":{"default":"Reranking Parameters","en-us":"Query text for reranking","zh-tw":"重排序的查询文本","ja-jp":"リランキング用のクエリテキスト"},"documents":{"default":"","en-us":"Array of documents to rerank","zh-tw":"要重排序的文档数组","ja-jp":"リランキングする文書の配列"},"normalize":{"default":"","en-us":"Normalize reranking scores (default: from model config)","zh-tw":"标准化重排序分数(默认:来自模型配置)","ja-jp":"リランキングスコアを正規化(デフォルト:モデル設定から)"},"topK":{"default":"","en-us":"Maximum number of documents to return (default: unlimited)","zh-tw":"返回的最大文档数(默认:无限制)","ja-jp":"返す文書の最大数(デフォルト:無制限)"}},"propertyControls":{"modelUrl":{"kind":"gguf-model-asset","displayName":"URL","normalizeDisplayName":false,"validator":{"fn":"uri","protocols":["https?","file"]},"fields":{"hashType":"modelHashType","hash":"modelHash"},"mediaFields":{"metadata":"_modelMediaMetadata"},"resetPropertiesOnChange":["modelHash"]},"modelHash":{"displayName":"Hash","normalizeDisplayName":false},"modelHashType":{"displayName":"Hash Type","normalizeDisplayName":false,"oneOfEmptyOption":false},"accelVariant":{"displayName":"Accelerator Variant","normalizeDisplayName":false},"mainGpu":{"displayName":"Main GPU","normalizeDisplayName":false},"gpuLayers":{"displayName":"GPU Layers","normalizeDisplayName":false},"maxThreads":{"displayName":"Max Threads","normalizeDisplayName":false},"useMlock":{"displayName":"Use mlock","normalizeDisplayName":false},"useMmap":{"displayName":"Use mmap","normalizeDisplayName":false},"query":{"displayName":"Query","normalizeDisplayName":false,"multiline":true},"documents":{"displayName":"Documents","normalizeDisplayName":false,"kind":"arrayOf","itemKind":"string"},"normalize":{"displayName":"Normalize Scores","normalizeDisplayName":false},"topK":{"displayName":"Top K","normalizeDisplayName":false}},"defaultBrickProps":{"init":false,"contextSize":512,"batchSize":512,"uBatchSize":512,"accelVariant":"default","mainGpu":0,"gpuLayers":0,"useMlock":true,"useMmap":true,"normalize":1},"propertyControlGroups":{"model":{"name":"Model Parameters","type":"group","content":["modelUrl","modelHash","modelHashType"]},"context":{"name":"Context Parameters","type":"group","content":["contextSize","batchSize","uBatchSize"]},"hardware":{"name":"Hardware Acceleration","type":"group","content":["accelVariant","mainGpu","gpuLayers","maxThreads"]},"memory":{"name":"Memory Settings","type":"group","content":["useMlock","useMmap"]},"reranking":{"name":"Reranking Parameters","type":"group","content":["query","documents","normalize","topK"]}},"propertyControlGroupDescriptions":{},"eventTypes":{"GENERATOR_RERANKER_ON_CONTEXT_STATE_CHANGE":"GENERATOR_RERANKER_ON_CONTEXT_STATE_CHANGE","GENERATOR_RERANKER_ON_ERROR":"GENERATOR_RERANKER_ON_ERROR"},"brickEventDescriptions":{"GENERATOR_RERANKER_ON_CONTEXT_STATE_CHANGE":{"default":"","en-us":"Event triggered when the reranker context state changes (loading, ready, error, released)","zh-tw":"當重排序上下文狀態變更時觸發的事件(加載中、就緒、錯誤、已釋放)","ja-jp":"リランカーコンテキストの状態が変更されたときにトリガーされるイベント(読み込み中、準備完了、エラー、解放済み)"},"GENERATOR_RERANKER_ON_ERROR":{"default":"","en-us":"Event triggered when an error occurs during reranker operations","zh-tw":"在重排序操作過程中發生錯誤時觸發的事件","ja-jp":"リランカー操作中にエラーが発生したときにトリガーされるイベント"}},"eventPropertyControls":{"GENERATOR_RERANKER_ON_CONTEXT_STATE_CHANGE":{"properties":{"GENERATOR_RERANKER_CONTEXT_STATE":{"name":"Context State","type":"string"},"GENERATOR_RERANKER_CONTEXT_DETAILS":{"name":"Context Details","type":"object"}}},"GENERATOR_RERANKER_ON_ERROR":{"properties":{"GENERATOR_RERANKER_ERROR":{"name":"Error","type":"string"}}}},"outletTypes":{"GENERATOR_RERANKER_CONTEXT_STATE":{"outlet":"GENERATOR_RERANKER_CONTEXT_STATE","type":"string"},"GENERATOR_RERANKER_CONTEXT_LOAD_PROGRESS":{"outlet":"GENERATOR_RERANKER_CONTEXT_LOAD_PROGRESS","type":"number"},"GENERATOR_RERANKER_CONTEXT_DETAILS":{"outlet":"GENERATOR_RERANKER_CONTEXT_DETAILS","type":"object"},"GENERATOR_RERANKER_RERANK_RESULT":{"outlet":"GENERATOR_RERANKER_RERANK_RESULT","type":"array"},"GENERATOR_RERANKER_IS_PROCESSING":{"outlet":"GENERATOR_RERANKER_IS_PROCESSING","type":"bool"}},"brickOutletDescriptions":{"GENERATOR_RERANKER_CONTEXT_STATE":{"default":"","en-us":"Current state of the reranker context (loading, ready, error, released)","zh-tw":"重排序上下文的當前狀態(加載中、就緒、錯誤、已釋放)","ja-jp":"リランカーコンテキストの現在の状態(読み込み中、準備完了、エラー、解放済み)"},"GENERATOR_RERANKER_CONTEXT_LOAD_PROGRESS":{"default":"","en-us":"Loading progress of the reranker model (0-100)","zh-tw":"重排序模型的加載進度(0-100)","ja-jp":"リランカーモデルの読み込み進捗(0-100)"},"GENERATOR_RERANKER_CONTEXT_DETAILS":{"default":"","en-us":"Detailed information about the reranker context including instance ID and processing status","zh-tw":"關於重排序上下文的詳細信息,包括實例ID和處理狀態","ja-jp":"インスタンスIDと処理状況を含むリランカーコンテキストの詳細情報"},"GENERATOR_RERANKER_RERANK_RESULT":{"default":"","en-us":"Result of the reranking operation containing scored and ranked documents","zh-tw":"包含評分和排序文檔的重排序操作結果","ja-jp":"スコア付きおよびランク付きドキュメントを含むリランキング操作の結果"},"GENERATOR_RERANKER_IS_PROCESSING":{"default":"","en-us":"Boolean indicating whether the reranker is currently processing a request","zh-tw":"表示重排序器是否正在處理請求的布爾值","ja-jp":"リランカーが現在リクエストを処理中かどうかを示すブール値"}},"actionTypes":{"GENERATOR_RERANKER_LOAD_MODEL":{"disallowMultiple":true,"canProvideProperty":false},"GENERATOR_RERANKER_RERANK":{"disallowMultiple":true,"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"GENERATOR_RERANKER_QUERY":{"name":"Query","type":"string"},"GENERATOR_RERANKER_DOCUMENTS":{"name":"Documents","type":"array"}}},"GENERATOR_RERANKER_RELEASE_CONTEXT":{"disallowMultiple":true,"canProvideProperty":false}},"brickActionDescriptions":{"GENERATOR_RERANKER_LOAD_MODEL":{"default":"","en-us":"Load the model","zh-tw":"讀取模型","ja-jp":"モデルを読み込む"},"GENERATOR_RERANKER_RERANK":{"default":"","en-us":"Rerank documents based on query relevance","zh-tw":"根據查詢相關性重新排序文件","ja-jp":"クエリの関連性に基づいてドキュメントを再ランキング"},"GENERATOR_RERANKER_RELEASE_CONTEXT":{"default":"","en-us":"Release context","zh-tw":"釋放上下文","ja-jp":"コンテキストを解放する"}},"scriptMemberFunctionDefs":{"load":{"arguments":[],"required":[],"return":{"type":"bool"}},"getModelInfo":{"arguments":[],"required":[],"return":{"type":"object"}},"rerank":{"arguments":[{"type":"object","name":"params","properties":{"query":{"name":"Query","type":"string"},"documents":{"name":"Documents","type":"array"},"normalize":{"name":"Normalize Scores","type":"number"},"topK":{"name":"Top K","type":"number"}}}],"required":["params"],"return":{"type":"array"}},"isProcessing":{"arguments":[],"required":[],"return":{"type":"bool"}},"release":{"arguments":[],"required":[],"return":{"type":"bool"}}},"scriptMemberFunctionDefDescriptions":{"load":{"default":"","en-us":"Load reranker model","zh-tw":"讀取重排序模型","ja-jp":"リランカーモデルを読み込む"},"getModelInfo":{"default":"","en-us":"Get reranker model information","zh-tw":"取得重排序模型資訊","ja-jp":"リランカーモデル情報を取得"},"rerank":{"default":"","en-us":"Rerank documents based on query relevance","zh-tw":"根據查詢相關性重新排序文件","ja-jp":"クエリの関連性に基づいてドキュメントを再ランキング"},"isProcessing":{"default":"","en-us":"Check if the reranker is currently processing a request","zh-tw":"檢查重排序器是否正在處理請求","ja-jp":"リランカーが現在リクエストを処理中かどうかを確認"},"release":{"default":"","en-us":"Release the reranker context","zh-tw":"釋放重排序上下文","ja-jp":"リランカーコンテキストを解放"}}}')},9067:e=>{e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},9068:(e,t,a)=>{var n=a(4700);e.exports=function(e,t){var a=n(this,e),r=a.size;return a.set(e,t),this.size+=a.size==r?0:1,this}},9073:e=>{e.exports=JSON.parse('{"name":"GeneratorMCP","brickDescription":{"default":"Model Context Protocol (MCP) Client, support SSE and Generator MCPServer direct link","en-us":"Model Context Protocol (MCP) Client, support SSE and Generator MCPServer direct link","zh-tw":"MCP 客戶端,支援 SSE 和 Generator MCPServer 直接連接","ja-jp":"Model Context Protocol (MCP) クライアント、SSE と Generator MCPServer の直接リンクをサポート"},"brickDisplayName":"MCP","brickTip":{"default":""},"brickPreviewIcon":{"type":"material-community","name":"protocol"},"brickMeta":{"canBeGlobalGenerator":true,"scriptMember":true},"propTypes":{"globalGeneratorKey":{"type":"string"},"init":{"type":"bool"},"type":{"type":"oneOf","content":["streamable-http","sse","direct-link"],"forcePropertyBank":false},"url":{"type":"string"},"autoReconnect":{"type":"bool"},"maxReconnectAttempts":{"type":"number"},"reconnectInterval":{"type":"number"},"sseHeaders":{"type":"object"},"sendHeaders":{"type":"object"},"bearerToken":{"type":"string"},"generatorId":{"type":"string"},"generatorKey":{"type":"string"},"name":{"type":"string"},"version":{"type":"string"},"ignoreResourceInList":{"type":"arrayOf","content":{"type":"string"},"forcePropertyBank":false},"ignoreToolInList":{"type":"arrayOf","content":{"type":"string"},"forcePropertyBank":false},"ignorePromptInList":{"type":"arrayOf","content":{"type":"string"},"forcePropertyBank":false},"requestTimeout":{"type":"number"}},"brickPropDescriptions":{"globalGeneratorKey":{"default":"","en-us":"Application-scoped generator key, key cannot be the same with other application-scoped generators","zh-tw":"應用程式範圍的 generator key,key 不能與其他應用程式範圍的 generator 相同","ja-jp":"アプリケーションスコープのジェネレーターキー、キーは他のアプリケーションスコープのジェネレーターと同じにできません"},"init":{"default":"","en-us":"Initialize the MCP client on start","zh-tw":"在啟動時初始化 MCP 客戶端","ja-jp":"起動時に MCP クライアントを初期化する"},"type":{"default":"","en-us":"Type of the MCP connection, e.g. sse or direct-link (generator)","zh-tw":"MCP 連接類型,例如 sse 或 direct-link (generator)","ja-jp":"MCP 接続のタイプ、例えば sse または direct-link (generator)"},"url":{"default":"","en-us":"URL of the MCP server, e.g. http://localhost:19853/sse","zh-tw":"MCP 伺服器的 URL,例如 http://localhost:19853/sse","ja-jp":"MCP サーバーの URL、例えば http://localhost:19853/sse"},"autoReconnect":{"default":"","en-us":"Whether to automatically reconnect to the MCP server","zh-tw":"是否自動重新連接到 MCP 伺服器","ja-jp":"MCP サーバーへの自動再接続を行うかどうか"},"maxReconnectAttempts":{"default":"","en-us":"Maximum number of reconnection attempts","zh-tw":"最大重連嘗試次數","ja-jp":"再接続の最大試行回数"},"reconnectInterval":{"default":"","en-us":"Reconnection interval in milliseconds","zh-tw":"重連間隔(毫秒)","ja-jp":"再接続間隔(ミリ秒)"},"sseHeaders":{"default":"","en-us":"SSE connection headers","zh-tw":"SSE 連線標頭","ja-jp":"SSE 接続ヘッダー"},"sendHeaders":{"default":"","en-us":"Send request headers","zh-tw":"傳送請求標頭","ja-jp":"リクエストヘッダーを送信"},"bearerToken":{"default":"","en-us":"Bearer token for authentication","zh-tw":"用於身份驗證的 Bearer 令牌","ja-jp":"認証用の Bearer トークン"},"generatorId":{"default":"","en-us":"Generator MCP Server ID for direct link","zh-tw":"Generator MCP Server ID,用於直接連接","ja-jp":"直接リンク用の Generator MCP Server ID"},"generatorKey":{"default":"","en-us":"Application-scoped key of Generator MCP Server for direct link (If ID is not provided)","zh-tw":"應用程式範圍的 Generator MCP Server key,用於直接連接(如果 ID 未提供)","ja-jp":"直接リンク用の Generator MCP Server のアプリケーションスコープキー(ID が提供されていない場合)"},"name":{"default":"","en-us":"Name of the MCP client","zh-tw":"MCP 客戶端的名稱","ja-jp":"MCP クライアントの名前"},"version":{"default":"","en-us":"Version of the MCP client","zh-tw":"MCP 客戶端的版本","ja-jp":"MCP クライアントのバージョン"},"ignoreResourceInList":{"default":"","en-us":"Ignore resources in list response","zh-tw":"忽略資源列表回應","ja-jp":"リスト応答内のリソースを無視する"},"ignoreToolInList":{"default":"","en-us":"Ignore tools in list response","zh-tw":"忽略工具列表回應","ja-jp":"リスト応答内のツールを無視する"},"ignorePromptInList":{"default":"","en-us":"Ignore prompts in list response","zh-tw":"忽略提示列表回應","ja-jp":"リスト応答内のプロンプトを無視する"},"requestTimeout":{"default":"","en-us":"Request timeout in milliseconds","zh-tw":"請求超時時間(毫秒)","ja-jp":"リクエストタイムアウト(ミリ秒)"}},"defaultBrickProps":{"init":false,"type":"streamable-http","url":"","autoReconnect":true,"maxReconnectAttempts":10,"reconnectInterval":1000,"generatorId":"","generatorKey":"","name":"bricks-foundation-mcp-client-default","version":"1.0.0","ignoreResourceInList":[],"ignoreToolInList":[],"ignorePromptInList":[],"requestTimeout":60000},"propertyControls":{"type":{"oneOfEmptyOption":false},"url":{"displayName":"URL","normalizeDisplayName":false},"sseHeaders":{"displayName":"SSE Headers","normalizeDisplayName":false},"generatorId":{"displayName":"Generator ID","normalizeDisplayName":false,"kind":"id","idType":"generator","idTypeFilter":["GENERATOR_MCP_SERVER"]}},"propertyControlGroups":{"sse":{"name":"Streamable-HTTP/SSE Config","type":"group","content":["url","sseHeaders","sendHeaders","bearerToken"]},"directLink":{"name":"Direct Link Config","type":"group","content":["generatorId","generatorKey"]},"client":{"name":"Client Config","type":"group","content":["name","version","ignoreToolInList","ignoreResourceInList","ignorePromptInList","requestTimeout"]}},"propertyControlGroupDescriptions":{"directLink":{"default":"","en-us":"Link to existing Generator MCPServer without network","zh-tw":"連接到現有的 Generator MCPServer 而不需要網路","ja-jp":"ネットワークなしで既存の Generator MCPServer に接続"}},"outletTypes":{"GENERATOR_MCP_CONNECTION_STATE":{"outlet":"GENERATOR_MCP_CONNECTION_STATE","type":"string"},"GENERATOR_MCP_LIST_RESOURCES_RESPONSE":{"outlet":"GENERATOR_MCP_LIST_RESOURCES_RESPONSE","type":"object"},"GENERATOR_MCP_LIST_RESOURCES_ERROR":{"outlet":"GENERATOR_MCP_LIST_RESOURCES_ERROR","type":"object"},"GENERATOR_MCP_LIST_RESOURCE_TEMPLATES_RESPONSE":{"outlet":"GENERATOR_MCP_LIST_RESOURCE_TEMPLATES_RESPONSE","type":"object"},"GENERATOR_MCP_LIST_RESOURCE_TEMPLATES_ERROR":{"outlet":"GENERATOR_MCP_LIST_RESOURCE_TEMPLATES_ERROR","type":"object"},"GENERATOR_MCP_READ_RESOURCE_RESPONSE":{"outlet":"GENERATOR_MCP_READ_RESOURCE_RESPONSE","type":"object"},"GENERATOR_MCP_READ_RESOURCE_ERROR":{"outlet":"GENERATOR_MCP_READ_RESOURCE_ERROR","type":"object"},"GENERATOR_MCP_LIST_TOOLS_RESPONSE":{"outlet":"GENERATOR_MCP_LIST_TOOLS_RESPONSE","type":"object"},"GENERATOR_MCP_LIST_TOOLS_ERROR":{"outlet":"GENERATOR_MCP_LIST_TOOLS_ERROR","type":"object"},"GENERATOR_MCP_CALL_TOOL_RESPONSE":{"outlet":"GENERATOR_MCP_CALL_TOOL_RESPONSE","type":"object"},"GENERATOR_MCP_CALL_TOOL_ERROR":{"outlet":"GENERATOR_MCP_CALL_TOOL_ERROR","type":"object"},"GENERATOR_MCP_LIST_PROMPTS_RESPONSE":{"outlet":"GENERATOR_MCP_LIST_PROMPTS_RESPONSE","type":"object"},"GENERATOR_MCP_LIST_PROMPTS_ERROR":{"outlet":"GENERATOR_MCP_LIST_PROMPTS_ERROR","type":"object"},"GENERATOR_MCP_GET_PROMPT_RESPONSE":{"outlet":"GENERATOR_MCP_GET_PROMPT_RESPONSE","type":"object"},"GENERATOR_MCP_GET_PROMPT_ERROR":{"outlet":"GENERATOR_MCP_GET_PROMPT_ERROR","type":"object"},"GENERATOR_MCP_LAST_ERROR":{"outlet":"GENERATOR_MCP_LAST_ERROR","type":"string"}},"brickOutletDescriptions":{"GENERATOR_MCP_CONNECTION_STATE":{"default":"","en-us":"Connection state","zh-tw":"連線狀態","ja-jp":"接続状態"},"GENERATOR_MCP_LIST_RESOURCES_RESPONSE":{"default":"","en-us":"List resources response","zh-tw":"列出資源回應","ja-jp":"リソースのリスト応答"},"GENERATOR_MCP_LIST_RESOURCES_ERROR":{"default":"","en-us":"List resources error","zh-tw":"列出資源錯誤","ja-jp":"リソースのリストエラー"},"GENERATOR_MCP_LIST_RESOURCE_TEMPLATES_RESPONSE":{"default":"","en-us":"List resource templates response","zh-tw":"列出資源範本回應","ja-jp":"リソーステンプレートのリスト応答"},"GENERATOR_MCP_LIST_RESOURCE_TEMPLATES_ERROR":{"default":"","en-us":"List resource templates error","zh-tw":"列出資源範本錯誤","ja-jp":"リソーステンプレートのリストエラー"},"GENERATOR_MCP_READ_RESOURCE_RESPONSE":{"default":"","en-us":"Read resource response","zh-tw":"讀取資源回應","ja-jp":"リソースの読み取り応答"},"GENERATOR_MCP_READ_RESOURCE_ERROR":{"default":"","en-us":"Read resource error","zh-tw":"讀取資源錯誤","ja-jp":"リソースの読み取りエラー"},"GENERATOR_MCP_LIST_TOOLS_RESPONSE":{"default":"","en-us":"List tools response","zh-tw":"列出工具回應","ja-jp":"ツールのリスト応答"},"GENERATOR_MCP_LIST_TOOLS_ERROR":{"default":"","en-us":"List tools error","zh-tw":"列出工具錯誤","ja-jp":"ツールのリストエラー"},"GENERATOR_MCP_CALL_TOOL_RESPONSE":{"default":"","en-us":"Call tool response","zh-tw":"呼叫工具回應","ja-jp":"ツールの呼び出し応答"},"GENERATOR_MCP_CALL_TOOL_ERROR":{"default":"","en-us":"Call tool error","zh-tw":"呼叫工具錯誤","ja-jp":"ツールの呼び出しエラー"},"GENERATOR_MCP_LIST_PROMPTS_RESPONSE":{"default":"","en-us":"List prompts response","zh-tw":"列出提示回應","ja-jp":"プロンプトのリスト応答"},"GENERATOR_MCP_LIST_PROMPTS_ERROR":{"default":"","en-us":"List prompts error","zh-tw":"列出提示錯誤","ja-jp":"プロンプトのリストエラー"},"GENERATOR_MCP_GET_PROMPT_RESPONSE":{"default":"","en-us":"Get prompt response","zh-tw":"獲取提示回應","ja-jp":"プロンプトの取得応答"},"GENERATOR_MCP_GET_PROMPT_ERROR":{"default":"","en-us":"Request prompt error","zh-tw":"請求提示錯誤","ja-jp":"プロンプトの取得エラー"},"GENERATOR_MCP_LAST_ERROR":{"default":"","en-us":"Last error","zh-tw":"最後的錯誤","ja-jp":"最後のエラー"}},"eventTypes":{"GENERATOR_MCP_ON_CONNECTED":"GENERATOR_MCP_ON_CONNECTED","GENERATOR_MCP_ON_CONNECTION_ERROR":"GENERATOR_MCP_ON_CONNECTION_ERROR","GENERATOR_MCP_ON_DISCONNECTED":"GENERATOR_MCP_ON_DISCONNECTED","GENERATOR_MCP_ON_LIST_RESOURCES":"GENERATOR_MCP_ON_LIST_RESOURCES","GENERATOR_MCP_ON_LIST_RESOURCES_ERROR":"GENERATOR_MCP_ON_LIST_RESOURCES_ERROR","GENERATOR_MCP_ON_LIST_RESOURCE_TEMPLATES":"GENERATOR_MCP_ON_LIST_RESOURCE_TEMPLATES","GENERATOR_MCP_ON_LIST_RESOURCE_TEMPLATES_ERROR":"GENERATOR_MCP_ON_LIST_RESOURCE_TEMPLATES_ERROR","GENERATOR_MCP_ON_READ_RESOURCE":"GENERATOR_MCP_ON_READ_RESOURCE","GENERATOR_MCP_ON_READ_RESOURCE_ERROR":"GENERATOR_MCP_ON_READ_RESOURCE_ERROR","GENERATOR_MCP_ON_LIST_TOOLS":"GENERATOR_MCP_ON_LIST_TOOLS","GENERATOR_MCP_ON_LIST_TOOLS_ERROR":"GENERATOR_MCP_ON_LIST_TOOLS_ERROR","GENERATOR_MCP_ON_CALL_TOOL":"GENERATOR_MCP_ON_CALL_TOOL","GENERATOR_MCP_ON_CALL_TOOL_ERROR":"GENERATOR_MCP_ON_CALL_TOOL_ERROR","GENERATOR_MCP_ON_LIST_PROMPTS":"GENERATOR_MCP_ON_LIST_PROMPTS","GENERATOR_MCP_ON_LIST_PROMPTS_ERROR":"GENERATOR_MCP_ON_LIST_PROMPTS_ERROR","GENERATOR_MCP_ON_GET_PROMPT":"GENERATOR_MCP_ON_GET_PROMPT","GENERATOR_MCP_ON_GET_PROMPT_ERROR":"GENERATOR_MCP_ON_GET_PROMPT_ERROR"},"brickEventDescriptions":{"GENERATOR_MCP_ON_CONNECTED":{"default":"","en-us":"On connected","zh-tw":"當連接時","ja-jp":"接続時"},"GENERATOR_MCP_ON_CONNECTION_ERROR":{"default":"","en-us":"On connection error","zh-tw":"當連接錯誤時","ja-jp":"接続エラー時"},"GENERATOR_MCP_ON_DISCONNECTED":{"default":"","en-us":"On disconnected","zh-tw":"當斷開連接時","ja-jp":"断開時"},"GENERATOR_MCP_ON_LIST_RESOURCES":{"default":"","en-us":"On list resources","zh-tw":"當列出資源時","ja-jp":"リソースのリスト時"},"GENERATOR_MCP_ON_LIST_RESOURCES_ERROR":{"default":"","en-us":"On list resources error","zh-tw":"當列出資源錯誤時","ja-jp":"リストエラー時"},"GENERATOR_MCP_ON_LIST_RESOURCE_TEMPLATES":{"default":"","en-us":"On list resource templates","zh-tw":"當列出資源範本時","ja-jp":"リソーステンプレートのリスト時"},"GENERATOR_MCP_ON_LIST_RESOURCE_TEMPLATES_ERROR":{"default":"","en-us":"On list resource templates error","zh-tw":"當列出資源範本錯誤時","ja-jp":"リストエラー時"},"GENERATOR_MCP_ON_READ_RESOURCE":{"default":"","en-us":"On read resource","zh-tw":"當讀取資源時","ja-jp":"リソースの読み取り時"},"GENERATOR_MCP_ON_READ_RESOURCE_ERROR":{"default":"","en-us":"On read resource error","zh-tw":"當讀取資源錯誤時","ja-jp":"リソースの読み取りエラー時"},"GENERATOR_MCP_ON_LIST_TOOLS":{"default":"","en-us":"On list tools","zh-tw":"當列出工具時","ja-jp":"ツールのリスト時"},"GENERATOR_MCP_ON_LIST_TOOLS_ERROR":{"default":"","en-us":"On list tools error","zh-tw":"當列出工具錯誤時","ja-jp":"ツールのリストエラー時"},"GENERATOR_MCP_ON_CALL_TOOL":{"default":"","en-us":"On call tool","zh-tw":"當呼叫工具時","ja-jp":"ツールの呼び出し時"},"GENERATOR_MCP_ON_CALL_TOOL_ERROR":{"default":"","en-us":"On call tool error","zh-tw":"當呼叫工具錯誤時","ja-jp":"ツールの呼び出しエラー時"},"GENERATOR_MCP_ON_LIST_PROMPTS":{"default":"","en-us":"On list prompts","zh-tw":"當列出提示時","ja-jp":"プロンプトのリスト時"},"GENERATOR_MCP_ON_LIST_PROMPTS_ERROR":{"default":"","en-us":"On list prompts error","zh-tw":"當列出提示錯誤時","ja-jp":"プロンプトのリストエラー時"},"GENERATOR_MCP_ON_GET_PROMPT":{"default":"","en-us":"On get prompt","zh-tw":"當獲取提示時","ja-jp":"プロンプトの取得時"},"GENERATOR_MCP_ON_GET_PROMPT_ERROR":{"default":"","en-us":"On get prompt error","zh-tw":"當獲取提示錯誤時","ja-jp":"プロンプトの取得エラー時"}},"eventPropertyControls":{"GENERATOR_MCP_ON_CONNECTION_ERROR":{"properties":{"GENERATOR_MCP_ERROR_MESSAGE":{"name":"Error","type":"string"}}},"GENERATOR_MCP_ON_LIST_RESOURCES":{"properties":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID","type":"string"},"GENERATOR_MCP_RESPONSE":{"name":"Response","type":"object"}}},"GENERATOR_MCP_ON_LIST_RESOURCES_ERROR":{"properties":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID","type":"string"},"GENERATOR_MCP_ERROR_MESSAGE":{"name":"Error","type":"string"}}},"GENERATOR_MCP_ON_LIST_RESOURCE_TEMPLATES":{"properties":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID","type":"string"},"GENERATOR_MCP_RESPONSE":{"name":"Response","type":"object"}}},"GENERATOR_MCP_ON_LIST_RESOURCE_TEMPLATES_ERROR":{"properties":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID","type":"string"},"GENERATOR_MCP_ERROR_MESSAGE":{"name":"Error","type":"string"}}},"GENERATOR_MCP_ON_READ_RESOURCE":{"properties":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID","type":"string"},"GENERATOR_MCP_RESPONSE":{"name":"Response","type":"object"}}},"GENERATOR_MCP_ON_READ_RESOURCE_ERROR":{"properties":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID","type":"string"},"GENERATOR_MCP_ERROR_MESSAGE":{"name":"Error","type":"string"}}},"GENERATOR_MCP_ON_LIST_TOOLS":{"properties":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID","type":"string"},"GENERATOR_MCP_RESPONSE":{"name":"Response","type":"object"}}},"GENERATOR_MCP_ON_LIST_TOOLS_ERROR":{"properties":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID","type":"string"},"GENERATOR_MCP_ERROR_MESSAGE":{"name":"Error","type":"string"}}},"GENERATOR_MCP_ON_CALL_TOOL":{"properties":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID","type":"string"},"GENERATOR_MCP_RESPONSE":{"name":"Response","type":"object"}}},"GENERATOR_MCP_ON_CALL_TOOL_ERROR":{"properties":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID","type":"string"},"GENERATOR_MCP_ERROR_MESSAGE":{"name":"Error","type":"string"}}},"GENERATOR_MCP_ON_LIST_PROMPTS":{"properties":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID","type":"string"},"GENERATOR_MCP_RESPONSE":{"name":"Response","type":"object"}}},"GENERATOR_MCP_ON_LIST_PROMPTS_ERROR":{"properties":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID","type":"string"},"GENERATOR_MCP_ERROR_MESSAGE":{"name":"Error","type":"string"}}},"GENERATOR_MCP_ON_GET_PROMPT":{"properties":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID","type":"string"},"GENERATOR_MCP_RESPONSE":{"name":"Response","type":"object"}}},"GENERATOR_MCP_ON_GET_PROMPT_ERROR":{"properties":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID","type":"string"},"GENERATOR_MCP_ERROR_MESSAGE":{"name":"Error","type":"string"}}}},"actionTypes":{"GENERATOR_MCP_CONNECT":{"canProvideProperty":false},"GENERATOR_MCP_DISCONNECT":{"canProvideProperty":false},"GENERATOR_MCP_LIST_RESOURCES":{"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID (Custom)","type":"string"}}},"GENERATOR_MCP_LIST_RESOURCE_TEMPLATES":{"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID (Custom)","type":"string"}}},"GENERATOR_MCP_READ_RESOURCE":{"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID (Custom)","type":"string"},"GENERATOR_MCP_URI":{"name":"Resource URI","type":"string"},"GENERATOR_MCP_VARIABLES":{"name":"Variables","type":"object","popover":true,"schema":{"allowCustomProperty":true,"type":"object","properties":{}}}}},"GENERATOR_MCP_LIST_TOOLS":{"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID (Custom)","type":"string"}}},"GENERATOR_MCP_CALL_TOOL":{"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID (Custom)","type":"string"},"GENERATOR_MCP_NAME":{"name":"Tool Name","type":"string"},"GENERATOR_MCP_VARIABLES":{"name":"Variables","type":"object","popover":true,"schema":{"allowCustomProperty":true,"type":"object","properties":{}}}}},"GENERATOR_MCP_LIST_PROMPTS":{"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID (Custom)","type":"string"}}},"GENERATOR_MCP_GET_PROMPT":{"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"GENERATOR_MCP_REQUEST_ID":{"name":"Request ID (Custom)","type":"string"},"GENERATOR_MCP_NAME":{"name":"Prompt Name","type":"string"},"GENERATOR_MCP_VARIABLES":{"name":"Arguments","type":"object","popover":true,"schema":{"allowCustomProperty":true,"type":"object","properties":{}}}}}},"brickActionDescriptions":{"GENERATOR_MCP_CONNECT":{"default":"","en-us":"Connect to MCP server","zh-tw":"連接到 MCP 伺服器","ja-jp":"MCP サーバーに接続"},"GENERATOR_MCP_DISCONNECT":{"default":"","en-us":"Disconnect from MCP server","zh-tw":"從 MCP 伺服器斷開連接","ja-jp":"MCP サーバーから切断"},"GENERATOR_MCP_LIST_RESOURCES":{"default":"","en-us":"List resources","zh-tw":"列出資源","ja-jp":"リソースのリスト"},"GENERATOR_MCP_LIST_RESOURCE_TEMPLATES":{"default":"","en-us":"List resource templates","zh-tw":"列出資源範本","ja-jp":"リソーステンプレートのリスト"},"GENERATOR_MCP_READ_RESOURCE":{"default":"","en-us":"Read resource","zh-tw":"讀取資源","ja-jp":"リソースの読み取り"},"GENERATOR_MCP_LIST_TOOLS":{"default":"","en-us":"List tools","zh-tw":"列出工具","ja-jp":"ツールのリスト"},"GENERATOR_MCP_CALL_TOOL":{"default":"","en-us":"Call tool","zh-tw":"呼叫工具","ja-jp":"ツールの呼び出し"},"GENERATOR_MCP_LIST_PROMPTS":{"default":"","en-us":"List prompts","zh-tw":"列出提示","ja-jp":"プロンプトのリスト"},"GENERATOR_MCP_GET_PROMPT":{"default":"","en-us":"Request prompt","zh-tw":"請求提示","ja-jp":"プロンプトの要求"}},"scriptMemberFunctionDefs":{"connect":{"arguments":[],"required":[],"return":{"type":"bool"}},"disconnect":{"arguments":[],"required":[],"return":{"type":"void"}},"getConnectionState":{"arguments":[],"required":[],"return":{"type":"string"}},"getLastError":{"arguments":[],"required":[],"return":{"type":"string"}},"listResources":{"arguments":[{"type":"object","name":"options","properties":{"requestId":{"name":"Request ID","type":"string"}}}],"required":[],"return":{"type":"object"}},"listResourceTemplates":{"arguments":[{"type":"object","name":"options","properties":{"requestId":{"name":"Request ID","type":"string"}}}],"required":[],"return":{"type":"object"}},"readResource":{"arguments":[{"type":"object","name":"options","properties":{"uri":{"name":"Resource URI","type":"string"},"variables":{"name":"Variables","type":"object"},"requestId":{"name":"Request ID","type":"string"}}}],"required":["uri"],"return":{"type":"object"}},"listTools":{"arguments":[{"type":"object","name":"options","properties":{"requestId":{"name":"Request ID","type":"string"}}}],"required":[],"return":{"type":"object"}},"callTool":{"arguments":[{"type":"object","name":"options","properties":{"name":{"name":"Tool Name","type":"string"},"arguments":{"name":"Arguments","type":"object"},"requestId":{"name":"Request ID","type":"string"}}}],"required":["name"],"return":{"type":"object"}},"listPrompts":{"arguments":[{"type":"object","name":"options","properties":{"requestId":{"name":"Request ID","type":"string"}}}],"required":[],"return":{"type":"object"}},"getPrompt":{"arguments":[{"type":"object","name":"options","properties":{"name":{"name":"Prompt Name","type":"string"},"arguments":{"name":"Arguments","type":"object"},"requestId":{"name":"Request ID","type":"string"}}}],"required":["name"],"return":{"type":"object"}}},"scriptMemberFunctionDefDescriptions":{"connect":{"default":"","en-us":"Connect to MCP server","zh-tw":"連接到 MCP 伺服器","ja-jp":"MCP サーバーに接続する"},"disconnect":{"default":"","en-us":"Disconnect from MCP server","zh-tw":"從 MCP 伺服器斷開連接","ja-jp":"MCP サーバーから切断する"},"getConnectionState":{"default":"","en-us":"Get connection state","zh-tw":"取得連線狀態","ja-jp":"接続状態を取得する"},"getLastError":{"default":"","en-us":"Get last error","zh-tw":"取得最後的錯誤","ja-jp":"最後のエラーを取得する"},"listResources":{"default":"","en-us":"List resources from MCP server","zh-tw":"列出 MCP 伺服器的資源","ja-jp":"MCP サーバーからリソースをリストする"},"listResourceTemplates":{"default":"","en-us":"List resource templates from MCP server","zh-tw":"列出 MCP 伺服器的資源範本","ja-jp":"MCP サーバーからリソーステンプレートをリストする"},"readResource":{"default":"","en-us":"Read a resource from MCP server","zh-tw":"從 MCP 伺服器讀取資源","ja-jp":"MCP サーバーからリソースを読み取る"},"listTools":{"default":"","en-us":"List tools from MCP server","zh-tw":"列出 MCP 伺服器的工具","ja-jp":"MCP サーバーからツールをリストする"},"callTool":{"default":"","en-us":"Call a tool on MCP server","zh-tw":"呼叫 MCP 伺服器上的工具","ja-jp":"MCP サーバー上のツールを呼び出す"},"listPrompts":{"default":"","en-us":"List prompts from MCP server","zh-tw":"列出 MCP 伺服器的提示","ja-jp":"MCP サーバーからプロンプトをリストする"},"getPrompt":{"default":"","en-us":"Get a prompt from MCP server","zh-tw":"從 MCP 伺服器取得提示","ja-jp":"MCP サーバーからプロンプトを取得する"}}}')},9074:(e,t,a)=>{a.d(t,{C:()=>u});var n=a(9212),r=a(3673),i=a(6192),o=a(6878),s=a(8414);function p(e,t){return t?t(e):r.c.of()}function l(e){return"function"==typeof e?new u(e):e}function d(e){return e.request.length<=1}var u=function(){function e(e){e&&(this.request=e)}return e.empty=function(){return new e(function(){return r.c.of()})},e.from=function(t){return 0===t.length?e.empty():t.map(l).reduce(function(e,t){return e.concat(t)})},e.split=function(t,a,n){var i,o=l(a),s=l(n||new e(p));return i=d(o)&&d(s)?new e(function(e){return t(e)?o.request(e)||r.c.of():s.request(e)||r.c.of()}):new e(function(e,a){return t(e)?o.request(e,a)||r.c.of():s.request(e,a)||r.c.of()}),Object.assign(i,{left:o,right:s})},e.execute=function(e,t){return e.request((0,o.k)(t.context,(0,s.A)((0,i.K)(t))))||r.c.of()},e.concat=function(t,a){var i=l(t);if(d(i))return!1!==globalThis.__DEV__&&n.invariant.warn(38,i),i;var o,s=l(a);return o=d(s)?new e(function(e){return i.request(e,function(e){return s.request(e)||r.c.of()})||r.c.of()}):new e(function(e,t){return i.request(e,function(e){return s.request(e,t)||r.c.of()})||r.c.of()}),Object.assign(o,{left:i,right:s})},e.prototype.split=function(t,a,n){return this.concat(e.split(t,a,n||new e(p)))},e.prototype.concat=function(t){return e.concat(this,t)},e.prototype.request=function(e,t){throw(0,n.newInvariantError)(39)},e.prototype.onError=function(e,t){if(t&&t.error)return t.error(e),!1;throw e},e.prototype.setOnError=function(e){return this.onError=e,this},e}()},9122:(e,t,a)=>{a.d(t,{A:()=>r});var n=a(1708);function r(){const{env:e}=n,{TERM:t,TERM_PROGRAM:a}=e;return"win32"!==n.platform?"linux"!==t:Boolean(e.WT_SESSION)||Boolean(e.TERMINUS_SUBLIME)||"{cmd::Cmder}"===e.ConEmuTask||"Terminus-Sublime"===a||"vscode"===a||"xterm-256color"===t||"alacritty"===t||"rxvt-unicode"===t||"rxvt-unicode-256color"===t||"JetBrains-JediTerm"===e.TERMINAL_EMULATOR}},9212:(e,t,a)=>{a.d(t,{DEV:()=>_,InvariantError:()=>n.InvariantError,__DEV__:()=>_,global:()=>o,invariant:()=>l,maybe:()=>i,newInvariantError:()=>d}),a.r(t);var n=a(9371),r=a(3972);function i(e){try{return e()}catch(e){}}const o=i(function(){return globalThis})||i(function(){return window})||i(function(){return self})||i(function(){return global})||i(function(){return i.constructor("return this")()});var s=a(6563);function p(e){return function(t){for(var a=[],n=1;n<arguments.length;n++)a[n-1]=arguments[n];if("number"==typeof t){var r=t;(t=m(r))||(t=f(r,a),a=[])}e.apply(void 0,[t].concat(a))}}var l=Object.assign(function(e,t){for(var a=[],r=2;r<arguments.length;r++)a[r-2]=arguments[r];e||(0,n.invariant)(e,m(t,a)||f(t,a))},{debug:p(n.invariant.debug),log:p(n.invariant.log),warn:p(n.invariant.warn),error:p(n.invariant.error)});function d(e){for(var t=[],a=1;a<arguments.length;a++)t[a-1]=arguments[a];return new n.InvariantError(m(e,t)||f(e,t))}var u=Symbol.for("ApolloErrorMessageHandler_"+r.r);function c(e){if("string"==typeof e)return e;try{return(0,s.p)(e,2).slice(0,1e3)}catch(e){return"<non-serializable>"}}function m(e,t){if(void 0===t&&(t=[]),e)return o[u]&&o[u](e,t.map(c))}function f(e,t){if(void 0===t&&(t=[]),e)return"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:r.r,message:e,args:t.map(c)})))}var _=!1!==globalThis.__DEV__},9218:e=>{e.exports=JSON.parse('{"name":"GeneratorUDP","brickDescription":{"default":"","en-us":"TCP Server","zh-tw":"TCP 伺服器","ja-jp":"TCPサーバー"},"brickDisplayName":"UDP","brickTip":{"default":""},"brickMeta":{"scriptMember":true},"brickPreviewIcon":{"type":"material-community","name":"network-outline"},"propTypes":{"init":{"type":"bool"},"type":{"type":"oneOf","content":["udp4","udp6"],"forcePropertyBank":false},"encoding":{"type":"oneOf","content":["base64","utf8","ascii"],"forcePropertyBank":false},"localPort":{"type":"number"},"broadcast":{"type":"bool"},"multicast":{"type":"string"}},"brickPropDescriptions":{"init":{"default":"","en-us":"Bind port on generator initialized","zh-tw":"Generator 初始化後直接啟動","ja-jp":"ジェネレータの初期化時にポートをバインドする"},"type":{"default":"","en-us":"The family of socket","zh-tw":"接口種類","ja-jp":"ソケットファミリー"},"encoding":{"default":"","en-us":"Encoding of data","zh-tw":"資料編碼","ja-jp":"データのエンコーディング"},"localPort":{"default":"","en-us":"Local bind port of UDP (0 or empty is random)","zh-tw":"UDP 本地連接埠(0 或留空為隨機)","ja-jp":"UDPのローカルバインドポート(0または空は任意)"},"broadcast":{"default":"","en-us":"Enable receive broadcast packets","zh-tw":"啟動接收廣播封包","ja-jp":"ブロードキャストパケットの受信を有効にする"},"multicast":{"default":"","en-us":"Join multicast group (Multicast address)","zh-tw":"加入多播群組(多播位置)","ja-jp":"マルチキャストグループに参加する(マルチキャストアドレス)"}},"defaultBrickProps":{"init":false,"type":"udp4","encoding":"base64","broadcast":false,"multicast":""},"propertyControls":{"localPort":{"required":true}},"outletTypes":{"GENERATOR_UDP_PORT":{"outlet":"GENERATOR_UDP_PORT","type":"number"},"GENERATOR_UDP_LAST_RECEIVE":{"outlet":"GENERATOR_UDP_LAST_RECEIVE","type":"object"},"GENERATOR_UDP_ERROR_MESSAGE":{"outlet":"GENERATOR_UDP_ERROR_MESSAGE","type":"string"}},"brickOutletDescriptions":{"GENERATOR_UDP_PORT":{"default":"","en-us":"Local UDP binded port","zh-tw":"本地 UDP 連接埠","ja-jp":"ローカルUDPバインドポート"},"GENERATOR_UDP_LAST_RECEIVE":{"default":"","en-us":"Last received packet","zh-tw":"最後收到的封包","ja-jp":"最後に受信したパケット"},"GENERATOR_UDP_ERROR_MESSAGE":{"default":"","en-us":"Error message","zh-tw":"錯誤訊息","ja-jp":"エラーメッセージ"}},"eventTypes":{"GENERATOR_UDP_ON_READY":"GENERATOR_UDP_ON_READY","GENERATOR_UDP_ON_DATA":"GENERATOR_UDP_ON_DATA","GENERATOR_UDP_ON_CLOSE":"GENERATOR_UDP_ON_CLOSE","GENERATOR_UDP_ON_ERROR":"GENERATOR_UDP_ON_ERROR"},"brickEventDescriptions":{"GENERATOR_UDP_ON_READY":{"default":"","en-us":"Event of UDP port is binded","zh-tw":"當 UDP 伺服器啟動完成時觸發事件","ja-jp":"UDPポートがバインドされた時のイベント"},"GENERATOR_UDP_ON_DATA":{"default":"","en-us":"Event of receive data","zh-tw":"當收到資料時觸發事件","ja-jp":"データを受信した時のイベント"},"GENERATOR_UDP_ON_CLOSE":{"default":"","en-us":"Event of socket closeed","zh-tw":"當接口結束時觸發事件","ja-jp":"ソケットが閉じられた時のイベント"},"GENERATOR_UDP_ON_ERROR":{"default":"","en-us":"Event of socket error","zh-tw":"當接口發生錯誤時觸發事件","ja-jp":"ソケットエラー発生時のイベント"}},"eventPropertyControls":{"GENERATOR_UDP_ON_DATA":{"properties":{"GENERATOR_UDP_REMOTE_ADDRESS":{"name":"Address","type":"string"},"GENERATOR_UDP_REMOTE_PORT":{"name":"Port","type":"number"},"GENERATOR_UDP_DATA":{"name":"Data","type":"string"}}},"GENERATOR_UDP_ON_ERROR":{"properties":{"GENERATOR_UDP_ERROR_MESSAGE":{"name":"Error","type":"string"}}}},"actionTypes":{"GENERATOR_UDP_BIND":{"disallowMultiple":true,"canProvideProperty":false},"GENERATOR_UDP_SEND":{"disallowMultiple":false,"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"GENERATOR_UDP_TARGET_HOST":{"name":"Host","type":"string"},"GENERATOR_UDP_TARGET_PORT":{"name":"Port","type":"number"},"GENERATOR_UDP_SEND_DATA":{"name":"Data","type":"string"}}},"GENERATOR_UDP_CLOSE":{"disallowMultiple":true,"canProvideProperty":false}},"brickActionDescriptions":{"GENERATOR_UDP_BIND":{"default":"","en-us":"Bind UDP port","zh-tw":"綁定 UDP 連接埠","ja-jp":"UDPポートをバインドする"},"GENERATOR_UDP_SEND":{"default":"","en-us":"Send data to target","zh-tw":"傳送資料到目標位置","ja-jp":"ターゲットにデータを送信する"},"GENERATOR_UDP_CLOSE":{"default":"","en-us":"Close UDP","zh-tw":"關閉 UDP","ja-jp":"UDPを閉じる"}},"scriptMemberFunctionDefs":{"getStatus":{"arguments":[],"required":[],"return":{"type":"object"}},"bind":{"arguments":[],"required":[],"return":{"type":"void"}},"send":{"arguments":[{"name":"data","type":"string"}],"required":[],"return":{"type":"void"}},"close":{"arguments":[],"required":[],"return":{"type":"void"}}},"scriptMemberFunctionDefDescriptions":{"getStatus":{"default":"","en-us":"Get the status of the UDP","zh-tw":"取得 UDP 的狀態","ja-jp":"UDPの状態を取得"},"bind":{"default":"","en-us":"Bind the UDP port","zh-tw":"綁定 UDP 連接埠","ja-jp":"UDPポートをバインドする"},"send":{"default":"","en-us":"Send data to the UDP","zh-tw":"傳送資料到 UDP","ja-jp":"UDPにデータを送信する"},"close":{"default":"","en-us":"Close the UDP","zh-tw":"關閉 UDP","ja-jp":"UDPを閉じる"}}}')},9220:e=>{e.exports=JSON.parse('{"name":"BrickVideoStreaming","brickDescription":{"default":"Brick video streaming component, supports RTSP / RTMP streaming."},"brickDisplayName":"Video Streaming","brickTip":{"default":"@brick-tip-video-streaming","en-us":"Add Video Streaming with URI, Cache, Ratio, etc. setting.","zh-tw":"串流影片元件,可透過 URI 設定來源,另可變更快取、比例等多種控制設定","ja-jp":"URI、キャッシュ、比率などの設定でビデオストリーミングを追加します。"},"brickMeta":{"pressable":true},"brickPreviewIcon":{"type":"font-awesome-6pro","name":"tower-broadcast"},"propTypes":{"uri":{"type":"string","isRequired":true},"networkCaching":{"type":"number"},"paused":{"type":"bool"},"volume":{"type":"number"},"muted":{"type":"bool"},"autoAspectRatio":{"type":"bool"},"aspectRatio":{"type":"string"},"repeat":{"type":"bool"},"replayOnError":{"type":"bool"},"replayTimeout":{"type":"number"}},"brickPropDescriptions":{"uri":{"default":"","en-us":"The video path list or single path (File, URL)","zh-tw":"Video 的播放清單或單一檔案 (File, URL)","ja-jp":"ビデオのパスリストまたは単一パス(ファイル、URL)"},"networkCaching":{"default":"","en-us":"Set cache time from streaming (You can adjust according to network conditions), it will delay the playing.","zh-tw":"設置快取時間(你可以視網路情況調整),如此將會延遲播放時間","ja-jp":"ストリーミングからキャッシュ時間を設定します(ネットワーク状況に応じて調整可能)、再生が遅延します。"},"paused":{"default":"","en-us":"Controls whether the video is paused","zh-tw":"控制影片是否暂停","ja-jp":"ビデオが一時停止しているかどうかを制御"},"volume":{"default":"","en-us":"Volume","zh-tw":"音量","ja-jp":"音量"},"muted":{"default":"","en-us":"Muted","zh-tw":"靜音","ja-jp":"ミュート"},"autoAspectRatio":{"default":"","en-us":"Video Auto Aspect Ratio","zh-tw":"自動寬高比","ja-jp":"ビデオの自動アスペクト比"},"aspectRatio":{"default":"","en-us":"Video Aspect Ratio","zh-tw":"影片寬高比","ja-jp":"ビデオのアスペクト比"},"repeat":{"default":"","en-us":"Repeat the video path list","zh-tw":"重播影片清單","ja-jp":"ビデオパスリストを繰り返す"},"replayOnError":{"default":"","en-us":"Replay on playing error","zh-tw":"重播影片清單","ja-jp":"再生エラー時に再生"},"replayTimeout":{"default":"","en-us":"Timeout to replay if repeat or replayOnError is true and video is end or error","zh-tw":"如果影片結束或錯誤且 repeat 或 replayOnError 為 true,需要等待的重播時間","ja-jp":"repeatまたはreplayOnErrorがtrueで、ビデオが終了またはエラーの場合の再生タイムアウト"}},"defaultBrickProps":{"networkCaching":300,"paused":false,"volume":100,"muted":false,"replayTimeout":500},"propertyControls":{"uri":{"displayName":"URI","normalizeDisplayName":false,"resetOnTemplateChange":true,"required":true,"validator":{"fn":"uri","protocols":["https?","rtsp","rtmps?","rtmpt","rtmpe","rtmfp"]}},"replayTimeout":{"kind":"unit","min":0,"unit":"ms"},"resizeMode":{"resetOnTemplateChange":true},"volume":{"kind":"unit","min":0,"max":100,"unit":"%","step":5}},"eventTypes":{"BRICK_VIDEO_STREAMING_ON_PRESS":"BRICK_VIDEO_STREAMING_ON_PRESS","BRICK_VIDEO_STREAMING_ON_PRESS_IN":"BRICK_VIDEO_STREAMING_ON_PRESS_IN","BRICK_VIDEO_STREAMING_ON_PRESS_OUT":"BRICK_VIDEO_STREAMING_ON_PRESS_OUT","BRICK_VIDEO_STREAMING_ON_LONG_PRESS":"BRICK_VIDEO_STREAMING_ON_LONG_PRESS","BRICK_VIDEO_STREAMING_ON_FOCUS":"BRICK_VIDEO_STREAMING_ON_FOCUS","BRICK_VIDEO_STREAMING_ON_BLUR":"BRICK_VIDEO_STREAMING_ON_BLUR","BRICK_VIDEO_STREAMING_ON_END":"BRICK_VIDEO_STREAMING_ON_END","BRICK_VIDEO_STREAMING_ON_LOAD":"BRICK_VIDEO_STREAMING_ON_LOAD","BRICK_VIDEO_STREAMING_ON_ERROR":"BRICK_VIDEO_STREAMING_ON_ERROR"},"brickEventDescriptions":{"BRICK_VIDEO_STREAMING_ON_PRESS":{"default":"","en-us":"Event of the brick press","zh-tw":"當 brick 被點擊時觸發","ja-jp":"ブリックが押されたときに発生するイベント"},"BRICK_VIDEO_STREAMING_ON_PRESS_IN":{"default":"","en-us":"Event of the brick press in","zh-tw":"當 brick 被按下時觸發","ja-jp":"ブリックが押されたときに発生するイベント"},"BRICK_VIDEO_STREAMING_ON_PRESS_OUT":{"default":"","en-us":"Event of the brick press out","zh-tw":"當 brick 按下後被放開時觸發","ja-jp":"ブリックが押されたときに発生するイベント"},"BRICK_VIDEO_STREAMING_ON_LONG_PRESS":{"default":"","en-us":"Event of the brick long press","zh-tw":"當 brick 被長按時觸發","ja-jp":"ブリックが長押しされたときに発生するイベント"},"BRICK_VIDEO_STREAMING_ON_FOCUS":{"default":"","en-us":"Event of the brick focus (Use TV Device with controller)","zh-tw":"當 brick 獲得焦點時觸發 (適用於 TV 裝置)","ja-jp":"ブリックがフォーカスを獲得したときに発生するイベント (TV デバイスとコントローラーを使用)"},"BRICK_VIDEO_STREAMING_ON_BLUR":{"default":"","en-us":"Event of the brick blur (Use TV Device with controller)","zh-tw":"當 brick 失去焦點時觸發 (適用於 TV 裝置)","ja-jp":"ブリックがフォーカスを失ったときに発生するイベント (TV デバイスとコントローラーを使用)"},"BRICK_VIDEO_STREAMING_ON_END":{"default":"","en-us":"Event on plays of path are end","zh-tw":"當 path 完全播放完畢時觸發事件","ja-jp":"パスの再生が終了した時のイベント"},"BRICK_VIDEO_STREAMING_ON_LOAD":{"default":"","en-us":"Event on plays of path are end","zh-tw":"當影片讀取完成時觸發事件","ja-jp":"ビデオの読み込みが完了した時のイベント"},"BRICK_VIDEO_STREAMING_ON_ERROR":{"default":"","en-us":"Event of the video playing error","zh-tw":"當影片讀取錯誤時觸發事件","ja-jp":"ビデオ再生エラー時のイベント"}},"eventPropertyControls":{},"outletTypes":{"BRICK_PRESSING":{"outlet":"BRICK_PRESSING","type":"bool"},"BRICK_FOCUSING":{"outlet":"BRICK_FOCUSING","type":"bool"}},"brickOutletDescriptions":{"BRICK_PRESSING":{"default":"","en-us":"Brick is pressing","zh-tw":"Brick 被按住中","ja-jp":"ブリックが押されています"},"BRICK_FOCUSING":{"default":"","en-us":"Brick is focusing (Use TV Device with controller)","zh-tw":"Brick 處於焦點狀態中 (適用於 TV 裝置)","ja-jp":"ブリックがフォーカスされています (TV デバイスとコントローラーを使用)"}}}')},9222:(e,t,a)=>{a.d(t,{D:()=>U});var n=a(5608),r=a(9212),i=a(7634),o=a(5888),s=a(2495),p=a(5702),l=a(9354),d=a(3925),u=a(555),c=a(4214),m=a(8678),f=a(8907),_=a(2455),h=a(1360),E=a(492),y=a(3777),T=a(671),R=a(2307),g=a(2904),v=a(7236),O=a(1777),N=a(3906),b=a(5207),A=a(3767),S=a(4592);var I=function(){function e(){this.known=new(h.En?WeakSet:Set),this.pool=new S.Trie(h.et),this.passes=new WeakMap,this.keysByJSON=new Map,this.empty=this.admit({})}return e.prototype.isKnown=function(e){return(0,O.U)(e)&&this.known.has(e)},e.prototype.pass=function(e){if((0,O.U)(e)){var t=function(e){return(0,O.U)(e)?(0,A.c)(e)?e.slice(0):(0,n.__assign)({__proto__:Object.getPrototypeOf(e)},e):e}(e);return this.passes.set(t,e),t}return e},e.prototype.admit=function(e){var t=this;if((0,O.U)(e)){var a=this.passes.get(e);if(a)return a;switch(Object.getPrototypeOf(e)){case Array.prototype:if(this.known.has(e))return e;var n=e.map(this.admit,this);return(s=this.pool.lookupArray(n)).array||(this.known.add(s.array=n),!1!==globalThis.__DEV__&&Object.freeze(n)),s.array;case null:case Object.prototype:if(this.known.has(e))return e;var r=Object.getPrototypeOf(e),i=[r],o=this.sortedKeys(e);i.push(o.json);var s,p=i.length;if(o.sorted.forEach(function(a){i.push(t.admit(e[a]))}),!(s=this.pool.lookupArray(i)).object){var l=s.object=Object.create(r);this.known.add(l),o.sorted.forEach(function(e,t){l[e]=i[p+t]}),!1!==globalThis.__DEV__&&Object.freeze(l)}return s.object}}return e},e.prototype.sortedKeys=function(e){var t=Object.keys(e),a=this.pool.lookupArray(t);if(!a.keys){t.sort();var n=JSON.stringify(t);(a.keys=this.keysByJSON.get(n))||this.keysByJSON.set(n,a.keys={sorted:t,json:n})}return a.keys},e}();function w(e){return[e.selectionSet,e.objectOrReference,e.context,e.context.canonizeResults]}var C=function(){function e(e){var t=this;this.knownResults=new(h.et?WeakMap:Map),this.config=(0,E.o)(e,{addTypename:!1!==e.addTypename,canonizeResults:(0,b.Xx)(e)}),this.canon=e.canon||new I,this.executeSelectionSet=(0,i.wrap)(function(e){var a,r=e.context.canonizeResults,i=w(e);i[3]=!r;var o=(a=t.executeSelectionSet).peek.apply(a,i);return o?r?(0,n.__assign)((0,n.__assign)({},o),{result:t.canon.admit(o.result)}):o:((0,N.M2)(e.context.store,e.enclosingRef.__ref),t.execSelectionSetImpl(e))},{max:this.config.resultCacheMaxSize||u.v["inMemoryCache.executeSelectionSet"]||5e4,keyArgs:w,makeCacheKey:function(e,t,a,n){if((0,N.$7)(a.store))return a.store.makeCacheKey(e,(0,f.A_)(t)?t.__ref:t,a.varString,n)}}),this.executeSubSelectedArray=(0,i.wrap)(function(e){return(0,N.M2)(e.context.store,e.enclosingRef.__ref),t.execSubSelectedArrayImpl(e)},{max:this.config.resultCacheMaxSize||u.v["inMemoryCache.executeSubSelectedArray"]||1e4,makeCacheKey:function(e){var t=e.field,a=e.array,n=e.context;if((0,N.$7)(n.store))return n.store.makeCacheKey(t,a,n.varString)}})}return e.prototype.resetCanon=function(){this.canon=new I},e.prototype.diffQueryAgainstStore=function(e){var t=e.store,a=e.query,r=e.rootId,i=void 0===r?"ROOT_QUERY":r,o=e.variables,s=e.returnPartialData,l=void 0===s||s,d=e.canonizeResults,u=void 0===d?this.config.canonizeResults:d,m=this.config.cache.policies;o=(0,n.__assign)((0,n.__assign)({},(0,y.wY)((0,y.AT)(a))),o);var _,h=(0,f.WU)(i),E=this.executeSelectionSet({selectionSet:(0,y.Vn)(a).selectionSet,objectOrReference:h,enclosingRef:h,context:(0,n.__assign)({store:t,query:a,policies:m,variables:o,varString:(0,c.M)(o),canonizeResults:u},(0,b.lq)(a,this.config.fragments))});if(E.missing&&(_=[new p.Z(D(E.missing),E.missing,a,o)],!l))throw _[0];return{result:E.result,complete:!_,missing:_}},e.prototype.isFresh=function(e,t,a,n){if((0,N.$7)(n.store)&&this.knownResults.get(e)===a){var r=this.executeSelectionSet.peek(a,t,n,this.canon.isKnown(e));if(r&&e===r.result)return!0}return!1},e.prototype.execSelectionSetImpl=function(e){var t=this,a=e.selectionSet,n=e.objectOrReference,i=e.enclosingRef,o=e.context;if((0,f.A_)(n)&&!o.policies.rootTypenamesById[n.__ref]&&!o.store.has(n.__ref))return{result:this.canon.empty,missing:"Dangling reference to missing ".concat(n.__ref," object")};var s,p=o.variables,l=o.policies,u=o.store.getFieldValue(n,"__typename"),c=[],m=new T.ZI;function h(e,t){var a;return e.missing&&(s=m.merge(s,((a={})[t]=e.missing,a))),e.result}this.config.addTypename&&"string"==typeof u&&!l.rootIdsByTypename[u]&&c.push({__typename:u});var E=new Set(a.selections);E.forEach(function(e){var a,y;if((0,R.MS)(e,p))if((0,f.dt)(e)){var T=l.readField({fieldName:e.name.value,field:e,variables:o.variables,from:n},o),v=(0,f.ue)(e);void 0===T?d.XY.added(e)||(s=m.merge(s,((a={})[v]="Can't find field '".concat(e.name.value,"' on ").concat((0,f.A_)(n)?n.__ref+" object":"object "+JSON.stringify(n,null,2)),a))):(0,A.c)(T)?T.length>0&&(T=h(t.executeSubSelectedArray({field:e,array:T,enclosingRef:i,context:o}),v)):e.selectionSet?null!=T&&(T=h(t.executeSelectionSet({selectionSet:e.selectionSet,objectOrReference:T,enclosingRef:(0,f.A_)(T)?T:i,context:o}),v)):o.canonizeResults&&(T=t.canon.pass(T)),void 0!==T&&c.push(((y={})[v]=T,y))}else{var O=(0,g.HQ)(e,o.lookupFragment);if(!O&&e.kind===_.b.FRAGMENT_SPREAD)throw(0,r.newInvariantError)(10,e.name.value);O&&l.fragmentMatches(O,u)&&O.selectionSet.selections.forEach(E.add,E)}});var y={result:(0,T.IM)(c),missing:s},O=o.canonizeResults?this.canon.admit(y):(0,v.G)(y);return O.result&&this.knownResults.set(O.result,a),O},e.prototype.execSubSelectedArrayImpl=function(e){var t,a=this,n=e.field,i=e.array,o=e.enclosingRef,s=e.context,p=new T.ZI;function l(e,a){var n;return e.missing&&(t=p.merge(t,((n={})[a]=e.missing,n))),e.result}return n.selectionSet&&(i=i.filter(s.store.canRead)),i=i.map(function(e,t){return null===e?null:(0,A.c)(e)?l(a.executeSubSelectedArray({field:n,array:e,enclosingRef:o,context:s}),t):n.selectionSet?l(a.executeSelectionSet({selectionSet:n.selectionSet,objectOrReference:e,enclosingRef:(0,f.A_)(e)?e:o,context:s}),t):(!1!==globalThis.__DEV__&&function(e,t,a){if(!t.selectionSet){var n=new Set([a]);n.forEach(function(a){(0,O.U)(a)&&((0,r.invariant)(!(0,f.A_)(a),11,(0,b.Ui)(e,a),t.name.value),Object.values(a).forEach(n.add,n))})}}(s.store,n,e),e)}),{result:s.canonizeResults?this.canon.admit(i):i,missing:t}},e}();function D(e){try{JSON.stringify(e,function(e,t){if("string"==typeof t)throw t;return t})}catch(e){return e}}var P=a(906),j=a(8338);function k(e,t,a){var r="".concat(t).concat(a),i=e.flavors.get(r);return i||e.flavors.set(r,i=e.clientOnly===t&&e.deferred===a?e:(0,n.__assign)((0,n.__assign)({},e),{clientOnly:t,deferred:a})),i}var L=function(){function e(e,t,a){this.cache=e,this.reader=t,this.fragments=a}return e.prototype.writeToStore=function(e,t){var a=this,i=t.query,s=t.result,p=t.dataId,l=t.variables,d=t.overwrite,u=(0,y.Vu)(i),m=(0,b.mv)();l=(0,n.__assign)((0,n.__assign)({},(0,y.wY)(u)),l);var _=(0,n.__assign)((0,n.__assign)({store:e,written:Object.create(null),merge:function(e,t){return m.merge(e,t)},variables:l,varString:(0,c.M)(l)},(0,b.lq)(i,this.fragments)),{overwrite:!!d,incomingById:new Map,clientOnly:!1,deferred:!1,flavors:new Map}),h=this.processSelectionSet({result:s||Object.create(null),dataId:p,selectionSet:u.selectionSet,mergeTree:{map:new Map},context:_});if(!(0,f.A_)(h))throw(0,r.newInvariantError)(12,s);return _.incomingById.forEach(function(t,i){var s=t.storeObject,p=t.mergeTree,l=t.fieldNodeSet,d=(0,f.WU)(i);if(p&&p.map.size){var u=a.applyMerges(p,d,s,_);if((0,f.A_)(u))return;s=u}if(!1!==globalThis.__DEV__&&!_.overwrite){var c=Object.create(null);l.forEach(function(e){e.selectionSet&&(c[e.name.value]=!0)});Object.keys(s).forEach(function(e){(function(e){return!0===c[(0,b.iJ)(e)]})(e)&&!function(e){var t=p&&p.map.get(e);return Boolean(t&&t.info&&t.info.merge)}(e)&&function(e,t,a,i){var s=function(e){var t=i.getFieldValue(e,a);return"object"==typeof t&&t},p=s(e);if(!p)return;var l=s(t);if(!l)return;if((0,f.A_)(p))return;if((0,o.equal)(p,l))return;if(Object.keys(p).every(function(e){return void 0!==i.getFieldValue(l,e)}))return;var d=i.getFieldValue(e,"__typename")||i.getFieldValue(t,"__typename"),u=(0,b.iJ)(a),c="".concat(d,".").concat(u);if(z.has(c))return;z.add(c);var m=[];(0,A.c)(p)||(0,A.c)(l)||[p,l].forEach(function(e){var t=i.getFieldValue(e,"__typename");"string"!=typeof t||m.includes(t)||m.push(t)});!1!==globalThis.__DEV__&&r.invariant.warn(15,u,d,m.length?"either ensure all objects of type "+m.join(" and ")+" have an ID or a custom merge function, or ":"",c,(0,n.__assign)({},p),(0,n.__assign)({},l))}(d,s,e,_.store)})}e.merge(i,s)}),e.retain(h.__ref),h},e.prototype.processSelectionSet=function(e){var t=this,a=e.dataId,i=e.result,o=e.selectionSet,s=e.context,p=e.mergeTree,l=this.cache.policies,u=Object.create(null),c=a&&l.rootTypenamesById[a]||(0,f.D$)(i,o,s.fragmentMap)||a&&s.store.get(a,"__typename");"string"==typeof c&&(u.__typename=c);var m=function(){var e=(0,j.m)(arguments,u,s.variables);if((0,f.A_)(e.from)){var t=s.incomingById.get(e.from.__ref);if(t){var a=l.readField((0,n.__assign)((0,n.__assign)({},e),{from:t.storeObject}),s);if(void 0!==a)return a}}return l.readField(e,s)},_=new Set;this.flattenFields(o,i,s,c).forEach(function(e,a){var n,o=(0,f.ue)(a),s=i[o];if(_.add(a),void 0!==s){var h=l.getStoreFieldName({typename:c,fieldName:a.name.value,field:a,variables:e.variables}),E=G(p,h),y=t.processFieldValue(s,a,a.selectionSet?k(e,!1,!1):e,E),T=void 0;a.selectionSet&&((0,f.A_)(y)||(0,b.d1)(y))&&(T=m("__typename",y));var R=l.getMergeFunction(c,a.name.value,T);R?E.info={field:a,typename:c,merge:R}:B(p,h),u=e.merge(u,((n={})[h]=y,n))}else!1===globalThis.__DEV__||e.clientOnly||e.deferred||d.XY.added(a)||l.getReadFunction(c,a.name.value)||!1!==globalThis.__DEV__&&r.invariant.error(13,(0,f.ue)(a),i)});try{var h=l.identify(i,{typename:c,selectionSet:o,fragmentMap:s.fragmentMap,storeObject:u,readField:m}),E=h[0],y=h[1];a=a||E,y&&(u=s.merge(u,y))}catch(e){if(!a)throw e}if("string"==typeof a){var T=(0,f.WU)(a),R=s.written[a]||(s.written[a]=[]);if(R.indexOf(o)>=0)return T;if(R.push(o),this.reader&&this.reader.isFresh(i,T,o,s))return T;var g=s.incomingById.get(a);return g?(g.storeObject=s.merge(g.storeObject,u),g.mergeTree=x(g.mergeTree,p),_.forEach(function(e){return g.fieldNodeSet.add(e)})):s.incomingById.set(a,{storeObject:u,mergeTree:F(p)?void 0:p,fieldNodeSet:_}),T}return u},e.prototype.processFieldValue=function(e,t,a,n){var r=this;return t.selectionSet&&null!==e?(0,A.c)(e)?e.map(function(e,i){var o=r.processFieldValue(e,t,a,G(n,i));return B(n,i),o}):this.processSelectionSet({result:e,selectionSet:t.selectionSet,context:a,mergeTree:n}):!1!==globalThis.__DEV__?(0,P.m)(e):e},e.prototype.flattenFields=function(e,t,a,n){void 0===n&&(n=(0,f.D$)(t,e,a.fragmentMap));var i=new Map,o=this.cache.policies,s=new S.Trie(!1);return function e(p,l){var d=s.lookup(p,l.clientOnly,l.deferred);d.visited||(d.visited=!0,p.selections.forEach(function(s){if((0,R.MS)(s,a.variables)){var p=l.clientOnly,d=l.deferred;if(p&&d||!(0,A.E)(s.directives)||s.directives.forEach(function(e){var t=e.name.value;if("client"===t&&(p=!0),"defer"===t){var n=(0,f.MB)(e,a.variables);n&&!1===n.if||(d=!0)}}),(0,f.dt)(s)){var u=i.get(s);u&&(p=p&&u.clientOnly,d=d&&u.deferred),i.set(s,k(a,p,d))}else{var c=(0,g.HQ)(s,a.lookupFragment);if(!c&&s.kind===_.b.FRAGMENT_SPREAD)throw(0,r.newInvariantError)(14,s.name.value);c&&o.fragmentMatches(c,n,t,a.variables)&&e(c.selectionSet,k(a,p,d))}}}))}(e,a),i},e.prototype.applyMerges=function(e,t,a,i,o){var s,p=this;if(e.map.size&&!(0,f.A_)(a)){var l,d=(0,A.c)(a)||!(0,f.A_)(t)&&!(0,b.d1)(t)?void 0:t,u=a;d&&!o&&(o=[(0,f.A_)(d)?d.__ref:d]);var c=function(e,t){return(0,A.c)(e)?"number"==typeof t?e[t]:void 0:i.store.getFieldValue(e,String(t))};e.map.forEach(function(e,t){var a=c(d,t),n=c(u,t);if(void 0!==n){o&&o.push(t);var s=p.applyMerges(e,a,n,i,o);s!==n&&(l=l||new Map).set(t,s),o&&(0,r.invariant)(o.pop()===t)}}),l&&(a=(0,A.c)(u)?u.slice(0):(0,n.__assign)({},u),l.forEach(function(e,t){a[t]=e}))}return e.info?this.cache.policies.runMergeFunction(t,a,e.info,i,o&&(s=i.store).getStorage.apply(s,o)):a},e}(),M=[];function G(e,t){var a=e.map;return a.has(t)||a.set(t,M.pop()||{map:new Map}),a.get(t)}function x(e,t){if(e===t||!t||F(t))return e;if(!e||F(e))return t;var a=e.info&&t.info?(0,n.__assign)((0,n.__assign)({},e.info),t.info):e.info||t.info,r=e.map.size&&t.map.size,i={info:a,map:r?new Map:e.map.size?e.map:t.map};if(r){var o=new Set(t.map.keys());e.map.forEach(function(e,a){i.map.set(a,x(e,t.map.get(a))),o.delete(a)}),o.forEach(function(a){i.map.set(a,x(t.map.get(a),e.map.get(a)))})}return i}function F(e){return!e||!(e.info||e.map.size)}function B(e,t){var a=e.map,n=a.get(t);n&&F(n)&&(M.push(n),a.delete(t))}var z=new Set;var V=a(777),$=a(4114),U=function(e){function t(t){void 0===t&&(t={});var a=e.call(this)||this;return a.watches=new Set,a.addTypenameTransform=new l.c(d.XY),a.assumeImmutableResults=!0,a.makeVar=V.UT,a.txCount=0,a.config=(0,b.I6)(t),a.addTypename=!!a.config.addTypename,a.policies=new j.l({cache:a,dataIdFromObject:a.config.dataIdFromObject,possibleTypes:a.config.possibleTypes,typePolicies:a.config.typePolicies}),a.init(),a}return(0,n.__extends)(t,e),t.prototype.init=function(){var e=this.data=new N.D_.Root({policies:this.policies,resultCaching:this.config.resultCaching});this.optimisticData=e.stump,this.resetResultCache()},t.prototype.resetResultCache=function(e){var t=this,a=this.storeReader,n=this.config.fragments;this.storeWriter=new L(this,this.storeReader=new C({cache:this,addTypename:this.addTypename,resultCacheMaxSize:this.config.resultCacheMaxSize,canonizeResults:(0,b.Xx)(this.config),canon:e?void 0:a&&a.canon,fragments:n}),n),this.maybeBroadcastWatch=(0,i.wrap)(function(e,a){return t.broadcastWatch(e,a)},{max:this.config.resultCacheMaxSize||u.v["inMemoryCache.maybeBroadcastWatch"]||5e3,makeCacheKey:function(e){var a=e.optimistic?t.optimisticData:t.data;if((0,N.$7)(a)){var n=e.optimistic,r=e.id,i=e.variables;return a.makeCacheKey(e.query,e.callback,(0,c.M)({optimistic:n,id:r,variables:i}))}}}),new Set([this.data.group,this.optimisticData.group]).forEach(function(e){return e.resetCaching()})},t.prototype.restore=function(e){return this.init(),e&&this.data.replace(e),this},t.prototype.extract=function(e){return void 0===e&&(e=!1),(e?this.optimisticData:this.data).extract()},t.prototype.read=function(e){var t=e.returnPartialData,a=void 0!==t&&t;try{return this.storeReader.diffQueryAgainstStore((0,n.__assign)((0,n.__assign)({},e),{store:e.optimistic?this.optimisticData:this.data,config:this.config,returnPartialData:a})).result||null}catch(e){if(e instanceof p.Z)return null;throw e}},t.prototype.write=function(e){try{return++this.txCount,this.storeWriter.writeToStore(this.data,e)}finally{--this.txCount||!1===e.broadcast||this.broadcastWatches()}},t.prototype.modify=function(e){if(b.$3.call(e,"id")&&!e.id)return!1;var t=e.optimistic?this.optimisticData:this.data;try{return++this.txCount,t.modify(e.id||"ROOT_QUERY",e.fields)}finally{--this.txCount||!1===e.broadcast||this.broadcastWatches()}},t.prototype.diff=function(e){return this.storeReader.diffQueryAgainstStore((0,n.__assign)((0,n.__assign)({},e),{store:e.optimistic?this.optimisticData:this.data,rootId:e.id||"ROOT_QUERY",config:this.config}))},t.prototype.watch=function(e){var t=this;return this.watches.size||(0,V.MS)(this),this.watches.add(e),e.immediate&&this.maybeBroadcastWatch(e),function(){t.watches.delete(e)&&!t.watches.size&&(0,V.WR)(t),t.maybeBroadcastWatch.forget(e)}},t.prototype.gc=function(e){var t;c.M.reset(),m.y.reset(),this.addTypenameTransform.resetCache(),null===(t=this.config.fragments)||void 0===t||t.resetCaches();var a=this.optimisticData.gc();return e&&!this.txCount&&(e.resetResultCache?this.resetResultCache(e.resetResultIdentities):e.resetResultIdentities&&this.storeReader.resetCanon()),a},t.prototype.retain=function(e,t){return(t?this.optimisticData:this.data).retain(e)},t.prototype.release=function(e,t){return(t?this.optimisticData:this.data).release(e)},t.prototype.identify=function(e){if((0,f.A_)(e))return e.__ref;try{return this.policies.identify(e)[0]}catch(e){!1!==globalThis.__DEV__&&r.invariant.warn(e)}},t.prototype.evict=function(e){if(!e.id){if(b.$3.call(e,"id"))return!1;e=(0,n.__assign)((0,n.__assign)({},e),{id:"ROOT_QUERY"})}try{return++this.txCount,this.optimisticData.evict(e,this.data)}finally{--this.txCount||!1===e.broadcast||this.broadcastWatches()}},t.prototype.reset=function(e){var t=this;return this.init(),c.M.reset(),e&&e.discardWatches?(this.watches.forEach(function(e){return t.maybeBroadcastWatch.forget(e)}),this.watches.clear(),(0,V.WR)(this)):this.broadcastWatches(),Promise.resolve()},t.prototype.removeOptimistic=function(e){var t=this.optimisticData.removeLayer(e);t!==this.optimisticData&&(this.optimisticData=t,this.broadcastWatches())},t.prototype.batch=function(e){var t,a=this,r=e.update,i=e.optimistic,o=void 0===i||i,s=e.removeOptimistic,p=e.onWatchUpdated,l=function(e){var n=a,i=n.data,o=n.optimisticData;++a.txCount,e&&(a.data=a.optimisticData=e);try{return t=r(a)}finally{--a.txCount,a.data=i,a.optimisticData=o}},d=new Set;return p&&!this.txCount&&this.broadcastWatches((0,n.__assign)((0,n.__assign)({},e),{onWatchUpdated:function(e){return d.add(e),!1}})),"string"==typeof o?this.optimisticData=this.optimisticData.addLayer(o,l):!1===o?l(this.data):l(),"string"==typeof s&&(this.optimisticData=this.optimisticData.removeLayer(s)),p&&d.size?(this.broadcastWatches((0,n.__assign)((0,n.__assign)({},e),{onWatchUpdated:function(e,t){var a=p.call(this,e,t);return!1!==a&&d.delete(e),a}})),d.size&&d.forEach(function(e){return a.maybeBroadcastWatch.dirty(e)})):this.broadcastWatches(e),t},t.prototype.performTransaction=function(e,t){return this.batch({update:e,optimistic:t||null!==t})},t.prototype.transformDocument=function(e){return this.addTypenameToDocument(this.addFragmentsToDocument(e))},t.prototype.fragmentMatches=function(e,t){return this.policies.fragmentMatches(e,t)},t.prototype.lookupFragment=function(e){var t;return(null===(t=this.config.fragments)||void 0===t?void 0:t.lookup(e))||null},t.prototype.broadcastWatches=function(e){var t=this;this.txCount||this.watches.forEach(function(a){return t.maybeBroadcastWatch(a,e)})},t.prototype.addFragmentsToDocument=function(e){var t=this.config.fragments;return t?t.transform(e):e},t.prototype.addTypenameToDocument=function(e){return this.addTypename?this.addTypenameTransform.transformDocument(e):e},t.prototype.broadcastWatch=function(e,t){var a=e.lastDiff,n=this.diff(e);t&&(e.optimistic&&"string"==typeof t.optimistic&&(n.fromOptimisticTransaction=!0),t.onWatchUpdated&&!1===t.onWatchUpdated.call(this,e,n,a))||a&&(0,o.equal)(a.result,n.result)||e.callback(e.lastDiff=n,a)},t}(s.k);!1!==globalThis.__DEV__&&(U.prototype.getMemoryInternals=$.cM)},9283:(e,t,a)=>{a.r(t),a.d(t,{disableWarningsSlot:()=>n.yV,maskFragment:()=>r.z,maskOperation:()=>i.m});var n=a(7150),r=a(2959),i=a(8354)},9348:(e,t,a)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validateKeywordUsage=t.validSchemaType=t.funcKeywordCode=t.macroKeywordCode=void 0;const n=a(7898),r=a(3036),i=a(4450),o=a(9409);function s(e){const{gen:t,data:a,it:r}=e;t.if(r.parentData,()=>t.assign(a,n._`${r.parentData}[${r.parentDataProperty}]`))}function p(e,t,a){if(void 0===a)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword","function"==typeof a?{ref:a}:{ref:a,code:(0,n.stringify)(a)})}t.macroKeywordCode=function(e,t){const{gen:a,keyword:r,schema:i,parentSchema:o,it:s}=e,l=t.macro.call(s.self,i,o,s),d=p(a,r,l);!1!==s.opts.validateSchema&&s.self.validateSchema(l,!0);const u=a.name("valid");e.subschema({schema:l,schemaPath:n.nil,errSchemaPath:`${s.errSchemaPath}/${r}`,topSchemaRef:d,compositeRule:!0},u),e.pass(u,()=>e.error(!0))},t.funcKeywordCode=function(e,t){var a;const{gen:l,keyword:d,schema:u,parentSchema:c,$data:m,it:f}=e;!function({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}(f,t);const _=!m&&t.compile?t.compile.call(f.self,u,c,f):t.validate,h=p(l,d,_),E=l.let("valid");function y(a=(t.async?n._`await `:n.nil)){const o=f.opts.passContext?r.default.this:r.default.self,s=!("compile"in t&&!m||!1===t.schema);l.assign(E,n._`${a}${(0,i.callValidateCode)(e,h,o,s)}`,t.modifying)}function T(e){var a;l.if((0,n.not)(null!==(a=t.valid)&&void 0!==a?a:E),e)}e.block$data(E,function(){if(!1===t.errors)y(),t.modifying&&s(e),T(()=>e.error());else{const a=t.async?function(){const e=l.let("ruleErrs",null);return l.try(()=>y(n._`await `),t=>l.assign(E,!1).if(n._`${t} instanceof ${f.ValidationError}`,()=>l.assign(e,n._`${t}.errors`),()=>l.throw(t))),e}():function(){const e=n._`${h}.errors`;return l.assign(e,null),y(n.nil),e}();t.modifying&&s(e),T(()=>function(e,t){const{gen:a}=e;a.if(n._`Array.isArray(${t})`,()=>{a.assign(r.default.vErrors,n._`${r.default.vErrors} === null ? ${t} : ${r.default.vErrors}.concat(${t})`).assign(r.default.errors,n._`${r.default.vErrors}.length`),(0,o.extendErrors)(e)},()=>e.error())}(e,a))}}),e.ok(null!==(a=t.valid)&&void 0!==a?a:E)},t.validSchemaType=function(e,t,a=!1){return!t.length||t.some(t=>"array"===t?Array.isArray(e):"object"===t?e&&"object"==typeof e&&!Array.isArray(e):typeof e==t||a&&void 0===e)},t.validateKeywordUsage=function({schema:e,opts:t,self:a,errSchemaPath:n},r,i){if(Array.isArray(r.keyword)?!r.keyword.includes(i):r.keyword!==i)throw new Error("ajv implementation error");const o=r.dependencies;if(null==o?void 0:o.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw new Error(`parent schema must have dependencies of ${i}: ${o.join(",")}`);if(r.validateSchema){if(!r.validateSchema(e[i])){const e=`keyword "${i}" value is invalid at path "${n}": `+a.errorsText(r.validateSchema.errors);if("log"!==t.validateSchema)throw new Error(e);a.logger.error(e)}}}},9354:(e,t,a)=>{a.d(t,{c:()=>u});var n=a(4592),r=a(1360),i=a(3777),o=a(9212),s=a(4019),p=a(7634),l=a(555);function d(e){return e}var u=function(){function e(e,t){void 0===t&&(t=Object.create(null)),this.resultCache=r.En?new WeakSet:new Set,this.transform=e,t.getCacheKey&&(this.getCacheKey=t.getCacheKey),this.cached=!1!==t.cache,this.resetCache()}return e.prototype.getCacheKey=function(e){return[e]},e.identity=function(){return new e(d,{cache:!1})},e.split=function(t,a,n){return void 0===n&&(n=e.identity()),Object.assign(new e(function(e){return(t(e)?a:n).transformDocument(e)},{cache:!1}),{left:a,right:n})},e.prototype.resetCache=function(){var t=this;if(this.cached){var a=new n.Trie(r.et);this.performWork=(0,p.wrap)(e.prototype.performWork.bind(this),{makeCacheKey:function(e){var n=t.getCacheKey(e);if(n)return(0,o.invariant)(Array.isArray(n),77),a.lookupArray(n)},max:l.v["documentTransform.cache"],cache:s.l})}},e.prototype.performWork=function(e){return(0,i.sw)(e),this.transform(e)},e.prototype.transformDocument=function(e){if(this.resultCache.has(e))return e;var t=this.performWork(e);return this.resultCache.add(t),t},e.prototype.concat=function(t){var a=this;return Object.assign(new e(function(e){return t.transformDocument(a.transformDocument(e))},{cache:!1}),{left:this,right:t})},e}()},9355:(e,t,a)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=a(458),r={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:a,it:r}=e;if(!Array.isArray(a))throw new Error("ajv implementation error");const i=t.name("valid");a.forEach((t,a)=>{if((0,n.alwaysValidSchema)(r,t))return;const o=e.subschema({keyword:"allOf",schemaProp:a},i);e.ok(i),e.mergeEvaluated(o)})}};t.default=r},9361:e=>{e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},9367:e=>{e.exports=JSON.parse('{"name":"BrickRect","brickDescription":{"default":"Brick rect component","en-us":"Rect brick ([Tutorial](https://intercom.help/bricks-dag-inc/articles/5378573-rect))","zh-tw":"矩形方塊 ([教學](https://intercom.help/bricks-dag-inc/articles/5378573-rect))","ja-jp":"長方形ブリック ([チュートリアル](https://intercom.help/bricks-dag-inc/articles/5378573-rect))"},"brickDisplayName":"Rect","brickTip":{"default":"@brick-tip-rect","en-us":"Add a Rectangle shape with Background, Border and Corner Radius.","zh-tw":"矩形元件,可設置顏色、邊框及外框導角半徑","ja-jp":"背景、境界線、角丸を設定できる長方形シェイプを追加します。"},"brickMeta":{"useBaseStyle":true,"pressable":true},"brickPreviewIcon":{"type":"font-awesome-6pro","name":"rectangle"},"propTypes":{"linearGradientEnabled":{"type":"bool"},"linearGradientColors":{"type":"arrayOf","content":{"type":"string"},"forcePropertyBank":false},"linearGradientStart":{"type":"shape","content":{"x":{"type":"number"},"y":{"type":"number"}},"forcePropertyBank":false},"linearGradientEnd":{"type":"shape","content":{"x":{"type":"number"},"y":{"type":"number"}},"forcePropertyBank":false},"linearGradientLocations":{"type":"arrayOf","content":{"type":"number"},"forcePropertyBank":false}},"brickPropDescriptions":{"linearGradientEnabled":{"default":"","en-us":"Enables or disables linear gradient","zh-tw":"Enables or disables linear gradient","ja-jp":"リニアグラデーションの有効/無効を切り替え"},"linearGradientColors":{"default":"","en-us":"An array of at least two color values that represent gradient colors","zh-tw":"一個包含至少兩個顏色值的數組,表示漸變顏色","ja-jp":"グラデーションカラーを表す少なくとも2つのカラー値を含む配列"},"linearGradientStart":{"default":"","en-us":"An optional object of the following type: { x: number, y: number }","zh-tw":"一個可選的對象,類型為:{ x: number, y: number }","ja-jp":"オプションのオブジェクト、タイプ: { x: number, y: number }"},"linearGradientEnd":{"default":"","en-us":"Same as start, but for the end of the gradient","zh-tw":"與 start 相同,但用於漸變的結束","ja-jp":"開始と同じですが、グラデーションの終了位置用"},"linearGradientLocations":{"default":"","en-us":"An optional array of numbers defining the location of each gradient color stop","zh-tw":"一個可選的數組,定義每個漸變顏色停止的位置","ja-jp":"各グラデーションカラーストップの位置を定義するオプションの数値配列"}},"propertyControls":{"linearGradientColors":{"popover":true,"popoverExpectIncludedModalOpen":true,"extendSchema":{"type":"string","kind":"color","popover":true}},"linearGradientStart":{"popover":true,"extendSchema":{"unallowRemoveProperty":true,"properties":{"x":{"type":"number","kind":"unit","unallowRemoveProperty":true,"min":0,"step":0.05},"y":{"type":"number","kind":"unit","unallowRemoveProperty":true,"min":0,"step":0.05}}}},"linearGradientEnd":{"popover":true,"extendSchema":{"unallowRemoveProperty":true,"properties":{"x":{"type":"number","kind":"unit","unallowRemoveProperty":true,"min":0,"step":0.05},"y":{"type":"number","kind":"unit","unallowRemoveProperty":true,"min":0,"step":0.05}}}},"linearGradientLocations":{"popover":true}},"propertyControlGroups":{"linearGradient":{"name":"Linear Gradient","type":"prefix","content":"linearGradient","editor":"gradient-editor"}},"propertyControlGroupDescriptions":{},"defaultBrickProps":{"linearGradientEnabled":false,"linearGradientColors":["#000000","#FFFFFF"],"linearGradientStart":{"x":0,"y":0},"linearGradientEnd":{"x":1,"y":1},"linearGradientLocations":[0,1]},"eventTypes":{"BRICK_RECT_ON_PRESS":"BRICK_RECT_ON_PRESS","BRICK_RECT_ON_PRESS_IN":"BRICK_RECT_ON_PRESS_IN","BRICK_RECT_ON_PRESS_OUT":"BRICK_RECT_ON_PRESS_OUT","BRICK_RECT_ON_LONG_PRESS":"BRICK_RECT_ON_LONG_PRESS","BRICK_RECT_ON_FOCUS":"BRICK_RECT_ON_FOCUS","BRICK_RECT_ON_BLUR":"BRICK_RECT_ON_BLUR"},"brickEventDescriptions":{"BRICK_RECT_ON_PRESS":{"default":"","en-us":"Event of the brick press","zh-tw":"當 brick 被點擊時觸發","ja-jp":"ブリックが押されたときに発生するイベント"},"BRICK_RECT_ON_PRESS_IN":{"default":"","en-us":"Event of the brick press in","zh-tw":"當 brick 被按下時觸發","ja-jp":"ブリックが押されたときに発生するイベント"},"BRICK_RECT_ON_PRESS_OUT":{"default":"","en-us":"Event of the brick press out","zh-tw":"當 brick 按下後被放開時觸發","ja-jp":"ブリックが押されたときに発生するイベント"},"BRICK_RECT_ON_LONG_PRESS":{"default":"","en-us":"Event of the brick long press","zh-tw":"當 brick 被長按時觸發","ja-jp":"ブリックが長押しされたときに発生するイベント"},"BRICK_RECT_ON_FOCUS":{"default":"","en-us":"Event of the brick focus (Use TV Device with controller)","zh-tw":"當 brick 獲得焦點時觸發 (適用於 TV 裝置)","ja-jp":"ブリックがフォーカスを獲得したときに発生するイベント (TV デバイスとコントローラーを使用)"},"BRICK_RECT_ON_BLUR":{"default":"","en-us":"Event of the brick blur (Use TV Device with controller)","zh-tw":"當 brick 失去焦點時觸發 (適用於 TV 裝置)","ja-jp":"ブリックがフォーカスを失ったときに発生するイベント (TV デバイスとコントローラーを使用)"}},"outletTypes":{"BRICK_PRESSING":{"outlet":"BRICK_PRESSING","type":"bool"},"BRICK_FOCUSING":{"outlet":"BRICK_FOCUSING","type":"bool"}},"brickOutletDescriptions":{"BRICK_PRESSING":{"default":"","en-us":"Brick is pressing","zh-tw":"Brick 被按住中","ja-jp":"ブリックが押されています"},"BRICK_FOCUSING":{"default":"","en-us":"Brick is focusing (Use TV Device with controller)","zh-tw":"Brick 處於焦點狀態中 (適用於 TV 裝置)","ja-jp":"ブリックがフォーカスされています (TV デバイスとコントローラーを使用)"}}}')},9371:(e,t,a)=>{a.r(t),a.d(t,{InvariantError:()=>s,default:()=>m,invariant:()=>p,setVerbosity:()=>c});var n=a(5608),r="Invariant Violation",i=Object.setPrototypeOf,o=void 0===i?function(e,t){return e.__proto__=t,e}:i,s=function(e){function t(a){void 0===a&&(a=r);var n=e.call(this,"number"==typeof a?r+": "+a+" (see https://github.com/apollographql/invariant-packages)":a)||this;return n.framesToPop=1,n.name=r,o(n,t.prototype),n}return(0,n.__extends)(t,e),t}(Error);function p(e,t){if(!e)throw new s(t)}var l=["debug","log","warn","error","silent"],d=l.indexOf("log");function u(e){return function(){if(l.indexOf(e)>=d)return(console[e]||console.log).apply(console,arguments)}}function c(e){var t=l[d];return d=Math.max(0,l.indexOf(e)),t}!function(e){e.debug=u("debug"),e.log=u("log"),e.warn=u("warn"),e.error=u("error")}(p||(p={}));const m=p},9392:(e,t,a)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.resolveSchema=t.getCompilingSchema=t.resolveRef=t.compileSchema=t.SchemaEnv=void 0;const n=a(7898),r=a(5031),i=a(3036),o=a(4856),s=a(458),p=a(6223);class l{constructor(e){var t;let a;this.refs={},this.dynamicAnchors={},"object"==typeof e.schema&&(a=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=null!==(t=e.baseId)&&void 0!==t?t:(0,o.normalizeId)(null==a?void 0:a[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=null==a?void 0:a.$async,this.refs={}}}function d(e){const t=c.call(this,e);if(t)return t;const a=(0,o.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:s,lines:l}=this.opts.code,{ownProperties:d}=this.opts,u=new n.CodeGen(this.scope,{es5:s,lines:l,ownProperties:d});let m;e.$async&&(m=u.scopeValue("Error",{ref:r.default,code:n._`require("ajv/dist/runtime/validation_error").default`}));const f=u.scopeName("validate");e.validateName=f;const _={gen:u,allErrors:this.opts.allErrors,data:i.default.data,parentData:i.default.parentData,parentDataProperty:i.default.parentDataProperty,dataNames:[i.default.data],dataPathArr:[n.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:u.scopeValue("schema",!0===this.opts.code.source?{ref:e.schema,code:(0,n.stringify)(e.schema)}:{ref:e.schema}),validateName:f,ValidationError:m,schema:e.schema,schemaEnv:e,rootId:a,baseId:e.baseId||a,schemaPath:n.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:n._`""`,opts:this.opts,self:this};let h;try{this._compilations.add(e),(0,p.validateFunctionCode)(_),u.optimize(this.opts.code.optimize);const t=u.toString();h=`${u.scopeRefs(i.default.scope)}return ${t}`,this.opts.code.process&&(h=this.opts.code.process(h,e));const a=new Function(`${i.default.self}`,`${i.default.scope}`,h)(this,this.scope.get());if(this.scope.value(f,{ref:a}),a.errors=null,a.schema=e.schema,a.schemaEnv=e,e.$async&&(a.$async=!0),!0===this.opts.code.source&&(a.source={validateName:f,validateCode:t,scopeValues:u._values}),this.opts.unevaluated){const{props:e,items:t}=_;a.evaluated={props:e instanceof n.Name?void 0:e,items:t instanceof n.Name?void 0:t,dynamicProps:e instanceof n.Name,dynamicItems:t instanceof n.Name},a.source&&(a.source.evaluated=(0,n.stringify)(a.evaluated))}return e.validate=a,e}catch(t){throw delete e.validate,delete e.validateName,h&&this.logger.error("Error compiling schema, function code:",h),t}finally{this._compilations.delete(e)}}function u(e){return(0,o.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:d.call(this,e)}function c(e){for(const t of this._compilations)if(m(t,e))return t}function m(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function f(e,t){let a;for(;"string"==typeof(a=this.refs[t]);)t=a;return a||this.schemas[t]||_.call(this,e,t)}function _(e,t){const a=this.opts.uriResolver.parse(t),n=(0,o._getFullPath)(this.opts.uriResolver,a);let r=(0,o.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===r)return E.call(this,a,e);const i=(0,o.normalizeId)(n),s=this.refs[i]||this.schemas[i];if("string"==typeof s){const t=_.call(this,e,s);if("object"!=typeof(null==t?void 0:t.schema))return;return E.call(this,a,t)}if("object"==typeof(null==s?void 0:s.schema)){if(s.validate||d.call(this,s),i===(0,o.normalizeId)(t)){const{schema:t}=s,{schemaId:a}=this.opts,n=t[a];return n&&(r=(0,o.resolveUrl)(this.opts.uriResolver,r,n)),new l({schema:t,schemaId:a,root:e,baseId:r})}return E.call(this,a,s)}}t.SchemaEnv=l,t.compileSchema=d,t.resolveRef=function(e,t,a){var n;a=(0,o.resolveUrl)(this.opts.uriResolver,t,a);const r=e.refs[a];if(r)return r;let i=f.call(this,e,a);if(void 0===i){const r=null===(n=e.localRefs)||void 0===n?void 0:n[a],{schemaId:o}=this.opts;r&&(i=new l({schema:r,schemaId:o,root:e,baseId:t}))}return void 0!==i?e.refs[a]=u.call(this,i):void 0},t.getCompilingSchema=c,t.resolveSchema=_;const h=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function E(e,{baseId:t,schema:a,root:n}){var r;if("/"!==(null===(r=e.fragment)||void 0===r?void 0:r[0]))return;for(const n of e.fragment.slice(1).split("/")){if("boolean"==typeof a)return;const e=a[(0,s.unescapeFragment)(n)];if(void 0===e)return;const r="object"==typeof(a=e)&&a[this.opts.schemaId];!h.has(n)&&r&&(t=(0,o.resolveUrl)(this.opts.uriResolver,t,r))}let i;if("boolean"!=typeof a&&a.$ref&&!(0,s.schemaHasRulesButRef)(a,this.RULES)){const e=(0,o.resolveUrl)(this.opts.uriResolver,t,a.$ref);i=_.call(this,n,e)}const{schemaId:p}=this.opts;return i=i||new l({schema:a,schemaId:p,root:n,baseId:t}),i.schema!==i.root.schema?i:void 0}},9409:(e,t,a)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.extendErrors=t.resetErrorsCount=t.reportExtraError=t.reportError=t.keyword$DataError=t.keywordError=void 0;const n=a(7898),r=a(458),i=a(3036);function o(e,t){const a=e.const("err",t);e.if(n._`${i.default.vErrors} === null`,()=>e.assign(i.default.vErrors,n._`[${a}]`),n._`${i.default.vErrors}.push(${a})`),e.code(n._`${i.default.errors}++`)}function s(e,t){const{gen:a,validateName:r,schemaEnv:i}=e;i.$async?a.throw(n._`new ${e.ValidationError}(${t})`):(a.assign(n._`${r}.errors`,t),a.return(!1))}t.keywordError={message:({keyword:e})=>n.str`must pass "${e}" keyword validation`},t.keyword$DataError={message:({keyword:e,schemaType:t})=>t?n.str`"${e}" keyword must be ${t} ($data)`:n.str`"${e}" keyword is invalid ($data)`},t.reportError=function(e,a=t.keywordError,r,i){const{it:p}=e,{gen:d,compositeRule:u,allErrors:c}=p,m=l(e,a,r);(null!=i?i:u||c)?o(d,m):s(p,n._`[${m}]`)},t.reportExtraError=function(e,a=t.keywordError,n){const{it:r}=e,{gen:p,compositeRule:d,allErrors:u}=r;o(p,l(e,a,n)),d||u||s(r,i.default.vErrors)},t.resetErrorsCount=function(e,t){e.assign(i.default.errors,t),e.if(n._`${i.default.vErrors} !== null`,()=>e.if(t,()=>e.assign(n._`${i.default.vErrors}.length`,t),()=>e.assign(i.default.vErrors,null)))},t.extendErrors=function({gen:e,keyword:t,schemaValue:a,data:r,errsCount:o,it:s}){if(void 0===o)throw new Error("ajv implementation error");const p=e.name("err");e.forRange("i",o,i.default.errors,o=>{e.const(p,n._`${i.default.vErrors}[${o}]`),e.if(n._`${p}.instancePath === undefined`,()=>e.assign(n._`${p}.instancePath`,(0,n.strConcat)(i.default.instancePath,s.errorPath))),e.assign(n._`${p}.schemaPath`,n.str`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign(n._`${p}.schema`,a),e.assign(n._`${p}.data`,r))})};const p={keyword:new n.Name("keyword"),schemaPath:new n.Name("schemaPath"),params:new n.Name("params"),propertyName:new n.Name("propertyName"),message:new n.Name("message"),schema:new n.Name("schema"),parentSchema:new n.Name("parentSchema")};function l(e,t,a){const{createErrors:r}=e.it;return!1===r?n._`{}`:function(e,t,a={}){const{gen:r,it:o}=e,s=[d(o,a),u(e,a)];return function(e,{params:t,message:a},r){const{keyword:o,data:s,schemaValue:l,it:d}=e,{opts:u,propertyName:c,topSchemaRef:m,schemaPath:f}=d;r.push([p.keyword,o],[p.params,"function"==typeof t?t(e):t||n._`{}`]),u.messages&&r.push([p.message,"function"==typeof a?a(e):a]);u.verbose&&r.push([p.schema,l],[p.parentSchema,n._`${m}${f}`],[i.default.data,s]);c&&r.push([p.propertyName,c])}(e,t,s),r.object(...s)}(e,t,a)}function d({errorPath:e},{instancePath:t}){const a=t?n.str`${e}${(0,r.getErrorPath)(t,r.Type.Str)}`:e;return[i.default.instancePath,(0,n.strConcat)(i.default.instancePath,a)]}function u({keyword:e,it:{errSchemaPath:t}},{schemaPath:a,parentSchema:i}){let o=i?t:n.str`${t}/${e}`;return a&&(o=n.str`${o}${(0,r.getErrorPath)(a,r.Type.Str)}`),[p.schemaPath,o]}},9417:e=>{e.exports=JSON.parse('{"name":"logictype","description":null,"description_zh_TW":null,"description_ja_JP":null,"commands":{"LOGICTYPE_AND":{"name":"And","description":"And","description_zh_TW":"且","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"},{"name":"other","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"bool"}]},"LOGICTYPE_CLONE":{"name":"Clone","description":"Clone value","description_zh_TW":"Clone value","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"any"}]},"LOGICTYPE_EQUAL_VALUE":{"name":"Equal value","description":"Compare by value (deep)","description_zh_TW":"判斷兩個參數是否相等 (深度比對)","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"},{"name":"other","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"bool"}]},"LOGICTYPE_IF":{"name":"If","description":"Condition for return truthy or falsy","description_zh_TW":"判斷 condition 來決定是傳回 truthy 或是 falsy 的指定值","arg":[{"name":"condition","type":"any","subType":false,"defaultValue":"undefined"},{"name":"truthy","type":"any","subType":false,"defaultValue":"undefined"},{"name":"falsy","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"any"}]},"LOGICTYPE_IS_ARRAY":{"name":"Is array","description":"Is it an array?","description_zh_TW":"判斷是否為陣列","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"bool"}]},"LOGICTYPE_IS_BOOLEAN":{"name":"Is boolean","description":"Is it boolean?","description_zh_TW":"判斷是否為布林值","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"bool"}]},"LOGICTYPE_IS_DATETIME":{"name":"Is datetime","description":"Is it a datetime?","description_zh_TW":"判斷是否為時間","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"bool"}]},"LOGICTYPE_IS_EMPTY":{"name":"Is empty","description":"Is it empty?","description_zh_TW":"判斷是否為空值","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"bool"}]},"LOGICTYPE_IS_INTEGER":{"name":"Is integer","description":"Is it integer?","description_zh_TW":"判斷是否為整數","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"bool"}]},"LOGICTYPE_IS_NUMBER":{"name":"Is number","description":"Is it a number?","description_zh_TW":"判斷是否為數字","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"bool"}]},"LOGICTYPE_IS_OBJECT":{"name":"Is object","description":"Is it a object?","description_zh_TW":"判斷是否為物件","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"bool"}]},"LOGICTYPE_IS_STRING":{"name":"Is string","description":"Is it string?","description_zh_TW":"判斷是否為字串","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"bool"}]},"LOGICTYPE_NOT":{"name":"Not","description":"Not","description_zh_TW":"反向值","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"bool"}]},"LOGICTYPE_NOT_EQUAL_VALUE":{"name":"Not equal value","description":"Compare not equal by value (deep)","description_zh_TW":"判斷兩個參數是否不相等 (深度比對)","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"},{"name":"other","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"bool"}]},"LOGICTYPE_OR":{"name":"或","description":"","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"},{"name":"other","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"bool"}]},"LOGICTYPE_TO_ARRAY":{"name":"Convert to array","description":"Convert to array if possible, return fail_value if failed (Supported JSON)","description_zh_TW":"盡可能的轉換為陣列,若轉換失敗則回傳 fail_value (支援 JSON)","arg":[{"name":"value","type":"any","subType":false},{"name":"fail_value","type":"array","subType":false,"defaultValue":"[]"}],"return":[{"name":"result","type":"array"}]},"LOGICTYPE_TO_BOOLEAN":{"name":"Convert to boolean","description":"Convert to boolean","description_zh_TW":"轉換為布林值","arg":[{"name":"value","type":"any","subType":false}],"return":[{"name":"result","type":"bool"}]},"LOGICTYPE_TO_DATETIME":{"name":"Convert to datetime","description":"Convert to datetime if possible, return fail_value if failed","description_zh_TW":"盡可能的換為日期時間,若轉換失敗則回傳 fail_value","arg":[{"name":"value","type":"any","subType":false},{"name":"fail_value","type":"datetime","subType":false,"defaultValue":"DATETIME_NOW"}],"return":[{"name":"result","type":"datetime"}]},"LOGICTYPE_TO_INTEGER":{"name":"Convert to integer","description":"Convert to integer if possible, return fail_value if failed","description_zh_TW":"盡可能的換為整數,若轉換失敗則回傳 fail_value","arg":[{"name":"value","type":"any","subType":false},{"name":"fail_value","type":"integer","subType":false,"defaultValue":"0"}],"return":[{"name":"result","type":"integer"}]},"LOGICTYPE_TO_NUMBER":{"name":"Convert to number","description":"Convert to number if possible, return fail_value if failed","description_zh_TW":"盡可能的換為數字,若轉換失敗則回傳 fail_value","arg":[{"name":"value","type":"any","subType":false},{"name":"fail_value","type":"number","subType":false,"defaultValue":"0"}],"return":[{"name":"result","type":"number"}]},"LOGICTYPE_TO_OBJECT":{"name":"Convert to object","description":"Convert to object if possible, return fail_value if failed (Supported JSON)","description_zh_TW":"盡可能的轉換為物件,若轉換失敗則回傳 fail_value (支援 JSON)","arg":[{"name":"value","type":"any","subType":false},{"name":"fail_value","type":"object","subType":false,"defaultValue":"{}"}],"return":[{"name":"result","type":"object"}]},"LOGICTYPE_TO_STRING":{"name":"Convert to string","description":"Convert to string if possible, return fail_value if failed (Supported JSON and Datetime format)","description_zh_TW":"盡可能的轉換為日期時間,若轉換失敗則回傳 fail_value (支援 JSON 以及 Datetime format)","arg":[{"name":"value","type":"any","subType":false},{"name":"fail_value","type":"string","subType":false,"defaultValue":"\\"\\""}],"return":[{"name":"result","type":"string"}]},"LOGICTYPE_XOR":{"name":"XOR","description":"XOR","description_zh_TW":"互斥或","arg":[{"name":"value","type":"any","subType":false,"defaultValue":"undefined"},{"name":"other","type":"any","subType":false,"defaultValue":"undefined"}],"return":[{"name":"result","type":"bool"}]}}}')},9430:(e,t,a)=>{Object.defineProperty(t,"__esModule",{value:!0});const n={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:a(4450).validateUnion,error:{message:"must match a schema in anyOf"}};t.default=n},9436:e=>{function t(e,t,a,n,r,i,o){try{var s=e[i](o),p=s.value}catch(e){return void a(e)}s.done?t(p):Promise.resolve(p).then(n,r)}e.exports=function(e){return function(){var a=this,n=arguments;return new Promise(function(r,i){var o=e.apply(a,n);function s(e){t(o,r,i,s,p,"next",e)}function p(e){t(o,r,i,s,p,"throw",e)}s(void 0)})}},e.exports.__esModule=!0,e.exports.default=e.exports},9458:(e,t,a)=>{const{getIDPattern:n}=a(1639),r=n("SUBSPACE"),i=n("TEST");e.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://display.bricks.tools/root.schema.json5",title:"Root",description:"A brick root config",type:"object",properties:{title:{type:"string",description:"The root config name."},root_subspace_id:{type:"string",description:"The root subspace id.",pattern:r},subspace_map:{type:"object",patternProperties:{[r]:{$ref:"http://display.bricks.tools/subspace.schema.json5",description:"Root config can have many subspace."}},additionalProperties:!1},test_map:{type:"object",patternProperties:{[i]:{$ref:"http://display.bricks.tw/test.schema.json5",description:"Root config can have many test."}},additionalProperties:!1,deprecated:!0,description:"Deprecated in favor of automation_map.AUTOMATION_MAP_DEFAULT"},automation_map:{$ref:"http://display.bricks.tools/automation_map.schema.json5",description:"Maps of automation tests organized by collection"},show_viewports:{type:"boolean",description:"Show device viewport reference on editor"},enable_unstable_bricks:{type:"boolean",description:"Enable unstable bricks / generators"},hide_short_refs:{type:"boolean",description:"Hide all instances in Short Edit mode"},warnings:{type:"array",description:"Config validation warnings from server"}},required:["title","subspace_map","root_subspace_id"]}},9470:e=>{e.exports=JSON.parse('{"name":"BrickCamera","brickDescription":{"default":"Brick camera component","en-us":"Camera view brick ([Tutorial](https://intercom.help/bricks-dag-inc/articles/5378589-camera))","zh-tw":"攝像頭顯示方塊 ([教學](https://intercom.help/bricks-dag-inc/articles/5378589-camera))","ja-jp":"カメラビューブリック ([チュートリアル](https://intercom.help/bricks-dag-inc/articles/5378589-camera))"},"brickDisplayName":"Camera","brickTip":{"default":"@brick-tip-camera","en-us":"Add a Device Camera Viewer with Type, Ratio, etc. setting.(Control by Camera Generator and Event)","zh-tw":"攝影機顯示元件,可透過 Type 決定鏡頭。需透過 Camera Generator 及事件做控制","ja-jp":"タイプやアスペクト比などの設定を備えたデバイスカメラビューアーを追加します。(カメラジェネレーターとイベントで制御)"},"brickMeta":{"hasActions":true,"scriptMember":true},"brickPreviewIcon":{"type":"font-awesome-6pro","name":"camera"},"propTypes":{"type":{"type":"oneOf","content":["back","front","external"],"forcePropertyBank":false},"isActive":{"type":"bool"},"zoom":{"type":"number"},"flashMode":{"type":"oneOf","content":["off","on","torch","auto"],"forcePropertyBank":false},"ratio":{"type":"string"},"captureAudio":{"type":"bool"},"whiteBalance":{"type":"oneOf","content":["auto","sunny","cloudy","shadow","incandescent","fluorescent"],"forcePropertyBank":false},"faceDetectionEnabled":{"type":"bool"},"faceDetectionEventMode":{"type":"oneOf","content":["when-detected","interval"],"forcePropertyBank":false},"pictureQuality":{"type":"number"},"pictureBase64":{"type":"bool"},"pictureIsMirrorImage":{"type":"bool"},"recordQuality":{"type":"oneOf","content":["4:3","288p","480p","720p","1080p","2160p"],"forcePropertyBank":false},"recordVideoBitrate":{"type":"number"},"recordMirrorVideo":{"type":"bool"},"recordMaxDuration":{"type":"number"},"recordMaxFileSize":{"type":"number"}},"brickPropDescriptions":{"type":{"default":"","en-us":"Camera type","zh-tw":"攝像頭位置","ja-jp":"カメラタイプ"},"isActive":{"default":"","en-us":"Enable or disable camera","zh-tw":"啟用或停用攝像頭","ja-jp":"カメラを有効または無効にする"},"zoom":{"default":"","en-us":"Camera zoom","zh-tw":"放大比例","ja-jp":"カメラズーム"},"flashMode":{"default":"","en-us":"Camera flash mode","zh-tw":"閃光模式","ja-jp":"カメラのフラッシュモード"},"ratio":{"default":"","en-us":"Camera ratio (Unsupported ratio will be ignored)","zh-tw":"相機比例(不支援的比例會被忽略)","ja-jp":"カメラ比率(サポートされていない比率は無視されます)"},"captureAudio":{"default":"","en-us":"Capture audio when start recording","zh-tw":"錄製影片時包含聲音","ja-jp":"録画開始時に音声もキャプチャする"},"whiteBalance":{"default":"","en-us":"Allows you to control the color temperature in your photos by cooling down or warming up the colors.","zh-tw":"白平衡設定","ja-jp":"色温度を調整して写真の色を冷たくしたり暖かくしたりすることができます"},"faceDetectionEnabled":{"default":"","en-us":"Enable face detection (Note: Barcode detection will be disabled when enabled)","zh-tw":"啟用臉部偵測(注意:啟用時條碼偵測將會停用)","ja-jp":"顔検出を有効化(注意:有効にするとバーコード検出は無効になります)"},"faceDetectionEventMode":{"default":"","en-us":"Face detection event mode","zh-tw":"Face detection event mode","ja-jp":"顔検出イベントモード"},"pictureQuality":{"default":"","en-us":"Quality of take picture","zh-tw":"擷取照片品質","ja-jp":"撮影画質"},"pictureBase64":{"default":"","en-us":"Take picture format as base64","zh-tw":"以 base64 格式資料作為擷取照片結果","ja-jp":"撮影画像をbase64形式で出力"},"pictureIsMirrorImage":{"default":"","en-us":"Mirror image of take picture","zh-tw":"擷取照片以鏡像呈現","ja-jp":"撮影画像を鏡像として表示"},"recordQuality":{"default":"","en-us":"Quality of record video","zh-tw":"錄製影片品質","ja-jp":"録画品質"},"recordVideoBitrate":{"default":"","en-us":"Bitrate of record video (bit/s)","zh-tw":"錄製影片位元傳輸率 (bit/s)","ja-jp":"録画ビットレート (bit/s)"},"recordMirrorVideo":{"default":"","en-us":"Mirror video of record video","zh-tw":"擷取照片以鏡像呈現","ja-jp":"録画を鏡像として表示"},"recordMaxDuration":{"default":"","en-us":"Max duration of record video (s)","zh-tw":"限制錄製最大時間 (s)","ja-jp":"録画の最大時間 (s)"},"recordMaxFileSize":{"default":"","en-us":"Max file size of record video (bytes)","zh-tw":"限制錄製最大檔案大小 (bytes)","ja-jp":"録画の最大ファイルサイズ (bytes)"}},"defaultBrickProps":{"type":"back","flashMode":"off","captureAudio":false,"whiteBalance":"auto","faceDetectionEnabled":false,"faceDetectionEventMode":"when-detected"},"propertyControls":{"zoom":{"kind":"unit","step":0.5,"max":16,"min":1},"flashMode":{"oneOfEmptyOption":false},"type":{"oneOfEmptyOption":false},"whiteBalance":{"oneOfEmptyOption":false},"faceDetectionEventMode":{"oneOfEmptyOption":false},"pictureQuality":{"kind":"unit","step":0.1,"max":1,"min":0},"recordVideoBitrate":{"kind":"unit","unit":"bit/s"},"recordMaxDuration":{"kind":"unit","unit":"s"},"recordMaxFileSize":{"kind":"unit","unit":"bytes"}},"propertyControlGroups":{"faceDetection":{"name":"Face Detection","type":"prefix","content":"faceDetection"},"picture":{"name":"Picture","type":"prefix","content":"picture"},"record":{"name":"Record","type":"prefix","content":"record"}},"propertyControlGroupDescriptions":{},"outletTypes":{"BRICK_CAMERA_INFO":{"outlet":"BRICK_CAMERA_INFO","type":"object"},"BRICK_CAMERA_PICTURE_TAKEN":{"outlet":"BRICK_CAMERA_PICTURE_TAKEN","type":"object"},"BRICK_CAMERA_RECORD_VIDEO":{"outlet":"BRICK_CAMERA_RECORD_VIDEO","type":"object"},"BRICK_CAMERA_BARCODE_READ":{"outlet":"BRICK_CAMERA_BARCODE_READ","type":"object"},"BRICK_CAMERA_FACE_DETECTED":{"outlet":"BRICK_CAMERA_FACE_DETECTED","type":"object"}},"brickOutletDescriptions":{"BRICK_CAMERA_INFO":{"default":"","en-us":"Camera device and format information","zh-tw":"攝像頭裝置與格式資訊","ja-jp":"カメラデバイスとフォーマット情報"},"BRICK_CAMERA_PICTURE_TAKEN":{"default":"","en-us":"Picture taken result","zh-tw":"擷取照片結果","ja-jp":"撮影結果"},"BRICK_CAMERA_RECORD_VIDEO":{"default":"","en-us":"Record video result","zh-tw":"錄製影片結果","ja-jp":"録画結果"},"BRICK_CAMERA_BARCODE_READ":{"default":"","en-us":"Barcode read result","zh-tw":"條碼辨識結果","ja-jp":"バーコード読み取り結果"},"BRICK_CAMERA_FACE_DETECTED":{"default":"","en-us":"Faces detected result","zh-tw":"人臉偵測結果","ja-jp":"顔検出結果"}},"actionTypes":{"BRICK_CAMERA_TAKE_PICTURE":{"disallowMultiple":true,"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"BRICK_CAMERA_WIDTH":{"type":"number"},"BRICK_CAMERA_QUALITY":{"type":"string"},"BRICK_CAMERA_BASE64":{"type":"bool"},"BRICK_CAMERA_MIRROR_IMAGE":{"type":"bool"}}},"BRICK_CAMERA_RECORD":{"disallowMultiple":true,"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"BRICK_CAMERA_QUALITY":{"type":"oneOf","oneOf":["4:3","288p","480p","720p","1080p","2160p"]},"BRICK_CAMERA_MIRROR_VIDEO":{"type":"bool"},"BRICK_CAMERA_VIDEO_BITRATE":{"type":"string"},"BRICK_CAMERA_MAX_DURATION":{"type":"number"},"BRICK_CAMERA_MAX_FILE_SIZE":{"type":"string"}}},"BRICK_CAMERA_STOP_RECORD":{"disallowMultiple":true,"canProvideProperty":false},"BRICK_CAMERA_FOCUS":{"disallowMultiple":true,"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"BRICK_CAMERA_FOCUS_X":{"type":"number"},"BRICK_CAMERA_FOCUS_Y":{"type":"number"}}}},"brickActionDescriptions":{"BRICK_CAMERA_TAKE_PICTURE":{"default":"","en-us":"Take picture on the Camera","zh-tw":"擷取照片","ja-jp":"カメラで写真を撮る"},"BRICK_CAMERA_RECORD":{"default":"","en-us":"Record video on the Camera","zh-tw":"錄製影片","ja-jp":"カメラで動画を録画"},"BRICK_CAMERA_STOP_RECORD":{"default":"","en-us":"Record video on the Camera","zh-tw":"結束錄製影片","ja-jp":"カメラでの録画を停止"},"BRICK_CAMERA_FOCUS":{"default":"","en-us":"Focus the Camera at a specific point","zh-tw":"對焦至指定位置","ja-jp":"指定位置にフォーカスを合わせる"}},"eventTypes":{"BRICK_CAMERA_STATE_CHANGE":"BRICK_CAMERA_STATE_CHANGE","BRICK_CAMERA_RECORD_START":"BRICK_CAMERA_RECORD_START","BRICK_CAMERA_RECORD_END":"BRICK_CAMERA_RECORD_END","BRICK_CAMERA_BARCODE_READ":"BRICK_CAMERA_BARCODE_READ","BRICK_CAMERA_PICTURE_TAKEN":"BRICK_CAMERA_PICTURE_TAKEN","BRICK_CAMERA_RECORD_FINISH":"BRICK_CAMERA_RECORD_FINISH","BRICK_CAMERA_MOUNT_ERROR":"BRICK_CAMERA_MOUNT_ERROR"},"brickEventDescriptions":{"BRICK_CAMERA_STATE_CHANGE":{"default":"","en-us":"Event of the Camera state change","zh-tw":"Event of the Camera state change","ja-jp":"カメラの状態変更イベント"},"BRICK_CAMERA_RECORD_START":{"default":"","en-us":"Event of the Camera record start","zh-tw":"當錄製開始時觸發事件","ja-jp":"カメラの録画開始イベント"},"BRICK_CAMERA_RECORD_END":{"default":"","en-us":"Event of the Camera record end","zh-tw":"當錄製結束時觸發事件","ja-jp":"カメラの録画終了イベント"},"BRICK_CAMERA_BARCODE_READ":{"default":"","en-us":"Event of the Camera barcode read","zh-tw":"當讀取到條碼時觸發事件","ja-jp":"カメラのバーコード読み取りイベント"},"BRICK_CAMERA_PICTURE_TAKEN":{"default":"","en-us":"Event of the Camera picture taken","zh-tw":"當擷取照片完畢時觸發事件","ja-jp":"カメラの写真撮影完了イベント"},"BRICK_CAMERA_RECORD_FINISH":{"default":"","en-us":"Event of the Camera record finished","zh-tw":"當錄製影片完畢時觸發事件","ja-jp":"カメラの録画完了イベント"},"BRICK_CAMERA_MOUNT_ERROR":{"default":"","en-us":"Event of the Camera mount error","zh-tw":"當攝像頭掛載失敗時觸發事件","ja-jp":"カメラのマウントエラーイベント"}},"eventPropertyControls":{"BRICK_CAMERA_STATE_CHANGE":{"properties":{"BRICK_CAMERA_STATUS":{"name":"Status","type":"string"},"BRICK_CAMERA_RECORD_AUDIO_PERM_STATUS":{"name":"Record Audio Permission Status","type":"string"}}},"BRICK_CAMERA_BARCODE_READ":{"properties":{"BRICK_CAMERA_BARCODE_TYPE":{"name":"Type","type":"string"},"BRICK_CAMERA_BARCODE_DATA":{"name":"Data","type":"string"},"BRICK_CAMERA_BARCODE_RAW_DATA":{"name":"Raw Data","type":"string"},"BRICK_CAMERA_BARCODE_X":{"name":"X","type":"number"},"BRICK_CAMERA_BARCODE_Y":{"name":"Y","type":"number"},"BRICK_CAMERA_BARCODE_WIDTH":{"name":"Width","type":"number"},"BRICK_CAMERA_BARCODE_HEIGHT":{"name":"Height","type":"number"}}},"BRICK_CAMERA_PICTURE_TAKEN":{"properties":{"BRICK_CAMERA_WIDTH":{"name":"Width","type":"number"},"BRICK_CAMERA_HEIGHT":{"name":"Height","type":"number"},"BRICK_CAMERA_URI":{"name":"URI","type":"string"}}},"BRICK_CAMERA_RECORD_FINISH":{"properties":{"BRICK_CAMERA_URI":{"name":"URI","type":"string"}}},"BRICK_CAMERA_MOUNT_ERROR":{"properties":{"BRICK_CAMERA_MOUNT_ERROR":{"name":"Error","type":"string"}}}},"scriptMemberFunctionDefs":{"takePicture":{"description":"Take a picture with the camera","arguments":[{"type":"object","name":"options","properties":{"quality":{"type":"number","description":"Picture quality (0-1)","default":0.6},"base64":{"type":"boolean","description":"Return base64 encoded image data","default":false},"isImageMirror":{"type":"boolean","description":"Mirror the captured image","default":false}}}],"required":[],"return":{"type":"object","description":"Picture data with width, height, uri, and optional base64"},"timeout":10000},"startRecord":{"description":"Start recording video with the camera","arguments":[{"type":"object","name":"options","properties":{"quality":{"type":"string","description":"Video quality (4:3, 288p, 480p, 720p, 1080p, 2160p)"},"videoBitrate":{"type":"number","description":"Video bitrate in bit/s"},"mirror":{"type":"boolean","description":"Mirror the recorded video","default":false},"maxDuration":{"type":"number","description":"Maximum recording duration in seconds"},"maxFileSize":{"type":"number","description":"Maximum file size in bytes"},"waitEnd":{"type":"boolean","description":"Wait for recording to end before resolving","default":false}}}],"required":[],"return":{"type":"object","description":"Recording result with uri (if waitEnd is true) or recording start confirmation"}},"stopRecord":{"description":"Stop recording video","arguments":[],"required":[],"return":{"type":"boolean"}},"pausePreview":{"description":"Pause camera preview","arguments":[],"required":[],"return":{"type":"boolean"}},"resumePreview":{"description":"Resume camera preview","arguments":[],"required":[],"return":{"type":"boolean"}},"focus":{"description":"Focus the camera at a specific point (tap-to-focus)","arguments":[{"type":"object","name":"point","properties":{"x":{"type":"number","description":"X coordinate (0-1 normalized or pixel value). 0 = left edge, 1 = right edge"},"y":{"type":"number","description":"Y coordinate (0-1 normalized or pixel value). 0 = top edge, 1 = bottom edge"}}}],"required":["point"],"return":{"type":"boolean","description":"True if focus was triggered successfully"}}},"scriptMemberFunctionDefDescriptions":{}}')},9520:(e,t,a)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=a(7898),r=a(458),i=a(2725),o={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:e})=>n._`{allowedValue: ${e}}`},code(e){const{gen:t,data:a,$data:o,schemaCode:s,schema:p}=e;o||p&&"object"==typeof p?e.fail$data(n._`!${(0,r.useFunc)(t,i.default)}(${a}, ${s})`):e.fail(n._`${p} !== ${a}`)}};t.default=o},9537:(e,t,a)=>{a.d(t,{_:()=>s,k:()=>o});var n=a(3217),r=a(5198),i=a(792);class o{constructor(e,t="GraphQL request",a={line:1,column:1}){"string"==typeof e||(0,n.U)(!1,`Body must be a string. Received: ${(0,r.N)(e)}.`),this.body=e,this.name=t,this.locationOffset=a,this.locationOffset.line>0||(0,n.U)(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||(0,n.U)(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}function s(e){return(0,i.h)(e,o)}},9546:e=>{var t=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;e.exports=function(e){return e.match(t)||[]}},9557:(e,t,a)=>{e.exports=(e=>{var t={};return a.d(t,e),t})({TerminalInfoProvider:()=>s.TerminalInfoProvider,default:()=>s.default})},9563:e=>{e.exports=JSON.parse('{"name":"GeneratorIterator","brickDescription":{"default":"","en-us":"Iterate through values (Array, Object, Number, String)","zh-tw":"數值迭代 (Array, Object, Number, String)","ja-jp":"値を反復処理 (配列、オブジェクト、数値、文字列)"},"brickDisplayName":"Iterator","brickTip":{"default":""},"brickPreviewIcon":{"type":"font-awesome-6pro","name":"rotate"},"propTypes":{"data":{"type":"any"},"start":{"type":"number"},"step":{"type":"number"},"maxQuantity":{"type":"number"},"loop":{"type":"bool"}},"brickPropDescriptions":{"data":{"default":"","en-us":"Data source for iteration. If it\'s an Array, it will iterate through elements. If it\'s an Object, it will use Object.entries() to get key-value pairs. If it\'s a String, it will iterate through characters. If it\'s a Number, it represents count from 1 to N.","zh-tw":"用來取值的資料來源,如果為 Array 則會取得元素,如果為 Object 則使用 Object.entries() 取得鍵值對,如果為 String 則迭代字元,如果為 Number 則代表由 1~N 的計數","ja-jp":"反復処理のためのデータソース。配列の場合は要素を取得し、オブジェクトの場合はObject.entries()でキーと値のペアを取得し、文字列の場合は文字を反復処理し、数値の場合は1〜Nのカウントを表します"},"start":{"default":"","en-us":"Starting element position","zh-tw":"起始元素位置","ja-jp":"開始要素の位置"},"step":{"default":"","en-us":"Step size for each iteration","zh-tw":"單次跳動的位移量","ja-jp":"各反復の増分"},"maxQuantity":{"default":"","en-us":"Maximum number of iterations (can be set to -1 for unlimited). When reached, further iteration actions will be silently ignored.","zh-tw":"總共可迭代個數上限 (可以設置為 -1 作為無上限)。達到上限後,後續的迭代動作將被靜默忽略。","ja-jp":"反復処理の最大数(無制限の場合は-1に設定可能)。上限に達すると、それ以降の反復アクションは静かに無視されます。"},"loop":{"default":"","en-us":"Whether to loop the iteration","zh-tw":"是否循環迭代","ja-jp":"反復処理をループするかどうか"}},"defaultBrickProps":{"data":[],"start":0,"step":1},"propertyControls":{"data":{"setupDefaultAfterNewItemOfSchema":true,"required":true},"step":{"kind":"unit","min":1,"step":1}},"outletTypes":{"GENERATOR_ITERATOR_ITERATED_ARRAY":{"outlet":"GENERATOR_ITERATOR_ITERATED_ARRAY","type":"array"},"GENERATOR_ITERATOR_UPCOMING_ARRAY":{"outlet":"GENERATOR_ITERATOR_UPCOMING_ARRAY","type":"array"},"GENERATOR_ITERATOR_VALUE":{"outlet":"GENERATOR_ITERATOR_VALUE","type":"any"},"GENERATOR_ITERATOR_KEY":{"outlet":"GENERATOR_ITERATOR_KEY","type":"any"},"GENERATOR_ITERATOR_INDEX":{"outlet":"GENERATOR_ITERATOR_INDEX","type":"number"}},"brickOutletDescriptions":{"GENERATOR_ITERATOR_ITERATED_ARRAY":{"default":"","en-us":"Elements that have been iterated (including current one)","zh-tw":"已經迭代過的元素(包含目前的)","ja-jp":"反復処理された要素(現在のものを含む)"},"GENERATOR_ITERATOR_UPCOMING_ARRAY":{"default":"","en-us":"Elements that will be iterated but have not been iterated yet","zh-tw":"會參與迭代但尚未迭代過的元素","ja-jp":"反復処理される予定だがまだ処理されていない要素"},"GENERATOR_ITERATOR_VALUE":{"default":"","en-us":"Current iteration element","zh-tw":"目前的迭代元素","ja-jp":"現在の反復要素"},"GENERATOR_ITERATOR_KEY":{"default":"","en-us":"Key of the current iteration element (for number: same as value, for array/string: index, for object: string key)","zh-tw":"目前迭代元素的 Key(number: 則此值與 value 相同,array, string: 則此值為 index,object: 則此值為字串)","ja-jp":"現在の反復要素のキー(数値の場合:値と同じ、配列・文字列の場合:インデックス、オブジェクトの場合:文字列キー)"},"GENERATOR_ITERATOR_INDEX":{"default":"","en-us":"Current iteration count (if data is 6 and step is 2, this will return: 1,2,3 in sequence)","zh-tw":"目前的迭代次數(如果 data 為 6, step 為 2,則此值會依序回傳:1,2,3)","ja-jp":"現在の反復回数(dataが6でstepが2の場合、この値は順番に1,2,3を返します)"}},"actionTypes":{"GENERATOR_ITERATOR_NEXT":{"canProvideProperty":false},"GENERATOR_ITERATOR_PREVIOUS":{"canProvideProperty":false},"GENERATOR_ITERATOR_FIRST":{"canProvideProperty":false},"GENERATOR_ITERATOR_LAST":{"canProvideProperty":false},"GENERATOR_ITERATOR_RESET":{"canProvideProperty":false}},"brickActionDescriptions":{"GENERATOR_ITERATOR_NEXT":{"default":"","en-us":"Proceed to next iteration","zh-tw":"進行下一次迭代","ja-jp":"次の反復に進む"},"GENERATOR_ITERATOR_PREVIOUS":{"default":"","en-us":"Go back to previous iteration","zh-tw":"退回至上一次迭代","ja-jp":"前の反復に戻る"},"GENERATOR_ITERATOR_FIRST":{"default":"","en-us":"Jump to the first iteration element","zh-tw":"跳至第一個迭代元素","ja-jp":"最初の反復要素にジャンプする"},"GENERATOR_ITERATOR_LAST":{"default":"","en-us":"Jump to the last iteration element (ignoring the loop setting)","zh-tw":"跳至最後一個迭代元素(忽略 loop 的設定值)","ja-jp":"最後の反復要素にジャンプする(loop設定を無視)"},"GENERATOR_ITERATOR_RESET":{"default":"","en-us":"Reset iteration state","zh-tw":"重置迭代狀態","ja-jp":"反復状態をリセット"}},"eventTypes":{"GENERATOR_ITERATOR_ITERATE":"GENERATOR_ITERATOR_ITERATE","GENERATOR_ITERATOR_FIRST":"GENERATOR_ITERATOR_FIRST","GENERATOR_ITERATOR_END":"GENERATOR_ITERATOR_END","GENERATOR_ITERATOR_ERROR":"GENERATOR_ITERATOR_ERROR"},"brickEventDescriptions":{"GENERATOR_ITERATOR_ITERATE":{"default":"","en-us":"Event triggered on each iteration","zh-tw":"每次發生迭代都會觸發此 Event","ja-jp":"各反復処理で発生するイベント"},"GENERATOR_ITERATOR_FIRST":{"default":"","en-us":"Event triggered on the first iteration of a round","zh-tw":"當單輪首次迭代會觸發此 Event","ja-jp":"1回の反復処理の最初に発生するイベント"},"GENERATOR_ITERATOR_END":{"default":"","en-us":"Event triggered on the last iteration of a round","zh-tw":"當單輪迭代至最後會觸發此 Event","ja-jp":"1回の反復処理の最後に発生するイベント"},"GENERATOR_ITERATOR_ERROR":{"default":"","en-us":"Event triggered when data type is invalid or unexpected","zh-tw":"當資料類型無效或非預期時觸發此 Event","ja-jp":"データ型が無効または予期しない場合に発生するイベント"}},"eventPropertyControls":{"GENERATOR_ITERATOR_ITERATE":{"properties":{"GENERATOR_ITERATOR_ITERATE_VALUE":{"name":"Value","type":"any"},"GENERATOR_ITERATOR_ITERATE_KEY":{"name":"Key","type":"any"},"GENERATOR_ITERATOR_ITERATE_INDEX":{"name":"Index","type":"number"}}},"GENERATOR_ITERATOR_FIRST":{"properties":{"GENERATOR_ITERATOR_ITERATE_VALUE":{"name":"Value","type":"any"},"GENERATOR_ITERATOR_ITERATE_KEY":{"name":"Key","type":"any"},"GENERATOR_ITERATOR_ITERATE_INDEX":{"name":"Index","type":"number"}}},"GENERATOR_ITERATOR_END":{"properties":{"GENERATOR_ITERATOR_ITERATE_VALUE":{"name":"Value","type":"any"},"GENERATOR_ITERATOR_ITERATE_KEY":{"name":"Key","type":"any"},"GENERATOR_ITERATOR_ITERATE_INDEX":{"name":"Index","type":"number"}}},"GENERATOR_ITERATOR_ERROR":{"properties":{"GENERATOR_ITERATOR_ERROR_MESSAGE":{"name":"Error Message","type":"string"},"GENERATOR_ITERATOR_ERROR_DATA":{"name":"Invalid Data","type":"any"}}}}}')},9594:(e,t,a)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=a(4450),r=a(7898),i=a(458),o={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:e}})=>r.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>r._`{missingProperty: ${e}}`},code(e){const{gen:t,schema:a,schemaCode:o,data:s,$data:p,it:l}=e,{opts:d}=l;if(!p&&0===a.length)return;const u=a.length>=d.loopRequired;if(l.allErrors?function(){if(u||p)e.block$data(r.nil,c);else for(const t of a)(0,n.checkReportMissingProp)(e,t)}():function(){const i=t.let("missing");if(u||p){const a=t.let("valid",!0);e.block$data(a,()=>function(a,i){e.setParams({missingProperty:a}),t.forOf(a,o,()=>{t.assign(i,(0,n.propertyInData)(t,s,a,d.ownProperties)),t.if((0,r.not)(i),()=>{e.error(),t.break()})},r.nil)}(i,a)),e.ok(a)}else t.if((0,n.checkMissingProp)(e,a,i)),(0,n.reportMissingProp)(e,i),t.else()}(),d.strictRequired){const t=e.parentSchema.properties,{definedProperties:n}=e.it;for(const e of a)if(void 0===(null==t?void 0:t[e])&&!n.has(e)){const t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,i.checkStrictMode)(l,t,l.opts.strictRequired)}}function c(){t.forOf("prop",o,a=>{e.setParams({missingProperty:a}),t.if((0,n.noPropertyInData)(t,s,a,d.ownProperties),()=>e.error())})}}};t.default=o},9611:e=>{e.exports=JSON.parse('{"name":"GeneratorOnnxLLM","brickDescription":{"default":"Local LLM inference","en-us":"Local LLM inference based on [transformers.js](https://huggingface.co/docs/transformers.js) \\n You can use any converted model on HuggingFace.","zh-tw":"基於 [transformers.js](https://huggingface.co/docs/transformers.js) 的本地 LLM 推論 \\n 您可以使用 HuggingFace 上任何轉換過的模型。","ja-jp":"[transformers.js](https://huggingface.co/docs/transformers.js) に基づくローカル LLM 推論 \\n HuggingFace で変換されたどのモデルでも使用できます。"},"brickDisplayName":"LLM (ONNX)","brickTip":{"default":""},"brickPreviewIcon":{"type":"font-awesome-6pro","name":"microchip-ai"},"brickMeta":{"preview":true,"scriptMember":true},"propTypes":{"init":{"type":"bool"},"model":{"type":"string"},"modelType":{"type":"string"},"quantizeType":{"type":"oneOf","content":["auto","none","fp16","q8","int8","uint8","q4","bnb4","q4f16"],"forcePropertyBank":false},"prompt":{"type":"string"},"messages":{"type":"arrayOf","content":{"type":"shape","content":{},"forcePropertyBank":false},"forcePropertyBank":false},"images":{"type":"arrayOf","content":{"type":"string"},"forcePropertyBank":false},"audios":{"type":"arrayOf","content":{"type":"string"},"forcePropertyBank":false},"toolCallParser":{"type":"oneOf","content":["llama3_json","mistral","hermes","internlm","phi4"],"forcePropertyBank":false},"tools":{"type":"arrayOf","content":{"type":"object"},"forcePropertyBank":false},"toolChoice":{"type":"oneOf","content":["none","auto"],"forcePropertyBank":false},"maxNewTokens":{"type":"number"},"temperature":{"type":"number"},"topK":{"type":"number"},"topP":{"type":"number"},"repetitionPenalty":{"type":"number"},"noRepeatNgramSize":{"type":"number"},"numBeams":{"type":"number"},"doSample":{"type":"bool"},"executors":{"type":"arrayOf","content":{"type":"oneOf","content":["qnn","dml","nnapi","xnnpack","coreml","cpu","wasm","webgpu"],"forcePropertyBank":false},"forcePropertyBank":false},"executionMode":{"type":"oneOf","content":["sequential","parallel"],"forcePropertyBank":false},"qnnBackend":{"type":"oneOf","content":["HTP","HTA","DSP","GPU","CPU"],"forcePropertyBank":false},"qnnHtpEnableFp16":{"type":"bool"},"qnnEnableDebug":{"type":"bool"}},"brickPropDescriptions":{"init":{"default":"","en-us":"Initialize the TTS context on generator initialization","zh-tw":"在 generator 初始化時是否要初始化","ja-jp":"generator の初期化時に TTS コンテキストを初期化する"},"model":{"default":"","en-us":"LLM model","zh-tw":"LLM 模型","ja-jp":"LLM モデル"},"modelType":{"default":"","en-us":"Model type","zh-tw":"模型類型","ja-jp":"モデルタイプ"},"quantizeType":{"default":"","en-us":"Quantize type","zh-tw":"量化類型","ja-jp":"量子化タイプ"},"prompt":{"default":"","en-us":"Prompt to inference","zh-tw":"要推論的提示","ja-jp":"推論するためのプロンプト"},"messages":{"default":"","en-us":"Messages to inference","zh-tw":"要推論的訊息","ja-jp":"推論するためのメッセージ"},"images":{"default":"","en-us":"Images with message to inference","zh-tw":"訊息附帶的圖片","ja-jp":"メッセージに添付する画像"},"audios":{"default":"","en-us":"Audios with message to inference","zh-tw":"訊息附帶的音檔","ja-jp":"メッセージに添付する音声"},"toolCallParser":{"default":"","en-us":"Tool call parser","zh-tw":"工具調用解析器","ja-jp":"ツールコールパーサー"},"tools":{"default":"","en-us":"Tools for chat mode using OpenAI-compatible function calling format \\n Format: Array of objects with {type, function: {name, description, parameters}} structure \\n See: https://platform.openai.com/docs/guides/function-calling","zh-tw":"聊天模式的工具,使用 OpenAI 相容的函數調用格式 \\n 格式:由 {type, function: {name, description, parameters}} 結構的物件陣列 \\n 參考:https://platform.openai.com/docs/guides/function-calling","ja-jp":"チャットモードで使用するツール。OpenAI 互換の関数呼び出し形式を使用します。 \\n 形式:{type, function: {name, description, parameters}} 構造のオブジェクトの配列 \\n 詳細:https://platform.openai.com/docs/guides/function-calling"},"toolChoice":{"default":"","en-us":"Tool choice for chat mode","zh-tw":"聊天模式的工具選擇"},"maxNewTokens":{"default":"","en-us":"Max new tokens to generate","zh-tw":"最大生成新 tokens","ja-jp":"生成する最大の新しいトークン数"},"temperature":{"default":"","en-us":"Temperature","zh-tw":"溫度","ja-jp":"温度"},"topK":{"default":"","en-us":"Top k","zh-tw":"Top k","ja-jp":"トップ k"},"topP":{"default":"","en-us":"Top p","zh-tw":"Top p","ja-jp":"トップ p"},"repetitionPenalty":{"default":"","en-us":"Repetition penalty","zh-tw":"重複懲罰","ja-jp":"繰り返しペナルティ"},"noRepeatNgramSize":{"default":"","en-us":"No repeat ngram size","zh-tw":"不重複 ngram 大小","ja-jp":"繰り返さない ngram サイズ"},"numBeams":{"default":"","en-us":"Number of beams","zh-tw":"光束數","ja-jp":"ビーム数"},"doSample":{"default":"","en-us":"Do sampling","zh-tw":"是否採樣","ja-jp":"サンプリングを行う"},"executors":{"default":"","en-us":"Executor candidates, descending order of priority \\n Default will be xnnpack, wasm, cpu","zh-tw":"執行器候選,按優先順序降序排列 \\n 預設為 xnnpack、wasm、cpu","ja-jp":"実行候補、優先順位の降順 \\n デフォルトは xnnpack、wasm、cpu"},"executionMode":{"default":"","en-us":"Execution mode \\n Usually when the model has many branches, setting this option to `parallel` will give you better performance.","zh-tw":"執行模式 \\n 通常當模型有許多分支時,將此選項設置為 `parallel` 將為您提供更好的性能。","ja-jp":"実行モード \\n 通常、モデルに多くの分岐がある場合、このオプションを `parallel` に設定するとパフォーマンスが向上します。"},"qnnBackend":{"default":"","en-us":"QNN backend","zh-tw":"QNN 後端","ja-jp":"QNN バックエンド"},"qnnHtpEnableFp16":{"default":"","en-us":"Enable FP16 for QNN HTP","zh-tw":"啟用 QNN HTP 的 FP16","ja-jp":"QNN HTP の FP16 を有効にする"},"qnnEnableDebug":{"default":"","en-us":"Enable QNN debug","zh-tw":"啟用 QNN 調試","ja-jp":"QNN デバッグを有効にする"}},"defaultBrickProps":{"modelType":"auto","toolCallParser":"llama3_json","toolChoice":"auto","maxNewTokens":256,"temperature":0.7,"topK":50,"topP":0.9,"repetitionPenalty":1,"noRepeatNgramSize":0,"numBeams":1,"doSample":true,"executionMode":"sequential"},"propertyControls":{"model":{"kind":"onnx-model-asset","fields":{"modelType":"modelType","quantizeType":"quantizeType"},"required":true},"messages":{"kind":"llm-messages"},"tools":{"kind":"llm-tools"}},"propertyControlGroups":{"inputs":{"name":"Input","type":"group","content":["prompt","messages","images","audios"]},"tools":{"name":"Tools","type":"group","content":["toolCallParser","tools","toolChoice"]},"providerOpts":{"name":"Provider Options","type":"group","content":["executors","executionMode","qnnBackend","qnnHtpEnableFp16","qnnEnableDebug"]}},"propertyControlGroupDescriptions":{},"outletTypes":{"GENERATOR_ONNX_LLM_CONTEXT_STATE":{"outlet":"GENERATOR_ONNX_LLM_CONTEXT_STATE","type":"string"},"GENERATOR_ONNX_LLM_GENERATED":{"outlet":"GENERATOR_ONNX_LLM_GENERATED","type":"string"},"GENERATOR_ONNX_LLM_FULL_RESULT":{"outlet":"GENERATOR_ONNX_LLM_FULL_RESULT","type":"string"},"GENERATOR_ONNX_LLM_LAST_FUNCTION_CALL":{"outlet":"GENERATOR_ONNX_LLM_LAST_FUNCTION_CALL","type":"object"}},"brickOutletDescriptions":{"GENERATOR_ONNX_LLM_CONTEXT_STATE":{"default":"","en-us":"Context state","zh-tw":"Context 狀態","ja-jp":"コンテキスト状態"},"GENERATOR_ONNX_LLM_GENERATED":{"default":"","en-us":"Generated output","zh-tw":"產生的輸出","ja-jp":"生成された出力"},"GENERATOR_ONNX_LLM_FULL_RESULT":{"default":"","en-us":"Full result of generation","zh-tw":"生成的完整結果","ja-jp":"生成の完全な結果"},"GENERATOR_ONNX_LLM_LAST_FUNCTION_CALL":{"default":"","en-us":"Last function call","zh-tw":"最後的函數調用"}},"eventTypes":{"GENERATOR_ONNX_LLM_ON_CONTEXT_STATE_CHANGE":"GENERATOR_ONNX_LLM_ON_CONTEXT_STATE_CHANGE","GENERATOR_ONNX_LLM_ON_FUNCTION_CALL":"GENERATOR_ONNX_LLM_ON_FUNCTION_CALL","GENERATOR_ONNX_LLM_ON_COMPLETION_FINISHED":"GENERATOR_ONNX_LLM_ON_COMPLETION_FINISHED","GENERATOR_ONNX_LLM_ON_ERROR":"GENERATOR_ONNX_LLM_ON_ERROR"},"brickEventDescriptions":{"GENERATOR_ONNX_LLM_ON_CONTEXT_STATE_CHANGE":{"default":"","en-us":"Event triggered when state change","zh-tw":"在狀態變更時觸發事件","ja-jp":"状態が変更されたときに発生するイベント"},"GENERATOR_ONNX_LLM_ON_FUNCTION_CALL":{"default":"","en-us":"Event triggered on get function call request","zh-tw":"在獲取函數調用請求時觸發事件"},"GENERATOR_ONNX_LLM_ON_COMPLETION_FINISHED":{"default":"","en-us":"Event triggered on completion finished","zh-tw":"在完成時觸發事件"},"GENERATOR_ONNX_LLM_ON_ERROR":{"default":"","en-us":"Event triggered when error occurs","zh-tw":"在發生錯誤時觸發事件","ja-jp":"エラーが発生したときに発生するイベント"}},"eventPropertyControls":{"GENERATOR_ONNX_LLM_ON_CONTEXT_STATE_CHANGE":{"properties":{"GENERATOR_ONNX_LLM_CONTEXT_STATE":{"name":"Context State","type":"string"}}},"GENERATOR_ONNX_LLM_ON_FUNCTION_CALL":{"properties":{"GENERATOR_ONNX_LLM_FUNCTION_CALL_NAME":{"name":"Function Call Name","type":"string"},"GENERATOR_ONNX_LLM_FUNCTION_CALL_ARGUMENTS":{"name":"Function Call Arguments","type":"object"},"GENERATOR_ONNX_LLM_FUNCTION_CALL_DETAILS":{"name":"Function Call Details","type":"object"}}},"GENERATOR_ONNX_LLM_ON_COMPLETION_FINISHED":{"properties":{"GENERATOR_ONNX_LLM_COMPLETION_RESULT":{"name":"Result","type":"string"},"GENERATOR_ONNX_LLM_COMPLETION_TOOL_CALLS":{"name":"Tool Calls","type":"array"},"GENERATOR_ONNX_LLM_COMPLETION_FULL_CONTEXT":{"name":"Full Context","type":"string"}}},"GENERATOR_ONNX_LLM_ON_ERROR":{"properties":{"GENERATOR_ONNX_LLM_ERROR":{"name":"Error","type":"string"}}}},"actionTypes":{"GENERATOR_ONNX_LLM_LOAD_MODEL":{"disallowMultiple":true,"canProvideProperty":false},"GENERATOR_ONNX_LLM_INFER":{"disallowMultiple":true,"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"GENERATOR_ONNX_LLM_PROMPT":{"name":"Prompt","type":"string"},"GENERATOR_ONNX_LLM_CHAT":{"name":"Chat","type":"array"},"GENERATOR_ONNX_LLM_IMAGES":{"name":"Image URLs","type":"array"},"GENERATOR_ONNX_LLM_AUDIOS":{"name":"Audio URLs","type":"array"},"GENERATOR_ONNX_LLM_TOOLS":{"name":"Tools","type":"array"},"GENERATOR_ONNX_LLM_TOOL_CHOICE":{"name":"Tool Choice","type":"string"}}},"GENERATOR_ONNX_LLM_CLEAN_CACHE":{"disallowMultiple":true,"canProvideProperty":false},"GENERATOR_ONNX_LLM_RELEASE_CONTEXT":{"disallowMultiple":true,"canProvideProperty":false}},"brickActionDescriptions":{"GENERATOR_ONNX_LLM_LOAD_MODEL":{"default":"","en-us":"Load the model","zh-tw":"讀取模型","ja-jp":"モデルを読み込む"},"GENERATOR_ONNX_LLM_INFER":{"default":"","en-us":"Inference","zh-tw":"推論","ja-jp":"推論"},"GENERATOR_ONNX_LLM_CLEAN_CACHE":{"default":"","en-us":"Clean cache","zh-tw":"清除快取","ja-jp":"キャッシュをクリアする"},"GENERATOR_ONNX_LLM_RELEASE_CONTEXT":{"default":"","en-us":"Release context","zh-tw":"釋放 context","ja-jp":"コンテキストを解放する"}},"scriptMemberFunctionDefs":{"load":{"arguments":[],"required":[],"return":{"type":"bool"}},"getState":{"arguments":[],"required":[],"return":{"type":"string"}},"infer":{"arguments":[{"type":"object","name":"params","properties":{"prompt":{"name":"Prompt","type":"string"},"messages":{"name":"Messages","type":"array"},"images":{"name":"Images","type":"array"},"audios":{"name":"Audios","type":"array"},"tools":{"name":"Tools","type":"array"},"toolChoice":{"name":"Tool Choice","type":"string"}}}],"required":["params"],"return":{"type":"object"}},"cleanCache":{"arguments":[],"required":[],"return":{"type":"bool"}},"release":{"arguments":[],"required":[],"return":{"type":"bool"}}},"scriptMemberFunctionDefDescriptions":{"load":{"default":"","en-us":"Load ONNX model","zh-tw":"讀取 ONNX 模型","ja-jp":"ONNX モデルを読み込む"},"getState":{"default":"","en-us":"Get model state","zh-tw":"取得模型狀態","ja-jp":"モデル状態を取得"},"infer":{"default":"","en-us":"Run text inference","zh-tw":"執行文字推論","ja-jp":"テキスト推論を実行"},"cleanCache":{"default":"","en-us":"Clean model cache","zh-tw":"清除模型快取","ja-jp":"モデルキャッシュをクリア"},"release":{"default":"","en-us":"Release the model","zh-tw":"釋放模型","ja-jp":"モデルを解放"}}}')},9624:(e,t,a)=>{var n=a(3655),r=a(4759),i=a(1580),o=a(4066),s=/^\[object .+?Constructor\]$/,p=Function.prototype,l=Object.prototype,d=p.toString,u=l.hasOwnProperty,c=RegExp("^"+d.call(u).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!i(e)||r(e))&&(n(e)?c:s).test(o(e))}},9660:(e,t,a)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=a(6223),r=a(4450),i=a(458),o=a(2697),s={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:a,parentSchema:s,data:p,it:l}=e;"all"===l.opts.removeAdditional&&void 0===s.additionalProperties&&o.default.code(new n.KeywordCxt(l,o.default,"additionalProperties"));const d=(0,r.allSchemaProperties)(a);for(const e of d)l.definedProperties.add(e);l.opts.unevaluated&&d.length&&!0!==l.props&&(l.props=i.mergeEvaluated.props(t,(0,i.toHash)(d),l.props));const u=d.filter(e=>!(0,i.alwaysValidSchema)(l,a[e]));if(0===u.length)return;const c=t.name("valid");for(const a of u)m(a)?f(a):(t.if((0,r.propertyInData)(t,p,a,l.opts.ownProperties)),f(a),l.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(a),e.ok(c);function m(e){return l.opts.useDefaults&&!l.compositeRule&&void 0!==a[e].default}function f(t){e.subschema({keyword:"properties",schemaProp:t,dataProp:t},c)}}};t.default=s},9690:(e,t,a)=>{const{humanReadableArgName:n}=a(1762);t.Help=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){const t=e.commands.filter(e=>!e._hidden),a=e._getHelpCommand();return a&&!a._hidden&&t.push(a),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){const a=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return a(e).localeCompare(a(t))}visibleOptions(e){const t=e.options.filter(e=>!e.hidden),a=e._getHelpOption();if(a&&!a.hidden){const n=a.short&&e._findOption(a.short),r=a.long&&e._findOption(a.long);n||r?a.long&&!r?t.push(e.createOption(a.long,a.description)):a.short&&!n&&t.push(e.createOption(a.short,a.description)):t.push(a)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];const t=[];for(let a=e.parent;a;a=a.parent){const e=a.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(e){const t=e.registeredArguments.map(e=>n(e)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,a)=>Math.max(e,t.subcommandTerm(a).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,a)=>Math.max(e,t.optionTerm(a).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,a)=>Math.max(e,t.optionTerm(a).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,a)=>Math.max(e,t.argumentTerm(a).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let a="";for(let t=e.parent;t;t=t.parent)a=t.name()+" "+a;return a+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue){(e.required||e.optional||e.isBoolean()&&"boolean"==typeof e.defaultValue)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}return void 0!==e.presetArg&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),void 0!==e.envVar&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){const a=`(${t.join(", ")})`;return e.description?`${e.description} ${a}`:a}return e.description}formatHelp(e,t){const a=t.padWidth(e,t),n=t.helpWidth||80;function r(e,r){if(r){const i=`${e.padEnd(a+2)}${r}`;return t.wrap(i,n-2,a+2)}return e}function i(e){return e.join("\n").replace(/^/gm," ".repeat(2))}let o=[`Usage: ${t.commandUsage(e)}`,""];const s=t.commandDescription(e);s.length>0&&(o=o.concat([t.wrap(s,n,0),""]));const p=t.visibleArguments(e).map(e=>r(t.argumentTerm(e),t.argumentDescription(e)));p.length>0&&(o=o.concat(["Arguments:",i(p),""]));const l=t.visibleOptions(e).map(e=>r(t.optionTerm(e),t.optionDescription(e)));if(l.length>0&&(o=o.concat(["Options:",i(l),""])),this.showGlobalOptions){const a=t.visibleGlobalOptions(e).map(e=>r(t.optionTerm(e),t.optionDescription(e)));a.length>0&&(o=o.concat(["Global Options:",i(a),""]))}const d=t.visibleCommands(e).map(e=>r(t.subcommandTerm(e),t.subcommandDescription(e)));return d.length>0&&(o=o.concat(["Commands:",i(d),""])),o.join("\n")}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,a,n=40){const r=new RegExp("[\\n][ \\f\\t\\v   -    \ufeff]+");if(e.match(r))return e;const i=t-a;if(i<n)return e;const o=e.slice(0,a),s=e.slice(a).replace("\r\n","\n"),p=" ".repeat(a),l="\\s​",d=new RegExp(`\n|.{1,${i-1}}([${l}]|$)|[^${l}]+?([${l}]|$)`,"g");return o+(s.match(d)||[]).map((e,t)=>"\n"===e?"":(t>0?p:"")+e.trimEnd()).join("\n")}}},9741:(e,t,a)=>{const n=a(5479),{animationRunTypes:r,autoGeneratedItemIdKind:i}=a(7089);t.systemActionDescriptions={PROPERTY_BANK_EXPRESSION:{default:"","en-us":"Change Data value with script expression. One expression of return value","zh-tw":"使用腳本表達式改變 Data 值。 一個表達式回傳值","ja-jp":"スクリプト式を使用して Data の値を変更する。1つの式で値を返す"},PROPERTY_BANK:{default:"","en-us":"Change Data value","zh-tw":"改變 Data 值","ja-jp":"Data の値を変更する"},PROPERTY_BANK_COMMAND:{default:"","en-us":"Trigger Data calculation flow without value change","zh-tw":"不需改變值,觸發 Data 計算流程","ja-jp":"値を変更せずに Data の計算フローをトリガーする"},DYNAMIC_BRICK:{default:"","en-us":"[Unstable] Dynamically generate bricks","zh-tw":"[Unstable] 動態地産生 Bricks","ja-jp":"動的に生成されたブリック"},DYNAMIC_BRICK_RESET:{default:"","en-us":"[Unstable] Reset Dynamic Bricks","zh-tw":"[Unstable] 重設 Dynamic Bricks","ja-jp":"動的に生成されたブリックをリセットする"},DYNAMIC_ANIMATION:{default:"","en-us":"Run specific Animation on specific Brick","zh-tw":"在指定的 Brick 上運行指定的 Animation","ja-jp":"指定されたブリックで指定されたアニメーションを実行する"},DYNAMIC_ANIMATION_RESET:{default:"","en-us":"Reset Dynamic Animation","zh-tw":"重設 Dynamic Animation","ja-jp":"動的なアニメーションをリセットする"},DYNAMIC_ANIMATION_STOP:{default:"","en-us":"Stop Dynamic Animation","zh-tw":"停止 Dynamic Animation","ja-jp":"動的なアニメーションを停止する"},CHANGE_CANVAS:{default:"","en-us":"Change canvas on the current Subspace","zh-tw":"在當前的 Subspace 中切換 Canvas","ja-jp":"現在の Subspace の Canvas を変更する"},MESSAGE:{default:"","en-us":"Log System message","zh-tw":"Log System message","ja-jp":"システムメッセージをログに記録する"},ALERT:{default:"","en-us":"Show system alert popup with custom message","zh-tw":"顯示自定義訊息的系統警告彈窗","ja-jp":"カスタムメッセージを使用してシステム警告ポップアップを表示する"},POPUP_RESET:{default:"","en-us":"Close current showing popups with type or id.","zh-tw":"關閉目前顯示的 Popup,可以指定 Popup 類型或 id。","ja-jp":"現在表示されているポップアップを閉じる、または ID で指定されたポップアップを閉じる。"},TAKE_SCREENSHOT:{default:"","en-us":"Take screenshot for current subspace","zh-tw":"為當前的 Subspace 截圖","ja-jp":"現在の Subspace のスクリーンショットを撮る"},STORAGE_SET:{default:"","en-us":"Store a value in application-specific storage","zh-tw":"在應用程式特定的儲存空間中儲存值","ja-jp":"アプリケーション固有のストレージに値を保存する"},STORAGE_RETRIEVE:{default:"","en-us":"Retrieve a value from application-specific storage","zh-tw":"從應用程式特定的儲存空間中取得值","ja-jp":"アプリケーション固有のストレージから値を取得する"},STORAGE_DELETE:{default:"","en-us":"Delete a value from application-specific storage or clear all values","zh-tw":"從應用程式特定的儲存空間中刪除值或清除所有值","ja-jp":"アプリケーション固有のストレージから値を削除するか、すべての値をクリアする"},CHANNEL_SUBSCRIBE:{default:"","en-us":"Subscribe to a channel for data update","zh-tw":"訂閱一個 Channel 以接收資料更新","ja-jp":"チャンネルを購読してデータ更新を受け取る"},CHANNEL_UNSUBSCRIBE:{default:"","en-us":"Unsubscribe from a channel","zh-tw":"取消訂閱一個 Channel","ja-jp":"チャンネルから購読を解除する"},CHANNEL_PUBLISH:{default:"","en-us":"Publish data to a channel","zh-tw":"發布資料到一個 Channel","ja-jp":"チャンネルにデータを発行する"},DELAY:{default:"","en-us":"Delay for a certain time between actions","zh-tw":"延遲一段時間,用於兩個動作之間","ja-jp":"一定時間遅延する、2つのアクションの間"},USE_SHARE_APPLICATION:{default:"","en-us":"[Internal] Use a shared application","zh-tw":"[Internal] 切換到分享的應用程式","ja-jp":"[Internal] 共有アプリケーションを使用する"},AUTH_IN_DEVICE:{default:"","en-us":"[Internal] Auth in device","zh-tw":"[Internal] 在裝置上進行帳號登入","ja-jp":"[Internal] デバイスで認証する"},REFRESH_BINDCODE:{default:"","en-us":"[Internal] Refresh passcode for bind device","zh-tw":"[Internal] 更新裝置綁定碼","ja-jp":"[Internal] デバイスのバインドコードを更新する"},OPEN_URL:{default:"","en-us":"Open URL","zh-tw":"開啟 URL","ja-jp":"URL を開く"},OPEN_FILE:{default:"","en-us":"Open File or Directory","zh-tw":"開啟檔案或目錄","ja-jp":"ファイルまたはディレクトリを開く"},THROW_EXCEPTION:{default:"","en-us":"Throw exception","zh-tw":"拋出例外","ja-jp":"例外を投げる"},RESTART_FOUNDATION:{default:"","en-us":"Restart the foundation (React Native bundle)","zh-tw":"重新啟動基礎設施 (React Native bundle)","ja-jp":"基盤を再起動する (React Native bundle)"},DISMISS_KEYBOARD:{default:"","en-us":"Dismiss keyboard","zh-tw":"關閉鍵盤","ja-jp":"キーボードを閉じる"},TRIGGER_APPLICATION_FILTER:{default:"","en-us":"Trigger application AI filter","zh-tw":"觸發應用程式 AI 過濾器","ja-jp":"アプリケーション AI フィルターをトリガーする"},STOP_APPLICATION_FILTER:{default:"","en-us":"Stop running application AI filter","zh-tw":"停止運行中的應用程式 AI 過濾器","ja-jp":"実行中のアプリケーション AI フィルターを停止する"},SAVE_UPDATE_SNAPSHOT:{default:"","en-us":"Save update snapshot (from Application Filter or DevTools MCP Server) to media system","zh-tw":"儲存更新快照 (來自 Application Filter 或 DevTools MCP Server) 到媒體系統","ja-jp":"メディアシステムに更新スナップショット (Application Filter または DevTools MCP サーバーから) を保存する"}},t.systemActions={PROPERTY_BANK_EXPRESSION:{displayName:"CHANGE DATA WITH EXPRESSION",canProvideProperty:!0,filterKind:[i],propertyNameType:"defined_properties",property:{EXPRESSION:{type:"string",displayName:"Expression",normalizeDisplayName:!1},VARIABLES:{type:"nested",schema:{type:"object",properties:{id:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1,displayName:"Data ID",normalizeDisplayName:!1},key:{type:"string"}},allowNewItem:!0},popover:!0,defaultValue:[]},RESULT:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1},RESULT_ASSIGN_PATH:{type:"string"},ERROR_RESULT:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1}},previewIcon:{type:"font-awesome-6pro",name:"bolt",size:14}},PROPERTY_BANK:{displayName:"CHANGE DATA",canProvideProperty:!0,filterKind:[i],propertyNameType:"property_bank",previewIcon:{type:"font-awesome-6pro",name:"bolt",size:14}},PROPERTY_BANK_COMMAND:{displayName:"TRIGGER DATA COMMAND",disallowMultiple:!0,canProvideProperty:!0,propertyNameType:"property_bank",type:"bool",previewIcon:{type:"font-awesome-6pro",name:"bolt",size:16}},DYNAMIC_BRICK:{hidden:"unstable",disallowMultiple:!0,canProvideProperty:!0,propertyNameType:"defined_properties",property:{DYNAMIC_BRICK_ADD_LIST:{type:"string"},DYNAMIC_BRICK_PREFER_AFTER_ITEM_ID:{type:"string"},DYNAMIC_BRICK_RESET:{type:"bool"},DYNAMIC_BRICK_REMOVE_ITEM_ID:{type:"string"},DYNAMIC_BRICK_REMOVE_ITEMS:{type:"string"}},previewIcon:{type:"font-awesome-6pro",name:"grid-2"}},DYNAMIC_BRICK_RESET:{hidden:"unstable",disallowMultiple:!0,canProvideProperty:!1,previewIcon:{type:"font-awesome-6pro",name:"rotate-right"}},DYNAMIC_ANIMATION:{disallowMultiple:!0,canProvideProperty:!0,propertyNameType:"defined_properties",property:{DYNAMIC_ANIMATION_BRICK_ID:{type:"string",kind:"id",idType:"brick"},DYNAMIC_ANIMATION_ANIMATION_ID:{type:"string",kind:"id",idType:"animation"},DYNAMIC_ANIMATION_RUN_TYPE:{type:"oneOf",oneOf:r},DYNAMIC_ANIMATION_RESET_INITIAL_VALUE:{type:"bool"}},previewIcon:{type:"font-awesome-6pro",name:"bars-staggered",size:16}},DYNAMIC_ANIMATION_RESET:{disallowMultiple:!0,canProvideProperty:!0,propertyNameType:"defined_properties",property:{DYNAMIC_ANIMATION_BRICK_ID:{type:"string",kind:"id",idType:"brick"}},previewIcon:{type:"font-awesome-6pro",name:"rotate-right"}},DYNAMIC_ANIMATION_STOP:{disallowMultiple:!0,canProvideProperty:!0,propertyNameType:"defined_properties",property:{DYNAMIC_ANIMATION_BRICK_ID:{type:"string",kind:"id",idType:"brick"}},previewIcon:{type:"font-awesome-6pro",name:"stop"}},CHANGE_CANVAS:{disallowMultiple:!0,canProvideProperty:!0,propertyNameType:"defined_properties",property:{CANVAS_ID:{type:"string",kind:"id",idType:"canvas"},CANVAS_TITLE_LIKE:{type:"string"},CANVAS_KEY_MAP_LIST:{type:"nested",schema:{type:"object",properties:{key:{displayName:"Key",type:"string"},value:{displayName:"Canvas ID",type:"string",kind:"id",idType:"canvas"}},allowNewItem:!0},popover:!0,defaultValue:[]},CANVAS_KEY:{type:"string"}},previewIcon:{type:"font-awesome-6pro",name:"diamond-turn-right",size:16}},MESSAGE:{canProvideProperty:!0,propertyNameType:"defined_properties",property:{SYSTEM_MESSAGE_TYPE:{type:"oneOf",oneOf:["SYSTEM_MESSAGE_TYPE_INFO","SYSTEM_MESSAGE_TYPE_SUCCESS","SYSTEM_MESSAGE_TYPE_WARNING","SYSTEM_MESSAGE_TYPE_ERROR"]},SYSTEM_MESSAGE_TITLE:{type:"string"},SYSTEM_MESSAGE_MESSAGE:{type:"string"}},previewIcon:{type:"font-awesome-6pro",name:"note"}},ALERT:{canProvideProperty:!0,propertyNameType:"defined_properties",property:{ALERT_ID:{type:"string"},ALERT_TYPE:{type:"oneOf",oneOf:["info","success","warning","error"]},ALERT_TITLE:{type:"string"},ALERT_MESSAGE:{type:"string"},ALERT_SELECTIONS:{type:"nested",schema:{type:"object",properties:{label:{type:"string"},color:{type:"string"},value:{type:"string"},disableResult:{type:"bool"}},allowNewItem:!0},popover:!0,defaultValue:[]},ALERT_SELECTION_RESULT:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1},ALERT_TIMEOUT:{type:"number",defaultValue:1e4},ALERT_HIDE_SELECTIONS:{type:"bool"}},previewIcon:{type:"font-awesome-6pro",name:"bell"}},POPUP_RESET:{disallowMultiple:!0,canProvideProperty:!0,propertyNameType:"defined_properties",property:{POPUP_CLEAR_TYPE:{type:"oneOf",oneOf:["all","alert","generator"]},POPUP_ID:{type:"string"}},previewIcon:{type:"font-awesome-6pro",name:"rotate-right"}},TAKE_SCREENSHOT:{canProvideProperty:!0,propertyNameType:"defined_properties",property:{TAKE_SCREENSHOT_CURRENT_SUBSPACE:{type:"bool"},TAKE_SCREENSHOT_BRICK_ID:{type:"string",kind:"id",idType:"brick",displayName:"Brick ID",normalizeDisplayName:!1},TAKE_SCREENSHOT_FORMAT:{type:"oneOf",oneOf:["jpg","png"]},TAKE_SCREENSHOT_QUALITY:{type:"number",max:1,min:0,step:.1},TAKE_SCREENSHOT_WIDTH:{type:"number"},TAKE_SCREENSHOT_HEIGHT:{type:"number"},TAKE_SCREENSHOT_SAVE_PROPERTY:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1}},previewIcon:{type:"font-awesome-6pro",name:"camera",size:16}},STORAGE_SET:{displayName:"STORAGE SET",canProvideProperty:!0,propertyNameType:"defined_properties",property:{STORAGE_TYPE:{type:"oneOf",oneOf:["persist","in-memory"],displayName:"Storage Type",defaultValue:"persist"},STORAGE_SCOPE:{type:"oneOf",oneOf:["global","subspace"],displayName:"Storage Scope",defaultValue:"global"},STORAGE_KEY:{type:"string",displayName:"Key",normalizeDisplayName:!1},STORAGE_VALUE:{type:"any",displayName:"Value",normalizeDisplayName:!1}},previewIcon:{type:"font-awesome-6pro",name:"database",size:14}},STORAGE_RETRIEVE:{displayName:"STORAGE RETRIEVE",canProvideProperty:!0,propertyNameType:"defined_properties",property:{STORAGE_TYPE:{type:"oneOf",oneOf:["persist","in-memory"],displayName:"Storage Type",defaultValue:"persist"},STORAGE_SCOPE:{type:"oneOf",oneOf:["global","subspace"],displayName:"Storage Scope",defaultValue:"global"},STORAGE_KEY:{type:"string",displayName:"Key",normalizeDisplayName:!1},STORAGE_RETRIEVE_RESULT:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1,displayName:"Result Target"},STORAGE_RETRIEVE_DEFAULT_VALUE:{type:"string",displayName:"Default Value",normalizeDisplayName:!1},STORAGE_RETRIEVE_SKIP_IF_NOT_FOUND:{type:"bool",displayName:"Skip if Not Found",defaultValue:!1}},previewIcon:{type:"font-awesome-6pro",name:"database",size:14}},STORAGE_DELETE:{displayName:"STORAGE DELETE",canProvideProperty:!0,propertyNameType:"defined_properties",property:{STORAGE_TYPE:{type:"oneOf",oneOf:["persist","in-memory"],displayName:"Storage Type",defaultValue:"persist"},STORAGE_SCOPE:{type:"oneOf",oneOf:["global","subspace"],displayName:"Storage Scope",defaultValue:"global"},STORAGE_KEY:{type:"string",displayName:"Key",normalizeDisplayName:!1},STORAGE_DELETE_ALL:{type:"bool",displayName:"Delete All Values",defaultValue:!1}},previewIcon:{type:"font-awesome-6pro",name:"trash",size:14}},CHANNEL_SUBSCRIBE:{canProvideProperty:!0,propertyNameType:"defined_properties",property:{CHANNEL_SUBSCRIBE_KEY:{type:"string"},CHANNEL_SUBSCRIBE_TYPE:{type:"oneOf",oneOf:["on","once"]},CHANNEL_SUBSCRIBE_LIVETIME:{type:"number",kind:"unit",unit:"ms"},CHANNEL_SUBSCRIBE_DATA_RESULT:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1,displayName:"Result"},CHANNEL_SUBSCRIBE_DATA_ASSIGN_LIST:{type:"nested",schema:{type:"object",properties:{path:{displayName:"Object Path",type:"string"},type:{type:"oneOf",oneOf:["any","string","number","bool","array","object"],oneOfEmptyOption:!1,defaultValue:"any"},id:{displayName:"Data ID",type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1},required:{type:"bool",defaultValue:!1}},allowNewItem:!0},popover:!0,defaultValue:[]},CHANNEL_SUBSCRIBE_PROGRESS_RESULT:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1,displayName:"Progress"},CHANNEL_SUBSCRIBE_PROGRESS_ASSIGN_LIST:{type:"nested",schema:{type:"object",properties:{path:{displayName:"Object Path",type:"string"},type:{type:"oneOf",oneOf:["any","string","number","bool","array","object"],oneOfEmptyOption:!1,defaultValue:"any"},id:{displayName:"Data ID",type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1},required:{type:"bool",defaultValue:!1}},allowNewItem:!0},popover:!0,defaultValue:[]},CHANNEL_SUBSCRIBE_ERROR_RESULT:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1,displayName:"Error"}},previewIcon:{type:"font-awesome-6pro",name:"display",size:16}},CHANNEL_UNSUBSCRIBE:{canProvideProperty:!0,propertyNameType:"defined_properties",property:{CHANNEL_UNSUBSCRIBE_KEY_MATCH:{type:"string"}}},CHANNEL_PUBLISH:{canProvideProperty:!0,propertyNameType:"defined_properties",property:{CHANNEL_PUBLISH_KEY_MATCH:{type:"string"},CHANNEL_PUBLISH_PAYLOAD_TYPE:{type:"oneOf",oneOf:["result","progress","error"]},CHANNEL_PUBLISH_PAYLOAD:{type:"string"}}},DELAY:{canProvideProperty:!0,propertyNameType:"defined_properties",property:{DELAY_TIME:{type:"number",kind:"unit",unit:"ms"}}},USE_SHARE_APPLICATION:{hidden:"internal",canProvideProperty:!0,propertyNameType:"defined_properties",property:{APPLICATION_ID:{type:"string"},RELEASE_VERSION:{type:"string"},USE_TYPE:{type:"oneOf",oneOf:["run","use-after-bind","cancel-use"]},VIEWPORT_PRESET_NAME_LIKE:{type:"string"},VIEWPORT_PRESET_DEVICE_TARGET:{type:"string"},ENABLE_LOCAL_SYNC:{type:"bool"}},previewIcon:{type:"font-awesome-6pro",name:"display",size:16}},AUTH_IN_DEVICE:{hidden:"internal",canProvideProperty:!1,previewIcon:{type:"font-awesome-6pro",name:"user",size:16}},REFRESH_BINDCODE:{hidden:"internal",canProvideProperty:!1,previewIcon:{type:"font-awesome-6pro",name:"arrows-rotate",size:16}},OPEN_URL:{canProvideProperty:!0,propertyNameType:"defined_properties",property:{URL:{type:"string",normalizeDisplayName:!1,displayName:"URL"},BEHAVIOR:{type:"oneOf",oneOf:["in-app","new-window"]},IN_APP_TINT_COLOR:{type:"string",kind:"color",popover:!0}},previewIcon:{type:"font-awesome-6pro",name:"external-link",size:16}},OPEN_FILE:{canProvideProperty:!0,propertyNameType:"defined_properties",property:{PICK_TYPE:{type:"oneOf",oneOf:["file","multiple","directory"],oneOfEmptyOption:!1},FILE_TYPE:{type:"any"},COPY_TO:{type:"oneOf",oneOf:["cache","document"]},MODE:{type:"oneOf",oneOf:["import","open"]},SAVE_PROPERTY:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1},SAVE_DETAIL_PROPERTY:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1},ERROR_SAVE_PROPERTY:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1}},previewIcon:{type:"font-awesome-6pro",name:"folder-open",size:16}},THROW_EXCEPTION:{canProvideProperty:!0,propertyNameType:"defined_properties",property:{BEHAVIOR:{type:"oneOf",oneOf:["application","native"]},EXCEPTION_MESSAGE:{type:"string",displayName:"Exception Message"}},previewIcon:{type:"font-awesome-6pro",name:"bomb",size:16}},RESTART_FOUNDATION:{canProvideProperty:!1,previewIcon:{type:"font-awesome-6pro",name:"arrows-rotate",size:16}},DISMISS_KEYBOARD:{canProvideProperty:!1,previewIcon:{type:"font-awesome-6pro",name:"keyboard-down",size:16}},TRIGGER_APPLICATION_FILTER:{canProvideProperty:!0,propertyNameType:"defined_properties",property:{NAME:{type:"string",displayName:"Filter Name",normalizeDisplayName:!1},VARIABLES:{type:"any",displayName:"Variables",normalizeDisplayName:!1},RESULT:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1,displayName:"Result Target"},ERROR:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1,displayName:"Error Target"}},previewIcon:{type:"font-awesome-6pro",name:"robot",size:16}},STOP_APPLICATION_FILTER:{canProvideProperty:!1,previewIcon:{type:"font-awesome-6pro",name:"stop",size:16}},SAVE_UPDATE_SNAPSHOT:{displayName:"SAVE UPDATE SNAPSHOT",canProvideProperty:!0,propertyNameType:"defined_properties",property:{SNAPSHOT_FILE_INDENTIFIER:{type:"string",displayName:"Filename Identifier",defaultValue:"default",normalizeDisplayName:!1},SNAPSHOT_SAVE_RESULT:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1,displayName:"Result Target"},SNAPSHOT_ERROR_RESULT:{type:"string",kind:"id",idType:"property_bank",showPropertyBankLink:!1,displayName:"Error Target"}},previewIcon:{type:"font-awesome-6pro",name:"camera-retro",size:16}}},t.getSubspaceActionTypes=e=>Object.entries(e.action_map||{}).reduce((e,[t,a])=>(e[`SUBSPACE_ACTION_${t}`]={canProvideProperty:Object.keys(a.event_property_map||{}).length>0,property:Object.entries(a.event_property_map||{}).reduce((e,[t,a])=>(e[`SUBSPACE_${t}`]={type:a.type,name:n(t)},e),{}),propertyNameType:"defined_properties"},e),{})},9753:(e,t,a)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=a(7898),r=a(458),i=a(4450),o=a(3426),s={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:e}})=>n.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>n._`{limit: ${e}}`},code(e){const{schema:t,parentSchema:a,it:n}=e,{prefixItems:s}=a;n.items=!0,(0,r.alwaysValidSchema)(n,t)||(s?(0,o.validateAdditionalItems)(e,s):e.ok((0,i.validateArray)(e)))}};t.default=s},9760:(e,t,a)=>{a.d(t,{$:()=>T});var n=a(5608),r=a(9212),i=a(9074),o=a(3673),s=a(2307),p=a(3647),l=a(3068),d=a(4874),u=a(7195),c=a(4559),m=a(1151),f=a(3161),_=a(783),h=a(3777),E=a(3925),y=(0,r.maybe)(function(){return fetch}),T=function(e){void 0===e&&(e={});var t=e.uri,a=void 0===t?"/graphql":t,T=e.fetch,R=e.print,g=void 0===R?c.i1:R,v=e.includeExtensions,O=e.preserveHeaderCase,N=e.useGETForQueries,b=e.includeUnusedVariables,A=void 0!==b&&b,S=(0,n.__rest)(e,["uri","fetch","print","includeExtensions","preserveHeaderCase","useGETForQueries","includeUnusedVariables"]);!1!==globalThis.__DEV__&&(0,u.S)(T||y);var I={http:{includeExtensions:v,preserveHeaderCase:O},options:S.fetchOptions,credentials:S.credentials,headers:S.headers};return new i.C(function(e){var t=(0,l.z)(e,a),i=e.getContext(),u={};if(i.clientAwareness){var R=i.clientAwareness,v=R.name,O=R.version;v&&(u["apollographql-client-name"]=v),O&&(u["apollographql-client-version"]=O)}var b=(0,n.__assign)((0,n.__assign)({},u),i.headers),S={http:i.http,options:i.fetchOptions,credentials:i.credentials,headers:b};if((0,s.d8)(["client"],e.query)){var w=(0,E.er)(e.query);if(!w)return(0,f.N)(new Error("HttpLink: Trying to send a client-only query to the server. To send to the server, ensure a non-client field is added to the query or set the `transformOptions.removeClientFields` option to `true`."));e.query=w}var C,D=(0,c.HY)(e,g,c.R4,I,S),P=D.options,j=D.body;j.variables&&!A&&(j.variables=(0,_.X)(j.variables,e.query)),P.signal||"undefined"==typeof AbortController||(C=new AbortController,P.signal=C.signal);var k,L="OperationDefinition"===(k=(0,h.Vn)(e.query)).kind&&"subscription"===k.operation,M=(0,s.d8)(["defer"],e.query);if(N&&!e.query.definitions.some(function(e){return"OperationDefinition"===e.kind&&"mutation"===e.operation})&&(P.method="GET"),M||L){P.headers=P.headers||{};var G="multipart/mixed;";L&&M&&!1!==globalThis.__DEV__&&r.invariant.warn(41),L?G+="boundary=graphql;subscriptionSpec=1.0,application/json":M&&(G+="deferSpec=20220824,application/json"),P.headers.accept=G}if("GET"===P.method){var x=(0,m.E)(t,j),F=x.newURI,B=x.parseError;if(B)return(0,f.N)(B);t=F}else try{P.body=(0,p.Y)(j,"Payload")}catch(B){return(0,f.N)(B)}return new o.c(function(a){var n=T||(0,r.maybe)(function(){return fetch})||y,i=a.next.bind(a);return n(t,P).then(function(t){var a;e.setContext({response:t});var n=null===(a=t.headers)||void 0===a?void 0:a.get("content-type");return null!==n&&/^multipart\/mixed/i.test(n)?(0,d.tD)(t,i):(0,d.OQ)(e)(t).then(i)}).then(function(){C=void 0,a.complete()}).catch(function(e){C=void 0,(0,d.H4)(e,a)}),function(){C&&C.abort()}})})}},9762:(e,t,a)=>{a.d(t,{Ll:()=>s,aD:()=>i,aZ:()=>n,cE:()=>p,ou:()=>r});class n{constructor(e,t,a){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=a}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class r{constructor(e,t,a,n,r,i){this.kind=e,this.start=t,this.end=a,this.line=n,this.column=r,this.value=i,this.prev=null,this.next=null}get[Symbol.toStringTag](){return"Token"}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}}const i={Name:[],Document:["definitions"],OperationDefinition:["description","name","variableDefinitions","directives","selectionSet"],VariableDefinition:["description","variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["description","name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"],TypeCoordinate:["name"],MemberCoordinate:["name","memberName"],ArgumentCoordinate:["name","fieldName","argumentName"],DirectiveCoordinate:["name"],DirectiveArgumentCoordinate:["name","argumentName"]},o=new Set(Object.keys(i));function s(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&o.has(t)}var p;!function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"}(p||(p={}))},9770:(e,t,a)=>{var n=a(4715)(a(8942),"Map");e.exports=n},9787:e=>{e.exports=JSON.parse('{"name":"GeneratorIntent","brickDescription":{"default":"","en-us":"Send intent to app and get result (Android only)","zh-tw":"向應用發送意圖並獲取結果 (僅限 Android)","ja-jp":"アプリにインテントを送信して結果を取得(Androidのみ)"},"brickDisplayName":"Intent","brickTip":{"default":""},"brickPreviewIcon":{"type":"font-awesome-6pro","name":"bullseye-arrow"},"brickMeta":{"preview":true},"propTypes":{"action":{"type":"string"},"data":{"type":"string"},"type":{"type":"string"},"extra":{"type":"object"},"className":{"type":"string"},"packageName":{"type":"string"},"category":{"type":"string"},"foregroundService":{"type":"bool"}},"brickPropDescriptions":{"action":{"default":"","en-us":"Intent action","zh-tw":"意圖動作","ja-jp":"インテントアクション"},"data":{"default":"","en-us":"Intent data","zh-tw":"意圖資料","ja-jp":"インテントデータ"},"type":{"default":"","en-us":"Intent type","zh-tw":"意圖類型","ja-jp":"インテントタイプ"},"extra":{"default":"","en-us":"Extra data","zh-tw":"額外資料","ja-jp":"追加データ"},"className":{"default":"","en-us":"Intent target class name in package","zh-tw":"意圖目標類名","ja-jp":"インテントターゲットのクラス名"},"packageName":{"default":"","en-us":"Intent target package name","zh-tw":"意圖目標包名","ja-jp":"インテントターゲットのパッケージ名"},"category":{"default":"","en-us":"Intent category","zh-tw":"意圖類別","ja-jp":"インテントカテゴリ"},"foregroundService":{"default":"","en-us":"Intent start foreground service","zh-tw":"意圖啟動前景服務","ja-jp":"インテント前景サービス"}},"defaultBrickProps":{},"propertyControls":{},"propertyControlGroups":{},"propertyControlGroupDescriptions":{},"eventTypes":{"GENERATOR_INTENT_ON_RESULT":"GENERATOR_INTENT_ON_RESULT","GENERATOR_INTENT_ON_ERROR":"GENERATOR_INTENT_ON_ERROR"},"brickEventDescriptions":{"GENERATOR_INTENT_ON_RESULT":{"default":"","en-us":"On intent return a result trigger","zh-tw":"在意圖返回結果時觸發","ja-jp":"インテントが結果を返した時に発生するイベント"},"GENERATOR_INTENT_ON_ERROR":{"default":"","en-us":"On intent error trigger","zh-tw":"在意圖錯誤時觸發","ja-jp":"インテントエラー時に発生するイベント"}},"eventPropertyControls":{"GENERATOR_INTENT_ON_RESULT":{"properties":{"GENERATOR_INTENT_RESULT_CODE":{"name":"Result Code","type":"number"},"GENERATOR_INTENT_RESULT_DATA":{"name":"Result Data","type":"string"},"GENERATOR_INTENT_RESULT_EXTRAS":{"name":"Extra Data","type":"object"}}},"GENERATOR_INTENT_ON_ERROR":{"properties":{"GENERATOR_INTENT_ERROR":{"name":"Error Message","type":"string"}}}},"outletTypes":{"GENERATOR_INTENT_RESULT":{"outlet":"GENERATOR_INTENT_RESULT","type":"object"}},"brickOutletDescriptions":{"GENERATOR_INTENT_RESULT":{"default":"","en-us":"Last intent result","zh-tw":"最後意圖結果","ja-jp":"最後のインテント結果"}},"actionTypes":{"GENERATOR_INTENT_SEND_INTENT":{"disallowMultiple":true,"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"GENERATOR_INTENT_ACTION":{"name":"Action","type":"string"},"GENERATOR_INTENT_DATA":{"name":"Data","type":"string"},"GENERATOR_INTENT_TYPE":{"name":"Type","type":"string"},"GENERATOR_INTENT_EXTRA":{"name":"Extra","type":"object"},"GENERATOR_INTENT_CLASS_NAME":{"name":"Class Name","type":"string"},"GENERATOR_INTENT_PACKAGE_NAME":{"name":"Package Name","type":"string"},"GENERATOR_INTENT_CATEGORY":{"name":"Category","type":"string"}}},"GENERATOR_INTENT_START_SERVICE":{"disallowMultiple":true,"canProvideProperty":true,"propertyNameType":"defined_properties","property":{"GENERATOR_INTENT_ACTION":{"name":"Action","type":"string"},"GENERATOR_INTENT_DATA":{"name":"Data","type":"string"},"GENERATOR_INTENT_TYPE":{"name":"Type","type":"string"},"GENERATOR_INTENT_EXTRA":{"name":"Extra","type":"object"},"GENERATOR_INTENT_CLASS_NAME":{"name":"Class Name","type":"string"},"GENERATOR_INTENT_PACKAGE_NAME":{"name":"Package Name","type":"string"},"GENERATOR_INTENT_CATEGORY":{"name":"Category","type":"string"},"GENERATOR_INTENT_FOREGROUND":{"name":"Foreground Service","type":"boolean"}}}},"brickActionDescriptions":{"GENERATOR_INTENT_SEND_INTENT":{"default":"","en-us":"Read stats","zh-tw":"讀取 stats","ja-jp":"統計情報を読み取る"},"GENERATOR_INTENT_START_SERVICE":{"default":"","en-us":"Start intent service","zh-tw":"啟動意圖服務","ja-jp":"インテントサービスを起動する"}}}')},9790:(e,t,a)=>{a.d(t,{default:()=>Q,oraPromise:()=>Y,spinners:()=>D}),a.r(t);var n=a(1708),r=a(8568);const i=(e,t,a,n)=>{if("length"===a||"prototype"===a)return;if("arguments"===a||"caller"===a)return;const r=Object.getOwnPropertyDescriptor(e,a),i=Object.getOwnPropertyDescriptor(t,a);!o(r,i)&&n||Object.defineProperty(e,a,i)},o=function(e,t){return void 0===e||e.configurable||e.writable===t.writable&&e.enumerable===t.enumerable&&e.configurable===t.configurable&&(e.writable||e.value===t.value)},s=(e,t)=>`/* Wrapped ${e}*/\n${t}`,p=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),l=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name");function d(e,t,{ignoreNonConfigurable:a=!1}={}){const{name:n}=e;for(const n of Reflect.ownKeys(t))i(e,t,n,a);return((e,t)=>{const a=Object.getPrototypeOf(t);a!==Object.getPrototypeOf(e)&&Object.setPrototypeOf(e,a)})(e,t),((e,t,a)=>{const n=""===a?"":`with ${a.trim()}() `,r=s.bind(null,n,t.toString());Object.defineProperty(r,"name",l);const{writable:i,enumerable:o,configurable:d}=p;Object.defineProperty(e,"toString",{value:r,writable:i,enumerable:o,configurable:d})})(e,t,n),e}const u=new WeakMap,c=(e,t={})=>{if("function"!=typeof e)throw new TypeError("Expected a function");let a,n=0;const r=e.displayName||e.name||"<anonymous>",i=function(...o){if(u.set(i,++n),1===n)a=e.apply(this,o),e=void 0;else if(!0===t.throw)throw new Error(`Function \`${r}\` can only be called once`);return a};return d(i,e),u.set(i,n),i};c.callCount=e=>{if(!u.has(e))throw new Error(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);return u.get(e)};const m=c,f=[];f.push("SIGHUP","SIGINT","SIGTERM"),"win32"!==process.platform&&f.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT"),"linux"===process.platform&&f.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");const _=e=>!!e&&"object"==typeof e&&"function"==typeof e.removeListener&&"function"==typeof e.emit&&"function"==typeof e.reallyExit&&"function"==typeof e.listeners&&"function"==typeof e.kill&&"number"==typeof e.pid&&"function"==typeof e.on,h=Symbol.for("signal-exit emitter"),E=globalThis,y=Object.defineProperty.bind(Object);class T{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(E[h])return E[h];y(E,h,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){const a=this.listeners[e],n=a.indexOf(t);-1!==n&&(0===n&&1===a.length?a.length=0:a.splice(n,1))}emit(e,t,a){if(this.emitted[e])return!1;this.emitted[e]=!0;let n=!1;for(const r of this.listeners[e])n=!0===r(t,a)||n;return"exit"===e&&(n=this.emit("afterExit",t,a)||n),n}}class R{}const g=globalThis.process,{onExit:v,load:O,unload:N}=(b=_(g)?new class extends R{#e="win32"===g.platform?"SIGINT":"SIGHUP";#t=new T;#a;#n;#r;#i={};#o=!1;constructor(e){super(),this.#a=e,this.#i={};for(const t of f)this.#i[t]=()=>{const a=this.#a.listeners(t);let{count:n}=this.#t;const r=e;if("object"==typeof r.__signal_exit_emitter__&&"number"==typeof r.__signal_exit_emitter__.count&&(n+=r.__signal_exit_emitter__.count),a.length===n){this.unload();const a=this.#t.emit("exit",null,t),n="SIGHUP"===t?this.#e:t;a||e.kill(e.pid,n)}};this.#r=e.reallyExit,this.#n=e.emit}onExit(e,t){if(!_(this.#a))return()=>{};!1===this.#o&&this.load();const a=t?.alwaysLast?"afterExit":"exit";return this.#t.on(a,e),()=>{this.#t.removeListener(a,e),0===this.#t.listeners.exit.length&&0===this.#t.listeners.afterExit.length&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#t.count+=1;for(const e of f)try{const t=this.#i[e];t&&this.#a.on(e,t)}catch(e){}this.#a.emit=(e,...t)=>this.#s(e,...t),this.#a.reallyExit=e=>this.#p(e)}}unload(){this.#o&&(this.#o=!1,f.forEach(e=>{const t=this.#i[e];if(!t)throw new Error("Listener not defined for signal: "+e);try{this.#a.removeListener(e,t)}catch(e){}}),this.#a.emit=this.#n,this.#a.reallyExit=this.#r,this.#t.count-=1)}#p(e){return _(this.#a)?(this.#a.exitCode=e||0,this.#t.emit("exit",this.#a.exitCode,null),this.#r.call(this.#a,this.#a.exitCode)):0}#s(e,...t){const a=this.#n;if("exit"===e&&_(this.#a)){"number"==typeof t[0]&&(this.#a.exitCode=t[0]);const n=a.call(this.#a,e,...t);return this.#t.emit("exit",this.#a.exitCode,null),n}return a.call(this.#a,e,...t)}}(g):new class extends R{onExit(){return()=>{}}load(){}unload(){}},{onExit:(e,t)=>b.onExit(e,t),load:()=>b.load(),unload:()=>b.unload()});var b;const A=n.stderr.isTTY?n.stderr:n.stdout.isTTY?n.stdout:void 0,S=A?m(()=>{v(()=>{A.write("[?25h")},{alwaysLast:!0})}):()=>{};let I=!1;const w={show:(e=n.stderr)=>{e.isTTY&&(I=!1,e.write("[?25h"))},hide:(e=n.stderr)=>{e.isTTY&&(S(),I=!0,e.write("[?25l"))},toggle:(e,t)=>{void 0!==e&&(I=e),I?w.show(t):w.hide(t)}},C=w;var D=a(7661);const P={info:r.Ay.blue("ℹ"),success:r.Ay.green("✔"),warning:r.Ay.yellow("⚠"),error:r.Ay.red("✖")},j={info:r.Ay.blue("i"),success:r.Ay.green("√"),warning:r.Ay.yellow("‼"),error:r.Ay.red("×")},k=("win32"!==n.platform?"linux"!==n.env.TERM:Boolean(n.env.CI)||Boolean(n.env.WT_SESSION)||Boolean(n.env.TERMINUS_SUBLIME)||"{cmd::Cmder}"===n.env.ConEmuTask||"Terminus-Sublime"===n.env.TERM_PROGRAM||"vscode"===n.env.TERM_PROGRAM||"xterm-256color"===n.env.TERM||"alacritty"===n.env.TERM||"JetBrains-JediTerm"===n.env.TERMINAL_EMULATOR)?P:j;const L=function({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}();function M(e){if("string"!=typeof e)throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(L,"")}function G(e){return 161===e||164===e||167===e||168===e||170===e||173===e||174===e||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||198===e||208===e||215===e||216===e||e>=222&&e<=225||230===e||e>=232&&e<=234||236===e||237===e||240===e||242===e||243===e||e>=247&&e<=250||252===e||254===e||257===e||273===e||275===e||283===e||294===e||295===e||299===e||e>=305&&e<=307||312===e||e>=319&&e<=322||324===e||e>=328&&e<=331||333===e||338===e||339===e||358===e||359===e||363===e||462===e||464===e||466===e||468===e||470===e||472===e||474===e||476===e||593===e||609===e||708===e||711===e||e>=713&&e<=715||717===e||720===e||e>=728&&e<=731||733===e||735===e||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||1025===e||e>=1040&&e<=1103||1105===e||8208===e||e>=8211&&e<=8214||8216===e||8217===e||8220===e||8221===e||e>=8224&&e<=8226||e>=8228&&e<=8231||8240===e||8242===e||8243===e||8245===e||8251===e||8254===e||8308===e||8319===e||e>=8321&&e<=8324||8364===e||8451===e||8453===e||8457===e||8467===e||8470===e||8481===e||8482===e||8486===e||8491===e||8531===e||8532===e||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||8585===e||e>=8592&&e<=8601||8632===e||8633===e||8658===e||8660===e||8679===e||8704===e||8706===e||8707===e||8711===e||8712===e||8715===e||8719===e||8721===e||8725===e||8730===e||e>=8733&&e<=8736||8739===e||8741===e||e>=8743&&e<=8748||8750===e||e>=8756&&e<=8759||8764===e||8765===e||8776===e||8780===e||8786===e||8800===e||8801===e||e>=8804&&e<=8807||8810===e||8811===e||8814===e||8815===e||8834===e||8835===e||8838===e||8839===e||8853===e||8857===e||8869===e||8895===e||8978===e||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||9632===e||9633===e||e>=9635&&e<=9641||9650===e||9651===e||9654===e||9655===e||9660===e||9661===e||9664===e||9665===e||e>=9670&&e<=9672||9675===e||e>=9678&&e<=9681||e>=9698&&e<=9701||9711===e||9733===e||9734===e||9737===e||9742===e||9743===e||9756===e||9758===e||9792===e||9794===e||9824===e||9825===e||e>=9827&&e<=9829||e>=9831&&e<=9834||9836===e||9837===e||9839===e||9886===e||9887===e||9919===e||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||9955===e||9960===e||9961===e||e>=9963&&e<=9969||9972===e||e>=9974&&e<=9977||9979===e||9980===e||9982===e||9983===e||10045===e||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||65533===e||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||127375===e||127376===e||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}function x(e){return 12288===e||e>=65281&&e<=65376||e>=65504&&e<=65510}function F(e){return e>=4352&&e<=4447||8986===e||8987===e||9001===e||9002===e||e>=9193&&e<=9196||9200===e||9203===e||9725===e||9726===e||9748===e||9749===e||e>=9776&&e<=9783||e>=9800&&e<=9811||9855===e||e>=9866&&e<=9871||9875===e||9889===e||9898===e||9899===e||9917===e||9918===e||9924===e||9925===e||9934===e||9940===e||9962===e||9970===e||9971===e||9973===e||9978===e||9981===e||9989===e||9994===e||9995===e||10024===e||10060===e||10062===e||e>=10067&&e<=10069||10071===e||e>=10133&&e<=10135||10160===e||10175===e||11035===e||11036===e||11088===e||11093===e||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e>=94192&&e<=94198||e>=94208&&e<=101589||e>=101631&&e<=101662||e>=101760&&e<=101874||e>=110576&&e<=110579||e>=110581&&e<=110587||110589===e||110590===e||e>=110592&&e<=110882||110898===e||e>=110928&&e<=110930||110933===e||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||126980===e||127183===e||127374===e||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||127568===e||127569===e||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||127988===e||e>=127992&&e<=128062||128064===e||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||128378===e||128405===e||128406===e||128420===e||e>=128507&&e<=128591||e>=128640&&e<=128709||128716===e||e>=128720&&e<=128722||e>=128725&&e<=128728||e>=128732&&e<=128735||128747===e||128748===e||e>=128756&&e<=128764||e>=128992&&e<=129003||129008===e||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129674||e>=129678&&e<=129734||129736===e||e>=129741&&e<=129756||e>=129759&&e<=129770||e>=129775&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}function B(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function z(e,{ambiguousAsWide:t=!1}={}){return B(e),x(e)||F(e)||t&&G(e)?2:1}const V=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g,$=new Intl.Segmenter,U=/^\p{Default_Ignorable_Code_Point}$/u;function H(e,t={}){if("string"!=typeof e||0===e.length)return 0;const{ambiguousIsNarrow:a=!0,countAnsiEscapeCodes:n=!1}=t;if(n||(e=M(e)),0===e.length)return 0;let r=0;const i={ambiguousAsWide:!a};for(const{segment:t}of $.segment(e)){const e=t.codePointAt(0);e<=31||e>=127&&e<=159||(e>=8203&&e<=8207||65279===e||e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=55296&&e<=57343||e>=65024&&e<=65039||U.test(t)||(V().test(t)?r+=2:r+=z(e,i)))}return r}var K=a(9122);const q=new class{#l=0;start(){this.#l++,1===this.#l&&this.#d()}stop(){if(this.#l<=0)throw new Error("`stop` called more times than `start`");this.#l--,0===this.#l&&this.#u()}#d(){"win32"!==n.platform&&n.stdin.isTTY&&(n.stdin.setRawMode(!0),n.stdin.on("data",this.#c),n.stdin.resume())}#u(){n.stdin.isTTY&&(n.stdin.off("data",this.#c),n.stdin.pause(),n.stdin.setRawMode(!1))}#c(e){3===e[0]&&n.emit("SIGINT")}};class W{#m=0;#f=!1;#_=0;#h=-1;#E=0;#y;#T;#R;#g;#v;#O;#N;#b;#A;#S;#I;color;constructor(e){"string"==typeof e&&(e={text:e}),this.#y={color:"cyan",stream:n.stderr,discardStdin:!0,hideCursor:!0,...e},this.color=this.#y.color,this.spinner=this.#y.spinner,this.#v=this.#y.interval,this.#R=this.#y.stream,this.#O="boolean"==typeof this.#y.isEnabled?this.#y.isEnabled:function({stream:e=process.stdout}={}){return Boolean(e&&e.isTTY&&"dumb"!==process.env.TERM&&!("CI"in process.env))}({stream:this.#R}),this.#N="boolean"==typeof this.#y.isSilent&&this.#y.isSilent,this.text=this.#y.text,this.prefixText=this.#y.prefixText,this.suffixText=this.#y.suffixText,this.indent=this.#y.indent}get indent(){return this.#b}set indent(e=0){if(!(e>=0&&Number.isInteger(e)))throw new Error("The `indent` option must be an integer from 0 and up");this.#b=e,this.#w()}get interval(){return this.#v??this.#T.interval??100}get spinner(){return this.#T}set spinner(e){if(this.#h=-1,this.#v=void 0,"object"==typeof e){if(void 0===e.frames)throw new Error("The given spinner must have a `frames` property");this.#T=e}else if((0,K.A)())if(void 0===e)this.#T=D.dots;else{if("default"===e||!D[e])throw new Error(`There is no built-in spinner named '${e}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`);this.#T=D[e]}else this.#T=D.line}get text(){return this.#A}set text(e=""){this.#A=e,this.#w()}get prefixText(){return this.#S}set prefixText(e=""){this.#S=e,this.#w()}get suffixText(){return this.#I}set suffixText(e=""){this.#I=e,this.#w()}get isSpinning(){return void 0!==this.#g}#C(e=this.#S,t=" "){return"string"==typeof e&&""!==e?e+t:"function"==typeof e?e()+t:""}#D(e=this.#I,t=" "){return"string"==typeof e&&""!==e?t+e:"function"==typeof e?t+e():""}#w(){const e=this.#R.columns??80,t=this.#C(this.#S,"-"),a=this.#D(this.#I,"-"),n=" ".repeat(this.#b)+t+"--"+this.#A+"--"+a;this.#_=0;for(const t of M(n).split("\n"))this.#_+=Math.max(1,Math.ceil(H(t,{countAnsiEscapeCodes:!0})/e))}get isEnabled(){return this.#O&&!this.#N}set isEnabled(e){if("boolean"!=typeof e)throw new TypeError("The `isEnabled` option must be a boolean");this.#O=e}get isSilent(){return this.#N}set isSilent(e){if("boolean"!=typeof e)throw new TypeError("The `isSilent` option must be a boolean");this.#N=e}frame(){const e=Date.now();(-1===this.#h||e-this.#E>=this.interval)&&(this.#h=++this.#h%this.#T.frames.length,this.#E=e);const{frames:t}=this.#T;let a=t[this.#h];this.color&&(a=r.Ay[this.color](a));return("string"==typeof this.#S&&""!==this.#S?this.#S+" ":"")+a+("string"==typeof this.text?" "+this.text:"")+("string"==typeof this.#I&&""!==this.#I?" "+this.#I:"")}clear(){if(!this.#O||!this.#R.isTTY)return this;this.#R.cursorTo(0);for(let e=0;e<this.#m;e++)e>0&&this.#R.moveCursor(0,-1),this.#R.clearLine(1);return(this.#b||this.lastIndent!==this.#b)&&this.#R.cursorTo(this.#b),this.lastIndent=this.#b,this.#m=0,this}render(){return this.#N||(this.clear(),this.#R.write(this.frame()),this.#m=this.#_),this}start(e){return e&&(this.text=e),this.#N?this:this.#O?(this.isSpinning||(this.#y.hideCursor&&C.hide(this.#R),this.#y.discardStdin&&n.stdin.isTTY&&(this.#f=!0,q.start()),this.render(),this.#g=setInterval(this.render.bind(this),this.interval)),this):(this.text&&this.#R.write(`- ${this.text}\n`),this)}stop(){return this.#O?(clearInterval(this.#g),this.#g=void 0,this.#h=0,this.clear(),this.#y.hideCursor&&C.show(this.#R),this.#y.discardStdin&&n.stdin.isTTY&&this.#f&&(q.stop(),this.#f=!1),this):this}succeed(e){return this.stopAndPersist({symbol:k.success,text:e})}fail(e){return this.stopAndPersist({symbol:k.error,text:e})}warn(e){return this.stopAndPersist({symbol:k.warning,text:e})}info(e){return this.stopAndPersist({symbol:k.info,text:e})}stopAndPersist(e={}){if(this.#N)return this;const t=e.prefixText??this.#S,a=this.#C(t," "),n=e.symbol??" ",r=e.text??this.text,i="string"==typeof r?(n?" ":"")+r:"",o=e.suffixText??this.#I,s=a+n+i+this.#D(o," ")+"\n";return this.stop(),this.#R.write(s),this}}function Q(e){return new W(e)}async function Y(e,t){const a="function"==typeof e,n="function"==typeof e.then;if(!a&&!n)throw new TypeError("Parameter `action` must be a Function or a Promise");const{successText:r,failText:i}="object"==typeof t?t:{successText:void 0,failText:void 0},o=Q(t).start();try{const t=a?e(o):e,n=await t;return o.succeed(void 0===r?void 0:"string"==typeof r?r:r(n)),n}catch(e){throw o.fail(void 0===i?void 0:"string"==typeof i?i:i(e)),e}}},9841:(e,t,a)=>{a.d(t,{I:()=>r});var n=a(8255);function r(e,t,a){return new n.eO(`Syntax Error: ${a}`,{source:e,positions:[t]})}},9850:(e,t,a)=>{var n=a(9546),r=a(5813),i=a(5243),o=a(482);e.exports=function(e,t,a){return e=i(e),void 0===(t=a?void 0:t)?r(e)?o(e):n(e):e.match(t)||[]}},9868:(e,t,a)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.validateSchemaDeps=t.validatePropertyDeps=t.error=void 0;const n=a(7898),r=a(458),i=a(4450);t.error={message:({params:{property:e,depsCount:t,deps:a}})=>{const r=1===t?"property":"properties";return n.str`must have ${r} ${a} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:a,missingProperty:r}})=>n._`{property: ${e},
655
655
  missingProperty: ${r},
656
656
  depsCount: ${t},
657
- deps: ${a}}`};const o={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(e){const[t,a]=function({schema:e}){const t={},a={};for(const n in e){if("__proto__"===n)continue;(Array.isArray(e[n])?t:a)[n]=e[n]}return[t,a]}(e);s(e,t),p(e,a)}};function s(e,t=e.schema){const{gen:a,data:r,it:o}=e;if(0===Object.keys(t).length)return;const s=a.let("missing");for(const p in t){const l=t[p];if(0===l.length)continue;const d=(0,i.propertyInData)(a,r,p,o.opts.ownProperties);e.setParams({property:p,depsCount:l.length,deps:l.join(", ")}),o.allErrors?a.if(d,()=>{for(const t of l)(0,i.checkReportMissingProp)(e,t)}):(a.if(n._`${d} && (${(0,i.checkMissingProp)(e,l,s)})`),(0,i.reportMissingProp)(e,s),a.else())}}function p(e,t=e.schema){const{gen:a,data:n,keyword:o,it:s}=e,p=a.name("valid");for(const l in t)(0,r.alwaysValidSchema)(s,t[l])||(a.if((0,i.propertyInData)(a,n,l,s.opts.ownProperties),()=>{const t=e.subschema({keyword:o,schemaProp:l},p);e.mergeValidEvaluated(t,p)},()=>a.var(p,!0)),e.ok(p))}t.validatePropertyDeps=s,t.validateSchemaDeps=p,t.default=o},9891:(e,t,a)=>{a.d(t,{ApolloLink:()=>n.C,concat:()=>s,empty:()=>r,execute:()=>p.g,from:()=>i,split:()=>o}),a.r(t);a(9212);var n=a(9074),r=n.C.empty,i=n.C.from,o=n.C.split,s=n.C.concat,p=a(5174)},9893:e=>{function t(a,n){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(a,n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},9896:e=>{e.exports=t("fs")},9952:(e,t,a)=>{a.d(t,{P:()=>o});var n=a(5608),r=a(9074),i=a(9760),o=function(e){function t(t){void 0===t&&(t={});var a=e.call(this,(0,i.$)(t).request)||this;return a.options=t,a}return(0,n.__extends)(t,e),t}(r.C)},9968:(e,t,a)=>{var n=a(1035)({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"});e.exports=n}},u={};function c(e){var t=u[e];if(void 0!==t)return t.exports;var a=u[e]={id:e,loaded:!1,exports:{}};return d[e].call(a.exports,a,a.exports,c),a.loaded=!0,a.exports}c.m=d,c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},c.d=(e,t)=>{for(var a in t)c.o(t,a)&&!c.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},c.f={},c.e=e=>Promise.all(Object.keys(c.f).reduce((t,a)=>(c.f[a](e,t),t),[])),c.u=e=>e+".index.js",c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),p={792:0},l=e=>{var t,a,{__webpack_esm_ids__:n,__webpack_esm_modules__:r,__webpack_esm_runtime__:i}=e,o=0;for(t in r)c.o(r,t)&&(c.m[t]=r[t]);for(i&&i(c);o<n.length;o++)a=n[o],c.o(p,a)&&p[a]&&p[a][0](),p[n[o]]=0},c.f.j=(e,t)=>{var a=c.o(p,e)?p[e]:void 0;if(0!==a)if(a)t.push(a[1]);else{var n=import("./"+c.u(e)).then(l,t=>{throw 0!==p[e]&&(p[e]=void 0),t});n=Promise.race([n,new Promise(t=>a=p[e]=[t])]),t.push(a[1]=n)}};var m={};c.r(m),c.d(m,{lI:()=>Rc,F3:()=>yc,mJ:()=>Tc,AW:()=>Nc,$V:()=>vc,J6:()=>Oc,Wt:()=>bc,qq:()=>gc,gw:()=>Ac,Yi:()=>Ec});var f={};c.r(f),c.d(f,{applicationFragment:()=>Rc,applicationShortFragment:()=>Dc,deviceFragment:()=>yc,deviceGroupFragment:()=>Tc,deviceShortFragment:()=>Pc,instanceVersionFragment:()=>Nc,mediaBoxFragment:()=>kc,mediaFileFragment:()=>Lc,mediaWorkspaceFragment:()=>jc,moduleFragment:()=>vc,moduleShortFragment:()=>Oc,operationFragment:()=>bc,publicApplicationBasicInfoFragment:()=>gc,userFavoriteFragment:()=>Ac,workspaceFragment:()=>wc,workspaceShortFragment:()=>Cc});var _={};c.r(_),c.d(_,{application:()=>dm,applicationByDevice:()=>Yc,applicationReleaseVersion:()=>qc,applicationReleaseVersions:()=>Kc,applicationTestsByDevice:()=>Xc,applications:()=>lm,checkBindDevicePasscode:()=>Jc,devices:()=>um,devicesByGroup:()=>em,devicesByUniqueId:()=>Zc,me:()=>zc,module:()=>Vc,moduleReleaseVersion:()=>Qc,moduleReleaseVersions:()=>Wc,modules:()=>$c,publicModules:()=>Uc,publicModulesByIdList:()=>Hc,workspace:()=>sm,workspacePricingPlans:()=>tm,workspaces:()=>pm});var h={};c.r(h),c.d(h,{addUserFavorite:()=>ef,assignGroupPermissions:()=>Ym,bindApplication:()=>Dm,bindApplicationWithDeviceGroup:()=>km,changeWorkspaceAdditionalLimitSpending:()=>nf,changeWorkspaceSubscriptionPlan:()=>af,controlDevice:()=>vm,createApplication:()=>Im,createApplicationWithShareVersion:()=>wm,createConfigChangeOperation:()=>Km,createDevice:()=>hm,createDeviceGroup:()=>Om,createDeviceGroupWithApp:()=>Gm,createModule:()=>zm,createVirtualDevice:()=>Em,createWorkspace:()=>mm,createWorkspaceOTP:()=>rf,dispatchDeviceGroupAction:()=>bm,doOperation:()=>qm,duplicateApplication:()=>Fm,duplicateModule:()=>Um,forkApplication:()=>xm,moveApplication:()=>Mm,moveDevice:()=>Tm,moveModule:()=>$m,registerFCMNotification:()=>Xm,registerRemoteDebug:()=>Jm,removeApplication:()=>Bm,removeDevice:()=>gm,removeDeviceGroup:()=>Am,removeModule:()=>Hm,removeOperation:()=>Qm,removeUserFavorite:()=>tf,removeWorkspace:()=>Sm,revokeWorkspaceOTP:()=>of,shareAccessToken:()=>Zm,shareApplication:()=>Lm,toggleShortEditApplication:()=>Pm,updateApplication:()=>Cm,updateApplicationViewportPreset:()=>jm,updateDevice:()=>ym,updateDeviceGroup:()=>Nm,updateModule:()=>Vm,updateOperation:()=>Wm,updateVirtualDevice:()=>Rm,updateWorkspace:()=>fm,updateWorkspaceTokens:()=>_m});var E={};c.r(E),c.d(E,{application:()=>Rf,applicationByDevice:()=>gf,applications:()=>Tf,device:()=>bf,devices:()=>Nf,devicesByApplication:()=>Af,mediaBox:()=>wf,mediaBoxes:()=>If,mediaFile:()=>Df,mediaFiles:()=>Cf,mediaWorkspace:()=>Sf,module:()=>Of,modules:()=>vf,workspace:()=>yf});var y={};c.r(y),c.d(y,{bindApplication:()=>Mf,copyMediaFiles:()=>Uf,createApplication:()=>kf,createModule:()=>xf,deleteMediaBoxFiles:()=>Kf,deleteMediaFiles:()=>Hf,requestFileUpload:()=>Bf,setMediaFileAsBoxPreview:()=>$f,unbindApplication:()=>Gf,updateApplication:()=>Lf,updateMediaFile:()=>zf,updateMediaFiles:()=>Vf,updateModule:()=>Ff});var T={};c.r(T),c.d(T,{mediaBox:()=>V_,mediaBoxes:()=>B_,mediaFile:()=>U_,mediaFiles:()=>$_,mediaWorkspace:()=>z_,mediaWorkspaces:()=>F_});var R={};c.r(R),c.d(R,{assignGroupPermissions:()=>ah,copyMediaFiles:()=>eh,createMediaBox:()=>q_,createMediaWorkspace:()=>H_,deleteMediaFiles:()=>Z_,moveMediaBox:()=>W_,requestFileUpload:()=>Y_,setMediaFileAsBoxPreview:()=>th,updateMediaBox:()=>Q_,updateMediaFile:()=>X_,updateMediaFiles:()=>J_,updateMediaWorkspace:()=>K_});var g={};c.r(g),c.d(g,{mediaBox:()=>rh,mediaFile:()=>oh,mediaFiles:()=>ih});var v={};c.r(v),c.d(v,{deleteMediaFiles:()=>dh,requestFileUpload:()=>sh,updateMediaFile:()=>ph,updateMediaFiles:()=>lh});var O=c(9436),N=c(5181);const{DM:b,gu:A,er:S,Ww:I,b7:w,Di:C,a2:D,uB:P,ef:j,c$:k,_V:L}=N;var M=c(8568),G=c(9790);const x=t("readline");var F,B,z,V=c(8765),$=c(7742),U=new P("auth").description("Authentication and token management");U.command("login").description("Login with a one-time passcode from BRICKS Controller (recommended)").argument("[passcode]","One-time passcode from BRICKS Controller").option("-p, --profile <profile>","Profile name to save the token","default").option("-n, --name <name>","Profile display name").action((F=O(function*(e,t){var a,n,r=t.profile,i=t.name,o=e;o||(console.log(M.Ay.cyan("Generate a one-time passcode from BRICKS Controller:")),console.log(M.Ay.gray(" 1. Open the link below (or select your workspace first)")),console.log(` ${M.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")}`),console.log(M.Ay.gray(' 2. Click "Generate OTP" to create a one-time passcode\n')),(o=yield(a="Enter passcode: ",n=x.createInterface({input:process.stdin,output:process.stdout}),new Promise(function(e){n.question(a,function(t){n.close(),e(t.trim())})})))||(console.log(M.Ay.red("Passcode is required")),process.exit(1)));var s=(0,G.default)("Validating passcode...").start();try{var p=(0,$.createPublicClient)((0,V.getBaseUrl)()),l=yield p.checkWorkspaceOTP(o);l.valid||(s.fail(`Invalid passcode: ${l.error||"Unknown error"}`),process.exit(1)),s.text=`Exchanging passcode for token (workspace: ${l.workspaceName})...`;var d=yield p.exchangeWorkspaceOTP(o);d.token||(s.fail("Failed to obtain token"),process.exit(1));var u=(0,$.createClient)((0,V.getBaseUrl)(),d.token),c=yield u.workspace();c||(s.fail("Token validation failed"),process.exit(1)),(0,V.setToken)(r,{token:d.token,name:i||c.name,workspaceId:c._id,workspaceName:c.name}),(0,V.setCurrentProfile)(r),s.succeed(`Logged in to workspace: ${M.Ay.green(c.name)}`),console.log(M.Ay.gray(`Profile saved as: ${r}`))}catch(e){s.fail(`Login failed: ${e.message}`),process.exit(1)}}),function(e,t){return F.apply(this,arguments)})),U.command("login-token").description("Login with a workspace token directly").option("-t, --token <token>","Workspace token").option("-p, --profile <profile>","Profile name to save the token","default").option("-n, --name <name>","Profile display name").action((B=O(function*(e){var t=e.token,a=e.profile,n=e.name;t||(console.error(M.Ay.red("Error: Token is required. Use -t or --token to provide it.")),console.log(M.Ay.gray("\nYou can get a workspace token from BRICKS Controller:")+M.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")),console.log(` ${M.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")}`),console.log(M.Ay.gray("Select your workspace and create a new token.\n")),console.log(M.Ay.yellow("Tip: Use `bricks auth login` for a simpler OTP-based login.")),process.exit(1));var r=(0,G.default)("Validating token...").start();try{var i=(0,$.createClient)((0,V.getBaseUrl)(),t),o=yield i.workspace();o||(r.fail("Invalid token or unable to access workspace"),process.exit(1)),(0,V.setToken)(a,{token:t,name:n||o.name,workspaceId:o._id,workspaceName:o.name}),(0,V.setCurrentProfile)(a),r.succeed(`Logged in to workspace: ${M.Ay.green(o.name)}`),console.log(M.Ay.gray(`Profile saved as: ${a}`))}catch(e){r.fail(`Login failed: ${e.message}`),process.exit(1)}}),function(e){return B.apply(this,arguments)})),U.command("logout").description("Remove saved token").option("-p, --profile <profile>","Profile to remove").option("-a, --all","Remove all profiles").action((z=O(function*(e){var t=e.profile;if(e.all)return(0,V.listProfiles)().forEach(function(e){return(0,V.removeToken)(e.name)}),void console.log(M.Ay.green("All profiles removed"));var a=t||(0,V.getCurrentProfile)();(0,V.getTokenInfo)(a)?((0,V.removeToken)(a),console.log(M.Ay.green(`Logged out from profile: ${a}`))):console.log(M.Ay.yellow(`No token found for profile: ${a}`))}),function(e){return z.apply(this,arguments)})),U.command("status").description("Show current authentication status").action(O(function*(){var e=(0,V.getCurrentProfile)(),t=(0,V.getTokenInfo)(e);if(!t)return console.log(M.Ay.yellow("Not logged in")),void console.log(M.Ay.gray("Use `bricks auth login` to login"));var a=(0,G.default)("Checking connection...").start();try{var n=(0,$.createClient)((0,V.getBaseUrl)(),t.token),r=yield n.workspace();a.stop(),console.log(M.Ay.bold("\nAuthentication Status")),console.log("─".repeat(40)),console.log(`Profile: ${M.Ay.cyan(e)}`),console.log(`Workspace: ${M.Ay.green(r.name)}`),console.log(`Workspace ID: ${M.Ay.gray(r._id)}`),console.log(`Base URL: ${M.Ay.gray((0,V.getBaseUrl)())}`),console.log(`Logged in: ${M.Ay.gray(t.createdAt)}`),console.log("─".repeat(40))}catch(e){a.fail(`Connection failed: ${e.message}`)}})),U.command("list").description("List all saved profiles").action(function(){var e=(0,V.listProfiles)();if(0===e.length)return console.log(M.Ay.yellow("No saved profiles")),void console.log(M.Ay.gray("Use `bricks auth login` to login"));console.log(M.Ay.bold("\nSaved Profiles")),console.log("─".repeat(60)),e.forEach(function(e){var t=e.current?M.Ay.green("● "):" ",a=e.current?M.Ay.green(e.name):e.name;console.log(`${t}${a.padEnd(15)} ${M.Ay.gray(e.workspaceName||"Unknown")}`)}),console.log("─".repeat(60))}),U.command("use <profile>").description("Switch to a different profile").action(function(e){var t=(0,V.getTokenInfo)(e);if(!t)return console.log(M.Ay.red(`Profile not found: ${e}`)),void console.log(M.Ay.gray("Use `bricks auth list` to see available profiles"));(0,V.setCurrentProfile)(e),console.log(M.Ay.green(`Switched to profile: ${e}`)),t.workspaceName&&console.log(M.Ay.gray(`Workspace: ${t.workspaceName}`))}),U.command("set-url <url>").description("Set the base URL for BRICKS API").action(function(e){(0,V.setBaseUrl)(e),console.log(M.Ay.green(`Base URL set to: ${e}`))});var H,K,q,W,Q,Y,X=c(8832),J=c(7336),Z=function(){var e=(0,V.getCurrentProfile)(),t=(0,V.getToken)(e);return t||(console.error(M.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,$.createClient)((0,V.getBaseUrl)(),t)},ee=function(e){if(!e)return M.Ay.gray("○ Unknown");var t=Date.now()-new Date(e).getTime();if(t<=3e5)return M.Ay.green("● Online");var a=Math.floor(t/6e4);if(a<60)return M.Ay.yellow(`○ Offline (${a}m ago)`);var n=Math.floor(a/60);if(n<24)return M.Ay.red(`○ Offline (${n}h ago)`);var r=Math.floor(n/24);return M.Ay.red(`○ Offline (${r}d ago)`)},te=new P("device").description("Device management");te.command("list").description("List all devices").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e){var t=Z(),a=(0,G.default)("Fetching devices...").start();try{var n=yield t.devices({keyword:e.keyword});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(M.Ay.yellow("No devices found"));console.log(M.Ay.bold("\nDevices")),console.log("─".repeat(80)),n.forEach(function(e){var t,a,n=null==(t=e.entry_detail)||null==(t=t.watch_dog_timer)?void 0:t.last_alive_time,r=ee(n),i=(null==(a=e.entry_detail)||null==(a=a.application)?void 0:a.name)||M.Ay.gray("No app bound");console.log(`${r} ${M.Ay.cyan(e.name||e.device_name)}`),console.log(` ID: ${M.Ay.gray(e._id)}`),console.log(` App: ${i}`),console.log()})}catch(e){a.fail(`Failed to list devices: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),te.command("get <id>").description("Get device details").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=Z(),n=(0,G.default)("Fetching device...").start();try{var r,i,o,s=yield a.device({id:e});if(n.stop(),s||(console.log(M.Ay.red("Device not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(s,null,2));var p=null==(r=s.entry_detail)||null==(r=r.watch_dog_timer)?void 0:r.last_alive_time,l=ee(p);if(console.log(M.Ay.bold(`\nDevice: ${s.name||s.device_name}`)),console.log("─".repeat(60)),console.log(`Status: ${l}`),console.log(`ID: ${M.Ay.gray(s._id)}`),console.log(`Device Name: ${s.device_name||M.Ay.gray("N/A")}`),console.log(`Description: ${s.description||M.Ay.gray("N/A")}`),console.log(`Tags: ${(null==(i=s.tags)?void 0:i.join(", "))||M.Ay.gray("None")}`),console.log(`Created: ${M.Ay.gray(s.create_datetime||"N/A")}`),console.log(`Modified: ${M.Ay.gray(s.last_modify_datetime||"N/A")}`),s.entry_detail){var d,u,c,m,f=s.entry_detail;if(console.log(`\n${M.Ay.bold("Entry Details")}`),console.log(`Type: ${f.type||M.Ay.gray("N/A")}`),console.log(`Unique ID: ${M.Ay.gray(f.unique_id||"N/A")}`),console.log(`Version: ${f.operation_version||M.Ay.gray("N/A")}`),console.log(`Mode: ${f.operation_mode||M.Ay.gray("N/A")}`),Array.isArray(f.screen)&&f.screen.length>0)console.log(`\n${M.Ay.bold("Screens")} (${f.screen.length})`),f.screen.forEach(function(e,t){var a,n=e.resolution,r=n?`${n.width}x${n.height} @${n.scale}x`:"N/A",i=e.master?M.Ay.green(" (master)"):"",o=e.orientation?` [${e.orientation}]`:"",s=null!=(a=e.touch)&&a.available?M.Ay.cyan(` touch:${e.touch.touch_point}pt`):"";console.log(` ${t+1}. ${e.title||"Screen"}${i}${o} - ${r}${s}`)});else if(null!=(d=f.screen)&&d.resolution){var _=f.screen.resolution;console.log(`Resolution: ${_.width}x${_.height} @${_.scale}x`)}var h=null!=f.memory_usage,E=null!=f.disk_usage;if(h||E){if(console.log(`\n${M.Ay.bold("System Resources")}`),h){var y=Array.isArray(f.memory_usage)?f.memory_usage[0]:f.memory_usage,T=Math.round(100*y),R=M.Ay.green;T>80?R=M.Ay.red:T>60&&(R=M.Ay.yellow),console.log(`Memory: ${R(`${T}%`)}`)}if(E){var g=Array.isArray(f.disk_usage)?f.disk_usage[0]:f.disk_usage,v=Math.round(100*g),O=M.Ay.green;v>90?O=M.Ay.red:v>75&&(O=M.Ay.yellow),console.log(`Disk: ${O(`${v}%`)}`)}}var N,b=[];if(null!=(u=f.sound)&&u.available&&b.push("Sound"),null!=(c=f.camera)&&c.available&&b.push("Camera"),null!=(m=f.audio_in)&&m.available&&b.push("Audio Input"),b.length>0)console.log(`\n${M.Ay.bold("Capabilities")}`),console.log(`Available: ${b.join(", ")}`),(null==(N=f.camera)||null==(N=N.channel)?void 0:N.length)>0&&f.camera.channel.forEach(function(e){var t=e.resolution?`${e.resolution.width}x${e.resolution.height}`:"";console.log(` Camera: ${e.title||"Camera"} ${t} [${e.orientation||"N/A"}]`)});if(f.local_sync){var A=f.local_sync;console.log(`\n${M.Ay.bold("Local Sync")}`),console.log(`Role: ${A.is_main?M.Ay.cyan("Main"):"Secondary"}`),null!=A.peer_count&&console.log(`Peers: ${A.peer_count}`),null!=A.mean_latency&&console.log(`Latency: ${A.mean_latency.toFixed(2)}ms`)}if(f.update){var S=f.update;console.log(`\n${M.Ay.bold("Update Status")}`),console.log(`Needs Update: ${S.need_update?M.Ay.yellow("Yes"):M.Ay.green("No")}`),S.current_version&&console.log(`App Version: ${S.current_version}`),S.running_mode&&console.log(`Running Mode: ${S.running_mode}`),S.last_update_at&&console.log(`Last Update: ${M.Ay.gray(S.last_update_at)}`)}if(f.watch_dog_timer){var I=f.watch_dog_timer;console.log(`\n${M.Ay.bold("Watchdog")}`),console.log(`Alive: ${I.alive?M.Ay.green("Yes"):M.Ay.red("No")}`),I.last_launch_time&&console.log(`Last Launch: ${M.Ay.gray(I.last_launch_time)}`),I.last_alive_time&&console.log(`Last Alive: ${M.Ay.gray(I.last_alive_time)}`)}}s.bound_application&&(console.log(`\n${M.Ay.bold("Bound Application")}`),console.log(`Name: ${s.bound_application.name}`),console.log(`ID: ${M.Ay.gray(s.bound_application._id)}`)),null!=(o=s.env)&&o.variables&&Object.keys(s.env.variables).length>0&&(console.log(`\n${M.Ay.bold("Environment Variables")}`),Object.entries(s.env.variables).forEach(function(e){var t=X(e,2),a=t[0],n=t[1];console.log(` ${M.Ay.cyan(a)}: ${n}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get device: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),te.command("bind <passcode>").description("Bind a new device using passcode").option("-n, --name <name>","Device name").action((H=O(function*(e,t){var a=Z(),n=(0,G.default)("Checking passcode...").start();try{var r,i,o=yield a.checkBindDevicePasscode({passcode:e});o||(n.fail("Invalid passcode or expired"),process.exit(1)),n.text="Binding device...";var s=yield a.createDevice({bindPasscode:e,name:t.name||(null==(r=o.payload)?void 0:r.deviceName)||"CLI Device",deviceName:null==(i=o.payload)?void 0:i.deviceName});n.succeed(`Device bound successfully: ${M.Ay.green(s.name)}`),console.log(M.Ay.gray(`Device ID: ${s._id}`))}catch(e){n.fail(`Failed to bind device: ${e.message}`),process.exit(1)}}),function(e,t){return H.apply(this,arguments)})),te.command("control <id> <type>").description("Control a device").option("-p, --payload <json>","Event payload as JSON").action((K=O(function*(e,t,a){var n=Z(),r=(0,G.default)(`Sending ${t} to device...`).start();try{var i;a.payload&&(i=JSON.parse(a.payload)),yield n.controlDevice({id:e,type:t,eventPayload:i}),r.succeed(`Control event sent: ${M.Ay.green(t)}`)}catch(e){r.fail(`Failed to control device: ${e.message}`),process.exit(1)}}),function(e,t,a){return K.apply(this,arguments)})),te.command("refresh <id>").description("Refresh device application").action((q=O(function*(e){var t=Z(),a=(0,G.default)("Refreshing device...").start();try{yield t.controlDevice({id:e,type:"refresh"}),a.succeed("Device refreshed")}catch(e){a.fail(`Failed to refresh device: ${e.message}`),process.exit(1)}}),function(e){return q.apply(this,arguments)})),te.command("clear-cache <id>").description("Clear device cache").action((W=O(function*(e){var t=Z(),a=(0,G.default)("Clearing cache...").start();try{yield t.controlDevice({id:e,type:"clear-cache"}),a.succeed("Cache cleared")}catch(e){a.fail(`Failed to clear cache: ${e.message}`),process.exit(1)}}),function(e){return W.apply(this,arguments)})),te.command("screenshot <id>").description("Take device screenshot and save to file").option("-o, --output <path>","Output file path").option("--no-take","Only fetch existing screenshot without taking a new one").action((Q=O(function*(e,t){var a=Z(),n=(0,G.default)("Fetching workspace info...").start();try{var r,i,o,s=yield a.workspace();null!=s&&null!=(r=s.media_resource)&&r.enable_media_workspace||(n.fail("Media workspace is not enabled for this workspace"),process.exit(1)),s.media_resource.system_media_box_id||(n.fail("No media box configured for this workspace"),process.exit(1)),!1!==t.take&&(n.text="Sending screenshot request to device...",yield a.controlDevice({id:e,type:"take-screenshot"}),n.text="Waiting for device to capture screenshot...",yield new Promise(function(e){return setTimeout(e,3e3)})),n.text="Fetching screenshot...";var p=yield(0,J.he)(a,s,e,t.output);if(p.error&&(n.fail(p.error),process.exit(1)),n.succeed("Screenshot saved"),console.log(),console.log(M.Ay.bold("Screenshot saved to:")),console.log(M.Ay.cyan(p.path)),console.log(),null!=(i=p.file)&&i.meta){var l=p.file.meta,d=l.originalWidth,u=l.originalHeight,c=l.originalFileSize;if(d&&u&&console.log(`${M.Ay.gray("Size:")} ${d}x${u}`),c){var m=(c/1024).toFixed(1);console.log(`${M.Ay.gray("File:")} ${m} KB`)}}null!=(o=p.file)&&o.updatedAt&&console.log(`${M.Ay.gray("Updated:")} ${new Date(p.file.updatedAt).toLocaleString()}`)}catch(e){n.fail(`Failed to get screenshot: ${e.message}`),process.exit(1)}}),function(e,t){return Q.apply(this,arguments)})),te.command("monitor").description("Monitor device status (polls every 60s)").option("-g, --group <id>","Monitor devices in a group").option("-i, --interval <seconds>","Polling interval in seconds","60").action((Y=O(function*(e){var t=Z(),a=1e3*parseInt(e.interval,10);console.log(M.Ay.bold("\nDevice Monitor")),console.log(M.Ay.gray(`Polling every ${e.interval}s. Press Ctrl+C to stop.\n`));var n,r=(n=O(function*(){try{var a;if(a=e.group?yield t.devicesByGroup({id:e.group}):yield t.devices({}),process.stdout.write(""),console.log(M.Ay.bold("Device Monitor")+M.Ay.gray(` - ${(new Date).toLocaleTimeString()}`)),console.log("─".repeat(80)),!a||0===a.length)return void console.log(M.Ay.yellow("No devices found"));a.forEach(function(e){var t,a,n=null==(t=e.entry_detail)||null==(t=t.watch_dog_timer)?void 0:t.last_alive_time,r=ee(n),i=e.name||e.device_name||e.device_target_name,o=(null==(a=e.entry_detail)||null==(a=a.application)?void 0:a.name)||M.Ay.gray("No app");console.log(`${r} ${M.Ay.cyan(i.padEnd(25))} ${o}`)}),console.log(`\n${M.Ay.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(M.Ay.red(`Error: ${e.message}`))}}),function(){return n.apply(this,arguments)});yield r(),setInterval(r,a)}),function(e){return Y.apply(this,arguments)}));var ae,ne,re=c(9896),ie=c(5704),oe=function(){var e=(0,V.getCurrentProfile)(),t=(0,V.getToken)(e);return t||(console.error(M.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,$.createClient)((0,V.getBaseUrl)(),t)},se=new P("app").description("Application management");se.command("list").description("List all applications").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e){var t=oe(),a=(0,G.default)("Fetching applications...").start();try{var n=yield t.applications({keyword:e.keyword});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(M.Ay.yellow("No applications found"));console.log(M.Ay.bold("\nApplications")),console.log("─".repeat(80)),n.forEach(function(e){var t=e.has_unreleased_changes?M.Ay.yellow("●"):M.Ay.green("●"),a=e.current_version?`v${e.current_version}`:M.Ay.gray("no version");console.log(`${t} ${M.Ay.cyan(e.name)} ${M.Ay.gray(a)}`),console.log(` ID: ${M.Ay.gray(e._id)}`),e.description&&console.log(` ${M.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list applications: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),se.command("get <id>").description("Get application details").option("-c, --composed","Get composed configuration").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=oe(),n=(0,G.default)("Fetching application...").start();try{var r,i,o,s,p,l,d=yield a.application({id:e,composed:t.composed});if(n.stop(),d||(console.log(M.Ay.red("Application not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(d,null,2));if(console.log(M.Ay.bold(`\nApplication: ${d.name}`)),console.log("─".repeat(60)),console.log(`ID: ${M.Ay.gray(d._id)}`),console.log(`Description: ${d.description||M.Ay.gray("N/A")}`),console.log(`Tags: ${(null==(r=d.tags)?void 0:r.join(", "))||M.Ay.gray("None")}`),console.log(`Created: ${M.Ay.gray(d.create_datetime)}`),console.log(`Modified: ${M.Ay.gray(d.last_modify_datetime)}`),console.log(`\n${M.Ay.bold("Version")}`),d.current_version){if(console.log(`Current: v${d.current_version}`),d.current_version_details){var u=d.current_version_details;u.name&&console.log(`Release Name: ${u.name}`),u.note&&console.log(`Release Note: ${M.Ay.gray(u.note)}`),u.create_datetime&&console.log(`Released At: ${M.Ay.gray(u.create_datetime)}`)}}else console.log(`Current: ${M.Ay.gray("No version")}`);if(console.log(`Unreleased: ${d.has_unreleased_changes?M.Ay.yellow("Yes"):M.Ay.green("No")}`),console.log(`\n${M.Ay.bold("Features")}`),console.log(`Short Edit: ${null!=(i=d.short_edit)&&i.enabled?M.Ay.green("Enabled"):M.Ay.gray("Disabled")}`),null!=(o=d.short_edit)&&o.enabled&&d.short_edit.ref_map){var c=Object.keys(d.short_edit.ref_map).length;console.log(` References: ${c} editable properties`)}console.log(`Automation: ${null!=(s=d.canvas_control)&&s.enable_schedule?M.Ay.green("Scheduled"):M.Ay.gray("No schedule")}`),null!=(p=d.lock)&&p.locked&&console.log(`Locked: ${M.Ay.yellow("Yes")} (at ${d.lock.locked_at||"N/A"})`),d.sync_key&&console.log(`Sync Key: ${M.Ay.gray(d.sync_key)}`),(null==(l=d.devices)?void 0:l.length)>0?(console.log(`\n${M.Ay.bold("Bound Devices")} (${d.devices.length})`),d.devices.forEach(function(e){var t="active"===e.status?M.Ay.green("●"):M.Ay.gray("○"),a=e.frame?M.Ay.gray(` [${e.frame.x||0},${e.frame.y||0} ${e.frame.width}x${e.frame.height}]`):"";console.log(` ${t} ${e.device_id}${a}`)})):console.log(`\n${M.Ay.bold("Bound Devices")}: ${M.Ay.gray("None")}`),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get application: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),se.command("update <id>").description("Update application").option("-n, --name <name>","Application name").option("-d, --description <description>","Application description").option("-c, --config <json>","Application config as JSON string").option("-f, --file <path>","Application config from file").option("--validate","Validate configuration").action(function(){var e=O(function*(e,t){var a=oe(),n=(0,G.default)("Updating application...").start();try{var r={id:e};t.name&&(r.name=t.name),t.description&&(r.description=t.description),t.validate&&(r.validateConfig=!0),t.config?r.config=t.config:t.file&&(r.config=re.readFileSync(t.file,"utf-8"));var i=yield a.updateApplication(r);n.succeed(`Application updated: ${M.Ay.green(i.name)}`),i.has_unreleased_changes&&console.log(M.Ay.yellow("Note: Application has unreleased changes"))}catch(e){n.fail(`Failed to update application: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),se.command("short-edit <id>").description("Short edit application properties").requiredOption("-l, --list <json>","Short edit list as JSON array").action((ae=O(function*(e,t){var a=oe(),n=(0,G.default)("Applying short edit...").start();try{var r=JSON.parse(t.list);Array.isArray(r)||(n.fail("List must be a JSON array"),process.exit(1));var i=yield a.shortEditApplication({id:e,list:r});n.succeed(`Short edit applied to: ${M.Ay.green(i.name)}`)}catch(e){n.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}}),function(e,t){return ae.apply(this,arguments)})),se.command("short-refs <id>").description("List short edit references for an application").option("-k, --keyword <keyword>","Filter by shortId or title").option("-t, --types <types>","Comma-separated shortId prefixes to include (e.g. B,C,S)").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=oe(),n=(0,G.default)("Fetching short edit references...").start();try{var r,i=yield a.application({id:e});if(n.stop(),null==i||null==(r=i.short_edit)||!r.enabled)return void console.log(M.Ay.yellow("Short Edit is not enabled for this application"));var o=t.types?t.types.split(",").map(function(e){return e.trim()}).filter(Boolean):[],s=(0,ie.V)(i.short_edit.ref_map,{keyword:t.keyword,types:o});if(t.json)return void console.log(JSON.stringify(s,null,2));if(0===s.length)return void console.log(M.Ay.yellow("No short edit references found"));console.log(M.Ay.bold(`\nShort Edit References: ${i.name}`)),s.forEach(function(e){console.log(M.Ay.cyan(`\n${e.label} (${e.prefix}_)`)),e.refs.forEach(function(e){var t=e.shortId,a=e.ref,n=null!=a&&a.title?M.Ay.gray(`- ${a.title}`):"";console.log(` ${M.Ay.green(t)} ${n}`)})}),console.log()}catch(e){n.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),se.command("bind <id>").description("Bind devices to application").option("-b, --bind <devices>","Device IDs to bind (comma-separated)").option("-u, --unbind <devices>","Device IDs to unbind (comma-separated)").action(function(){var e=O(function*(e,t){var a=oe(),n=(0,G.default)("Updating device bindings...").start();try{var r={id:e};t.bind&&(r.bindDevices=t.bind.split(",").map(function(e){return e.trim()})),t.unbind&&(r.unbindDevices=t.unbind.split(",").map(function(e){return e.trim()})),yield a.bindApplication(r),n.succeed("Device bindings updated")}catch(e){n.fail(`Failed to update bindings: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),se.command("trigger <id> <testId>").description("Trigger automation test on application").option("--play","Play the test",!0).option("--stop","Stop the test").option("--setup-at-launch","Setup to run at app launch").option("-g, --match-group <group>","Match group").action(function(){var e=O(function*(e,t,a){var n=oe(),r=(0,G.default)("Triggering automation...").start();try{yield n.triggerApplicationCanvasControl({id:e,testId:t,play:!a.stop&&a.play,setupAtLaunch:a.setupAtLaunch,matchGroup:a.matchGroup}),r.succeed(`Automation triggered: ${M.Ay.green(t)}`)}catch(e){r.fail(`Failed to trigger automation: ${e.message}`),process.exit(1)}});return function(t,a,n){return e.apply(this,arguments)}}()),se.command("release <id>").description("Release application to BRICKS platform").requiredOption("-c, --config <path|json>","Application config file path or JSON string").option("--version <version>","Version name").option("--changelogs <text>","Release changelogs").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=oe(),n=t.json?null:(0,G.default)("Releasing application...").start();try{var r,i=t.config;(t.config.endsWith(".json")||t.config.includes("/"))&&(re.existsSync(t.config)||(n?n.fail(`Config file not found: ${t.config}`):console.error(JSON.stringify({error:`Config file not found: ${t.config}`})),process.exit(1)),i=re.readFileSync(t.config,"utf-8"));var o=yield a.application({id:e});o||(n?n.fail("Application not found"):console.error(JSON.stringify({error:"Application not found"})),process.exit(1)),null!=(r=o.lock)&&r.enabled&&(n?n.fail("Application is locked"):console.error(JSON.stringify({error:"Application is locked"})),process.exit(1));var s=t.version||o.name||"Untitled",p=t.changelogs?`${t.changelogs}\n\nRelease by BRICKS CLI`:"Release by BRICKS CLI";yield a.releaseApplication({id:e,config:i,releaseCurrentVersion:s,releaseCurrentVersionNote:p}),t.json?console.log(JSON.stringify({success:!0,name:o.name})):n.succeed(`Application released: ${M.Ay.green(o.name)}`)}catch(e){t.json?console.error(JSON.stringify({error:e.message})):n.fail(`Failed to release application: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),se.command("project-pull <id>").description("Pull application source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action(function(){var e=O(function*(e,t){var a=oe(),n=t.json?null:(0,G.default)("Pulling application project...").start();try{var r,i=yield a.applicationProject({id:e,buildApplicationOnly:!0});if(i||(n?n.fail("Application project not found"):console.error(JSON.stringify({error:"Application project not found"})),process.exit(1)),t.json)console.log(JSON.stringify(i));else n.succeed(`Application project fetched: ${M.Ay.green((null==(r=i.files)?void 0:r.length)||0)} files`),console.log(JSON.stringify(i,null,2))}catch(e){t.json?console.error(JSON.stringify({error:e.message})):n.fail(`Failed to pull application project: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),se.command("project-init <id>").description("Initialize a BRICKS Project from an application").option("-o, --output <dir>","Output directory (default: current directory)").option("--github-actions","Include GitHub Actions workflow (default: true)").option("--no-github-actions","Skip GitHub Actions workflow setup").option("--agents","Include AGENTS.md (default: true)").option("--no-agents","Skip AGENTS.md setup").option("--claude","Include CLAUDE.md (default: true)").option("--no-claude","Skip CLAUDE.md setup").option("--gemini","Include GEMINI.md (default: false)").option("--no-gemini","Skip GEMINI.md setup").option("--install","Run bun install after generation (default: true)").option("--no-install","Skip bun install after generation").option("--git","Initialize git repository (default: true)").option("--no-git","Skip git initialization").option("-y, --yes","Skip prompts and use defaults/flags").option("-j, --json","Output as JSON (for programmatic use)").action((ne=O(function*(e,t){var a=(yield Promise.all([c.e(616),c.e(153)]).then(c.bind(c,7153))).initProject;yield a("application",e,t)}),function(e,t){return ne.apply(this,arguments)}));var pe=function(){var e=(0,V.getCurrentProfile)(),t=(0,V.getToken)(e);return t||(console.error(M.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,$.createClient)((0,V.getBaseUrl)(),t)},le=new P("module").description("Module management");le.command("list").description("List all modules").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e){var t=pe(),a=(0,G.default)("Fetching modules...").start();try{var n=yield t.modules({keyword:e.keyword});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(M.Ay.yellow("No modules found"));console.log(M.Ay.bold("\nModules")),console.log("─".repeat(80)),n.forEach(function(e){var t=e.current_version?`v${e.current_version}`:M.Ay.gray("no version");console.log(`● ${M.Ay.cyan(e.name)} ${M.Ay.gray(t)}`),console.log(` ID: ${M.Ay.gray(e._id)}`),e.description&&console.log(` ${M.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list modules: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),le.command("get <id>").description("Get module details").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=pe(),n=(0,G.default)("Fetching module...").start();try{var r,i,o,s,p,l=yield a.module({id:e});if(n.stop(),l||(console.log(M.Ay.red("Module not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(l,null,2));if(console.log(M.Ay.bold(`\nModule: ${l.name}`)),console.log("─".repeat(60)),console.log(`ID: ${M.Ay.gray(l._id)}`),console.log(`Description: ${l.description||M.Ay.gray("N/A")}`),console.log(`Tags: ${(null==(r=l.tags)?void 0:r.join(", "))||M.Ay.gray("None")}`),console.log(`Created: ${M.Ay.gray(l.create_datetime)}`),console.log(`Modified: ${M.Ay.gray(l.last_modify_datetime)}`),console.log(`\n${M.Ay.bold("Version")}`),console.log(`Current: ${l.current_version?`v${l.current_version}`:M.Ay.gray("No version")}`),console.log(`Unreleased: ${l.has_unreleased_changes?M.Ay.yellow("Yes"):M.Ay.green("No")}`),console.log(`\n${M.Ay.bold("Settings")}`),console.log(`Public: ${l.is_public?M.Ay.green("Yes"):M.Ay.gray("No")}`),console.log(`Allow Modify: ${l.is_allow_modify?M.Ay.green("Yes"):M.Ay.gray("No")}`),console.log(`Short Edit: ${null!=(i=l.short_edit)&&i.enabled?M.Ay.green("Enabled"):M.Ay.gray("Disabled")}`),null!=(o=l.short_edit)&&o.enabled&&l.short_edit.ref_map){var d=Object.keys(l.short_edit.ref_map).length;console.log(` References: ${d} editable properties`)}null!=(null==(s=l.use_count)?void 0:s.total_count)&&(console.log(`\n${M.Ay.bold("Usage")}`),console.log(`Used In: ${l.use_count.total_count} application(s)`)),(null==(p=l.expose_properties)?void 0:p.length)>0&&(console.log(`\n${M.Ay.bold("Exposed Properties")} (${l.expose_properties.length})`),l.expose_properties.forEach(function(e){console.log(` - ${M.Ay.cyan(e)}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get module: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),le.command("update <id>").description("Update module").option("-n, --name <name>","Module name").option("-d, --description <description>","Module description").option("-c, --config <json>","Module config as JSON string").option("-f, --file <path>","Module config from file").option("--validate","Validate configuration").action(function(){var e=O(function*(e,t){var a=pe(),n=(0,G.default)("Updating module...").start();try{var r={id:e};t.name&&(r.name=t.name),t.description&&(r.description=t.description),t.validate&&(r.validateConfig=!0),t.config?r.config=t.config:t.file&&(r.config=re.readFileSync(t.file,"utf-8"));var i=yield a.updateModule(r);n.succeed(`Module updated: ${M.Ay.green(i.name)}`)}catch(e){n.fail(`Failed to update module: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),le.command("short-edit <id>").description("Short edit module properties").requiredOption("-l, --list <json>","Short edit list as JSON array").action(function(){var e=O(function*(e,t){var a=pe(),n=(0,G.default)("Applying short edit...").start();try{var r=JSON.parse(t.list);Array.isArray(r)||(n.fail("List must be a JSON array"),process.exit(1));var i=yield a.shortEditModule({id:e,list:r});n.succeed(`Short edit applied to: ${M.Ay.green(i.name)}`)}catch(e){n.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),le.command("short-refs <id>").description("List short edit references for a module").option("-k, --keyword <keyword>","Filter by shortId or title").option("-t, --types <types>","Comma-separated shortId prefixes to include (e.g. B,C,S)").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=pe(),n=(0,G.default)("Fetching short edit references...").start();try{var r,i=yield a.module({id:e});if(n.stop(),null==i||null==(r=i.short_edit)||!r.enabled)return void console.log(M.Ay.yellow("Short Edit is not enabled for this module"));var o=t.types?t.types.split(",").map(function(e){return e.trim()}).filter(Boolean):[],s=(0,ie.V)(i.short_edit.ref_map,{keyword:t.keyword,types:o});if(t.json)return void console.log(JSON.stringify(s,null,2));if(0===s.length)return void console.log(M.Ay.yellow("No short edit references found"));console.log(M.Ay.bold(`\nShort Edit References: ${i.name}`)),s.forEach(function(e){console.log(M.Ay.cyan(`\n${e.label} (${e.prefix}_)`)),e.refs.forEach(function(e){var t=e.shortId,a=e.ref,n=null!=a&&a.title?M.Ay.gray(`- ${a.title}`):"";console.log(` ${M.Ay.green(t)} ${n}`)})}),console.log()}catch(e){n.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),le.command("release <id>").description("Release module to BRICKS platform").requiredOption("-c, --config <path|json>","Module config file path or JSON string").option("--version <version>","Version name").option("--changelogs <text>","Release changelogs").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=pe(),n=t.json?null:(0,G.default)("Releasing module...").start();try{var r=t.config;(t.config.endsWith(".json")||t.config.includes("/"))&&(re.existsSync(t.config)||(n?n.fail(`Config file not found: ${t.config}`):console.error(JSON.stringify({error:`Config file not found: ${t.config}`})),process.exit(1)),r=re.readFileSync(t.config,"utf-8"));var i=yield a.module({id:e});i||(n?n.fail("Module not found"):console.error(JSON.stringify({error:"Module not found"})),process.exit(1)),i.is_public&&(n?n.fail("Public module deployment is temporarily not recommended"):console.error(JSON.stringify({error:"Public module deployment is temporarily not recommended"})),process.exit(1));var o=t.version||i.name||"Untitled",s=t.changelogs?`${t.changelogs}\n\nRelease by BRICKS CLI`:"Release by BRICKS CLI";yield a.releaseModule({id:e,config:r,releaseCurrentVersion:o,releaseCurrentVersionNote:s}),t.json?console.log(JSON.stringify({success:!0,name:i.name})):n.succeed(`Module released: ${M.Ay.green(i.name)}`)}catch(e){t.json?console.error(JSON.stringify({error:e.message})):n.fail(`Failed to release module: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),le.command("project-pull <id>").description("Pull module source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action(function(){var e=O(function*(e,t){var a=pe(),n=t.json?null:(0,G.default)("Pulling module project...").start();try{var r,i=yield a.moduleProject({id:e,buildApplicationOnly:!0});if(i||(n?n.fail("Module project not found"):console.error(JSON.stringify({error:"Module project not found"})),process.exit(1)),t.json)console.log(JSON.stringify(i));else n.succeed(`Module project fetched: ${M.Ay.green((null==(r=i.files)?void 0:r.length)||0)} files`),console.log(JSON.stringify(i,null,2))}catch(e){t.json?console.error(JSON.stringify({error:e.message})):n.fail(`Failed to pull module project: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),le.command("project-init <id>").description("Initialize a BRICKS Project from a module").option("-o, --output <dir>","Output directory (default: current directory)").option("--github-actions","Include GitHub Actions workflow (default: true)").option("--no-github-actions","Skip GitHub Actions workflow setup").option("--agents","Include AGENTS.md (default: true)").option("--no-agents","Skip AGENTS.md setup").option("--claude","Include CLAUDE.md (default: true)").option("--no-claude","Skip CLAUDE.md setup").option("--gemini","Include GEMINI.md (default: false)").option("--no-gemini","Skip GEMINI.md setup").option("--install","Run bun install after generation (default: true)").option("--no-install","Skip bun install after generation").option("--git","Initialize git repository (default: true)").option("--no-git","Skip git initialization").option("-y, --yes","Skip prompts and use defaults/flags").option("-j, --json","Output as JSON (for programmatic use)").action(function(){var e=O(function*(e,t){var a=(yield Promise.all([c.e(616),c.e(153)]).then(c.bind(c,7153))).initProject;yield a("module",e,t)});return function(t,a){return e.apply(this,arguments)}}());var de=function(){var e=(0,V.getCurrentProfile)(),t=(0,V.getToken)(e);return t||(console.error(M.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,$.createClient)((0,V.getBaseUrl)(),t)},ue=3e5,ce=function(e){if(!e)return M.Ay.gray("○");var t=Date.now()-new Date(e).getTime();return t<=ue?M.Ay.green("●"):Math.floor(t/6e4)<60?M.Ay.yellow("○"):M.Ay.red("○")},me=new P("group").description("Device Group management");me.command("list").description("List all device groups").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e){var t=de(),a=(0,G.default)("Fetching device groups...").start();try{var n=yield t.deviceGroups({});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(M.Ay.yellow("No device groups found"));console.log(M.Ay.bold("\nDevice Groups")),console.log("─".repeat(80)),n.forEach(function(e){var t,a=(null==(t=e.devices)?void 0:t.length)||0;console.log(`● ${M.Ay.cyan(e.name)} ${M.Ay.gray(`(${a} devices)`)}`),console.log(` ID: ${M.Ay.gray(e._id)}`),e.description&&console.log(` ${M.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list groups: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),me.command("get <id>").description("Get device group details").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=de(),n=(0,G.default)("Fetching device group...").start();try{var r,i,o=yield a.deviceGroup({id:e});if(n.stop(),o||(console.log(M.Ay.red("Device group not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(o,null,2));console.log(M.Ay.bold(`\nDevice Group: ${o.name}`)),console.log("─".repeat(60)),console.log(`ID: ${M.Ay.gray(o._id)}`),console.log(`Description: ${o.description||M.Ay.gray("N/A")}`),console.log(`Tags: ${(null==(r=o.tags)?void 0:r.join(", "))||M.Ay.gray("None")}`),console.log(`Created: ${M.Ay.gray(o.create_datetime)}`),console.log(`Modified: ${M.Ay.gray(o.last_modify_datetime)}`),(null==(i=o.devices)?void 0:i.length)>0&&(console.log(`\n${M.Ay.bold("Devices")} (${o.devices.length})`),o.devices.forEach(function(e){var t=e.device_target_name||e.device_id;console.log(` - ${t} ${M.Ay.gray(`(${e.device_id})`)}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get group: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),me.command("devices <id>").description("List devices in a group with status").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=de(),n=(0,G.default)("Fetching devices...").start();try{var r=yield a.devicesByGroup({id:e});if(n.stop(),t.json)return void console.log(JSON.stringify(r,null,2));if(!r||0===r.length)return void console.log(M.Ay.yellow("No devices in this group"));console.log(M.Ay.bold("\nDevices in Group")),console.log("─".repeat(80)),r.forEach(function(e){var t,a,n=null==(t=e.entry_detail)||null==(t=t.watch_dog_timer)?void 0:t.last_alive_time,r=ce(n),i=e.name||e.device_name||e.device_target_name,o=(null==(a=e.entry_detail)||null==(a=a.application)?void 0:a.name)||M.Ay.gray("No app");console.log(`${r} ${M.Ay.cyan(i.padEnd(30))} ${o}`)}),console.log("─".repeat(80))}catch(e){n.fail(`Failed to get devices: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),me.command("dispatch <id> <action>").description("Dispatch action to all devices in group").action(function(){var e=O(function*(e,t){var a=de(),n=(0,G.default)(`Dispatching ${t}...`).start(),r=["refresh","clear-cache","system-menu-open","system-menu-close","system-info-open","system-info-close","local-sync-panel-open","local-sync-panel-close","debug-panel-open","debug-panel-close","logging-on","logging-off","test-panel-open","test-panel-close"];r.includes(t)||(n.fail(`Invalid action. Valid actions: ${r.join(", ")}`),process.exit(1));try{var i=yield a.dispatchDeviceGroupAction({id:e,action:t});n.succeed(`Action dispatched: ${M.Ay.green(t)}`),i&&(console.log(`Success: ${M.Ay.green(i.success||0)}`),console.log(`Failed: ${M.Ay.red(i.failed||0)}`))}catch(e){n.fail(`Failed to dispatch action: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),me.command("refresh <id>").description("Refresh all devices in group").action(function(){var e=O(function*(e){var t=de(),a=(0,G.default)("Refreshing devices...").start();try{var n=yield t.dispatchDeviceGroupAction({id:e,action:"refresh"});a.succeed("Devices refreshed"),n&&(console.log(`Success: ${M.Ay.green(n.success||0)}`),console.log(`Failed: ${M.Ay.red(n.failed||0)}`))}catch(e){a.fail(`Failed to refresh: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),me.command("monitor <id>").description("Monitor devices in group (polls every 60s)").option("-i, --interval <seconds>","Polling interval in seconds","60").action(function(){var e=O(function*(e,t){var a=de(),n=1e3*parseInt(t.interval,10);console.log(M.Ay.bold("\nDevice Group Monitor")),console.log(M.Ay.gray(`Polling every ${t.interval}s. Press Ctrl+C to stop.\n`));var r=function(){var t=O(function*(){try{var t=yield Promise.all([a.deviceGroup({id:e}),a.devicesByGroup({id:e})]),n=X(t,2),r=n[0],i=n[1];if(process.stdout.write(""),console.log(M.Ay.bold(`Device Group: ${r.name}`)+M.Ay.gray(` - ${(new Date).toLocaleTimeString()}`)),console.log("─".repeat(80)),!i||0===i.length)return void console.log(M.Ay.yellow("No devices in this group"));var o=0,s=0;i.forEach(function(e){var t,a,n=null==(t=e.entry_detail)||null==(t=t.watch_dog_timer)?void 0:t.last_alive_time,r=ce(n),i=e.name||e.device_name||e.device_target_name,p=(null==(a=e.entry_detail)||null==(a=a.application)?void 0:a.name)||M.Ay.gray("No app");n&&Date.now()-new Date(n).getTime()<=ue?o++:s++,console.log(`${r} ${M.Ay.cyan(i.padEnd(30))} ${p}`)}),console.log("─".repeat(80)),console.log(`Online: ${M.Ay.green(o)} Offline: ${M.Ay.red(s)}`),console.log(`\n${M.Ay.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(M.Ay.red(`Error: ${e.message}`))}});return function(){return t.apply(this,arguments)}}();yield r(),setInterval(r,n)});return function(t,a){return e.apply(this,arguments)}}());var fe=c(147),_e=function(){var e=(0,V.getCurrentProfile)(),t=(0,V.getToken)(e);return t||(console.error(M.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,$.createClient)((0,V.getBaseUrl)(),t)},he=function(){var e=O(function*(e){var t=yield e.workspace();if(!(0,J.wR)(t))throw new Error("Media workspace not enabled for this workspace")});return function(t){return e.apply(this,arguments)}}(),Ee=new P("media").description("Media Flow support");Ee.command("boxes").description("List Media Flow boxes").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e){var t=_e(),a=(0,G.default)("Fetching media boxes...").start();try{yield he(t);var n=yield t.mediaBoxes();if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(M.Ay.yellow("No media boxes found"));console.log(M.Ay.bold("\nMedia Boxes")),console.log("─".repeat(80)),n.forEach(function(e){var t;console.log(`${M.Ay.cyan(e.name||"Unnamed")} ${M.Ay.gray(e.id)}`),e.description&&console.log(` ${e.description}`),null!=(t=e.tags)&&t.length&&console.log(` Tags: ${e.tags.join(", ")}`),null!=e.size&&console.log(` Size: ${e.size}`),console.log()})}catch(e){a.fail(`Failed to list media boxes: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Ee.command("box <id>").description("Get Media Flow box details").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=_e(),n=(0,G.default)("Fetching media box...").start();try{var r,i;yield he(a);var o=yield a.mediaBox({id:e});if(n.stop(),o||(console.log(M.Ay.red("Media box not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(o,null,2));console.log(M.Ay.bold(`\nMedia Box: ${o.name||"Unnamed"}`)),console.log("─".repeat(60)),console.log(`ID: ${M.Ay.gray(o.id)}`),console.log(`Description: ${o.description||M.Ay.gray("N/A")}`),console.log(`Tags: ${(null==(r=o.tags)?void 0:r.join(", "))||M.Ay.gray("None")}`),null!=o.size&&console.log(`Size: ${o.size}`),null!=(i=o.passcodes)&&i.length&&(console.log(`\n${M.Ay.bold("Passcodes")}`),o.passcodes.forEach(function(e){console.log(`- ${e.name||"Passcode"}: ${e.code}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get media box: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ee.command("files <boxId>").description("List Media Flow files in a box").option("-t, --types <types>","Comma-separated file types to include").option("-u, --user-tag <tag>","Filter by user tag (repeatable)",function(e,t){return[].concat(fe(t),[e])},[]).option("-l, --limit <limit>","Limit results",function(e){return Number.parseInt(e,10)}).option("-o, --offset <offset>","Offset results",function(e){return Number.parseInt(e,10)}).option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=_e(),n=(0,G.default)("Fetching media files...").start();try{var r;yield he(a);var i=t.types?t.types.split(",").map(function(e){return e.trim()}).filter(Boolean):void 0,o=null!=(r=t.userTag)&&r.length?t.userTag:void 0,s=yield a.mediaFiles({boxId:e,includeTypes:i,userTags:o,limit:t.limit,offset:t.offset});if(n.stop(),t.json)return void console.log(JSON.stringify(s,null,2));if(!s||0===s.length)return void console.log(M.Ay.yellow("No media files found"));console.log(M.Ay.bold(`\nMedia Files (${s.length})`)),console.log("─".repeat(100)),s.forEach(function(e){var t;console.log(`${M.Ay.cyan(e.name||"Unnamed")} ${M.Ay.gray(e.id)}`),console.log(` Type: ${e.fileType}`),null!=(t=e.userTags)&&t.length&&console.log(` Tags: ${e.userTags.join(", ")}`),e.updatedAt&&console.log(` Updated: ${new Date(e.updatedAt).toLocaleString()}`),console.log()})}catch(e){n.fail(`Failed to list media files: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ee.command("file <id>").description("Get Media Flow file details").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=_e(),n=(0,G.default)("Fetching media file...").start();try{var r,i;yield he(a);var o=yield a.mediaFile({id:e});if(n.stop(),o||(console.log(M.Ay.red("Media file not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(o,null,2));console.log(M.Ay.bold(`\nMedia File: ${o.name||"Unnamed"}`)),console.log("─".repeat(60)),console.log(`ID: ${M.Ay.gray(o.id)}`),console.log(`Box ID: ${M.Ay.gray(o.boxId)}`),console.log(`Type: ${o.fileType}`),console.log(`Description: ${o.description||M.Ay.gray("N/A")}`),console.log(`Tags: ${(null==(r=o.userTags)?void 0:r.join(", "))||M.Ay.gray("None")}`),console.log(`Created: ${M.Ay.gray(o.createdAt||"N/A")}`),console.log(`Updated: ${M.Ay.gray(o.updatedAt||"N/A")}`);var s=(0,J.Gu)(o),p=(0,J.Gu)(o,{preferThumbnail:!0});null!=(i=o.meta)&&i.originalFileKey&&console.log(`Original Key: ${M.Ay.gray(o.meta.originalFileKey)}`),s&&console.log(`Original URL: ${M.Ay.gray(s)}`),p&&p!==s&&console.log(`Thumbnail URL: ${M.Ay.gray(p)}`),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get media file: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}());var ye,Te,Re={prod:"https://display.bricks.tools",beta:"https://display-beta.bricks.tools",dev:"http://localhost:3001"},ge=function(e){var t=Object.entries(Re).find(function(t){var a=X(t,2)[1];return e===a});return t?t[0]:null},ve=new P("config").description("CLI configuration management");ve.command("endpoint").argument("[environment]","Environment to use (prod, beta, dev)").description("Show or set the API endpoint environment").action(function(e){var t=(0,V.getBaseUrl)(),a=ge(t);if(!e)return console.log(M.Ay.bold("\nAPI Endpoint Configuration")),console.log("─".repeat(50)),console.log(`Current URL: ${M.Ay.cyan(t)}`),a?console.log(`Environment: ${M.Ay.green(a)}`):console.log(`Environment: ${M.Ay.yellow("custom")}`),console.log("─".repeat(50)),console.log(M.Ay.gray("\nAvailable environments:")),Object.entries(Re).forEach(function(e){var a=X(e,2),n=a[0],r=a[1],i=t===r?M.Ay.green("● "):" ",o=t===r?M.Ay.green(n):n;console.log(`${i}${o.padEnd(8)} ${M.Ay.gray(r)}`)}),console.log(""),void console.log(M.Ay.gray("Usage: bricks config endpoint <prod|beta|dev>"));var n=Object.keys(Re);n.includes(e)||(console.error(M.Ay.red(`Invalid environment: ${e}`)),console.log(M.Ay.gray(`Valid options: ${n.join(", ")}`)),process.exit(1));var r=Re[e];t!==r?((0,V.setBaseUrl)(r),console.log(M.Ay.green(`✓ Endpoint changed to ${e}: ${r}`)),console.log(M.Ay.yellow("\nNote: You may need to re-authenticate if your token is for a different environment.")),console.log(M.Ay.gray("Use `bricks auth status` to check your connection."))):console.log(M.Ay.yellow(`Already using ${e} environment: ${r}`))}),ve.command("show").description("Show current configuration").option("-j, --json","Output as JSON").action(function(e){var t=(0,V.getBaseUrl)(),a=ge(t);e.json?console.log(JSON.stringify({endpoint:t,environment:a||"custom"},null,2)):(console.log(M.Ay.bold("\nBRICKS CLI Configuration")),console.log("─".repeat(50)),console.log(`API Endpoint: ${M.Ay.cyan(t)}`),a?console.log(`Environment: ${M.Ay.green(a)}`):console.log(`Environment: ${M.Ay.yellow("custom")}`),console.log("─".repeat(50)))}),function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const a of e)t[a]=a;return t},e.getValidEnumValues=t=>{const a=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),n={};for(const e of a)n[e]=t[e];return e.objectValues(n)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.push(a);return t},e.find=(e,t)=>{for(const a of e)if(t(a))return a},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(ye||(ye={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(Te||(Te={}));const Oe=ye.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ne=e=>{switch(typeof e){case"undefined":return Oe.undefined;case"string":return Oe.string;case"number":return Number.isNaN(e)?Oe.nan:Oe.number;case"boolean":return Oe.boolean;case"function":return Oe.function;case"bigint":return Oe.bigint;case"symbol":return Oe.symbol;case"object":return Array.isArray(e)?Oe.array:null===e?Oe.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?Oe.promise:"undefined"!=typeof Map&&e instanceof Map?Oe.map:"undefined"!=typeof Set&&e instanceof Set?Oe.set:"undefined"!=typeof Date&&e instanceof Date?Oe.date:Oe.object;default:return Oe.unknown}},be=ye.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"]);class Ae extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},a={_errors:[]},n=e=>{for(const r of e.issues)if("invalid_union"===r.code)r.unionErrors.map(n);else if("invalid_return_type"===r.code)n(r.returnTypeError);else if("invalid_arguments"===r.code)n(r.argumentsError);else if(0===r.path.length)a._errors.push(t(r));else{let e=a,n=0;for(;n<r.path.length;){const a=r.path[n];n===r.path.length-1?(e[a]=e[a]||{_errors:[]},e[a]._errors.push(t(r))):e[a]=e[a]||{_errors:[]},e=e[a],n++}}};return n(this),a}static assert(e){if(!(e instanceof Ae))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ye.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},a=[];for(const n of this.issues)if(n.path.length>0){const a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else a.push(e(n));return{formErrors:a,fieldErrors:t}}get formErrors(){return this.flatten()}}Ae.create=e=>new Ae(e);const Se=(e,t)=>{let a;switch(e.code){case be.invalid_type:a=e.received===Oe.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case be.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(e.expected,ye.jsonStringifyReplacer)}`;break;case be.unrecognized_keys:a=`Unrecognized key(s) in object: ${ye.joinValues(e.keys,", ")}`;break;case be.invalid_union:a="Invalid input";break;case be.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${ye.joinValues(e.options)}`;break;case be.invalid_enum_value:a=`Invalid enum value. Expected ${ye.joinValues(e.options)}, received '${e.received}'`;break;case be.invalid_arguments:a="Invalid function arguments";break;case be.invalid_return_type:a="Invalid function return type";break;case be.invalid_date:a="Invalid date";break;case be.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(a=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(a=`${a} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?a=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?a=`Invalid input: must end with "${e.validation.endsWith}"`:ye.assertNever(e.validation):a="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case be.too_small:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case be.too_big:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case be.custom:a="Invalid input";break;case be.invalid_intersection_types:a="Intersection results could not be merged";break;case be.not_multiple_of:a=`Number must be a multiple of ${e.multipleOf}`;break;case be.not_finite:a="Number must be finite";break;default:a=t.defaultError,ye.assertNever(e)}return{message:a}};let Ie=Se;function we(){return Ie}var Ce;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(Ce||(Ce={}));const De=e=>{const{data:t,path:a,errorMaps:n,issueData:r}=e,i=[...a,...r.path||[]],o={...r,path:i};if(void 0!==r.message)return{...r,path:i,message:r.message};let s="";const p=n.filter(e=>!!e).slice().reverse();for(const e of p)s=e(o,{data:t,defaultError:s}).message;return{...r,path:i,message:s}};function Pe(e,t){const a=we(),n=De({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,a,a===Se?void 0:Se].filter(e=>!!e)});e.common.issues.push(n)}class je{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const a=[];for(const n of t){if("aborted"===n.status)return ke;"dirty"===n.status&&e.dirty(),a.push(n.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,t){const a=[];for(const e of t){const t=await e.key,n=await e.value;a.push({key:t,value:n})}return je.mergeObjectSync(e,a)}static mergeObjectSync(e,t){const a={};for(const n of t){const{key:t,value:r}=n;if("aborted"===t.status)return ke;if("aborted"===r.status)return ke;"dirty"===t.status&&e.dirty(),"dirty"===r.status&&e.dirty(),"__proto__"===t.value||void 0===r.value&&!n.alwaysSet||(a[t.value]=r.value)}return{status:e.value,value:a}}}const ke=Object.freeze({status:"aborted"}),Le=e=>({status:"dirty",value:e}),Me=e=>({status:"valid",value:e}),Ge=e=>"aborted"===e.status,xe=e=>"dirty"===e.status,Fe=e=>"valid"===e.status,Be=e=>"undefined"!=typeof Promise&&e instanceof Promise;class ze{constructor(e,t,a,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=a,this._key=n}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}}const Ve=(e,t)=>{if(Fe(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;const t=new Ae(e.common.issues);return this._error=t,this._error}}};function $e(e){if(!e)return{};const{errorMap:t,invalid_type_error:a,required_error:n,description:r}=e;if(t&&(a||n))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:r};return{errorMap:(t,r)=>{const{message:i}=e;return"invalid_enum_value"===t.code?{message:i??r.defaultError}:void 0===r.data?{message:i??n??r.defaultError}:"invalid_type"!==t.code?{message:r.defaultError}:{message:i??a??r.defaultError}},description:r}}class Ue{get description(){return this._def.description}_getType(e){return Ne(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ne(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new je,ctx:{common:e.parent.common,data:e.data,parsedType:Ne(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Be(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const a=this.safeParse(e,t);if(a.success)return a.data;throw a.error}safeParse(e,t){const a={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ne(e)},n=this._parseSync({data:e,path:a.path,parent:a});return Ve(a,n)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ne(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:t});return Fe(a)?{value:a.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>Fe(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){const a=await this.safeParseAsync(e,t);if(a.success)return a.data;throw a.error}async safeParseAsync(e,t){const a={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ne(e)},n=this._parse({data:e,path:a.path,parent:a}),r=await(Be(n)?n:Promise.resolve(n));return Ve(a,r)}refine(e,t){const a=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,n)=>{const r=e(t),i=()=>n.addIssue({code:be.custom,...a(t)});return"undefined"!=typeof Promise&&r instanceof Promise?r.then(e=>!!e||(i(),!1)):!!r||(i(),!1)})}refinement(e,t){return this._refinement((a,n)=>!!e(a)||(n.addIssue("function"==typeof t?t(a,n):t),!1))}_refinement(e){return new Vt({schema:this,typeName:Xt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,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:e=>this["~validate"](e)}}optional(){return $t.create(this,this._def)}nullable(){return Ut.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return St.create(this)}promise(){return zt.create(this,this._def)}or(e){return Ct.create([this,e],this._def)}and(e){return Pt.create(this,e,this._def)}transform(e){return new Vt({...$e(this._def),schema:this,typeName:Xt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Ht({...$e(this._def),innerType:this,defaultValue:t,typeName:Xt.ZodDefault})}brand(){return new Wt({typeName:Xt.ZodBranded,type:this,...$e(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Kt({...$e(this._def),innerType:this,catchValue:t,typeName:Xt.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Qt.create(this,e)}readonly(){return Yt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const He=/^c[^\s-]{8,}$/i,Ke=/^[0-9a-z]+$/,qe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,We=/^[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,Qe=/^[a-z0-9_-]{21}$/i,Ye=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Xe=/^[-+]?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)?)??$/,Je=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let Ze;const et=/^(?:(?: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])$/,tt=/^(?:(?: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])$/,at=/^(([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]))$/,nt=/^(([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])$/,rt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,it=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ot="((\\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])))",st=new RegExp(`^${ot}$`);function pt(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function lt(e){return new RegExp(`^${pt(e)}$`)}function dt(e){let t=`${ot}T${pt(e)}`;const a=[];return a.push(e.local?"Z?":"Z"),e.offset&&a.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${a.join("|")})`,new RegExp(`^${t}$`)}function ut(e,t){return!("v4"!==t&&t||!et.test(e))||!("v6"!==t&&t||!at.test(e))}function ct(e,t){if(!Ye.test(e))return!1;try{const[a]=e.split(".");if(!a)return!1;const n=a.replace(/-/g,"+").replace(/_/g,"/").padEnd(a.length+(4-a.length%4)%4,"="),r=JSON.parse(atob(n));return"object"==typeof r&&null!==r&&((!("typ"in r)||"JWT"===r?.typ)&&(!!r.alg&&(!t||r.alg===t)))}catch{return!1}}function mt(e,t){return!("v4"!==t&&t||!tt.test(e))||!("v6"!==t&&t||!nt.test(e))}class ft extends Ue{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==Oe.string){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.string,received:t.parsedType}),ke}const t=new je;let a;for(const n of this._def.checks)if("min"===n.kind)e.data.length<n.value&&(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if("max"===n.kind)e.data.length>n.value&&(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if("length"===n.kind){const r=e.data.length>n.value,i=e.data.length<n.value;(r||i)&&(a=this._getOrReturnCtx(e,a),r?Pe(a,{code:be.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):i&&Pe(a,{code:be.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if("email"===n.kind)Je.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"email",code:be.invalid_string,message:n.message}),t.dirty());else if("emoji"===n.kind)Ze||(Ze=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ze.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"emoji",code:be.invalid_string,message:n.message}),t.dirty());else if("uuid"===n.kind)We.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"uuid",code:be.invalid_string,message:n.message}),t.dirty());else if("nanoid"===n.kind)Qe.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"nanoid",code:be.invalid_string,message:n.message}),t.dirty());else if("cuid"===n.kind)He.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"cuid",code:be.invalid_string,message:n.message}),t.dirty());else if("cuid2"===n.kind)Ke.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"cuid2",code:be.invalid_string,message:n.message}),t.dirty());else if("ulid"===n.kind)qe.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"ulid",code:be.invalid_string,message:n.message}),t.dirty());else if("url"===n.kind)try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),Pe(a,{validation:"url",code:be.invalid_string,message:n.message}),t.dirty()}else if("regex"===n.kind){n.regex.lastIndex=0;n.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"regex",code:be.invalid_string,message:n.message}),t.dirty())}else if("trim"===n.kind)e.data=e.data.trim();else if("includes"===n.kind)e.data.includes(n.value,n.position)||(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty());else if("toLowerCase"===n.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===n.kind)e.data=e.data.toUpperCase();else if("startsWith"===n.kind)e.data.startsWith(n.value)||(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty());else if("endsWith"===n.kind)e.data.endsWith(n.value)||(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty());else if("datetime"===n.kind){dt(n).test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.invalid_string,validation:"datetime",message:n.message}),t.dirty())}else if("date"===n.kind){st.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.invalid_string,validation:"date",message:n.message}),t.dirty())}else if("time"===n.kind){lt(n).test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.invalid_string,validation:"time",message:n.message}),t.dirty())}else"duration"===n.kind?Xe.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"duration",code:be.invalid_string,message:n.message}),t.dirty()):"ip"===n.kind?ut(e.data,n.version)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"ip",code:be.invalid_string,message:n.message}),t.dirty()):"jwt"===n.kind?ct(e.data,n.alg)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"jwt",code:be.invalid_string,message:n.message}),t.dirty()):"cidr"===n.kind?mt(e.data,n.version)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"cidr",code:be.invalid_string,message:n.message}),t.dirty()):"base64"===n.kind?rt.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"base64",code:be.invalid_string,message:n.message}),t.dirty()):"base64url"===n.kind?it.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"base64url",code:be.invalid_string,message:n.message}),t.dirty()):ye.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,a){return this.refinement(t=>e.test(t),{validation:t,code:be.invalid_string,...Ce.errToObj(a)})}_addCheck(e){return new ft({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ce.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ce.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ce.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ce.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ce.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ce.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ce.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ce.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ce.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Ce.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Ce.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ce.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Ce.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Ce.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...Ce.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Ce.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ce.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...Ce.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ce.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ce.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ce.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ce.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ce.errToObj(t)})}nonempty(e){return this.min(1,Ce.errToObj(e))}trim(){return new ft({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ft({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ft({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function _t(e,t){const a=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,r=a>n?a:n;return Number.parseInt(e.toFixed(r).replace(".",""))%Number.parseInt(t.toFixed(r).replace(".",""))/10**r}ft.create=e=>new ft({checks:[],typeName:Xt.ZodString,coerce:e?.coerce??!1,...$e(e)});class ht extends Ue{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==Oe.number){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.number,received:t.parsedType}),ke}let t;const a=new je;for(const n of this._def.checks)if("int"===n.kind)ye.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.invalid_type,expected:"integer",received:"float",message:n.message}),a.dirty());else if("min"===n.kind){(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty())}else if("max"===n.kind){(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty())}else"multipleOf"===n.kind?0!==_t(e.data,n.value)&&(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.not_finite,message:n.message}),a.dirty()):ye.assertNever(n);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ce.toString(t))}setLimit(e,t,a,n){return new ht({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Ce.toString(n)}]})}_addCheck(e){return new ht({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ce.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ce.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ce.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ce.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ce.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ce.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ce.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ce.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ce.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&ye.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const a of this._def.checks){if("finite"===a.kind||"int"===a.kind||"multipleOf"===a.kind)return!0;"min"===a.kind?(null===t||a.value>t)&&(t=a.value):"max"===a.kind&&(null===e||a.value<e)&&(e=a.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ht.create=e=>new ht({checks:[],typeName:Xt.ZodNumber,coerce:e?.coerce||!1,...$e(e)});class Et extends Ue{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Oe.bigint)return this._getInvalidInput(e);let t;const a=new je;for(const n of this._def.checks)if("min"===n.kind){(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty())}else if("max"===n.kind){(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty())}else"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):ye.assertNever(n);return{status:a.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.bigint,received:t.parsedType}),ke}gte(e,t){return this.setLimit("min",e,!0,Ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ce.toString(t))}setLimit(e,t,a,n){return new Et({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Ce.toString(n)}]})}_addCheck(e){return new Et({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ce.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ce.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ce.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ce.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ce.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}Et.create=e=>new Et({checks:[],typeName:Xt.ZodBigInt,coerce:e?.coerce??!1,...$e(e)});class yt extends Ue{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==Oe.boolean){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.boolean,received:t.parsedType}),ke}return Me(e.data)}}yt.create=e=>new yt({typeName:Xt.ZodBoolean,coerce:e?.coerce||!1,...$e(e)});class Tt extends Ue{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==Oe.date){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.date,received:t.parsedType}),ke}if(Number.isNaN(e.data.getTime())){return Pe(this._getOrReturnCtx(e),{code:be.invalid_date}),ke}const t=new je;let a;for(const n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):ye.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Tt({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ce.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ce.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}Tt.create=e=>new Tt({checks:[],coerce:e?.coerce||!1,typeName:Xt.ZodDate,...$e(e)});class Rt extends Ue{_parse(e){if(this._getType(e)!==Oe.symbol){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.symbol,received:t.parsedType}),ke}return Me(e.data)}}Rt.create=e=>new Rt({typeName:Xt.ZodSymbol,...$e(e)});class gt extends Ue{_parse(e){if(this._getType(e)!==Oe.undefined){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.undefined,received:t.parsedType}),ke}return Me(e.data)}}gt.create=e=>new gt({typeName:Xt.ZodUndefined,...$e(e)});class vt extends Ue{_parse(e){if(this._getType(e)!==Oe.null){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.null,received:t.parsedType}),ke}return Me(e.data)}}vt.create=e=>new vt({typeName:Xt.ZodNull,...$e(e)});class Ot extends Ue{constructor(){super(...arguments),this._any=!0}_parse(e){return Me(e.data)}}Ot.create=e=>new Ot({typeName:Xt.ZodAny,...$e(e)});class Nt extends Ue{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Me(e.data)}}Nt.create=e=>new Nt({typeName:Xt.ZodUnknown,...$e(e)});class bt extends Ue{_parse(e){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.never,received:t.parsedType}),ke}}bt.create=e=>new bt({typeName:Xt.ZodNever,...$e(e)});class At extends Ue{_parse(e){if(this._getType(e)!==Oe.undefined){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.void,received:t.parsedType}),ke}return Me(e.data)}}At.create=e=>new At({typeName:Xt.ZodVoid,...$e(e)});class St extends Ue{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),n=this._def;if(t.parsedType!==Oe.array)return Pe(t,{code:be.invalid_type,expected:Oe.array,received:t.parsedType}),ke;if(null!==n.exactLength){const e=t.data.length>n.exactLength.value,r=t.data.length<n.exactLength.value;(e||r)&&(Pe(t,{code:e?be.too_big:be.too_small,minimum:r?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),a.dirty())}if(null!==n.minLength&&t.data.length<n.minLength.value&&(Pe(t,{code:be.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),a.dirty()),null!==n.maxLength&&t.data.length>n.maxLength.value&&(Pe(t,{code:be.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((e,a)=>n.type._parseAsync(new ze(t,e,t.path,a)))).then(e=>je.mergeArray(a,e));const r=[...t.data].map((e,a)=>n.type._parseSync(new ze(t,e,t.path,a)));return je.mergeArray(a,r)}get element(){return this._def.type}min(e,t){return new St({...this._def,minLength:{value:e,message:Ce.toString(t)}})}max(e,t){return new St({...this._def,maxLength:{value:e,message:Ce.toString(t)}})}length(e,t){return new St({...this._def,exactLength:{value:e,message:Ce.toString(t)}})}nonempty(e){return this.min(1,e)}}function It(e){if(e instanceof wt){const t={};for(const a in e.shape){const n=e.shape[a];t[a]=$t.create(It(n))}return new wt({...e._def,shape:()=>t})}return e instanceof St?new St({...e._def,type:It(e.element)}):e instanceof $t?$t.create(It(e.unwrap())):e instanceof Ut?Ut.create(It(e.unwrap())):e instanceof jt?jt.create(e.items.map(e=>It(e))):e}St.create=(e,t)=>new St({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Xt.ZodArray,...$e(t)});class wt extends Ue{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=ye.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==Oe.object){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.object,received:t.parsedType}),ke}const{status:t,ctx:a}=this._processInputParams(e),{shape:n,keys:r}=this._getCached(),i=[];if(!(this._def.catchall instanceof bt&&"strip"===this._def.unknownKeys))for(const e in a.data)r.includes(e)||i.push(e);const o=[];for(const e of r){const t=n[e],r=a.data[e];o.push({key:{status:"valid",value:e},value:t._parse(new ze(a,r,a.path,e)),alwaysSet:e in a.data})}if(this._def.catchall instanceof bt){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of i)o.push({key:{status:"valid",value:e},value:{status:"valid",value:a.data[e]}});else if("strict"===e)i.length>0&&(Pe(a,{code:be.unrecognized_keys,keys:i}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of i){const n=a.data[t];o.push({key:{status:"valid",value:t},value:e._parse(new ze(a,n,a.path,t)),alwaysSet:t in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of o){const a=await t.key,n=await t.value;e.push({key:a,value:n,alwaysSet:t.alwaysSet})}return e}).then(e=>je.mergeObjectSync(t,e)):je.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return Ce.errToObj,new wt({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,a)=>{const n=this._def.errorMap?.(t,a).message??a.defaultError;return"unrecognized_keys"===t.code?{message:Ce.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new wt({...this._def,unknownKeys:"strip"})}passthrough(){return new wt({...this._def,unknownKeys:"passthrough"})}extend(e){return new wt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new wt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Xt.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new wt({...this._def,catchall:e})}pick(e){const t={};for(const a of ye.objectKeys(e))e[a]&&this.shape[a]&&(t[a]=this.shape[a]);return new wt({...this._def,shape:()=>t})}omit(e){const t={};for(const a of ye.objectKeys(this.shape))e[a]||(t[a]=this.shape[a]);return new wt({...this._def,shape:()=>t})}deepPartial(){return It(this)}partial(e){const t={};for(const a of ye.objectKeys(this.shape)){const n=this.shape[a];e&&!e[a]?t[a]=n:t[a]=n.optional()}return new wt({...this._def,shape:()=>t})}required(e){const t={};for(const a of ye.objectKeys(this.shape))if(e&&!e[a])t[a]=this.shape[a];else{let e=this.shape[a];for(;e instanceof $t;)e=e._def.innerType;t[a]=e}return new wt({...this._def,shape:()=>t})}keyof(){return xt(ye.objectKeys(this.shape))}}wt.create=(e,t)=>new wt({shape:()=>e,unknownKeys:"strip",catchall:bt.create(),typeName:Xt.ZodObject,...$e(t)}),wt.strictCreate=(e,t)=>new wt({shape:()=>e,unknownKeys:"strict",catchall:bt.create(),typeName:Xt.ZodObject,...$e(t)}),wt.lazycreate=(e,t)=>new wt({shape:e,unknownKeys:"strip",catchall:bt.create(),typeName:Xt.ZodObject,...$e(t)});class Ct extends Ue{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.options;if(t.common.async)return Promise.all(a.map(async e=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const a of e)if("dirty"===a.result.status)return t.common.issues.push(...a.ctx.common.issues),a.result;const a=e.map(e=>new Ae(e.ctx.common.issues));return Pe(t,{code:be.invalid_union,unionErrors:a}),ke});{let e;const n=[];for(const r of a){const a={...t,common:{...t.common,issues:[]},parent:null},i=r._parseSync({data:t.data,path:t.path,parent:a});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:a}),a.common.issues.length&&n.push(a.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const r=n.map(e=>new Ae(e));return Pe(t,{code:be.invalid_union,unionErrors:r}),ke}}get options(){return this._def.options}}Ct.create=(e,t)=>new Ct({options:e,typeName:Xt.ZodUnion,...$e(t)});function Dt(e,t){const a=Ne(e),n=Ne(t);if(e===t)return{valid:!0,data:e};if(a===Oe.object&&n===Oe.object){const a=ye.objectKeys(t),n=ye.objectKeys(e).filter(e=>-1!==a.indexOf(e)),r={...e,...t};for(const a of n){const n=Dt(e[a],t[a]);if(!n.valid)return{valid:!1};r[a]=n.data}return{valid:!0,data:r}}if(a===Oe.array&&n===Oe.array){if(e.length!==t.length)return{valid:!1};const a=[];for(let n=0;n<e.length;n++){const r=Dt(e[n],t[n]);if(!r.valid)return{valid:!1};a.push(r.data)}return{valid:!0,data:a}}return a===Oe.date&&n===Oe.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}class Pt extends Ue{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),n=(e,n)=>{if(Ge(e)||Ge(n))return ke;const r=Dt(e.value,n.value);return r.valid?((xe(e)||xe(n))&&t.dirty(),{status:t.value,value:r.data}):(Pe(a,{code:be.invalid_intersection_types}),ke)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([e,t])=>n(e,t)):n(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}Pt.create=(e,t,a)=>new Pt({left:e,right:t,typeName:Xt.ZodIntersection,...$e(a)});class jt extends Ue{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==Oe.array)return Pe(a,{code:be.invalid_type,expected:Oe.array,received:a.parsedType}),ke;if(a.data.length<this._def.items.length)return Pe(a,{code:be.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ke;!this._def.rest&&a.data.length>this._def.items.length&&(Pe(a,{code:be.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...a.data].map((e,t)=>{const n=this._def.items[t]||this._def.rest;return n?n._parse(new ze(a,e,a.path,t)):null}).filter(e=>!!e);return a.common.async?Promise.all(n).then(e=>je.mergeArray(t,e)):je.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new jt({...this._def,rest:e})}}jt.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new jt({items:e,typeName:Xt.ZodTuple,rest:null,...$e(t)})};class kt extends Ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==Oe.map)return Pe(a,{code:be.invalid_type,expected:Oe.map,received:a.parsedType}),ke;const n=this._def.keyType,r=this._def.valueType,i=[...a.data.entries()].map(([e,t],i)=>({key:n._parse(new ze(a,e,a.path,[i,"key"])),value:r._parse(new ze(a,t,a.path,[i,"value"]))}));if(a.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const a of i){const n=await a.key,r=await a.value;if("aborted"===n.status||"aborted"===r.status)return ke;"dirty"!==n.status&&"dirty"!==r.status||t.dirty(),e.set(n.value,r.value)}return{status:t.value,value:e}})}{const e=new Map;for(const a of i){const n=a.key,r=a.value;if("aborted"===n.status||"aborted"===r.status)return ke;"dirty"!==n.status&&"dirty"!==r.status||t.dirty(),e.set(n.value,r.value)}return{status:t.value,value:e}}}}kt.create=(e,t,a)=>new kt({valueType:t,keyType:e,typeName:Xt.ZodMap,...$e(a)});class Lt extends Ue{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==Oe.set)return Pe(a,{code:be.invalid_type,expected:Oe.set,received:a.parsedType}),ke;const n=this._def;null!==n.minSize&&a.data.size<n.minSize.value&&(Pe(a,{code:be.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),null!==n.maxSize&&a.data.size>n.maxSize.value&&(Pe(a,{code:be.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const r=this._def.valueType;function i(e){const a=new Set;for(const n of e){if("aborted"===n.status)return ke;"dirty"===n.status&&t.dirty(),a.add(n.value)}return{status:t.value,value:a}}const o=[...a.data.values()].map((e,t)=>r._parse(new ze(a,e,a.path,t)));return a.common.async?Promise.all(o).then(e=>i(e)):i(o)}min(e,t){return new Lt({...this._def,minSize:{value:e,message:Ce.toString(t)}})}max(e,t){return new Lt({...this._def,maxSize:{value:e,message:Ce.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Lt.create=(e,t)=>new Lt({valueType:e,minSize:null,maxSize:null,typeName:Xt.ZodSet,...$e(t)});class Mt extends Ue{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Mt.create=(e,t)=>new Mt({getter:e,typeName:Xt.ZodLazy,...$e(t)});class Gt extends Ue{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return Pe(t,{received:t.data,code:be.invalid_literal,expected:this._def.value}),ke}return{status:"valid",value:e.data}}get value(){return this._def.value}}function xt(e,t){return new Ft({values:e,typeName:Xt.ZodEnum,...$e(t)})}Gt.create=(e,t)=>new Gt({value:e,typeName:Xt.ZodLiteral,...$e(t)});class Ft extends Ue{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),a=this._def.values;return Pe(t,{expected:ye.joinValues(a),received:t.parsedType,code:be.invalid_type}),ke}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),a=this._def.values;return Pe(t,{received:t.data,code:be.invalid_enum_value,options:a}),ke}return Me(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Ft.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ft.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}Ft.create=xt;class Bt extends Ue{_parse(e){const t=ye.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==Oe.string&&a.parsedType!==Oe.number){const e=ye.objectValues(t);return Pe(a,{expected:ye.joinValues(e),received:a.parsedType,code:be.invalid_type}),ke}if(this._cache||(this._cache=new Set(ye.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=ye.objectValues(t);return Pe(a,{received:a.data,code:be.invalid_enum_value,options:e}),ke}return Me(e.data)}get enum(){return this._def.values}}Bt.create=(e,t)=>new Bt({values:e,typeName:Xt.ZodNativeEnum,...$e(t)});class zt extends Ue{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Oe.promise&&!1===t.common.async)return Pe(t,{code:be.invalid_type,expected:Oe.promise,received:t.parsedType}),ke;const a=t.parsedType===Oe.promise?t.data:Promise.resolve(t.data);return Me(a.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}zt.create=(e,t)=>new zt({type:e,typeName:Xt.ZodPromise,...$e(t)});class Vt extends Ue{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Xt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:a}=this._processInputParams(e),n=this._def.effect||null,r={addIssue:e=>{Pe(a,e),e.fatal?t.abort():t.dirty()},get path(){return a.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===n.type){const e=n.transform(a.data,r);if(a.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return ke;const n=await this._def.schema._parseAsync({data:e,path:a.path,parent:a});return"aborted"===n.status?ke:"dirty"===n.status||"dirty"===t.value?Le(n.value):n});{if("aborted"===t.value)return ke;const n=this._def.schema._parseSync({data:e,path:a.path,parent:a});return"aborted"===n.status?ke:"dirty"===n.status||"dirty"===t.value?Le(n.value):n}}if("refinement"===n.type){const e=e=>{const t=n.refinement(e,r);if(a.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===a.common.async){const n=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===n.status?ke:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(a=>"aborted"===a.status?ke:("dirty"===a.status&&t.dirty(),e(a.value).then(()=>({status:t.value,value:a.value}))))}if("transform"===n.type){if(!1===a.common.async){const e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Fe(e))return ke;const i=n.transform(e.value,r);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(e=>Fe(e)?Promise.resolve(n.transform(e.value,r)).then(e=>({status:t.value,value:e})):ke)}ye.assertNever(n)}}Vt.create=(e,t,a)=>new Vt({schema:e,typeName:Xt.ZodEffects,effect:t,...$e(a)}),Vt.createWithPreprocess=(e,t,a)=>new Vt({schema:t,effect:{type:"preprocess",transform:e},typeName:Xt.ZodEffects,...$e(a)});class $t extends Ue{_parse(e){return this._getType(e)===Oe.undefined?Me(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}$t.create=(e,t)=>new $t({innerType:e,typeName:Xt.ZodOptional,...$e(t)});class Ut extends Ue{_parse(e){return this._getType(e)===Oe.null?Me(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ut.create=(e,t)=>new Ut({innerType:e,typeName:Xt.ZodNullable,...$e(t)});class Ht extends Ue{_parse(e){const{ctx:t}=this._processInputParams(e);let a=t.data;return t.parsedType===Oe.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ht.create=(e,t)=>new Ht({innerType:e,typeName:Xt.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...$e(t)});class Kt extends Ue{_parse(e){const{ctx:t}=this._processInputParams(e),a={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return Be(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new Ae(a.common.issues)},input:a.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new Ae(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}Kt.create=(e,t)=>new Kt({innerType:e,typeName:Xt.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...$e(t)});class qt extends Ue{_parse(e){if(this._getType(e)!==Oe.nan){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.nan,received:t.parsedType}),ke}return{status:"valid",value:e.data}}}qt.create=e=>new qt({typeName:Xt.ZodNaN,...$e(e)});Symbol("zod_brand");class Wt extends Ue{_parse(e){const{ctx:t}=this._processInputParams(e),a=t.data;return this._def.type._parse({data:a,path:t.path,parent:t})}unwrap(){return this._def.type}}class Qt extends Ue{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?ke:"dirty"===e.status?(t.dirty(),Le(e.value)):this._def.out._parseAsync({data:e.value,path:a.path,parent:a})})()}{const e=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?ke:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:a.path,parent:a})}}static create(e,t){return new Qt({in:e,out:t,typeName:Xt.ZodPipeline})}}class Yt extends Ue{_parse(e){const t=this._def.innerType._parse(e),a=e=>(Fe(e)&&(e.value=Object.freeze(e.value)),e);return Be(t)?t.then(e=>a(e)):a(t)}unwrap(){return this._def.innerType}}Yt.create=(e,t)=>new Yt({innerType:e,typeName:Xt.ZodReadonly,...$e(t)});wt.lazycreate;var Xt;!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"}(Xt||(Xt={}));const Jt=ft.create,Zt=ht.create,ea=(qt.create,Et.create,yt.create,Tt.create,Rt.create,gt.create,vt.create,Ot.create,Nt.create,bt.create,At.create,St.create),ta=wt.create,aa=(wt.strictCreate,Ct.create,Pt.create,jt.create,kt.create,Lt.create,Mt.create,Gt.create,Ft.create);Bt.create,zt.create,Vt.create,$t.create,Ut.create,Vt.createWithPreprocess,Qt.create,Object.freeze({status:"aborted"});function na(e,t,a){function n(a,n){var r;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(r=a._zod).traits??(r.traits=new Set),a._zod.traits.add(e),t(a,n);for(const e in o.prototype)e in a||Object.defineProperty(a,e,{value:o.prototype[e].bind(a)});a._zod.constr=o,a._zod.def=n}const r=a?.Parent??Object;class i extends r{}function o(e){var t;const r=a?.Parent?new i:this;n(r,e),(t=r._zod).deferred??(t.deferred=[]);for(const e of r._zod.deferred)e();return r}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!(a?.Parent&&t instanceof a.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}Symbol("zod_brand");class ra extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const ia={};function oa(e){return e&&Object.assign(ia,e),ia}const sa=/^[cC][^\s-]{8,}$/,pa=/^[0-9a-z]+$/,la=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,da=/^[0-9a-vA-V]{20}$/,ua=/^[A-Za-z0-9]{27}$/,ca=/^[a-zA-Z0-9_-]{21}$/,ma=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,fa=/^([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})$/,_a=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)$/,ha=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const Ea=/^(?:(?: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])$/,ya=/^(([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})$/,Ta=/^((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])$/,Ra=/^(([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])$/,ga=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,va=/^[A-Za-z0-9_-]*$/,Oa=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Na=/^\+(?:[0-9]){6,14}[0-9]$/,ba="(?:(?:\\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])))",Aa=new RegExp(`^${ba}$`);function Sa(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const Ia=/^\d+$/,wa=/^-?\d+(?:\.\d+)?/i,Ca=/true|false/i,Da=/null/i,Pa=/^[^A-Z]*$/,ja=/^[^a-z]*$/;function ka(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,a])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function La(e,t){return"bigint"==typeof t?t.toString():t}function Ma(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ga(e){return null==e}function xa(e){const t=e.startsWith("^")?1:0,a=e.endsWith("$")?e.length-1:e.length;return e.slice(t,a)}function Fa(e,t,a){Object.defineProperty(e,t,{get(){{const n=a();return e[t]=n,n}},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function Ba(e,t,a){Object.defineProperty(e,t,{value:a,writable:!0,enumerable:!0,configurable:!0})}function za(e){return JSON.stringify(e)}const Va=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function $a(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const Ua=Ma(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Ha(e){if(!1===$a(e))return!1;const t=e.constructor;if(void 0===t)return!0;const a=t.prototype;return!1!==$a(a)&&!1!==Object.prototype.hasOwnProperty.call(a,"isPrototypeOf")}const Ka=new Set(["string","number","symbol"]);new Set(["string","number","bigint","boolean","symbol","undefined"]);function qa(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wa(e,t,a){const n=new e._zod.constr(t??e._zod.def);return t&&!a?.parent||(n._zod.parent=e),n}function Qa(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const Ya={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]};function Xa(e,t=0){for(let a=t;a<e.issues.length;a++)if(!0!==e.issues[a]?.continue)return!0;return!1}function Ja(e,t){return t.map(t=>{var a;return(a=t).path??(a.path=[]),t.path.unshift(e),t})}function Za(e){return"string"==typeof e?e:e?.message}function en(e,t,a){const n={...e,path:e.path??[]};if(!e.message){const r=Za(e.inst?._zod.def?.error?.(e))??Za(t?.error?.(e))??Za(a.customError?.(e))??Za(a.localeError?.(e))??"Invalid input";n.message=r}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function tn(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function an(...e){const[t,a,n]=e;return"string"==typeof t?{message:t,code:"custom",input:a,inst:n}:{...t}}const nn=na("$ZodCheck",(e,t)=>{var a;e._zod??(e._zod={}),e._zod.def=t,(a=e._zod).onattach??(a.onattach=[])}),rn={number:"number",bigint:"bigint",object:"date"},on=na("$ZodCheckLessThan",(e,t)=>{nn.init(e,t);const a=rn[typeof t.value];e._zod.onattach.push(e=>{const a=e._zod.bag,n=(t.inclusive?a.maximum:a.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<n&&(t.inclusive?a.maximum=t.value:a.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:a,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),sn=na("$ZodCheckGreaterThan",(e,t)=>{nn.init(e,t);const a=rn[typeof t.value];e._zod.onattach.push(e=>{const a=e._zod.bag,n=(t.inclusive?a.minimum:a.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>n&&(t.inclusive?a.minimum=t.value:a.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:a,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),pn=na("$ZodCheckMultipleOf",(e,t)=>{nn.init(e,t),e._zod.onattach.push(e=>{var a;(a=e._zod.bag).multipleOf??(a.multipleOf=t.value)}),e._zod.check=a=>{if(typeof a.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof a.value?a.value%t.value===BigInt(0):0===function(e,t){const a=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,r=a>n?a:n;return Number.parseInt(e.toFixed(r).replace(".",""))%Number.parseInt(t.toFixed(r).replace(".",""))/10**r}(a.value,t.value))||a.issues.push({origin:typeof a.value,code:"not_multiple_of",divisor:t.value,input:a.value,inst:e,continue:!t.abort})}}),ln=na("$ZodCheckNumberFormat",(e,t)=>{nn.init(e,t),t.format=t.format||"float64";const a=t.format?.includes("int"),n=a?"int":"number",[r,i]=Ya[t.format];e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,n.minimum=r,n.maximum=i,a&&(n.pattern=Ia)}),e._zod.check=o=>{const s=o.value;if(a){if(!Number.isInteger(s))return void o.issues.push({expected:n,format:t.format,code:"invalid_type",input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?o.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,continue:!t.abort}):o.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,continue:!t.abort}))}s<r&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),s>i&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inst:e})}}),dn=na("$ZodCheckMaxLength",(e,t)=>{var a;nn.init(e,t),(a=e._zod.def).when??(a.when=e=>{const t=e.value;return!Ga(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const a=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const n=a.value;if(n.length<=t.maximum)return;const r=tn(n);a.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),un=na("$ZodCheckMinLength",(e,t)=>{var a;nn.init(e,t),(a=e._zod.def).when??(a.when=e=>{const t=e.value;return!Ga(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const a=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const n=a.value;if(n.length>=t.minimum)return;const r=tn(n);a.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),cn=na("$ZodCheckLengthEquals",(e,t)=>{var a;nn.init(e,t),(a=e._zod.def).when??(a.when=e=>{const t=e.value;return!Ga(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const a=e._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=a=>{const n=a.value,r=n.length;if(r===t.length)return;const i=tn(n),o=r>t.length;a.issues.push({origin:i,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),mn=na("$ZodCheckStringFormat",(e,t)=>{var a,n;nn.init(e,t),e._zod.onattach.push(e=>{const a=e._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(a=e._zod).check??(a.check=a=>{t.pattern.lastIndex=0,t.pattern.test(a.value)||a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),fn=na("$ZodCheckRegex",(e,t)=>{mn.init(e,t),e._zod.check=a=>{t.pattern.lastIndex=0,t.pattern.test(a.value)||a.issues.push({origin:"string",code:"invalid_format",format:"regex",input:a.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),_n=na("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Pa),mn.init(e,t)}),hn=na("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ja),mn.init(e,t)}),En=na("$ZodCheckIncludes",(e,t)=>{nn.init(e,t);const a=qa(t.includes),n=new RegExp("number"==typeof t.position?`^.{${t.position}}${a}`:a);t.pattern=n,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),yn=na("$ZodCheckStartsWith",(e,t)=>{nn.init(e,t);const a=new RegExp(`^${qa(t.prefix)}.*`);t.pattern??(t.pattern=a),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(a)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),Tn=na("$ZodCheckEndsWith",(e,t)=>{nn.init(e,t);const a=new RegExp(`.*${qa(t.suffix)}$`);t.pattern??(t.pattern=a),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(a)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}});const Rn=na("$ZodCheckOverwrite",(e,t)=>{nn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class gn{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),a=Math.min(...t.map(e=>e.length-e.trimStart().length)),n=t.map(e=>e.slice(a)).map(e=>" ".repeat(2*this.indent)+e);for(const e of n)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const vn=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(t,La,2),enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},On=na("$ZodError",vn),Nn=na("$ZodError",vn,{Parent:Error});const bn=e=>(t,a,n,r)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},o=t._zod.run({value:a,issues:[]},i);if(o instanceof Promise)throw new ra;if(o.issues.length){const t=new(r?.Err??e)(o.issues.map(e=>en(e,i,oa())));throw Va(t,r?.callee),t}return o.value},An=bn(Nn),Sn=e=>async(t,a,n,r)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:a,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const t=new(r?.Err??e)(o.issues.map(e=>en(e,i,oa())));throw Va(t,r?.callee),t}return o.value},In=Sn(Nn),wn=e=>(t,a,n)=>{const r=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:a,issues:[]},r);if(i instanceof Promise)throw new ra;return i.issues.length?{success:!1,error:new(e??On)(i.issues.map(e=>en(e,r,oa())))}:{success:!0,data:i.value}},Cn=wn(Nn),Dn=e=>async(t,a,n)=>{const r=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:a,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(e=>en(e,r,oa())))}:{success:!0,data:i.value}},Pn=Dn(Nn),jn={major:4,minor:0,patch:0},kn=na("$ZodType",(e,t)=>{var a;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=jn;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const t of n)for(const a of t._zod.onattach)a(e);if(0===n.length)(a=e._zod).deferred??(a.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,a)=>{let n,r=Xa(e);for(const i of t){if(i._zod.def.when){if(!i._zod.def.when(e))continue}else if(r)continue;const t=e.issues.length,o=i._zod.check(e);if(o instanceof Promise&&!1===a?.async)throw new ra;if(n||o instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await o;e.issues.length!==t&&(r||(r=Xa(e,t)))});else{if(e.issues.length===t)continue;r||(r=Xa(e,t))}}return n?n.then(()=>e):e};e._zod.run=(a,r)=>{const i=e._zod.parse(a,r);if(i instanceof Promise){if(!1===r.async)throw new ra;return i.then(e=>t(e,n,r))}return t(i,n,r)}}e["~standard"]={validate:t=>{try{const a=Cn(e,t);return a.success?{value:a.data}:{issues:a.error?.issues}}catch(a){return Pn(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),Ln=na("$ZodString",(e,t)=>{var a;kn.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(a=e._zod.bag,new RegExp(`^${a?`[\\s\\S]{${a?.minimum??0},${a?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(a,n)=>{if(t.coerce)try{a.value=String(a.value)}catch(n){}return"string"==typeof a.value||a.issues.push({expected:"string",code:"invalid_type",input:a.value,inst:e}),a}}),Mn=na("$ZodStringFormat",(e,t)=>{mn.init(e,t),Ln.init(e,t)}),Gn=na("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=fa),Mn.init(e,t)}),xn=na("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=_a(e))}else t.pattern??(t.pattern=_a());Mn.init(e,t)}),Fn=na("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ha),Mn.init(e,t)}),Bn=na("$ZodURL",(e,t)=>{Mn.init(e,t),e._zod.check=a=>{try{const n=a.value,r=new URL(n),i=r.href;return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||a.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Oa.source,input:a.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||a.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:a.value,inst:e,continue:!t.abort})),void(!n.endsWith("/")&&i.endsWith("/")?a.value=i.slice(0,-1):a.value=i)}catch(n){a.issues.push({code:"invalid_format",format:"url",input:a.value,inst:e,continue:!t.abort})}}}),zn=na("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Mn.init(e,t)}),Vn=na("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ca),Mn.init(e,t)}),$n=na("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=sa),Mn.init(e,t)}),Un=na("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=pa),Mn.init(e,t)}),Hn=na("$ZodULID",(e,t)=>{t.pattern??(t.pattern=la),Mn.init(e,t)}),Kn=na("$ZodXID",(e,t)=>{t.pattern??(t.pattern=da),Mn.init(e,t)}),qn=na("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ua),Mn.init(e,t)}),Wn=na("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=Sa({precision:e.precision}),a=["Z"];e.local&&a.push(""),e.offset&&a.push("([+-]\\d{2}:\\d{2})");const n=`${t}(?:${a.join("|")})`;return new RegExp(`^${ba}T(?:${n})$`)}(t)),Mn.init(e,t)}),Qn=na("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Aa),Mn.init(e,t)}),Yn=na("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${Sa(t)}$`)),Mn.init(e,t)}),Xn=na("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ma),Mn.init(e,t)}),Jn=na("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ea),Mn.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv4"})}),Zn=na("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ya),Mn.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv6"}),e._zod.check=a=>{try{new URL(`http://[${a.value}]`)}catch{a.issues.push({code:"invalid_format",format:"ipv6",input:a.value,inst:e,continue:!t.abort})}}}),er=na("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ta),Mn.init(e,t)}),tr=na("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ra),Mn.init(e,t),e._zod.check=a=>{const[n,r]=a.value.split("/");try{if(!r)throw new Error;const e=Number(r);if(`${e}`!==r)throw new Error;if(e<0||e>128)throw new Error;new URL(`http://[${n}]`)}catch{a.issues.push({code:"invalid_format",format:"cidrv6",input:a.value,inst:e,continue:!t.abort})}}});function ar(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const nr=na("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ga),Mn.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64"}),e._zod.check=a=>{ar(a.value)||a.issues.push({code:"invalid_format",format:"base64",input:a.value,inst:e,continue:!t.abort})}});const rr=na("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=va),Mn.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64url"}),e._zod.check=a=>{(function(e){if(!va.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return ar(t.padEnd(4*Math.ceil(t.length/4),"="))})(a.value)||a.issues.push({code:"invalid_format",format:"base64url",input:a.value,inst:e,continue:!t.abort})}}),ir=na("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Na),Mn.init(e,t)});const or=na("$ZodJWT",(e,t)=>{Mn.init(e,t),e._zod.check=a=>{(function(e,t=null){try{const a=e.split(".");if(3!==a.length)return!1;const[n]=a;if(!n)return!1;const r=JSON.parse(atob(n));return!("typ"in r&&"JWT"!==r?.typ||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}})(a.value,t.alg)||a.issues.push({code:"invalid_format",format:"jwt",input:a.value,inst:e,continue:!t.abort})}}),sr=na("$ZodNumber",(e,t)=>{kn.init(e,t),e._zod.pattern=e._zod.bag.pattern??wa,e._zod.parse=(a,n)=>{if(t.coerce)try{a.value=Number(a.value)}catch(e){}const r=a.value;if("number"==typeof r&&!Number.isNaN(r)&&Number.isFinite(r))return a;const i="number"==typeof r?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return a.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),a}}),pr=na("$ZodNumber",(e,t)=>{ln.init(e,t),sr.init(e,t)}),lr=na("$ZodBoolean",(e,t)=>{kn.init(e,t),e._zod.pattern=Ca,e._zod.parse=(a,n)=>{if(t.coerce)try{a.value=Boolean(a.value)}catch(e){}const r=a.value;return"boolean"==typeof r||a.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),a}}),dr=na("$ZodNull",(e,t)=>{kn.init(e,t),e._zod.pattern=Da,e._zod.values=new Set([null]),e._zod.parse=(t,a)=>{const n=t.value;return null===n||t.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),t}}),ur=na("$ZodUnknown",(e,t)=>{kn.init(e,t),e._zod.parse=e=>e}),cr=na("$ZodNever",(e,t)=>{kn.init(e,t),e._zod.parse=(t,a)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function mr(e,t,a){e.issues.length&&t.issues.push(...Ja(a,e.issues)),t.value[a]=e.value}const fr=na("$ZodArray",(e,t)=>{kn.init(e,t),e._zod.parse=(a,n)=>{const r=a.value;if(!Array.isArray(r))return a.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),a;a.value=Array(r.length);const i=[];for(let e=0;e<r.length;e++){const o=r[e],s=t.element._zod.run({value:o,issues:[]},n);s instanceof Promise?i.push(s.then(t=>mr(t,a,e))):mr(s,a,e)}return i.length?Promise.all(i).then(()=>a):a}});function _r(e,t,a){e.issues.length&&t.issues.push(...Ja(a,e.issues)),t.value[a]=e.value}function hr(e,t,a,n){e.issues.length?void 0===n[a]?t.value[a]=a in n?void 0:e.value:t.issues.push(...Ja(a,e.issues)):void 0===e.value?a in n&&(t.value[a]=void 0):t.value[a]=e.value}const Er=na("$ZodObject",(e,t)=>{kn.init(e,t);const a=Ma(()=>{const e=Object.keys(t.shape);for(const a of e)if(!(t.shape[a]instanceof kn))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const a=(n=t.shape,Object.keys(n).filter(e=>"optional"===n[e]._zod.optin&&"optional"===n[e]._zod.optout));var n;return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(a)}});Fa(e._zod,"propValues",()=>{const e=t.shape,a={};for(const t in e){const n=e[t]._zod;if(n.values){a[t]??(a[t]=new Set);for(const e of n.values)a[t].add(e)}}return a});let n;const r=$a,i=!ia.jitless,o=i&&Ua.value,s=t.catchall;let p;e._zod.parse=(l,d)=>{p??(p=a.value);const u=l.value;if(!r(u))return l.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),l;const c=[];if(i&&o&&!1===d?.async&&!0!==d.jitless)n||(n=(e=>{const t=new gn(["shape","payload","ctx"]),n=a.value,r=e=>{const t=za(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let o=0;for(const e of n.keys)i[e]="key_"+o++;t.write("const newResult = {}");for(const e of n.keys)if(n.optionalKeys.has(e)){const a=i[e];t.write(`const ${a} = ${r(e)};`);const n=za(e);t.write(`\n if (${a}.issues.length) {\n if (input[${n}] === undefined) {\n if (${n} in input) {\n newResult[${n}] = undefined;\n }\n } else {\n payload.issues = payload.issues.concat(\n ${a}.issues.map((iss) => ({\n ...iss,\n path: iss.path ? [${n}, ...iss.path] : [${n}],\n }))\n );\n }\n } else if (${a}.value === undefined) {\n if (${n} in input) newResult[${n}] = undefined;\n } else {\n newResult[${n}] = ${a}.value;\n }\n `)}else{const a=i[e];t.write(`const ${a} = ${r(e)};`),t.write(`\n if (${a}.issues.length) payload.issues = payload.issues.concat(${a}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${za(e)}, ...iss.path] : [${za(e)}]\n })));`),t.write(`newResult[${za(e)}] = ${a}.value`)}t.write("payload.value = newResult;"),t.write("return payload;");const s=t.compile();return(t,a)=>s(e,t,a)})(t.shape)),l=n(l,d);else{l.value={};const e=p.shape;for(const t of p.keys){const a=e[t],n=a._zod.run({value:u[t],issues:[]},d),r="optional"===a._zod.optin&&"optional"===a._zod.optout;n instanceof Promise?c.push(n.then(e=>r?hr(e,l,t,u):_r(e,l,t))):r?hr(n,l,t,u):_r(n,l,t)}}if(!s)return c.length?Promise.all(c).then(()=>l):l;const m=[],f=p.keySet,_=s._zod,h=_.def.type;for(const e of Object.keys(u)){if(f.has(e))continue;if("never"===h){m.push(e);continue}const t=_.run({value:u[e],issues:[]},d);t instanceof Promise?c.push(t.then(t=>_r(t,l,e))):_r(t,l,e)}return m.length&&l.issues.push({code:"unrecognized_keys",keys:m,input:u,inst:e}),c.length?Promise.all(c).then(()=>l):l}});function yr(e,t,a,n){for(const a of e)if(0===a.issues.length)return t.value=a.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:a,errors:e.map(e=>e.issues.map(e=>en(e,n,oa())))}),t}const Tr=na("$ZodUnion",(e,t)=>{kn.init(e,t),Fa(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),Fa(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),Fa(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Fa(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>xa(e.source)).join("|")})$`)}}),e._zod.parse=(a,n)=>{let r=!1;const i=[];for(const e of t.options){const t=e._zod.run({value:a.value,issues:[]},n);if(t instanceof Promise)i.push(t),r=!0;else{if(0===t.issues.length)return t;i.push(t)}}return r?Promise.all(i).then(t=>yr(t,a,e,n)):yr(i,a,e,n)}}),Rr=na("$ZodDiscriminatedUnion",(e,t)=>{Tr.init(e,t);const a=e._zod.parse;Fa(e._zod,"propValues",()=>{const e={};for(const a of t.options){const n=a._zod.propValues;if(!n||0===Object.keys(n).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const[t,a]of Object.entries(n)){e[t]||(e[t]=new Set);for(const n of a)e[t].add(n)}}return e});const n=Ma(()=>{const e=t.options,a=new Map;for(const n of e){const e=n._zod.propValues[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const t of e){if(a.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);a.set(t,n)}}return a});e._zod.parse=(r,i)=>{const o=r.value;if(!$a(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;const s=n.value.get(o?.[t.discriminator]);return s?s._zod.run(r,i):t.unionFallback?a(r,i):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:o,path:[t.discriminator],inst:e}),r)}}),gr=na("$ZodIntersection",(e,t)=>{kn.init(e,t),e._zod.parse=(e,a)=>{const n=e.value,r=t.left._zod.run({value:n,issues:[]},a),i=t.right._zod.run({value:n,issues:[]},a);return r instanceof Promise||i instanceof Promise?Promise.all([r,i]).then(([t,a])=>Or(e,t,a)):Or(e,r,i)}});function vr(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(Ha(e)&&Ha(t)){const a=Object.keys(t),n=Object.keys(e).filter(e=>-1!==a.indexOf(e)),r={...e,...t};for(const a of n){const n=vr(e[a],t[a]);if(!n.valid)return{valid:!1,mergeErrorPath:[a,...n.mergeErrorPath]};r[a]=n.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const a=[];for(let n=0;n<e.length;n++){const r=vr(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};a.push(r.data)}return{valid:!0,data:a}}return{valid:!1,mergeErrorPath:[]}}function Or(e,t,a){if(t.issues.length&&e.issues.push(...t.issues),a.issues.length&&e.issues.push(...a.issues),Xa(e))return e;const n=vr(t.value,a.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}const Nr=na("$ZodRecord",(e,t)=>{kn.init(e,t),e._zod.parse=(a,n)=>{const r=a.value;if(!Ha(r))return a.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),a;const i=[];if(t.keyType._zod.values){const o=t.keyType._zod.values;a.value={};for(const e of o)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){const o=t.valueType._zod.run({value:r[e],issues:[]},n);o instanceof Promise?i.push(o.then(t=>{t.issues.length&&a.issues.push(...Ja(e,t.issues)),a.value[e]=t.value})):(o.issues.length&&a.issues.push(...Ja(e,o.issues)),a.value[e]=o.value)}let s;for(const e in r)o.has(e)||(s=s??[],s.push(e));s&&s.length>0&&a.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:s})}else{a.value={};for(const o of Reflect.ownKeys(r)){if("__proto__"===o)continue;const s=t.keyType._zod.run({value:o,issues:[]},n);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(s.issues.length){a.issues.push({origin:"record",code:"invalid_key",issues:s.issues.map(e=>en(e,n,oa())),input:o,path:[o],inst:e}),a.value[s.value]=s.value;continue}const p=t.valueType._zod.run({value:r[o],issues:[]},n);p instanceof Promise?i.push(p.then(e=>{e.issues.length&&a.issues.push(...Ja(o,e.issues)),a.value[s.value]=e.value})):(p.issues.length&&a.issues.push(...Ja(o,p.issues)),a.value[s.value]=p.value)}}return i.length?Promise.all(i).then(()=>a):a}});const br=na("$ZodEnum",(e,t)=>{kn.init(e,t);const a=ka(t.entries);e._zod.values=new Set(a),e._zod.pattern=new RegExp(`^(${a.filter(e=>Ka.has(typeof e)).map(e=>"string"==typeof e?qa(e):e.toString()).join("|")})$`),e._zod.parse=(t,n)=>{const r=t.value;return e._zod.values.has(r)||t.issues.push({code:"invalid_value",values:a,input:r,inst:e}),t}}),Ar=na("$ZodLiteral",(e,t)=>{kn.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?qa(e):e?e.toString():String(e)).join("|")})$`),e._zod.parse=(a,n)=>{const r=a.value;return e._zod.values.has(r)||a.issues.push({code:"invalid_value",values:t.values,input:r,inst:e}),a}}),Sr=na("$ZodTransform",(e,t)=>{kn.init(e,t),e._zod.parse=(e,a)=>{const n=t.transform(e.value,e);if(a.async){return(n instanceof Promise?n:Promise.resolve(n)).then(t=>(e.value=t,e))}if(n instanceof Promise)throw new ra;return e.value=n,e}}),Ir=na("$ZodOptional",(e,t)=>{kn.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Fa(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Fa(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${xa(e.source)})?$`):void 0}),e._zod.parse=(e,a)=>"optional"===t.innerType._zod.optin?t.innerType._zod.run(e,a):void 0===e.value?e:t.innerType._zod.run(e,a)}),wr=na("$ZodNullable",(e,t)=>{kn.init(e,t),Fa(e._zod,"optin",()=>t.innerType._zod.optin),Fa(e._zod,"optout",()=>t.innerType._zod.optout),Fa(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${xa(e.source)}|null)$`):void 0}),Fa(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,a)=>null===e.value?e:t.innerType._zod.run(e,a)}),Cr=na("$ZodDefault",(e,t)=>{kn.init(e,t),e._zod.optin="optional",Fa(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,a)=>{if(void 0===e.value)return e.value=t.defaultValue,e;const n=t.innerType._zod.run(e,a);return n instanceof Promise?n.then(e=>Dr(e,t)):Dr(n,t)}});function Dr(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Pr=na("$ZodPrefault",(e,t)=>{kn.init(e,t),e._zod.optin="optional",Fa(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,a)=>(void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,a))}),jr=na("$ZodNonOptional",(e,t)=>{kn.init(e,t),Fa(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(a,n)=>{const r=t.innerType._zod.run(a,n);return r instanceof Promise?r.then(t=>kr(t,e)):kr(r,e)}});function kr(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Lr=na("$ZodCatch",(e,t)=>{kn.init(e,t),e._zod.optin="optional",Fa(e._zod,"optout",()=>t.innerType._zod.optout),Fa(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,a)=>{const n=t.innerType._zod.run(e,a);return n instanceof Promise?n.then(n=>(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>en(e,a,oa()))},input:e.value}),e.issues=[]),e)):(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>en(e,a,oa()))},input:e.value}),e.issues=[]),e)}}),Mr=na("$ZodPipe",(e,t)=>{kn.init(e,t),Fa(e._zod,"values",()=>t.in._zod.values),Fa(e._zod,"optin",()=>t.in._zod.optin),Fa(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(e,a)=>{const n=t.in._zod.run(e,a);return n instanceof Promise?n.then(e=>Gr(e,t,a)):Gr(n,t,a)}});function Gr(e,t,a){return Xa(e)?e:t.out._zod.run({value:e.value,issues:e.issues},a)}const xr=na("$ZodReadonly",(e,t)=>{kn.init(e,t),Fa(e._zod,"propValues",()=>t.innerType._zod.propValues),Fa(e._zod,"values",()=>t.innerType._zod.values),Fa(e._zod,"optin",()=>t.innerType._zod.optin),Fa(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(e,a)=>{const n=t.innerType._zod.run(e,a);return n instanceof Promise?n.then(Fr):Fr(n)}});function Fr(e){return e.value=Object.freeze(e.value),e}const Br=na("$ZodCustom",(e,t)=>{nn.init(e,t),kn.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=a=>{const n=a.value,r=t.fn(n);if(r instanceof Promise)return r.then(t=>zr(t,a,n,e));zr(r,a,n,e)}});function zr(e,t,a,n){if(!e){const e={code:"custom",input:a,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(e.params=n._zod.def.params),t.issues.push(an(e))}}const Vr=na("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");kn.init(e,t),e.def=t,e.parse=(t,a)=>An(e,t,a,{callee:e.parse}),e.safeParse=(t,a)=>Cn(e,t,a),e.parseAsync=async(t,a)=>In(e,t,a,{callee:e.parseAsync}),e.safeParseAsync=async(t,a)=>Pn(e,t,a),e.check=(...a)=>e.clone({...t,checks:[...t.checks??[],...a.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),e.clone=(t,a)=>Wa(e,t,a),e.brand=()=>e,e.register=(t,a)=>(t.add(e,a),e)});const $r=na("ZodMiniObject",(e,t)=>{Er.init(e,t),Vr.init(e,t),Fa(e,"shape",()=>t.shape)});function Ur(e,t){const a={type:"object",get shape(){return Ba(this,"shape",{...e}),this.shape},...Qa(t)};return new $r(a)}function Hr(e){return!!e._zod}function Kr(e){const t=Object.values(e);if(0===t.length)return Ur({});const a=t.every(Hr),n=t.every(e=>!Hr(e));if(a)return Ur(e);if(n)return ta(e);throw new Error("Mixed Zod versions detected in object shape.")}function qr(e,t){if(Hr(e)){return Cn(e,t)}return e.safeParse(t)}async function Wr(e,t){if(Hr(e)){return await Pn(e,t)}const a=e;return await a.safeParseAsync(t)}function Qr(e){var t,a;if(!e)return;let n;if(Hr(e)){n=null===(a=null===(t=e._zod)||void 0===t?void 0:t.def)||void 0===a?void 0:a.shape}else{n=e.shape}if(n){if("function"==typeof n)try{return n()}catch(e){return}return n}}function Yr(e){var t;if(e){if("object"==typeof e){const t=e;if(!e._def&&!t._zod){const t=Object.values(e);if(t.length>0&&t.every(e=>"object"==typeof e&&null!==e&&(void 0!==e._def||void 0!==e._zod||"function"==typeof e.parse)))return Kr(e)}}if(Hr(e)){const a=null===(t=e._zod)||void 0===t?void 0:t.def;if(a&&("object"===a.type||void 0!==a.shape))return e}else{if(void 0!==e.shape)return e}}}function Xr(e){if(e&&"object"==typeof e){if("message"in e&&"string"==typeof e.message)return e.message;if("issues"in e&&Array.isArray(e.issues)&&e.issues.length>0){const t=e.issues[0];if(t&&"object"==typeof t&&"message"in t)return String(t.message)}try{return JSON.stringify(e)}catch(t){return String(e)}}return String(e)}function Jr(e){var t;if(Hr(e)){const a=null===(t=e._zod)||void 0===t?void 0:t.def;if(a){if(void 0!==a.value)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}}const a=e._def;if(a){if(void 0!==a.value)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}const n=e.value;if(void 0!==n)return n}Symbol("ZodOutput"),Symbol("ZodInput");class Zr{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){const a=t[0];if(this._map.set(e,a),a&&"object"==typeof a&&"id"in a){if(this._idmap.has(a.id))throw new Error(`ID ${a.id} already exists in the registry`);this._idmap.set(a.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const a={...this.get(t)??{}};return delete a.id,{...a,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function ei(){return new Zr}const ti=ei();function ai(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Qa(t)})}function ni(e,t){return new on({check:"less_than",...Qa(t),value:e,inclusive:!1})}function ri(e,t){return new on({check:"less_than",...Qa(t),value:e,inclusive:!0})}function ii(e,t){return new sn({check:"greater_than",...Qa(t),value:e,inclusive:!1})}function oi(e,t){return new sn({check:"greater_than",...Qa(t),value:e,inclusive:!0})}function si(e,t){return new pn({check:"multiple_of",...Qa(t),value:e})}function pi(e,t){return new dn({check:"max_length",...Qa(t),maximum:e})}function li(e,t){return new un({check:"min_length",...Qa(t),minimum:e})}function di(e,t){return new cn({check:"length_equals",...Qa(t),length:e})}function ui(e){return new Rn({check:"overwrite",tx:e})}const ci=na("ZodISODateTime",(e,t)=>{Wn.init(e,t),Ci.init(e,t)});function mi(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Qa(t)})}(ci,e)}const fi=na("ZodISODate",(e,t)=>{Qn.init(e,t),Ci.init(e,t)});function _i(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...Qa(t)})}(fi,e)}const hi=na("ZodISOTime",(e,t)=>{Yn.init(e,t),Ci.init(e,t)});function Ei(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Qa(t)})}(hi,e)}const yi=na("ZodISODuration",(e,t)=>{Xn.init(e,t),Ci.init(e,t)});function Ti(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...Qa(t)})}(yi,e)}const Ri=(e,t)=>{On.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t){const a=t||function(e){return e.message},n={_errors:[]},r=e=>{for(const t of e.issues)if("invalid_union"===t.code&&t.errors.length)t.errors.map(e=>r({issues:e}));else if("invalid_key"===t.code)r({issues:t.issues});else if("invalid_element"===t.code)r({issues:t.issues});else if(0===t.path.length)n._errors.push(a(t));else{let e=n,r=0;for(;r<t.path.length;){const n=t.path[r];r===t.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(a(t))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const a={},n=[];for(const r of e.issues)r.path.length>0?(a[r.path[0]]=a[r.path[0]]||[],a[r.path[0]].push(t(r))):n.push(t(r));return{formErrors:n,fieldErrors:a}}(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get:()=>0===e.issues.length}})},gi=(na("ZodError",Ri),na("ZodError",Ri,{Parent:Error})),vi=bn(gi),Oi=Sn(gi),Ni=wn(gi),bi=Dn(gi),Ai=na("ZodType",(e,t)=>(kn.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...a)=>e.clone({...t,checks:[...t.checks??[],...a.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),e.clone=(t,a)=>Wa(e,t,a),e.brand=()=>e,e.register=(t,a)=>(t.add(e,a),e),e.parse=(t,a)=>vi(e,t,a,{callee:e.parse}),e.safeParse=(t,a)=>Ni(e,t,a),e.parseAsync=async(t,a)=>Oi(e,t,a,{callee:e.parseAsync}),e.safeParseAsync=async(t,a)=>bi(e,t,a),e.spa=e.safeParseAsync,e.refine=(t,a)=>e.check(function(e,t={}){return function(e,t,a){return new e({type:"custom",check:"custom",fn:t,...Qa(a)})}(Fo,e,t)}(t,a)),e.superRefine=t=>e.check(function(e){const t=function(e){const t=new nn({check:"custom"});return t._zod.check=e,t}(a=>(a.addIssue=e=>{if("string"==typeof e)a.issues.push(an(e,a.value,t._zod.def));else{const n=e;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=a.value),n.inst??(n.inst=t),n.continue??(n.continue=!t._zod.def.abort),a.issues.push(an(n))}},e(a.value,a)));return t}(t)),e.overwrite=t=>e.check(ui(t)),e.optional=()=>wo(e),e.nullable=()=>Do(e),e.nullish=()=>wo(Do(e)),e.nonoptional=t=>function(e,t){return new ko({type:"nonoptional",innerType:e,...Qa(t)})}(e,t),e.array=()=>lo(e),e.or=t=>_o([e,t]),e.and=t=>To(e,t),e.transform=t=>Go(e,So(t)),e.default=t=>{return a=t,new Po({type:"default",innerType:e,get defaultValue(){return"function"==typeof a?a():a}});var a},e.prefault=t=>{return a=t,new jo({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof a?a():a}});var a},e.catch=t=>{return new Lo({type:"catch",innerType:e,catchValue:"function"==typeof(a=t)?a:()=>a});var a},e.pipe=t=>Go(e,t),e.readonly=()=>new xo({type:"readonly",innerType:e}),e.describe=t=>{const a=e.clone();return ti.add(a,{description:t}),a},Object.defineProperty(e,"description",{get:()=>ti.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return ti.get(e);const a=e.clone();return ti.add(a,t[0]),a},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Si=na("_ZodString",(e,t)=>{Ln.init(e,t),Ai.init(e,t);const a=e._zod.bag;e.format=a.format??null,e.minLength=a.minimum??null,e.maxLength=a.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new fn({check:"string_format",format:"regex",...Qa(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new En({check:"string_format",format:"includes",...Qa(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new yn({check:"string_format",format:"starts_with",...Qa(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Tn({check:"string_format",format:"ends_with",...Qa(t),suffix:e})}(...t)),e.min=(...t)=>e.check(li(...t)),e.max=(...t)=>e.check(pi(...t)),e.length=(...t)=>e.check(di(...t)),e.nonempty=(...t)=>e.check(li(1,...t)),e.lowercase=t=>e.check(function(e){return new _n({check:"string_format",format:"lowercase",...Qa(e)})}(t)),e.uppercase=t=>e.check(function(e){return new hn({check:"string_format",format:"uppercase",...Qa(e)})}(t)),e.trim=()=>e.check(ui(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return ui(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(ui(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(ui(e=>e.toUpperCase()))}),Ii=na("ZodString",(e,t)=>{Ln.init(e,t),Si.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Qa(t)})}(Di,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Qa(t)})}(ki,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Qa(t)})}(Qi,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Qa(t)})}(Li,t)),e.guid=t=>e.check(ai(Pi,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Qa(t)})}(ji,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Qa(t)})}(ji,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Qa(t)})}(ji,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Qa(t)})}(ji,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Qa(t)})}(Mi,t)),e.guid=t=>e.check(ai(Pi,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Qa(t)})}(Gi,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Qa(t)})}(xi,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Qa(t)})}(Fi,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Qa(t)})}(Ki,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Qa(t)})}(qi,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Qa(t)})}(Bi,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Qa(t)})}(zi,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Qa(t)})}(Vi,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Qa(t)})}($i,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Qa(t)})}(Ui,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Qa(t)})}(Hi,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Qa(t)})}(Wi,t)),e.datetime=t=>e.check(mi(t)),e.date=t=>e.check(_i(t)),e.time=t=>e.check(Ei(t)),e.duration=t=>e.check(Ti(t))});function wi(e){return function(e,t){return new e({type:"string",...Qa(t)})}(Ii,e)}const Ci=na("ZodStringFormat",(e,t)=>{Mn.init(e,t),Si.init(e,t)}),Di=na("ZodEmail",(e,t)=>{Fn.init(e,t),Ci.init(e,t)});const Pi=na("ZodGUID",(e,t)=>{Gn.init(e,t),Ci.init(e,t)});const ji=na("ZodUUID",(e,t)=>{xn.init(e,t),Ci.init(e,t)});const ki=na("ZodURL",(e,t)=>{Bn.init(e,t),Ci.init(e,t)});const Li=na("ZodEmoji",(e,t)=>{zn.init(e,t),Ci.init(e,t)});const Mi=na("ZodNanoID",(e,t)=>{Vn.init(e,t),Ci.init(e,t)});const Gi=na("ZodCUID",(e,t)=>{$n.init(e,t),Ci.init(e,t)});const xi=na("ZodCUID2",(e,t)=>{Un.init(e,t),Ci.init(e,t)});const Fi=na("ZodULID",(e,t)=>{Hn.init(e,t),Ci.init(e,t)});const Bi=na("ZodXID",(e,t)=>{Kn.init(e,t),Ci.init(e,t)});const zi=na("ZodKSUID",(e,t)=>{qn.init(e,t),Ci.init(e,t)});const Vi=na("ZodIPv4",(e,t)=>{Jn.init(e,t),Ci.init(e,t)});const $i=na("ZodIPv6",(e,t)=>{Zn.init(e,t),Ci.init(e,t)});const Ui=na("ZodCIDRv4",(e,t)=>{er.init(e,t),Ci.init(e,t)});const Hi=na("ZodCIDRv6",(e,t)=>{tr.init(e,t),Ci.init(e,t)});const Ki=na("ZodBase64",(e,t)=>{nr.init(e,t),Ci.init(e,t)});const qi=na("ZodBase64URL",(e,t)=>{rr.init(e,t),Ci.init(e,t)});const Wi=na("ZodE164",(e,t)=>{ir.init(e,t),Ci.init(e,t)});const Qi=na("ZodJWT",(e,t)=>{or.init(e,t),Ci.init(e,t)});const Yi=na("ZodNumber",(e,t)=>{sr.init(e,t),Ai.init(e,t),e.gt=(t,a)=>e.check(ii(t,a)),e.gte=(t,a)=>e.check(oi(t,a)),e.min=(t,a)=>e.check(oi(t,a)),e.lt=(t,a)=>e.check(ni(t,a)),e.lte=(t,a)=>e.check(ri(t,a)),e.max=(t,a)=>e.check(ri(t,a)),e.int=t=>e.check(Zi(t)),e.safe=t=>e.check(Zi(t)),e.positive=t=>e.check(ii(0,t)),e.nonnegative=t=>e.check(oi(0,t)),e.negative=t=>e.check(ni(0,t)),e.nonpositive=t=>e.check(ri(0,t)),e.multipleOf=(t,a)=>e.check(si(t,a)),e.step=(t,a)=>e.check(si(t,a)),e.finite=()=>e;const a=e._zod.bag;e.minValue=Math.max(a.minimum??Number.NEGATIVE_INFINITY,a.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(a.maximum??Number.POSITIVE_INFINITY,a.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(a.format??"").includes("int")||Number.isSafeInteger(a.multipleOf??.5),e.isFinite=!0,e.format=a.format??null});function Xi(e){return function(e,t){return new e({type:"number",checks:[],...Qa(t)})}(Yi,e)}const Ji=na("ZodNumberFormat",(e,t)=>{pr.init(e,t),Yi.init(e,t)});function Zi(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Qa(t)})}(Ji,e)}const eo=na("ZodBoolean",(e,t)=>{lr.init(e,t),Ai.init(e,t)});function to(e){return function(e,t){return new e({type:"boolean",...Qa(t)})}(eo,e)}const ao=na("ZodNull",(e,t)=>{dr.init(e,t),Ai.init(e,t)});function no(e){return function(e,t){return new e({type:"null",...Qa(t)})}(ao,e)}const ro=na("ZodUnknown",(e,t)=>{ur.init(e,t),Ai.init(e,t)});function io(){return function(e){return new e({type:"unknown"})}(ro)}const oo=na("ZodNever",(e,t)=>{cr.init(e,t),Ai.init(e,t)});function so(e){return function(e,t){return new e({type:"never",...Qa(t)})}(oo,e)}const po=na("ZodArray",(e,t)=>{fr.init(e,t),Ai.init(e,t),e.element=t.element,e.min=(t,a)=>e.check(li(t,a)),e.nonempty=t=>e.check(li(1,t)),e.max=(t,a)=>e.check(pi(t,a)),e.length=(t,a)=>e.check(di(t,a)),e.unwrap=()=>e.element});function lo(e,t){return function(e,t,a){return new e({type:"array",element:t,...Qa(a)})}(po,e,t)}const uo=na("ZodObject",(e,t)=>{Er.init(e,t),Ai.init(e,t),Fa(e,"shape",()=>t.shape),e.keyof=()=>Oo(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:io()}),e.loose=()=>e.clone({...e._zod.def,catchall:io()}),e.strict=()=>e.clone({...e._zod.def,catchall:so()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!Ha(t))throw new Error("Invalid input to extend: expected a plain object");const a={...e._zod.def,get shape(){const a={...e._zod.def.shape,...t};return Ba(this,"shape",a),a},checks:[]};return Wa(e,a)}(e,t),e.merge=t=>{return n=t,Wa(a=e,{...a._zod.def,get shape(){const e={...a._zod.def.shape,...n._zod.def.shape};return Ba(this,"shape",e),e},catchall:n._zod.def.catchall,checks:[]});var a,n},e.pick=t=>function(e,t){const a={},n=e._zod.def;for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&(a[e]=n.shape[e])}return Wa(e,{...e._zod.def,shape:a,checks:[]})}(e,t),e.omit=t=>function(e,t){const a={...e._zod.def.shape},n=e._zod.def;for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete a[e]}return Wa(e,{...e._zod.def,shape:a,checks:[]})}(e,t),e.partial=(...t)=>function(e,t,a){const n=t._zod.def.shape,r={...n};if(a)for(const t in a){if(!(t in n))throw new Error(`Unrecognized key: "${t}"`);a[t]&&(r[t]=e?new e({type:"optional",innerType:n[t]}):n[t])}else for(const t in n)r[t]=e?new e({type:"optional",innerType:n[t]}):n[t];return Wa(t,{...t._zod.def,shape:r,checks:[]})}(Io,e,t[0]),e.required=(...t)=>function(e,t,a){const n=t._zod.def.shape,r={...n};if(a)for(const t in a){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);a[t]&&(r[t]=new e({type:"nonoptional",innerType:n[t]}))}else for(const t in n)r[t]=new e({type:"nonoptional",innerType:n[t]});return Wa(t,{...t._zod.def,shape:r,checks:[]})}(ko,e,t[0])});function co(e,t){const a={type:"object",get shape(){return Ba(this,"shape",{...e}),this.shape},...Qa(t)};return new uo(a)}function mo(e,t){return new uo({type:"object",get shape(){return Ba(this,"shape",{...e}),this.shape},catchall:io(),...Qa(t)})}const fo=na("ZodUnion",(e,t)=>{Tr.init(e,t),Ai.init(e,t),e.options=t.options});function _o(e,t){return new fo({type:"union",options:e,...Qa(t)})}const ho=na("ZodDiscriminatedUnion",(e,t)=>{fo.init(e,t),Rr.init(e,t)});function Eo(e,t,a){return new ho({type:"union",options:t,discriminator:e,...Qa(a)})}const yo=na("ZodIntersection",(e,t)=>{gr.init(e,t),Ai.init(e,t)});function To(e,t){return new yo({type:"intersection",left:e,right:t})}const Ro=na("ZodRecord",(e,t)=>{Nr.init(e,t),Ai.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function go(e,t,a){return new Ro({type:"record",keyType:e,valueType:t,...Qa(a)})}const vo=na("ZodEnum",(e,t)=>{br.init(e,t),Ai.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const a=new Set(Object.keys(t.entries));e.extract=(e,n)=>{const r={};for(const n of e){if(!a.has(n))throw new Error(`Key ${n} not found in enum`);r[n]=t.entries[n]}return new vo({...t,checks:[],...Qa(n),entries:r})},e.exclude=(e,n)=>{const r={...t.entries};for(const t of e){if(!a.has(t))throw new Error(`Key ${t} not found in enum`);delete r[t]}return new vo({...t,checks:[],...Qa(n),entries:r})}});function Oo(e,t){const a=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new vo({type:"enum",entries:a,...Qa(t)})}const No=na("ZodLiteral",(e,t)=>{Ar.init(e,t),Ai.init(e,t),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 bo(e,t){return new No({type:"literal",values:Array.isArray(e)?e:[e],...Qa(t)})}const Ao=na("ZodTransform",(e,t)=>{Sr.init(e,t),Ai.init(e,t),e._zod.parse=(a,n)=>{a.addIssue=n=>{if("string"==typeof n)a.issues.push(an(n,a.value,t));else{const t=n;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=a.value),t.inst??(t.inst=e),t.continue??(t.continue=!0),a.issues.push(an(t))}};const r=t.transform(a.value,a);return r instanceof Promise?r.then(e=>(a.value=e,a)):(a.value=r,a)}});function So(e){return new Ao({type:"transform",transform:e})}const Io=na("ZodOptional",(e,t)=>{Ir.init(e,t),Ai.init(e,t),e.unwrap=()=>e._zod.def.innerType});function wo(e){return new Io({type:"optional",innerType:e})}const Co=na("ZodNullable",(e,t)=>{wr.init(e,t),Ai.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Do(e){return new Co({type:"nullable",innerType:e})}const Po=na("ZodDefault",(e,t)=>{Cr.init(e,t),Ai.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const jo=na("ZodPrefault",(e,t)=>{Pr.init(e,t),Ai.init(e,t),e.unwrap=()=>e._zod.def.innerType});const ko=na("ZodNonOptional",(e,t)=>{jr.init(e,t),Ai.init(e,t),e.unwrap=()=>e._zod.def.innerType});const Lo=na("ZodCatch",(e,t)=>{Lr.init(e,t),Ai.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const Mo=na("ZodPipe",(e,t)=>{Mr.init(e,t),Ai.init(e,t),e.in=t.in,e.out=t.out});function Go(e,t){return new Mo({type:"pipe",in:e,out:t})}const xo=na("ZodReadonly",(e,t)=>{xr.init(e,t),Ai.init(e,t)});const Fo=na("ZodCustom",(e,t)=>{Br.init(e,t),Ai.init(e,t)});function Bo(e,t){return Go(So(e),t)}const zo="2025-11-25",Vo=[zo,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],$o="io.modelcontextprotocol/related-task",Uo="2.0",Ho=function(e,t,a){const n=Qa(a);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}(Fo,(e=>null!==e&&("object"==typeof e||"function"==typeof e))??(()=>!0),Ko);var Ko;const qo=_o([wi(),Xi().int()]),Wo=wi(),Qo=mo({ttl:_o([Xi(),no()]).optional(),pollInterval:Xi().optional()}),Yo=mo({taskId:wi()}),Xo=mo({progressToken:qo.optional(),[$o]:Yo.optional()}),Jo=mo({task:Qo.optional(),_meta:Xo.optional()}),Zo=co({method:wi(),params:Jo.optional()}),es=mo({_meta:co({[$o]:wo(Yo)}).passthrough().optional()}),ts=co({method:wi(),params:es.optional()}),as=mo({_meta:mo({[$o]:Yo.optional()}).optional()}),ns=_o([wi(),Xi().int()]),rs=co({jsonrpc:bo(Uo),id:ns,...Zo.shape}).strict(),is=e=>rs.safeParse(e).success,os=co({jsonrpc:bo(Uo),...ts.shape}).strict(),ss=co({jsonrpc:bo(Uo),id:ns,result:as}).strict(),ps=e=>ss.safeParse(e).success;var ls;!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"}(ls||(ls={}));const ds=co({jsonrpc:bo(Uo),id:ns,error:co({code:Xi().int(),message:wi(),data:wo(io())})}).strict(),us=_o([rs,os,ss,ds]),cs=as.strict(),ms=es.extend({requestId:ns,reason:wi().optional()}),fs=ts.extend({method:bo("notifications/cancelled"),params:ms}),_s=co({src:wi(),mimeType:wi().optional(),sizes:lo(wi()).optional()}),hs=co({icons:lo(_s).optional()}),Es=co({name:wi(),title:wi().optional()}),ys=Es.extend({...Es.shape,...hs.shape,version:wi(),websiteUrl:wi().optional()}),Ts=To(co({applyDefaults:to().optional()}),go(wi(),io())),Rs=Bo(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,To(co({form:Ts.optional(),url:Ho.optional()}),go(wi(),io()).optional())),gs=co({list:wo(co({}).passthrough()),cancel:wo(co({}).passthrough()),requests:wo(co({sampling:wo(co({createMessage:wo(co({}).passthrough())}).passthrough()),elicitation:wo(co({create:wo(co({}).passthrough())}).passthrough())}).passthrough())}).passthrough(),vs=co({list:wo(co({}).passthrough()),cancel:wo(co({}).passthrough()),requests:wo(co({tools:wo(co({call:wo(co({}).passthrough())}).passthrough())}).passthrough())}).passthrough(),Os=co({experimental:go(wi(),Ho).optional(),sampling:co({context:Ho.optional(),tools:Ho.optional()}).optional(),elicitation:Rs.optional(),roots:co({listChanged:to().optional()}).optional(),tasks:wo(gs)}),Ns=Jo.extend({protocolVersion:wi(),capabilities:Os,clientInfo:ys}),bs=Zo.extend({method:bo("initialize"),params:Ns}),As=co({experimental:go(wi(),Ho).optional(),logging:Ho.optional(),completions:Ho.optional(),prompts:wo(co({listChanged:wo(to())})),resources:co({subscribe:to().optional(),listChanged:to().optional()}).optional(),tools:co({listChanged:to().optional()}).optional(),tasks:wo(vs)}).passthrough(),Ss=as.extend({protocolVersion:wi(),capabilities:As,serverInfo:ys,instructions:wi().optional()}),Is=ts.extend({method:bo("notifications/initialized")}),ws=Zo.extend({method:bo("ping")}),Cs=co({progress:Xi(),total:wo(Xi()),message:wo(wi())}),Ds=co({...es.shape,...Cs.shape,progressToken:qo}),Ps=ts.extend({method:bo("notifications/progress"),params:Ds}),js=Jo.extend({cursor:Wo.optional()}),ks=Zo.extend({params:js.optional()}),Ls=as.extend({nextCursor:wo(Wo)}),Ms=co({taskId:wi(),status:Oo(["working","input_required","completed","failed","cancelled"]),ttl:_o([Xi(),no()]),createdAt:wi(),lastUpdatedAt:wi(),pollInterval:wo(Xi()),statusMessage:wo(wi())}),Gs=as.extend({task:Ms}),xs=es.merge(Ms),Fs=ts.extend({method:bo("notifications/tasks/status"),params:xs}),Bs=Zo.extend({method:bo("tasks/get"),params:Jo.extend({taskId:wi()})}),zs=as.merge(Ms),Vs=Zo.extend({method:bo("tasks/result"),params:Jo.extend({taskId:wi()})}),$s=ks.extend({method:bo("tasks/list")}),Us=Ls.extend({tasks:lo(Ms)}),Hs=Zo.extend({method:bo("tasks/cancel"),params:Jo.extend({taskId:wi()})}),Ks=as.merge(Ms),qs=co({uri:wi(),mimeType:wo(wi()),_meta:go(wi(),io()).optional()}),Ws=qs.extend({text:wi()}),Qs=wi().refine(e=>{try{return atob(e),!0}catch(e){return!1}},{message:"Invalid Base64 string"}),Ys=qs.extend({blob:Qs}),Xs=co({audience:lo(Oo(["user","assistant"])).optional(),priority:Xi().min(0).max(1).optional(),lastModified:mi({offset:!0}).optional()}),Js=co({...Es.shape,...hs.shape,uri:wi(),description:wo(wi()),mimeType:wo(wi()),annotations:Xs.optional(),_meta:wo(mo({}))}),Zs=co({...Es.shape,...hs.shape,uriTemplate:wi(),description:wo(wi()),mimeType:wo(wi()),annotations:Xs.optional(),_meta:wo(mo({}))}),ep=ks.extend({method:bo("resources/list")}),tp=Ls.extend({resources:lo(Js)}),ap=ks.extend({method:bo("resources/templates/list")}),np=Ls.extend({resourceTemplates:lo(Zs)}),rp=Jo.extend({uri:wi()}),ip=rp,op=Zo.extend({method:bo("resources/read"),params:ip}),sp=as.extend({contents:lo(_o([Ws,Ys]))}),pp=ts.extend({method:bo("notifications/resources/list_changed")}),lp=rp,dp=Zo.extend({method:bo("resources/subscribe"),params:lp}),up=rp,cp=Zo.extend({method:bo("resources/unsubscribe"),params:up}),mp=es.extend({uri:wi()}),fp=ts.extend({method:bo("notifications/resources/updated"),params:mp}),_p=co({name:wi(),description:wo(wi()),required:wo(to())}),hp=co({...Es.shape,...hs.shape,description:wo(wi()),arguments:wo(lo(_p)),_meta:wo(mo({}))}),Ep=ks.extend({method:bo("prompts/list")}),yp=Ls.extend({prompts:lo(hp)}),Tp=Jo.extend({name:wi(),arguments:go(wi(),wi()).optional()}),Rp=Zo.extend({method:bo("prompts/get"),params:Tp}),gp=co({type:bo("text"),text:wi(),annotations:Xs.optional(),_meta:go(wi(),io()).optional()}),vp=co({type:bo("image"),data:Qs,mimeType:wi(),annotations:Xs.optional(),_meta:go(wi(),io()).optional()}),Op=co({type:bo("audio"),data:Qs,mimeType:wi(),annotations:Xs.optional(),_meta:go(wi(),io()).optional()}),Np=co({type:bo("tool_use"),name:wi(),id:wi(),input:co({}).passthrough(),_meta:wo(co({}).passthrough())}).passthrough(),bp=co({type:bo("resource"),resource:_o([Ws,Ys]),annotations:Xs.optional(),_meta:go(wi(),io()).optional()}),Ap=_o([gp,vp,Op,Js.extend({type:bo("resource_link")}),bp]),Sp=co({role:Oo(["user","assistant"]),content:Ap}),Ip=as.extend({description:wo(wi()),messages:lo(Sp)}),wp=ts.extend({method:bo("notifications/prompts/list_changed")}),Cp=co({title:wi().optional(),readOnlyHint:to().optional(),destructiveHint:to().optional(),idempotentHint:to().optional(),openWorldHint:to().optional()}),Dp=co({taskSupport:Oo(["required","optional","forbidden"]).optional()}),Pp=co({...Es.shape,...hs.shape,description:wi().optional(),inputSchema:co({type:bo("object"),properties:go(wi(),Ho).optional(),required:lo(wi()).optional()}).catchall(io()),outputSchema:co({type:bo("object"),properties:go(wi(),Ho).optional(),required:lo(wi()).optional()}).catchall(io()).optional(),annotations:wo(Cp),execution:wo(Dp),_meta:go(wi(),io()).optional()}),jp=ks.extend({method:bo("tools/list")}),kp=Ls.extend({tools:lo(Pp)}),Lp=as.extend({content:lo(Ap).default([]),structuredContent:go(wi(),io()).optional(),isError:wo(to())}),Mp=(Lp.or(as.extend({toolResult:io()})),Jo.extend({name:wi(),arguments:wo(go(wi(),io()))})),Gp=Zo.extend({method:bo("tools/call"),params:Mp}),xp=ts.extend({method:bo("notifications/tools/list_changed")}),Fp=Oo(["debug","info","notice","warning","error","critical","alert","emergency"]),Bp=Jo.extend({level:Fp}),zp=Zo.extend({method:bo("logging/setLevel"),params:Bp}),Vp=es.extend({level:Fp,logger:wi().optional(),data:io()}),$p=ts.extend({method:bo("notifications/message"),params:Vp}),Up=co({name:wi().optional()}),Hp=co({hints:wo(lo(Up)),costPriority:wo(Xi().min(0).max(1)),speedPriority:wo(Xi().min(0).max(1)),intelligencePriority:wo(Xi().min(0).max(1))}),Kp=co({mode:wo(Oo(["auto","required","none"]))}),qp=co({type:bo("tool_result"),toolUseId:wi().describe("The unique identifier for the corresponding tool call."),content:lo(Ap).default([]),structuredContent:co({}).passthrough().optional(),isError:wo(to()),_meta:wo(co({}).passthrough())}).passthrough(),Wp=Eo("type",[gp,vp,Op]),Qp=Eo("type",[gp,vp,Op,Np,qp]),Yp=co({role:Oo(["user","assistant"]),content:_o([Qp,lo(Qp)]),_meta:wo(co({}).passthrough())}).passthrough(),Xp=Jo.extend({messages:lo(Yp),modelPreferences:Hp.optional(),systemPrompt:wi().optional(),includeContext:Oo(["none","thisServer","allServers"]).optional(),temperature:Xi().optional(),maxTokens:Xi().int(),stopSequences:lo(wi()).optional(),metadata:Ho.optional(),tools:wo(lo(Pp)),toolChoice:wo(Kp)}),Jp=Zo.extend({method:bo("sampling/createMessage"),params:Xp}),Zp=as.extend({model:wi(),stopReason:wo(Oo(["endTurn","stopSequence","maxTokens"]).or(wi())),role:Oo(["user","assistant"]),content:Wp}),el=as.extend({model:wi(),stopReason:wo(Oo(["endTurn","stopSequence","maxTokens","toolUse"]).or(wi())),role:Oo(["user","assistant"]),content:_o([Qp,lo(Qp)])}),tl=co({type:bo("boolean"),title:wi().optional(),description:wi().optional(),default:to().optional()}),al=co({type:bo("string"),title:wi().optional(),description:wi().optional(),minLength:Xi().optional(),maxLength:Xi().optional(),format:Oo(["email","uri","date","date-time"]).optional(),default:wi().optional()}),nl=co({type:Oo(["number","integer"]),title:wi().optional(),description:wi().optional(),minimum:Xi().optional(),maximum:Xi().optional(),default:Xi().optional()}),rl=co({type:bo("string"),title:wi().optional(),description:wi().optional(),enum:lo(wi()),default:wi().optional()}),il=co({type:bo("string"),title:wi().optional(),description:wi().optional(),oneOf:lo(co({const:wi(),title:wi()})),default:wi().optional()}),ol=co({type:bo("string"),title:wi().optional(),description:wi().optional(),enum:lo(wi()),enumNames:lo(wi()).optional(),default:wi().optional()}),sl=_o([rl,il]),pl=_o([co({type:bo("array"),title:wi().optional(),description:wi().optional(),minItems:Xi().optional(),maxItems:Xi().optional(),items:co({type:bo("string"),enum:lo(wi())}),default:lo(wi()).optional()}),co({type:bo("array"),title:wi().optional(),description:wi().optional(),minItems:Xi().optional(),maxItems:Xi().optional(),items:co({anyOf:lo(co({const:wi(),title:wi()}))}),default:lo(wi()).optional()})]),ll=_o([ol,sl,pl]),dl=_o([ll,tl,al,nl]),ul=_o([Jo.extend({mode:bo("form").optional(),message:wi(),requestedSchema:co({type:bo("object"),properties:go(wi(),dl),required:lo(wi()).optional()})}),Jo.extend({mode:bo("url"),message:wi(),elicitationId:wi(),url:wi().url()})]),cl=Zo.extend({method:bo("elicitation/create"),params:ul}),ml=es.extend({elicitationId:wi()}),fl=ts.extend({method:bo("notifications/elicitation/complete"),params:ml}),_l=as.extend({action:Oo(["accept","decline","cancel"]),content:Bo(e=>null===e?void 0:e,go(wi(),_o([wi(),Xi(),to(),lo(wi())])).optional())}),hl=co({type:bo("ref/resource"),uri:wi()}),El=co({type:bo("ref/prompt"),name:wi()}),yl=Jo.extend({ref:_o([El,hl]),argument:co({name:wi(),value:wi()}),context:co({arguments:go(wi(),wi()).optional()}).optional()}),Tl=Zo.extend({method:bo("completion/complete"),params:yl});const Rl=as.extend({completion:mo({values:lo(wi()).max(100),total:wo(Xi().int()),hasMore:wo(to())})}),gl=co({uri:wi().startsWith("file://"),name:wi().optional(),_meta:go(wi(),io()).optional()}),vl=Zo.extend({method:bo("roots/list")}),Ol=as.extend({roots:lo(gl)}),Nl=ts.extend({method:bo("notifications/roots/list_changed")});_o([ws,bs,Tl,zp,Rp,Ep,ep,ap,op,dp,cp,Gp,jp,Bs,Vs,$s]),_o([fs,Ps,Is,Nl,Fs]),_o([cs,Zp,el,_l,Ol,zs,Us,Gs]),_o([ws,Jp,cl,vl,Bs,Vs,$s]),_o([fs,Ps,$p,fp,pp,xp,wp,Fs,fl]),_o([cs,Ss,Rl,Ip,yp,tp,np,sp,Lp,kp,zs,Us,Gs]);class bl extends Error{constructor(e,t,a){super(`MCP error ${e}: ${t}`),this.code=e,this.data=a,this.name="McpError"}static fromError(e,t,a){if(e===ls.UrlElicitationRequired&&a){const e=a;if(e.elicitations)return new Al(e.elicitations,t)}return new bl(e,t,a)}}class Al extends bl{constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(ls.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){var e,t;return null!==(t=null===(e=this.data)||void 0===e?void 0:e.elicitations)&&void 0!==t?t:[]}}function Sl(e){return"completed"===e||"failed"===e||"cancelled"===e}class Il{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??ti,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,t={path:[],schemaPath:[]}){var a;const n=e._zod.def,r={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(e);if(i){i.count++;return t.schemaPath.includes(e)&&(i.cycle=t.path),i.schema}const o={schema:{},count:1,cycle:void 0,path:t.path};this.seen.set(e,o);const s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{const a={...t,schemaPath:[...t.schemaPath,e],path:t.path},i=e._zod.parent;if(i)o.ref=i,this.process(i,a),this.seen.get(i).isParent=!0;else{const t=o.schema;switch(n.type){case"string":{const a=t;a.type="string";const{minimum:n,maximum:i,format:s,patterns:p,contentEncoding:l}=e._zod.bag;if("number"==typeof n&&(a.minLength=n),"number"==typeof i&&(a.maxLength=i),s&&(a.format=r[s]??s,""===a.format&&delete a.format),l&&(a.contentEncoding=l),p&&p.size>0){const e=[...p];1===e.length?a.pattern=e[0].source:e.length>1&&(o.schema.allOf=[...e.map(e=>({..."draft-7"===this.target?{type:"string"}:{},pattern:e.source}))])}break}case"number":{const a=t,{minimum:n,maximum:r,format:i,multipleOf:o,exclusiveMaximum:s,exclusiveMinimum:p}=e._zod.bag;"string"==typeof i&&i.includes("int")?a.type="integer":a.type="number","number"==typeof p&&(a.exclusiveMinimum=p),"number"==typeof n&&(a.minimum=n,"number"==typeof p&&(p>=n?delete a.minimum:delete a.exclusiveMinimum)),"number"==typeof s&&(a.exclusiveMaximum=s),"number"==typeof r&&(a.maximum=r,"number"==typeof s&&(s<=r?delete a.maximum:delete a.exclusiveMaximum)),"number"==typeof o&&(a.multipleOf=o);break}case"boolean":t.type="boolean";break;case"bigint":if("throw"===this.unrepresentable)throw new Error("BigInt cannot be represented in JSON Schema");break;case"symbol":if("throw"===this.unrepresentable)throw new Error("Symbols cannot be represented in JSON Schema");break;case"null":t.type="null";break;case"any":case"unknown":break;case"undefined":if("throw"===this.unrepresentable)throw new Error("Undefined cannot be represented in JSON Schema");break;case"void":if("throw"===this.unrepresentable)throw new Error("Void cannot be represented in JSON Schema");break;case"never":t.not={};break;case"date":if("throw"===this.unrepresentable)throw new Error("Date cannot be represented in JSON Schema");break;case"array":{const r=t,{minimum:i,maximum:o}=e._zod.bag;"number"==typeof i&&(r.minItems=i),"number"==typeof o&&(r.maxItems=o),r.type="array",r.items=this.process(n.element,{...a,path:[...a.path,"items"]});break}case"object":{const e=t;e.type="object",e.properties={};const r=n.shape;for(const t in r)e.properties[t]=this.process(r[t],{...a,path:[...a.path,"properties",t]});const i=new Set(Object.keys(r)),o=new Set([...i].filter(e=>{const t=n.shape[e]._zod;return"input"===this.io?void 0===t.optin:void 0===t.optout}));o.size>0&&(e.required=Array.from(o)),"never"===n.catchall?._zod.def.type?e.additionalProperties=!1:n.catchall?n.catchall&&(e.additionalProperties=this.process(n.catchall,{...a,path:[...a.path,"additionalProperties"]})):"output"===this.io&&(e.additionalProperties=!1);break}case"union":t.anyOf=n.options.map((e,t)=>this.process(e,{...a,path:[...a.path,"anyOf",t]}));break;case"intersection":{const e=t,r=this.process(n.left,{...a,path:[...a.path,"allOf",0]}),i=this.process(n.right,{...a,path:[...a.path,"allOf",1]}),o=e=>"allOf"in e&&1===Object.keys(e).length,s=[...o(r)?r.allOf:[r],...o(i)?i.allOf:[i]];e.allOf=s;break}case"tuple":{const r=t;r.type="array";const i=n.items.map((e,t)=>this.process(e,{...a,path:[...a.path,"prefixItems",t]}));if("draft-2020-12"===this.target?r.prefixItems=i:r.items=i,n.rest){const e=this.process(n.rest,{...a,path:[...a.path,"items"]});"draft-2020-12"===this.target?r.items=e:r.additionalItems=e}n.rest&&(r.items=this.process(n.rest,{...a,path:[...a.path,"items"]}));const{minimum:o,maximum:s}=e._zod.bag;"number"==typeof o&&(r.minItems=o),"number"==typeof s&&(r.maxItems=s);break}case"record":{const e=t;e.type="object",e.propertyNames=this.process(n.keyType,{...a,path:[...a.path,"propertyNames"]}),e.additionalProperties=this.process(n.valueType,{...a,path:[...a.path,"additionalProperties"]});break}case"map":if("throw"===this.unrepresentable)throw new Error("Map cannot be represented in JSON Schema");break;case"set":if("throw"===this.unrepresentable)throw new Error("Set cannot be represented in JSON Schema");break;case"enum":{const e=t,a=ka(n.entries);a.every(e=>"number"==typeof e)&&(e.type="number"),a.every(e=>"string"==typeof e)&&(e.type="string"),e.enum=a;break}case"literal":{const e=t,a=[];for(const e of n.values)if(void 0===e){if("throw"===this.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof e){if("throw"===this.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(e))}else a.push(e);if(0===a.length);else if(1===a.length){const t=a[0];e.type=null===t?"null":typeof t,e.const=t}else a.every(e=>"number"==typeof e)&&(e.type="number"),a.every(e=>"string"==typeof e)&&(e.type="string"),a.every(e=>"boolean"==typeof e)&&(e.type="string"),a.every(e=>null===e)&&(e.type="null"),e.enum=a;break}case"file":{const a=t,n={type:"string",format:"binary",contentEncoding:"binary"},{minimum:r,maximum:i,mime:o}=e._zod.bag;void 0!==r&&(n.minLength=r),void 0!==i&&(n.maxLength=i),o?1===o.length?(n.contentMediaType=o[0],Object.assign(a,n)):a.anyOf=o.map(e=>({...n,contentMediaType:e})):Object.assign(a,n);break}case"transform":if("throw"===this.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema");break;case"nullable":{const e=this.process(n.innerType,a);t.anyOf=[e,{type:"null"}];break}case"nonoptional":case"promise":case"optional":this.process(n.innerType,a),o.ref=n.innerType;break;case"success":t.type="boolean";break;case"default":this.process(n.innerType,a),o.ref=n.innerType,t.default=JSON.parse(JSON.stringify(n.defaultValue));break;case"prefault":this.process(n.innerType,a),o.ref=n.innerType,"input"===this.io&&(t._prefault=JSON.parse(JSON.stringify(n.defaultValue)));break;case"catch":{let e;this.process(n.innerType,a),o.ref=n.innerType;try{e=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=e;break}case"nan":if("throw"===this.unrepresentable)throw new Error("NaN cannot be represented in JSON Schema");break;case"template_literal":{const a=t,n=e._zod.pattern;if(!n)throw new Error("Pattern not found in template literal");a.type="string",a.pattern=n.source;break}case"pipe":{const e="input"===this.io?"transform"===n.in._zod.def.type?n.out:n.in:n.out;this.process(e,a),o.ref=e;break}case"readonly":this.process(n.innerType,a),o.ref=n.innerType,t.readOnly=!0;break;case"lazy":{const t=e._zod.innerType;this.process(t,a),o.ref=t;break}case"custom":if("throw"===this.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")}}}const p=this.metadataRegistry.get(e);p&&Object.assign(o.schema,p),"input"===this.io&&wl(e)&&(delete o.schema.examples,delete o.schema.default),"input"===this.io&&o.schema._prefault&&((a=o.schema).default??(a.default=o.schema._prefault)),delete o.schema._prefault;return this.seen.get(e).schema}emit(e,t){const a={cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0},n=this.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=e=>{const t="draft-2020-12"===this.target?"$defs":"definitions";if(a.external){const n=a.external.registry.get(e[0])?.id,r=a.external.uri??(e=>e);if(n)return{ref:r(n)};const i=e[1].defId??e[1].schema.id??"schema"+this.counter++;return e[1].defId=i,{defId:i,ref:`${r("__shared")}#/${t}/${i}`}}if(e[1]===n)return{ref:"#"};const r=`#/${t}/`,i=e[1].schema.id??"__schema"+this.counter++;return{defId:i,ref:r+i}},i=e=>{if(e[1].schema.$ref)return;const t=e[1],{ref:a,defId:n}=r(e);t.def={...t.schema},n&&(t.defId=n);const i=t.schema;for(const e in i)delete i[e];i.$ref=a};if("throw"===a.cycles)for(const e of this.seen.entries()){const t=e[1];if(t.cycle)throw new Error(`Cycle detected: #/${t.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const t of this.seen.entries()){const n=t[1];if(e===t[0]){i(t);continue}if(a.external){const n=a.external.registry.get(t[0])?.id;if(e!==t[0]&&n){i(t);continue}}const r=this.metadataRegistry.get(t[0])?.id;r?i(t):(n.cycle||n.count>1&&"ref"===a.reused)&&i(t)}const o=(e,t)=>{const a=this.seen.get(e),n=a.def??a.schema,r={...n};if(null===a.ref)return;const i=a.ref;if(a.ref=null,i){o(i,t);const e=this.seen.get(i).schema;e.$ref&&"draft-7"===t.target?(n.allOf=n.allOf??[],n.allOf.push(e)):(Object.assign(n,e),Object.assign(n,r))}a.isParent||this.override({zodSchema:e,jsonSchema:n,path:a.path??[]})};for(const e of[...this.seen.entries()].reverse())o(e[0],{target:this.target});const s={};if("draft-2020-12"===this.target?s.$schema="https://json-schema.org/draft/2020-12/schema":"draft-7"===this.target?s.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),a.external?.uri){const t=a.external.registry.get(e)?.id;if(!t)throw new Error("Schema is missing an `id` property");s.$id=a.external.uri(t)}Object.assign(s,n.def);const p=a.external?.defs??{};for(const e of this.seen.entries()){const t=e[1];t.def&&t.defId&&(p[t.defId]=t.def)}a.external||Object.keys(p).length>0&&("draft-2020-12"===this.target?s.$defs=p:s.definitions=p);try{return JSON.parse(JSON.stringify(s))}catch(e){throw new Error("Error converting schema to JSON.")}}}function wl(e,t){const a=t??{seen:new Set};if(a.seen.has(e))return!1;a.seen.add(e);const n=e._zod.def;switch(n.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":case"custom":case"success":case"catch":return!1;case"array":return wl(n.element,a);case"object":for(const e in n.shape)if(wl(n.shape[e],a))return!0;return!1;case"union":for(const e of n.options)if(wl(e,a))return!0;return!1;case"intersection":return wl(n.left,a)||wl(n.right,a);case"tuple":for(const e of n.items)if(wl(e,a))return!0;return!(!n.rest||!wl(n.rest,a));case"record":case"map":return wl(n.keyType,a)||wl(n.valueType,a);case"set":return wl(n.valueType,a);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":case"default":case"prefault":return wl(n.innerType,a);case"lazy":return wl(n.getter(),a);case"transform":return!0;case"pipe":return wl(n.in,a)||wl(n.out,a)}throw new Error(`Unknown schema type: ${n.type}`)}const Cl=Symbol("Let zodToJsonSchema decide on which parser to use"),Dl={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},Pl=e=>{const t=(e=>"string"==typeof e?{...Dl,name:e}:{...Dl,...e})(e),a=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:a,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,a])=>[a._def,{def:a._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},jl=(e,t)=>{let a=0;for(;a<e.length&&a<t.length&&e[a]===t[a];a++);return[(e.length-a).toString(),...t.slice(a)].join("/")};function kl(e){if("openAi"!==e.target)return{};const t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?jl(t,e.currentPath):t.join("/")}}function Ll(e,t,a,n){n?.errorMessages&&a&&(e.errorMessage={...e.errorMessage,[t]:a})}function Ml(e,t,a,n,r){e[t]=a,Ll(e,t,n,r)}function Gl(e,t){return dd(e.type._def,t)}function xl(e,t,a){const n=a??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((a,n)=>xl(e,t,a))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Fl(e,t)}}const Fl=(e,t)=>{const a={type:"integer",format:"unix-time"};if("openApi3"===t.target)return a;for(const n of e.checks)switch(n.kind){case"min":Ml(a,"minimum",n.value,n.message,t);break;case"max":Ml(a,"maximum",n.value,n.message,t)}return a};let Bl;const zl=/^[cC][^\s-]{8,}$/,Vl=/^[0-9a-z]+$/,$l=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ul=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,Hl=()=>(void 0===Bl&&(Bl=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Bl),Kl=/^(?:(?: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])$/,ql=/^(([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])$/,Wl=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ql=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Yl=/^[a-zA-Z0-9_-]{21}$/,Xl=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function Jl(e,t){const a={type:"string"};if(e.checks)for(const n of e.checks)switch(n.kind){case"min":Ml(a,"minLength","number"==typeof a.minLength?Math.max(a.minLength,n.value):n.value,n.message,t);break;case"max":Ml(a,"maxLength","number"==typeof a.maxLength?Math.min(a.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":td(a,"email",n.message,t);break;case"format:idn-email":td(a,"idn-email",n.message,t);break;case"pattern:zod":ad(a,Ul,n.message,t)}break;case"url":td(a,"uri",n.message,t);break;case"uuid":td(a,"uuid",n.message,t);break;case"regex":ad(a,n.regex,n.message,t);break;case"cuid":ad(a,zl,n.message,t);break;case"cuid2":ad(a,Vl,n.message,t);break;case"startsWith":ad(a,RegExp(`^${Zl(n.value,t)}`),n.message,t);break;case"endsWith":ad(a,RegExp(`${Zl(n.value,t)}$`),n.message,t);break;case"datetime":td(a,"date-time",n.message,t);break;case"date":td(a,"date",n.message,t);break;case"time":td(a,"time",n.message,t);break;case"duration":td(a,"duration",n.message,t);break;case"length":Ml(a,"minLength","number"==typeof a.minLength?Math.max(a.minLength,n.value):n.value,n.message,t),Ml(a,"maxLength","number"==typeof a.maxLength?Math.min(a.maxLength,n.value):n.value,n.message,t);break;case"includes":ad(a,RegExp(Zl(n.value,t)),n.message,t);break;case"ip":"v6"!==n.version&&td(a,"ipv4",n.message,t),"v4"!==n.version&&td(a,"ipv6",n.message,t);break;case"base64url":ad(a,Ql,n.message,t);break;case"jwt":ad(a,Xl,n.message,t);break;case"cidr":"v6"!==n.version&&ad(a,Kl,n.message,t),"v4"!==n.version&&ad(a,ql,n.message,t);break;case"emoji":ad(a,Hl(),n.message,t);break;case"ulid":ad(a,$l,n.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":td(a,"binary",n.message,t);break;case"contentEncoding:base64":Ml(a,"contentEncoding","base64",n.message,t);break;case"pattern:zod":ad(a,Wl,n.message,t)}break;case"nanoid":ad(a,Yl,n.message,t);case"toLowerCase":case"toUpperCase":case"trim":break;default:(()=>{})()}return a}function Zl(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let a=0;a<e.length;a++)ed.has(e[a])||(t+="\\"),t+=e[a];return t}(e):e}const ed=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function td(e,t,a,n){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...a&&n.errorMessages&&{errorMessage:{format:a}}})):Ml(e,"format",t,a,n)}function ad(e,t,a,n){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:nd(t,n),...a&&n.errorMessages&&{errorMessage:{pattern:a}}})):Ml(e,"pattern",nd(t,n),a,n)}function nd(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;const a=e.flags.includes("i"),n=e.flags.includes("m"),r=e.flags.includes("s"),i=a?e.source.toLowerCase():e.source;let o="",s=!1,p=!1,l=!1;for(let e=0;e<i.length;e++)if(s)o+=i[e],s=!1;else{if(a)if(p){if(i[e].match(/[a-z]/)){l?(o+=i[e],o+=`${i[e-2]}-${i[e]}`.toUpperCase(),l=!1):"-"===i[e+1]&&i[e+2]?.match(/[a-z]/)?(o+=i[e],l=!0):o+=`${i[e]}${i[e].toUpperCase()}`;continue}}else if(i[e].match(/[a-z]/)){o+=`[${i[e]}${i[e].toUpperCase()}]`;continue}if(n){if("^"===i[e]){o+="(^|(?<=[\r\n]))";continue}if("$"===i[e]){o+="($|(?=[\r\n]))";continue}}r&&"."===i[e]?o+=p?`${i[e]}\r\n`:`[${i[e]}\r\n]`:(o+=i[e],"\\"===i[e]?s=!0:p&&"]"===i[e]?p=!1:p||"["!==i[e]||(p=!0))}try{new RegExp(o)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return o}function rd(e,t){if("openAi"===t.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===t.target&&e.keyType?._def.typeName===Xt.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((a,n)=>({...a,[n]:dd(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??kl(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};const a={type:"object",additionalProperties:dd(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return a;if(e.keyType?._def.typeName===Xt.ZodString&&e.keyType._def.checks?.length){const{type:n,...r}=Jl(e.keyType._def,t);return{...a,propertyNames:r}}if(e.keyType?._def.typeName===Xt.ZodEnum)return{...a,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===Xt.ZodBranded&&e.keyType._def.type._def.typeName===Xt.ZodString&&e.keyType._def.type._def.checks?.length){const{type:n,...r}=Gl(e.keyType._def,t);return{...a,propertyNames:r}}return a}const id={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};const od=(e,t)=>{const a=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,a)=>dd(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${a}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return a.length?{anyOf:a}:void 0};function sd(e,t){const a="openAi"===t.target,n={type:"object",properties:{}},r=[],i=e.shape();for(const e in i){let o=i[e];if(void 0===o||void 0===o._def)continue;let s=pd(o);s&&a&&("ZodOptional"===o._def.typeName&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);const p=dd(o._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==p&&(n.properties[e]=p,s||r.push(e))}r.length&&(n.required=r);const o=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return dd(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==o&&(n.additionalProperties=o),n}function pd(e){try{return e.isOptional()}catch{return!0}}const ld=(e,t,a)=>{switch(t){case Xt.ZodString:return Jl(e,a);case Xt.ZodNumber:return function(e,t){const a={type:"number"};if(!e.checks)return a;for(const n of e.checks)switch(n.kind){case"int":a.type="integer",Ll(a,"type",n.message,t);break;case"min":"jsonSchema7"===t.target?n.inclusive?Ml(a,"minimum",n.value,n.message,t):Ml(a,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(a.exclusiveMinimum=!0),Ml(a,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?Ml(a,"maximum",n.value,n.message,t):Ml(a,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(a.exclusiveMaximum=!0),Ml(a,"maximum",n.value,n.message,t));break;case"multipleOf":Ml(a,"multipleOf",n.value,n.message,t)}return a}(e,a);case Xt.ZodObject:return sd(e,a);case Xt.ZodBigInt:return function(e,t){const a={type:"integer",format:"int64"};if(!e.checks)return a;for(const n of e.checks)switch(n.kind){case"min":"jsonSchema7"===t.target?n.inclusive?Ml(a,"minimum",n.value,n.message,t):Ml(a,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(a.exclusiveMinimum=!0),Ml(a,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?Ml(a,"maximum",n.value,n.message,t):Ml(a,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(a.exclusiveMaximum=!0),Ml(a,"maximum",n.value,n.message,t));break;case"multipleOf":Ml(a,"multipleOf",n.value,n.message,t)}return a}(e,a);case Xt.ZodBoolean:return{type:"boolean"};case Xt.ZodDate:return xl(e,a);case Xt.ZodUndefined:return function(e){return{not:kl(e)}}(a);case Xt.ZodNull:return function(e){return"openApi3"===e.target?{enum:["null"],nullable:!0}:{type:"null"}}(a);case Xt.ZodArray:return function(e,t){const a={type:"array"};return e.type?._def&&e.type?._def?.typeName!==Xt.ZodAny&&(a.items=dd(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Ml(a,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Ml(a,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Ml(a,"minItems",e.exactLength.value,e.exactLength.message,t),Ml(a,"maxItems",e.exactLength.value,e.exactLength.message,t)),a}(e,a);case Xt.ZodUnion:case Xt.ZodDiscriminatedUnion:return function(e,t){if("openApi3"===t.target)return od(e,t);const a=e.options instanceof Map?Array.from(e.options.values()):e.options;if(a.every(e=>e._def.typeName in id&&(!e._def.checks||!e._def.checks.length))){const e=a.reduce((e,t)=>{const a=id[t._def.typeName];return a&&!e.includes(a)?[...e,a]:e},[]);return{type:e.length>1?e:e[0]}}if(a.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){const e=a.reduce((e,t)=>{const a=typeof t._def.value;switch(a){case"string":case"number":case"boolean":return[...e,a];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===a.length){const t=e.filter((e,t,a)=>a.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:a.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(a.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:a.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return od(e,t)}(e,a);case Xt.ZodIntersection:return function(e,t){const a=[dd(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),dd(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(e=>!!e);let n="jsonSchema2019-09"===t.target?{unevaluatedProperties:!1}:void 0;const r=[];return a.forEach(e=>{if("type"in(t=e)&&"string"===t.type||!("allOf"in t)){let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){const{additionalProperties:a,...n}=e;t=n}else n=void 0;r.push(t)}else r.push(...e.allOf),void 0===e.unevaluatedProperties&&(n=void 0);var t}),r.length?{allOf:r,...n}:void 0}(e,a);case Xt.ZodTuple:return function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,a)=>dd(e._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:dd(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,a)=>dd(e._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])}}(e,a);case Xt.ZodRecord:return rd(e,a);case Xt.ZodLiteral:return function(e,t){const a=typeof e.value;return"bigint"!==a&&"number"!==a&&"boolean"!==a&&"string"!==a?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===t.target?{type:"bigint"===a?"integer":a,enum:[e.value]}:{type:"bigint"===a?"integer":a,const:e.value}}(e,a);case Xt.ZodEnum:return function(e){return{type:"string",enum:Array.from(e.values)}}(e);case Xt.ZodNativeEnum:return function(e){const t=e.values,a=Object.keys(e.values).filter(e=>"number"!=typeof t[t[e]]).map(e=>t[e]),n=Array.from(new Set(a.map(e=>typeof e)));return{type:1===n.length?"string"===n[0]?"string":"number":["string","number"],enum:a}}(e);case Xt.ZodNullable:return function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===t.target?{type:id[e.innerType._def.typeName],nullable:!0}:{type:[id[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){const a=dd(e.innerType._def,{...t,currentPath:[...t.currentPath]});return a&&"$ref"in a?{allOf:[a],nullable:!0}:a&&{...a,nullable:!0}}const a=dd(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return a&&{anyOf:[a,{type:"null"}]}}(e,a);case Xt.ZodOptional:return((e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return dd(e.innerType._def,t);const a=dd(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return a?{anyOf:[{not:kl(t)},a]}:kl(t)})(e,a);case Xt.ZodMap:return function(e,t){return"record"===t.mapStrategy?rd(e,t):{type:"array",maxItems:125,items:{type:"array",items:[dd(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||kl(t),dd(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||kl(t)],minItems:2,maxItems:2}}}(e,a);case Xt.ZodSet:return function(e,t){const a={type:"array",uniqueItems:!0,items:dd(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Ml(a,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Ml(a,"maxItems",e.maxSize.value,e.maxSize.message,t),a}(e,a);case Xt.ZodLazy:return()=>e.getter()._def;case Xt.ZodPromise:return function(e,t){return dd(e.type._def,t)}(e,a);case Xt.ZodNaN:case Xt.ZodNever:return function(e){return"openAi"===e.target?void 0:{not:kl({...e,currentPath:[...e.currentPath,"not"]})}}(a);case Xt.ZodEffects:return function(e,t){return"input"===t.effectStrategy?dd(e.schema._def,t):kl(t)}(e,a);case Xt.ZodAny:return kl(a);case Xt.ZodUnknown:return function(e){return kl(e)}(a);case Xt.ZodDefault:return function(e,t){return{...dd(e.innerType._def,t),default:e.defaultValue()}}(e,a);case Xt.ZodBranded:return Gl(e,a);case Xt.ZodReadonly:case Xt.ZodCatch:return((e,t)=>dd(e.innerType._def,t))(e,a);case Xt.ZodPipeline:return((e,t)=>{if("input"===t.pipeStrategy)return dd(e.in._def,t);if("output"===t.pipeStrategy)return dd(e.out._def,t);const a=dd(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[a,dd(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",a?"1":"0"]})].filter(e=>void 0!==e)}})(e,a);case Xt.ZodFunction:case Xt.ZodVoid:case Xt.ZodSymbol:default:return}};function dd(e,t,a=!1){const n=t.seen.get(e);if(t.override){const r=t.override?.(e,t,n,a);if(r!==Cl)return r}if(n&&!a){const e=ud(n,t);if(void 0!==e)return e}const r={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,r);const i=ld(e,e.typeName,t),o="function"==typeof i?dd(i(),t):i;if(o&&cd(e,t,o),t.postProcess){const a=t.postProcess(o,e,t);return r.jsonSchema=o,a}return r.jsonSchema=o,o}const ud=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:jl(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((e,a)=>t.currentPath[a]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),kl(t)):"seen"===t.$refStrategy?kl(t):void 0}},cd=(e,t,a)=>(e.description&&(a.description=e.description,t.markdownDescription&&(a.markdownDescription=e.description)),a);function md(e,t){var a,n,r,i;return Hr(e)?function(e,t){if(e instanceof Zr){const a=new Il(t),n={};for(const t of e._idmap.entries()){const[e,n]=t;a.process(n)}const r={},i={registry:e,uri:t?.uri,defs:n};for(const n of e._idmap.entries()){const[e,o]=n;r[e]=a.emit(o,{...t,external:i})}if(Object.keys(n).length>0){const e="draft-2020-12"===a.target?"$defs":"definitions";r.__shared={[e]:n}}return{schemas:r}}const a=new Il(t);return a.process(e),a.emit(e,t)}(e,{target:(i=null==t?void 0:t.target,i?"jsonSchema7"===i||"draft-7"===i?"draft-7":"jsonSchema2019-09"===i||"draft-2020-12"===i?"draft-2020-12":"draft-7":"draft-7"),io:null!==(a=null==t?void 0:t.pipeStrategy)&&void 0!==a?a:"input"}):((e,t)=>{const a=Pl(t);let n="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,n])=>({...e,[t]:dd(n._def,{...a,currentPath:[...a.basePath,a.definitionPath,t]},!0)??kl(a)}),{}):void 0;const r="string"==typeof t?t:"title"===t?.nameStrategy?void 0:t?.name,i=dd(e._def,void 0===r?a:{...a,currentPath:[...a.basePath,a.definitionPath,r]},!1)??kl(a),o="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==o&&(i.title=o),a.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[a.openAiAnyTypeName]||(n[a.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===a.$refStrategy?"1":[...a.basePath,a.definitionPath,a.openAiAnyTypeName].join("/")}}));const s=void 0===r?n?{...i,[a.definitionPath]:n}:i:{$ref:[..."relative"===a.$refStrategy?[]:a.basePath,a.definitionPath,r].join("/"),[a.definitionPath]:{...n,[r]:i}};return"jsonSchema7"===a.target?s.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"!==a.target&&"openAi"!==a.target||(s.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===a.target&&("anyOf"in s||"oneOf"in s||"allOf"in s||"type"in s&&Array.isArray(s.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),s})(e,{strictUnions:null===(n=null==t?void 0:t.strictUnions)||void 0===n||n,pipeStrategy:null!==(r=null==t?void 0:t.pipeStrategy)&&void 0!==r?r:"input"})}function fd(e){const t=Qr(e),a=null==t?void 0:t.method;if(!a)throw new Error("Schema is missing a method literal");const n=Jr(a);if("string"!=typeof n)throw new Error("Schema method literal must be a string");return n}function _d(e,t){const a=qr(e,t);if(!a.success)throw a.error;return a.data}class hd{constructor(e){this._options=e,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(fs,e=>{this._oncancel(e)}),this.setNotificationHandler(Ps,e=>{this._onprogress(e)}),this.setRequestHandler(ws,e=>({})),this._taskStore=null==e?void 0:e.taskStore,this._taskMessageQueue=null==e?void 0:e.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Bs,async(e,t)=>{const a=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!a)throw new bl(ls.InvalidParams,"Failed to retrieve task: Task not found");return{...a}}),this.setRequestHandler(Vs,async(e,t)=>{const a=async()=>{var n;const r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if("response"===e.type||"error"===e.type){const t=e.message,a=t.id,n=this._requestResolvers.get(a);if(n)if(this._requestResolvers.delete(a),"response"===e.type)n(t);else{const e=t;n(new bl(e.error.code,e.error.message,e.error.data))}else{const t="response"===e.type?"Response":"Error";this._onerror(new Error(`${t} handler missing for request ${a}`))}continue}await(null===(n=this._transport)||void 0===n?void 0:n.send(e.message,{relatedRequestId:t.requestId}))}}const i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new bl(ls.InvalidParams,`Task not found: ${r}`);if(!Sl(i.status))return await this._waitForTaskUpdate(r,t.signal),await a();if(Sl(i.status)){const e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[$o]:{taskId:r}}}}return await a()};return await a()}),this.setRequestHandler($s,async(e,t)=>{var a;try{const{tasks:n,nextCursor:r}=await this._taskStore.listTasks(null===(a=e.params)||void 0===a?void 0:a.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new bl(ls.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(Hs,async(e,t)=>{try{const a=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!a)throw new bl(ls.InvalidParams,`Task not found: ${e.params.taskId}`);if(Sl(a.status))throw new bl(ls.InvalidParams,`Cannot cancel task in terminal status: ${a.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,"cancelled","Client cancelled task execution.",t.sessionId),this._clearTaskQueue(e.params.taskId);const n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new bl(ls.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...n}}catch(e){if(e instanceof bl)throw e;throw new bl(ls.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){const t=this._requestHandlerAbortControllers.get(e.params.requestId);null==t||t.abort(e.params.reason)}_setupTimeout(e,t,a,n,r=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,t),startTime:Date.now(),timeout:t,maxTotalTimeout:a,resetTimeoutOnProgress:r,onTimeout:n})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const a=Date.now()-t.startTime;if(t.maxTotalTimeout&&a>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),bl.fromError(ls.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:a});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var t,a,n;this._transport=e;const r=null===(t=this.transport)||void 0===t?void 0:t.onclose;this._transport.onclose=()=>{null==r||r(),this._onclose()};const i=null===(a=this.transport)||void 0===a?void 0:a.onerror;this._transport.onerror=e=>{null==i||i(e),this._onerror(e)};const o=null===(n=this._transport)||void 0===n?void 0:n.onmessage;this._transport.onmessage=(e,t)=>{var a;null==o||o(e,t),ps(e)||(a=e,ds.safeParse(a).success)?this._onresponse(e):is(e)?this._onrequest(e,t):(e=>os.safeParse(e).success)(e)?this._onnotification(e):this._onerror(new Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){var e;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();const a=bl.fromError(ls.ConnectionClosed,"Connection closed");this._transport=void 0,null===(e=this.onclose)||void 0===e||e.call(this);for(const e of t.values())e(a)}_onerror(e){var t;null===(t=this.onerror)||void 0===t||t.call(this,e)}_onnotification(e){var t;const a=null!==(t=this._notificationHandlers.get(e.method))&&void 0!==t?t:this.fallbackNotificationHandler;void 0!==a&&Promise.resolve().then(()=>a(e)).catch(e=>this._onerror(new Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){var a,n,r,i,o,s;const p=null!==(a=this._requestHandlers.get(e.method))&&void 0!==a?a:this.fallbackRequestHandler,l=this._transport,d=null===(i=null===(r=null===(n=e.params)||void 0===n?void 0:n._meta)||void 0===r?void 0:r[$o])||void 0===i?void 0:i.taskId;if(void 0===p){const t={jsonrpc:"2.0",id:e.id,error:{code:ls.MethodNotFound,message:"Method not found"}};return void(d&&this._taskMessageQueue?this._enqueueTaskMessage(d,{type:"error",message:t,timestamp:Date.now()},null==l?void 0:l.sessionId).catch(e=>this._onerror(new Error(`Failed to enqueue error response: ${e}`))):null==l||l.send(t).catch(e=>this._onerror(new Error(`Failed to send an error response: ${e}`))))}const u=new AbortController;this._requestHandlerAbortControllers.set(e.id,u);const c=null===(o=e.params)||void 0===o?void 0:o.task,m=this._taskStore?this.requestTaskStore(e,null==l?void 0:l.sessionId):void 0,f={signal:u.signal,sessionId:null==l?void 0:l.sessionId,_meta:null===(s=e.params)||void 0===s?void 0:s._meta,sendNotification:async t=>{const a={relatedRequestId:e.id};d&&(a.relatedTask={taskId:d}),await this.notification(t,a)},sendRequest:async(t,a,n)=>{var r,i;const o={...n,relatedRequestId:e.id};d&&!o.relatedTask&&(o.relatedTask={taskId:d});const s=null!==(i=null===(r=o.relatedTask)||void 0===r?void 0:r.taskId)&&void 0!==i?i:d;return s&&m&&await m.updateTaskStatus(s,"input_required"),await this.request(t,a,o)},authInfo:null==t?void 0:t.authInfo,requestId:e.id,requestInfo:null==t?void 0:t.requestInfo,taskId:d,taskStore:m,taskRequestedTtl:null==c?void 0:c.ttl,closeSSEStream:null==t?void 0:t.closeSSEStream,closeStandaloneSSEStream:null==t?void 0:t.closeStandaloneSSEStream};Promise.resolve().then(()=>{c&&this.assertTaskHandlerCapability(e.method)}).then(()=>p(e,f)).then(async t=>{if(u.signal.aborted)return;const a={result:t,jsonrpc:"2.0",id:e.id};d&&this._taskMessageQueue?await this._enqueueTaskMessage(d,{type:"response",message:a,timestamp:Date.now()},null==l?void 0:l.sessionId):await(null==l?void 0:l.send(a))},async t=>{var a;if(u.signal.aborted)return;const n={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:ls.InternalError,message:null!==(a=t.message)&&void 0!==a?a:"Internal error",...void 0!==t.data&&{data:t.data}}};d&&this._taskMessageQueue?await this._enqueueTaskMessage(d,{type:"error",message:n,timestamp:Date.now()},null==l?void 0:l.sessionId):await(null==l?void 0:l.send(n))}).catch(e=>this._onerror(new Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...a}=e.params,n=Number(t),r=this._progressHandlers.get(n);if(!r)return void this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));const i=this._responseHandlers.get(n),o=this._timeoutInfo.get(n);if(o&&i&&o.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(e){return this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),void i(e)}r(a)}_onresponse(e){const t=Number(e.id),a=this._requestResolvers.get(t);if(a){if(this._requestResolvers.delete(t),ps(e))a(e);else{a(new bl(e.error.code,e.error.message,e.error.data))}return}const n=this._responseHandlers.get(t);if(void 0===n)return void this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));this._responseHandlers.delete(t),this._cleanupTimeout(t);let r=!1;if(ps(e)&&e.result&&"object"==typeof e.result){const a=e.result;if(a.task&&"object"==typeof a.task){const e=a.task;"string"==typeof e.taskId&&(r=!0,this._taskProgressTokens.set(e.taskId,t))}}if(r||this._progressHandlers.delete(t),ps(e))n(e);else{n(bl.fromError(e.error.code,e.error.message,e.error.data))}}get transport(){return this._transport}async close(){var e;await(null===(e=this._transport)||void 0===e?void 0:e.close())}async*requestStream(e,t,a){var n,r,i,o;const{task:s}=null!=a?a:{};if(!s){try{const n=await this.request(e,t,a);yield{type:"result",result:n}}catch(e){yield{type:"error",error:e instanceof bl?e:new bl(ls.InternalError,String(e))}}return}let p;try{const s=await this.request(e,Gs,a);if(!s.task)throw new bl(ls.InternalError,"Task creation did not return a task");for(p=s.task.taskId,yield{type:"taskCreated",task:s.task};;){const e=await this.getTask({taskId:p},a);if(yield{type:"taskStatus",task:e},Sl(e.status)){if("completed"===e.status){const e=await this.getTaskResult({taskId:p},t,a);yield{type:"result",result:e}}else"failed"===e.status?yield{type:"error",error:new bl(ls.InternalError,`Task ${p} failed`)}:"cancelled"===e.status&&(yield{type:"error",error:new bl(ls.InternalError,`Task ${p} was cancelled`)});return}if("input_required"===e.status){const e=await this.getTaskResult({taskId:p},t,a);return void(yield{type:"result",result:e})}const s=null!==(i=null!==(n=e.pollInterval)&&void 0!==n?n:null===(r=this._options)||void 0===r?void 0:r.defaultTaskPollInterval)&&void 0!==i?i:1e3;await new Promise(e=>setTimeout(e,s)),null===(o=null==a?void 0:a.signal)||void 0===o||o.throwIfAborted()}}catch(e){yield{type:"error",error:e instanceof bl?e:new bl(ls.InternalError,String(e))}}}request(e,t,a){const{relatedRequestId:n,resumptionToken:r,onresumptiontoken:i,task:o,relatedTask:s}=null!=a?a:{};return new Promise((p,l)=>{var d,u,c,m,f,_,h;const E=e=>{l(e)};if(!this._transport)return void E(new Error("Not connected"));if(!0===(null===(d=this._options)||void 0===d?void 0:d.enforceStrictCapabilities))try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){return void E(e)}null===(u=null==a?void 0:a.signal)||void 0===u||u.throwIfAborted();const y=this._requestMessageId++,T={...e,jsonrpc:"2.0",id:y};(null==a?void 0:a.onprogress)&&(this._progressHandlers.set(y,a.onprogress),T.params={...e.params,_meta:{...(null===(c=e.params)||void 0===c?void 0:c._meta)||{},progressToken:y}}),o&&(T.params={...T.params,task:o}),s&&(T.params={...T.params,_meta:{...(null===(m=T.params)||void 0===m?void 0:m._meta)||{},[$o]:s}});const R=e=>{var t;this._responseHandlers.delete(y),this._progressHandlers.delete(y),this._cleanupTimeout(y),null===(t=this._transport)||void 0===t||t.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:y,reason:String(e)}},{relatedRequestId:n,resumptionToken:r,onresumptiontoken:i}).catch(e=>this._onerror(new Error(`Failed to send cancellation: ${e}`)));const a=e instanceof bl?e:new bl(ls.RequestTimeout,String(e));l(a)};this._responseHandlers.set(y,e=>{var n;if(!(null===(n=null==a?void 0:a.signal)||void 0===n?void 0:n.aborted)){if(e instanceof Error)return l(e);try{const a=qr(t,e.result);a.success?p(a.data):l(a.error)}catch(e){l(e)}}}),null===(f=null==a?void 0:a.signal)||void 0===f||f.addEventListener("abort",()=>{var e;R(null===(e=null==a?void 0:a.signal)||void 0===e?void 0:e.reason)});const g=null!==(_=null==a?void 0:a.timeout)&&void 0!==_?_:6e4;this._setupTimeout(y,g,null==a?void 0:a.maxTotalTimeout,()=>R(bl.fromError(ls.RequestTimeout,"Request timed out",{timeout:g})),null!==(h=null==a?void 0:a.resetTimeoutOnProgress)&&void 0!==h&&h);const v=null==s?void 0:s.taskId;if(v){const e=e=>{const t=this._responseHandlers.get(y);t?t(e):this._onerror(new Error(`Response handler missing for side-channeled request ${y}`))};this._requestResolvers.set(y,e),this._enqueueTaskMessage(v,{type:"request",message:T,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(y),l(e)})}else this._transport.send(T,{relatedRequestId:n,resumptionToken:r,onresumptiontoken:i}).catch(e=>{this._cleanupTimeout(y),l(e)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},zs,t)}async getTaskResult(e,t,a){return this.request({method:"tasks/result",params:e},t,a)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},Us,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},Ks,t)}async notification(e,t){var a,n,r,i,o;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const s=null===(a=null==t?void 0:t.relatedTask)||void 0===a?void 0:a.taskId;if(s){const a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...(null===(n=e.params)||void 0===n?void 0:n._meta)||{},[$o]:t.relatedTask}}};return void await this._enqueueTaskMessage(s,{type:"notification",message:a,timestamp:Date.now()})}if((null!==(i=null===(r=this._options)||void 0===r?void 0:r.debouncedNotificationMethods)&&void 0!==i?i:[]).includes(e.method)&&!e.params&&!(null==t?void 0:t.relatedRequestId)&&!(null==t?void 0:t.relatedTask)){if(this._pendingDebouncedNotifications.has(e.method))return;return this._pendingDebouncedNotifications.add(e.method),void Promise.resolve().then(()=>{var a,n;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let r={...e,jsonrpc:"2.0"};(null==t?void 0:t.relatedTask)&&(r={...r,params:{...r.params,_meta:{...(null===(a=r.params)||void 0===a?void 0:a._meta)||{},[$o]:t.relatedTask}}}),null===(n=this._transport)||void 0===n||n.send(r,t).catch(e=>this._onerror(e))})}let p={...e,jsonrpc:"2.0"};(null==t?void 0:t.relatedTask)&&(p={...p,params:{...p.params,_meta:{...(null===(o=p.params)||void 0===o?void 0:o._meta)||{},[$o]:t.relatedTask}}}),await this._transport.send(p,t)}setRequestHandler(e,t){const a=fd(e);this.assertRequestHandlerCapability(a),this._requestHandlers.set(a,(a,n)=>{const r=_d(e,a);return Promise.resolve(t(r,n))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const a=fd(e);this._notificationHandlers.set(a,a=>{const n=_d(e,a);return Promise.resolve(t(n))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);void 0!==t&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,a){var n;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const r=null===(n=this._options)||void 0===n?void 0:n.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,a,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const a=await this._taskMessageQueue.dequeueAll(e,t);for(const t of a)if("request"===t.type&&is(t.message)){const a=t.message.id,n=this._requestResolvers.get(a);n?(n(new bl(ls.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(a)):this._onerror(new Error(`Resolver missing for request ${a} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){var a,n,r;let i=null!==(n=null===(a=this._options)||void 0===a?void 0:a.defaultTaskPollInterval)&&void 0!==n?n:1e3;try{const t=await(null===(r=this._taskStore)||void 0===r?void 0:r.getTask(e));(null==t?void 0:t.pollInterval)&&(i=t.pollInterval)}catch(e){}return new Promise((e,a)=>{if(t.aborted)return void a(new bl(ls.InvalidRequest,"Request cancelled"));const n=setTimeout(e,i);t.addEventListener("abort",()=>{clearTimeout(n),a(new bl(ls.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const a=this._taskStore;if(!a)throw new Error("No task store configured");return{createTask:async n=>{if(!e)throw new Error("No request provided");return await a.createTask(n,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{const n=await a.getTask(e,t);if(!n)throw new bl(ls.InvalidParams,"Failed to retrieve task: Task not found");return n},storeTaskResult:async(e,n,r)=>{await a.storeTaskResult(e,n,r,t);const i=await a.getTask(e,t);if(i){const t=Fs.parse({method:"notifications/tasks/status",params:i});await this.notification(t),Sl(i.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>a.getTaskResult(e,t),updateTaskStatus:async(e,n,r)=>{const i=await a.getTask(e,t);if(!i)throw new bl(ls.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(Sl(i.status))throw new bl(ls.InvalidParams,`Cannot update task "${e}" from terminal status "${i.status}" to "${n}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await a.updateTaskStatus(e,n,r,t);const o=await a.getTask(e,t);if(o){const t=Fs.parse({method:"notifications/tasks/status",params:o});await this.notification(t),Sl(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>a.listTasks(e,t)}}}function Ed(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}var yd=c(1601),Td=c(4421);class Rd{constructor(e){this._ajv=null!=e?e:function(){const e=new yd.Ajv({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return Td(e),e}()}getValidator(e){var t;const a="$id"in e&&"string"==typeof e.$id&&null!==(t=this._ajv.getSchema(e.$id))&&void 0!==t?t:this._ajv.compile(e);return e=>a(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(a.errors)}}}class gd{constructor(e){this._server=e}requestStream(e,t,a){return this._server.requestStream(e,t,a)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,a){return this._server.getTaskResult({taskId:e},t,a)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}}class vd extends hd{constructor(e,t){var a,n;super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Fp.options.map((e,t)=>[e,t])),this.isMessageIgnored=(e,t)=>{const a=this._loggingLevels.get(t);return!!a&&this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(a)},this._capabilities=null!==(a=null==t?void 0:t.capabilities)&&void 0!==a?a:{},this._instructions=null==t?void 0:t.instructions,this._jsonSchemaValidator=null!==(n=null==t?void 0:t.jsonSchemaValidator)&&void 0!==n?n:new Rd,this.setRequestHandler(bs,e=>this._oninitialize(e)),this.setNotificationHandler(Is,()=>{var e;return null===(e=this.oninitialized)||void 0===e?void 0:e.call(this)}),this._capabilities.logging&&this.setRequestHandler(zp,async(e,t)=>{var a;const n=t.sessionId||(null===(a=t.requestInfo)||void 0===a?void 0:a.headers["mcp-session-id"])||void 0,{level:r}=e.params,i=Fp.safeParse(r);return i.success&&this._loggingLevels.set(n,i.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new gd(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=function(e,t){const a={...e};for(const e in t){const n=e,r=t[n];if(void 0===r)continue;const i=a[n];Ed(i)&&Ed(r)?a[n]={...i,...r}:a[n]=r}return a}(this._capabilities,e)}setRequestHandler(e,t){var a,n,r;const i=Qr(e),o=null==i?void 0:i.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(Hr(o)){const e=o,t=null===(a=e._zod)||void 0===a?void 0:a.def;s=null!==(n=null==t?void 0:t.value)&&void 0!==n?n:e.value}else{const e=o,t=e._def;s=null!==(r=null==t?void 0:t.value)&&void 0!==r?r:e.value}if("string"!=typeof s)throw new Error("Schema method literal must be a string");if("tools/call"===s){const a=async(e,a)=>{const n=qr(Gp,e);if(!n.success){const e=n.error instanceof Error?n.error.message:String(n.error);throw new bl(ls.InvalidParams,`Invalid tools/call request: ${e}`)}const{params:r}=n.data,i=await Promise.resolve(t(e,a));if(r.task){const e=qr(Gs,i);if(!e.success){const t=e.error instanceof Error?e.error.message:String(e.error);throw new bl(ls.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}const o=qr(Lp,i);if(!o.success){const e=o.error instanceof Error?o.error.message:String(o.error);throw new bl(ls.InvalidParams,`Invalid tools/call result: ${e}`)}return o.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,t)}assertCapabilityForMethod(e){var t,a,n;switch(e){case"sampling/createMessage":if(!(null===(t=this._clientCapabilities)||void 0===t?void 0:t.sampling))throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!(null===(a=this._clientCapabilities)||void 0===a?void 0:a.elicitation))throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!(null===(n=this._clientCapabilities)||void 0===n?void 0:n.roots))throw new Error(`Client does not support listing roots (required for ${e})`)}}assertNotificationCapability(e){var t,a;switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);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 ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!(null===(a=null===(t=this._clientCapabilities)||void 0===t?void 0:t.elicitation)||void 0===a?void 0:a.url))throw new Error(`Client does not support URL elicitation (required for ${e})`)}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);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 ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);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 ${e})`)}}assertTaskCapability(e){var t,a;!function(e,t,a){var n,r;if(!e)throw new Error(`${a} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!(null===(n=e.sampling)||void 0===n?void 0:n.createMessage))throw new Error(`${a} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!(null===(r=e.elicitation)||void 0===r?void 0:r.create))throw new Error(`${a} does not support task creation for elicitation/create (required for ${t})`)}}(null===(a=null===(t=this._clientCapabilities)||void 0===t?void 0:t.tasks)||void 0===a?void 0:a.requests,e,"Client")}assertTaskHandlerCapability(e){var t;this._capabilities&&function(e,t,a){var n;if(!e)throw new Error(`${a} does not support task creation (required for ${t})`);if("tools/call"===t&&!(null===(n=e.tools)||void 0===n?void 0:n.call))throw new Error(`${a} does not support task creation for tools/call (required for ${t})`)}(null===(t=this._capabilities.tasks)||void 0===t?void 0:t.requests,e,"Server")}async _oninitialize(e){const t=e.params.protocolVersion;this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo;return{protocolVersion:Vo.includes(t)?t:zo,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"},cs)}async createMessage(e,t){var a,n;if((e.tools||e.toolChoice)&&!(null===(n=null===(a=this._clientCapabilities)||void 0===a?void 0:a.sampling)||void 0===n?void 0:n.tools))throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){const t=e.messages[e.messages.length-1],a=Array.isArray(t.content)?t.content:[t.content],n=a.some(e=>"tool_result"===e.type),r=e.messages.length>1?e.messages[e.messages.length-2]:void 0,i=r?Array.isArray(r.content)?r.content:[r.content]:[],o=i.some(e=>"tool_use"===e.type);if(n){if(a.some(e=>"tool_result"!==e.type))throw new Error("The last message must contain only tool_result content if any is present");if(!o)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(o){const e=new Set(i.filter(e=>"tool_use"===e.type).map(e=>e.id)),t=new Set(a.filter(e=>"tool_result"===e.type).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},el,t):this.request({method:"sampling/createMessage",params:e},Zp,t)}async elicitInput(e,t){var a,n,r,i,o;switch(null!==(a=e.mode)&&void 0!==a?a:"form"){case"url":{if(!(null===(r=null===(n=this._clientCapabilities)||void 0===n?void 0:n.elicitation)||void 0===r?void 0:r.url))throw new Error("Client does not support url elicitation.");const a=e;return this.request({method:"elicitation/create",params:a},_l,t)}case"form":{if(!(null===(o=null===(i=this._clientCapabilities)||void 0===i?void 0:i.elicitation)||void 0===o?void 0:o.form))throw new Error("Client does not support form elicitation.");const a="form"===e.mode?e:{...e,mode:"form"},n=await this.request({method:"elicitation/create",params:a},_l,t);if("accept"===n.action&&n.content&&a.requestedSchema)try{const e=this._jsonSchemaValidator.getValidator(a.requestedSchema)(n.content);if(!e.valid)throw new bl(ls.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){if(e instanceof bl)throw e;throw new bl(ls.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return n}}}createElicitationCompletionNotifier(e,t){var a,n;if(!(null===(n=null===(a=this._clientCapabilities)||void 0===a?void 0:a.elicitation)||void 0===n?void 0:n.url))throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},t)}async listRoots(e,t){return this.request({method:"roots/list",params:e},Ol,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}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"})}}const Od=Symbol.for("mcp.completable");var Nd;!function(e){e.Completable="McpCompletable"}(Nd||(Nd={}));const bd=/^[A-Za-z0-9._-]{1,128}$/;function Ad(e){const t=function(e){const t=[];if(0===e.length)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!bd.test(e)){const a=e.split("").filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,a)=>a.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${a.map(e=>`"${e}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}(e);return function(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(const e of t)console.warn(` - ${e}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}(e,t.warnings),t.isValid}class Sd{constructor(e){this._mcpServer=e}registerToolTask(e,t,a){const n={taskSupport:"required",...t.execution};if("forbidden"===n.taskSupport)throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,t.title,t.description,t.inputSchema,t.outputSchema,t.annotations,n,t._meta,a)}}class Id{constructor(e,t){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new vd(e,t)}get experimental(){return this._experimental||(this._experimental={tasks:new Sd(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(kd(jp)),this.server.assertCanSetRequestHandler(kd(Gp)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(jp,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{const a={name:e,title:t.title,description:t.description,inputSchema:(()=>{const e=Yr(t.inputSchema);return e?md(e,{strictUnions:!0,pipeStrategy:"input"}):wd})(),annotations:t.annotations,execution:t.execution,_meta:t._meta};if(t.outputSchema){const e=Yr(t.outputSchema);e&&(a.outputSchema=md(e,{strictUnions:!0,pipeStrategy:"output"}))}return a})})),this.server.setRequestHandler(Gp,async(e,t)=>{var a;try{const n=this._registeredTools[e.params.name];if(!n)throw new bl(ls.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new bl(ls.InvalidParams,`Tool ${e.params.name} disabled`);const r=!!e.params.task,i=null===(a=n.execution)||void 0===a?void 0:a.taskSupport,o="createTask"in n.handler;if(("required"===i||"optional"===i)&&!o)throw new bl(ls.InternalError,`Tool ${e.params.name} has taskSupport '${i}' but was not registered with registerToolTask`);if("required"===i&&!r)throw new bl(ls.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if("optional"===i&&!r&&o)return await this.handleAutomaticTaskPolling(n,e,t);const s=await this.validateToolInput(n,e.params.arguments,e.params.name),p=await this.executeToolHandler(n,s,t);return r||await this.validateToolOutput(n,p,e.params.name),p}catch(e){if(e instanceof bl&&e.code===ls.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,t,a){if(!e.inputSchema)return;const n=Yr(e.inputSchema),r=null!=n?n:e.inputSchema,i=await Wr(r,t);if(!i.success){const e=Xr("error"in i?i.error:"Unknown error");throw new bl(ls.InvalidParams,`Input validation error: Invalid arguments for tool ${a}: ${e}`)}return i.data}async validateToolOutput(e,t,a){if(!e.outputSchema)return;if(!("content"in t))return;if(t.isError)return;if(!t.structuredContent)throw new bl(ls.InvalidParams,`Output validation error: Tool ${a} has an output schema but no structured content was provided`);const n=Yr(e.outputSchema),r=await Wr(n,t.structuredContent);if(!r.success){const e=Xr("error"in r?r.error:"Unknown error");throw new bl(ls.InvalidParams,`Output validation error: Invalid structured content for tool ${a}: ${e}`)}}async executeToolHandler(e,t,a){const n=e.handler;if("createTask"in n){if(!a.taskStore)throw new Error("No task store provided.");const r={...a,taskStore:a.taskStore};if(e.inputSchema){const e=n;return await Promise.resolve(e.createTask(t,r))}{const e=n;return await Promise.resolve(e.createTask(r))}}if(e.inputSchema){const e=n;return await Promise.resolve(e(t,a))}{const e=n;return await Promise.resolve(e(a))}}async handleAutomaticTaskPolling(e,t,a){var n;if(!a.taskStore)throw new Error("No task store provided for task-capable tool.");const r=await this.validateToolInput(e,t.params.arguments,t.params.name),i=e.handler,o={...a,taskStore:a.taskStore},s=r?await Promise.resolve(i.createTask(r,o)):await Promise.resolve(i.createTask(o)),p=s.task.taskId;let l=s.task;const d=null!==(n=l.pollInterval)&&void 0!==n?n:5e3;for(;"completed"!==l.status&&"failed"!==l.status&&"cancelled"!==l.status;){await new Promise(e=>setTimeout(e,d));const e=await a.taskStore.getTask(p);if(!e)throw new bl(ls.InternalError,`Task ${p} not found during polling`);l=e}return await a.taskStore.getTaskResult(p)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(kd(Tl)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Tl,async e=>{switch(e.params.ref.type){case"ref/prompt":return function(e){if("ref/prompt"!==e.params.ref.type)throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return function(e){if("ref/resource"!==e.params.ref.type)throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}(e),this.handleResourceCompletion(e,e.params.ref);default:throw new bl(ls.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){const a=this._registeredPrompts[t.name];if(!a)throw new bl(ls.InvalidParams,`Prompt ${t.name} not found`);if(!a.enabled)throw new bl(ls.InvalidParams,`Prompt ${t.name} disabled`);if(!a.argsSchema)return Md;const n=Qr(a.argsSchema),r=null==n?void 0:n[e.params.argument.name];if(!function(e){return!!e&&"object"==typeof e&&Od in e}(r))return Md;const i=function(e){const t=e[Od];return null==t?void 0:t.complete}(r);if(!i)return Md;return Ld(await i(e.params.argument.value,e.params.context))}async handleResourceCompletion(e,t){const a=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!a){if(this._registeredResources[t.uri])return Md;throw new bl(ls.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}const n=a.resourceTemplate.completeCallback(e.params.argument.name);if(!n)return Md;return Ld(await n(e.params.argument.value,e.params.context))}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(kd(ep)),this.server.assertCanSetRequestHandler(kd(ap)),this.server.assertCanSetRequestHandler(kd(op)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(ep,async(e,t)=>{const a=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),n=[];for(const e of Object.values(this._registeredResourceTemplates)){if(!e.resourceTemplate.listCallback)continue;const a=await e.resourceTemplate.listCallback(t);for(const t of a.resources)n.push({...e.metadata,...t})}return{resources:[...a,...n]}}),this.server.setRequestHandler(ap,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler(op,async(e,t)=>{const a=new URL(e.params.uri),n=this._registeredResources[a.toString()];if(n){if(!n.enabled)throw new bl(ls.InvalidParams,`Resource ${a} disabled`);return n.readCallback(a,t)}for(const e of Object.values(this._registeredResourceTemplates)){const n=e.resourceTemplate.uriTemplate.match(a.toString());if(n)return e.readCallback(a,n,t)}throw new bl(ls.InvalidParams,`Resource ${a} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(kd(Ep)),this.server.assertCanSetRequestHandler(kd(Rp)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Ep,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?jd(t.argsSchema):void 0}))})),this.server.setRequestHandler(Rp,async(e,t)=>{const a=this._registeredPrompts[e.params.name];if(!a)throw new bl(ls.InvalidParams,`Prompt ${e.params.name} not found`);if(!a.enabled)throw new bl(ls.InvalidParams,`Prompt ${e.params.name} disabled`);if(a.argsSchema){const n=Yr(a.argsSchema),r=await Wr(n,e.params.arguments);if(!r.success){const t=Xr("error"in r?r.error:"Unknown error");throw new bl(ls.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${t}`)}const i=r.data,o=a.callback;return await Promise.resolve(o(i,t))}{const e=a.callback;return await Promise.resolve(e(t))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0)}resource(e,t,...a){let n;"object"==typeof a[0]&&(n=a.shift());const r=a[0];if("string"==typeof t){if(this._registeredResources[t])throw new Error(`Resource ${t} is already registered`);const a=this._createRegisteredResource(e,void 0,t,n,r);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const a=this._createRegisteredResourceTemplate(e,void 0,t,n,r);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}}registerResource(e,t,a,n){if("string"==typeof t){if(this._registeredResources[t])throw new Error(`Resource ${t} is already registered`);const r=this._createRegisteredResource(e,a.title,t,a,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),r}{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const r=this._createRegisteredResourceTemplate(e,a.title,t,a,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),r}}_createRegisteredResource(e,t,a,n,r){const i={name:e,title:t,metadata:n,readCallback:r,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:e=>{void 0!==e.uri&&e.uri!==a&&(delete this._registeredResources[a],e.uri&&(this._registeredResources[e.uri]=i)),void 0!==e.name&&(i.name=e.name),void 0!==e.title&&(i.title=e.title),void 0!==e.metadata&&(i.metadata=e.metadata),void 0!==e.callback&&(i.readCallback=e.callback),void 0!==e.enabled&&(i.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[a]=i,i}_createRegisteredResourceTemplate(e,t,a,n,r){const i={resourceTemplate:a,title:t,metadata:n,readCallback:r,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=i)),void 0!==t.title&&(i.title=t.title),void 0!==t.template&&(i.resourceTemplate=t.template),void 0!==t.metadata&&(i.metadata=t.metadata),void 0!==t.callback&&(i.readCallback=t.callback),void 0!==t.enabled&&(i.enabled=t.enabled),this.sendResourceListChanged()}};return this._registeredResourceTemplates[e]=i,i}_createRegisteredPrompt(e,t,a,n,r){const i={title:t,description:a,argsSchema:void 0===n?void 0:Kr(n),callback:r,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=i)),void 0!==t.title&&(i.title=t.title),void 0!==t.description&&(i.description=t.description),void 0!==t.argsSchema&&(i.argsSchema=Kr(t.argsSchema)),void 0!==t.callback&&(i.callback=t.callback),void 0!==t.enabled&&(i.enabled=t.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,i}_createRegisteredTool(e,t,a,n,r,i,o,s,p){Ad(e);const l={title:t,description:a,inputSchema:Pd(n),outputSchema:Pd(r),annotations:i,execution:o,_meta:s,handler:p,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&("string"==typeof t.name&&Ad(t.name),delete this._registeredTools[e],t.name&&(this._registeredTools[t.name]=l)),void 0!==t.title&&(l.title=t.title),void 0!==t.description&&(l.description=t.description),void 0!==t.paramsSchema&&(l.inputSchema=Kr(t.paramsSchema)),void 0!==t.callback&&(l.handler=t.callback),void 0!==t.annotations&&(l.annotations=t.annotations),void 0!==t._meta&&(l._meta=t._meta),void 0!==t.enabled&&(l.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...t){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let a,n,r;if("string"==typeof t[0]&&(a=t.shift()),t.length>1){const e=t[0];Dd(e)?(n=t.shift(),t.length>1&&"object"==typeof t[0]&&null!==t[0]&&!Dd(t[0])&&(r=t.shift())):"object"==typeof e&&null!==e&&(r=t.shift())}const i=t[0];return this._createRegisteredTool(e,void 0,a,n,undefined,r,{taskSupport:"forbidden"},void 0,i)}registerTool(e,t,a){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);const{title:n,description:r,inputSchema:i,outputSchema:o,annotations:s,_meta:p}=t;return this._createRegisteredTool(e,n,r,i,o,s,{taskSupport:"forbidden"},p,a)}prompt(e,...t){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let a,n;"string"==typeof t[0]&&(a=t.shift()),t.length>1&&(n=t.shift());const r=t[0],i=this._createRegisteredPrompt(e,void 0,a,n,r);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}registerPrompt(e,t,a){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);const{title:n,description:r,argsSchema:i}=t,o=this._createRegisteredPrompt(e,n,r,i,a);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}isConnected(){return void 0!==this.server.transport}async sendLoggingMessage(e,t){return this.server.sendLoggingMessage(e,t)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}}const wd={type:"object",properties:{}};function Cd(e){return null!==e&&"object"==typeof e&&"parse"in e&&"function"==typeof e.parse&&"safeParse"in e&&"function"==typeof e.safeParse}function Dd(e){return"object"==typeof e&&null!==e&&(!function(e){return"_def"in e||"_zod"in e||Cd(e)}(e)&&(0===Object.keys(e).length||Object.values(e).some(Cd)))}function Pd(e){if(e)return Dd(e)?Kr(e):e}function jd(e){const t=Qr(e);return t?Object.entries(t).map(([e,t])=>{const a=function(e){var t,a,n,r;if(Hr(e))return null===(a=null===(t=e._zod)||void 0===t?void 0:t.def)||void 0===a?void 0:a.description;const i=e;return null!==(n=e.description)&&void 0!==n?n:null===(r=i._def)||void 0===r?void 0:r.description}(t),n=function(e){var t,a,n;if(Hr(e))return"optional"===(null===(a=null===(t=e._zod)||void 0===t?void 0:t.def)||void 0===a?void 0:a.type);const r=e;return"function"==typeof e.isOptional?e.isOptional():"ZodOptional"===(null===(n=r._def)||void 0===n?void 0:n.typeName)}(t);return{name:e,description:a,required:!n}}):[]}function kd(e){const t=Qr(e),a=null==t?void 0:t.method;if(!a)throw new Error("Schema is missing a method literal");const n=Jr(a);if("string"==typeof n)return n;throw new Error("Schema method literal must be a string")}function Ld(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}const Md={completion:{values:[],hasMore:!1}};var Gd=c(1708);class xd{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;const e=this._buffer.indexOf("\n");if(-1===e)return null;const t=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),function(e){return us.parse(JSON.parse(e))}(t)}clear(){this._buffer=void 0}}class Fd{constructor(e=Gd.stdin,t=Gd.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new xd,this._started=!1,this._ondata=e=>{this._readBuffer.append(e),this.processReadBuffer()},this._onerror=e=>{var t;null===(t=this.onerror)||void 0===t||t.call(this,e)}}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(var e,t;;)try{const t=this._readBuffer.readMessage();if(null===t)break;null===(e=this.onmessage)||void 0===e||e.call(this,t)}catch(e){null===(t=this.onerror)||void 0===t||t.call(this,e)}}async close(){var e;this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror);0===this._stdin.listenerCount("data")&&this._stdin.pause(),this._readBuffer.clear(),null===(e=this.onclose)||void 0===e||e.call(this)}send(e){return new Promise(t=>{const a=function(e){return JSON.stringify(e)+"\n"}(e);this._stdout.write(a)?t():this._stdout.once("drain",t)})}}var Bd={info:"info",manage_signature:"sign",query_application:"qa",query_device:"qd",query_device_group:"qdg",query_module:"qm",query_activity_log:"qal",create_application:"ca",create_device:"cd",create_device_group:"cdg",create_module:"cm",update_application:"ua",bind_application:"ba",short_edit_application:"uas",canvas_control_application:"uacc",update_device:"ud",update_device_group:"udg",update_module:"um",short_edit_module:"ums",remove_application:"ra",remove_device:"rd",remove_device_group:"rdg",remove_module:"rm",control_device:"ctld",control_application_device:"ctlad",control_device_group:"ctldg",query_media_flow:"qmf",write_media_flow:"wmf",access_unstable_feature:"UNSTABLE"},zd=Object.entries(Bd).reduce(function(e,t){var a=X(t,2),n=a[0];return e[a[1]]=n,e},{}),Vd=["HS256","RS256"],$d=["https://auth0.bricks.tools/","https://mybigday.auth0.com/"];function Ud(e){try{var t,a,n=null==(t=e.queryStringParameters)?void 0:t.token;if(!n)n=null==(a=new Headers(e.headers).get("authorization"))?void 0:a.replace("Bearer ","");if(!n)return{success:!1,message:"Authentication failed: No token provided"};var r=function(e){try{var t=e.split(".");if(t.length<3)return null;var a=JSON.parse(Buffer.from(t[0],"base64url").toString());return Vd.includes(null==a?void 0:a.alg)?JSON.parse(Buffer.from(t[1],"base64url").toString()):null}catch(e){return null}}(n);if(!r)return{success:!1,message:"Authentication failed: Invalid token"};var i=$d.includes(r.iss)?"user":"workspace";if("workspace"===i){var o=Array.isArray(r.t)?r.t:[];r.permissions=o.map(function(e){return zd[e]}).filter(Boolean)}else r.permissions=Object.keys(Bd);return{success:!0,token:n,tokenInfo:r,tokenType:i}}catch(e){return{success:!1,message:`Authentication failed: ${e.message}`}}}const Hd='# Getting Started with BRICKS\n\nBRICKS (方塊磚) is a comprehensive platform for creating interactive multimedia display applications specifically designed for digital signage screens. It enables users to design complete applications without programming, using a visual, component-based approach.\n\n**Important**: Users interact through a visual GUI editor, not raw configuration files. Always describe features in user-friendly terms:\n- "text display" not "BRICK_TEXT"\n- "image" not "BRICK_IMAGE"\n- "canvas name" not "CANVAS_xxx"\n- "data storage" not "PROPERTY_BANK"\n- Focus on what users see and do, not technical implementation details\n\n## Core Philosophy\n\nBRICKS operates as a **Launcher system** that reads configuration files from the cloud (or cached locally) and must maintain normal operation even when offline. The system periodically reports health status and supports watchdog timers for automatic restart or maintenance mode activation.\n\n## Fundamental Architecture\n\n### The Three Core Elements\n\n#### 1. Canvas (畫布)\n- **Definition**: The visual container that defines what users see on screen\n- **Behavior**: Screen transitions occur by switching between different canvases\n- **Smart Transitions**: When switching canvases, BRICKS automatically compares shared elements and smoothly animates their position/size changes\n- **Properties**:\n - `Showing Timeout`: Auto-advance to next canvas after specified time\n - `Next Canvas ID`: Target canvas for timeout transitions\n - `Background Color`: Canvas background\n - `Dismiss Keyboard On Press`: Touch behavior for keyboard dismissal\n- **Events**: `CANVAS_FIRST_ENTER`, `CANVAS_ENTER`, `CANVAS_SHOWING_TIMEOUT`, `CANVAS_EXIT`\n\n#### 2. Brick (方塊)\n- **Definition**: Visual components that display content and handle user interactions\n- **Animation System**: All bricks support three animation phases:\n - **Enter Animation**: How the brick appears on screen\n - **Display Animation**: Ongoing animations while visible\n - **Exit Animation**: How the brick disappears\n- **Positioning**: Uses grid-based positioning system for resolution independence\n- **Interaction**: Can respond to touch events and trigger system actions\n\nAvailable template:\n[:BRICK_IDS:]\n\n#### 3. Generator (處理器)\n- **Definition**: Invisible processing units that handle non-visual functionality\n- **Purpose**: Handle hardware interactions (camera, sensors), data processing, network communication\n- **Input**: Receives parameters exclusively through Property Bank\n- **Output**: Returns results exclusively through Property Bank\n- **Triggers**: Activated by Events connected to their Actions\n\nAvailable template:\n[:GENERATOR_IDS:]\n\n### Data (Property Bank, 參數庫)\nThe central data management system that serves as the backbone of BRICKS applications:\n\n#### Key Features\n- **KEY-VALUE Structure**: Simple, accessible data storage\n- **Dual Events**: Each property supports both "Update" and "Value Change" events\n- **Auto-Refresh**: UI elements automatically update when linked data changes\n- **Cross-Subspace Communication**: Properties can be shared between different subspaces\n- **Data Types**: `string`, `number`, `bool`, `object`, `array`, `any`\n- **Special Kinds**: `color`, `datetime`, `id`, `media-resource-*`, `lottie-file-uri`\n- **Units**: `grid`, `px`, `ms` for different measurement types\n\n#### Routing Options\n- **read-only**: Cannot be changed from other subspaces\n- **Default**: Accepts changes from other subspaces\n\nTerminology note: We refer to the central data system as "Data" in docs and UI. Internally, it remains "Property Bank" and uses `PROPERTY_BANK_*` identifiers.\n\n### Event System\nBRICKS uses a comprehensive event-driven architecture:\n\n#### Event Sources\n- **System Events**: Property Bank changes, timer events, canvas transitions\n- **Brick Events**: User interactions (press, focus, value changes)\n- **Generator Events**: Hardware responses, network callbacks, processing completions\n\n#### Event Handling\n- **Sequential Processing**: Events trigger Actions in defined order\n- **Parameter Passing**: All parameters passed through Property Bank\n- **Action Types**: System actions or Generator actions\n\n### Subspace (子空間)\nAdvanced modularity system for complex applications:\n\n#### Concept\n- **Nested Systems**: Complete BRICKS system within a brick\n- **Independent Operation**: Own canvases, bricks, and property banks\n- **Modular Behavior**: Can be positioned, scaled, and animated like regular bricks\n\n#### Communication\n- **Input**: External Property Bank values copied to internal Property Bank\n- **Output**: Internal Property Bank changes trigger external events\n- **Data Flow**: Call-by-value copying maintains isolation while enabling communication\n\n## Grid System\n\n### Resolution Independence\n- **Default Grid**: 96×54 units (optimized for HD displays)\n- **Automatic Scaling**: Grid units convert to pixels based on device resolution\n- **Calculation**: `grid_unit_size_px = device_width_px / app_grid_width`\n\n### Examples\n| Device Resolution | App Grid Size | Grid Unit Size |\n|------------------|---------------|----------------|\n| 1920×1080 | 96×54 | 20px |\n| 3840×2160 | 96×54 | 40px |\n| 1280×720 | 96×54 | 13.33px |\n\n### Positioning Features\n- **Overflow Support**: Elements can extend beyond visible area\n- **Partial Display**: Elements at negative positions show partial content\n- **Performance Optimization**: Completely off-screen elements are automatically ignored\n\n## Configuration Structure\n\n### Hierarchy\n```\nApplication (應用程式)\n├── Root Subspace\n├── Subspace Map\n│ ├── Canvas Map\n│ ├── Brick Map\n│ └── Generator Map\n├── Property Bank\n├── Property Bank Calc\n├── Event Map\n└── Automation Map\n```\n\n### Item property\nProperties can set constant value or link data like this\n\n```js\n{\n "example1": 123,\n "example2": "PROPERTY_BANK#<Data Node ID>", // Link Data\n "example3": {\n "PROPERTY_BANK#<Data Node ID>", // Link Data in object, we recommend direct link without middle object data\n }\n}\n```\n\n### Item outlet\nData output from brick or generator, you can link it to data\n\n```js\n{\n OUTLET_NAME: \'<Data Node ID>\'\n}\n```\n\n### Event actions\nOn handling event can do actions with this schema\n\n```js\n[\n {\n "action": "string",\n "handler": "string",\n "parameter_list": [\n {\n "input_to_receiver": "string", // Argument\n "result_from_sender": "string" // Link data\n }\n ],\n "wait_async": "boolean"\n }\n]\n```\n\n- `handler: SYSTEM`\n[:SYSTEM_ACTIONS:]\n- `handler: GENERATOR_<UUID>`\n- `handler: BRICK_<UUID>`\n\n## Development Workflow\n\n### 1. Design Phase\n- Define grid layout (usually 96×54)\n- Plan canvas flow and transitions\n- Identify required data flows\n\n### 2. Implementation\n- Use `create_item` to constuct config\n- Create subspaces for different app sections\n- Add canvases for each screen/state\n- Place and configure bricks for UI elements\n- Add generators for processing logic\n- Connect events to actions\n\n### 3. Data Management\n- Set up Property Bank structure\n- Configure property types and routing\n- Link UI elements to data sources\n- Implement data processing flows\n\n#### Mental Model\n- Reactive architecture: events trigger actions; actions update Data; UI and generators react to Data changes.\n- Calculations: optional graphs transform Data using Data Calculation (command/data nodes or script).\n- Always read/write via Data. Generators receive input from Data and write outputs back to Data.\n\n#### Common Patterns\n- Event → Action → Data update or Outlet → Data update\n- Data change → Triggers downstream calculations → Updates target Data\n- Cross-subspace routing: respect `read-only` vs `default`\n\n### 4. Testing & Deployment\n- Use automation maps for testing\n- Validate configuration schema\n- Deploy to target devices\n- Monitor system health\n\n## Best Practices\n\n### Performance\n- Use 96×54 grid for standard content\n- Minimize off-screen elements\n- Optimize property bank access patterns\n- Cache media resources appropriately\n\n### User Experience\n- Always use enter/exit animations (avoid sudden appearances)\n- Maintain consistent transition timing\n- Design for offline operation\n- Implement proper error handling\n\n### Architecture\n- Keep subspaces focused and modular\n- Use generators for all non-visual processing\n- Minimize cross-subspace dependencies\n- Design for reusability through modules\n\n## Network & Offline Behavior\n\n### Online Operation\n- Configuration sync from cloud\n- Media resource loading\n- Real-time data updates\n- Health status reporting\n\n### Offline Requirements\n- **Display Continuity**: All display and reading functions must work offline\n- **Data Caching**: Write operations cached locally and synced when online\n- **Resource Management**: Media and assets preloaded during online periods\n- **Graceful Degradation**: Non-essential features disabled, core functionality maintained\n\nThis comprehensive foundation enables the creation of sophisticated, interactive digital signage applications that are both powerful and maintainable.\n\n## Local Sync\n\nLocal Sync enables near real-time intranet communication between devices for seamless multi-screen display splicing.\n\n- Data Sync: Synchronize selected data (Property Bank/Data nodes) across devices so UI updates remain consistent.\n- Canvas Sync: Optionally synchronize active canvas to orchestrate state transitions across screens.\n- Typical Use: Video walls, tiled displays, or clustered players that must behave as one.\n- Transport: LAN/intranet only; optimized for low latency and reliability inside the local network.\n- Resilience: Designed to tolerate temporary disconnections; devices rejoin and resynchronize state.\n\nConfiguration hints (high level):\n- Subspaces can define local sync behavior (e.g., whether to sync canvas changes).\n- Generators may opt into specific local sync run modes.\n- Keep payloads small and data normalized for best performance.';var Kd=c(181),qd=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{content:[Kd.Buffer.isBuffer(e)?Object.assign({},t,{blob:e.toString("base64"),type:"blob"}):Object.assign({},t,{text:"string"==typeof e?e:JSON.stringify(e,null,2),type:"text"})],isError:!1}};var Wd=c(8212),Qd=c(1313);const Yd=t("node:net"),Xd=t("node:http"),Jd=t("node:https");var Zd=c(8875);const eu=t("node:dns"),tu={allowPrivateIPAddress:!1,allowMetaIPAddress:!1,allowIPAddressList:[],denyIPAddressList:[]},au=({address:e,host:t,family:a},n)=>{if(0!==Yd.isIP(e))try{const r=Zd.parse(e).range();if(n.allowIPAddressList.length>0&&n.allowIPAddressList.includes(e))return;if(!n.allowMetaIPAddress&&"unspecified"===r)return new Error(`DNS lookup ${e}(family:${a}, host:${t}) is not allowed. Because, It is meta IP address.`);if(!n.allowPrivateIPAddress&&"unicast"!==r)return new Error(`DNS lookup ${e}(family:${a}, host:${t}) is not allowed. Because, It is private IP address.`);if(n.denyIPAddressList.length>0&&n.denyIPAddressList.includes(e))return new Error(`DNS lookup ${e}(family:${a}, host:${t}) is not allowed. Because It is defined in denyIPAddressList.`)}catch(e){return e}},nu=(e,t)=>(a,n,r)=>{const i=e.lookup||eu.lookup;let o;o=n.all?(e,n)=>{if(e)r(e);else{for(const{address:e,family:i}of n){const n=au({address:e,family:i,host:a},t);if(n)return void r(n)}r(null,n)}}:(e,n,i)=>{if(e)return void r(e);const o=au({address:n,family:i,host:a},t);o?r(o):r(null,n,i)},i(a,n,o)};class ru extends Xd.Agent{requestFilterOptions;constructor(e){super(e),this.requestFilterOptions={allowPrivateIPAddress:e&&void 0!==e.allowPrivateIPAddress?e.allowPrivateIPAddress:tu.allowPrivateIPAddress,allowMetaIPAddress:e&&void 0!==e.allowMetaIPAddress?e.allowMetaIPAddress:tu.allowMetaIPAddress,allowIPAddressList:e&&e.allowIPAddressList?e.allowIPAddressList:tu.allowIPAddressList,denyIPAddressList:e&&e.denyIPAddressList?e.denyIPAddressList:tu.denyIPAddressList}}createConnection(e,t){const{host:a}=e;if(void 0!==a){const e=au({address:a},this.requestFilterOptions);if(e)throw e}return super.createConnection({...e,lookup:nu(e,this.requestFilterOptions)},t)}}class iu extends Jd.Agent{requestFilterOptions;constructor(e){super(e),this.requestFilterOptions={allowPrivateIPAddress:!(!e||void 0===e.allowPrivateIPAddress)&&e.allowPrivateIPAddress,allowMetaIPAddress:!(!e||void 0===e.allowMetaIPAddress)&&e.allowMetaIPAddress,allowIPAddressList:e&&e.allowIPAddressList?e.allowIPAddressList:[],denyIPAddressList:e&&e.denyIPAddressList?e.denyIPAddressList:[]}}createConnection(e,t){const{host:a}=e;if(void 0!==a){const e=au({address:a},this.requestFilterOptions);if(e)throw e}return super.createConnection({...e,lookup:nu(e,this.requestFilterOptions)},t)}}const ou=new ru,su=new iu,pu=(e,t)=>t?e.startsWith("https")?new iu(t):new ru(t):e.startsWith("https")?su:ou;var lu=c(6123),du=c(211),uu=c(5907),cu=c(6502),mu=c.n(cu),fu=c(5838);function _u(){return _u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},_u.apply(this,arguments)}var hu={enum:1,type:0},Eu=/"/g,yu=/NOT/g,Tu=/\//g,Ru=function(e){var t=e.value,a=e.suggestions,n=e.format,r=void 0===n?function(e){return"Did you mean '"+e+"'?"}:n;if(!t)return"";var i=a.reduce(function(e,a){var n=mu()(t,a);return e.distance>n?{value:a,distance:n}:e},{distance:1/0,value:""});return i.distance<t.length?r(i.value):""},gu=function(e){return e.split("/").pop()},vu=function(e){var t=e.object,a=e.pnter,n=e.fallback;try{return fu.get(t,a)}catch(e){return n}},Ou=function(e){var t=e.errors,a=e.data,n=e.schema,r=e.basePath,i=void 0===r?"{base}":r;if(!Array.isArray(t)||0===t.length)return[];var o=function(e){var t=e.reduce(function(e,t){var a,n,r,i,o,s,p=t.instancePath+(null!=(a=null!=(n=null==(r=t.params)?void 0:r.additionalProperty)?n:null==(i=t.params)?void 0:i.missingProperty)?a:""),l=e[p];return l?((null!=(o=hu[t.keyword])?o:0)>(null!=(s=hu[l.keyword])?s:0)&&(e[p]=t),e):(e[p]=t,e)},{});return Object.values(t)}(t);return o.map(function(e){var t,r=(i+e.instancePath).replace(Tu,"."),o=gu(e.instancePath),s={errorType:e.keyword},p=(o?"property '"+o+"'":r)+" "+e.message.replace(Eu,"'").replace(yu,"not");switch(e.keyword){case"additionalProperties":var l=e.params.additionalProperty,d=e.schemaPath.replace("#","").replace("/additionalProperties",""),u=vu({object:n,pnter:d,fallback:{properties:{}}}).properties;t={message:"'"+l+"' property is not expected to be here",suggestion:Ru({value:l,suggestions:Object.keys(null!=u?u:{}),format:function(e){return"Did you mean property '"+e+"'?"}}),path:r,context:s};break;case"enum":var c=e.params.allowedValues.map(function(e){return e.toString()}),m=gu(e.instancePath),f=vu({object:a,pnter:e.instancePath,fallback:""});t={message:"'"+m+"' property must be equal to one of the allowed values",suggestion:Ru({value:f,suggestions:c}),path:r,context:_u({},s,{allowedValues:e.params.allowedValues})};break;case"type":t={message:"'"+gu(e.instancePath)+"' property type must be "+e.params.type,path:r,context:s};break;case"required":t={message:r+" must have required property '"+e.params.missingProperty+"'",path:r,context:s};break;case"const":return{message:"'"+o+"' property must be equal to the allowed value",path:r,context:_u({},s,{allowedValue:e.params.allowedValue})};default:return{message:p,path:r,context:s}}for(var _=0,h=Object.entries(t);_<h.length;_++){var E=h[_],y=E[0],T=E[1];null!=T&&""!==T||delete t[y]}return t})};const Nu=(e,t="Internal Logic Error")=>{if(!e)throw new Error("function"==typeof t?t():t)};class bu{constructor(e,t){this.value=e,this.excluded=t,this.isSimpleStarRec="**"===e,this.isRegexStarRec=e.startsWith("**(")&&e.endsWith(")"),this.isStarRec=this.isSimpleStarRec||this.isRegexStarRec}}class Au{constructor(e,t=null){this.left=null===t,this.link=null===t?new Au(e,this):t,this.type=e,this.isStarRec="**"===this.type,this.node=null,this.pointer=null}setPointer(e){this.pointer=e,this.link.pointer=e}setNode(e){this.node=e,this.link.node=e}}const Su=(e,t,a={})=>{throw new Error(Object.entries(a).reduce((e,[t,a])=>`${e}, ${t} ${a}`,`${e}: ${t}`))},Iu=e=>1===e.length?e[0]:e,wu=/^[?*+\d]+$/,Cu=(e,t,a={})=>{throw new Error(Object.entries(a).reduce((e,[t,a])=>`${e}, ${t} ${a}`,`${e}: ${t}`))},Du=(e,t)=>{if(""===e)return new bu("",!1);if(Array.isArray(e))return 0===e.length?new bu("",!1):e.map((a,n)=>"number"==typeof a?(t.useArraySelector||Cu("Forbidden Array Selector",JSON.stringify(e),{idx:n}),new bu(`[${a}]`,!1)):new bu(a.replaceAll("\\","\\\\"),!1));const a=(e=>{let t=[];t.or=!0;let a=!1,n=!1,r=0;const i=[],o=e=>{!0===t.excluded&&(Nu(!1===n),n=!0),i.push(t),t=[],t.or=e},s=()=>{const e=i.pop(),a=Iu(t);!0===e.or&&!0===a.or?e.push(...a):e.push(a),t=e};return o(!1),{setInArray:(t,n)=>{a===t&&Su(a?"Bad Array Start":"Bad Array Terminator",e,{char:n}),a=t},finishElement:(i,o,s,{finReq:p=!1,group:l=!1}={})=>{if(r===i)s.includes(e[i-1]||null)||Su(o,e,{char:i}),r+=1;else{p&&Su(o,e,{char:i});const s=e.slice(r,i);l&&!["**","++"].includes(s)&&Su("Bad Group Start",e,{char:i}),a&&!(wu.test(s)||s.startsWith("(")&&s.endsWith(")"))&&Su("Bad Array Selector",e,{selector:s}),l?t.push(new Au(s)):(t.push(new bu(a?`[${s}]`:s,n)),n=!1),r=i+1}},startExclusion:t=>{!1!==n&&Su("Redundant Exclusion",e,{char:t}),n=!0},startGroup:()=>{o(!0),n&&(t.excluded=!0,n=!1),o(!1)},newGroupElement:()=>{s(),o(!1)},finishGroup:a=>{i.length<2&&Su("Unexpected Group Terminator",e,{char:a}),s(),s(),Nu(Array.isArray(t));const n=t[t.length-2];n instanceof Au&&!0===n.left&&t.push(n.link)},finalizeResult:()=>(s(),Nu(!1===n),0!==i.length&&Su("Non Terminated Group",e),a&&Su("Non Terminated Array",e),Iu(t))}})(e),n=e.length;let r=!1,i=0;for(let o=0;o<n;o+=1){const n=e[o];if(!1===r){if(0===i)switch(n){case".":a.finishElement(o,"Bad Path Separator",["]","}"]);break;case"[":t.useArraySelector||Cu("Forbidden Array Selector",e,{char:o}),a.finishElement(o,"Bad Array Start",[null,"!","{",",","}","]"]),a.setInArray(!0,o);break;case"]":a.finishElement(o,"Bad Array Terminator",["}"]),a.setInArray(!1,o);break;case"{":a.finishElement(o,"Bad Group Start",[null,"!",".","[","{",","],{group:!0}),a.startGroup();break;case",":a.finishElement(o,"Bad Group Separator",["]","}"]),a.newGroupElement();break;case"}":a.finishElement(o,"Bad Group Terminator",["]","}"]),a.finishGroup(o);break;case"!":a.finishElement(o,"Bad Exclusion",[null,".",",","{","["],{finReq:!0}),a.startExclusion(o)}switch(n){case"(":i+=1;break;case")":0===i&&Cu("Unexpected Parentheses",e,{char:o}),i-=1}}r="\\"===n&&!r}return!1!==r&&Cu("Dangling Escape",e,{char:n-1}),0!==i&&Cu("Unterminated Parentheses",e),a.finishElement(n,"Bad Terminator",["]","}"]),a.finalizeResult()},Pu=(e,t,a,{onAdd:n,onFin:r})=>{const i=[[[e,null]]];let o=!1;((e,t)=>{const a=[e],n=[null],r=[],i=[];let o=0,s=!0;for(;-1!==o;){const e=a[o];Array.isArray(e)?!0!==e.or?(a.splice(o,1,...e),n.splice(o,1,...new Array(e.length).fill(n[o])),null!==n[o]&&(i[n[o]]+=e.length-1)):(void 0===r[o]?(r[o]=0,i[o]=0):0!==i[o]&&(a.splice(o+1,i[o]),n.splice(o+1,i[o]),i[o]=0),r[o]<e.length?(a.splice(o+1,0,e[r[o]]),n.splice(o+1,0,o),r[o]=(r[o]||0)+1,i[o]+=1,s=!0,o+=1):(r[o]=0,o-=1)):!0===s?(t("ADD",e),o===a.length-1?(t("FIN",e),s=!1):o+=1):(t("RM",e),o-=1)}})(a,(a,s)=>{if("RM"===a)!0===s.excluded&&(o=!1),i.length-=2;else if("ADD"===a){if(!0===s.excluded){if(o)throw new Error(`Redundant Exclusion: "${t}"`);o=!0}const e=[],a=i[i.length-2];i[i.length-1].forEach(([t,r])=>n(t,r,s,a,a=>e.push([a,t]))),i.push(s,e)}else i[i.length-1].filter(([t])=>t!==e).forEach(([e,t])=>r(e,t,s,o))})},ju=/[?!,.*+[\](){}\\]/g,ku=/^\^?[^-/\\^$*+?.()|[\]{}]*\$?$/g,Lu=e=>{if(ku.test(e)){const t=e.startsWith("^"),a=e.endsWith("$");if(t&&a){const t=e.slice(1,-1);return{test:e=>String(e)===t}}if(t){const t=e.slice(1);return{test:e=>String(e).startsWith(t)}}if(a){const t=e.slice(0,-1);return{test:e=>String(e).endsWith(t)}}return{test:t=>String(t).includes(e)}}try{return new RegExp(e)}catch(t){throw new Error(`Invalid Regex: "${e}"`)}},Mu=e=>e.reduce((e,t)=>`${e}${"number"==typeof t?`[${t}]`:`${e?".":""}${(e=>e.replace(ju,"\\$&"))(t)}`}`,""),Gu=e=>Array.isArray(e)?Mu(e):e,xu=["-","/","\\","^","$","*","+","?",".","(",")","|","[","]","{","}"],Fu=e=>{let t="",a=!1,n=!0;for(let r=0;r<e.length;r+=1){const i=e[r];a||"\\"!==i?a||"*"!==i?a||"+"!==i?a||"?"!==i?(xu.includes(i)&&(n=!1,t+="\\"),t+=i,a=!1):(n=!1,t+="."):(n=!1,t+=".+"):(n=!1,t+=".*"):a=!0}return n?{test:e=>String(e)===t}:".+"===t?{test:e=>""!==e}:new RegExp(`^${t}$`)};class Bu{constructor(e,t){if(t.nodes.push(this),this.value=e,this.ctx=t,this.order=t.counter,this.children=[],this.match=!1,this.matches=!1,this.needles=[],this.leafNeedles=[],this.leafNeedlesExclude=[],this.leafNeedlesMatch=[],this.isArrayTarget=e.startsWith("[")&&e.endsWith("]"),this.isSimpleStarRec="**"===e,this.isSimplePlusRec="++"===e,this.isSimpleRec=this.isSimpleStarRec||this.isSimplePlusRec,this.isRegexStarRec=e.startsWith("**(")&&e.endsWith(")"),this.isRegexPlusRec=e.startsWith("++(")&&e.endsWith(")"),this.isStarRec=this.isSimpleStarRec||this.isRegexStarRec,this.isPlusRec=this.isSimplePlusRec||this.isRegexPlusRec,this.isRec=this.isStarRec||this.isPlusRec,this.isAnyArrayTarget="[*]"===e,this.isAnyObjTarget="*"===e,this.isSimpleRec||this.isAnyObjTarget||this.isAnyArrayTarget)this.regex=null;else{const{regex:a}=t;e in a||(a[e]=(e=>(e.startsWith("**(")||e.startsWith("++("))&&e.endsWith(")")?Lu(e.slice(3,-1)):e.startsWith("[(")&&e.endsWith(")]")?Lu(e.slice(2,-2)):e.startsWith("(")&&e.endsWith(")")?Lu(e.slice(1,-1)):e.startsWith("[")&&e.endsWith("]")?Fu(e.slice(1,-1)):Fu(e))(e)),this.regex=a[e]}}recMatch(e){return!!this.isRec&&(!!this.isSimpleRec||this.regex.test(e))}typeMatch(e,t){return!!this.isSimpleRec||(this.isAnyArrayTarget?t:this.isAnyObjTarget?!t:!(t!==this.isArrayTarget&&!this.isRec)&&this.regex.test(e))}add(e){this.children.push(e)}get(e){return this.children.find(({value:t})=>t===e)}markMatches(){this.matches=!0}addNeedle(e){this.needles.includes(e)||this.needles.push(e)}setRoots(e){this.roots=e}finish(e,t,a){this.addNeedle(e),this.leafNeedles.includes(e)||this.leafNeedles.push(e);const n=t?this.leafNeedlesExclude:this.leafNeedlesMatch;n.includes(e)||n.push(e),this.match=!t,this.matches=this.match,this.index=a}}const zu=(e,t,a,n)=>{Pu(e,t,a,{onAdd:(e,a,r,i,o)=>{if(e.addNeedle(t),r instanceof Au)return void(!0===r.left?(r.isStarRec&&r.setPointer(e),r.setNode(new Bu("*",n)),n.links.push(e,r.node),o(r.node)):(r.target="target"in i?i.target:a.get(i.value),n.links.push(r.target,r.node),null!==r.pointer&&(o(r.pointer),r.setPointer(null)),o(e)));const s=r.isStarRec&&r.value===i?.value;if(s&&n.strict)throw new Error(`Redundant Recursion: "${t}"`);if(s)r.target=e;else{let t=e.get(r.value);void 0===t&&(t=new Bu(r.value,n),e.add(t)),o(t)}r.isStarRec&&o(e)},onFin:(e,a,r,i)=>{if(n.strict&&r.isSimpleStarRec){const e=a.children.filter(({value:e})=>!["","**"].includes(e));if(0!==e.length)throw new Error(`Needle Target Invalidated: "${e[0].needles[0]}" by "${t}"`)}if(n.strict&&0!==e.leafNeedles.length){const a=Gu(e.leafNeedles[0]),n=Gu(t);throw new Error(`Redundant Needle Target: "${a}" vs "${n}"`)}e.finish(t,i,n.counter),n.counter+=1}})},Vu=(e,t)=>{const a=[];for(let n=0,r=e.length;n<r;n+=1){const r=e[n][t];for(let e=0,t=r.length;e<t;e+=1){const t=r[e];a.includes(t)||a.push(t)}}return a},$u=e=>{let t=-1,a=!1,n=e.length;for(;n--;){const{index:r,match:i}=e[n];r>t&&(t=r,a=i)}return a},Uu=(e,t)=>t?Mu(e):[...e],Hu=(e,t,a)=>{const n={haystack:e,context:a.context};if(void 0!==a.beforeFn){const e=a.beforeFn(n);void 0!==e&&(n.haystack=e)}const r=[!1,[t],null,0],i=[],o=[];let s,p,l,d,u=n.haystack;const c={getKey:(e=a.joined)=>Uu(i,e),get key(){return c.getKey()},getValue:()=>u,get value(){return c.getValue()},getEntry:(e=a.joined)=>[Uu(i,e),u],get entry(){return c.getEntry()},getIsMatch:()=>d,get isMatch(){return c.getIsMatch()},getMatchedBy:()=>(e=>Vu(e,"leafNeedlesMatch"))(l),get matchedBy(){return c.getMatchedBy()},getExcludedBy:()=>(e=>Vu(e,"leafNeedlesExclude"))(l),get excludedBy(){return c.getExcludedBy()},getTraversedBy:()=>(e=>Vu(e,"needles"))(l),get traversedBy(){return c.getTraversedBy()},getGproperty:()=>i[i.length-2],get gproperty(){return c.getGproperty()},getProperty:()=>i[i.length-1],get property(){return c.getProperty()},getGparent:()=>o[o.length-2],get gparent(){return c.getGparent()},getParent:()=>o[o.length-1],get parent(){return c.getParent()},getParents:()=>[...o].reverse(),get parents(){return c.getParents()},getIsCircular:()=>o.includes(u),get isCircular(){return c.getIsCircular()},getIsLeaf:()=>!(u instanceof Object),get isLeaf(){return c.getIsLeaf()},getDepth:()=>i.length,get depth(){return c.getDepth()},get result(){return c.getResult()},context:n.context},m=((e,t)=>{if("context"===t.rtn)return{onMatch:()=>{},get:()=>e.context};if("bool"===t.rtn){let e=!1;return{onMatch:()=>{e=!0},get:()=>e}}if("count"===t.rtn){let e=0;return{onMatch:()=>{e+=1},get:()=>e}}if("sum"===t.rtn){let e=0;return{onMatch:({value:t})=>{e+=t},get:()=>e}}const a=[];return{onMatch:"function"==typeof t.rtn?()=>a.push(t.rtn(e)):Array.isArray(t.rtn)?()=>a.push(t.rtn.map(t=>e[t])):()=>a.push(e[t.rtn]),get:()=>t.abort?a[0]:a}})(c,a);if(c.getResult=()=>m.get(),a.useArraySelector||!Array.isArray(n.haystack)){const e=t.get("");void 0!==e&&r[1].push(e)}do{s=r.pop(),p=r.pop(),l=r.pop(),d=r.pop();const e=i.length-s;for(let t=0;t<e;t+=1)o.pop(),i.pop();if(-1===e?(o.push(u),i.push(p),u=u[p]):null!==p?(i[i.length-1]=p,u=o[o.length-1][p]):u=n.haystack,d){void 0!==a.filterFn&&!1===a.filterFn(c)||(m.onMatch(c),a.abort&&(r.length=0));continue}if(!l.some(({matches:e})=>e))continue;const f=!1===a.useArraySelector&&Array.isArray(u);if(!f&&$u(l)&&(r.push(!0,l,p,s),d=!0),(void 0===a.breakFn||!0!==a.breakFn(c))&&u instanceof Object){const e=Array.isArray(u),n=e?u.map((e,t)=>t).filter(()=>!0):Object.keys(u);!e&&a.compareFn&&n.sort(a.compareFn(c)),a.reverse||n.reverse();for(let i=0,o=n.length;i<o;i+=1){const o=n[i],p=[];if(f)p.push(...l),0===s&&p.push(...t.roots);else for(let t=0,a=l.length;t!==a;t+=1){const a=l[t];a.recMatch(o)&&p.push(a);const{children:n}=a;let r=n.length;for(;r--;){const t=n[r];t.typeMatch(o,e)&&p.push(t)}}if(a.orderByNeedles){p.index=Buffer.from(p.map(({order:e})=>e).sort());let e=r.length-3;const t=e-4*i;for(;e!==t&&1===Buffer.compare(p.index,r[e].index);)e-=4;r.splice(e+3,0,!1,p,o,s+1)}else r.push(!1,p,o,s+1)}}}while(0!==r.length);if(n.result=m.get(),void 0!==a.afterFn){const e=a.afterFn(n);void 0!==e&&(n.result=e)}return n.result},Ku=(e,t,a)=>{Nu(a.includes(typeof e[t]),()=>`Option "${t}" not one of [${a.join(", ")}]`)};var qu=du.ajv.getSchema("http://display.bricks.tools/root.schema.json5"),Wu=((e,t={})=>{if(Nu(Array.isArray(e),'Argument "needles" expected to be Array'),Nu(t instanceof Object&&!Array.isArray(t),'Argument "opts" expected to be Object'),0===e.length)return(e,t)=>void 0===t?[]:t;const a=(e=>{const t={filterFn:void 0,breakFn:void 0,beforeFn:void 0,afterFn:void 0,compareFn:void 0,reverse:!0,orderByNeedles:!1,abort:!1,rtn:void 0,joined:!1,useArraySelector:!0,strict:!0,...e};return Nu(12===Object.keys(t).length,"Unexpected Option provided"),Ku(t,"filterFn",["function","undefined"]),Ku(t,"breakFn",["function","undefined"]),Ku(t,"beforeFn",["function","undefined"]),Ku(t,"afterFn",["function","undefined"]),Ku(t,"compareFn",["function","undefined"]),Ku(t,"reverse",["boolean"]),Ku(t,"orderByNeedles",["boolean"]),Ku(t,"abort",["boolean"]),Nu("function"==typeof t.rtn&&1===t.rtn.length||[void 0,"context","key","value","entry","property","gproperty","parent","gparent","parents","isMatch","matchedBy","excludedBy","traversedBy","isCircular","isLeaf","depth","bool","count","sum"].includes(t.rtn)||Array.isArray(t.rtn)&&t.rtn.every(e=>["key","value","entry","property","gproperty","parent","gparent","parents","isMatch","matchedBy","excludedBy","traversedBy","isCircular","isLeaf","depth"].includes(e)),'Option "rtn" is malformed'),Ku(t,"joined",["boolean"]),Ku(t,"useArraySelector",["boolean"]),Ku(t,"strict",["boolean"]),t})(t),n=((e,t)=>{t.counter=0,t.links=[],t.nodes=[],t.regex=Object.create(null);const a=new Bu("*",t);for(let n=0;n<e.length;n+=1){const r=e[n],i=[Du(r,t)];zu(a,r,i,t)}return((e,t)=>{const{links:a}=t;for(;0!==a.length;){const e=a.pop(),t=a.pop(),{children:n}=t;t.children=[...e.children.filter(e=>!n.includes(e)),...n]}!1===t.useArraySelector&&e.setRoots(e.children.filter(({isStarRec:e,value:t})=>e||""===t));const{nodes:n}=t;for(;0!==n.length;){const e=n.pop(),{children:t}=e;t.reverse(),t.some(({matches:e})=>e)&&e.markMatches()}})(a,t),a})(e,a);return(e,t)=>Hu(e,n,{context:t,...a,rtn:a.rtn||(void 0===t?"key":"context")})})(["subspace_map.*.property_bank_calc_map.*.script_config"]);function Qu(e){var t=[];try{var a=du(e);t.push.apply(t,fe(Ou({errors:a,schema:qu,data:e}).map(function(e){return`${e.path}: ${e.message}`})));try{t.push.apply(t,fe(uu(e).map(function(e){return`${e.field}: ${e.message}`})))}catch(e){t.push(`Component reference validation failed: ${e.message}`)}return Wu(e).forEach(function(a){var n=a.slice(0,-1),r=lu(e,n),i=n.join(".");if(0===Object.keys(r.map).length)t.push(`${i}.map is empty`);else{var o=r.script_config,s=o.inputs,p=o.output,l=o.outputs,d=o.error;s&&Object.keys(s).forEach(function(e){r.map[e]||t.push(`${i}.map.${e} is missing`)}),p&&!r.map[p]&&t.push(`${i}.map.${p} is missing`),l&&Object.values(l).forEach(function(e){r.map[e]||t.push(`${i}.map.${e} is missing`)}),d&&!r.map[d]&&t.push(`${i}.map.${d} is missing`)}}),{valid:0===t.length,errors:t}}catch(e){return{valid:!1,errors:[`Validation failed: ${e.message}`]}}}var Yu=c(9741),Xu=c(3981),Ju=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-us";return"object"==typeof e&&null!==e?Object.fromEntries(Object.entries(e).map(function(e){var a,n=X(e,2),r=n[0],i=n[1];return[r,"object"!=typeof i||Array.isArray(i)?i:null!=(a=i[t])?a:Ju(i,t)]})):e},Zu=Ju(Yu.systemActionDescriptions),ec=Object.entries(Yu.systemActions).map(function(e){var t=X(e,2),a=t[0],n=t[1],r=n.propertyNameType,i=n.property;return` - \`${a}\`: ${Zu[a]}\n${function(e,t){switch(e){case"defined_properties":return Object.entries(t).map(function(e){var t=X(e,2),a=t[0],n=t[1];return` - \`${a}\`: ${JSON.stringify(n)}`}).join("\n");case"property_bank":return" - `PROPERTY_BANK_DATA_NODE_*`: Value";default:return""}}(r,i)}\n`.trim()}).join("\n"),tc=Object.keys(Xu.brickMapping).map(function(e){return`- \`${e}\``}).join("\n"),ac=Object.keys(Xu.generatorMapping).map(function(e){return`- \`${e}\``}).join("\n");const nc=Hd.replace("[:SYSTEM_ACTIONS:]",ec).replace("[:BRICK_IDS:]",tc).replace("[:GENERATOR_IDS:]",ac);var rc=function(e,t){var a;return!t||(null==(a=e.tokenInfo.permissions)?void 0:a.includes(t))||!1},ic=c(4668),oc=c(5018),sc=c(3315),pc=c(409),lc=c(8525),dc=c(9760),uc=c(6078),cc=c(9222),mc=c(5608),fc=c(9074),_c=c(3673);var hc=c(4370);const Ec=hc.default`
657
+ deps: ${a}}`};const o={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(e){const[t,a]=function({schema:e}){const t={},a={};for(const n in e){if("__proto__"===n)continue;(Array.isArray(e[n])?t:a)[n]=e[n]}return[t,a]}(e);s(e,t),p(e,a)}};function s(e,t=e.schema){const{gen:a,data:r,it:o}=e;if(0===Object.keys(t).length)return;const s=a.let("missing");for(const p in t){const l=t[p];if(0===l.length)continue;const d=(0,i.propertyInData)(a,r,p,o.opts.ownProperties);e.setParams({property:p,depsCount:l.length,deps:l.join(", ")}),o.allErrors?a.if(d,()=>{for(const t of l)(0,i.checkReportMissingProp)(e,t)}):(a.if(n._`${d} && (${(0,i.checkMissingProp)(e,l,s)})`),(0,i.reportMissingProp)(e,s),a.else())}}function p(e,t=e.schema){const{gen:a,data:n,keyword:o,it:s}=e,p=a.name("valid");for(const l in t)(0,r.alwaysValidSchema)(s,t[l])||(a.if((0,i.propertyInData)(a,n,l,s.opts.ownProperties),()=>{const t=e.subschema({keyword:o,schemaProp:l},p);e.mergeValidEvaluated(t,p)},()=>a.var(p,!0)),e.ok(p))}t.validatePropertyDeps=s,t.validateSchemaDeps=p,t.default=o},9891:(e,t,a)=>{a.d(t,{ApolloLink:()=>n.C,concat:()=>s,empty:()=>r,execute:()=>p.g,from:()=>i,split:()=>o}),a.r(t);a(9212);var n=a(9074),r=n.C.empty,i=n.C.from,o=n.C.split,s=n.C.concat,p=a(5174)},9893:e=>{function t(a,n){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(a,n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},9896:e=>{e.exports=t("fs")},9952:(e,t,a)=>{a.d(t,{P:()=>o});var n=a(5608),r=a(9074),i=a(9760),o=function(e){function t(t){void 0===t&&(t={});var a=e.call(this,(0,i.$)(t).request)||this;return a.options=t,a}return(0,n.__extends)(t,e),t}(r.C)},9968:(e,t,a)=>{var n=a(1035)({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"});e.exports=n}},u={};function c(e){var t=u[e];if(void 0!==t)return t.exports;var a=u[e]={id:e,loaded:!1,exports:{}};return d[e].call(a.exports,a,a.exports,c),a.loaded=!0,a.exports}c.m=d,c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},c.d=(e,t)=>{for(var a in t)c.o(t,a)&&!c.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},c.f={},c.e=e=>Promise.all(Object.keys(c.f).reduce((t,a)=>(c.f[a](e,t),t),[])),c.u=e=>e+".index.js",c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),p={792:0},l=e=>{var t,a,{__webpack_esm_ids__:n,__webpack_esm_modules__:r,__webpack_esm_runtime__:i}=e,o=0;for(t in r)c.o(r,t)&&(c.m[t]=r[t]);for(i&&i(c);o<n.length;o++)a=n[o],c.o(p,a)&&p[a]&&p[a][0](),p[n[o]]=0},c.f.j=(e,t)=>{var a=c.o(p,e)?p[e]:void 0;if(0!==a)if(a)t.push(a[1]);else{var n=import("./"+c.u(e)).then(l,t=>{throw 0!==p[e]&&(p[e]=void 0),t});n=Promise.race([n,new Promise(t=>a=p[e]=[t])]),t.push(a[1]=n)}};var m={};c.r(m),c.d(m,{lI:()=>Rc,F3:()=>yc,mJ:()=>Tc,AW:()=>Nc,$V:()=>vc,J6:()=>Oc,Wt:()=>bc,qq:()=>gc,gw:()=>Ac,Yi:()=>Ec});var f={};c.r(f),c.d(f,{applicationFragment:()=>Rc,applicationShortFragment:()=>Dc,deviceFragment:()=>yc,deviceGroupFragment:()=>Tc,deviceShortFragment:()=>Pc,instanceVersionFragment:()=>Nc,mediaBoxFragment:()=>kc,mediaFileFragment:()=>Lc,mediaWorkspaceFragment:()=>jc,moduleFragment:()=>vc,moduleShortFragment:()=>Oc,operationFragment:()=>bc,publicApplicationBasicInfoFragment:()=>gc,userFavoriteFragment:()=>Ac,workspaceFragment:()=>wc,workspaceShortFragment:()=>Cc});var _={};c.r(_),c.d(_,{application:()=>dm,applicationByDevice:()=>Yc,applicationReleaseVersion:()=>qc,applicationReleaseVersions:()=>Kc,applicationTestsByDevice:()=>Xc,applications:()=>lm,checkBindDevicePasscode:()=>Jc,devices:()=>um,devicesByGroup:()=>em,devicesByUniqueId:()=>Zc,me:()=>zc,module:()=>Vc,moduleReleaseVersion:()=>Qc,moduleReleaseVersions:()=>Wc,modules:()=>$c,publicModules:()=>Uc,publicModulesByIdList:()=>Hc,workspace:()=>sm,workspacePricingPlans:()=>tm,workspaces:()=>pm});var h={};c.r(h),c.d(h,{addUserFavorite:()=>ef,assignGroupPermissions:()=>Ym,bindApplication:()=>Dm,bindApplicationWithDeviceGroup:()=>km,changeWorkspaceAdditionalLimitSpending:()=>nf,changeWorkspaceSubscriptionPlan:()=>af,controlDevice:()=>vm,createApplication:()=>Im,createApplicationWithShareVersion:()=>wm,createConfigChangeOperation:()=>Km,createDevice:()=>hm,createDeviceGroup:()=>Om,createDeviceGroupWithApp:()=>Gm,createModule:()=>zm,createVirtualDevice:()=>Em,createWorkspace:()=>mm,createWorkspaceOTP:()=>rf,dispatchDeviceGroupAction:()=>bm,doOperation:()=>qm,duplicateApplication:()=>Fm,duplicateModule:()=>Um,forkApplication:()=>xm,moveApplication:()=>Mm,moveDevice:()=>Tm,moveModule:()=>$m,registerFCMNotification:()=>Xm,registerRemoteDebug:()=>Jm,removeApplication:()=>Bm,removeDevice:()=>gm,removeDeviceGroup:()=>Am,removeModule:()=>Hm,removeOperation:()=>Qm,removeUserFavorite:()=>tf,removeWorkspace:()=>Sm,revokeWorkspaceOTP:()=>of,shareAccessToken:()=>Zm,shareApplication:()=>Lm,toggleShortEditApplication:()=>Pm,updateApplication:()=>Cm,updateApplicationViewportPreset:()=>jm,updateDevice:()=>ym,updateDeviceGroup:()=>Nm,updateModule:()=>Vm,updateOperation:()=>Wm,updateVirtualDevice:()=>Rm,updateWorkspace:()=>fm,updateWorkspaceTokens:()=>_m});var E={};c.r(E),c.d(E,{application:()=>Rf,applicationByDevice:()=>gf,applications:()=>Tf,device:()=>bf,devices:()=>Nf,devicesByApplication:()=>Af,mediaBox:()=>wf,mediaBoxes:()=>If,mediaFile:()=>Df,mediaFiles:()=>Cf,mediaWorkspace:()=>Sf,module:()=>Of,modules:()=>vf,workspace:()=>yf});var y={};c.r(y),c.d(y,{bindApplication:()=>Mf,copyMediaFiles:()=>Uf,createApplication:()=>kf,createModule:()=>xf,deleteMediaBoxFiles:()=>Kf,deleteMediaFiles:()=>Hf,requestFileUpload:()=>Bf,setMediaFileAsBoxPreview:()=>$f,unbindApplication:()=>Gf,updateApplication:()=>Lf,updateMediaFile:()=>zf,updateMediaFiles:()=>Vf,updateModule:()=>Ff});var T={};c.r(T),c.d(T,{mediaBox:()=>V_,mediaBoxes:()=>B_,mediaFile:()=>U_,mediaFiles:()=>$_,mediaWorkspace:()=>z_,mediaWorkspaces:()=>F_});var R={};c.r(R),c.d(R,{assignGroupPermissions:()=>ah,copyMediaFiles:()=>eh,createMediaBox:()=>q_,createMediaWorkspace:()=>H_,deleteMediaFiles:()=>Z_,moveMediaBox:()=>W_,requestFileUpload:()=>Y_,setMediaFileAsBoxPreview:()=>th,updateMediaBox:()=>Q_,updateMediaFile:()=>X_,updateMediaFiles:()=>J_,updateMediaWorkspace:()=>K_});var g={};c.r(g),c.d(g,{mediaBox:()=>rh,mediaFile:()=>oh,mediaFiles:()=>ih});var v={};c.r(v),c.d(v,{deleteMediaFiles:()=>dh,requestFileUpload:()=>sh,updateMediaFile:()=>ph,updateMediaFiles:()=>lh});var O=c(9436),N=c(5181);const{DM:b,gu:A,er:S,Ww:I,b7:w,Di:C,a2:D,uB:P,ef:j,c$:k,_V:L}=N;var M=c(8568),G=c(9790);const x=t("readline");var F,B,z,V=c(8765),$=c(7742),U=new P("auth").description("Authentication and token management");U.command("login").description("Login with a one-time passcode from BRICKS Controller (recommended)").argument("[passcode]","One-time passcode from BRICKS Controller").option("-p, --profile <profile>","Profile name to save the token","default").option("-n, --name <name>","Profile display name").action((F=O(function*(e,t){var a,n,r=t.profile,i=t.name,o=e;o||(console.log(M.Ay.cyan("Generate a one-time passcode from BRICKS Controller:")),console.log(M.Ay.gray(" 1. Open the link below (or select your workspace first)")),console.log(` ${M.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")}`),console.log(M.Ay.gray(' 2. Click "Generate OTP" to create a one-time passcode\n')),(o=yield(a="Enter passcode: ",n=x.createInterface({input:process.stdin,output:process.stdout}),new Promise(function(e){n.question(a,function(t){n.close(),e(t.trim())})})))||(console.log(M.Ay.red("Passcode is required")),process.exit(1)));var s=(0,G.default)("Validating passcode...").start();try{var p=(0,$.createPublicClient)((0,V.getBaseUrl)()),l=yield p.checkWorkspaceOTP(o);l.valid||(s.fail(`Invalid passcode: ${l.error||"Unknown error"}`),process.exit(1)),s.text=`Exchanging passcode for token (workspace: ${l.workspaceName})...`;var d=yield p.exchangeWorkspaceOTP(o);d.token||(s.fail("Failed to obtain token"),process.exit(1));var u=(0,$.createClient)((0,V.getBaseUrl)(),d.token),c=yield u.workspace();c||(s.fail("Token validation failed"),process.exit(1)),(0,V.setToken)(r,{token:d.token,name:i||c.name,workspaceId:c._id,workspaceName:c.name}),(0,V.setCurrentProfile)(r),s.succeed(`Logged in to workspace: ${M.Ay.green(c.name)}`),console.log(M.Ay.gray(`Profile saved as: ${r}`))}catch(e){s.fail(`Login failed: ${e.message}`),process.exit(1)}}),function(e,t){return F.apply(this,arguments)})),U.command("login-token").description("Login with a workspace token directly").option("-t, --token <token>","Workspace token").option("-p, --profile <profile>","Profile name to save the token","default").option("-n, --name <name>","Profile display name").action((B=O(function*(e){var t=e.token,a=e.profile,n=e.name;t||(console.error(M.Ay.red("Error: Token is required. Use -t or --token to provide it.")),console.log(M.Ay.gray("\nYou can get a workspace token from BRICKS Controller:")+M.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")),console.log(` ${M.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")}`),console.log(M.Ay.gray("Select your workspace and create a new token.\n")),console.log(M.Ay.yellow("Tip: Use `bricks auth login` for a simpler OTP-based login.")),process.exit(1));var r=(0,G.default)("Validating token...").start();try{var i=(0,$.createClient)((0,V.getBaseUrl)(),t),o=yield i.workspace();o||(r.fail("Invalid token or unable to access workspace"),process.exit(1)),(0,V.setToken)(a,{token:t,name:n||o.name,workspaceId:o._id,workspaceName:o.name}),(0,V.setCurrentProfile)(a),r.succeed(`Logged in to workspace: ${M.Ay.green(o.name)}`),console.log(M.Ay.gray(`Profile saved as: ${a}`))}catch(e){r.fail(`Login failed: ${e.message}`),process.exit(1)}}),function(e){return B.apply(this,arguments)})),U.command("logout").description("Remove saved token").option("-p, --profile <profile>","Profile to remove").option("-a, --all","Remove all profiles").action((z=O(function*(e){var t=e.profile;if(e.all)return(0,V.listProfiles)().forEach(function(e){return(0,V.removeToken)(e.name)}),void console.log(M.Ay.green("All profiles removed"));var a=t||(0,V.getCurrentProfile)();(0,V.getTokenInfo)(a)?((0,V.removeToken)(a),console.log(M.Ay.green(`Logged out from profile: ${a}`))):console.log(M.Ay.yellow(`No token found for profile: ${a}`))}),function(e){return z.apply(this,arguments)})),U.command("status").description("Show current authentication status").action(O(function*(){var e=(0,V.getCurrentProfile)(),t=(0,V.getTokenInfo)(e);if(!t)return console.log(M.Ay.yellow("Not logged in")),void console.log(M.Ay.gray("Use `bricks auth login` to login"));var a=(0,G.default)("Checking connection...").start();try{var n=(0,$.createClient)((0,V.getBaseUrl)(),t.token),r=yield n.workspace();a.stop(),console.log(M.Ay.bold("\nAuthentication Status")),console.log("─".repeat(40)),console.log(`Profile: ${M.Ay.cyan(e)}`),console.log(`Workspace: ${M.Ay.green(r.name)}`),console.log(`Workspace ID: ${M.Ay.gray(r._id)}`),console.log(`Base URL: ${M.Ay.gray((0,V.getBaseUrl)())}`),console.log(`Logged in: ${M.Ay.gray(t.createdAt)}`),console.log("─".repeat(40))}catch(e){a.fail(`Connection failed: ${e.message}`)}})),U.command("list").description("List all saved profiles").action(function(){var e=(0,V.listProfiles)();if(0===e.length)return console.log(M.Ay.yellow("No saved profiles")),void console.log(M.Ay.gray("Use `bricks auth login` to login"));console.log(M.Ay.bold("\nSaved Profiles")),console.log("─".repeat(60)),e.forEach(function(e){var t=e.current?M.Ay.green("● "):" ",a=e.current?M.Ay.green(e.name):e.name;console.log(`${t}${a.padEnd(15)} ${M.Ay.gray(e.workspaceName||"Unknown")}`)}),console.log("─".repeat(60))}),U.command("use <profile>").description("Switch to a different profile").action(function(e){var t=(0,V.getTokenInfo)(e);if(!t)return console.log(M.Ay.red(`Profile not found: ${e}`)),void console.log(M.Ay.gray("Use `bricks auth list` to see available profiles"));(0,V.setCurrentProfile)(e),console.log(M.Ay.green(`Switched to profile: ${e}`)),t.workspaceName&&console.log(M.Ay.gray(`Workspace: ${t.workspaceName}`))}),U.command("set-url <url>").description("Set the base URL for BRICKS API").action(function(e){(0,V.setBaseUrl)(e),console.log(M.Ay.green(`Base URL set to: ${e}`))});var H,K,q,W,Q,Y,X=c(8832),J=c(7336),Z=function(){var e=(0,V.getCurrentProfile)(),t=(0,V.getToken)(e);return t||(console.error(M.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,$.createClient)((0,V.getBaseUrl)(),t)},ee=function(e){if(!e)return M.Ay.gray("○ Unknown");var t=Date.now()-new Date(e).getTime();if(t<=3e5)return M.Ay.green("● Online");var a=Math.floor(t/6e4);if(a<60)return M.Ay.yellow(`○ Offline (${a}m ago)`);var n=Math.floor(a/60);if(n<24)return M.Ay.red(`○ Offline (${n}h ago)`);var r=Math.floor(n/24);return M.Ay.red(`○ Offline (${r}d ago)`)},te=new P("device").description("Device management");te.command("list").description("List all devices").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e){var t=Z(),a=(0,G.default)("Fetching devices...").start();try{var n=yield t.devices({keyword:e.keyword});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(M.Ay.yellow("No devices found"));console.log(M.Ay.bold("\nDevices")),console.log("─".repeat(80)),n.forEach(function(e){var t,a,n=null==(t=e.entry_detail)||null==(t=t.watch_dog_timer)?void 0:t.last_alive_time,r=ee(n),i=(null==(a=e.entry_detail)||null==(a=a.application)?void 0:a.name)||M.Ay.gray("No app bound");console.log(`${r} ${M.Ay.cyan(e.name||e.device_name)}`),console.log(` ID: ${M.Ay.gray(e._id)}`),console.log(` App: ${i}`),console.log()})}catch(e){a.fail(`Failed to list devices: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),te.command("get <id>").description("Get device details").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=Z(),n=(0,G.default)("Fetching device...").start();try{var r,i,o,s=yield a.device({id:e});if(n.stop(),s||(console.log(M.Ay.red("Device not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(s,null,2));var p=null==(r=s.entry_detail)||null==(r=r.watch_dog_timer)?void 0:r.last_alive_time,l=ee(p);if(console.log(M.Ay.bold(`\nDevice: ${s.name||s.device_name}`)),console.log("─".repeat(60)),console.log(`Status: ${l}`),console.log(`ID: ${M.Ay.gray(s._id)}`),console.log(`Device Name: ${s.device_name||M.Ay.gray("N/A")}`),console.log(`Description: ${s.description||M.Ay.gray("N/A")}`),console.log(`Tags: ${(null==(i=s.tags)?void 0:i.join(", "))||M.Ay.gray("None")}`),console.log(`Created: ${M.Ay.gray(s.create_datetime||"N/A")}`),console.log(`Modified: ${M.Ay.gray(s.last_modify_datetime||"N/A")}`),s.entry_detail){var d,u,c,m,f=s.entry_detail;if(console.log(`\n${M.Ay.bold("Entry Details")}`),console.log(`Type: ${f.type||M.Ay.gray("N/A")}`),console.log(`Unique ID: ${M.Ay.gray(f.unique_id||"N/A")}`),console.log(`Version: ${f.operation_version||M.Ay.gray("N/A")}`),console.log(`Mode: ${f.operation_mode||M.Ay.gray("N/A")}`),Array.isArray(f.screen)&&f.screen.length>0)console.log(`\n${M.Ay.bold("Screens")} (${f.screen.length})`),f.screen.forEach(function(e,t){var a,n=e.resolution,r=n?`${n.width}x${n.height} @${n.scale}x`:"N/A",i=e.master?M.Ay.green(" (master)"):"",o=e.orientation?` [${e.orientation}]`:"",s=null!=(a=e.touch)&&a.available?M.Ay.cyan(` touch:${e.touch.touch_point}pt`):"";console.log(` ${t+1}. ${e.title||"Screen"}${i}${o} - ${r}${s}`)});else if(null!=(d=f.screen)&&d.resolution){var _=f.screen.resolution;console.log(`Resolution: ${_.width}x${_.height} @${_.scale}x`)}var h=null!=f.memory_usage,E=null!=f.disk_usage;if(h||E){if(console.log(`\n${M.Ay.bold("System Resources")}`),h){var y=Array.isArray(f.memory_usage)?f.memory_usage[0]:f.memory_usage,T=Math.round(100*y),R=M.Ay.green;T>80?R=M.Ay.red:T>60&&(R=M.Ay.yellow),console.log(`Memory: ${R(`${T}%`)}`)}if(E){var g=Array.isArray(f.disk_usage)?f.disk_usage[0]:f.disk_usage,v=Math.round(100*g),O=M.Ay.green;v>90?O=M.Ay.red:v>75&&(O=M.Ay.yellow),console.log(`Disk: ${O(`${v}%`)}`)}}var N,b=[];if(null!=(u=f.sound)&&u.available&&b.push("Sound"),null!=(c=f.camera)&&c.available&&b.push("Camera"),null!=(m=f.audio_in)&&m.available&&b.push("Audio Input"),b.length>0)console.log(`\n${M.Ay.bold("Capabilities")}`),console.log(`Available: ${b.join(", ")}`),(null==(N=f.camera)||null==(N=N.channel)?void 0:N.length)>0&&f.camera.channel.forEach(function(e){var t=e.resolution?`${e.resolution.width}x${e.resolution.height}`:"";console.log(` Camera: ${e.title||"Camera"} ${t} [${e.orientation||"N/A"}]`)});if(f.local_sync){var A=f.local_sync;console.log(`\n${M.Ay.bold("Local Sync")}`),console.log(`Role: ${A.is_main?M.Ay.cyan("Main"):"Secondary"}`),null!=A.peer_count&&console.log(`Peers: ${A.peer_count}`),null!=A.mean_latency&&console.log(`Latency: ${A.mean_latency.toFixed(2)}ms`)}if(f.update){var S=f.update;console.log(`\n${M.Ay.bold("Update Status")}`),console.log(`Needs Update: ${S.need_update?M.Ay.yellow("Yes"):M.Ay.green("No")}`),S.current_version&&console.log(`App Version: ${S.current_version}`),S.running_mode&&console.log(`Running Mode: ${S.running_mode}`),S.last_update_at&&console.log(`Last Update: ${M.Ay.gray(S.last_update_at)}`)}if(f.watch_dog_timer){var I=f.watch_dog_timer;console.log(`\n${M.Ay.bold("Watchdog")}`),console.log(`Alive: ${I.alive?M.Ay.green("Yes"):M.Ay.red("No")}`),I.last_launch_time&&console.log(`Last Launch: ${M.Ay.gray(I.last_launch_time)}`),I.last_alive_time&&console.log(`Last Alive: ${M.Ay.gray(I.last_alive_time)}`)}}s.bound_application&&(console.log(`\n${M.Ay.bold("Bound Application")}`),console.log(`Name: ${s.bound_application.name}`),console.log(`ID: ${M.Ay.gray(s.bound_application._id)}`)),null!=(o=s.env)&&o.variables&&Object.keys(s.env.variables).length>0&&(console.log(`\n${M.Ay.bold("Environment Variables")}`),Object.entries(s.env.variables).forEach(function(e){var t=X(e,2),a=t[0],n=t[1];console.log(` ${M.Ay.cyan(a)}: ${n}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get device: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),te.command("bind <passcode>").description("Bind a new device using passcode").option("-n, --name <name>","Device name").action((H=O(function*(e,t){var a=Z(),n=(0,G.default)("Checking passcode...").start();try{var r,i,o=yield a.checkBindDevicePasscode({passcode:e});o||(n.fail("Invalid passcode or expired"),process.exit(1)),n.text="Binding device...";var s=yield a.createDevice({bindPasscode:e,name:t.name||(null==(r=o.payload)?void 0:r.deviceName)||"CLI Device",deviceName:null==(i=o.payload)?void 0:i.deviceName});n.succeed(`Device bound successfully: ${M.Ay.green(s.name)}`),console.log(M.Ay.gray(`Device ID: ${s._id}`))}catch(e){n.fail(`Failed to bind device: ${e.message}`),process.exit(1)}}),function(e,t){return H.apply(this,arguments)})),te.command("control <id> <type>").description("Control a device").option("-p, --payload <json>","Event payload as JSON").action((K=O(function*(e,t,a){var n=Z(),r=(0,G.default)(`Sending ${t} to device...`).start();try{var i;a.payload&&(i=JSON.parse(a.payload)),yield n.controlDevice({id:e,type:t,eventPayload:i}),r.succeed(`Control event sent: ${M.Ay.green(t)}`)}catch(e){r.fail(`Failed to control device: ${e.message}`),process.exit(1)}}),function(e,t,a){return K.apply(this,arguments)})),te.command("refresh <id>").description("Refresh device application").action((q=O(function*(e){var t=Z(),a=(0,G.default)("Refreshing device...").start();try{yield t.controlDevice({id:e,type:"refresh"}),a.succeed("Device refreshed")}catch(e){a.fail(`Failed to refresh device: ${e.message}`),process.exit(1)}}),function(e){return q.apply(this,arguments)})),te.command("clear-cache <id>").description("Clear device cache").action((W=O(function*(e){var t=Z(),a=(0,G.default)("Clearing cache...").start();try{yield t.controlDevice({id:e,type:"clear-cache"}),a.succeed("Cache cleared")}catch(e){a.fail(`Failed to clear cache: ${e.message}`),process.exit(1)}}),function(e){return W.apply(this,arguments)})),te.command("screenshot <id>").description("Take device screenshot and save to file").option("-o, --output <path>","Output file path").option("--no-take","Only fetch existing screenshot without taking a new one").action((Q=O(function*(e,t){var a=Z(),n=(0,G.default)("Fetching workspace info...").start();try{var r,i,o,s=yield a.workspace();null!=s&&null!=(r=s.media_resource)&&r.enable_media_workspace||(n.fail("Media workspace is not enabled for this workspace"),process.exit(1)),s.media_resource.system_media_box_id||(n.fail("No media box configured for this workspace"),process.exit(1)),!1!==t.take&&(n.text="Sending screenshot request to device...",yield a.controlDevice({id:e,type:"take-screenshot"}),n.text="Waiting for device to capture screenshot...",yield new Promise(function(e){return setTimeout(e,3e3)})),n.text="Fetching screenshot...";var p=yield(0,J.he)(a,s,e,t.output);if(p.error&&(n.fail(p.error),process.exit(1)),n.succeed("Screenshot saved"),console.log(),console.log(M.Ay.bold("Screenshot saved to:")),console.log(M.Ay.cyan(p.path)),console.log(),null!=(i=p.file)&&i.meta){var l=p.file.meta,d=l.originalWidth,u=l.originalHeight,c=l.originalFileSize;if(d&&u&&console.log(`${M.Ay.gray("Size:")} ${d}x${u}`),c){var m=(c/1024).toFixed(1);console.log(`${M.Ay.gray("File:")} ${m} KB`)}}null!=(o=p.file)&&o.updatedAt&&console.log(`${M.Ay.gray("Updated:")} ${new Date(p.file.updatedAt).toLocaleString()}`)}catch(e){n.fail(`Failed to get screenshot: ${e.message}`),process.exit(1)}}),function(e,t){return Q.apply(this,arguments)})),te.command("monitor").description("Monitor device status (polls every 60s)").option("-g, --group <id>","Monitor devices in a group").option("-i, --interval <seconds>","Polling interval in seconds","60").action((Y=O(function*(e){var t=Z(),a=1e3*parseInt(e.interval,10);console.log(M.Ay.bold("\nDevice Monitor")),console.log(M.Ay.gray(`Polling every ${e.interval}s. Press Ctrl+C to stop.\n`));var n,r=(n=O(function*(){try{var a;if(a=e.group?yield t.devicesByGroup({id:e.group}):yield t.devices({}),process.stdout.write(""),console.log(M.Ay.bold("Device Monitor")+M.Ay.gray(` - ${(new Date).toLocaleTimeString()}`)),console.log("─".repeat(80)),!a||0===a.length)return void console.log(M.Ay.yellow("No devices found"));a.forEach(function(e){var t,a,n=null==(t=e.entry_detail)||null==(t=t.watch_dog_timer)?void 0:t.last_alive_time,r=ee(n),i=e.name||e.device_name||e.device_target_name,o=(null==(a=e.entry_detail)||null==(a=a.application)?void 0:a.name)||M.Ay.gray("No app");console.log(`${r} ${M.Ay.cyan(i.padEnd(25))} ${o}`)}),console.log(`\n${M.Ay.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(M.Ay.red(`Error: ${e.message}`))}}),function(){return n.apply(this,arguments)});yield r(),setInterval(r,a)}),function(e){return Y.apply(this,arguments)}));var ae,ne,re=c(9896),ie=c(5704),oe=function(){var e=(0,V.getCurrentProfile)(),t=(0,V.getToken)(e);return t||(console.error(M.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,$.createClient)((0,V.getBaseUrl)(),t)},se=new P("app").description("Application management");se.command("list").description("List all applications").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e){var t=oe(),a=(0,G.default)("Fetching applications...").start();try{var n=yield t.applications({keyword:e.keyword});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(M.Ay.yellow("No applications found"));console.log(M.Ay.bold("\nApplications")),console.log("─".repeat(80)),n.forEach(function(e){var t=e.has_unreleased_changes?M.Ay.yellow("●"):M.Ay.green("●"),a=e.current_version?`v${e.current_version}`:M.Ay.gray("no version");console.log(`${t} ${M.Ay.cyan(e.name)} ${M.Ay.gray(a)}`),console.log(` ID: ${M.Ay.gray(e._id)}`),e.description&&console.log(` ${M.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list applications: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),se.command("get <id>").description("Get application details").option("-c, --composed","Get composed configuration").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=oe(),n=(0,G.default)("Fetching application...").start();try{var r,i,o,s,p,l,d=yield a.application({id:e,composed:t.composed});if(n.stop(),d||(console.log(M.Ay.red("Application not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(d,null,2));if(console.log(M.Ay.bold(`\nApplication: ${d.name}`)),console.log("─".repeat(60)),console.log(`ID: ${M.Ay.gray(d._id)}`),console.log(`Description: ${d.description||M.Ay.gray("N/A")}`),console.log(`Tags: ${(null==(r=d.tags)?void 0:r.join(", "))||M.Ay.gray("None")}`),console.log(`Created: ${M.Ay.gray(d.create_datetime)}`),console.log(`Modified: ${M.Ay.gray(d.last_modify_datetime)}`),console.log(`\n${M.Ay.bold("Version")}`),d.current_version){if(console.log(`Current: v${d.current_version}`),d.current_version_details){var u=d.current_version_details;u.name&&console.log(`Release Name: ${u.name}`),u.note&&console.log(`Release Note: ${M.Ay.gray(u.note)}`),u.create_datetime&&console.log(`Released At: ${M.Ay.gray(u.create_datetime)}`)}}else console.log(`Current: ${M.Ay.gray("No version")}`);if(console.log(`Unreleased: ${d.has_unreleased_changes?M.Ay.yellow("Yes"):M.Ay.green("No")}`),console.log(`\n${M.Ay.bold("Features")}`),console.log(`Short Edit: ${null!=(i=d.short_edit)&&i.enabled?M.Ay.green("Enabled"):M.Ay.gray("Disabled")}`),null!=(o=d.short_edit)&&o.enabled&&d.short_edit.ref_map){var c=Object.keys(d.short_edit.ref_map).length;console.log(` References: ${c} editable properties`)}console.log(`Automation: ${null!=(s=d.canvas_control)&&s.enable_schedule?M.Ay.green("Scheduled"):M.Ay.gray("No schedule")}`),null!=(p=d.lock)&&p.locked&&console.log(`Locked: ${M.Ay.yellow("Yes")} (at ${d.lock.locked_at||"N/A"})`),d.sync_key&&console.log(`Sync Key: ${M.Ay.gray(d.sync_key)}`),(null==(l=d.devices)?void 0:l.length)>0?(console.log(`\n${M.Ay.bold("Bound Devices")} (${d.devices.length})`),d.devices.forEach(function(e){var t="active"===e.status?M.Ay.green("●"):M.Ay.gray("○"),a=e.frame?M.Ay.gray(` [${e.frame.x||0},${e.frame.y||0} ${e.frame.width}x${e.frame.height}]`):"";console.log(` ${t} ${e.device_id}${a}`)})):console.log(`\n${M.Ay.bold("Bound Devices")}: ${M.Ay.gray("None")}`),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get application: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),se.command("update <id>").description("Update application").option("-n, --name <name>","Application name").option("-d, --description <description>","Application description").option("-c, --config <json>","Application config as JSON string").option("-f, --file <path>","Application config from file").option("--validate","Validate configuration").action(function(){var e=O(function*(e,t){var a=oe(),n=(0,G.default)("Updating application...").start();try{var r={id:e};t.name&&(r.name=t.name),t.description&&(r.description=t.description),t.validate&&(r.validateConfig=!0),t.config?r.config=t.config:t.file&&(r.config=re.readFileSync(t.file,"utf-8"));var i=yield a.updateApplication(r);n.succeed(`Application updated: ${M.Ay.green(i.name)}`),i.has_unreleased_changes&&console.log(M.Ay.yellow("Note: Application has unreleased changes"))}catch(e){n.fail(`Failed to update application: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),se.command("short-edit <id>").description("Short edit application properties").requiredOption("-l, --list <json>","Short edit list as JSON array").action((ae=O(function*(e,t){var a=oe(),n=(0,G.default)("Applying short edit...").start();try{var r=JSON.parse(t.list);Array.isArray(r)||(n.fail("List must be a JSON array"),process.exit(1));var i=yield a.shortEditApplication({id:e,list:r});n.succeed(`Short edit applied to: ${M.Ay.green(i.name)}`)}catch(e){n.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}}),function(e,t){return ae.apply(this,arguments)})),se.command("short-refs <id>").description("List short edit references for an application").option("-k, --keyword <keyword>","Filter by shortId or title").option("-t, --types <types>","Comma-separated shortId prefixes to include (e.g. B,C,S)").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=oe(),n=(0,G.default)("Fetching short edit references...").start();try{var r,i=yield a.application({id:e});if(n.stop(),null==i||null==(r=i.short_edit)||!r.enabled)return void console.log(M.Ay.yellow("Short Edit is not enabled for this application"));var o=t.types?t.types.split(",").map(function(e){return e.trim()}).filter(Boolean):[],s=(0,ie.V)(i.short_edit.ref_map,{keyword:t.keyword,types:o});if(t.json)return void console.log(JSON.stringify(s,null,2));if(0===s.length)return void console.log(M.Ay.yellow("No short edit references found"));console.log(M.Ay.bold(`\nShort Edit References: ${i.name}`)),s.forEach(function(e){console.log(M.Ay.cyan(`\n${e.label} (${e.prefix}_)`)),e.refs.forEach(function(e){var t=e.shortId,a=e.ref,n=null!=a&&a.title?M.Ay.gray(`- ${a.title}`):"";console.log(` ${M.Ay.green(t)} ${n}`)})}),console.log()}catch(e){n.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),se.command("bind <id>").description("Bind devices to application").option("-b, --bind <devices>","Device IDs to bind (comma-separated)").option("-u, --unbind <devices>","Device IDs to unbind (comma-separated)").action(function(){var e=O(function*(e,t){var a=oe(),n=(0,G.default)("Updating device bindings...").start();try{var r={id:e};t.bind&&(r.bindDevices=t.bind.split(",").map(function(e){return e.trim()})),t.unbind&&(r.unbindDevices=t.unbind.split(",").map(function(e){return e.trim()})),yield a.bindApplication(r),n.succeed("Device bindings updated")}catch(e){n.fail(`Failed to update bindings: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),se.command("trigger <id> <testId>").description("Trigger automation test on application").option("--play","Play the test",!0).option("--stop","Stop the test").option("--setup-at-launch","Setup to run at app launch").option("-g, --match-group <group>","Match group").action(function(){var e=O(function*(e,t,a){var n=oe(),r=(0,G.default)("Triggering automation...").start();try{yield n.triggerApplicationCanvasControl({id:e,testId:t,play:!a.stop&&a.play,setupAtLaunch:a.setupAtLaunch,matchGroup:a.matchGroup}),r.succeed(`Automation triggered: ${M.Ay.green(t)}`)}catch(e){r.fail(`Failed to trigger automation: ${e.message}`),process.exit(1)}});return function(t,a,n){return e.apply(this,arguments)}}()),se.command("release <id>").description("Release application to BRICKS platform").requiredOption("-c, --config <path|json>","Application config file path or JSON string").option("--version <version>","Version name").option("--changelogs <text>","Release changelogs").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=oe(),n=t.json?null:(0,G.default)("Releasing application...").start();try{var r,i=t.config;(t.config.endsWith(".json")||t.config.includes("/"))&&(re.existsSync(t.config)||(n?n.fail(`Config file not found: ${t.config}`):console.error(JSON.stringify({error:`Config file not found: ${t.config}`})),process.exit(1)),i=re.readFileSync(t.config,"utf-8"));var o=yield a.application({id:e});o||(n?n.fail("Application not found"):console.error(JSON.stringify({error:"Application not found"})),process.exit(1)),null!=(r=o.lock)&&r.enabled&&(n?n.fail("Application is locked"):console.error(JSON.stringify({error:"Application is locked"})),process.exit(1));var s=t.version||o.name||"Untitled",p=t.changelogs?`${t.changelogs}\n\nRelease by BRICKS CLI`:"Release by BRICKS CLI";yield a.releaseApplication({id:e,config:i,releaseCurrentVersion:s,releaseCurrentVersionNote:p}),t.json?console.log(JSON.stringify({success:!0,name:o.name})):n.succeed(`Application released: ${M.Ay.green(o.name)}`)}catch(e){t.json?console.error(JSON.stringify({error:e.message})):n.fail(`Failed to release application: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),se.command("project-pull <id>").description("Pull application source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action(function(){var e=O(function*(e,t){var a=oe(),n=t.json?null:(0,G.default)("Pulling application project...").start();try{var r,i=yield a.applicationProject({id:e,buildApplicationOnly:!0});if(i||(n?n.fail("Application project not found"):console.error(JSON.stringify({error:"Application project not found"})),process.exit(1)),t.json)console.log(JSON.stringify(i));else n.succeed(`Application project fetched: ${M.Ay.green((null==(r=i.files)?void 0:r.length)||0)} files`),console.log(JSON.stringify(i,null,2))}catch(e){t.json?console.error(JSON.stringify({error:e.message})):n.fail(`Failed to pull application project: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),se.command("project-init <id>").description("Initialize a BRICKS Project from an application").option("-o, --output <dir>","Output directory (default: current directory)").option("--github-actions","Include GitHub Actions workflow (default: true)").option("--no-github-actions","Skip GitHub Actions workflow setup").option("--agents","Include AGENTS.md (default: true)").option("--no-agents","Skip AGENTS.md setup").option("--claude","Include CLAUDE.md (default: true)").option("--no-claude","Skip CLAUDE.md setup").option("--gemini","Include GEMINI.md (default: false)").option("--no-gemini","Skip GEMINI.md setup").option("--install","Run bun install after generation (default: true)").option("--no-install","Skip bun install after generation").option("--git","Initialize git repository (default: true)").option("--no-git","Skip git initialization").option("-y, --yes","Skip prompts and use defaults/flags").option("-j, --json","Output as JSON (for programmatic use)").action((ne=O(function*(e,t){var a=(yield Promise.all([c.e(832),c.e(153)]).then(c.bind(c,7153))).initProject;yield a("application",e,t)}),function(e,t){return ne.apply(this,arguments)}));var pe=function(){var e=(0,V.getCurrentProfile)(),t=(0,V.getToken)(e);return t||(console.error(M.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,$.createClient)((0,V.getBaseUrl)(),t)},le=new P("module").description("Module management");le.command("list").description("List all modules").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e){var t=pe(),a=(0,G.default)("Fetching modules...").start();try{var n=yield t.modules({keyword:e.keyword});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(M.Ay.yellow("No modules found"));console.log(M.Ay.bold("\nModules")),console.log("─".repeat(80)),n.forEach(function(e){var t=e.current_version?`v${e.current_version}`:M.Ay.gray("no version");console.log(`● ${M.Ay.cyan(e.name)} ${M.Ay.gray(t)}`),console.log(` ID: ${M.Ay.gray(e._id)}`),e.description&&console.log(` ${M.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list modules: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),le.command("get <id>").description("Get module details").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=pe(),n=(0,G.default)("Fetching module...").start();try{var r,i,o,s,p,l=yield a.module({id:e});if(n.stop(),l||(console.log(M.Ay.red("Module not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(l,null,2));if(console.log(M.Ay.bold(`\nModule: ${l.name}`)),console.log("─".repeat(60)),console.log(`ID: ${M.Ay.gray(l._id)}`),console.log(`Description: ${l.description||M.Ay.gray("N/A")}`),console.log(`Tags: ${(null==(r=l.tags)?void 0:r.join(", "))||M.Ay.gray("None")}`),console.log(`Created: ${M.Ay.gray(l.create_datetime)}`),console.log(`Modified: ${M.Ay.gray(l.last_modify_datetime)}`),console.log(`\n${M.Ay.bold("Version")}`),console.log(`Current: ${l.current_version?`v${l.current_version}`:M.Ay.gray("No version")}`),console.log(`Unreleased: ${l.has_unreleased_changes?M.Ay.yellow("Yes"):M.Ay.green("No")}`),console.log(`\n${M.Ay.bold("Settings")}`),console.log(`Public: ${l.is_public?M.Ay.green("Yes"):M.Ay.gray("No")}`),console.log(`Allow Modify: ${l.is_allow_modify?M.Ay.green("Yes"):M.Ay.gray("No")}`),console.log(`Short Edit: ${null!=(i=l.short_edit)&&i.enabled?M.Ay.green("Enabled"):M.Ay.gray("Disabled")}`),null!=(o=l.short_edit)&&o.enabled&&l.short_edit.ref_map){var d=Object.keys(l.short_edit.ref_map).length;console.log(` References: ${d} editable properties`)}null!=(null==(s=l.use_count)?void 0:s.total_count)&&(console.log(`\n${M.Ay.bold("Usage")}`),console.log(`Used In: ${l.use_count.total_count} application(s)`)),(null==(p=l.expose_properties)?void 0:p.length)>0&&(console.log(`\n${M.Ay.bold("Exposed Properties")} (${l.expose_properties.length})`),l.expose_properties.forEach(function(e){console.log(` - ${M.Ay.cyan(e)}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get module: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),le.command("update <id>").description("Update module").option("-n, --name <name>","Module name").option("-d, --description <description>","Module description").option("-c, --config <json>","Module config as JSON string").option("-f, --file <path>","Module config from file").option("--validate","Validate configuration").action(function(){var e=O(function*(e,t){var a=pe(),n=(0,G.default)("Updating module...").start();try{var r={id:e};t.name&&(r.name=t.name),t.description&&(r.description=t.description),t.validate&&(r.validateConfig=!0),t.config?r.config=t.config:t.file&&(r.config=re.readFileSync(t.file,"utf-8"));var i=yield a.updateModule(r);n.succeed(`Module updated: ${M.Ay.green(i.name)}`)}catch(e){n.fail(`Failed to update module: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),le.command("short-edit <id>").description("Short edit module properties").requiredOption("-l, --list <json>","Short edit list as JSON array").action(function(){var e=O(function*(e,t){var a=pe(),n=(0,G.default)("Applying short edit...").start();try{var r=JSON.parse(t.list);Array.isArray(r)||(n.fail("List must be a JSON array"),process.exit(1));var i=yield a.shortEditModule({id:e,list:r});n.succeed(`Short edit applied to: ${M.Ay.green(i.name)}`)}catch(e){n.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),le.command("short-refs <id>").description("List short edit references for a module").option("-k, --keyword <keyword>","Filter by shortId or title").option("-t, --types <types>","Comma-separated shortId prefixes to include (e.g. B,C,S)").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=pe(),n=(0,G.default)("Fetching short edit references...").start();try{var r,i=yield a.module({id:e});if(n.stop(),null==i||null==(r=i.short_edit)||!r.enabled)return void console.log(M.Ay.yellow("Short Edit is not enabled for this module"));var o=t.types?t.types.split(",").map(function(e){return e.trim()}).filter(Boolean):[],s=(0,ie.V)(i.short_edit.ref_map,{keyword:t.keyword,types:o});if(t.json)return void console.log(JSON.stringify(s,null,2));if(0===s.length)return void console.log(M.Ay.yellow("No short edit references found"));console.log(M.Ay.bold(`\nShort Edit References: ${i.name}`)),s.forEach(function(e){console.log(M.Ay.cyan(`\n${e.label} (${e.prefix}_)`)),e.refs.forEach(function(e){var t=e.shortId,a=e.ref,n=null!=a&&a.title?M.Ay.gray(`- ${a.title}`):"";console.log(` ${M.Ay.green(t)} ${n}`)})}),console.log()}catch(e){n.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),le.command("release <id>").description("Release module to BRICKS platform").requiredOption("-c, --config <path|json>","Module config file path or JSON string").option("--version <version>","Version name").option("--changelogs <text>","Release changelogs").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=pe(),n=t.json?null:(0,G.default)("Releasing module...").start();try{var r=t.config;(t.config.endsWith(".json")||t.config.includes("/"))&&(re.existsSync(t.config)||(n?n.fail(`Config file not found: ${t.config}`):console.error(JSON.stringify({error:`Config file not found: ${t.config}`})),process.exit(1)),r=re.readFileSync(t.config,"utf-8"));var i=yield a.module({id:e});i||(n?n.fail("Module not found"):console.error(JSON.stringify({error:"Module not found"})),process.exit(1)),i.is_public&&(n?n.fail("Public module deployment is temporarily not recommended"):console.error(JSON.stringify({error:"Public module deployment is temporarily not recommended"})),process.exit(1));var o=t.version||i.name||"Untitled",s=t.changelogs?`${t.changelogs}\n\nRelease by BRICKS CLI`:"Release by BRICKS CLI";yield a.releaseModule({id:e,config:r,releaseCurrentVersion:o,releaseCurrentVersionNote:s}),t.json?console.log(JSON.stringify({success:!0,name:i.name})):n.succeed(`Module released: ${M.Ay.green(i.name)}`)}catch(e){t.json?console.error(JSON.stringify({error:e.message})):n.fail(`Failed to release module: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),le.command("project-pull <id>").description("Pull module source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action(function(){var e=O(function*(e,t){var a=pe(),n=t.json?null:(0,G.default)("Pulling module project...").start();try{var r,i=yield a.moduleProject({id:e,buildApplicationOnly:!0});if(i||(n?n.fail("Module project not found"):console.error(JSON.stringify({error:"Module project not found"})),process.exit(1)),t.json)console.log(JSON.stringify(i));else n.succeed(`Module project fetched: ${M.Ay.green((null==(r=i.files)?void 0:r.length)||0)} files`),console.log(JSON.stringify(i,null,2))}catch(e){t.json?console.error(JSON.stringify({error:e.message})):n.fail(`Failed to pull module project: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),le.command("project-init <id>").description("Initialize a BRICKS Project from a module").option("-o, --output <dir>","Output directory (default: current directory)").option("--github-actions","Include GitHub Actions workflow (default: true)").option("--no-github-actions","Skip GitHub Actions workflow setup").option("--agents","Include AGENTS.md (default: true)").option("--no-agents","Skip AGENTS.md setup").option("--claude","Include CLAUDE.md (default: true)").option("--no-claude","Skip CLAUDE.md setup").option("--gemini","Include GEMINI.md (default: false)").option("--no-gemini","Skip GEMINI.md setup").option("--install","Run bun install after generation (default: true)").option("--no-install","Skip bun install after generation").option("--git","Initialize git repository (default: true)").option("--no-git","Skip git initialization").option("-y, --yes","Skip prompts and use defaults/flags").option("-j, --json","Output as JSON (for programmatic use)").action(function(){var e=O(function*(e,t){var a=(yield Promise.all([c.e(832),c.e(153)]).then(c.bind(c,7153))).initProject;yield a("module",e,t)});return function(t,a){return e.apply(this,arguments)}}());var de=function(){var e=(0,V.getCurrentProfile)(),t=(0,V.getToken)(e);return t||(console.error(M.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,$.createClient)((0,V.getBaseUrl)(),t)},ue=3e5,ce=function(e){if(!e)return M.Ay.gray("○");var t=Date.now()-new Date(e).getTime();return t<=ue?M.Ay.green("●"):Math.floor(t/6e4)<60?M.Ay.yellow("○"):M.Ay.red("○")},me=new P("group").description("Device Group management");me.command("list").description("List all device groups").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e){var t=de(),a=(0,G.default)("Fetching device groups...").start();try{var n=yield t.deviceGroups({});if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(M.Ay.yellow("No device groups found"));console.log(M.Ay.bold("\nDevice Groups")),console.log("─".repeat(80)),n.forEach(function(e){var t,a=(null==(t=e.devices)?void 0:t.length)||0;console.log(`● ${M.Ay.cyan(e.name)} ${M.Ay.gray(`(${a} devices)`)}`),console.log(` ID: ${M.Ay.gray(e._id)}`),e.description&&console.log(` ${M.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list groups: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),me.command("get <id>").description("Get device group details").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=de(),n=(0,G.default)("Fetching device group...").start();try{var r,i,o=yield a.deviceGroup({id:e});if(n.stop(),o||(console.log(M.Ay.red("Device group not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(o,null,2));console.log(M.Ay.bold(`\nDevice Group: ${o.name}`)),console.log("─".repeat(60)),console.log(`ID: ${M.Ay.gray(o._id)}`),console.log(`Description: ${o.description||M.Ay.gray("N/A")}`),console.log(`Tags: ${(null==(r=o.tags)?void 0:r.join(", "))||M.Ay.gray("None")}`),console.log(`Created: ${M.Ay.gray(o.create_datetime)}`),console.log(`Modified: ${M.Ay.gray(o.last_modify_datetime)}`),(null==(i=o.devices)?void 0:i.length)>0&&(console.log(`\n${M.Ay.bold("Devices")} (${o.devices.length})`),o.devices.forEach(function(e){var t=e.device_target_name||e.device_id;console.log(` - ${t} ${M.Ay.gray(`(${e.device_id})`)}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get group: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),me.command("devices <id>").description("List devices in a group with status").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=de(),n=(0,G.default)("Fetching devices...").start();try{var r=yield a.devicesByGroup({id:e});if(n.stop(),t.json)return void console.log(JSON.stringify(r,null,2));if(!r||0===r.length)return void console.log(M.Ay.yellow("No devices in this group"));console.log(M.Ay.bold("\nDevices in Group")),console.log("─".repeat(80)),r.forEach(function(e){var t,a,n=null==(t=e.entry_detail)||null==(t=t.watch_dog_timer)?void 0:t.last_alive_time,r=ce(n),i=e.name||e.device_name||e.device_target_name,o=(null==(a=e.entry_detail)||null==(a=a.application)?void 0:a.name)||M.Ay.gray("No app");console.log(`${r} ${M.Ay.cyan(i.padEnd(30))} ${o}`)}),console.log("─".repeat(80))}catch(e){n.fail(`Failed to get devices: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),me.command("dispatch <id> <action>").description("Dispatch action to all devices in group").action(function(){var e=O(function*(e,t){var a=de(),n=(0,G.default)(`Dispatching ${t}...`).start(),r=["refresh","clear-cache","system-menu-open","system-menu-close","system-info-open","system-info-close","local-sync-panel-open","local-sync-panel-close","debug-panel-open","debug-panel-close","logging-on","logging-off","test-panel-open","test-panel-close"];r.includes(t)||(n.fail(`Invalid action. Valid actions: ${r.join(", ")}`),process.exit(1));try{var i=yield a.dispatchDeviceGroupAction({id:e,action:t});n.succeed(`Action dispatched: ${M.Ay.green(t)}`),i&&(console.log(`Success: ${M.Ay.green(i.success||0)}`),console.log(`Failed: ${M.Ay.red(i.failed||0)}`))}catch(e){n.fail(`Failed to dispatch action: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),me.command("refresh <id>").description("Refresh all devices in group").action(function(){var e=O(function*(e){var t=de(),a=(0,G.default)("Refreshing devices...").start();try{var n=yield t.dispatchDeviceGroupAction({id:e,action:"refresh"});a.succeed("Devices refreshed"),n&&(console.log(`Success: ${M.Ay.green(n.success||0)}`),console.log(`Failed: ${M.Ay.red(n.failed||0)}`))}catch(e){a.fail(`Failed to refresh: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),me.command("monitor <id>").description("Monitor devices in group (polls every 60s)").option("-i, --interval <seconds>","Polling interval in seconds","60").action(function(){var e=O(function*(e,t){var a=de(),n=1e3*parseInt(t.interval,10);console.log(M.Ay.bold("\nDevice Group Monitor")),console.log(M.Ay.gray(`Polling every ${t.interval}s. Press Ctrl+C to stop.\n`));var r=function(){var t=O(function*(){try{var t=yield Promise.all([a.deviceGroup({id:e}),a.devicesByGroup({id:e})]),n=X(t,2),r=n[0],i=n[1];if(process.stdout.write(""),console.log(M.Ay.bold(`Device Group: ${r.name}`)+M.Ay.gray(` - ${(new Date).toLocaleTimeString()}`)),console.log("─".repeat(80)),!i||0===i.length)return void console.log(M.Ay.yellow("No devices in this group"));var o=0,s=0;i.forEach(function(e){var t,a,n=null==(t=e.entry_detail)||null==(t=t.watch_dog_timer)?void 0:t.last_alive_time,r=ce(n),i=e.name||e.device_name||e.device_target_name,p=(null==(a=e.entry_detail)||null==(a=a.application)?void 0:a.name)||M.Ay.gray("No app");n&&Date.now()-new Date(n).getTime()<=ue?o++:s++,console.log(`${r} ${M.Ay.cyan(i.padEnd(30))} ${p}`)}),console.log("─".repeat(80)),console.log(`Online: ${M.Ay.green(o)} Offline: ${M.Ay.red(s)}`),console.log(`\n${M.Ay.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(M.Ay.red(`Error: ${e.message}`))}});return function(){return t.apply(this,arguments)}}();yield r(),setInterval(r,n)});return function(t,a){return e.apply(this,arguments)}}());var fe=c(147),_e=function(){var e=(0,V.getCurrentProfile)(),t=(0,V.getToken)(e);return t||(console.error(M.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,$.createClient)((0,V.getBaseUrl)(),t)},he=function(){var e=O(function*(e){var t=yield e.workspace();if(!(0,J.wR)(t))throw new Error("Media workspace not enabled for this workspace")});return function(t){return e.apply(this,arguments)}}(),Ee=new P("media").description("Media Flow support");Ee.command("boxes").description("List Media Flow boxes").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e){var t=_e(),a=(0,G.default)("Fetching media boxes...").start();try{yield he(t);var n=yield t.mediaBoxes();if(a.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(M.Ay.yellow("No media boxes found"));console.log(M.Ay.bold("\nMedia Boxes")),console.log("─".repeat(80)),n.forEach(function(e){var t;console.log(`${M.Ay.cyan(e.name||"Unnamed")} ${M.Ay.gray(e.id)}`),e.description&&console.log(` ${e.description}`),null!=(t=e.tags)&&t.length&&console.log(` Tags: ${e.tags.join(", ")}`),null!=e.size&&console.log(` Size: ${e.size}`),console.log()})}catch(e){a.fail(`Failed to list media boxes: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),Ee.command("box <id>").description("Get Media Flow box details").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=_e(),n=(0,G.default)("Fetching media box...").start();try{var r,i;yield he(a);var o=yield a.mediaBox({id:e});if(n.stop(),o||(console.log(M.Ay.red("Media box not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(o,null,2));console.log(M.Ay.bold(`\nMedia Box: ${o.name||"Unnamed"}`)),console.log("─".repeat(60)),console.log(`ID: ${M.Ay.gray(o.id)}`),console.log(`Description: ${o.description||M.Ay.gray("N/A")}`),console.log(`Tags: ${(null==(r=o.tags)?void 0:r.join(", "))||M.Ay.gray("None")}`),null!=o.size&&console.log(`Size: ${o.size}`),null!=(i=o.passcodes)&&i.length&&(console.log(`\n${M.Ay.bold("Passcodes")}`),o.passcodes.forEach(function(e){console.log(`- ${e.name||"Passcode"}: ${e.code}`)})),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get media box: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ee.command("files <boxId>").description("List Media Flow files in a box").option("-t, --types <types>","Comma-separated file types to include").option("-u, --user-tag <tag>","Filter by user tag (repeatable)",function(e,t){return[].concat(fe(t),[e])},[]).option("-l, --limit <limit>","Limit results",function(e){return Number.parseInt(e,10)}).option("-o, --offset <offset>","Offset results",function(e){return Number.parseInt(e,10)}).option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=_e(),n=(0,G.default)("Fetching media files...").start();try{var r;yield he(a);var i=t.types?t.types.split(",").map(function(e){return e.trim()}).filter(Boolean):void 0,o=null!=(r=t.userTag)&&r.length?t.userTag:void 0,s=yield a.mediaFiles({boxId:e,includeTypes:i,userTags:o,limit:t.limit,offset:t.offset});if(n.stop(),t.json)return void console.log(JSON.stringify(s,null,2));if(!s||0===s.length)return void console.log(M.Ay.yellow("No media files found"));console.log(M.Ay.bold(`\nMedia Files (${s.length})`)),console.log("─".repeat(100)),s.forEach(function(e){var t;console.log(`${M.Ay.cyan(e.name||"Unnamed")} ${M.Ay.gray(e.id)}`),console.log(` Type: ${e.fileType}`),null!=(t=e.userTags)&&t.length&&console.log(` Tags: ${e.userTags.join(", ")}`),e.updatedAt&&console.log(` Updated: ${new Date(e.updatedAt).toLocaleString()}`),console.log()})}catch(e){n.fail(`Failed to list media files: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}()),Ee.command("file <id>").description("Get Media Flow file details").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e,t){var a=_e(),n=(0,G.default)("Fetching media file...").start();try{var r,i;yield he(a);var o=yield a.mediaFile({id:e});if(n.stop(),o||(console.log(M.Ay.red("Media file not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(o,null,2));console.log(M.Ay.bold(`\nMedia File: ${o.name||"Unnamed"}`)),console.log("─".repeat(60)),console.log(`ID: ${M.Ay.gray(o.id)}`),console.log(`Box ID: ${M.Ay.gray(o.boxId)}`),console.log(`Type: ${o.fileType}`),console.log(`Description: ${o.description||M.Ay.gray("N/A")}`),console.log(`Tags: ${(null==(r=o.userTags)?void 0:r.join(", "))||M.Ay.gray("None")}`),console.log(`Created: ${M.Ay.gray(o.createdAt||"N/A")}`),console.log(`Updated: ${M.Ay.gray(o.updatedAt||"N/A")}`);var s=(0,J.Gu)(o),p=(0,J.Gu)(o,{preferThumbnail:!0});null!=(i=o.meta)&&i.originalFileKey&&console.log(`Original Key: ${M.Ay.gray(o.meta.originalFileKey)}`),s&&console.log(`Original URL: ${M.Ay.gray(s)}`),p&&p!==s&&console.log(`Thumbnail URL: ${M.Ay.gray(p)}`),console.log("─".repeat(60))}catch(e){n.fail(`Failed to get media file: ${e.message}`),process.exit(1)}});return function(t,a){return e.apply(this,arguments)}}());var ye,Te,Re={prod:"https://display.bricks.tools",beta:"https://display-beta.bricks.tools",dev:"http://localhost:3001"},ge=function(e){var t=Object.entries(Re).find(function(t){var a=X(t,2)[1];return e===a});return t?t[0]:null},ve=new P("config").description("CLI configuration management");ve.command("endpoint").argument("[environment]","Environment to use (prod, beta, dev)").description("Show or set the API endpoint environment").action(function(e){var t=(0,V.getBaseUrl)(),a=ge(t);if(!e)return console.log(M.Ay.bold("\nAPI Endpoint Configuration")),console.log("─".repeat(50)),console.log(`Current URL: ${M.Ay.cyan(t)}`),a?console.log(`Environment: ${M.Ay.green(a)}`):console.log(`Environment: ${M.Ay.yellow("custom")}`),console.log("─".repeat(50)),console.log(M.Ay.gray("\nAvailable environments:")),Object.entries(Re).forEach(function(e){var a=X(e,2),n=a[0],r=a[1],i=t===r?M.Ay.green("● "):" ",o=t===r?M.Ay.green(n):n;console.log(`${i}${o.padEnd(8)} ${M.Ay.gray(r)}`)}),console.log(""),void console.log(M.Ay.gray("Usage: bricks config endpoint <prod|beta|dev>"));var n=Object.keys(Re);n.includes(e)||(console.error(M.Ay.red(`Invalid environment: ${e}`)),console.log(M.Ay.gray(`Valid options: ${n.join(", ")}`)),process.exit(1));var r=Re[e];t!==r?((0,V.setBaseUrl)(r),console.log(M.Ay.green(`✓ Endpoint changed to ${e}: ${r}`)),console.log(M.Ay.yellow("\nNote: You may need to re-authenticate if your token is for a different environment.")),console.log(M.Ay.gray("Use `bricks auth status` to check your connection."))):console.log(M.Ay.yellow(`Already using ${e} environment: ${r}`))}),ve.command("show").description("Show current configuration").option("-j, --json","Output as JSON").action(function(e){var t=(0,V.getBaseUrl)(),a=ge(t);e.json?console.log(JSON.stringify({endpoint:t,environment:a||"custom"},null,2)):(console.log(M.Ay.bold("\nBRICKS CLI Configuration")),console.log("─".repeat(50)),console.log(`API Endpoint: ${M.Ay.cyan(t)}`),a?console.log(`Environment: ${M.Ay.green(a)}`):console.log(`Environment: ${M.Ay.yellow("custom")}`),console.log("─".repeat(50)))}),function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const a of e)t[a]=a;return t},e.getValidEnumValues=t=>{const a=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),n={};for(const e of a)n[e]=t[e];return e.objectValues(n)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.push(a);return t},e.find=(e,t)=>{for(const a of e)if(t(a))return a},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(ye||(ye={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(Te||(Te={}));const Oe=ye.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ne=e=>{switch(typeof e){case"undefined":return Oe.undefined;case"string":return Oe.string;case"number":return Number.isNaN(e)?Oe.nan:Oe.number;case"boolean":return Oe.boolean;case"function":return Oe.function;case"bigint":return Oe.bigint;case"symbol":return Oe.symbol;case"object":return Array.isArray(e)?Oe.array:null===e?Oe.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?Oe.promise:"undefined"!=typeof Map&&e instanceof Map?Oe.map:"undefined"!=typeof Set&&e instanceof Set?Oe.set:"undefined"!=typeof Date&&e instanceof Date?Oe.date:Oe.object;default:return Oe.unknown}},be=ye.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"]);class Ae extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},a={_errors:[]},n=e=>{for(const r of e.issues)if("invalid_union"===r.code)r.unionErrors.map(n);else if("invalid_return_type"===r.code)n(r.returnTypeError);else if("invalid_arguments"===r.code)n(r.argumentsError);else if(0===r.path.length)a._errors.push(t(r));else{let e=a,n=0;for(;n<r.path.length;){const a=r.path[n];n===r.path.length-1?(e[a]=e[a]||{_errors:[]},e[a]._errors.push(t(r))):e[a]=e[a]||{_errors:[]},e=e[a],n++}}};return n(this),a}static assert(e){if(!(e instanceof Ae))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ye.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},a=[];for(const n of this.issues)if(n.path.length>0){const a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else a.push(e(n));return{formErrors:a,fieldErrors:t}}get formErrors(){return this.flatten()}}Ae.create=e=>new Ae(e);const Se=(e,t)=>{let a;switch(e.code){case be.invalid_type:a=e.received===Oe.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case be.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(e.expected,ye.jsonStringifyReplacer)}`;break;case be.unrecognized_keys:a=`Unrecognized key(s) in object: ${ye.joinValues(e.keys,", ")}`;break;case be.invalid_union:a="Invalid input";break;case be.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${ye.joinValues(e.options)}`;break;case be.invalid_enum_value:a=`Invalid enum value. Expected ${ye.joinValues(e.options)}, received '${e.received}'`;break;case be.invalid_arguments:a="Invalid function arguments";break;case be.invalid_return_type:a="Invalid function return type";break;case be.invalid_date:a="Invalid date";break;case be.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(a=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(a=`${a} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?a=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?a=`Invalid input: must end with "${e.validation.endsWith}"`:ye.assertNever(e.validation):a="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case be.too_small:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case be.too_big:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case be.custom:a="Invalid input";break;case be.invalid_intersection_types:a="Intersection results could not be merged";break;case be.not_multiple_of:a=`Number must be a multiple of ${e.multipleOf}`;break;case be.not_finite:a="Number must be finite";break;default:a=t.defaultError,ye.assertNever(e)}return{message:a}};let Ie=Se;function we(){return Ie}var Ce;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(Ce||(Ce={}));const De=e=>{const{data:t,path:a,errorMaps:n,issueData:r}=e,i=[...a,...r.path||[]],o={...r,path:i};if(void 0!==r.message)return{...r,path:i,message:r.message};let s="";const p=n.filter(e=>!!e).slice().reverse();for(const e of p)s=e(o,{data:t,defaultError:s}).message;return{...r,path:i,message:s}};function Pe(e,t){const a=we(),n=De({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,a,a===Se?void 0:Se].filter(e=>!!e)});e.common.issues.push(n)}class je{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const a=[];for(const n of t){if("aborted"===n.status)return ke;"dirty"===n.status&&e.dirty(),a.push(n.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,t){const a=[];for(const e of t){const t=await e.key,n=await e.value;a.push({key:t,value:n})}return je.mergeObjectSync(e,a)}static mergeObjectSync(e,t){const a={};for(const n of t){const{key:t,value:r}=n;if("aborted"===t.status)return ke;if("aborted"===r.status)return ke;"dirty"===t.status&&e.dirty(),"dirty"===r.status&&e.dirty(),"__proto__"===t.value||void 0===r.value&&!n.alwaysSet||(a[t.value]=r.value)}return{status:e.value,value:a}}}const ke=Object.freeze({status:"aborted"}),Le=e=>({status:"dirty",value:e}),Me=e=>({status:"valid",value:e}),Ge=e=>"aborted"===e.status,xe=e=>"dirty"===e.status,Fe=e=>"valid"===e.status,Be=e=>"undefined"!=typeof Promise&&e instanceof Promise;class ze{constructor(e,t,a,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=a,this._key=n}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}}const Ve=(e,t)=>{if(Fe(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;const t=new Ae(e.common.issues);return this._error=t,this._error}}};function $e(e){if(!e)return{};const{errorMap:t,invalid_type_error:a,required_error:n,description:r}=e;if(t&&(a||n))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:r};return{errorMap:(t,r)=>{const{message:i}=e;return"invalid_enum_value"===t.code?{message:i??r.defaultError}:void 0===r.data?{message:i??n??r.defaultError}:"invalid_type"!==t.code?{message:r.defaultError}:{message:i??a??r.defaultError}},description:r}}class Ue{get description(){return this._def.description}_getType(e){return Ne(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Ne(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new je,ctx:{common:e.parent.common,data:e.data,parsedType:Ne(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Be(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const a=this.safeParse(e,t);if(a.success)return a.data;throw a.error}safeParse(e,t){const a={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ne(e)},n=this._parseSync({data:e,path:a.path,parent:a});return Ve(a,n)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ne(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:t});return Fe(a)?{value:a.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>Fe(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){const a=await this.safeParseAsync(e,t);if(a.success)return a.data;throw a.error}async safeParseAsync(e,t){const a={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ne(e)},n=this._parse({data:e,path:a.path,parent:a}),r=await(Be(n)?n:Promise.resolve(n));return Ve(a,r)}refine(e,t){const a=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,n)=>{const r=e(t),i=()=>n.addIssue({code:be.custom,...a(t)});return"undefined"!=typeof Promise&&r instanceof Promise?r.then(e=>!!e||(i(),!1)):!!r||(i(),!1)})}refinement(e,t){return this._refinement((a,n)=>!!e(a)||(n.addIssue("function"==typeof t?t(a,n):t),!1))}_refinement(e){return new Vt({schema:this,typeName:Xt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,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:e=>this["~validate"](e)}}optional(){return $t.create(this,this._def)}nullable(){return Ut.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return St.create(this)}promise(){return zt.create(this,this._def)}or(e){return Ct.create([this,e],this._def)}and(e){return Pt.create(this,e,this._def)}transform(e){return new Vt({...$e(this._def),schema:this,typeName:Xt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Ht({...$e(this._def),innerType:this,defaultValue:t,typeName:Xt.ZodDefault})}brand(){return new Wt({typeName:Xt.ZodBranded,type:this,...$e(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Kt({...$e(this._def),innerType:this,catchValue:t,typeName:Xt.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Qt.create(this,e)}readonly(){return Yt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const He=/^c[^\s-]{8,}$/i,Ke=/^[0-9a-z]+$/,qe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,We=/^[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,Qe=/^[a-z0-9_-]{21}$/i,Ye=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Xe=/^[-+]?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)?)??$/,Je=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let Ze;const et=/^(?:(?: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])$/,tt=/^(?:(?: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])$/,at=/^(([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]))$/,nt=/^(([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])$/,rt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,it=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ot="((\\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])))",st=new RegExp(`^${ot}$`);function pt(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function lt(e){return new RegExp(`^${pt(e)}$`)}function dt(e){let t=`${ot}T${pt(e)}`;const a=[];return a.push(e.local?"Z?":"Z"),e.offset&&a.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${a.join("|")})`,new RegExp(`^${t}$`)}function ut(e,t){return!("v4"!==t&&t||!et.test(e))||!("v6"!==t&&t||!at.test(e))}function ct(e,t){if(!Ye.test(e))return!1;try{const[a]=e.split(".");if(!a)return!1;const n=a.replace(/-/g,"+").replace(/_/g,"/").padEnd(a.length+(4-a.length%4)%4,"="),r=JSON.parse(atob(n));return"object"==typeof r&&null!==r&&((!("typ"in r)||"JWT"===r?.typ)&&(!!r.alg&&(!t||r.alg===t)))}catch{return!1}}function mt(e,t){return!("v4"!==t&&t||!tt.test(e))||!("v6"!==t&&t||!nt.test(e))}class ft extends Ue{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==Oe.string){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.string,received:t.parsedType}),ke}const t=new je;let a;for(const n of this._def.checks)if("min"===n.kind)e.data.length<n.value&&(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if("max"===n.kind)e.data.length>n.value&&(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if("length"===n.kind){const r=e.data.length>n.value,i=e.data.length<n.value;(r||i)&&(a=this._getOrReturnCtx(e,a),r?Pe(a,{code:be.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):i&&Pe(a,{code:be.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if("email"===n.kind)Je.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"email",code:be.invalid_string,message:n.message}),t.dirty());else if("emoji"===n.kind)Ze||(Ze=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ze.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"emoji",code:be.invalid_string,message:n.message}),t.dirty());else if("uuid"===n.kind)We.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"uuid",code:be.invalid_string,message:n.message}),t.dirty());else if("nanoid"===n.kind)Qe.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"nanoid",code:be.invalid_string,message:n.message}),t.dirty());else if("cuid"===n.kind)He.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"cuid",code:be.invalid_string,message:n.message}),t.dirty());else if("cuid2"===n.kind)Ke.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"cuid2",code:be.invalid_string,message:n.message}),t.dirty());else if("ulid"===n.kind)qe.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"ulid",code:be.invalid_string,message:n.message}),t.dirty());else if("url"===n.kind)try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),Pe(a,{validation:"url",code:be.invalid_string,message:n.message}),t.dirty()}else if("regex"===n.kind){n.regex.lastIndex=0;n.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"regex",code:be.invalid_string,message:n.message}),t.dirty())}else if("trim"===n.kind)e.data=e.data.trim();else if("includes"===n.kind)e.data.includes(n.value,n.position)||(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty());else if("toLowerCase"===n.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===n.kind)e.data=e.data.toUpperCase();else if("startsWith"===n.kind)e.data.startsWith(n.value)||(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty());else if("endsWith"===n.kind)e.data.endsWith(n.value)||(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty());else if("datetime"===n.kind){dt(n).test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.invalid_string,validation:"datetime",message:n.message}),t.dirty())}else if("date"===n.kind){st.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.invalid_string,validation:"date",message:n.message}),t.dirty())}else if("time"===n.kind){lt(n).test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.invalid_string,validation:"time",message:n.message}),t.dirty())}else"duration"===n.kind?Xe.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"duration",code:be.invalid_string,message:n.message}),t.dirty()):"ip"===n.kind?ut(e.data,n.version)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"ip",code:be.invalid_string,message:n.message}),t.dirty()):"jwt"===n.kind?ct(e.data,n.alg)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"jwt",code:be.invalid_string,message:n.message}),t.dirty()):"cidr"===n.kind?mt(e.data,n.version)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"cidr",code:be.invalid_string,message:n.message}),t.dirty()):"base64"===n.kind?rt.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"base64",code:be.invalid_string,message:n.message}),t.dirty()):"base64url"===n.kind?it.test(e.data)||(a=this._getOrReturnCtx(e,a),Pe(a,{validation:"base64url",code:be.invalid_string,message:n.message}),t.dirty()):ye.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,a){return this.refinement(t=>e.test(t),{validation:t,code:be.invalid_string,...Ce.errToObj(a)})}_addCheck(e){return new ft({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Ce.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Ce.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Ce.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Ce.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Ce.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Ce.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Ce.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Ce.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Ce.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Ce.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Ce.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Ce.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Ce.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Ce.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...Ce.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Ce.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Ce.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...Ce.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Ce.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Ce.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Ce.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Ce.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Ce.errToObj(t)})}nonempty(e){return this.min(1,Ce.errToObj(e))}trim(){return new ft({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ft({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ft({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function _t(e,t){const a=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,r=a>n?a:n;return Number.parseInt(e.toFixed(r).replace(".",""))%Number.parseInt(t.toFixed(r).replace(".",""))/10**r}ft.create=e=>new ft({checks:[],typeName:Xt.ZodString,coerce:e?.coerce??!1,...$e(e)});class ht extends Ue{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==Oe.number){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.number,received:t.parsedType}),ke}let t;const a=new je;for(const n of this._def.checks)if("int"===n.kind)ye.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.invalid_type,expected:"integer",received:"float",message:n.message}),a.dirty());else if("min"===n.kind){(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty())}else if("max"===n.kind){(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty())}else"multipleOf"===n.kind?0!==_t(e.data,n.value)&&(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.not_finite,message:n.message}),a.dirty()):ye.assertNever(n);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ce.toString(t))}setLimit(e,t,a,n){return new ht({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Ce.toString(n)}]})}_addCheck(e){return new ht({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Ce.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ce.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ce.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ce.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ce.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ce.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Ce.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ce.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ce.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&ye.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const a of this._def.checks){if("finite"===a.kind||"int"===a.kind||"multipleOf"===a.kind)return!0;"min"===a.kind?(null===t||a.value>t)&&(t=a.value):"max"===a.kind&&(null===e||a.value<e)&&(e=a.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ht.create=e=>new ht({checks:[],typeName:Xt.ZodNumber,coerce:e?.coerce||!1,...$e(e)});class Et extends Ue{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==Oe.bigint)return this._getInvalidInput(e);let t;const a=new je;for(const n of this._def.checks)if("min"===n.kind){(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty())}else if("max"===n.kind){(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty())}else"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),Pe(t,{code:be.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):ye.assertNever(n);return{status:a.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.bigint,received:t.parsedType}),ke}gte(e,t){return this.setLimit("min",e,!0,Ce.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Ce.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Ce.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Ce.toString(t))}setLimit(e,t,a,n){return new Et({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:Ce.toString(n)}]})}_addCheck(e){return new Et({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ce.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ce.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ce.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ce.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Ce.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}Et.create=e=>new Et({checks:[],typeName:Xt.ZodBigInt,coerce:e?.coerce??!1,...$e(e)});class yt extends Ue{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==Oe.boolean){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.boolean,received:t.parsedType}),ke}return Me(e.data)}}yt.create=e=>new yt({typeName:Xt.ZodBoolean,coerce:e?.coerce||!1,...$e(e)});class Tt extends Ue{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==Oe.date){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.date,received:t.parsedType}),ke}if(Number.isNaN(e.data.getTime())){return Pe(this._getOrReturnCtx(e),{code:be.invalid_date}),ke}const t=new je;let a;for(const n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(a=this._getOrReturnCtx(e,a),Pe(a,{code:be.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):ye.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Tt({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Ce.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Ce.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}Tt.create=e=>new Tt({checks:[],coerce:e?.coerce||!1,typeName:Xt.ZodDate,...$e(e)});class Rt extends Ue{_parse(e){if(this._getType(e)!==Oe.symbol){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.symbol,received:t.parsedType}),ke}return Me(e.data)}}Rt.create=e=>new Rt({typeName:Xt.ZodSymbol,...$e(e)});class gt extends Ue{_parse(e){if(this._getType(e)!==Oe.undefined){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.undefined,received:t.parsedType}),ke}return Me(e.data)}}gt.create=e=>new gt({typeName:Xt.ZodUndefined,...$e(e)});class vt extends Ue{_parse(e){if(this._getType(e)!==Oe.null){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.null,received:t.parsedType}),ke}return Me(e.data)}}vt.create=e=>new vt({typeName:Xt.ZodNull,...$e(e)});class Ot extends Ue{constructor(){super(...arguments),this._any=!0}_parse(e){return Me(e.data)}}Ot.create=e=>new Ot({typeName:Xt.ZodAny,...$e(e)});class Nt extends Ue{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Me(e.data)}}Nt.create=e=>new Nt({typeName:Xt.ZodUnknown,...$e(e)});class bt extends Ue{_parse(e){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.never,received:t.parsedType}),ke}}bt.create=e=>new bt({typeName:Xt.ZodNever,...$e(e)});class At extends Ue{_parse(e){if(this._getType(e)!==Oe.undefined){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.void,received:t.parsedType}),ke}return Me(e.data)}}At.create=e=>new At({typeName:Xt.ZodVoid,...$e(e)});class St extends Ue{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),n=this._def;if(t.parsedType!==Oe.array)return Pe(t,{code:be.invalid_type,expected:Oe.array,received:t.parsedType}),ke;if(null!==n.exactLength){const e=t.data.length>n.exactLength.value,r=t.data.length<n.exactLength.value;(e||r)&&(Pe(t,{code:e?be.too_big:be.too_small,minimum:r?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),a.dirty())}if(null!==n.minLength&&t.data.length<n.minLength.value&&(Pe(t,{code:be.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),a.dirty()),null!==n.maxLength&&t.data.length>n.maxLength.value&&(Pe(t,{code:be.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((e,a)=>n.type._parseAsync(new ze(t,e,t.path,a)))).then(e=>je.mergeArray(a,e));const r=[...t.data].map((e,a)=>n.type._parseSync(new ze(t,e,t.path,a)));return je.mergeArray(a,r)}get element(){return this._def.type}min(e,t){return new St({...this._def,minLength:{value:e,message:Ce.toString(t)}})}max(e,t){return new St({...this._def,maxLength:{value:e,message:Ce.toString(t)}})}length(e,t){return new St({...this._def,exactLength:{value:e,message:Ce.toString(t)}})}nonempty(e){return this.min(1,e)}}function It(e){if(e instanceof wt){const t={};for(const a in e.shape){const n=e.shape[a];t[a]=$t.create(It(n))}return new wt({...e._def,shape:()=>t})}return e instanceof St?new St({...e._def,type:It(e.element)}):e instanceof $t?$t.create(It(e.unwrap())):e instanceof Ut?Ut.create(It(e.unwrap())):e instanceof jt?jt.create(e.items.map(e=>It(e))):e}St.create=(e,t)=>new St({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Xt.ZodArray,...$e(t)});class wt extends Ue{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=ye.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==Oe.object){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.object,received:t.parsedType}),ke}const{status:t,ctx:a}=this._processInputParams(e),{shape:n,keys:r}=this._getCached(),i=[];if(!(this._def.catchall instanceof bt&&"strip"===this._def.unknownKeys))for(const e in a.data)r.includes(e)||i.push(e);const o=[];for(const e of r){const t=n[e],r=a.data[e];o.push({key:{status:"valid",value:e},value:t._parse(new ze(a,r,a.path,e)),alwaysSet:e in a.data})}if(this._def.catchall instanceof bt){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of i)o.push({key:{status:"valid",value:e},value:{status:"valid",value:a.data[e]}});else if("strict"===e)i.length>0&&(Pe(a,{code:be.unrecognized_keys,keys:i}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of i){const n=a.data[t];o.push({key:{status:"valid",value:t},value:e._parse(new ze(a,n,a.path,t)),alwaysSet:t in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of o){const a=await t.key,n=await t.value;e.push({key:a,value:n,alwaysSet:t.alwaysSet})}return e}).then(e=>je.mergeObjectSync(t,e)):je.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return Ce.errToObj,new wt({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,a)=>{const n=this._def.errorMap?.(t,a).message??a.defaultError;return"unrecognized_keys"===t.code?{message:Ce.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new wt({...this._def,unknownKeys:"strip"})}passthrough(){return new wt({...this._def,unknownKeys:"passthrough"})}extend(e){return new wt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new wt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Xt.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new wt({...this._def,catchall:e})}pick(e){const t={};for(const a of ye.objectKeys(e))e[a]&&this.shape[a]&&(t[a]=this.shape[a]);return new wt({...this._def,shape:()=>t})}omit(e){const t={};for(const a of ye.objectKeys(this.shape))e[a]||(t[a]=this.shape[a]);return new wt({...this._def,shape:()=>t})}deepPartial(){return It(this)}partial(e){const t={};for(const a of ye.objectKeys(this.shape)){const n=this.shape[a];e&&!e[a]?t[a]=n:t[a]=n.optional()}return new wt({...this._def,shape:()=>t})}required(e){const t={};for(const a of ye.objectKeys(this.shape))if(e&&!e[a])t[a]=this.shape[a];else{let e=this.shape[a];for(;e instanceof $t;)e=e._def.innerType;t[a]=e}return new wt({...this._def,shape:()=>t})}keyof(){return xt(ye.objectKeys(this.shape))}}wt.create=(e,t)=>new wt({shape:()=>e,unknownKeys:"strip",catchall:bt.create(),typeName:Xt.ZodObject,...$e(t)}),wt.strictCreate=(e,t)=>new wt({shape:()=>e,unknownKeys:"strict",catchall:bt.create(),typeName:Xt.ZodObject,...$e(t)}),wt.lazycreate=(e,t)=>new wt({shape:e,unknownKeys:"strip",catchall:bt.create(),typeName:Xt.ZodObject,...$e(t)});class Ct extends Ue{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.options;if(t.common.async)return Promise.all(a.map(async e=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const a of e)if("dirty"===a.result.status)return t.common.issues.push(...a.ctx.common.issues),a.result;const a=e.map(e=>new Ae(e.ctx.common.issues));return Pe(t,{code:be.invalid_union,unionErrors:a}),ke});{let e;const n=[];for(const r of a){const a={...t,common:{...t.common,issues:[]},parent:null},i=r._parseSync({data:t.data,path:t.path,parent:a});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:a}),a.common.issues.length&&n.push(a.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const r=n.map(e=>new Ae(e));return Pe(t,{code:be.invalid_union,unionErrors:r}),ke}}get options(){return this._def.options}}Ct.create=(e,t)=>new Ct({options:e,typeName:Xt.ZodUnion,...$e(t)});function Dt(e,t){const a=Ne(e),n=Ne(t);if(e===t)return{valid:!0,data:e};if(a===Oe.object&&n===Oe.object){const a=ye.objectKeys(t),n=ye.objectKeys(e).filter(e=>-1!==a.indexOf(e)),r={...e,...t};for(const a of n){const n=Dt(e[a],t[a]);if(!n.valid)return{valid:!1};r[a]=n.data}return{valid:!0,data:r}}if(a===Oe.array&&n===Oe.array){if(e.length!==t.length)return{valid:!1};const a=[];for(let n=0;n<e.length;n++){const r=Dt(e[n],t[n]);if(!r.valid)return{valid:!1};a.push(r.data)}return{valid:!0,data:a}}return a===Oe.date&&n===Oe.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}class Pt extends Ue{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),n=(e,n)=>{if(Ge(e)||Ge(n))return ke;const r=Dt(e.value,n.value);return r.valid?((xe(e)||xe(n))&&t.dirty(),{status:t.value,value:r.data}):(Pe(a,{code:be.invalid_intersection_types}),ke)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([e,t])=>n(e,t)):n(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}Pt.create=(e,t,a)=>new Pt({left:e,right:t,typeName:Xt.ZodIntersection,...$e(a)});class jt extends Ue{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==Oe.array)return Pe(a,{code:be.invalid_type,expected:Oe.array,received:a.parsedType}),ke;if(a.data.length<this._def.items.length)return Pe(a,{code:be.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ke;!this._def.rest&&a.data.length>this._def.items.length&&(Pe(a,{code:be.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...a.data].map((e,t)=>{const n=this._def.items[t]||this._def.rest;return n?n._parse(new ze(a,e,a.path,t)):null}).filter(e=>!!e);return a.common.async?Promise.all(n).then(e=>je.mergeArray(t,e)):je.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new jt({...this._def,rest:e})}}jt.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new jt({items:e,typeName:Xt.ZodTuple,rest:null,...$e(t)})};class kt extends Ue{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==Oe.map)return Pe(a,{code:be.invalid_type,expected:Oe.map,received:a.parsedType}),ke;const n=this._def.keyType,r=this._def.valueType,i=[...a.data.entries()].map(([e,t],i)=>({key:n._parse(new ze(a,e,a.path,[i,"key"])),value:r._parse(new ze(a,t,a.path,[i,"value"]))}));if(a.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const a of i){const n=await a.key,r=await a.value;if("aborted"===n.status||"aborted"===r.status)return ke;"dirty"!==n.status&&"dirty"!==r.status||t.dirty(),e.set(n.value,r.value)}return{status:t.value,value:e}})}{const e=new Map;for(const a of i){const n=a.key,r=a.value;if("aborted"===n.status||"aborted"===r.status)return ke;"dirty"!==n.status&&"dirty"!==r.status||t.dirty(),e.set(n.value,r.value)}return{status:t.value,value:e}}}}kt.create=(e,t,a)=>new kt({valueType:t,keyType:e,typeName:Xt.ZodMap,...$e(a)});class Lt extends Ue{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==Oe.set)return Pe(a,{code:be.invalid_type,expected:Oe.set,received:a.parsedType}),ke;const n=this._def;null!==n.minSize&&a.data.size<n.minSize.value&&(Pe(a,{code:be.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),null!==n.maxSize&&a.data.size>n.maxSize.value&&(Pe(a,{code:be.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const r=this._def.valueType;function i(e){const a=new Set;for(const n of e){if("aborted"===n.status)return ke;"dirty"===n.status&&t.dirty(),a.add(n.value)}return{status:t.value,value:a}}const o=[...a.data.values()].map((e,t)=>r._parse(new ze(a,e,a.path,t)));return a.common.async?Promise.all(o).then(e=>i(e)):i(o)}min(e,t){return new Lt({...this._def,minSize:{value:e,message:Ce.toString(t)}})}max(e,t){return new Lt({...this._def,maxSize:{value:e,message:Ce.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Lt.create=(e,t)=>new Lt({valueType:e,minSize:null,maxSize:null,typeName:Xt.ZodSet,...$e(t)});class Mt extends Ue{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Mt.create=(e,t)=>new Mt({getter:e,typeName:Xt.ZodLazy,...$e(t)});class Gt extends Ue{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return Pe(t,{received:t.data,code:be.invalid_literal,expected:this._def.value}),ke}return{status:"valid",value:e.data}}get value(){return this._def.value}}function xt(e,t){return new Ft({values:e,typeName:Xt.ZodEnum,...$e(t)})}Gt.create=(e,t)=>new Gt({value:e,typeName:Xt.ZodLiteral,...$e(t)});class Ft extends Ue{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),a=this._def.values;return Pe(t,{expected:ye.joinValues(a),received:t.parsedType,code:be.invalid_type}),ke}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),a=this._def.values;return Pe(t,{received:t.data,code:be.invalid_enum_value,options:a}),ke}return Me(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Ft.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ft.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}Ft.create=xt;class Bt extends Ue{_parse(e){const t=ye.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==Oe.string&&a.parsedType!==Oe.number){const e=ye.objectValues(t);return Pe(a,{expected:ye.joinValues(e),received:a.parsedType,code:be.invalid_type}),ke}if(this._cache||(this._cache=new Set(ye.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=ye.objectValues(t);return Pe(a,{received:a.data,code:be.invalid_enum_value,options:e}),ke}return Me(e.data)}get enum(){return this._def.values}}Bt.create=(e,t)=>new Bt({values:e,typeName:Xt.ZodNativeEnum,...$e(t)});class zt extends Ue{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==Oe.promise&&!1===t.common.async)return Pe(t,{code:be.invalid_type,expected:Oe.promise,received:t.parsedType}),ke;const a=t.parsedType===Oe.promise?t.data:Promise.resolve(t.data);return Me(a.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}zt.create=(e,t)=>new zt({type:e,typeName:Xt.ZodPromise,...$e(t)});class Vt extends Ue{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Xt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:a}=this._processInputParams(e),n=this._def.effect||null,r={addIssue:e=>{Pe(a,e),e.fatal?t.abort():t.dirty()},get path(){return a.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===n.type){const e=n.transform(a.data,r);if(a.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return ke;const n=await this._def.schema._parseAsync({data:e,path:a.path,parent:a});return"aborted"===n.status?ke:"dirty"===n.status||"dirty"===t.value?Le(n.value):n});{if("aborted"===t.value)return ke;const n=this._def.schema._parseSync({data:e,path:a.path,parent:a});return"aborted"===n.status?ke:"dirty"===n.status||"dirty"===t.value?Le(n.value):n}}if("refinement"===n.type){const e=e=>{const t=n.refinement(e,r);if(a.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===a.common.async){const n=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===n.status?ke:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(a=>"aborted"===a.status?ke:("dirty"===a.status&&t.dirty(),e(a.value).then(()=>({status:t.value,value:a.value}))))}if("transform"===n.type){if(!1===a.common.async){const e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Fe(e))return ke;const i=n.transform(e.value,r);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(e=>Fe(e)?Promise.resolve(n.transform(e.value,r)).then(e=>({status:t.value,value:e})):ke)}ye.assertNever(n)}}Vt.create=(e,t,a)=>new Vt({schema:e,typeName:Xt.ZodEffects,effect:t,...$e(a)}),Vt.createWithPreprocess=(e,t,a)=>new Vt({schema:t,effect:{type:"preprocess",transform:e},typeName:Xt.ZodEffects,...$e(a)});class $t extends Ue{_parse(e){return this._getType(e)===Oe.undefined?Me(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}$t.create=(e,t)=>new $t({innerType:e,typeName:Xt.ZodOptional,...$e(t)});class Ut extends Ue{_parse(e){return this._getType(e)===Oe.null?Me(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ut.create=(e,t)=>new Ut({innerType:e,typeName:Xt.ZodNullable,...$e(t)});class Ht extends Ue{_parse(e){const{ctx:t}=this._processInputParams(e);let a=t.data;return t.parsedType===Oe.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ht.create=(e,t)=>new Ht({innerType:e,typeName:Xt.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...$e(t)});class Kt extends Ue{_parse(e){const{ctx:t}=this._processInputParams(e),a={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return Be(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new Ae(a.common.issues)},input:a.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new Ae(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}Kt.create=(e,t)=>new Kt({innerType:e,typeName:Xt.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...$e(t)});class qt extends Ue{_parse(e){if(this._getType(e)!==Oe.nan){const t=this._getOrReturnCtx(e);return Pe(t,{code:be.invalid_type,expected:Oe.nan,received:t.parsedType}),ke}return{status:"valid",value:e.data}}}qt.create=e=>new qt({typeName:Xt.ZodNaN,...$e(e)});Symbol("zod_brand");class Wt extends Ue{_parse(e){const{ctx:t}=this._processInputParams(e),a=t.data;return this._def.type._parse({data:a,path:t.path,parent:t})}unwrap(){return this._def.type}}class Qt extends Ue{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?ke:"dirty"===e.status?(t.dirty(),Le(e.value)):this._def.out._parseAsync({data:e.value,path:a.path,parent:a})})()}{const e=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===e.status?ke:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:a.path,parent:a})}}static create(e,t){return new Qt({in:e,out:t,typeName:Xt.ZodPipeline})}}class Yt extends Ue{_parse(e){const t=this._def.innerType._parse(e),a=e=>(Fe(e)&&(e.value=Object.freeze(e.value)),e);return Be(t)?t.then(e=>a(e)):a(t)}unwrap(){return this._def.innerType}}Yt.create=(e,t)=>new Yt({innerType:e,typeName:Xt.ZodReadonly,...$e(t)});wt.lazycreate;var Xt;!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"}(Xt||(Xt={}));const Jt=ft.create,Zt=ht.create,ea=(qt.create,Et.create,yt.create,Tt.create,Rt.create,gt.create,vt.create,Ot.create,Nt.create,bt.create,At.create,St.create),ta=wt.create,aa=(wt.strictCreate,Ct.create,Pt.create,jt.create,kt.create,Lt.create,Mt.create,Gt.create,Ft.create);Bt.create,zt.create,Vt.create,$t.create,Ut.create,Vt.createWithPreprocess,Qt.create,Object.freeze({status:"aborted"});function na(e,t,a){function n(a,n){var r;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(r=a._zod).traits??(r.traits=new Set),a._zod.traits.add(e),t(a,n);for(const e in o.prototype)e in a||Object.defineProperty(a,e,{value:o.prototype[e].bind(a)});a._zod.constr=o,a._zod.def=n}const r=a?.Parent??Object;class i extends r{}function o(e){var t;const r=a?.Parent?new i:this;n(r,e),(t=r._zod).deferred??(t.deferred=[]);for(const e of r._zod.deferred)e();return r}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!(a?.Parent&&t instanceof a.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}Symbol("zod_brand");class ra extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const ia={};function oa(e){return e&&Object.assign(ia,e),ia}const sa=/^[cC][^\s-]{8,}$/,pa=/^[0-9a-z]+$/,la=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,da=/^[0-9a-vA-V]{20}$/,ua=/^[A-Za-z0-9]{27}$/,ca=/^[a-zA-Z0-9_-]{21}$/,ma=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,fa=/^([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})$/,_a=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)$/,ha=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const Ea=/^(?:(?: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])$/,ya=/^(([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})$/,Ta=/^((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])$/,Ra=/^(([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])$/,ga=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,va=/^[A-Za-z0-9_-]*$/,Oa=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Na=/^\+(?:[0-9]){6,14}[0-9]$/,ba="(?:(?:\\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])))",Aa=new RegExp(`^${ba}$`);function Sa(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const Ia=/^\d+$/,wa=/^-?\d+(?:\.\d+)?/i,Ca=/true|false/i,Da=/null/i,Pa=/^[^A-Z]*$/,ja=/^[^a-z]*$/;function ka(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,a])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function La(e,t){return"bigint"==typeof t?t.toString():t}function Ma(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ga(e){return null==e}function xa(e){const t=e.startsWith("^")?1:0,a=e.endsWith("$")?e.length-1:e.length;return e.slice(t,a)}function Fa(e,t,a){Object.defineProperty(e,t,{get(){{const n=a();return e[t]=n,n}},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function Ba(e,t,a){Object.defineProperty(e,t,{value:a,writable:!0,enumerable:!0,configurable:!0})}function za(e){return JSON.stringify(e)}const Va=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function $a(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const Ua=Ma(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Ha(e){if(!1===$a(e))return!1;const t=e.constructor;if(void 0===t)return!0;const a=t.prototype;return!1!==$a(a)&&!1!==Object.prototype.hasOwnProperty.call(a,"isPrototypeOf")}const Ka=new Set(["string","number","symbol"]);new Set(["string","number","bigint","boolean","symbol","undefined"]);function qa(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wa(e,t,a){const n=new e._zod.constr(t??e._zod.def);return t&&!a?.parent||(n._zod.parent=e),n}function Qa(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const Ya={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]};function Xa(e,t=0){for(let a=t;a<e.issues.length;a++)if(!0!==e.issues[a]?.continue)return!0;return!1}function Ja(e,t){return t.map(t=>{var a;return(a=t).path??(a.path=[]),t.path.unshift(e),t})}function Za(e){return"string"==typeof e?e:e?.message}function en(e,t,a){const n={...e,path:e.path??[]};if(!e.message){const r=Za(e.inst?._zod.def?.error?.(e))??Za(t?.error?.(e))??Za(a.customError?.(e))??Za(a.localeError?.(e))??"Invalid input";n.message=r}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function tn(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function an(...e){const[t,a,n]=e;return"string"==typeof t?{message:t,code:"custom",input:a,inst:n}:{...t}}const nn=na("$ZodCheck",(e,t)=>{var a;e._zod??(e._zod={}),e._zod.def=t,(a=e._zod).onattach??(a.onattach=[])}),rn={number:"number",bigint:"bigint",object:"date"},on=na("$ZodCheckLessThan",(e,t)=>{nn.init(e,t);const a=rn[typeof t.value];e._zod.onattach.push(e=>{const a=e._zod.bag,n=(t.inclusive?a.maximum:a.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<n&&(t.inclusive?a.maximum=t.value:a.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:a,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),sn=na("$ZodCheckGreaterThan",(e,t)=>{nn.init(e,t);const a=rn[typeof t.value];e._zod.onattach.push(e=>{const a=e._zod.bag,n=(t.inclusive?a.minimum:a.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>n&&(t.inclusive?a.minimum=t.value:a.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:a,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),pn=na("$ZodCheckMultipleOf",(e,t)=>{nn.init(e,t),e._zod.onattach.push(e=>{var a;(a=e._zod.bag).multipleOf??(a.multipleOf=t.value)}),e._zod.check=a=>{if(typeof a.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof a.value?a.value%t.value===BigInt(0):0===function(e,t){const a=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,r=a>n?a:n;return Number.parseInt(e.toFixed(r).replace(".",""))%Number.parseInt(t.toFixed(r).replace(".",""))/10**r}(a.value,t.value))||a.issues.push({origin:typeof a.value,code:"not_multiple_of",divisor:t.value,input:a.value,inst:e,continue:!t.abort})}}),ln=na("$ZodCheckNumberFormat",(e,t)=>{nn.init(e,t),t.format=t.format||"float64";const a=t.format?.includes("int"),n=a?"int":"number",[r,i]=Ya[t.format];e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,n.minimum=r,n.maximum=i,a&&(n.pattern=Ia)}),e._zod.check=o=>{const s=o.value;if(a){if(!Number.isInteger(s))return void o.issues.push({expected:n,format:t.format,code:"invalid_type",input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?o.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,continue:!t.abort}):o.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,continue:!t.abort}))}s<r&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),s>i&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inst:e})}}),dn=na("$ZodCheckMaxLength",(e,t)=>{var a;nn.init(e,t),(a=e._zod.def).when??(a.when=e=>{const t=e.value;return!Ga(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const a=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const n=a.value;if(n.length<=t.maximum)return;const r=tn(n);a.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),un=na("$ZodCheckMinLength",(e,t)=>{var a;nn.init(e,t),(a=e._zod.def).when??(a.when=e=>{const t=e.value;return!Ga(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const a=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const n=a.value;if(n.length>=t.minimum)return;const r=tn(n);a.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),cn=na("$ZodCheckLengthEquals",(e,t)=>{var a;nn.init(e,t),(a=e._zod.def).when??(a.when=e=>{const t=e.value;return!Ga(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const a=e._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=a=>{const n=a.value,r=n.length;if(r===t.length)return;const i=tn(n),o=r>t.length;a.issues.push({origin:i,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),mn=na("$ZodCheckStringFormat",(e,t)=>{var a,n;nn.init(e,t),e._zod.onattach.push(e=>{const a=e._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(a=e._zod).check??(a.check=a=>{t.pattern.lastIndex=0,t.pattern.test(a.value)||a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),fn=na("$ZodCheckRegex",(e,t)=>{mn.init(e,t),e._zod.check=a=>{t.pattern.lastIndex=0,t.pattern.test(a.value)||a.issues.push({origin:"string",code:"invalid_format",format:"regex",input:a.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),_n=na("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Pa),mn.init(e,t)}),hn=na("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ja),mn.init(e,t)}),En=na("$ZodCheckIncludes",(e,t)=>{nn.init(e,t);const a=qa(t.includes),n=new RegExp("number"==typeof t.position?`^.{${t.position}}${a}`:a);t.pattern=n,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),yn=na("$ZodCheckStartsWith",(e,t)=>{nn.init(e,t);const a=new RegExp(`^${qa(t.prefix)}.*`);t.pattern??(t.pattern=a),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(a)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),Tn=na("$ZodCheckEndsWith",(e,t)=>{nn.init(e,t);const a=new RegExp(`.*${qa(t.suffix)}$`);t.pattern??(t.pattern=a),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(a)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}});const Rn=na("$ZodCheckOverwrite",(e,t)=>{nn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class gn{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),a=Math.min(...t.map(e=>e.length-e.trimStart().length)),n=t.map(e=>e.slice(a)).map(e=>" ".repeat(2*this.indent)+e);for(const e of n)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const vn=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(t,La,2),enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},On=na("$ZodError",vn),Nn=na("$ZodError",vn,{Parent:Error});const bn=e=>(t,a,n,r)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},o=t._zod.run({value:a,issues:[]},i);if(o instanceof Promise)throw new ra;if(o.issues.length){const t=new(r?.Err??e)(o.issues.map(e=>en(e,i,oa())));throw Va(t,r?.callee),t}return o.value},An=bn(Nn),Sn=e=>async(t,a,n,r)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:a,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const t=new(r?.Err??e)(o.issues.map(e=>en(e,i,oa())));throw Va(t,r?.callee),t}return o.value},In=Sn(Nn),wn=e=>(t,a,n)=>{const r=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:a,issues:[]},r);if(i instanceof Promise)throw new ra;return i.issues.length?{success:!1,error:new(e??On)(i.issues.map(e=>en(e,r,oa())))}:{success:!0,data:i.value}},Cn=wn(Nn),Dn=e=>async(t,a,n)=>{const r=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:a,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(e=>en(e,r,oa())))}:{success:!0,data:i.value}},Pn=Dn(Nn),jn={major:4,minor:0,patch:0},kn=na("$ZodType",(e,t)=>{var a;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=jn;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const t of n)for(const a of t._zod.onattach)a(e);if(0===n.length)(a=e._zod).deferred??(a.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,a)=>{let n,r=Xa(e);for(const i of t){if(i._zod.def.when){if(!i._zod.def.when(e))continue}else if(r)continue;const t=e.issues.length,o=i._zod.check(e);if(o instanceof Promise&&!1===a?.async)throw new ra;if(n||o instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await o;e.issues.length!==t&&(r||(r=Xa(e,t)))});else{if(e.issues.length===t)continue;r||(r=Xa(e,t))}}return n?n.then(()=>e):e};e._zod.run=(a,r)=>{const i=e._zod.parse(a,r);if(i instanceof Promise){if(!1===r.async)throw new ra;return i.then(e=>t(e,n,r))}return t(i,n,r)}}e["~standard"]={validate:t=>{try{const a=Cn(e,t);return a.success?{value:a.data}:{issues:a.error?.issues}}catch(a){return Pn(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),Ln=na("$ZodString",(e,t)=>{var a;kn.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(a=e._zod.bag,new RegExp(`^${a?`[\\s\\S]{${a?.minimum??0},${a?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(a,n)=>{if(t.coerce)try{a.value=String(a.value)}catch(n){}return"string"==typeof a.value||a.issues.push({expected:"string",code:"invalid_type",input:a.value,inst:e}),a}}),Mn=na("$ZodStringFormat",(e,t)=>{mn.init(e,t),Ln.init(e,t)}),Gn=na("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=fa),Mn.init(e,t)}),xn=na("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=_a(e))}else t.pattern??(t.pattern=_a());Mn.init(e,t)}),Fn=na("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ha),Mn.init(e,t)}),Bn=na("$ZodURL",(e,t)=>{Mn.init(e,t),e._zod.check=a=>{try{const n=a.value,r=new URL(n),i=r.href;return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||a.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Oa.source,input:a.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||a.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:a.value,inst:e,continue:!t.abort})),void(!n.endsWith("/")&&i.endsWith("/")?a.value=i.slice(0,-1):a.value=i)}catch(n){a.issues.push({code:"invalid_format",format:"url",input:a.value,inst:e,continue:!t.abort})}}}),zn=na("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Mn.init(e,t)}),Vn=na("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ca),Mn.init(e,t)}),$n=na("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=sa),Mn.init(e,t)}),Un=na("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=pa),Mn.init(e,t)}),Hn=na("$ZodULID",(e,t)=>{t.pattern??(t.pattern=la),Mn.init(e,t)}),Kn=na("$ZodXID",(e,t)=>{t.pattern??(t.pattern=da),Mn.init(e,t)}),qn=na("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ua),Mn.init(e,t)}),Wn=na("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=Sa({precision:e.precision}),a=["Z"];e.local&&a.push(""),e.offset&&a.push("([+-]\\d{2}:\\d{2})");const n=`${t}(?:${a.join("|")})`;return new RegExp(`^${ba}T(?:${n})$`)}(t)),Mn.init(e,t)}),Qn=na("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Aa),Mn.init(e,t)}),Yn=na("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${Sa(t)}$`)),Mn.init(e,t)}),Xn=na("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ma),Mn.init(e,t)}),Jn=na("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ea),Mn.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv4"})}),Zn=na("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ya),Mn.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv6"}),e._zod.check=a=>{try{new URL(`http://[${a.value}]`)}catch{a.issues.push({code:"invalid_format",format:"ipv6",input:a.value,inst:e,continue:!t.abort})}}}),er=na("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ta),Mn.init(e,t)}),tr=na("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ra),Mn.init(e,t),e._zod.check=a=>{const[n,r]=a.value.split("/");try{if(!r)throw new Error;const e=Number(r);if(`${e}`!==r)throw new Error;if(e<0||e>128)throw new Error;new URL(`http://[${n}]`)}catch{a.issues.push({code:"invalid_format",format:"cidrv6",input:a.value,inst:e,continue:!t.abort})}}});function ar(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const nr=na("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ga),Mn.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64"}),e._zod.check=a=>{ar(a.value)||a.issues.push({code:"invalid_format",format:"base64",input:a.value,inst:e,continue:!t.abort})}});const rr=na("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=va),Mn.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64url"}),e._zod.check=a=>{(function(e){if(!va.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return ar(t.padEnd(4*Math.ceil(t.length/4),"="))})(a.value)||a.issues.push({code:"invalid_format",format:"base64url",input:a.value,inst:e,continue:!t.abort})}}),ir=na("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Na),Mn.init(e,t)});const or=na("$ZodJWT",(e,t)=>{Mn.init(e,t),e._zod.check=a=>{(function(e,t=null){try{const a=e.split(".");if(3!==a.length)return!1;const[n]=a;if(!n)return!1;const r=JSON.parse(atob(n));return!("typ"in r&&"JWT"!==r?.typ||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}})(a.value,t.alg)||a.issues.push({code:"invalid_format",format:"jwt",input:a.value,inst:e,continue:!t.abort})}}),sr=na("$ZodNumber",(e,t)=>{kn.init(e,t),e._zod.pattern=e._zod.bag.pattern??wa,e._zod.parse=(a,n)=>{if(t.coerce)try{a.value=Number(a.value)}catch(e){}const r=a.value;if("number"==typeof r&&!Number.isNaN(r)&&Number.isFinite(r))return a;const i="number"==typeof r?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return a.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),a}}),pr=na("$ZodNumber",(e,t)=>{ln.init(e,t),sr.init(e,t)}),lr=na("$ZodBoolean",(e,t)=>{kn.init(e,t),e._zod.pattern=Ca,e._zod.parse=(a,n)=>{if(t.coerce)try{a.value=Boolean(a.value)}catch(e){}const r=a.value;return"boolean"==typeof r||a.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),a}}),dr=na("$ZodNull",(e,t)=>{kn.init(e,t),e._zod.pattern=Da,e._zod.values=new Set([null]),e._zod.parse=(t,a)=>{const n=t.value;return null===n||t.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),t}}),ur=na("$ZodUnknown",(e,t)=>{kn.init(e,t),e._zod.parse=e=>e}),cr=na("$ZodNever",(e,t)=>{kn.init(e,t),e._zod.parse=(t,a)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function mr(e,t,a){e.issues.length&&t.issues.push(...Ja(a,e.issues)),t.value[a]=e.value}const fr=na("$ZodArray",(e,t)=>{kn.init(e,t),e._zod.parse=(a,n)=>{const r=a.value;if(!Array.isArray(r))return a.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),a;a.value=Array(r.length);const i=[];for(let e=0;e<r.length;e++){const o=r[e],s=t.element._zod.run({value:o,issues:[]},n);s instanceof Promise?i.push(s.then(t=>mr(t,a,e))):mr(s,a,e)}return i.length?Promise.all(i).then(()=>a):a}});function _r(e,t,a){e.issues.length&&t.issues.push(...Ja(a,e.issues)),t.value[a]=e.value}function hr(e,t,a,n){e.issues.length?void 0===n[a]?t.value[a]=a in n?void 0:e.value:t.issues.push(...Ja(a,e.issues)):void 0===e.value?a in n&&(t.value[a]=void 0):t.value[a]=e.value}const Er=na("$ZodObject",(e,t)=>{kn.init(e,t);const a=Ma(()=>{const e=Object.keys(t.shape);for(const a of e)if(!(t.shape[a]instanceof kn))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const a=(n=t.shape,Object.keys(n).filter(e=>"optional"===n[e]._zod.optin&&"optional"===n[e]._zod.optout));var n;return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(a)}});Fa(e._zod,"propValues",()=>{const e=t.shape,a={};for(const t in e){const n=e[t]._zod;if(n.values){a[t]??(a[t]=new Set);for(const e of n.values)a[t].add(e)}}return a});let n;const r=$a,i=!ia.jitless,o=i&&Ua.value,s=t.catchall;let p;e._zod.parse=(l,d)=>{p??(p=a.value);const u=l.value;if(!r(u))return l.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),l;const c=[];if(i&&o&&!1===d?.async&&!0!==d.jitless)n||(n=(e=>{const t=new gn(["shape","payload","ctx"]),n=a.value,r=e=>{const t=za(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let o=0;for(const e of n.keys)i[e]="key_"+o++;t.write("const newResult = {}");for(const e of n.keys)if(n.optionalKeys.has(e)){const a=i[e];t.write(`const ${a} = ${r(e)};`);const n=za(e);t.write(`\n if (${a}.issues.length) {\n if (input[${n}] === undefined) {\n if (${n} in input) {\n newResult[${n}] = undefined;\n }\n } else {\n payload.issues = payload.issues.concat(\n ${a}.issues.map((iss) => ({\n ...iss,\n path: iss.path ? [${n}, ...iss.path] : [${n}],\n }))\n );\n }\n } else if (${a}.value === undefined) {\n if (${n} in input) newResult[${n}] = undefined;\n } else {\n newResult[${n}] = ${a}.value;\n }\n `)}else{const a=i[e];t.write(`const ${a} = ${r(e)};`),t.write(`\n if (${a}.issues.length) payload.issues = payload.issues.concat(${a}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${za(e)}, ...iss.path] : [${za(e)}]\n })));`),t.write(`newResult[${za(e)}] = ${a}.value`)}t.write("payload.value = newResult;"),t.write("return payload;");const s=t.compile();return(t,a)=>s(e,t,a)})(t.shape)),l=n(l,d);else{l.value={};const e=p.shape;for(const t of p.keys){const a=e[t],n=a._zod.run({value:u[t],issues:[]},d),r="optional"===a._zod.optin&&"optional"===a._zod.optout;n instanceof Promise?c.push(n.then(e=>r?hr(e,l,t,u):_r(e,l,t))):r?hr(n,l,t,u):_r(n,l,t)}}if(!s)return c.length?Promise.all(c).then(()=>l):l;const m=[],f=p.keySet,_=s._zod,h=_.def.type;for(const e of Object.keys(u)){if(f.has(e))continue;if("never"===h){m.push(e);continue}const t=_.run({value:u[e],issues:[]},d);t instanceof Promise?c.push(t.then(t=>_r(t,l,e))):_r(t,l,e)}return m.length&&l.issues.push({code:"unrecognized_keys",keys:m,input:u,inst:e}),c.length?Promise.all(c).then(()=>l):l}});function yr(e,t,a,n){for(const a of e)if(0===a.issues.length)return t.value=a.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:a,errors:e.map(e=>e.issues.map(e=>en(e,n,oa())))}),t}const Tr=na("$ZodUnion",(e,t)=>{kn.init(e,t),Fa(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),Fa(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),Fa(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Fa(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>xa(e.source)).join("|")})$`)}}),e._zod.parse=(a,n)=>{let r=!1;const i=[];for(const e of t.options){const t=e._zod.run({value:a.value,issues:[]},n);if(t instanceof Promise)i.push(t),r=!0;else{if(0===t.issues.length)return t;i.push(t)}}return r?Promise.all(i).then(t=>yr(t,a,e,n)):yr(i,a,e,n)}}),Rr=na("$ZodDiscriminatedUnion",(e,t)=>{Tr.init(e,t);const a=e._zod.parse;Fa(e._zod,"propValues",()=>{const e={};for(const a of t.options){const n=a._zod.propValues;if(!n||0===Object.keys(n).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const[t,a]of Object.entries(n)){e[t]||(e[t]=new Set);for(const n of a)e[t].add(n)}}return e});const n=Ma(()=>{const e=t.options,a=new Map;for(const n of e){const e=n._zod.propValues[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const t of e){if(a.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);a.set(t,n)}}return a});e._zod.parse=(r,i)=>{const o=r.value;if(!$a(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;const s=n.value.get(o?.[t.discriminator]);return s?s._zod.run(r,i):t.unionFallback?a(r,i):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:o,path:[t.discriminator],inst:e}),r)}}),gr=na("$ZodIntersection",(e,t)=>{kn.init(e,t),e._zod.parse=(e,a)=>{const n=e.value,r=t.left._zod.run({value:n,issues:[]},a),i=t.right._zod.run({value:n,issues:[]},a);return r instanceof Promise||i instanceof Promise?Promise.all([r,i]).then(([t,a])=>Or(e,t,a)):Or(e,r,i)}});function vr(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(Ha(e)&&Ha(t)){const a=Object.keys(t),n=Object.keys(e).filter(e=>-1!==a.indexOf(e)),r={...e,...t};for(const a of n){const n=vr(e[a],t[a]);if(!n.valid)return{valid:!1,mergeErrorPath:[a,...n.mergeErrorPath]};r[a]=n.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const a=[];for(let n=0;n<e.length;n++){const r=vr(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};a.push(r.data)}return{valid:!0,data:a}}return{valid:!1,mergeErrorPath:[]}}function Or(e,t,a){if(t.issues.length&&e.issues.push(...t.issues),a.issues.length&&e.issues.push(...a.issues),Xa(e))return e;const n=vr(t.value,a.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}const Nr=na("$ZodRecord",(e,t)=>{kn.init(e,t),e._zod.parse=(a,n)=>{const r=a.value;if(!Ha(r))return a.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),a;const i=[];if(t.keyType._zod.values){const o=t.keyType._zod.values;a.value={};for(const e of o)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){const o=t.valueType._zod.run({value:r[e],issues:[]},n);o instanceof Promise?i.push(o.then(t=>{t.issues.length&&a.issues.push(...Ja(e,t.issues)),a.value[e]=t.value})):(o.issues.length&&a.issues.push(...Ja(e,o.issues)),a.value[e]=o.value)}let s;for(const e in r)o.has(e)||(s=s??[],s.push(e));s&&s.length>0&&a.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:s})}else{a.value={};for(const o of Reflect.ownKeys(r)){if("__proto__"===o)continue;const s=t.keyType._zod.run({value:o,issues:[]},n);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(s.issues.length){a.issues.push({origin:"record",code:"invalid_key",issues:s.issues.map(e=>en(e,n,oa())),input:o,path:[o],inst:e}),a.value[s.value]=s.value;continue}const p=t.valueType._zod.run({value:r[o],issues:[]},n);p instanceof Promise?i.push(p.then(e=>{e.issues.length&&a.issues.push(...Ja(o,e.issues)),a.value[s.value]=e.value})):(p.issues.length&&a.issues.push(...Ja(o,p.issues)),a.value[s.value]=p.value)}}return i.length?Promise.all(i).then(()=>a):a}});const br=na("$ZodEnum",(e,t)=>{kn.init(e,t);const a=ka(t.entries);e._zod.values=new Set(a),e._zod.pattern=new RegExp(`^(${a.filter(e=>Ka.has(typeof e)).map(e=>"string"==typeof e?qa(e):e.toString()).join("|")})$`),e._zod.parse=(t,n)=>{const r=t.value;return e._zod.values.has(r)||t.issues.push({code:"invalid_value",values:a,input:r,inst:e}),t}}),Ar=na("$ZodLiteral",(e,t)=>{kn.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?qa(e):e?e.toString():String(e)).join("|")})$`),e._zod.parse=(a,n)=>{const r=a.value;return e._zod.values.has(r)||a.issues.push({code:"invalid_value",values:t.values,input:r,inst:e}),a}}),Sr=na("$ZodTransform",(e,t)=>{kn.init(e,t),e._zod.parse=(e,a)=>{const n=t.transform(e.value,e);if(a.async){return(n instanceof Promise?n:Promise.resolve(n)).then(t=>(e.value=t,e))}if(n instanceof Promise)throw new ra;return e.value=n,e}}),Ir=na("$ZodOptional",(e,t)=>{kn.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Fa(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Fa(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${xa(e.source)})?$`):void 0}),e._zod.parse=(e,a)=>"optional"===t.innerType._zod.optin?t.innerType._zod.run(e,a):void 0===e.value?e:t.innerType._zod.run(e,a)}),wr=na("$ZodNullable",(e,t)=>{kn.init(e,t),Fa(e._zod,"optin",()=>t.innerType._zod.optin),Fa(e._zod,"optout",()=>t.innerType._zod.optout),Fa(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${xa(e.source)}|null)$`):void 0}),Fa(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,a)=>null===e.value?e:t.innerType._zod.run(e,a)}),Cr=na("$ZodDefault",(e,t)=>{kn.init(e,t),e._zod.optin="optional",Fa(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,a)=>{if(void 0===e.value)return e.value=t.defaultValue,e;const n=t.innerType._zod.run(e,a);return n instanceof Promise?n.then(e=>Dr(e,t)):Dr(n,t)}});function Dr(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Pr=na("$ZodPrefault",(e,t)=>{kn.init(e,t),e._zod.optin="optional",Fa(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,a)=>(void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,a))}),jr=na("$ZodNonOptional",(e,t)=>{kn.init(e,t),Fa(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(a,n)=>{const r=t.innerType._zod.run(a,n);return r instanceof Promise?r.then(t=>kr(t,e)):kr(r,e)}});function kr(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Lr=na("$ZodCatch",(e,t)=>{kn.init(e,t),e._zod.optin="optional",Fa(e._zod,"optout",()=>t.innerType._zod.optout),Fa(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,a)=>{const n=t.innerType._zod.run(e,a);return n instanceof Promise?n.then(n=>(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>en(e,a,oa()))},input:e.value}),e.issues=[]),e)):(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>en(e,a,oa()))},input:e.value}),e.issues=[]),e)}}),Mr=na("$ZodPipe",(e,t)=>{kn.init(e,t),Fa(e._zod,"values",()=>t.in._zod.values),Fa(e._zod,"optin",()=>t.in._zod.optin),Fa(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(e,a)=>{const n=t.in._zod.run(e,a);return n instanceof Promise?n.then(e=>Gr(e,t,a)):Gr(n,t,a)}});function Gr(e,t,a){return Xa(e)?e:t.out._zod.run({value:e.value,issues:e.issues},a)}const xr=na("$ZodReadonly",(e,t)=>{kn.init(e,t),Fa(e._zod,"propValues",()=>t.innerType._zod.propValues),Fa(e._zod,"values",()=>t.innerType._zod.values),Fa(e._zod,"optin",()=>t.innerType._zod.optin),Fa(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(e,a)=>{const n=t.innerType._zod.run(e,a);return n instanceof Promise?n.then(Fr):Fr(n)}});function Fr(e){return e.value=Object.freeze(e.value),e}const Br=na("$ZodCustom",(e,t)=>{nn.init(e,t),kn.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=a=>{const n=a.value,r=t.fn(n);if(r instanceof Promise)return r.then(t=>zr(t,a,n,e));zr(r,a,n,e)}});function zr(e,t,a,n){if(!e){const e={code:"custom",input:a,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(e.params=n._zod.def.params),t.issues.push(an(e))}}const Vr=na("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");kn.init(e,t),e.def=t,e.parse=(t,a)=>An(e,t,a,{callee:e.parse}),e.safeParse=(t,a)=>Cn(e,t,a),e.parseAsync=async(t,a)=>In(e,t,a,{callee:e.parseAsync}),e.safeParseAsync=async(t,a)=>Pn(e,t,a),e.check=(...a)=>e.clone({...t,checks:[...t.checks??[],...a.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),e.clone=(t,a)=>Wa(e,t,a),e.brand=()=>e,e.register=(t,a)=>(t.add(e,a),e)});const $r=na("ZodMiniObject",(e,t)=>{Er.init(e,t),Vr.init(e,t),Fa(e,"shape",()=>t.shape)});function Ur(e,t){const a={type:"object",get shape(){return Ba(this,"shape",{...e}),this.shape},...Qa(t)};return new $r(a)}function Hr(e){return!!e._zod}function Kr(e){const t=Object.values(e);if(0===t.length)return Ur({});const a=t.every(Hr),n=t.every(e=>!Hr(e));if(a)return Ur(e);if(n)return ta(e);throw new Error("Mixed Zod versions detected in object shape.")}function qr(e,t){if(Hr(e)){return Cn(e,t)}return e.safeParse(t)}async function Wr(e,t){if(Hr(e)){return await Pn(e,t)}const a=e;return await a.safeParseAsync(t)}function Qr(e){var t,a;if(!e)return;let n;if(Hr(e)){n=null===(a=null===(t=e._zod)||void 0===t?void 0:t.def)||void 0===a?void 0:a.shape}else{n=e.shape}if(n){if("function"==typeof n)try{return n()}catch(e){return}return n}}function Yr(e){var t;if(e){if("object"==typeof e){const t=e;if(!e._def&&!t._zod){const t=Object.values(e);if(t.length>0&&t.every(e=>"object"==typeof e&&null!==e&&(void 0!==e._def||void 0!==e._zod||"function"==typeof e.parse)))return Kr(e)}}if(Hr(e)){const a=null===(t=e._zod)||void 0===t?void 0:t.def;if(a&&("object"===a.type||void 0!==a.shape))return e}else{if(void 0!==e.shape)return e}}}function Xr(e){if(e&&"object"==typeof e){if("message"in e&&"string"==typeof e.message)return e.message;if("issues"in e&&Array.isArray(e.issues)&&e.issues.length>0){const t=e.issues[0];if(t&&"object"==typeof t&&"message"in t)return String(t.message)}try{return JSON.stringify(e)}catch(t){return String(e)}}return String(e)}function Jr(e){var t;if(Hr(e)){const a=null===(t=e._zod)||void 0===t?void 0:t.def;if(a){if(void 0!==a.value)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}}const a=e._def;if(a){if(void 0!==a.value)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}const n=e.value;if(void 0!==n)return n}Symbol("ZodOutput"),Symbol("ZodInput");class Zr{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){const a=t[0];if(this._map.set(e,a),a&&"object"==typeof a&&"id"in a){if(this._idmap.has(a.id))throw new Error(`ID ${a.id} already exists in the registry`);this._idmap.set(a.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const a={...this.get(t)??{}};return delete a.id,{...a,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function ei(){return new Zr}const ti=ei();function ai(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Qa(t)})}function ni(e,t){return new on({check:"less_than",...Qa(t),value:e,inclusive:!1})}function ri(e,t){return new on({check:"less_than",...Qa(t),value:e,inclusive:!0})}function ii(e,t){return new sn({check:"greater_than",...Qa(t),value:e,inclusive:!1})}function oi(e,t){return new sn({check:"greater_than",...Qa(t),value:e,inclusive:!0})}function si(e,t){return new pn({check:"multiple_of",...Qa(t),value:e})}function pi(e,t){return new dn({check:"max_length",...Qa(t),maximum:e})}function li(e,t){return new un({check:"min_length",...Qa(t),minimum:e})}function di(e,t){return new cn({check:"length_equals",...Qa(t),length:e})}function ui(e){return new Rn({check:"overwrite",tx:e})}const ci=na("ZodISODateTime",(e,t)=>{Wn.init(e,t),Ci.init(e,t)});function mi(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Qa(t)})}(ci,e)}const fi=na("ZodISODate",(e,t)=>{Qn.init(e,t),Ci.init(e,t)});function _i(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...Qa(t)})}(fi,e)}const hi=na("ZodISOTime",(e,t)=>{Yn.init(e,t),Ci.init(e,t)});function Ei(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Qa(t)})}(hi,e)}const yi=na("ZodISODuration",(e,t)=>{Xn.init(e,t),Ci.init(e,t)});function Ti(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...Qa(t)})}(yi,e)}const Ri=(e,t)=>{On.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t){const a=t||function(e){return e.message},n={_errors:[]},r=e=>{for(const t of e.issues)if("invalid_union"===t.code&&t.errors.length)t.errors.map(e=>r({issues:e}));else if("invalid_key"===t.code)r({issues:t.issues});else if("invalid_element"===t.code)r({issues:t.issues});else if(0===t.path.length)n._errors.push(a(t));else{let e=n,r=0;for(;r<t.path.length;){const n=t.path[r];r===t.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(a(t))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const a={},n=[];for(const r of e.issues)r.path.length>0?(a[r.path[0]]=a[r.path[0]]||[],a[r.path[0]].push(t(r))):n.push(t(r));return{formErrors:n,fieldErrors:a}}(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get:()=>0===e.issues.length}})},gi=(na("ZodError",Ri),na("ZodError",Ri,{Parent:Error})),vi=bn(gi),Oi=Sn(gi),Ni=wn(gi),bi=Dn(gi),Ai=na("ZodType",(e,t)=>(kn.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...a)=>e.clone({...t,checks:[...t.checks??[],...a.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),e.clone=(t,a)=>Wa(e,t,a),e.brand=()=>e,e.register=(t,a)=>(t.add(e,a),e),e.parse=(t,a)=>vi(e,t,a,{callee:e.parse}),e.safeParse=(t,a)=>Ni(e,t,a),e.parseAsync=async(t,a)=>Oi(e,t,a,{callee:e.parseAsync}),e.safeParseAsync=async(t,a)=>bi(e,t,a),e.spa=e.safeParseAsync,e.refine=(t,a)=>e.check(function(e,t={}){return function(e,t,a){return new e({type:"custom",check:"custom",fn:t,...Qa(a)})}(Fo,e,t)}(t,a)),e.superRefine=t=>e.check(function(e){const t=function(e){const t=new nn({check:"custom"});return t._zod.check=e,t}(a=>(a.addIssue=e=>{if("string"==typeof e)a.issues.push(an(e,a.value,t._zod.def));else{const n=e;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=a.value),n.inst??(n.inst=t),n.continue??(n.continue=!t._zod.def.abort),a.issues.push(an(n))}},e(a.value,a)));return t}(t)),e.overwrite=t=>e.check(ui(t)),e.optional=()=>wo(e),e.nullable=()=>Do(e),e.nullish=()=>wo(Do(e)),e.nonoptional=t=>function(e,t){return new ko({type:"nonoptional",innerType:e,...Qa(t)})}(e,t),e.array=()=>lo(e),e.or=t=>_o([e,t]),e.and=t=>To(e,t),e.transform=t=>Go(e,So(t)),e.default=t=>{return a=t,new Po({type:"default",innerType:e,get defaultValue(){return"function"==typeof a?a():a}});var a},e.prefault=t=>{return a=t,new jo({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof a?a():a}});var a},e.catch=t=>{return new Lo({type:"catch",innerType:e,catchValue:"function"==typeof(a=t)?a:()=>a});var a},e.pipe=t=>Go(e,t),e.readonly=()=>new xo({type:"readonly",innerType:e}),e.describe=t=>{const a=e.clone();return ti.add(a,{description:t}),a},Object.defineProperty(e,"description",{get:()=>ti.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return ti.get(e);const a=e.clone();return ti.add(a,t[0]),a},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Si=na("_ZodString",(e,t)=>{Ln.init(e,t),Ai.init(e,t);const a=e._zod.bag;e.format=a.format??null,e.minLength=a.minimum??null,e.maxLength=a.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new fn({check:"string_format",format:"regex",...Qa(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new En({check:"string_format",format:"includes",...Qa(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new yn({check:"string_format",format:"starts_with",...Qa(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Tn({check:"string_format",format:"ends_with",...Qa(t),suffix:e})}(...t)),e.min=(...t)=>e.check(li(...t)),e.max=(...t)=>e.check(pi(...t)),e.length=(...t)=>e.check(di(...t)),e.nonempty=(...t)=>e.check(li(1,...t)),e.lowercase=t=>e.check(function(e){return new _n({check:"string_format",format:"lowercase",...Qa(e)})}(t)),e.uppercase=t=>e.check(function(e){return new hn({check:"string_format",format:"uppercase",...Qa(e)})}(t)),e.trim=()=>e.check(ui(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return ui(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(ui(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(ui(e=>e.toUpperCase()))}),Ii=na("ZodString",(e,t)=>{Ln.init(e,t),Si.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Qa(t)})}(Di,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Qa(t)})}(ki,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Qa(t)})}(Qi,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Qa(t)})}(Li,t)),e.guid=t=>e.check(ai(Pi,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Qa(t)})}(ji,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Qa(t)})}(ji,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Qa(t)})}(ji,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Qa(t)})}(ji,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Qa(t)})}(Mi,t)),e.guid=t=>e.check(ai(Pi,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Qa(t)})}(Gi,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Qa(t)})}(xi,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Qa(t)})}(Fi,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Qa(t)})}(Ki,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Qa(t)})}(qi,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Qa(t)})}(Bi,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Qa(t)})}(zi,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Qa(t)})}(Vi,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Qa(t)})}($i,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Qa(t)})}(Ui,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Qa(t)})}(Hi,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Qa(t)})}(Wi,t)),e.datetime=t=>e.check(mi(t)),e.date=t=>e.check(_i(t)),e.time=t=>e.check(Ei(t)),e.duration=t=>e.check(Ti(t))});function wi(e){return function(e,t){return new e({type:"string",...Qa(t)})}(Ii,e)}const Ci=na("ZodStringFormat",(e,t)=>{Mn.init(e,t),Si.init(e,t)}),Di=na("ZodEmail",(e,t)=>{Fn.init(e,t),Ci.init(e,t)});const Pi=na("ZodGUID",(e,t)=>{Gn.init(e,t),Ci.init(e,t)});const ji=na("ZodUUID",(e,t)=>{xn.init(e,t),Ci.init(e,t)});const ki=na("ZodURL",(e,t)=>{Bn.init(e,t),Ci.init(e,t)});const Li=na("ZodEmoji",(e,t)=>{zn.init(e,t),Ci.init(e,t)});const Mi=na("ZodNanoID",(e,t)=>{Vn.init(e,t),Ci.init(e,t)});const Gi=na("ZodCUID",(e,t)=>{$n.init(e,t),Ci.init(e,t)});const xi=na("ZodCUID2",(e,t)=>{Un.init(e,t),Ci.init(e,t)});const Fi=na("ZodULID",(e,t)=>{Hn.init(e,t),Ci.init(e,t)});const Bi=na("ZodXID",(e,t)=>{Kn.init(e,t),Ci.init(e,t)});const zi=na("ZodKSUID",(e,t)=>{qn.init(e,t),Ci.init(e,t)});const Vi=na("ZodIPv4",(e,t)=>{Jn.init(e,t),Ci.init(e,t)});const $i=na("ZodIPv6",(e,t)=>{Zn.init(e,t),Ci.init(e,t)});const Ui=na("ZodCIDRv4",(e,t)=>{er.init(e,t),Ci.init(e,t)});const Hi=na("ZodCIDRv6",(e,t)=>{tr.init(e,t),Ci.init(e,t)});const Ki=na("ZodBase64",(e,t)=>{nr.init(e,t),Ci.init(e,t)});const qi=na("ZodBase64URL",(e,t)=>{rr.init(e,t),Ci.init(e,t)});const Wi=na("ZodE164",(e,t)=>{ir.init(e,t),Ci.init(e,t)});const Qi=na("ZodJWT",(e,t)=>{or.init(e,t),Ci.init(e,t)});const Yi=na("ZodNumber",(e,t)=>{sr.init(e,t),Ai.init(e,t),e.gt=(t,a)=>e.check(ii(t,a)),e.gte=(t,a)=>e.check(oi(t,a)),e.min=(t,a)=>e.check(oi(t,a)),e.lt=(t,a)=>e.check(ni(t,a)),e.lte=(t,a)=>e.check(ri(t,a)),e.max=(t,a)=>e.check(ri(t,a)),e.int=t=>e.check(Zi(t)),e.safe=t=>e.check(Zi(t)),e.positive=t=>e.check(ii(0,t)),e.nonnegative=t=>e.check(oi(0,t)),e.negative=t=>e.check(ni(0,t)),e.nonpositive=t=>e.check(ri(0,t)),e.multipleOf=(t,a)=>e.check(si(t,a)),e.step=(t,a)=>e.check(si(t,a)),e.finite=()=>e;const a=e._zod.bag;e.minValue=Math.max(a.minimum??Number.NEGATIVE_INFINITY,a.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(a.maximum??Number.POSITIVE_INFINITY,a.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(a.format??"").includes("int")||Number.isSafeInteger(a.multipleOf??.5),e.isFinite=!0,e.format=a.format??null});function Xi(e){return function(e,t){return new e({type:"number",checks:[],...Qa(t)})}(Yi,e)}const Ji=na("ZodNumberFormat",(e,t)=>{pr.init(e,t),Yi.init(e,t)});function Zi(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Qa(t)})}(Ji,e)}const eo=na("ZodBoolean",(e,t)=>{lr.init(e,t),Ai.init(e,t)});function to(e){return function(e,t){return new e({type:"boolean",...Qa(t)})}(eo,e)}const ao=na("ZodNull",(e,t)=>{dr.init(e,t),Ai.init(e,t)});function no(e){return function(e,t){return new e({type:"null",...Qa(t)})}(ao,e)}const ro=na("ZodUnknown",(e,t)=>{ur.init(e,t),Ai.init(e,t)});function io(){return function(e){return new e({type:"unknown"})}(ro)}const oo=na("ZodNever",(e,t)=>{cr.init(e,t),Ai.init(e,t)});function so(e){return function(e,t){return new e({type:"never",...Qa(t)})}(oo,e)}const po=na("ZodArray",(e,t)=>{fr.init(e,t),Ai.init(e,t),e.element=t.element,e.min=(t,a)=>e.check(li(t,a)),e.nonempty=t=>e.check(li(1,t)),e.max=(t,a)=>e.check(pi(t,a)),e.length=(t,a)=>e.check(di(t,a)),e.unwrap=()=>e.element});function lo(e,t){return function(e,t,a){return new e({type:"array",element:t,...Qa(a)})}(po,e,t)}const uo=na("ZodObject",(e,t)=>{Er.init(e,t),Ai.init(e,t),Fa(e,"shape",()=>t.shape),e.keyof=()=>Oo(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:io()}),e.loose=()=>e.clone({...e._zod.def,catchall:io()}),e.strict=()=>e.clone({...e._zod.def,catchall:so()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!Ha(t))throw new Error("Invalid input to extend: expected a plain object");const a={...e._zod.def,get shape(){const a={...e._zod.def.shape,...t};return Ba(this,"shape",a),a},checks:[]};return Wa(e,a)}(e,t),e.merge=t=>{return n=t,Wa(a=e,{...a._zod.def,get shape(){const e={...a._zod.def.shape,...n._zod.def.shape};return Ba(this,"shape",e),e},catchall:n._zod.def.catchall,checks:[]});var a,n},e.pick=t=>function(e,t){const a={},n=e._zod.def;for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&(a[e]=n.shape[e])}return Wa(e,{...e._zod.def,shape:a,checks:[]})}(e,t),e.omit=t=>function(e,t){const a={...e._zod.def.shape},n=e._zod.def;for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete a[e]}return Wa(e,{...e._zod.def,shape:a,checks:[]})}(e,t),e.partial=(...t)=>function(e,t,a){const n=t._zod.def.shape,r={...n};if(a)for(const t in a){if(!(t in n))throw new Error(`Unrecognized key: "${t}"`);a[t]&&(r[t]=e?new e({type:"optional",innerType:n[t]}):n[t])}else for(const t in n)r[t]=e?new e({type:"optional",innerType:n[t]}):n[t];return Wa(t,{...t._zod.def,shape:r,checks:[]})}(Io,e,t[0]),e.required=(...t)=>function(e,t,a){const n=t._zod.def.shape,r={...n};if(a)for(const t in a){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);a[t]&&(r[t]=new e({type:"nonoptional",innerType:n[t]}))}else for(const t in n)r[t]=new e({type:"nonoptional",innerType:n[t]});return Wa(t,{...t._zod.def,shape:r,checks:[]})}(ko,e,t[0])});function co(e,t){const a={type:"object",get shape(){return Ba(this,"shape",{...e}),this.shape},...Qa(t)};return new uo(a)}function mo(e,t){return new uo({type:"object",get shape(){return Ba(this,"shape",{...e}),this.shape},catchall:io(),...Qa(t)})}const fo=na("ZodUnion",(e,t)=>{Tr.init(e,t),Ai.init(e,t),e.options=t.options});function _o(e,t){return new fo({type:"union",options:e,...Qa(t)})}const ho=na("ZodDiscriminatedUnion",(e,t)=>{fo.init(e,t),Rr.init(e,t)});function Eo(e,t,a){return new ho({type:"union",options:t,discriminator:e,...Qa(a)})}const yo=na("ZodIntersection",(e,t)=>{gr.init(e,t),Ai.init(e,t)});function To(e,t){return new yo({type:"intersection",left:e,right:t})}const Ro=na("ZodRecord",(e,t)=>{Nr.init(e,t),Ai.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function go(e,t,a){return new Ro({type:"record",keyType:e,valueType:t,...Qa(a)})}const vo=na("ZodEnum",(e,t)=>{br.init(e,t),Ai.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const a=new Set(Object.keys(t.entries));e.extract=(e,n)=>{const r={};for(const n of e){if(!a.has(n))throw new Error(`Key ${n} not found in enum`);r[n]=t.entries[n]}return new vo({...t,checks:[],...Qa(n),entries:r})},e.exclude=(e,n)=>{const r={...t.entries};for(const t of e){if(!a.has(t))throw new Error(`Key ${t} not found in enum`);delete r[t]}return new vo({...t,checks:[],...Qa(n),entries:r})}});function Oo(e,t){const a=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new vo({type:"enum",entries:a,...Qa(t)})}const No=na("ZodLiteral",(e,t)=>{Ar.init(e,t),Ai.init(e,t),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 bo(e,t){return new No({type:"literal",values:Array.isArray(e)?e:[e],...Qa(t)})}const Ao=na("ZodTransform",(e,t)=>{Sr.init(e,t),Ai.init(e,t),e._zod.parse=(a,n)=>{a.addIssue=n=>{if("string"==typeof n)a.issues.push(an(n,a.value,t));else{const t=n;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=a.value),t.inst??(t.inst=e),t.continue??(t.continue=!0),a.issues.push(an(t))}};const r=t.transform(a.value,a);return r instanceof Promise?r.then(e=>(a.value=e,a)):(a.value=r,a)}});function So(e){return new Ao({type:"transform",transform:e})}const Io=na("ZodOptional",(e,t)=>{Ir.init(e,t),Ai.init(e,t),e.unwrap=()=>e._zod.def.innerType});function wo(e){return new Io({type:"optional",innerType:e})}const Co=na("ZodNullable",(e,t)=>{wr.init(e,t),Ai.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Do(e){return new Co({type:"nullable",innerType:e})}const Po=na("ZodDefault",(e,t)=>{Cr.init(e,t),Ai.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const jo=na("ZodPrefault",(e,t)=>{Pr.init(e,t),Ai.init(e,t),e.unwrap=()=>e._zod.def.innerType});const ko=na("ZodNonOptional",(e,t)=>{jr.init(e,t),Ai.init(e,t),e.unwrap=()=>e._zod.def.innerType});const Lo=na("ZodCatch",(e,t)=>{Lr.init(e,t),Ai.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const Mo=na("ZodPipe",(e,t)=>{Mr.init(e,t),Ai.init(e,t),e.in=t.in,e.out=t.out});function Go(e,t){return new Mo({type:"pipe",in:e,out:t})}const xo=na("ZodReadonly",(e,t)=>{xr.init(e,t),Ai.init(e,t)});const Fo=na("ZodCustom",(e,t)=>{Br.init(e,t),Ai.init(e,t)});function Bo(e,t){return Go(So(e),t)}const zo="2025-11-25",Vo=[zo,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],$o="io.modelcontextprotocol/related-task",Uo="2.0",Ho=function(e,t,a){const n=Qa(a);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}(Fo,(e=>null!==e&&("object"==typeof e||"function"==typeof e))??(()=>!0),Ko);var Ko;const qo=_o([wi(),Xi().int()]),Wo=wi(),Qo=mo({ttl:_o([Xi(),no()]).optional(),pollInterval:Xi().optional()}),Yo=mo({taskId:wi()}),Xo=mo({progressToken:qo.optional(),[$o]:Yo.optional()}),Jo=mo({task:Qo.optional(),_meta:Xo.optional()}),Zo=co({method:wi(),params:Jo.optional()}),es=mo({_meta:co({[$o]:wo(Yo)}).passthrough().optional()}),ts=co({method:wi(),params:es.optional()}),as=mo({_meta:mo({[$o]:Yo.optional()}).optional()}),ns=_o([wi(),Xi().int()]),rs=co({jsonrpc:bo(Uo),id:ns,...Zo.shape}).strict(),is=e=>rs.safeParse(e).success,os=co({jsonrpc:bo(Uo),...ts.shape}).strict(),ss=co({jsonrpc:bo(Uo),id:ns,result:as}).strict(),ps=e=>ss.safeParse(e).success;var ls;!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"}(ls||(ls={}));const ds=co({jsonrpc:bo(Uo),id:ns,error:co({code:Xi().int(),message:wi(),data:wo(io())})}).strict(),us=_o([rs,os,ss,ds]),cs=as.strict(),ms=es.extend({requestId:ns,reason:wi().optional()}),fs=ts.extend({method:bo("notifications/cancelled"),params:ms}),_s=co({src:wi(),mimeType:wi().optional(),sizes:lo(wi()).optional()}),hs=co({icons:lo(_s).optional()}),Es=co({name:wi(),title:wi().optional()}),ys=Es.extend({...Es.shape,...hs.shape,version:wi(),websiteUrl:wi().optional()}),Ts=To(co({applyDefaults:to().optional()}),go(wi(),io())),Rs=Bo(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,To(co({form:Ts.optional(),url:Ho.optional()}),go(wi(),io()).optional())),gs=co({list:wo(co({}).passthrough()),cancel:wo(co({}).passthrough()),requests:wo(co({sampling:wo(co({createMessage:wo(co({}).passthrough())}).passthrough()),elicitation:wo(co({create:wo(co({}).passthrough())}).passthrough())}).passthrough())}).passthrough(),vs=co({list:wo(co({}).passthrough()),cancel:wo(co({}).passthrough()),requests:wo(co({tools:wo(co({call:wo(co({}).passthrough())}).passthrough())}).passthrough())}).passthrough(),Os=co({experimental:go(wi(),Ho).optional(),sampling:co({context:Ho.optional(),tools:Ho.optional()}).optional(),elicitation:Rs.optional(),roots:co({listChanged:to().optional()}).optional(),tasks:wo(gs)}),Ns=Jo.extend({protocolVersion:wi(),capabilities:Os,clientInfo:ys}),bs=Zo.extend({method:bo("initialize"),params:Ns}),As=co({experimental:go(wi(),Ho).optional(),logging:Ho.optional(),completions:Ho.optional(),prompts:wo(co({listChanged:wo(to())})),resources:co({subscribe:to().optional(),listChanged:to().optional()}).optional(),tools:co({listChanged:to().optional()}).optional(),tasks:wo(vs)}).passthrough(),Ss=as.extend({protocolVersion:wi(),capabilities:As,serverInfo:ys,instructions:wi().optional()}),Is=ts.extend({method:bo("notifications/initialized")}),ws=Zo.extend({method:bo("ping")}),Cs=co({progress:Xi(),total:wo(Xi()),message:wo(wi())}),Ds=co({...es.shape,...Cs.shape,progressToken:qo}),Ps=ts.extend({method:bo("notifications/progress"),params:Ds}),js=Jo.extend({cursor:Wo.optional()}),ks=Zo.extend({params:js.optional()}),Ls=as.extend({nextCursor:wo(Wo)}),Ms=co({taskId:wi(),status:Oo(["working","input_required","completed","failed","cancelled"]),ttl:_o([Xi(),no()]),createdAt:wi(),lastUpdatedAt:wi(),pollInterval:wo(Xi()),statusMessage:wo(wi())}),Gs=as.extend({task:Ms}),xs=es.merge(Ms),Fs=ts.extend({method:bo("notifications/tasks/status"),params:xs}),Bs=Zo.extend({method:bo("tasks/get"),params:Jo.extend({taskId:wi()})}),zs=as.merge(Ms),Vs=Zo.extend({method:bo("tasks/result"),params:Jo.extend({taskId:wi()})}),$s=ks.extend({method:bo("tasks/list")}),Us=Ls.extend({tasks:lo(Ms)}),Hs=Zo.extend({method:bo("tasks/cancel"),params:Jo.extend({taskId:wi()})}),Ks=as.merge(Ms),qs=co({uri:wi(),mimeType:wo(wi()),_meta:go(wi(),io()).optional()}),Ws=qs.extend({text:wi()}),Qs=wi().refine(e=>{try{return atob(e),!0}catch(e){return!1}},{message:"Invalid Base64 string"}),Ys=qs.extend({blob:Qs}),Xs=co({audience:lo(Oo(["user","assistant"])).optional(),priority:Xi().min(0).max(1).optional(),lastModified:mi({offset:!0}).optional()}),Js=co({...Es.shape,...hs.shape,uri:wi(),description:wo(wi()),mimeType:wo(wi()),annotations:Xs.optional(),_meta:wo(mo({}))}),Zs=co({...Es.shape,...hs.shape,uriTemplate:wi(),description:wo(wi()),mimeType:wo(wi()),annotations:Xs.optional(),_meta:wo(mo({}))}),ep=ks.extend({method:bo("resources/list")}),tp=Ls.extend({resources:lo(Js)}),ap=ks.extend({method:bo("resources/templates/list")}),np=Ls.extend({resourceTemplates:lo(Zs)}),rp=Jo.extend({uri:wi()}),ip=rp,op=Zo.extend({method:bo("resources/read"),params:ip}),sp=as.extend({contents:lo(_o([Ws,Ys]))}),pp=ts.extend({method:bo("notifications/resources/list_changed")}),lp=rp,dp=Zo.extend({method:bo("resources/subscribe"),params:lp}),up=rp,cp=Zo.extend({method:bo("resources/unsubscribe"),params:up}),mp=es.extend({uri:wi()}),fp=ts.extend({method:bo("notifications/resources/updated"),params:mp}),_p=co({name:wi(),description:wo(wi()),required:wo(to())}),hp=co({...Es.shape,...hs.shape,description:wo(wi()),arguments:wo(lo(_p)),_meta:wo(mo({}))}),Ep=ks.extend({method:bo("prompts/list")}),yp=Ls.extend({prompts:lo(hp)}),Tp=Jo.extend({name:wi(),arguments:go(wi(),wi()).optional()}),Rp=Zo.extend({method:bo("prompts/get"),params:Tp}),gp=co({type:bo("text"),text:wi(),annotations:Xs.optional(),_meta:go(wi(),io()).optional()}),vp=co({type:bo("image"),data:Qs,mimeType:wi(),annotations:Xs.optional(),_meta:go(wi(),io()).optional()}),Op=co({type:bo("audio"),data:Qs,mimeType:wi(),annotations:Xs.optional(),_meta:go(wi(),io()).optional()}),Np=co({type:bo("tool_use"),name:wi(),id:wi(),input:co({}).passthrough(),_meta:wo(co({}).passthrough())}).passthrough(),bp=co({type:bo("resource"),resource:_o([Ws,Ys]),annotations:Xs.optional(),_meta:go(wi(),io()).optional()}),Ap=_o([gp,vp,Op,Js.extend({type:bo("resource_link")}),bp]),Sp=co({role:Oo(["user","assistant"]),content:Ap}),Ip=as.extend({description:wo(wi()),messages:lo(Sp)}),wp=ts.extend({method:bo("notifications/prompts/list_changed")}),Cp=co({title:wi().optional(),readOnlyHint:to().optional(),destructiveHint:to().optional(),idempotentHint:to().optional(),openWorldHint:to().optional()}),Dp=co({taskSupport:Oo(["required","optional","forbidden"]).optional()}),Pp=co({...Es.shape,...hs.shape,description:wi().optional(),inputSchema:co({type:bo("object"),properties:go(wi(),Ho).optional(),required:lo(wi()).optional()}).catchall(io()),outputSchema:co({type:bo("object"),properties:go(wi(),Ho).optional(),required:lo(wi()).optional()}).catchall(io()).optional(),annotations:wo(Cp),execution:wo(Dp),_meta:go(wi(),io()).optional()}),jp=ks.extend({method:bo("tools/list")}),kp=Ls.extend({tools:lo(Pp)}),Lp=as.extend({content:lo(Ap).default([]),structuredContent:go(wi(),io()).optional(),isError:wo(to())}),Mp=(Lp.or(as.extend({toolResult:io()})),Jo.extend({name:wi(),arguments:wo(go(wi(),io()))})),Gp=Zo.extend({method:bo("tools/call"),params:Mp}),xp=ts.extend({method:bo("notifications/tools/list_changed")}),Fp=Oo(["debug","info","notice","warning","error","critical","alert","emergency"]),Bp=Jo.extend({level:Fp}),zp=Zo.extend({method:bo("logging/setLevel"),params:Bp}),Vp=es.extend({level:Fp,logger:wi().optional(),data:io()}),$p=ts.extend({method:bo("notifications/message"),params:Vp}),Up=co({name:wi().optional()}),Hp=co({hints:wo(lo(Up)),costPriority:wo(Xi().min(0).max(1)),speedPriority:wo(Xi().min(0).max(1)),intelligencePriority:wo(Xi().min(0).max(1))}),Kp=co({mode:wo(Oo(["auto","required","none"]))}),qp=co({type:bo("tool_result"),toolUseId:wi().describe("The unique identifier for the corresponding tool call."),content:lo(Ap).default([]),structuredContent:co({}).passthrough().optional(),isError:wo(to()),_meta:wo(co({}).passthrough())}).passthrough(),Wp=Eo("type",[gp,vp,Op]),Qp=Eo("type",[gp,vp,Op,Np,qp]),Yp=co({role:Oo(["user","assistant"]),content:_o([Qp,lo(Qp)]),_meta:wo(co({}).passthrough())}).passthrough(),Xp=Jo.extend({messages:lo(Yp),modelPreferences:Hp.optional(),systemPrompt:wi().optional(),includeContext:Oo(["none","thisServer","allServers"]).optional(),temperature:Xi().optional(),maxTokens:Xi().int(),stopSequences:lo(wi()).optional(),metadata:Ho.optional(),tools:wo(lo(Pp)),toolChoice:wo(Kp)}),Jp=Zo.extend({method:bo("sampling/createMessage"),params:Xp}),Zp=as.extend({model:wi(),stopReason:wo(Oo(["endTurn","stopSequence","maxTokens"]).or(wi())),role:Oo(["user","assistant"]),content:Wp}),el=as.extend({model:wi(),stopReason:wo(Oo(["endTurn","stopSequence","maxTokens","toolUse"]).or(wi())),role:Oo(["user","assistant"]),content:_o([Qp,lo(Qp)])}),tl=co({type:bo("boolean"),title:wi().optional(),description:wi().optional(),default:to().optional()}),al=co({type:bo("string"),title:wi().optional(),description:wi().optional(),minLength:Xi().optional(),maxLength:Xi().optional(),format:Oo(["email","uri","date","date-time"]).optional(),default:wi().optional()}),nl=co({type:Oo(["number","integer"]),title:wi().optional(),description:wi().optional(),minimum:Xi().optional(),maximum:Xi().optional(),default:Xi().optional()}),rl=co({type:bo("string"),title:wi().optional(),description:wi().optional(),enum:lo(wi()),default:wi().optional()}),il=co({type:bo("string"),title:wi().optional(),description:wi().optional(),oneOf:lo(co({const:wi(),title:wi()})),default:wi().optional()}),ol=co({type:bo("string"),title:wi().optional(),description:wi().optional(),enum:lo(wi()),enumNames:lo(wi()).optional(),default:wi().optional()}),sl=_o([rl,il]),pl=_o([co({type:bo("array"),title:wi().optional(),description:wi().optional(),minItems:Xi().optional(),maxItems:Xi().optional(),items:co({type:bo("string"),enum:lo(wi())}),default:lo(wi()).optional()}),co({type:bo("array"),title:wi().optional(),description:wi().optional(),minItems:Xi().optional(),maxItems:Xi().optional(),items:co({anyOf:lo(co({const:wi(),title:wi()}))}),default:lo(wi()).optional()})]),ll=_o([ol,sl,pl]),dl=_o([ll,tl,al,nl]),ul=_o([Jo.extend({mode:bo("form").optional(),message:wi(),requestedSchema:co({type:bo("object"),properties:go(wi(),dl),required:lo(wi()).optional()})}),Jo.extend({mode:bo("url"),message:wi(),elicitationId:wi(),url:wi().url()})]),cl=Zo.extend({method:bo("elicitation/create"),params:ul}),ml=es.extend({elicitationId:wi()}),fl=ts.extend({method:bo("notifications/elicitation/complete"),params:ml}),_l=as.extend({action:Oo(["accept","decline","cancel"]),content:Bo(e=>null===e?void 0:e,go(wi(),_o([wi(),Xi(),to(),lo(wi())])).optional())}),hl=co({type:bo("ref/resource"),uri:wi()}),El=co({type:bo("ref/prompt"),name:wi()}),yl=Jo.extend({ref:_o([El,hl]),argument:co({name:wi(),value:wi()}),context:co({arguments:go(wi(),wi()).optional()}).optional()}),Tl=Zo.extend({method:bo("completion/complete"),params:yl});const Rl=as.extend({completion:mo({values:lo(wi()).max(100),total:wo(Xi().int()),hasMore:wo(to())})}),gl=co({uri:wi().startsWith("file://"),name:wi().optional(),_meta:go(wi(),io()).optional()}),vl=Zo.extend({method:bo("roots/list")}),Ol=as.extend({roots:lo(gl)}),Nl=ts.extend({method:bo("notifications/roots/list_changed")});_o([ws,bs,Tl,zp,Rp,Ep,ep,ap,op,dp,cp,Gp,jp,Bs,Vs,$s]),_o([fs,Ps,Is,Nl,Fs]),_o([cs,Zp,el,_l,Ol,zs,Us,Gs]),_o([ws,Jp,cl,vl,Bs,Vs,$s]),_o([fs,Ps,$p,fp,pp,xp,wp,Fs,fl]),_o([cs,Ss,Rl,Ip,yp,tp,np,sp,Lp,kp,zs,Us,Gs]);class bl extends Error{constructor(e,t,a){super(`MCP error ${e}: ${t}`),this.code=e,this.data=a,this.name="McpError"}static fromError(e,t,a){if(e===ls.UrlElicitationRequired&&a){const e=a;if(e.elicitations)return new Al(e.elicitations,t)}return new bl(e,t,a)}}class Al extends bl{constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(ls.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){var e,t;return null!==(t=null===(e=this.data)||void 0===e?void 0:e.elicitations)&&void 0!==t?t:[]}}function Sl(e){return"completed"===e||"failed"===e||"cancelled"===e}class Il{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??ti,this.target=e?.target??"draft-2020-12",this.unrepresentable=e?.unrepresentable??"throw",this.override=e?.override??(()=>{}),this.io=e?.io??"output",this.seen=new Map}process(e,t={path:[],schemaPath:[]}){var a;const n=e._zod.def,r={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},i=this.seen.get(e);if(i){i.count++;return t.schemaPath.includes(e)&&(i.cycle=t.path),i.schema}const o={schema:{},count:1,cycle:void 0,path:t.path};this.seen.set(e,o);const s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{const a={...t,schemaPath:[...t.schemaPath,e],path:t.path},i=e._zod.parent;if(i)o.ref=i,this.process(i,a),this.seen.get(i).isParent=!0;else{const t=o.schema;switch(n.type){case"string":{const a=t;a.type="string";const{minimum:n,maximum:i,format:s,patterns:p,contentEncoding:l}=e._zod.bag;if("number"==typeof n&&(a.minLength=n),"number"==typeof i&&(a.maxLength=i),s&&(a.format=r[s]??s,""===a.format&&delete a.format),l&&(a.contentEncoding=l),p&&p.size>0){const e=[...p];1===e.length?a.pattern=e[0].source:e.length>1&&(o.schema.allOf=[...e.map(e=>({..."draft-7"===this.target?{type:"string"}:{},pattern:e.source}))])}break}case"number":{const a=t,{minimum:n,maximum:r,format:i,multipleOf:o,exclusiveMaximum:s,exclusiveMinimum:p}=e._zod.bag;"string"==typeof i&&i.includes("int")?a.type="integer":a.type="number","number"==typeof p&&(a.exclusiveMinimum=p),"number"==typeof n&&(a.minimum=n,"number"==typeof p&&(p>=n?delete a.minimum:delete a.exclusiveMinimum)),"number"==typeof s&&(a.exclusiveMaximum=s),"number"==typeof r&&(a.maximum=r,"number"==typeof s&&(s<=r?delete a.maximum:delete a.exclusiveMaximum)),"number"==typeof o&&(a.multipleOf=o);break}case"boolean":t.type="boolean";break;case"bigint":if("throw"===this.unrepresentable)throw new Error("BigInt cannot be represented in JSON Schema");break;case"symbol":if("throw"===this.unrepresentable)throw new Error("Symbols cannot be represented in JSON Schema");break;case"null":t.type="null";break;case"any":case"unknown":break;case"undefined":if("throw"===this.unrepresentable)throw new Error("Undefined cannot be represented in JSON Schema");break;case"void":if("throw"===this.unrepresentable)throw new Error("Void cannot be represented in JSON Schema");break;case"never":t.not={};break;case"date":if("throw"===this.unrepresentable)throw new Error("Date cannot be represented in JSON Schema");break;case"array":{const r=t,{minimum:i,maximum:o}=e._zod.bag;"number"==typeof i&&(r.minItems=i),"number"==typeof o&&(r.maxItems=o),r.type="array",r.items=this.process(n.element,{...a,path:[...a.path,"items"]});break}case"object":{const e=t;e.type="object",e.properties={};const r=n.shape;for(const t in r)e.properties[t]=this.process(r[t],{...a,path:[...a.path,"properties",t]});const i=new Set(Object.keys(r)),o=new Set([...i].filter(e=>{const t=n.shape[e]._zod;return"input"===this.io?void 0===t.optin:void 0===t.optout}));o.size>0&&(e.required=Array.from(o)),"never"===n.catchall?._zod.def.type?e.additionalProperties=!1:n.catchall?n.catchall&&(e.additionalProperties=this.process(n.catchall,{...a,path:[...a.path,"additionalProperties"]})):"output"===this.io&&(e.additionalProperties=!1);break}case"union":t.anyOf=n.options.map((e,t)=>this.process(e,{...a,path:[...a.path,"anyOf",t]}));break;case"intersection":{const e=t,r=this.process(n.left,{...a,path:[...a.path,"allOf",0]}),i=this.process(n.right,{...a,path:[...a.path,"allOf",1]}),o=e=>"allOf"in e&&1===Object.keys(e).length,s=[...o(r)?r.allOf:[r],...o(i)?i.allOf:[i]];e.allOf=s;break}case"tuple":{const r=t;r.type="array";const i=n.items.map((e,t)=>this.process(e,{...a,path:[...a.path,"prefixItems",t]}));if("draft-2020-12"===this.target?r.prefixItems=i:r.items=i,n.rest){const e=this.process(n.rest,{...a,path:[...a.path,"items"]});"draft-2020-12"===this.target?r.items=e:r.additionalItems=e}n.rest&&(r.items=this.process(n.rest,{...a,path:[...a.path,"items"]}));const{minimum:o,maximum:s}=e._zod.bag;"number"==typeof o&&(r.minItems=o),"number"==typeof s&&(r.maxItems=s);break}case"record":{const e=t;e.type="object",e.propertyNames=this.process(n.keyType,{...a,path:[...a.path,"propertyNames"]}),e.additionalProperties=this.process(n.valueType,{...a,path:[...a.path,"additionalProperties"]});break}case"map":if("throw"===this.unrepresentable)throw new Error("Map cannot be represented in JSON Schema");break;case"set":if("throw"===this.unrepresentable)throw new Error("Set cannot be represented in JSON Schema");break;case"enum":{const e=t,a=ka(n.entries);a.every(e=>"number"==typeof e)&&(e.type="number"),a.every(e=>"string"==typeof e)&&(e.type="string"),e.enum=a;break}case"literal":{const e=t,a=[];for(const e of n.values)if(void 0===e){if("throw"===this.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof e){if("throw"===this.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(e))}else a.push(e);if(0===a.length);else if(1===a.length){const t=a[0];e.type=null===t?"null":typeof t,e.const=t}else a.every(e=>"number"==typeof e)&&(e.type="number"),a.every(e=>"string"==typeof e)&&(e.type="string"),a.every(e=>"boolean"==typeof e)&&(e.type="string"),a.every(e=>null===e)&&(e.type="null"),e.enum=a;break}case"file":{const a=t,n={type:"string",format:"binary",contentEncoding:"binary"},{minimum:r,maximum:i,mime:o}=e._zod.bag;void 0!==r&&(n.minLength=r),void 0!==i&&(n.maxLength=i),o?1===o.length?(n.contentMediaType=o[0],Object.assign(a,n)):a.anyOf=o.map(e=>({...n,contentMediaType:e})):Object.assign(a,n);break}case"transform":if("throw"===this.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema");break;case"nullable":{const e=this.process(n.innerType,a);t.anyOf=[e,{type:"null"}];break}case"nonoptional":case"promise":case"optional":this.process(n.innerType,a),o.ref=n.innerType;break;case"success":t.type="boolean";break;case"default":this.process(n.innerType,a),o.ref=n.innerType,t.default=JSON.parse(JSON.stringify(n.defaultValue));break;case"prefault":this.process(n.innerType,a),o.ref=n.innerType,"input"===this.io&&(t._prefault=JSON.parse(JSON.stringify(n.defaultValue)));break;case"catch":{let e;this.process(n.innerType,a),o.ref=n.innerType;try{e=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=e;break}case"nan":if("throw"===this.unrepresentable)throw new Error("NaN cannot be represented in JSON Schema");break;case"template_literal":{const a=t,n=e._zod.pattern;if(!n)throw new Error("Pattern not found in template literal");a.type="string",a.pattern=n.source;break}case"pipe":{const e="input"===this.io?"transform"===n.in._zod.def.type?n.out:n.in:n.out;this.process(e,a),o.ref=e;break}case"readonly":this.process(n.innerType,a),o.ref=n.innerType,t.readOnly=!0;break;case"lazy":{const t=e._zod.innerType;this.process(t,a),o.ref=t;break}case"custom":if("throw"===this.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")}}}const p=this.metadataRegistry.get(e);p&&Object.assign(o.schema,p),"input"===this.io&&wl(e)&&(delete o.schema.examples,delete o.schema.default),"input"===this.io&&o.schema._prefault&&((a=o.schema).default??(a.default=o.schema._prefault)),delete o.schema._prefault;return this.seen.get(e).schema}emit(e,t){const a={cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0},n=this.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=e=>{const t="draft-2020-12"===this.target?"$defs":"definitions";if(a.external){const n=a.external.registry.get(e[0])?.id,r=a.external.uri??(e=>e);if(n)return{ref:r(n)};const i=e[1].defId??e[1].schema.id??"schema"+this.counter++;return e[1].defId=i,{defId:i,ref:`${r("__shared")}#/${t}/${i}`}}if(e[1]===n)return{ref:"#"};const r=`#/${t}/`,i=e[1].schema.id??"__schema"+this.counter++;return{defId:i,ref:r+i}},i=e=>{if(e[1].schema.$ref)return;const t=e[1],{ref:a,defId:n}=r(e);t.def={...t.schema},n&&(t.defId=n);const i=t.schema;for(const e in i)delete i[e];i.$ref=a};if("throw"===a.cycles)for(const e of this.seen.entries()){const t=e[1];if(t.cycle)throw new Error(`Cycle detected: #/${t.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const t of this.seen.entries()){const n=t[1];if(e===t[0]){i(t);continue}if(a.external){const n=a.external.registry.get(t[0])?.id;if(e!==t[0]&&n){i(t);continue}}const r=this.metadataRegistry.get(t[0])?.id;r?i(t):(n.cycle||n.count>1&&"ref"===a.reused)&&i(t)}const o=(e,t)=>{const a=this.seen.get(e),n=a.def??a.schema,r={...n};if(null===a.ref)return;const i=a.ref;if(a.ref=null,i){o(i,t);const e=this.seen.get(i).schema;e.$ref&&"draft-7"===t.target?(n.allOf=n.allOf??[],n.allOf.push(e)):(Object.assign(n,e),Object.assign(n,r))}a.isParent||this.override({zodSchema:e,jsonSchema:n,path:a.path??[]})};for(const e of[...this.seen.entries()].reverse())o(e[0],{target:this.target});const s={};if("draft-2020-12"===this.target?s.$schema="https://json-schema.org/draft/2020-12/schema":"draft-7"===this.target?s.$schema="http://json-schema.org/draft-07/schema#":console.warn(`Invalid target: ${this.target}`),a.external?.uri){const t=a.external.registry.get(e)?.id;if(!t)throw new Error("Schema is missing an `id` property");s.$id=a.external.uri(t)}Object.assign(s,n.def);const p=a.external?.defs??{};for(const e of this.seen.entries()){const t=e[1];t.def&&t.defId&&(p[t.defId]=t.def)}a.external||Object.keys(p).length>0&&("draft-2020-12"===this.target?s.$defs=p:s.definitions=p);try{return JSON.parse(JSON.stringify(s))}catch(e){throw new Error("Error converting schema to JSON.")}}}function wl(e,t){const a=t??{seen:new Set};if(a.seen.has(e))return!1;a.seen.add(e);const n=e._zod.def;switch(n.type){case"string":case"number":case"bigint":case"boolean":case"date":case"symbol":case"undefined":case"null":case"any":case"unknown":case"never":case"void":case"literal":case"enum":case"nan":case"file":case"template_literal":case"custom":case"success":case"catch":return!1;case"array":return wl(n.element,a);case"object":for(const e in n.shape)if(wl(n.shape[e],a))return!0;return!1;case"union":for(const e of n.options)if(wl(e,a))return!0;return!1;case"intersection":return wl(n.left,a)||wl(n.right,a);case"tuple":for(const e of n.items)if(wl(e,a))return!0;return!(!n.rest||!wl(n.rest,a));case"record":case"map":return wl(n.keyType,a)||wl(n.valueType,a);case"set":return wl(n.valueType,a);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":case"default":case"prefault":return wl(n.innerType,a);case"lazy":return wl(n.getter(),a);case"transform":return!0;case"pipe":return wl(n.in,a)||wl(n.out,a)}throw new Error(`Unknown schema type: ${n.type}`)}const Cl=Symbol("Let zodToJsonSchema decide on which parser to use"),Dl={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},Pl=e=>{const t=(e=>"string"==typeof e?{...Dl,name:e}:{...Dl,...e})(e),a=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:a,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,a])=>[a._def,{def:a._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},jl=(e,t)=>{let a=0;for(;a<e.length&&a<t.length&&e[a]===t[a];a++);return[(e.length-a).toString(),...t.slice(a)].join("/")};function kl(e){if("openAi"!==e.target)return{};const t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?jl(t,e.currentPath):t.join("/")}}function Ll(e,t,a,n){n?.errorMessages&&a&&(e.errorMessage={...e.errorMessage,[t]:a})}function Ml(e,t,a,n,r){e[t]=a,Ll(e,t,n,r)}function Gl(e,t){return dd(e.type._def,t)}function xl(e,t,a){const n=a??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((a,n)=>xl(e,t,a))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Fl(e,t)}}const Fl=(e,t)=>{const a={type:"integer",format:"unix-time"};if("openApi3"===t.target)return a;for(const n of e.checks)switch(n.kind){case"min":Ml(a,"minimum",n.value,n.message,t);break;case"max":Ml(a,"maximum",n.value,n.message,t)}return a};let Bl;const zl=/^[cC][^\s-]{8,}$/,Vl=/^[0-9a-z]+$/,$l=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ul=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,Hl=()=>(void 0===Bl&&(Bl=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Bl),Kl=/^(?:(?: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])$/,ql=/^(([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])$/,Wl=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ql=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Yl=/^[a-zA-Z0-9_-]{21}$/,Xl=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function Jl(e,t){const a={type:"string"};if(e.checks)for(const n of e.checks)switch(n.kind){case"min":Ml(a,"minLength","number"==typeof a.minLength?Math.max(a.minLength,n.value):n.value,n.message,t);break;case"max":Ml(a,"maxLength","number"==typeof a.maxLength?Math.min(a.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":td(a,"email",n.message,t);break;case"format:idn-email":td(a,"idn-email",n.message,t);break;case"pattern:zod":ad(a,Ul,n.message,t)}break;case"url":td(a,"uri",n.message,t);break;case"uuid":td(a,"uuid",n.message,t);break;case"regex":ad(a,n.regex,n.message,t);break;case"cuid":ad(a,zl,n.message,t);break;case"cuid2":ad(a,Vl,n.message,t);break;case"startsWith":ad(a,RegExp(`^${Zl(n.value,t)}`),n.message,t);break;case"endsWith":ad(a,RegExp(`${Zl(n.value,t)}$`),n.message,t);break;case"datetime":td(a,"date-time",n.message,t);break;case"date":td(a,"date",n.message,t);break;case"time":td(a,"time",n.message,t);break;case"duration":td(a,"duration",n.message,t);break;case"length":Ml(a,"minLength","number"==typeof a.minLength?Math.max(a.minLength,n.value):n.value,n.message,t),Ml(a,"maxLength","number"==typeof a.maxLength?Math.min(a.maxLength,n.value):n.value,n.message,t);break;case"includes":ad(a,RegExp(Zl(n.value,t)),n.message,t);break;case"ip":"v6"!==n.version&&td(a,"ipv4",n.message,t),"v4"!==n.version&&td(a,"ipv6",n.message,t);break;case"base64url":ad(a,Ql,n.message,t);break;case"jwt":ad(a,Xl,n.message,t);break;case"cidr":"v6"!==n.version&&ad(a,Kl,n.message,t),"v4"!==n.version&&ad(a,ql,n.message,t);break;case"emoji":ad(a,Hl(),n.message,t);break;case"ulid":ad(a,$l,n.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":td(a,"binary",n.message,t);break;case"contentEncoding:base64":Ml(a,"contentEncoding","base64",n.message,t);break;case"pattern:zod":ad(a,Wl,n.message,t)}break;case"nanoid":ad(a,Yl,n.message,t);case"toLowerCase":case"toUpperCase":case"trim":break;default:(()=>{})()}return a}function Zl(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let a=0;a<e.length;a++)ed.has(e[a])||(t+="\\"),t+=e[a];return t}(e):e}const ed=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function td(e,t,a,n){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...a&&n.errorMessages&&{errorMessage:{format:a}}})):Ml(e,"format",t,a,n)}function ad(e,t,a,n){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:nd(t,n),...a&&n.errorMessages&&{errorMessage:{pattern:a}}})):Ml(e,"pattern",nd(t,n),a,n)}function nd(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;const a=e.flags.includes("i"),n=e.flags.includes("m"),r=e.flags.includes("s"),i=a?e.source.toLowerCase():e.source;let o="",s=!1,p=!1,l=!1;for(let e=0;e<i.length;e++)if(s)o+=i[e],s=!1;else{if(a)if(p){if(i[e].match(/[a-z]/)){l?(o+=i[e],o+=`${i[e-2]}-${i[e]}`.toUpperCase(),l=!1):"-"===i[e+1]&&i[e+2]?.match(/[a-z]/)?(o+=i[e],l=!0):o+=`${i[e]}${i[e].toUpperCase()}`;continue}}else if(i[e].match(/[a-z]/)){o+=`[${i[e]}${i[e].toUpperCase()}]`;continue}if(n){if("^"===i[e]){o+="(^|(?<=[\r\n]))";continue}if("$"===i[e]){o+="($|(?=[\r\n]))";continue}}r&&"."===i[e]?o+=p?`${i[e]}\r\n`:`[${i[e]}\r\n]`:(o+=i[e],"\\"===i[e]?s=!0:p&&"]"===i[e]?p=!1:p||"["!==i[e]||(p=!0))}try{new RegExp(o)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return o}function rd(e,t){if("openAi"===t.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===t.target&&e.keyType?._def.typeName===Xt.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((a,n)=>({...a,[n]:dd(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??kl(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};const a={type:"object",additionalProperties:dd(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return a;if(e.keyType?._def.typeName===Xt.ZodString&&e.keyType._def.checks?.length){const{type:n,...r}=Jl(e.keyType._def,t);return{...a,propertyNames:r}}if(e.keyType?._def.typeName===Xt.ZodEnum)return{...a,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===Xt.ZodBranded&&e.keyType._def.type._def.typeName===Xt.ZodString&&e.keyType._def.type._def.checks?.length){const{type:n,...r}=Gl(e.keyType._def,t);return{...a,propertyNames:r}}return a}const id={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};const od=(e,t)=>{const a=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,a)=>dd(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${a}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return a.length?{anyOf:a}:void 0};function sd(e,t){const a="openAi"===t.target,n={type:"object",properties:{}},r=[],i=e.shape();for(const e in i){let o=i[e];if(void 0===o||void 0===o._def)continue;let s=pd(o);s&&a&&("ZodOptional"===o._def.typeName&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);const p=dd(o._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==p&&(n.properties[e]=p,s||r.push(e))}r.length&&(n.required=r);const o=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return dd(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==o&&(n.additionalProperties=o),n}function pd(e){try{return e.isOptional()}catch{return!0}}const ld=(e,t,a)=>{switch(t){case Xt.ZodString:return Jl(e,a);case Xt.ZodNumber:return function(e,t){const a={type:"number"};if(!e.checks)return a;for(const n of e.checks)switch(n.kind){case"int":a.type="integer",Ll(a,"type",n.message,t);break;case"min":"jsonSchema7"===t.target?n.inclusive?Ml(a,"minimum",n.value,n.message,t):Ml(a,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(a.exclusiveMinimum=!0),Ml(a,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?Ml(a,"maximum",n.value,n.message,t):Ml(a,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(a.exclusiveMaximum=!0),Ml(a,"maximum",n.value,n.message,t));break;case"multipleOf":Ml(a,"multipleOf",n.value,n.message,t)}return a}(e,a);case Xt.ZodObject:return sd(e,a);case Xt.ZodBigInt:return function(e,t){const a={type:"integer",format:"int64"};if(!e.checks)return a;for(const n of e.checks)switch(n.kind){case"min":"jsonSchema7"===t.target?n.inclusive?Ml(a,"minimum",n.value,n.message,t):Ml(a,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(a.exclusiveMinimum=!0),Ml(a,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?Ml(a,"maximum",n.value,n.message,t):Ml(a,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(a.exclusiveMaximum=!0),Ml(a,"maximum",n.value,n.message,t));break;case"multipleOf":Ml(a,"multipleOf",n.value,n.message,t)}return a}(e,a);case Xt.ZodBoolean:return{type:"boolean"};case Xt.ZodDate:return xl(e,a);case Xt.ZodUndefined:return function(e){return{not:kl(e)}}(a);case Xt.ZodNull:return function(e){return"openApi3"===e.target?{enum:["null"],nullable:!0}:{type:"null"}}(a);case Xt.ZodArray:return function(e,t){const a={type:"array"};return e.type?._def&&e.type?._def?.typeName!==Xt.ZodAny&&(a.items=dd(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Ml(a,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Ml(a,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Ml(a,"minItems",e.exactLength.value,e.exactLength.message,t),Ml(a,"maxItems",e.exactLength.value,e.exactLength.message,t)),a}(e,a);case Xt.ZodUnion:case Xt.ZodDiscriminatedUnion:return function(e,t){if("openApi3"===t.target)return od(e,t);const a=e.options instanceof Map?Array.from(e.options.values()):e.options;if(a.every(e=>e._def.typeName in id&&(!e._def.checks||!e._def.checks.length))){const e=a.reduce((e,t)=>{const a=id[t._def.typeName];return a&&!e.includes(a)?[...e,a]:e},[]);return{type:e.length>1?e:e[0]}}if(a.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){const e=a.reduce((e,t)=>{const a=typeof t._def.value;switch(a){case"string":case"number":case"boolean":return[...e,a];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===a.length){const t=e.filter((e,t,a)=>a.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:a.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(a.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:a.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return od(e,t)}(e,a);case Xt.ZodIntersection:return function(e,t){const a=[dd(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),dd(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(e=>!!e);let n="jsonSchema2019-09"===t.target?{unevaluatedProperties:!1}:void 0;const r=[];return a.forEach(e=>{if("type"in(t=e)&&"string"===t.type||!("allOf"in t)){let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){const{additionalProperties:a,...n}=e;t=n}else n=void 0;r.push(t)}else r.push(...e.allOf),void 0===e.unevaluatedProperties&&(n=void 0);var t}),r.length?{allOf:r,...n}:void 0}(e,a);case Xt.ZodTuple:return function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,a)=>dd(e._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:dd(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,a)=>dd(e._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])}}(e,a);case Xt.ZodRecord:return rd(e,a);case Xt.ZodLiteral:return function(e,t){const a=typeof e.value;return"bigint"!==a&&"number"!==a&&"boolean"!==a&&"string"!==a?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===t.target?{type:"bigint"===a?"integer":a,enum:[e.value]}:{type:"bigint"===a?"integer":a,const:e.value}}(e,a);case Xt.ZodEnum:return function(e){return{type:"string",enum:Array.from(e.values)}}(e);case Xt.ZodNativeEnum:return function(e){const t=e.values,a=Object.keys(e.values).filter(e=>"number"!=typeof t[t[e]]).map(e=>t[e]),n=Array.from(new Set(a.map(e=>typeof e)));return{type:1===n.length?"string"===n[0]?"string":"number":["string","number"],enum:a}}(e);case Xt.ZodNullable:return function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===t.target?{type:id[e.innerType._def.typeName],nullable:!0}:{type:[id[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){const a=dd(e.innerType._def,{...t,currentPath:[...t.currentPath]});return a&&"$ref"in a?{allOf:[a],nullable:!0}:a&&{...a,nullable:!0}}const a=dd(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return a&&{anyOf:[a,{type:"null"}]}}(e,a);case Xt.ZodOptional:return((e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return dd(e.innerType._def,t);const a=dd(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return a?{anyOf:[{not:kl(t)},a]}:kl(t)})(e,a);case Xt.ZodMap:return function(e,t){return"record"===t.mapStrategy?rd(e,t):{type:"array",maxItems:125,items:{type:"array",items:[dd(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||kl(t),dd(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||kl(t)],minItems:2,maxItems:2}}}(e,a);case Xt.ZodSet:return function(e,t){const a={type:"array",uniqueItems:!0,items:dd(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Ml(a,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Ml(a,"maxItems",e.maxSize.value,e.maxSize.message,t),a}(e,a);case Xt.ZodLazy:return()=>e.getter()._def;case Xt.ZodPromise:return function(e,t){return dd(e.type._def,t)}(e,a);case Xt.ZodNaN:case Xt.ZodNever:return function(e){return"openAi"===e.target?void 0:{not:kl({...e,currentPath:[...e.currentPath,"not"]})}}(a);case Xt.ZodEffects:return function(e,t){return"input"===t.effectStrategy?dd(e.schema._def,t):kl(t)}(e,a);case Xt.ZodAny:return kl(a);case Xt.ZodUnknown:return function(e){return kl(e)}(a);case Xt.ZodDefault:return function(e,t){return{...dd(e.innerType._def,t),default:e.defaultValue()}}(e,a);case Xt.ZodBranded:return Gl(e,a);case Xt.ZodReadonly:case Xt.ZodCatch:return((e,t)=>dd(e.innerType._def,t))(e,a);case Xt.ZodPipeline:return((e,t)=>{if("input"===t.pipeStrategy)return dd(e.in._def,t);if("output"===t.pipeStrategy)return dd(e.out._def,t);const a=dd(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[a,dd(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",a?"1":"0"]})].filter(e=>void 0!==e)}})(e,a);case Xt.ZodFunction:case Xt.ZodVoid:case Xt.ZodSymbol:default:return}};function dd(e,t,a=!1){const n=t.seen.get(e);if(t.override){const r=t.override?.(e,t,n,a);if(r!==Cl)return r}if(n&&!a){const e=ud(n,t);if(void 0!==e)return e}const r={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,r);const i=ld(e,e.typeName,t),o="function"==typeof i?dd(i(),t):i;if(o&&cd(e,t,o),t.postProcess){const a=t.postProcess(o,e,t);return r.jsonSchema=o,a}return r.jsonSchema=o,o}const ud=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:jl(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((e,a)=>t.currentPath[a]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),kl(t)):"seen"===t.$refStrategy?kl(t):void 0}},cd=(e,t,a)=>(e.description&&(a.description=e.description,t.markdownDescription&&(a.markdownDescription=e.description)),a);function md(e,t){var a,n,r,i;return Hr(e)?function(e,t){if(e instanceof Zr){const a=new Il(t),n={};for(const t of e._idmap.entries()){const[e,n]=t;a.process(n)}const r={},i={registry:e,uri:t?.uri,defs:n};for(const n of e._idmap.entries()){const[e,o]=n;r[e]=a.emit(o,{...t,external:i})}if(Object.keys(n).length>0){const e="draft-2020-12"===a.target?"$defs":"definitions";r.__shared={[e]:n}}return{schemas:r}}const a=new Il(t);return a.process(e),a.emit(e,t)}(e,{target:(i=null==t?void 0:t.target,i?"jsonSchema7"===i||"draft-7"===i?"draft-7":"jsonSchema2019-09"===i||"draft-2020-12"===i?"draft-2020-12":"draft-7":"draft-7"),io:null!==(a=null==t?void 0:t.pipeStrategy)&&void 0!==a?a:"input"}):((e,t)=>{const a=Pl(t);let n="object"==typeof t&&t.definitions?Object.entries(t.definitions).reduce((e,[t,n])=>({...e,[t]:dd(n._def,{...a,currentPath:[...a.basePath,a.definitionPath,t]},!0)??kl(a)}),{}):void 0;const r="string"==typeof t?t:"title"===t?.nameStrategy?void 0:t?.name,i=dd(e._def,void 0===r?a:{...a,currentPath:[...a.basePath,a.definitionPath,r]},!1)??kl(a),o="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==o&&(i.title=o),a.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[a.openAiAnyTypeName]||(n[a.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===a.$refStrategy?"1":[...a.basePath,a.definitionPath,a.openAiAnyTypeName].join("/")}}));const s=void 0===r?n?{...i,[a.definitionPath]:n}:i:{$ref:[..."relative"===a.$refStrategy?[]:a.basePath,a.definitionPath,r].join("/"),[a.definitionPath]:{...n,[r]:i}};return"jsonSchema7"===a.target?s.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"!==a.target&&"openAi"!==a.target||(s.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===a.target&&("anyOf"in s||"oneOf"in s||"allOf"in s||"type"in s&&Array.isArray(s.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),s})(e,{strictUnions:null===(n=null==t?void 0:t.strictUnions)||void 0===n||n,pipeStrategy:null!==(r=null==t?void 0:t.pipeStrategy)&&void 0!==r?r:"input"})}function fd(e){const t=Qr(e),a=null==t?void 0:t.method;if(!a)throw new Error("Schema is missing a method literal");const n=Jr(a);if("string"!=typeof n)throw new Error("Schema method literal must be a string");return n}function _d(e,t){const a=qr(e,t);if(!a.success)throw a.error;return a.data}class hd{constructor(e){this._options=e,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(fs,e=>{this._oncancel(e)}),this.setNotificationHandler(Ps,e=>{this._onprogress(e)}),this.setRequestHandler(ws,e=>({})),this._taskStore=null==e?void 0:e.taskStore,this._taskMessageQueue=null==e?void 0:e.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Bs,async(e,t)=>{const a=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!a)throw new bl(ls.InvalidParams,"Failed to retrieve task: Task not found");return{...a}}),this.setRequestHandler(Vs,async(e,t)=>{const a=async()=>{var n;const r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if("response"===e.type||"error"===e.type){const t=e.message,a=t.id,n=this._requestResolvers.get(a);if(n)if(this._requestResolvers.delete(a),"response"===e.type)n(t);else{const e=t;n(new bl(e.error.code,e.error.message,e.error.data))}else{const t="response"===e.type?"Response":"Error";this._onerror(new Error(`${t} handler missing for request ${a}`))}continue}await(null===(n=this._transport)||void 0===n?void 0:n.send(e.message,{relatedRequestId:t.requestId}))}}const i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new bl(ls.InvalidParams,`Task not found: ${r}`);if(!Sl(i.status))return await this._waitForTaskUpdate(r,t.signal),await a();if(Sl(i.status)){const e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[$o]:{taskId:r}}}}return await a()};return await a()}),this.setRequestHandler($s,async(e,t)=>{var a;try{const{tasks:n,nextCursor:r}=await this._taskStore.listTasks(null===(a=e.params)||void 0===a?void 0:a.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new bl(ls.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(Hs,async(e,t)=>{try{const a=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!a)throw new bl(ls.InvalidParams,`Task not found: ${e.params.taskId}`);if(Sl(a.status))throw new bl(ls.InvalidParams,`Cannot cancel task in terminal status: ${a.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,"cancelled","Client cancelled task execution.",t.sessionId),this._clearTaskQueue(e.params.taskId);const n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new bl(ls.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...n}}catch(e){if(e instanceof bl)throw e;throw new bl(ls.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){const t=this._requestHandlerAbortControllers.get(e.params.requestId);null==t||t.abort(e.params.reason)}_setupTimeout(e,t,a,n,r=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,t),startTime:Date.now(),timeout:t,maxTotalTimeout:a,resetTimeoutOnProgress:r,onTimeout:n})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const a=Date.now()-t.startTime;if(t.maxTotalTimeout&&a>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),bl.fromError(ls.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:a});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var t,a,n;this._transport=e;const r=null===(t=this.transport)||void 0===t?void 0:t.onclose;this._transport.onclose=()=>{null==r||r(),this._onclose()};const i=null===(a=this.transport)||void 0===a?void 0:a.onerror;this._transport.onerror=e=>{null==i||i(e),this._onerror(e)};const o=null===(n=this._transport)||void 0===n?void 0:n.onmessage;this._transport.onmessage=(e,t)=>{var a;null==o||o(e,t),ps(e)||(a=e,ds.safeParse(a).success)?this._onresponse(e):is(e)?this._onrequest(e,t):(e=>os.safeParse(e).success)(e)?this._onnotification(e):this._onerror(new Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){var e;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();const a=bl.fromError(ls.ConnectionClosed,"Connection closed");this._transport=void 0,null===(e=this.onclose)||void 0===e||e.call(this);for(const e of t.values())e(a)}_onerror(e){var t;null===(t=this.onerror)||void 0===t||t.call(this,e)}_onnotification(e){var t;const a=null!==(t=this._notificationHandlers.get(e.method))&&void 0!==t?t:this.fallbackNotificationHandler;void 0!==a&&Promise.resolve().then(()=>a(e)).catch(e=>this._onerror(new Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){var a,n,r,i,o,s;const p=null!==(a=this._requestHandlers.get(e.method))&&void 0!==a?a:this.fallbackRequestHandler,l=this._transport,d=null===(i=null===(r=null===(n=e.params)||void 0===n?void 0:n._meta)||void 0===r?void 0:r[$o])||void 0===i?void 0:i.taskId;if(void 0===p){const t={jsonrpc:"2.0",id:e.id,error:{code:ls.MethodNotFound,message:"Method not found"}};return void(d&&this._taskMessageQueue?this._enqueueTaskMessage(d,{type:"error",message:t,timestamp:Date.now()},null==l?void 0:l.sessionId).catch(e=>this._onerror(new Error(`Failed to enqueue error response: ${e}`))):null==l||l.send(t).catch(e=>this._onerror(new Error(`Failed to send an error response: ${e}`))))}const u=new AbortController;this._requestHandlerAbortControllers.set(e.id,u);const c=null===(o=e.params)||void 0===o?void 0:o.task,m=this._taskStore?this.requestTaskStore(e,null==l?void 0:l.sessionId):void 0,f={signal:u.signal,sessionId:null==l?void 0:l.sessionId,_meta:null===(s=e.params)||void 0===s?void 0:s._meta,sendNotification:async t=>{const a={relatedRequestId:e.id};d&&(a.relatedTask={taskId:d}),await this.notification(t,a)},sendRequest:async(t,a,n)=>{var r,i;const o={...n,relatedRequestId:e.id};d&&!o.relatedTask&&(o.relatedTask={taskId:d});const s=null!==(i=null===(r=o.relatedTask)||void 0===r?void 0:r.taskId)&&void 0!==i?i:d;return s&&m&&await m.updateTaskStatus(s,"input_required"),await this.request(t,a,o)},authInfo:null==t?void 0:t.authInfo,requestId:e.id,requestInfo:null==t?void 0:t.requestInfo,taskId:d,taskStore:m,taskRequestedTtl:null==c?void 0:c.ttl,closeSSEStream:null==t?void 0:t.closeSSEStream,closeStandaloneSSEStream:null==t?void 0:t.closeStandaloneSSEStream};Promise.resolve().then(()=>{c&&this.assertTaskHandlerCapability(e.method)}).then(()=>p(e,f)).then(async t=>{if(u.signal.aborted)return;const a={result:t,jsonrpc:"2.0",id:e.id};d&&this._taskMessageQueue?await this._enqueueTaskMessage(d,{type:"response",message:a,timestamp:Date.now()},null==l?void 0:l.sessionId):await(null==l?void 0:l.send(a))},async t=>{var a;if(u.signal.aborted)return;const n={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:ls.InternalError,message:null!==(a=t.message)&&void 0!==a?a:"Internal error",...void 0!==t.data&&{data:t.data}}};d&&this._taskMessageQueue?await this._enqueueTaskMessage(d,{type:"error",message:n,timestamp:Date.now()},null==l?void 0:l.sessionId):await(null==l?void 0:l.send(n))}).catch(e=>this._onerror(new Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...a}=e.params,n=Number(t),r=this._progressHandlers.get(n);if(!r)return void this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));const i=this._responseHandlers.get(n),o=this._timeoutInfo.get(n);if(o&&i&&o.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(e){return this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),void i(e)}r(a)}_onresponse(e){const t=Number(e.id),a=this._requestResolvers.get(t);if(a){if(this._requestResolvers.delete(t),ps(e))a(e);else{a(new bl(e.error.code,e.error.message,e.error.data))}return}const n=this._responseHandlers.get(t);if(void 0===n)return void this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));this._responseHandlers.delete(t),this._cleanupTimeout(t);let r=!1;if(ps(e)&&e.result&&"object"==typeof e.result){const a=e.result;if(a.task&&"object"==typeof a.task){const e=a.task;"string"==typeof e.taskId&&(r=!0,this._taskProgressTokens.set(e.taskId,t))}}if(r||this._progressHandlers.delete(t),ps(e))n(e);else{n(bl.fromError(e.error.code,e.error.message,e.error.data))}}get transport(){return this._transport}async close(){var e;await(null===(e=this._transport)||void 0===e?void 0:e.close())}async*requestStream(e,t,a){var n,r,i,o;const{task:s}=null!=a?a:{};if(!s){try{const n=await this.request(e,t,a);yield{type:"result",result:n}}catch(e){yield{type:"error",error:e instanceof bl?e:new bl(ls.InternalError,String(e))}}return}let p;try{const s=await this.request(e,Gs,a);if(!s.task)throw new bl(ls.InternalError,"Task creation did not return a task");for(p=s.task.taskId,yield{type:"taskCreated",task:s.task};;){const e=await this.getTask({taskId:p},a);if(yield{type:"taskStatus",task:e},Sl(e.status)){if("completed"===e.status){const e=await this.getTaskResult({taskId:p},t,a);yield{type:"result",result:e}}else"failed"===e.status?yield{type:"error",error:new bl(ls.InternalError,`Task ${p} failed`)}:"cancelled"===e.status&&(yield{type:"error",error:new bl(ls.InternalError,`Task ${p} was cancelled`)});return}if("input_required"===e.status){const e=await this.getTaskResult({taskId:p},t,a);return void(yield{type:"result",result:e})}const s=null!==(i=null!==(n=e.pollInterval)&&void 0!==n?n:null===(r=this._options)||void 0===r?void 0:r.defaultTaskPollInterval)&&void 0!==i?i:1e3;await new Promise(e=>setTimeout(e,s)),null===(o=null==a?void 0:a.signal)||void 0===o||o.throwIfAborted()}}catch(e){yield{type:"error",error:e instanceof bl?e:new bl(ls.InternalError,String(e))}}}request(e,t,a){const{relatedRequestId:n,resumptionToken:r,onresumptiontoken:i,task:o,relatedTask:s}=null!=a?a:{};return new Promise((p,l)=>{var d,u,c,m,f,_,h;const E=e=>{l(e)};if(!this._transport)return void E(new Error("Not connected"));if(!0===(null===(d=this._options)||void 0===d?void 0:d.enforceStrictCapabilities))try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){return void E(e)}null===(u=null==a?void 0:a.signal)||void 0===u||u.throwIfAborted();const y=this._requestMessageId++,T={...e,jsonrpc:"2.0",id:y};(null==a?void 0:a.onprogress)&&(this._progressHandlers.set(y,a.onprogress),T.params={...e.params,_meta:{...(null===(c=e.params)||void 0===c?void 0:c._meta)||{},progressToken:y}}),o&&(T.params={...T.params,task:o}),s&&(T.params={...T.params,_meta:{...(null===(m=T.params)||void 0===m?void 0:m._meta)||{},[$o]:s}});const R=e=>{var t;this._responseHandlers.delete(y),this._progressHandlers.delete(y),this._cleanupTimeout(y),null===(t=this._transport)||void 0===t||t.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:y,reason:String(e)}},{relatedRequestId:n,resumptionToken:r,onresumptiontoken:i}).catch(e=>this._onerror(new Error(`Failed to send cancellation: ${e}`)));const a=e instanceof bl?e:new bl(ls.RequestTimeout,String(e));l(a)};this._responseHandlers.set(y,e=>{var n;if(!(null===(n=null==a?void 0:a.signal)||void 0===n?void 0:n.aborted)){if(e instanceof Error)return l(e);try{const a=qr(t,e.result);a.success?p(a.data):l(a.error)}catch(e){l(e)}}}),null===(f=null==a?void 0:a.signal)||void 0===f||f.addEventListener("abort",()=>{var e;R(null===(e=null==a?void 0:a.signal)||void 0===e?void 0:e.reason)});const g=null!==(_=null==a?void 0:a.timeout)&&void 0!==_?_:6e4;this._setupTimeout(y,g,null==a?void 0:a.maxTotalTimeout,()=>R(bl.fromError(ls.RequestTimeout,"Request timed out",{timeout:g})),null!==(h=null==a?void 0:a.resetTimeoutOnProgress)&&void 0!==h&&h);const v=null==s?void 0:s.taskId;if(v){const e=e=>{const t=this._responseHandlers.get(y);t?t(e):this._onerror(new Error(`Response handler missing for side-channeled request ${y}`))};this._requestResolvers.set(y,e),this._enqueueTaskMessage(v,{type:"request",message:T,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(y),l(e)})}else this._transport.send(T,{relatedRequestId:n,resumptionToken:r,onresumptiontoken:i}).catch(e=>{this._cleanupTimeout(y),l(e)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},zs,t)}async getTaskResult(e,t,a){return this.request({method:"tasks/result",params:e},t,a)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},Us,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},Ks,t)}async notification(e,t){var a,n,r,i,o;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const s=null===(a=null==t?void 0:t.relatedTask)||void 0===a?void 0:a.taskId;if(s){const a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...(null===(n=e.params)||void 0===n?void 0:n._meta)||{},[$o]:t.relatedTask}}};return void await this._enqueueTaskMessage(s,{type:"notification",message:a,timestamp:Date.now()})}if((null!==(i=null===(r=this._options)||void 0===r?void 0:r.debouncedNotificationMethods)&&void 0!==i?i:[]).includes(e.method)&&!e.params&&!(null==t?void 0:t.relatedRequestId)&&!(null==t?void 0:t.relatedTask)){if(this._pendingDebouncedNotifications.has(e.method))return;return this._pendingDebouncedNotifications.add(e.method),void Promise.resolve().then(()=>{var a,n;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let r={...e,jsonrpc:"2.0"};(null==t?void 0:t.relatedTask)&&(r={...r,params:{...r.params,_meta:{...(null===(a=r.params)||void 0===a?void 0:a._meta)||{},[$o]:t.relatedTask}}}),null===(n=this._transport)||void 0===n||n.send(r,t).catch(e=>this._onerror(e))})}let p={...e,jsonrpc:"2.0"};(null==t?void 0:t.relatedTask)&&(p={...p,params:{...p.params,_meta:{...(null===(o=p.params)||void 0===o?void 0:o._meta)||{},[$o]:t.relatedTask}}}),await this._transport.send(p,t)}setRequestHandler(e,t){const a=fd(e);this.assertRequestHandlerCapability(a),this._requestHandlers.set(a,(a,n)=>{const r=_d(e,a);return Promise.resolve(t(r,n))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const a=fd(e);this._notificationHandlers.set(a,a=>{const n=_d(e,a);return Promise.resolve(t(n))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);void 0!==t&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,a){var n;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const r=null===(n=this._options)||void 0===n?void 0:n.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,a,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const a=await this._taskMessageQueue.dequeueAll(e,t);for(const t of a)if("request"===t.type&&is(t.message)){const a=t.message.id,n=this._requestResolvers.get(a);n?(n(new bl(ls.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(a)):this._onerror(new Error(`Resolver missing for request ${a} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){var a,n,r;let i=null!==(n=null===(a=this._options)||void 0===a?void 0:a.defaultTaskPollInterval)&&void 0!==n?n:1e3;try{const t=await(null===(r=this._taskStore)||void 0===r?void 0:r.getTask(e));(null==t?void 0:t.pollInterval)&&(i=t.pollInterval)}catch(e){}return new Promise((e,a)=>{if(t.aborted)return void a(new bl(ls.InvalidRequest,"Request cancelled"));const n=setTimeout(e,i);t.addEventListener("abort",()=>{clearTimeout(n),a(new bl(ls.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const a=this._taskStore;if(!a)throw new Error("No task store configured");return{createTask:async n=>{if(!e)throw new Error("No request provided");return await a.createTask(n,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{const n=await a.getTask(e,t);if(!n)throw new bl(ls.InvalidParams,"Failed to retrieve task: Task not found");return n},storeTaskResult:async(e,n,r)=>{await a.storeTaskResult(e,n,r,t);const i=await a.getTask(e,t);if(i){const t=Fs.parse({method:"notifications/tasks/status",params:i});await this.notification(t),Sl(i.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>a.getTaskResult(e,t),updateTaskStatus:async(e,n,r)=>{const i=await a.getTask(e,t);if(!i)throw new bl(ls.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(Sl(i.status))throw new bl(ls.InvalidParams,`Cannot update task "${e}" from terminal status "${i.status}" to "${n}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await a.updateTaskStatus(e,n,r,t);const o=await a.getTask(e,t);if(o){const t=Fs.parse({method:"notifications/tasks/status",params:o});await this.notification(t),Sl(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>a.listTasks(e,t)}}}function Ed(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}var yd=c(1601),Td=c(4421);class Rd{constructor(e){this._ajv=null!=e?e:function(){const e=new yd.Ajv({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return Td(e),e}()}getValidator(e){var t;const a="$id"in e&&"string"==typeof e.$id&&null!==(t=this._ajv.getSchema(e.$id))&&void 0!==t?t:this._ajv.compile(e);return e=>a(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(a.errors)}}}class gd{constructor(e){this._server=e}requestStream(e,t,a){return this._server.requestStream(e,t,a)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,a){return this._server.getTaskResult({taskId:e},t,a)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}}class vd extends hd{constructor(e,t){var a,n;super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Fp.options.map((e,t)=>[e,t])),this.isMessageIgnored=(e,t)=>{const a=this._loggingLevels.get(t);return!!a&&this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(a)},this._capabilities=null!==(a=null==t?void 0:t.capabilities)&&void 0!==a?a:{},this._instructions=null==t?void 0:t.instructions,this._jsonSchemaValidator=null!==(n=null==t?void 0:t.jsonSchemaValidator)&&void 0!==n?n:new Rd,this.setRequestHandler(bs,e=>this._oninitialize(e)),this.setNotificationHandler(Is,()=>{var e;return null===(e=this.oninitialized)||void 0===e?void 0:e.call(this)}),this._capabilities.logging&&this.setRequestHandler(zp,async(e,t)=>{var a;const n=t.sessionId||(null===(a=t.requestInfo)||void 0===a?void 0:a.headers["mcp-session-id"])||void 0,{level:r}=e.params,i=Fp.safeParse(r);return i.success&&this._loggingLevels.set(n,i.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new gd(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=function(e,t){const a={...e};for(const e in t){const n=e,r=t[n];if(void 0===r)continue;const i=a[n];Ed(i)&&Ed(r)?a[n]={...i,...r}:a[n]=r}return a}(this._capabilities,e)}setRequestHandler(e,t){var a,n,r;const i=Qr(e),o=null==i?void 0:i.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(Hr(o)){const e=o,t=null===(a=e._zod)||void 0===a?void 0:a.def;s=null!==(n=null==t?void 0:t.value)&&void 0!==n?n:e.value}else{const e=o,t=e._def;s=null!==(r=null==t?void 0:t.value)&&void 0!==r?r:e.value}if("string"!=typeof s)throw new Error("Schema method literal must be a string");if("tools/call"===s){const a=async(e,a)=>{const n=qr(Gp,e);if(!n.success){const e=n.error instanceof Error?n.error.message:String(n.error);throw new bl(ls.InvalidParams,`Invalid tools/call request: ${e}`)}const{params:r}=n.data,i=await Promise.resolve(t(e,a));if(r.task){const e=qr(Gs,i);if(!e.success){const t=e.error instanceof Error?e.error.message:String(e.error);throw new bl(ls.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}const o=qr(Lp,i);if(!o.success){const e=o.error instanceof Error?o.error.message:String(o.error);throw new bl(ls.InvalidParams,`Invalid tools/call result: ${e}`)}return o.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,t)}assertCapabilityForMethod(e){var t,a,n;switch(e){case"sampling/createMessage":if(!(null===(t=this._clientCapabilities)||void 0===t?void 0:t.sampling))throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!(null===(a=this._clientCapabilities)||void 0===a?void 0:a.elicitation))throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!(null===(n=this._clientCapabilities)||void 0===n?void 0:n.roots))throw new Error(`Client does not support listing roots (required for ${e})`)}}assertNotificationCapability(e){var t,a;switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);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 ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!(null===(a=null===(t=this._clientCapabilities)||void 0===t?void 0:t.elicitation)||void 0===a?void 0:a.url))throw new Error(`Client does not support URL elicitation (required for ${e})`)}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);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 ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);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 ${e})`)}}assertTaskCapability(e){var t,a;!function(e,t,a){var n,r;if(!e)throw new Error(`${a} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!(null===(n=e.sampling)||void 0===n?void 0:n.createMessage))throw new Error(`${a} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!(null===(r=e.elicitation)||void 0===r?void 0:r.create))throw new Error(`${a} does not support task creation for elicitation/create (required for ${t})`)}}(null===(a=null===(t=this._clientCapabilities)||void 0===t?void 0:t.tasks)||void 0===a?void 0:a.requests,e,"Client")}assertTaskHandlerCapability(e){var t;this._capabilities&&function(e,t,a){var n;if(!e)throw new Error(`${a} does not support task creation (required for ${t})`);if("tools/call"===t&&!(null===(n=e.tools)||void 0===n?void 0:n.call))throw new Error(`${a} does not support task creation for tools/call (required for ${t})`)}(null===(t=this._capabilities.tasks)||void 0===t?void 0:t.requests,e,"Server")}async _oninitialize(e){const t=e.params.protocolVersion;this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo;return{protocolVersion:Vo.includes(t)?t:zo,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"},cs)}async createMessage(e,t){var a,n;if((e.tools||e.toolChoice)&&!(null===(n=null===(a=this._clientCapabilities)||void 0===a?void 0:a.sampling)||void 0===n?void 0:n.tools))throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){const t=e.messages[e.messages.length-1],a=Array.isArray(t.content)?t.content:[t.content],n=a.some(e=>"tool_result"===e.type),r=e.messages.length>1?e.messages[e.messages.length-2]:void 0,i=r?Array.isArray(r.content)?r.content:[r.content]:[],o=i.some(e=>"tool_use"===e.type);if(n){if(a.some(e=>"tool_result"!==e.type))throw new Error("The last message must contain only tool_result content if any is present");if(!o)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(o){const e=new Set(i.filter(e=>"tool_use"===e.type).map(e=>e.id)),t=new Set(a.filter(e=>"tool_result"===e.type).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},el,t):this.request({method:"sampling/createMessage",params:e},Zp,t)}async elicitInput(e,t){var a,n,r,i,o;switch(null!==(a=e.mode)&&void 0!==a?a:"form"){case"url":{if(!(null===(r=null===(n=this._clientCapabilities)||void 0===n?void 0:n.elicitation)||void 0===r?void 0:r.url))throw new Error("Client does not support url elicitation.");const a=e;return this.request({method:"elicitation/create",params:a},_l,t)}case"form":{if(!(null===(o=null===(i=this._clientCapabilities)||void 0===i?void 0:i.elicitation)||void 0===o?void 0:o.form))throw new Error("Client does not support form elicitation.");const a="form"===e.mode?e:{...e,mode:"form"},n=await this.request({method:"elicitation/create",params:a},_l,t);if("accept"===n.action&&n.content&&a.requestedSchema)try{const e=this._jsonSchemaValidator.getValidator(a.requestedSchema)(n.content);if(!e.valid)throw new bl(ls.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){if(e instanceof bl)throw e;throw new bl(ls.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return n}}}createElicitationCompletionNotifier(e,t){var a,n;if(!(null===(n=null===(a=this._clientCapabilities)||void 0===a?void 0:a.elicitation)||void 0===n?void 0:n.url))throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},t)}async listRoots(e,t){return this.request({method:"roots/list",params:e},Ol,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}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"})}}const Od=Symbol.for("mcp.completable");var Nd;!function(e){e.Completable="McpCompletable"}(Nd||(Nd={}));const bd=/^[A-Za-z0-9._-]{1,128}$/;function Ad(e){const t=function(e){const t=[];if(0===e.length)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!bd.test(e)){const a=e.split("").filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,a)=>a.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${a.map(e=>`"${e}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}(e);return function(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(const e of t)console.warn(` - ${e}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}(e,t.warnings),t.isValid}class Sd{constructor(e){this._mcpServer=e}registerToolTask(e,t,a){const n={taskSupport:"required",...t.execution};if("forbidden"===n.taskSupport)throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,t.title,t.description,t.inputSchema,t.outputSchema,t.annotations,n,t._meta,a)}}class Id{constructor(e,t){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new vd(e,t)}get experimental(){return this._experimental||(this._experimental={tasks:new Sd(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(kd(jp)),this.server.assertCanSetRequestHandler(kd(Gp)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(jp,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{const a={name:e,title:t.title,description:t.description,inputSchema:(()=>{const e=Yr(t.inputSchema);return e?md(e,{strictUnions:!0,pipeStrategy:"input"}):wd})(),annotations:t.annotations,execution:t.execution,_meta:t._meta};if(t.outputSchema){const e=Yr(t.outputSchema);e&&(a.outputSchema=md(e,{strictUnions:!0,pipeStrategy:"output"}))}return a})})),this.server.setRequestHandler(Gp,async(e,t)=>{var a;try{const n=this._registeredTools[e.params.name];if(!n)throw new bl(ls.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new bl(ls.InvalidParams,`Tool ${e.params.name} disabled`);const r=!!e.params.task,i=null===(a=n.execution)||void 0===a?void 0:a.taskSupport,o="createTask"in n.handler;if(("required"===i||"optional"===i)&&!o)throw new bl(ls.InternalError,`Tool ${e.params.name} has taskSupport '${i}' but was not registered with registerToolTask`);if("required"===i&&!r)throw new bl(ls.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if("optional"===i&&!r&&o)return await this.handleAutomaticTaskPolling(n,e,t);const s=await this.validateToolInput(n,e.params.arguments,e.params.name),p=await this.executeToolHandler(n,s,t);return r||await this.validateToolOutput(n,p,e.params.name),p}catch(e){if(e instanceof bl&&e.code===ls.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,t,a){if(!e.inputSchema)return;const n=Yr(e.inputSchema),r=null!=n?n:e.inputSchema,i=await Wr(r,t);if(!i.success){const e=Xr("error"in i?i.error:"Unknown error");throw new bl(ls.InvalidParams,`Input validation error: Invalid arguments for tool ${a}: ${e}`)}return i.data}async validateToolOutput(e,t,a){if(!e.outputSchema)return;if(!("content"in t))return;if(t.isError)return;if(!t.structuredContent)throw new bl(ls.InvalidParams,`Output validation error: Tool ${a} has an output schema but no structured content was provided`);const n=Yr(e.outputSchema),r=await Wr(n,t.structuredContent);if(!r.success){const e=Xr("error"in r?r.error:"Unknown error");throw new bl(ls.InvalidParams,`Output validation error: Invalid structured content for tool ${a}: ${e}`)}}async executeToolHandler(e,t,a){const n=e.handler;if("createTask"in n){if(!a.taskStore)throw new Error("No task store provided.");const r={...a,taskStore:a.taskStore};if(e.inputSchema){const e=n;return await Promise.resolve(e.createTask(t,r))}{const e=n;return await Promise.resolve(e.createTask(r))}}if(e.inputSchema){const e=n;return await Promise.resolve(e(t,a))}{const e=n;return await Promise.resolve(e(a))}}async handleAutomaticTaskPolling(e,t,a){var n;if(!a.taskStore)throw new Error("No task store provided for task-capable tool.");const r=await this.validateToolInput(e,t.params.arguments,t.params.name),i=e.handler,o={...a,taskStore:a.taskStore},s=r?await Promise.resolve(i.createTask(r,o)):await Promise.resolve(i.createTask(o)),p=s.task.taskId;let l=s.task;const d=null!==(n=l.pollInterval)&&void 0!==n?n:5e3;for(;"completed"!==l.status&&"failed"!==l.status&&"cancelled"!==l.status;){await new Promise(e=>setTimeout(e,d));const e=await a.taskStore.getTask(p);if(!e)throw new bl(ls.InternalError,`Task ${p} not found during polling`);l=e}return await a.taskStore.getTaskResult(p)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(kd(Tl)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Tl,async e=>{switch(e.params.ref.type){case"ref/prompt":return function(e){if("ref/prompt"!==e.params.ref.type)throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return function(e){if("ref/resource"!==e.params.ref.type)throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}(e),this.handleResourceCompletion(e,e.params.ref);default:throw new bl(ls.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){const a=this._registeredPrompts[t.name];if(!a)throw new bl(ls.InvalidParams,`Prompt ${t.name} not found`);if(!a.enabled)throw new bl(ls.InvalidParams,`Prompt ${t.name} disabled`);if(!a.argsSchema)return Md;const n=Qr(a.argsSchema),r=null==n?void 0:n[e.params.argument.name];if(!function(e){return!!e&&"object"==typeof e&&Od in e}(r))return Md;const i=function(e){const t=e[Od];return null==t?void 0:t.complete}(r);if(!i)return Md;return Ld(await i(e.params.argument.value,e.params.context))}async handleResourceCompletion(e,t){const a=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!a){if(this._registeredResources[t.uri])return Md;throw new bl(ls.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}const n=a.resourceTemplate.completeCallback(e.params.argument.name);if(!n)return Md;return Ld(await n(e.params.argument.value,e.params.context))}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(kd(ep)),this.server.assertCanSetRequestHandler(kd(ap)),this.server.assertCanSetRequestHandler(kd(op)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(ep,async(e,t)=>{const a=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),n=[];for(const e of Object.values(this._registeredResourceTemplates)){if(!e.resourceTemplate.listCallback)continue;const a=await e.resourceTemplate.listCallback(t);for(const t of a.resources)n.push({...e.metadata,...t})}return{resources:[...a,...n]}}),this.server.setRequestHandler(ap,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler(op,async(e,t)=>{const a=new URL(e.params.uri),n=this._registeredResources[a.toString()];if(n){if(!n.enabled)throw new bl(ls.InvalidParams,`Resource ${a} disabled`);return n.readCallback(a,t)}for(const e of Object.values(this._registeredResourceTemplates)){const n=e.resourceTemplate.uriTemplate.match(a.toString());if(n)return e.readCallback(a,n,t)}throw new bl(ls.InvalidParams,`Resource ${a} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(kd(Ep)),this.server.assertCanSetRequestHandler(kd(Rp)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Ep,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?jd(t.argsSchema):void 0}))})),this.server.setRequestHandler(Rp,async(e,t)=>{const a=this._registeredPrompts[e.params.name];if(!a)throw new bl(ls.InvalidParams,`Prompt ${e.params.name} not found`);if(!a.enabled)throw new bl(ls.InvalidParams,`Prompt ${e.params.name} disabled`);if(a.argsSchema){const n=Yr(a.argsSchema),r=await Wr(n,e.params.arguments);if(!r.success){const t=Xr("error"in r?r.error:"Unknown error");throw new bl(ls.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${t}`)}const i=r.data,o=a.callback;return await Promise.resolve(o(i,t))}{const e=a.callback;return await Promise.resolve(e(t))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0)}resource(e,t,...a){let n;"object"==typeof a[0]&&(n=a.shift());const r=a[0];if("string"==typeof t){if(this._registeredResources[t])throw new Error(`Resource ${t} is already registered`);const a=this._createRegisteredResource(e,void 0,t,n,r);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const a=this._createRegisteredResourceTemplate(e,void 0,t,n,r);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}}registerResource(e,t,a,n){if("string"==typeof t){if(this._registeredResources[t])throw new Error(`Resource ${t} is already registered`);const r=this._createRegisteredResource(e,a.title,t,a,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),r}{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const r=this._createRegisteredResourceTemplate(e,a.title,t,a,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),r}}_createRegisteredResource(e,t,a,n,r){const i={name:e,title:t,metadata:n,readCallback:r,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:e=>{void 0!==e.uri&&e.uri!==a&&(delete this._registeredResources[a],e.uri&&(this._registeredResources[e.uri]=i)),void 0!==e.name&&(i.name=e.name),void 0!==e.title&&(i.title=e.title),void 0!==e.metadata&&(i.metadata=e.metadata),void 0!==e.callback&&(i.readCallback=e.callback),void 0!==e.enabled&&(i.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[a]=i,i}_createRegisteredResourceTemplate(e,t,a,n,r){const i={resourceTemplate:a,title:t,metadata:n,readCallback:r,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=i)),void 0!==t.title&&(i.title=t.title),void 0!==t.template&&(i.resourceTemplate=t.template),void 0!==t.metadata&&(i.metadata=t.metadata),void 0!==t.callback&&(i.readCallback=t.callback),void 0!==t.enabled&&(i.enabled=t.enabled),this.sendResourceListChanged()}};return this._registeredResourceTemplates[e]=i,i}_createRegisteredPrompt(e,t,a,n,r){const i={title:t,description:a,argsSchema:void 0===n?void 0:Kr(n),callback:r,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=i)),void 0!==t.title&&(i.title=t.title),void 0!==t.description&&(i.description=t.description),void 0!==t.argsSchema&&(i.argsSchema=Kr(t.argsSchema)),void 0!==t.callback&&(i.callback=t.callback),void 0!==t.enabled&&(i.enabled=t.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,i}_createRegisteredTool(e,t,a,n,r,i,o,s,p){Ad(e);const l={title:t,description:a,inputSchema:Pd(n),outputSchema:Pd(r),annotations:i,execution:o,_meta:s,handler:p,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&("string"==typeof t.name&&Ad(t.name),delete this._registeredTools[e],t.name&&(this._registeredTools[t.name]=l)),void 0!==t.title&&(l.title=t.title),void 0!==t.description&&(l.description=t.description),void 0!==t.paramsSchema&&(l.inputSchema=Kr(t.paramsSchema)),void 0!==t.callback&&(l.handler=t.callback),void 0!==t.annotations&&(l.annotations=t.annotations),void 0!==t._meta&&(l._meta=t._meta),void 0!==t.enabled&&(l.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...t){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let a,n,r;if("string"==typeof t[0]&&(a=t.shift()),t.length>1){const e=t[0];Dd(e)?(n=t.shift(),t.length>1&&"object"==typeof t[0]&&null!==t[0]&&!Dd(t[0])&&(r=t.shift())):"object"==typeof e&&null!==e&&(r=t.shift())}const i=t[0];return this._createRegisteredTool(e,void 0,a,n,undefined,r,{taskSupport:"forbidden"},void 0,i)}registerTool(e,t,a){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);const{title:n,description:r,inputSchema:i,outputSchema:o,annotations:s,_meta:p}=t;return this._createRegisteredTool(e,n,r,i,o,s,{taskSupport:"forbidden"},p,a)}prompt(e,...t){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let a,n;"string"==typeof t[0]&&(a=t.shift()),t.length>1&&(n=t.shift());const r=t[0],i=this._createRegisteredPrompt(e,void 0,a,n,r);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}registerPrompt(e,t,a){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);const{title:n,description:r,argsSchema:i}=t,o=this._createRegisteredPrompt(e,n,r,i,a);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}isConnected(){return void 0!==this.server.transport}async sendLoggingMessage(e,t){return this.server.sendLoggingMessage(e,t)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}}const wd={type:"object",properties:{}};function Cd(e){return null!==e&&"object"==typeof e&&"parse"in e&&"function"==typeof e.parse&&"safeParse"in e&&"function"==typeof e.safeParse}function Dd(e){return"object"==typeof e&&null!==e&&(!function(e){return"_def"in e||"_zod"in e||Cd(e)}(e)&&(0===Object.keys(e).length||Object.values(e).some(Cd)))}function Pd(e){if(e)return Dd(e)?Kr(e):e}function jd(e){const t=Qr(e);return t?Object.entries(t).map(([e,t])=>{const a=function(e){var t,a,n,r;if(Hr(e))return null===(a=null===(t=e._zod)||void 0===t?void 0:t.def)||void 0===a?void 0:a.description;const i=e;return null!==(n=e.description)&&void 0!==n?n:null===(r=i._def)||void 0===r?void 0:r.description}(t),n=function(e){var t,a,n;if(Hr(e))return"optional"===(null===(a=null===(t=e._zod)||void 0===t?void 0:t.def)||void 0===a?void 0:a.type);const r=e;return"function"==typeof e.isOptional?e.isOptional():"ZodOptional"===(null===(n=r._def)||void 0===n?void 0:n.typeName)}(t);return{name:e,description:a,required:!n}}):[]}function kd(e){const t=Qr(e),a=null==t?void 0:t.method;if(!a)throw new Error("Schema is missing a method literal");const n=Jr(a);if("string"==typeof n)return n;throw new Error("Schema method literal must be a string")}function Ld(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}const Md={completion:{values:[],hasMore:!1}};var Gd=c(1708);class xd{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;const e=this._buffer.indexOf("\n");if(-1===e)return null;const t=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),function(e){return us.parse(JSON.parse(e))}(t)}clear(){this._buffer=void 0}}class Fd{constructor(e=Gd.stdin,t=Gd.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new xd,this._started=!1,this._ondata=e=>{this._readBuffer.append(e),this.processReadBuffer()},this._onerror=e=>{var t;null===(t=this.onerror)||void 0===t||t.call(this,e)}}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(var e,t;;)try{const t=this._readBuffer.readMessage();if(null===t)break;null===(e=this.onmessage)||void 0===e||e.call(this,t)}catch(e){null===(t=this.onerror)||void 0===t||t.call(this,e)}}async close(){var e;this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror);0===this._stdin.listenerCount("data")&&this._stdin.pause(),this._readBuffer.clear(),null===(e=this.onclose)||void 0===e||e.call(this)}send(e){return new Promise(t=>{const a=function(e){return JSON.stringify(e)+"\n"}(e);this._stdout.write(a)?t():this._stdout.once("drain",t)})}}var Bd={info:"info",manage_signature:"sign",query_application:"qa",query_device:"qd",query_device_group:"qdg",query_module:"qm",query_activity_log:"qal",create_application:"ca",create_device:"cd",create_device_group:"cdg",create_module:"cm",update_application:"ua",bind_application:"ba",short_edit_application:"uas",canvas_control_application:"uacc",update_device:"ud",update_device_group:"udg",update_module:"um",short_edit_module:"ums",remove_application:"ra",remove_device:"rd",remove_device_group:"rdg",remove_module:"rm",control_device:"ctld",control_application_device:"ctlad",control_device_group:"ctldg",query_media_flow:"qmf",write_media_flow:"wmf",access_unstable_feature:"UNSTABLE"},zd=Object.entries(Bd).reduce(function(e,t){var a=X(t,2),n=a[0];return e[a[1]]=n,e},{}),Vd=["HS256","RS256"],$d=["https://auth0.bricks.tools/","https://mybigday.auth0.com/"];function Ud(e){try{var t,a,n=null==(t=e.queryStringParameters)?void 0:t.token;if(!n)n=null==(a=new Headers(e.headers).get("authorization"))?void 0:a.replace("Bearer ","");if(!n)return{success:!1,message:"Authentication failed: No token provided"};var r=function(e){try{var t=e.split(".");if(t.length<3)return null;var a=JSON.parse(Buffer.from(t[0],"base64url").toString());return Vd.includes(null==a?void 0:a.alg)?JSON.parse(Buffer.from(t[1],"base64url").toString()):null}catch(e){return null}}(n);if(!r)return{success:!1,message:"Authentication failed: Invalid token"};var i=$d.includes(r.iss)?"user":"workspace";if("workspace"===i){var o=Array.isArray(r.t)?r.t:[];r.permissions=o.map(function(e){return zd[e]}).filter(Boolean)}else r.permissions=Object.keys(Bd);return{success:!0,token:n,tokenInfo:r,tokenType:i}}catch(e){return{success:!1,message:`Authentication failed: ${e.message}`}}}const Hd='# Getting Started with BRICKS\n\nBRICKS (方塊磚) is a comprehensive platform for creating interactive multimedia display applications specifically designed for digital signage screens. It enables users to design complete applications without programming, using a visual, component-based approach.\n\n**Important**: Users interact through a visual GUI editor, not raw configuration files. Always describe features in user-friendly terms:\n- "text display" not "BRICK_TEXT"\n- "image" not "BRICK_IMAGE"\n- "canvas name" not "CANVAS_xxx"\n- "data storage" not "PROPERTY_BANK"\n- Focus on what users see and do, not technical implementation details\n\n## Core Philosophy\n\nBRICKS operates as a **Launcher system** that reads configuration files from the cloud (or cached locally) and must maintain normal operation even when offline. The system periodically reports health status and supports watchdog timers for automatic restart or maintenance mode activation.\n\n## Fundamental Architecture\n\n### The Three Core Elements\n\n#### 1. Canvas (畫布)\n- **Definition**: The visual container that defines what users see on screen\n- **Behavior**: Screen transitions occur by switching between different canvases\n- **Smart Transitions**: When switching canvases, BRICKS automatically compares shared elements and smoothly animates their position/size changes\n- **Properties**:\n - `Showing Timeout`: Auto-advance to next canvas after specified time\n - `Next Canvas ID`: Target canvas for timeout transitions\n - `Background Color`: Canvas background\n - `Dismiss Keyboard On Press`: Touch behavior for keyboard dismissal\n- **Events**: `CANVAS_FIRST_ENTER`, `CANVAS_ENTER`, `CANVAS_SHOWING_TIMEOUT`, `CANVAS_EXIT`\n\n#### 2. Brick (方塊)\n- **Definition**: Visual components that display content and handle user interactions\n- **Animation System**: All bricks support three animation phases:\n - **Enter Animation**: How the brick appears on screen\n - **Display Animation**: Ongoing animations while visible\n - **Exit Animation**: How the brick disappears\n- **Positioning**: Uses grid-based positioning system for resolution independence\n- **Interaction**: Can respond to touch events and trigger system actions\n\nAvailable template:\n[:BRICK_IDS:]\n\n#### 3. Generator (處理器)\n- **Definition**: Invisible processing units that handle non-visual functionality\n- **Purpose**: Handle hardware interactions (camera, sensors), data processing, network communication\n- **Input**: Receives parameters exclusively through Property Bank\n- **Output**: Returns results exclusively through Property Bank\n- **Triggers**: Activated by Events connected to their Actions\n\nAvailable template:\n[:GENERATOR_IDS:]\n\n### Data (Property Bank, 參數庫)\nThe central data management system that serves as the backbone of BRICKS applications:\n\n#### Key Features\n- **KEY-VALUE Structure**: Simple, accessible data storage\n- **Dual Events**: Each property supports both "Update" and "Value Change" events\n- **Auto-Refresh**: UI elements automatically update when linked data changes\n- **Cross-Subspace Communication**: Properties can be shared between different subspaces\n- **Data Types**: `string`, `number`, `bool`, `object`, `array`, `any`\n- **Special Kinds**: `color`, `datetime`, `id`, `media-resource-*`, `lottie-file-uri`\n- **Units**: `grid`, `px`, `ms` for different measurement types\n\n#### Routing Options\n- **read-only**: Cannot be changed from other subspaces\n- **Default**: Accepts changes from other subspaces\n\nTerminology note: We refer to the central data system as "Data" in docs and UI. Internally, it remains "Property Bank" and uses `PROPERTY_BANK_*` identifiers.\n\n### Event System\nBRICKS uses a comprehensive event-driven architecture:\n\n#### Event Sources\n- **System Events**: Property Bank changes, timer events, canvas transitions\n- **Brick Events**: User interactions (press, focus, value changes)\n- **Generator Events**: Hardware responses, network callbacks, processing completions\n\n#### Event Handling\n- **Sequential Processing**: Events trigger Actions in defined order\n- **Parameter Passing**: All parameters passed through Property Bank\n- **Action Types**: System actions or Generator actions\n\n### Subspace (子空間)\nAdvanced modularity system for complex applications:\n\n#### Concept\n- **Nested Systems**: Complete BRICKS system within a brick\n- **Independent Operation**: Own canvases, bricks, and property banks\n- **Modular Behavior**: Can be positioned, scaled, and animated like regular bricks\n\n#### Communication\n- **Input**: External Property Bank values copied to internal Property Bank\n- **Output**: Internal Property Bank changes trigger external events\n- **Data Flow**: Call-by-value copying maintains isolation while enabling communication\n\n## Grid System\n\n### Resolution Independence\n- **Default Grid**: 96×54 units (optimized for HD displays)\n- **Automatic Scaling**: Grid units convert to pixels based on device resolution\n- **Calculation**: `grid_unit_size_px = device_width_px / app_grid_width`\n\n### Examples\n| Device Resolution | App Grid Size | Grid Unit Size |\n|------------------|---------------|----------------|\n| 1920×1080 | 96×54 | 20px |\n| 3840×2160 | 96×54 | 40px |\n| 1280×720 | 96×54 | 13.33px |\n\n### Positioning Features\n- **Overflow Support**: Elements can extend beyond visible area\n- **Partial Display**: Elements at negative positions show partial content\n- **Performance Optimization**: Completely off-screen elements are automatically ignored\n\n## Configuration Structure\n\n### Hierarchy\n```\nApplication (應用程式)\n├── Root Subspace\n├── Subspace Map\n│ ├── Canvas Map\n│ ├── Brick Map\n│ └── Generator Map\n├── Property Bank\n├── Property Bank Calc\n├── Event Map\n└── Automation Map\n```\n\n### Item property\nProperties can set constant value or link data like this\n\n```js\n{\n "example1": 123,\n "example2": "PROPERTY_BANK#<Data Node ID>", // Link Data\n "example3": {\n "PROPERTY_BANK#<Data Node ID>", // Link Data in object, we recommend direct link without middle object data\n }\n}\n```\n\n### Item outlet\nData output from brick or generator, you can link it to data\n\n```js\n{\n OUTLET_NAME: \'<Data Node ID>\'\n}\n```\n\n### Event actions\nOn handling event can do actions with this schema\n\n```js\n[\n {\n "action": "string",\n "handler": "string",\n "parameter_list": [\n {\n "input_to_receiver": "string", // Argument\n "result_from_sender": "string" // Link data\n }\n ],\n "wait_async": "boolean"\n }\n]\n```\n\n- `handler: SYSTEM`\n[:SYSTEM_ACTIONS:]\n- `handler: GENERATOR_<UUID>`\n- `handler: BRICK_<UUID>`\n\n## Development Workflow\n\n### 1. Design Phase\n- Define grid layout (usually 96×54)\n- Plan canvas flow and transitions\n- Identify required data flows\n\n### 2. Implementation\n- Use `create_item` to constuct config\n- Create subspaces for different app sections\n- Add canvases for each screen/state\n- Place and configure bricks for UI elements\n- Add generators for processing logic\n- Connect events to actions\n\n### 3. Data Management\n- Set up Property Bank structure\n- Configure property types and routing\n- Link UI elements to data sources\n- Implement data processing flows\n\n#### Mental Model\n- Reactive architecture: events trigger actions; actions update Data; UI and generators react to Data changes.\n- Calculations: optional graphs transform Data using Data Calculation (command/data nodes or script).\n- Always read/write via Data. Generators receive input from Data and write outputs back to Data.\n\n#### Common Patterns\n- Event → Action → Data update or Outlet → Data update\n- Data change → Triggers downstream calculations → Updates target Data\n- Cross-subspace routing: respect `read-only` vs `default`\n\n### 4. Testing & Deployment\n- Use automation maps for testing\n- Validate configuration schema\n- Deploy to target devices\n- Monitor system health\n\n## Best Practices\n\n### Performance\n- Use 96×54 grid for standard content\n- Minimize off-screen elements\n- Optimize property bank access patterns\n- Cache media resources appropriately\n\n### User Experience\n- Always use enter/exit animations (avoid sudden appearances)\n- Maintain consistent transition timing\n- Design for offline operation\n- Implement proper error handling\n\n### Architecture\n- Keep subspaces focused and modular\n- Use generators for all non-visual processing\n- Minimize cross-subspace dependencies\n- Design for reusability through modules\n\n## Network & Offline Behavior\n\n### Online Operation\n- Configuration sync from cloud\n- Media resource loading\n- Real-time data updates\n- Health status reporting\n\n### Offline Requirements\n- **Display Continuity**: All display and reading functions must work offline\n- **Data Caching**: Write operations cached locally and synced when online\n- **Resource Management**: Media and assets preloaded during online periods\n- **Graceful Degradation**: Non-essential features disabled, core functionality maintained\n\nThis comprehensive foundation enables the creation of sophisticated, interactive digital signage applications that are both powerful and maintainable.\n\n## Local Sync\n\nLocal Sync enables near real-time intranet communication between devices for seamless multi-screen display splicing.\n\n- Data Sync: Synchronize selected data (Property Bank/Data nodes) across devices so UI updates remain consistent.\n- Canvas Sync: Optionally synchronize active canvas to orchestrate state transitions across screens.\n- Typical Use: Video walls, tiled displays, or clustered players that must behave as one.\n- Transport: LAN/intranet only; optimized for low latency and reliability inside the local network.\n- Resilience: Designed to tolerate temporary disconnections; devices rejoin and resynchronize state.\n\nConfiguration hints (high level):\n- Subspaces can define local sync behavior (e.g., whether to sync canvas changes).\n- Generators may opt into specific local sync run modes.\n- Keep payloads small and data normalized for best performance.';var Kd=c(181),qd=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{content:[Kd.Buffer.isBuffer(e)?Object.assign({},t,{blob:e.toString("base64"),type:"blob"}):Object.assign({},t,{text:"string"==typeof e?e:JSON.stringify(e,null,2),type:"text"})],isError:!1}};var Wd=c(8212),Qd=c(1313);const Yd=t("node:net"),Xd=t("node:http"),Jd=t("node:https");var Zd=c(8875);const eu=t("node:dns"),tu={allowPrivateIPAddress:!1,allowMetaIPAddress:!1,allowIPAddressList:[],denyIPAddressList:[]},au=({address:e,host:t,family:a},n)=>{if(0!==Yd.isIP(e))try{const r=Zd.parse(e).range();if(n.allowIPAddressList.length>0&&n.allowIPAddressList.includes(e))return;if(!n.allowMetaIPAddress&&"unspecified"===r)return new Error(`DNS lookup ${e}(family:${a}, host:${t}) is not allowed. Because, It is meta IP address.`);if(!n.allowPrivateIPAddress&&"unicast"!==r)return new Error(`DNS lookup ${e}(family:${a}, host:${t}) is not allowed. Because, It is private IP address.`);if(n.denyIPAddressList.length>0&&n.denyIPAddressList.includes(e))return new Error(`DNS lookup ${e}(family:${a}, host:${t}) is not allowed. Because It is defined in denyIPAddressList.`)}catch(e){return e}},nu=(e,t)=>(a,n,r)=>{const i=e.lookup||eu.lookup;let o;o=n.all?(e,n)=>{if(e)r(e);else{for(const{address:e,family:i}of n){const n=au({address:e,family:i,host:a},t);if(n)return void r(n)}r(null,n)}}:(e,n,i)=>{if(e)return void r(e);const o=au({address:n,family:i,host:a},t);o?r(o):r(null,n,i)},i(a,n,o)};class ru extends Xd.Agent{requestFilterOptions;constructor(e){super(e),this.requestFilterOptions={allowPrivateIPAddress:e&&void 0!==e.allowPrivateIPAddress?e.allowPrivateIPAddress:tu.allowPrivateIPAddress,allowMetaIPAddress:e&&void 0!==e.allowMetaIPAddress?e.allowMetaIPAddress:tu.allowMetaIPAddress,allowIPAddressList:e&&e.allowIPAddressList?e.allowIPAddressList:tu.allowIPAddressList,denyIPAddressList:e&&e.denyIPAddressList?e.denyIPAddressList:tu.denyIPAddressList}}createConnection(e,t){const{host:a}=e;if(void 0!==a){const e=au({address:a},this.requestFilterOptions);if(e)throw e}return super.createConnection({...e,lookup:nu(e,this.requestFilterOptions)},t)}}class iu extends Jd.Agent{requestFilterOptions;constructor(e){super(e),this.requestFilterOptions={allowPrivateIPAddress:!(!e||void 0===e.allowPrivateIPAddress)&&e.allowPrivateIPAddress,allowMetaIPAddress:!(!e||void 0===e.allowMetaIPAddress)&&e.allowMetaIPAddress,allowIPAddressList:e&&e.allowIPAddressList?e.allowIPAddressList:[],denyIPAddressList:e&&e.denyIPAddressList?e.denyIPAddressList:[]}}createConnection(e,t){const{host:a}=e;if(void 0!==a){const e=au({address:a},this.requestFilterOptions);if(e)throw e}return super.createConnection({...e,lookup:nu(e,this.requestFilterOptions)},t)}}const ou=new ru,su=new iu,pu=(e,t)=>t?e.startsWith("https")?new iu(t):new ru(t):e.startsWith("https")?su:ou;var lu=c(6123),du=c(211),uu=c(5907),cu=c(6502),mu=c.n(cu),fu=c(5838);function _u(){return _u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},_u.apply(this,arguments)}var hu={enum:1,type:0},Eu=/"/g,yu=/NOT/g,Tu=/\//g,Ru=function(e){var t=e.value,a=e.suggestions,n=e.format,r=void 0===n?function(e){return"Did you mean '"+e+"'?"}:n;if(!t)return"";var i=a.reduce(function(e,a){var n=mu()(t,a);return e.distance>n?{value:a,distance:n}:e},{distance:1/0,value:""});return i.distance<t.length?r(i.value):""},gu=function(e){return e.split("/").pop()},vu=function(e){var t=e.object,a=e.pnter,n=e.fallback;try{return fu.get(t,a)}catch(e){return n}},Ou=function(e){var t=e.errors,a=e.data,n=e.schema,r=e.basePath,i=void 0===r?"{base}":r;if(!Array.isArray(t)||0===t.length)return[];var o=function(e){var t=e.reduce(function(e,t){var a,n,r,i,o,s,p=t.instancePath+(null!=(a=null!=(n=null==(r=t.params)?void 0:r.additionalProperty)?n:null==(i=t.params)?void 0:i.missingProperty)?a:""),l=e[p];return l?((null!=(o=hu[t.keyword])?o:0)>(null!=(s=hu[l.keyword])?s:0)&&(e[p]=t),e):(e[p]=t,e)},{});return Object.values(t)}(t);return o.map(function(e){var t,r=(i+e.instancePath).replace(Tu,"."),o=gu(e.instancePath),s={errorType:e.keyword},p=(o?"property '"+o+"'":r)+" "+e.message.replace(Eu,"'").replace(yu,"not");switch(e.keyword){case"additionalProperties":var l=e.params.additionalProperty,d=e.schemaPath.replace("#","").replace("/additionalProperties",""),u=vu({object:n,pnter:d,fallback:{properties:{}}}).properties;t={message:"'"+l+"' property is not expected to be here",suggestion:Ru({value:l,suggestions:Object.keys(null!=u?u:{}),format:function(e){return"Did you mean property '"+e+"'?"}}),path:r,context:s};break;case"enum":var c=e.params.allowedValues.map(function(e){return e.toString()}),m=gu(e.instancePath),f=vu({object:a,pnter:e.instancePath,fallback:""});t={message:"'"+m+"' property must be equal to one of the allowed values",suggestion:Ru({value:f,suggestions:c}),path:r,context:_u({},s,{allowedValues:e.params.allowedValues})};break;case"type":t={message:"'"+gu(e.instancePath)+"' property type must be "+e.params.type,path:r,context:s};break;case"required":t={message:r+" must have required property '"+e.params.missingProperty+"'",path:r,context:s};break;case"const":return{message:"'"+o+"' property must be equal to the allowed value",path:r,context:_u({},s,{allowedValue:e.params.allowedValue})};default:return{message:p,path:r,context:s}}for(var _=0,h=Object.entries(t);_<h.length;_++){var E=h[_],y=E[0],T=E[1];null!=T&&""!==T||delete t[y]}return t})};const Nu=(e,t="Internal Logic Error")=>{if(!e)throw new Error("function"==typeof t?t():t)};class bu{constructor(e,t){this.value=e,this.excluded=t,this.isSimpleStarRec="**"===e,this.isRegexStarRec=e.startsWith("**(")&&e.endsWith(")"),this.isStarRec=this.isSimpleStarRec||this.isRegexStarRec}}class Au{constructor(e,t=null){this.left=null===t,this.link=null===t?new Au(e,this):t,this.type=e,this.isStarRec="**"===this.type,this.node=null,this.pointer=null}setPointer(e){this.pointer=e,this.link.pointer=e}setNode(e){this.node=e,this.link.node=e}}const Su=(e,t,a={})=>{throw new Error(Object.entries(a).reduce((e,[t,a])=>`${e}, ${t} ${a}`,`${e}: ${t}`))},Iu=e=>1===e.length?e[0]:e,wu=/^[?*+\d]+$/,Cu=(e,t,a={})=>{throw new Error(Object.entries(a).reduce((e,[t,a])=>`${e}, ${t} ${a}`,`${e}: ${t}`))},Du=(e,t)=>{if(""===e)return new bu("",!1);if(Array.isArray(e))return 0===e.length?new bu("",!1):e.map((a,n)=>"number"==typeof a?(t.useArraySelector||Cu("Forbidden Array Selector",JSON.stringify(e),{idx:n}),new bu(`[${a}]`,!1)):new bu(a.replaceAll("\\","\\\\"),!1));const a=(e=>{let t=[];t.or=!0;let a=!1,n=!1,r=0;const i=[],o=e=>{!0===t.excluded&&(Nu(!1===n),n=!0),i.push(t),t=[],t.or=e},s=()=>{const e=i.pop(),a=Iu(t);!0===e.or&&!0===a.or?e.push(...a):e.push(a),t=e};return o(!1),{setInArray:(t,n)=>{a===t&&Su(a?"Bad Array Start":"Bad Array Terminator",e,{char:n}),a=t},finishElement:(i,o,s,{finReq:p=!1,group:l=!1}={})=>{if(r===i)s.includes(e[i-1]||null)||Su(o,e,{char:i}),r+=1;else{p&&Su(o,e,{char:i});const s=e.slice(r,i);l&&!["**","++"].includes(s)&&Su("Bad Group Start",e,{char:i}),a&&!(wu.test(s)||s.startsWith("(")&&s.endsWith(")"))&&Su("Bad Array Selector",e,{selector:s}),l?t.push(new Au(s)):(t.push(new bu(a?`[${s}]`:s,n)),n=!1),r=i+1}},startExclusion:t=>{!1!==n&&Su("Redundant Exclusion",e,{char:t}),n=!0},startGroup:()=>{o(!0),n&&(t.excluded=!0,n=!1),o(!1)},newGroupElement:()=>{s(),o(!1)},finishGroup:a=>{i.length<2&&Su("Unexpected Group Terminator",e,{char:a}),s(),s(),Nu(Array.isArray(t));const n=t[t.length-2];n instanceof Au&&!0===n.left&&t.push(n.link)},finalizeResult:()=>(s(),Nu(!1===n),0!==i.length&&Su("Non Terminated Group",e),a&&Su("Non Terminated Array",e),Iu(t))}})(e),n=e.length;let r=!1,i=0;for(let o=0;o<n;o+=1){const n=e[o];if(!1===r){if(0===i)switch(n){case".":a.finishElement(o,"Bad Path Separator",["]","}"]);break;case"[":t.useArraySelector||Cu("Forbidden Array Selector",e,{char:o}),a.finishElement(o,"Bad Array Start",[null,"!","{",",","}","]"]),a.setInArray(!0,o);break;case"]":a.finishElement(o,"Bad Array Terminator",["}"]),a.setInArray(!1,o);break;case"{":a.finishElement(o,"Bad Group Start",[null,"!",".","[","{",","],{group:!0}),a.startGroup();break;case",":a.finishElement(o,"Bad Group Separator",["]","}"]),a.newGroupElement();break;case"}":a.finishElement(o,"Bad Group Terminator",["]","}"]),a.finishGroup(o);break;case"!":a.finishElement(o,"Bad Exclusion",[null,".",",","{","["],{finReq:!0}),a.startExclusion(o)}switch(n){case"(":i+=1;break;case")":0===i&&Cu("Unexpected Parentheses",e,{char:o}),i-=1}}r="\\"===n&&!r}return!1!==r&&Cu("Dangling Escape",e,{char:n-1}),0!==i&&Cu("Unterminated Parentheses",e),a.finishElement(n,"Bad Terminator",["]","}"]),a.finalizeResult()},Pu=(e,t,a,{onAdd:n,onFin:r})=>{const i=[[[e,null]]];let o=!1;((e,t)=>{const a=[e],n=[null],r=[],i=[];let o=0,s=!0;for(;-1!==o;){const e=a[o];Array.isArray(e)?!0!==e.or?(a.splice(o,1,...e),n.splice(o,1,...new Array(e.length).fill(n[o])),null!==n[o]&&(i[n[o]]+=e.length-1)):(void 0===r[o]?(r[o]=0,i[o]=0):0!==i[o]&&(a.splice(o+1,i[o]),n.splice(o+1,i[o]),i[o]=0),r[o]<e.length?(a.splice(o+1,0,e[r[o]]),n.splice(o+1,0,o),r[o]=(r[o]||0)+1,i[o]+=1,s=!0,o+=1):(r[o]=0,o-=1)):!0===s?(t("ADD",e),o===a.length-1?(t("FIN",e),s=!1):o+=1):(t("RM",e),o-=1)}})(a,(a,s)=>{if("RM"===a)!0===s.excluded&&(o=!1),i.length-=2;else if("ADD"===a){if(!0===s.excluded){if(o)throw new Error(`Redundant Exclusion: "${t}"`);o=!0}const e=[],a=i[i.length-2];i[i.length-1].forEach(([t,r])=>n(t,r,s,a,a=>e.push([a,t]))),i.push(s,e)}else i[i.length-1].filter(([t])=>t!==e).forEach(([e,t])=>r(e,t,s,o))})},ju=/[?!,.*+[\](){}\\]/g,ku=/^\^?[^-/\\^$*+?.()|[\]{}]*\$?$/g,Lu=e=>{if(ku.test(e)){const t=e.startsWith("^"),a=e.endsWith("$");if(t&&a){const t=e.slice(1,-1);return{test:e=>String(e)===t}}if(t){const t=e.slice(1);return{test:e=>String(e).startsWith(t)}}if(a){const t=e.slice(0,-1);return{test:e=>String(e).endsWith(t)}}return{test:t=>String(t).includes(e)}}try{return new RegExp(e)}catch(t){throw new Error(`Invalid Regex: "${e}"`)}},Mu=e=>e.reduce((e,t)=>`${e}${"number"==typeof t?`[${t}]`:`${e?".":""}${(e=>e.replace(ju,"\\$&"))(t)}`}`,""),Gu=e=>Array.isArray(e)?Mu(e):e,xu=["-","/","\\","^","$","*","+","?",".","(",")","|","[","]","{","}"],Fu=e=>{let t="",a=!1,n=!0;for(let r=0;r<e.length;r+=1){const i=e[r];a||"\\"!==i?a||"*"!==i?a||"+"!==i?a||"?"!==i?(xu.includes(i)&&(n=!1,t+="\\"),t+=i,a=!1):(n=!1,t+="."):(n=!1,t+=".+"):(n=!1,t+=".*"):a=!0}return n?{test:e=>String(e)===t}:".+"===t?{test:e=>""!==e}:new RegExp(`^${t}$`)};class Bu{constructor(e,t){if(t.nodes.push(this),this.value=e,this.ctx=t,this.order=t.counter,this.children=[],this.match=!1,this.matches=!1,this.needles=[],this.leafNeedles=[],this.leafNeedlesExclude=[],this.leafNeedlesMatch=[],this.isArrayTarget=e.startsWith("[")&&e.endsWith("]"),this.isSimpleStarRec="**"===e,this.isSimplePlusRec="++"===e,this.isSimpleRec=this.isSimpleStarRec||this.isSimplePlusRec,this.isRegexStarRec=e.startsWith("**(")&&e.endsWith(")"),this.isRegexPlusRec=e.startsWith("++(")&&e.endsWith(")"),this.isStarRec=this.isSimpleStarRec||this.isRegexStarRec,this.isPlusRec=this.isSimplePlusRec||this.isRegexPlusRec,this.isRec=this.isStarRec||this.isPlusRec,this.isAnyArrayTarget="[*]"===e,this.isAnyObjTarget="*"===e,this.isSimpleRec||this.isAnyObjTarget||this.isAnyArrayTarget)this.regex=null;else{const{regex:a}=t;e in a||(a[e]=(e=>(e.startsWith("**(")||e.startsWith("++("))&&e.endsWith(")")?Lu(e.slice(3,-1)):e.startsWith("[(")&&e.endsWith(")]")?Lu(e.slice(2,-2)):e.startsWith("(")&&e.endsWith(")")?Lu(e.slice(1,-1)):e.startsWith("[")&&e.endsWith("]")?Fu(e.slice(1,-1)):Fu(e))(e)),this.regex=a[e]}}recMatch(e){return!!this.isRec&&(!!this.isSimpleRec||this.regex.test(e))}typeMatch(e,t){return!!this.isSimpleRec||(this.isAnyArrayTarget?t:this.isAnyObjTarget?!t:!(t!==this.isArrayTarget&&!this.isRec)&&this.regex.test(e))}add(e){this.children.push(e)}get(e){return this.children.find(({value:t})=>t===e)}markMatches(){this.matches=!0}addNeedle(e){this.needles.includes(e)||this.needles.push(e)}setRoots(e){this.roots=e}finish(e,t,a){this.addNeedle(e),this.leafNeedles.includes(e)||this.leafNeedles.push(e);const n=t?this.leafNeedlesExclude:this.leafNeedlesMatch;n.includes(e)||n.push(e),this.match=!t,this.matches=this.match,this.index=a}}const zu=(e,t,a,n)=>{Pu(e,t,a,{onAdd:(e,a,r,i,o)=>{if(e.addNeedle(t),r instanceof Au)return void(!0===r.left?(r.isStarRec&&r.setPointer(e),r.setNode(new Bu("*",n)),n.links.push(e,r.node),o(r.node)):(r.target="target"in i?i.target:a.get(i.value),n.links.push(r.target,r.node),null!==r.pointer&&(o(r.pointer),r.setPointer(null)),o(e)));const s=r.isStarRec&&r.value===i?.value;if(s&&n.strict)throw new Error(`Redundant Recursion: "${t}"`);if(s)r.target=e;else{let t=e.get(r.value);void 0===t&&(t=new Bu(r.value,n),e.add(t)),o(t)}r.isStarRec&&o(e)},onFin:(e,a,r,i)=>{if(n.strict&&r.isSimpleStarRec){const e=a.children.filter(({value:e})=>!["","**"].includes(e));if(0!==e.length)throw new Error(`Needle Target Invalidated: "${e[0].needles[0]}" by "${t}"`)}if(n.strict&&0!==e.leafNeedles.length){const a=Gu(e.leafNeedles[0]),n=Gu(t);throw new Error(`Redundant Needle Target: "${a}" vs "${n}"`)}e.finish(t,i,n.counter),n.counter+=1}})},Vu=(e,t)=>{const a=[];for(let n=0,r=e.length;n<r;n+=1){const r=e[n][t];for(let e=0,t=r.length;e<t;e+=1){const t=r[e];a.includes(t)||a.push(t)}}return a},$u=e=>{let t=-1,a=!1,n=e.length;for(;n--;){const{index:r,match:i}=e[n];r>t&&(t=r,a=i)}return a},Uu=(e,t)=>t?Mu(e):[...e],Hu=(e,t,a)=>{const n={haystack:e,context:a.context};if(void 0!==a.beforeFn){const e=a.beforeFn(n);void 0!==e&&(n.haystack=e)}const r=[!1,[t],null,0],i=[],o=[];let s,p,l,d,u=n.haystack;const c={getKey:(e=a.joined)=>Uu(i,e),get key(){return c.getKey()},getValue:()=>u,get value(){return c.getValue()},getEntry:(e=a.joined)=>[Uu(i,e),u],get entry(){return c.getEntry()},getIsMatch:()=>d,get isMatch(){return c.getIsMatch()},getMatchedBy:()=>(e=>Vu(e,"leafNeedlesMatch"))(l),get matchedBy(){return c.getMatchedBy()},getExcludedBy:()=>(e=>Vu(e,"leafNeedlesExclude"))(l),get excludedBy(){return c.getExcludedBy()},getTraversedBy:()=>(e=>Vu(e,"needles"))(l),get traversedBy(){return c.getTraversedBy()},getGproperty:()=>i[i.length-2],get gproperty(){return c.getGproperty()},getProperty:()=>i[i.length-1],get property(){return c.getProperty()},getGparent:()=>o[o.length-2],get gparent(){return c.getGparent()},getParent:()=>o[o.length-1],get parent(){return c.getParent()},getParents:()=>[...o].reverse(),get parents(){return c.getParents()},getIsCircular:()=>o.includes(u),get isCircular(){return c.getIsCircular()},getIsLeaf:()=>!(u instanceof Object),get isLeaf(){return c.getIsLeaf()},getDepth:()=>i.length,get depth(){return c.getDepth()},get result(){return c.getResult()},context:n.context},m=((e,t)=>{if("context"===t.rtn)return{onMatch:()=>{},get:()=>e.context};if("bool"===t.rtn){let e=!1;return{onMatch:()=>{e=!0},get:()=>e}}if("count"===t.rtn){let e=0;return{onMatch:()=>{e+=1},get:()=>e}}if("sum"===t.rtn){let e=0;return{onMatch:({value:t})=>{e+=t},get:()=>e}}const a=[];return{onMatch:"function"==typeof t.rtn?()=>a.push(t.rtn(e)):Array.isArray(t.rtn)?()=>a.push(t.rtn.map(t=>e[t])):()=>a.push(e[t.rtn]),get:()=>t.abort?a[0]:a}})(c,a);if(c.getResult=()=>m.get(),a.useArraySelector||!Array.isArray(n.haystack)){const e=t.get("");void 0!==e&&r[1].push(e)}do{s=r.pop(),p=r.pop(),l=r.pop(),d=r.pop();const e=i.length-s;for(let t=0;t<e;t+=1)o.pop(),i.pop();if(-1===e?(o.push(u),i.push(p),u=u[p]):null!==p?(i[i.length-1]=p,u=o[o.length-1][p]):u=n.haystack,d){void 0!==a.filterFn&&!1===a.filterFn(c)||(m.onMatch(c),a.abort&&(r.length=0));continue}if(!l.some(({matches:e})=>e))continue;const f=!1===a.useArraySelector&&Array.isArray(u);if(!f&&$u(l)&&(r.push(!0,l,p,s),d=!0),(void 0===a.breakFn||!0!==a.breakFn(c))&&u instanceof Object){const e=Array.isArray(u),n=e?u.map((e,t)=>t).filter(()=>!0):Object.keys(u);!e&&a.compareFn&&n.sort(a.compareFn(c)),a.reverse||n.reverse();for(let i=0,o=n.length;i<o;i+=1){const o=n[i],p=[];if(f)p.push(...l),0===s&&p.push(...t.roots);else for(let t=0,a=l.length;t!==a;t+=1){const a=l[t];a.recMatch(o)&&p.push(a);const{children:n}=a;let r=n.length;for(;r--;){const t=n[r];t.typeMatch(o,e)&&p.push(t)}}if(a.orderByNeedles){p.index=Buffer.from(p.map(({order:e})=>e).sort());let e=r.length-3;const t=e-4*i;for(;e!==t&&1===Buffer.compare(p.index,r[e].index);)e-=4;r.splice(e+3,0,!1,p,o,s+1)}else r.push(!1,p,o,s+1)}}}while(0!==r.length);if(n.result=m.get(),void 0!==a.afterFn){const e=a.afterFn(n);void 0!==e&&(n.result=e)}return n.result},Ku=(e,t,a)=>{Nu(a.includes(typeof e[t]),()=>`Option "${t}" not one of [${a.join(", ")}]`)};var qu=du.ajv.getSchema("http://display.bricks.tools/root.schema.json5"),Wu=((e,t={})=>{if(Nu(Array.isArray(e),'Argument "needles" expected to be Array'),Nu(t instanceof Object&&!Array.isArray(t),'Argument "opts" expected to be Object'),0===e.length)return(e,t)=>void 0===t?[]:t;const a=(e=>{const t={filterFn:void 0,breakFn:void 0,beforeFn:void 0,afterFn:void 0,compareFn:void 0,reverse:!0,orderByNeedles:!1,abort:!1,rtn:void 0,joined:!1,useArraySelector:!0,strict:!0,...e};return Nu(12===Object.keys(t).length,"Unexpected Option provided"),Ku(t,"filterFn",["function","undefined"]),Ku(t,"breakFn",["function","undefined"]),Ku(t,"beforeFn",["function","undefined"]),Ku(t,"afterFn",["function","undefined"]),Ku(t,"compareFn",["function","undefined"]),Ku(t,"reverse",["boolean"]),Ku(t,"orderByNeedles",["boolean"]),Ku(t,"abort",["boolean"]),Nu("function"==typeof t.rtn&&1===t.rtn.length||[void 0,"context","key","value","entry","property","gproperty","parent","gparent","parents","isMatch","matchedBy","excludedBy","traversedBy","isCircular","isLeaf","depth","bool","count","sum"].includes(t.rtn)||Array.isArray(t.rtn)&&t.rtn.every(e=>["key","value","entry","property","gproperty","parent","gparent","parents","isMatch","matchedBy","excludedBy","traversedBy","isCircular","isLeaf","depth"].includes(e)),'Option "rtn" is malformed'),Ku(t,"joined",["boolean"]),Ku(t,"useArraySelector",["boolean"]),Ku(t,"strict",["boolean"]),t})(t),n=((e,t)=>{t.counter=0,t.links=[],t.nodes=[],t.regex=Object.create(null);const a=new Bu("*",t);for(let n=0;n<e.length;n+=1){const r=e[n],i=[Du(r,t)];zu(a,r,i,t)}return((e,t)=>{const{links:a}=t;for(;0!==a.length;){const e=a.pop(),t=a.pop(),{children:n}=t;t.children=[...e.children.filter(e=>!n.includes(e)),...n]}!1===t.useArraySelector&&e.setRoots(e.children.filter(({isStarRec:e,value:t})=>e||""===t));const{nodes:n}=t;for(;0!==n.length;){const e=n.pop(),{children:t}=e;t.reverse(),t.some(({matches:e})=>e)&&e.markMatches()}})(a,t),a})(e,a);return(e,t)=>Hu(e,n,{context:t,...a,rtn:a.rtn||(void 0===t?"key":"context")})})(["subspace_map.*.property_bank_calc_map.*.script_config"]);function Qu(e){var t=[];try{var a=du(e);t.push.apply(t,fe(Ou({errors:a,schema:qu,data:e}).map(function(e){return`${e.path}: ${e.message}`})));try{t.push.apply(t,fe(uu(e).map(function(e){return`${e.field}: ${e.message}`})))}catch(e){t.push(`Component reference validation failed: ${e.message}`)}return Wu(e).forEach(function(a){var n=a.slice(0,-1),r=lu(e,n),i=n.join(".");if(0===Object.keys(r.map).length)t.push(`${i}.map is empty`);else{var o=r.script_config,s=o.inputs,p=o.output,l=o.outputs,d=o.error;s&&Object.keys(s).forEach(function(e){r.map[e]||t.push(`${i}.map.${e} is missing`)}),p&&!r.map[p]&&t.push(`${i}.map.${p} is missing`),l&&Object.values(l).forEach(function(e){r.map[e]||t.push(`${i}.map.${e} is missing`)}),d&&!r.map[d]&&t.push(`${i}.map.${d} is missing`)}}),{valid:0===t.length,errors:t}}catch(e){return{valid:!1,errors:[`Validation failed: ${e.message}`]}}}var Yu=c(9741),Xu=c(3981),Ju=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-us";return"object"==typeof e&&null!==e?Object.fromEntries(Object.entries(e).map(function(e){var a,n=X(e,2),r=n[0],i=n[1];return[r,"object"!=typeof i||Array.isArray(i)?i:null!=(a=i[t])?a:Ju(i,t)]})):e},Zu=Ju(Yu.systemActionDescriptions),ec=Object.entries(Yu.systemActions).map(function(e){var t=X(e,2),a=t[0],n=t[1],r=n.propertyNameType,i=n.property;return` - \`${a}\`: ${Zu[a]}\n${function(e,t){switch(e){case"defined_properties":return Object.entries(t).map(function(e){var t=X(e,2),a=t[0],n=t[1];return` - \`${a}\`: ${JSON.stringify(n)}`}).join("\n");case"property_bank":return" - `PROPERTY_BANK_DATA_NODE_*`: Value";default:return""}}(r,i)}\n`.trim()}).join("\n"),tc=Object.keys(Xu.brickMapping).map(function(e){return`- \`${e}\``}).join("\n"),ac=Object.keys(Xu.generatorMapping).map(function(e){return`- \`${e}\``}).join("\n");const nc=Hd.replace("[:SYSTEM_ACTIONS:]",ec).replace("[:BRICK_IDS:]",tc).replace("[:GENERATOR_IDS:]",ac);var rc=function(e,t){var a;return!t||(null==(a=e.tokenInfo.permissions)?void 0:a.includes(t))||!1},ic=c(4668),oc=c(5018),sc=c(3315),pc=c(409),lc=c(8525),dc=c(9760),uc=c(6078),cc=c(9222),mc=c(5608),fc=c(9074),_c=c(3673);var hc=c(4370);const Ec=hc.default`
658
658
  fragment workspaceArguments on Workspace {
659
659
  __typename
660
660
  _id
@@ -2735,7 +2735,7 @@ import{createRequire as e}from"node:module";const t=e(import.meta.url);import*as
2735
2735
  createdAt
2736
2736
  updatedAt
2737
2737
  }
2738
- `,x_=e=>{const t=function({endpointURL:e,subscriptionEndpointURL:t,accessToken:a,boxId:n,passcode:r,origin:i,enableSubscription:o,enableRetry:s=!0,subscriptionOnConnectionOrError:p,onNetworkError:l=()=>{}}){const d=n&&r,u={};i&&(u.origin=i),d||(u.authorization=`Bearer ${a}`);const c=new u_({uri:e,headers:u});let m,f,_,h;const E=()=>{h&&(clearTimeout(h),h=void 0)};o&&(m=N_({url:t,lazy:!0,connectionParams:u,retryAttempts:1/0,shouldRetry:()=>!0,keepAlive:1e4,on:{error:e=>{E(),p?.(e)},opened:e=>{p?.(),_=e,E()},ping:e=>{e||(E(),h=setTimeout(()=>{_&&_.readyState===WebSocket.OPEN&&_.close(4205,"Client Restart")},5e3))},pong:e=>{e&&E()},closed:()=>{E()}}}),f=new f_(m));const y=fc.C.from([S_(({networkError:e,operation:t})=>{e&&l(e,t)}),s&&new Xf,new(w_())(3e4),o?fc.C.split(({query:e})=>{const{kind:t,operation:a}=j_(e);return"OperationDefinition"===t&&"subscription"===a},f,c):c].filter(Boolean));return y.closeSubscriptionClient=()=>o&&m.close(!0,!0),y}(e),a=new cc.D,n=new uc.R({link:t,cache:a,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"ignore"},query:{fetchPolicy:"no-cache",errorPolicy:"all"}}});return n.close=()=>t.closeSubscriptionClient(),n},F_=hc.default`
2738
+ `,x_=e=>{const t=function({endpointURL:e,subscriptionEndpointURL:t,accessToken:a,boxId:n,passcode:r,origin:i,enableSubscription:o,enableRetry:s=!0,subscriptionOnConnectionOrError:p,onNetworkError:l=()=>{}}){const d=n&&r,u={};i&&(u.origin=i),d||(u.authorization=`Bearer ${a}`);const c=new u_({uri:e,headers:u});let m,f,_,h;const E=()=>{h&&(clearTimeout(h),h=void 0)};o&&(m=N_({url:t,lazy:!0,connectionParams:u,retryAttempts:1/0,shouldRetry:()=>!0,keepAlive:1e4,on:{error:e=>{E(),p?.(e)},opened:e=>{p?.(),_=e,E()},ping:e=>{e||(E(),h=setTimeout(()=>{_&&_.readyState===WebSocket.OPEN&&_.close(4205,"Client Restart")},5e3))},pong:e=>{e&&E()},closed:()=>{E()}}}),f=new f_(m));const y=fc.C.from([S_(({networkError:e,operation:t})=>{e&&l(e,t)}),s&&new Xf({attempts:{max:3,retryIf:e=>{const t="string"==typeof e?.message?e.message:"string"==typeof e?e:"";return!!e&&!t.includes("Too many requests")&&429!==e?.response?.status&&403!==e?.statusCode&&403!==e?.status&&!e?.timeout&&"Timeout exceeded"!==t&&"Aborted"!==t&&"AbortError"!==e?.name}}}),new(w_())(3e4),o?fc.C.split(({query:e})=>{const{kind:t,operation:a}=j_(e);return"OperationDefinition"===t&&"subscription"===a},f,c):c].filter(Boolean));return y.closeSubscriptionClient=()=>o&&m.close(!0,!0),y}(e),a=new cc.D,n=new uc.R({link:t,cache:a,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"ignore"},query:{fetchPolicy:"no-cache",errorPolicy:"all"}}});return n.close=()=>t.closeSubscriptionClient(),n},F_=hc.default`
2739
2739
  query MediaClient_workspaces {
2740
2740
  mediaWorkspaces {
2741
2741
  ...mediaWorkspaceArguments
@@ -3066,4 +3066,4 @@ import{createRequire as e}from"node:module";const t=e(import.meta.url);import*as
3066
3066
  }
3067
3067
  }
3068
3068
  ${M_}
3069
- `,ch={query:"query",mutation:"mutate"},mh=(e,t,a)=>([n,r])=>{if(e[n])throw new Error(`Overwriting client.${n}`);e[n]=async(i,o={})=>{let s,p;const l={[t]:r,variables:i,...o};if(a&&(l.variables={...a,...l.variables}),o.readQuery?s=e.readQuery(l):o.writeQuery?e.writeQuery({...l,data:o.writeQuery}):({data:s,errors:p}=await e[ch[t]](l)),p)throw new Error(p.map(e=>e.message).join("\n"));return s?s[n]:null}},fh=e=>{const t=(({endpoint:e="http://localhost:3002",accessToken:t,boxId:a,passcode:n,enableSubscription:r=!0,enableRetry:i=!0,subscriptionOnConnectionOrError:o,onNetworkError:s}={})=>{const p=a&&n;let l=`${e}/api/graphql`;return p&&(l=`${e}/api/graphql_with_passcode`),x_({endpointURL:l,subscriptionEndpointURL:l.replace("http:","ws:"),accessToken:t,enableSubscription:!p&&r,enableRetry:i,subscriptionOnConnectionOrError:o,onNetworkError:s})})(e);if(e.boxId&&e.passcode){t.type="passcode",t.queries=g,t.mutations=v;const a={boxId:e.boxId,passcode:e.passcode};Object.entries(g).forEach(mh(t,"query",a)),Object.entries(v).forEach(mh(t,"mutation",a)),t.listenBoxChanged=(e,n)=>t.subscribe({query:uh,variables:{...a,...e}}).subscribe({next:async({data:e})=>{await n(null,e.mediaBoxChanged)},error(e){n(e)}})}else t.accessToken=e.accessToken,t.type="token",t.queries=T,t.mutations=R,Object.entries(T).forEach(mh(t,"query")),Object.entries(R).forEach(mh(t,"mutation")),t.listenBoxChanged=(e,a)=>t.subscribe({query:nh,variables:e}).subscribe({next:async({data:e})=>{await a(null,e.mediaBoxChanged)},error(e){a(e)}});return t};function _h(e,t,a){switch(a){case"user":return new pf(e,t);case"workspace":return new Wf(e,t);default:throw new Error(`Invalid token type: ${a}.`)}}process.env.STAGE,process.env.URL_BASE;var hh="bricks-mcp",Eh={bricks:process.env.BRICKS_API_SERVER||"https://display-beta.bricks.tools",media:process.env.MEDIA_API_SERVER||"https://media-beta.bricks.tools"},yh=(process.env.AUTH0_DOMAIN,process.env.CACHE_URL,c(1639));const Th=function(e){var t,a,n=e.type,r=e.title,i=e.template_key,o=(0,yh.makeId)(n);switch(n){case"subspace":t={title:r,layout:{width:"number",height:"number"},root_canvas_id:"CANVAS_<UUID>",canvas_map:{},brick_map:{},animation_map:{},generator_map:{},property_bank_map:{},property_bank_calc_map:{}},a={"canvas_map.CANVAS_<UUID>.item_list":[{type:"subspace",subspace_id:"SUBSPACE_<UUID>",$note:"If not a root subspace, it can be linked to canvas in other subspace"}]};break;case"canvas":var s=Ju(Xu.canvas);t={title:r,item_list:[],property:{$definitions:Object.fromEntries(Object.entries(s.propTypes).map(function(e){var t=X(e,2),a=t[0],n=t[1];return[a,Object.assign({},n,{description:s.brickPropDescriptions[a]})]}))},event_map:{$definitions:Object.fromEntries(Object.entries(s.eventTypes).map(function(e){var t=X(e,1)[0];return[t,{description:s.brickEventDescriptions[t]}]}))}},a={property_bank_map:Wd({},(0,yh.makeId)("property_bank"),{title:`Canvas ID: ${r}`,type:"string",value:o,routing:"read-only",kind:"auto-generated-item-id",idType:"canvas"})};break;case"brick":var p=Ju(Xu.components.Basic),l=Ju(Xu.brickMapping[i]);if(!l)throw new Error(`Brick ${i} not found`);var d=Object.assign({},l,{propTypes:Object.assign({},p.propTypes,l.propTypes),brickPropDescriptions:Object.assign({},p.brickPropDescriptions,l.brickPropDescriptions),eventTypes:Object.assign({},p.eventTypes,l.eventTypes),brickEventDescriptions:Object.assign({},p.brickEventDescriptions,l.brickEventDescriptions)});t={title:r,template_key:i,property:{$definitions:Object.fromEntries(Object.entries(d.propTypes).map(function(e){var t=X(e,2),a=t[0],n=t[1];return[a,Object.assign({},n,{description:d.brickPropDescriptions[a]})]}))},event_map:{$definitions:Object.fromEntries(Object.entries(d.eventTypes).map(function(e){var t=X(e,1)[0];return[t,{description:d.brickEventDescriptions[t]}]}))},outlet:{$definitions:Object.fromEntries(Object.entries(d.outletTypes).map(function(e){var t=X(e,1)[0];return[t,{description:d.brickOutletDescriptions[t]}]}))},state_group:{"BRICK_STATE_GROUP_<UUID>":{}}},a={canvas_map:{"CANVAS_<UUID WHICH NEED DISPLAY THIS BRICK>":{item_list:[{type:"brick",brick_id:o,frame:{x:"number",y:"number",width:"number",height:"number",standby_mode:"custom|top|left|right|bottom",standby_delay:"number",standby_easing:{default:{method:"ease",duration:"number"}}}}]}}};break;case"state_group":t={title:r,description:"State Group Description",conds:[{type:"property_bank|inner_state",key:"PROPERTY_BANK#<Data Node ID>|[current_canvas|BRICK_<OUTLET NAME>]|",method:"==|!=|>|>=|<|<=",value:"value_to_compare"}],override:{property:!1,event:!1,outlet:!1},commented:!1,break:!1,property:{},outlet:{},animation:{}};case"generator":var u=Ju(Xu.generatorMapping[i]);if(!u)throw new Error(`Generator ${i} not found`);t={title:r,template_key:i,property:{$definitions:Object.fromEntries(Object.entries(u.propTypes).map(function(e){var t=X(e,2),a=t[0],n=t[1];return[a,Object.assign({},n,{description:u.brickPropDescriptions[a]})]}))},event_map:{$definitions:Object.fromEntries(Object.entries(u.eventTypes).map(function(e){var t=X(e,1)[0];return[t,{description:u.brickEventDescriptions[t]}]}))},outlet:{$definitions:Object.fromEntries(Object.entries(u.outletTypes).map(function(e){var t=X(e,1)[0];return[t,{description:u.brickOutletDescriptions[t]}]}))}};break;case"animation":t={title:r,type:"timing|decay|spring",property:"opacity|transform.translateX|transform.scale|etc",config:{$note:"Config for the animation"},compose_type:"parallel|sequence",item_list:[{animation_id:"ANIMATION_<SUB ANIMATION UUID>"}]};break;case"property_bank":t={title:r,description:"Property Bank Description",linkedFrom:"SUBSPACE_<UUID WHICH IS CROSS SUBSPACE>",type:"string|number|bool|object|array|any",kind:"color|datetime|id|media-resource-*|lottie-file-uri",unit:"grid|px|ms",routing:"read-only|default",value:"fit-to-type",event_map:{$note:`Available events: ${Object.keys(Xu.propertyBank.eventTypes).join(", ")}`},local_sync:{update_mode:"all|main-only|minor-only|dont-sync"},$remote_update_additional:{$note:"Configure remote update behavior",enable_remote_update:!0,bank_type:"create|create-device-specific"}};break;case"property_bank_command":break;case"property_bank_calc":var c=(0,yh.makeId)("property_bank_command"),m=(0,yh.makeId)("property_bank_command"),f=(0,yh.makeId)("property_bank_command"),_="const { arg_name } = inputs;\n\nreturn { arg_name };";t={title:r,map:Wd(Wd(Wd(Wd(Wd(Wd({$note:"Required, actual implementation","PROPERTY_BANK_DATA_NODE_<UUID>":{type:"data-node",properties:{},in:{change:null},out:{value:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID>",port:"value"}]},$note:"Use this to input data to the sandbox"},"PROPERTY_BANK_COMMAND_NODE_<UUID FIRST>":{type:"command-node-object",title:"Command: OBJECT_SET",properties:{command:"OBJECT_SET",args:{path:"arg_name"}},in:{obj:null,path:null,value:[{id:"PROPERTY_BANK_DATA_NODE_<UUID>",port:"value"}]},out:{result:[{id:`PROPERTY_BANK_COMMAND_NODE_<UUID NEXT> | ${c}`,port:"obj | inputs"}]}},"PROPERTY_BANK_COMMAND_NODE_<UUID SECOND>":{type:"command-node-object",title:"Command: OBJECT_SET",properties:{command:"OBJECT_SET",args:{path:"arg_name"}},in:{obj:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID PREVIOUS>",port:"result"}],path:null,value:[{id:"PROPERTY_BANK_DATA_NODE_<UUID SECOND>",port:"value"}]},out:{result:[{id:`PROPERTY_BANK_COMMAND_NODE_<UUID NEXT> | ${c}`,port:"obj | inputs"}]}}},c,{type:"command-node-sandbox",title:"Command: SANDBOX_RUN_JAVASCRIPT",properties:{command:"SANDBOX_RUN_JAVASCRIPT",args:{code:_,enable_async:!1}},in:{code:null,inputs:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID FINAL>",port:"result"}]},out:{result:[{id:f,port:"result"},{id:m,port:"result"}]}}),f,{type:"command-node-sandbox",title:"Command: SANDBOX_GET_ERROR",properties:{command:"SANDBOX_GET_ERROR"},in:{result:[{id:c,port:"result"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE ERROR>",port:"change"}],$note:"Set `result` as null if there is no error"}}),m,{type:"command-node-sandbox",title:"Command: SANDBOX_GET_RETURN_VALUE",properties:{command:"SANDBOX_GET_RETURN_VALUE"},in:{result:[{id:c,port:"result"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT> | PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT> | null",port:"change"}]}}),"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT>",{type:"data-node",properties:{},in:{change:[{id:m,port:"result"}]},out:{value:null},$note:"Put full result into data node"}),"PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT>",{type:"command-node-object",title:"Command: OBJECT_GET",properties:{command:"OBJECT_GET",args:{path:"obj_key"}},in:{obj:[{id:m,port:"obj"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>",port:"change"}]},$note:"Parse result object into data node"}),"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>",{type:"data-node",properties:{},in:{change:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT>",port:"result"}]},out:{value:null},$note:"Put partial result into data node"}),editor_info:{},type:"script",script_config:{title:r,enable_async:!1,inputs:{"PROPERTY_BANK_DATA_NODE_<UUID>":"arg_name"},disabled_triggers:{},error:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE ERROR> | null",output:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT> | null",outputs:{obj_key:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>"},code:_,$note:"Required, info for GUI editor"}}}return qd({id:o,example:t,extraInfo:a})};function Rh(e,t){var a,n,r,i,o,s,p,l,d,u,c,m,f,_,h,E,y,T,R,g="user"===t.tokenType,v=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(a,n){var r=a.name,i=a.description,o=a.inputSchema,s=a.permission;rc(t,s)&&e.tool(r,i,o,n)}}(e,t),N=function(e){return Object.assign({},e,g?{workspace_id:Jt().describe("Workspace ID")}:{})},b=t.client,A=g?function(e){var t=e.endpoint,a=e.accessToken;if(!t)throw new Error("Media API endpoint is required");if(!a)throw new Error("Access token is required");return fh({endpoint:t,accessToken:a,enableSubscription:!1,enableRetry:!0})}({endpoint:Eh.media,accessToken:t.token}):b;g&&e.tool("list_workspaces","List all workspaces",{},O(function*(){return qd(yield b.workspaces())})),v({name:"get_workspace_overview",description:"Get comprehensive overview of the BRICKS workspace including stats and summary",inputSchema:N({}),permission:"info"},function(){var e=O(function*(e){var t,a,n,r,i,o=e.workspace_id,s=yield Promise.all([b.workspace({id:o}),b.applications({workspaceId:o,paginate:{limit:50,offset:0}}),b.modules({workspaceId:o,paginate:{limit:50,offset:0}}),b.devices({workspaceId:o,paginate:{limit:50,offset:0}}),g?A.mediaWorkspace({workspaceId:o}).catch(function(){return null}):A.mediaWorkspace().catch(function(){return null}),g?A.mediaBoxes({workspaceId:o}).catch(function(){return[]}):A.mediaBoxes().catch(function(){return[]})]),p=X(s,6),l=p[0],d=p[1],u=p[2],c=p[3],m=p[4],f=p[5];if(!l)throw new Error("Authentication failed, please check your token");return qd({workspace:l,stats:{applications:null!=(t=null==d?void 0:d.length)?t:"No permission",modules:null!=(a=null==u?void 0:u.length)?a:"No permission",devices:null!=(n=null==c?void 0:c.length)?n:"No permission",running_apps:null!=(r=null==d?void 0:d.filter(function(e){var t;return null==(t=e.status)?void 0:t.running}).length)?r:"No permission",media_boxes:null!=(i=null==f?void 0:f.length)?i:"No permission",media_enabled:!!m,notes:"Note: The stats are based on the first 50 applications, modules, and devices in the workspace."},recent_activity:{latest_apps:(null==d?void 0:d.slice(0,5).map(function(e){var t;return{id:e._id,name:e.name,status:null!=(t=e.status)&&t.running?"running":"stopped",last_update:e.last_modify_datetime}}))||[]},media_info:m?{workspace_id:m.id,name:m.name,size_used:m.size,size_limit:m.sizeLimit,boxes:(null==f?void 0:f.slice(0,5).map(function(e){return{id:e.id,name:e.name,size:e.size,description:e.description}}))||[]}:{enabled:!1,note:"Media workspace is not enabled for this workspace"}})});return function(t){return e.apply(this,arguments)}}()),v({name:"get_applications",description:"List all applications in the workspace",inputSchema:N({limit:Zt().describe("Maximum number of applications to return").optional().default(50),offset:Zt().describe("Number of applications to skip").optional().default(0)}),permission:"query_application"},function(){var e=O(function*(e){var t=e.workspace_id,a=e.limit,n=void 0===a?50:a,r=e.offset,i=void 0===r?0:r;return qd(yield b.applications({workspaceId:t,paginate:{limit:n,offset:i}}))});return function(t){return e.apply(this,arguments)}}()),v({name:"get_application",description:"Get detailed info and config of a specific application",inputSchema:N({id:Jt().describe("Application ID")}),permission:"query_application"},function(){var e=O(function*(e){var t=e.workspace_id,a=e.id;return qd(yield b.application({workspaceId:t,id:a}))});return function(t){return e.apply(this,arguments)}}()),v({name:"get_modules",description:"List all modules in the workspace",inputSchema:N({limit:Zt().describe("Maximum number of modules to return").optional().default(50),offset:Zt().describe("Number of modules to skip").optional().default(0)}),permission:"query_module"},function(){var e=O(function*(e){var t=e.workspace_id,a=e.limit,n=void 0===a?50:a,r=e.offset,i=void 0===r?0:r;return qd(yield b.modules({workspaceId:t,paginate:{limit:n,offset:i}}))});return function(t){return e.apply(this,arguments)}}()),v({name:"get_module",description:"Get detailed info and config of a specific module",inputSchema:N({id:Jt().describe("Module ID")}),permission:"query_module"},function(){var e=O(function*(e){var t=e.workspace_id,a=e.id;return qd(yield b.module({workspaceId:t,id:a}))});return function(t){return e.apply(this,arguments)}}()),v({name:"update_module_info",description:"Update a specific module info",inputSchema:N({id:Jt().describe("Module ID"),name:Jt().describe("Module name"),description:Jt().describe("Module description")}),permission:"update_module"},(a=O(function*(e){var t=e.workspace_id,a=e.id,n=e.name,r=e.description;return qd(yield b.updateModule({workspaceId:t,id:a,name:n,description:r}))}),function(e){return a.apply(this,arguments)})),v({name:"update_module_config",description:"Update a specific module configuration",inputSchema:N({id:Jt().describe("Module ID"),config:ta({}).passthrough().describe("New configuration object, see file://docs/config-schema.md for schema reference")}),permission:"update_module"},(n=O(function*(e){var t=e.workspace_id,a=e.id,n=e.config,r=yield Qu(n);if(!r.valid)throw new Error(`Config validation failed: ${r.errors.join(", ")}`);return qd(yield b.updateModule({workspaceId:t,id:a,config:JSON.stringify(n),validateConfig:!0}))}),function(e){return n.apply(this,arguments)})),v({name:"get_devices",description:"List all devices in the workspace",inputSchema:N({limit:Zt().describe("Maximum number of devices to return").optional().default(50),offset:Zt().describe("Number of devices to skip").optional().default(0)}),permission:"query_device"},(r=O(function*(e){var t=e.workspace_id,a=e.limit,n=void 0===a?50:a,r=e.offset,i=void 0===r?0:r;return qd(yield b.devices({workspaceId:t,paginate:{limit:n,offset:i}}))}),function(e){return r.apply(this,arguments)})),v({name:"create_application",description:"Create a new BRICKS application with default grid layout",inputSchema:N({name:Jt().describe("Application name"),description:Jt().describe("Application description").optional(),grid_width:Zt().describe("Grid width in units").optional().default(96),grid_height:Zt().describe("Grid height in units").optional().default(54)}),permission:"create_application"},(i=O(function*(e){var t=e.workspace_id,a=e.name,n=e.description,r=e.grid_width,i=e.grid_height;return qd(yield b.createApplication({workspaceId:t,name:a,description:n,gridWidth:r,gridHeight:i}))}),function(e){return i.apply(this,arguments)})),v({name:"update_application_info",description:"Update application info",inputSchema:{id:Jt().describe("Application ID"),name:Jt().describe("Application name"),description:Jt().describe("Application description")},permission:"update_application"},(o=O(function*(e){var t=e.id,a=e.name,n=e.description;return qd(yield b.updateApplication({id:t,name:a,description:n}))}),function(e){return o.apply(this,arguments)})),v({name:"update_application_config",description:"Update application configuration with validation",inputSchema:{id:Jt().describe("Application ID"),config:ta({}).passthrough().describe("New application configuration. Please read `getting-started` for BRICKS concepts before changing")},permission:"update_application"},(s=O(function*(e){var t=e.id,a=e.config,n=yield Qu(a);if(!n.valid)throw new Error(`Config validation failed: ${n.errors.join(", ")}`);return qd(yield b.updateApplication({id:t,config:JSON.stringify(a)}))}),function(e){return s.apply(this,arguments)})),v({name:"bind_application",description:"Bind application to device with viewport configuration",inputSchema:{app_id:Jt().describe("Application ID"),viewports:ea(ta({device_id:Jt().describe("Device ID"),x:Zt().describe("X coordinate"),y:Zt().describe("Y coordinate"),width:Zt().describe("Width"),height:Zt().describe("Height"),rotate:Zt().describe("Rotation"),rotateType:Jt().describe("Rotation type")})).describe("Viewport configuration")},permission:"bind_application"},(p=O(function*(e){var t=e.app_id,a=e.viewports;return qd(yield b.bindApplication({id:t,bind_devices:a.map(function(e){return e.device_id}),device_frames:a.reduce(function(e,t){return Object.assign({},e,Wd({},t.device_id,{x:t.x,y:t.y,width:t.width,height:t.height,rotate:t.rotate,rotateType:t.rotateType}))},{})}))}),function(e){return p.apply(this,arguments)})),v({name:"unbind_application",description:"Unbind application from device",inputSchema:{app_id:Jt().describe("Application ID"),device_id:Jt().describe("Device ID")},permission:"bind_application"},(l=O(function*(e){var t=e.app_id,a=e.device_id;return qd(yield b.bindApplication({id:t,unbindDevices:[a]}))}),function(e){return l.apply(this,arguments)})),g&&v({name:"list_media_workspaces",description:"List all media workspaces",inputSchema:{},permission:"query_media_flow"},O(function*(){return qd(yield A.mediaWorkspaces())})),v({name:"get_media_workspace",description:"Get media workspace information and status",inputSchema:N({}),permission:"query_media_flow"},(d=O(function*(e){var t=e.workspace_id;return qd(yield A.mediaWorkspace({workspaceId:t}))}),function(e){return d.apply(this,arguments)})),v({name:"list_media_boxes",description:"List all media boxes in the workspace",inputSchema:N({}),permission:"query_media_flow"},(u=O(function*(e){var t=e.workspace_id;return qd(yield A.mediaBoxes({workspaceId:t}))}),function(e){return u.apply(this,arguments)})),v({name:"get_media_box",description:"Get detailed information about a specific media box",inputSchema:{box_id:Jt().describe("Media box ID")},permission:"query_media_flow"},(c=O(function*(e){var t=e.box_id;return qd(yield A.mediaBox({boxId:t}))}),function(e){return c.apply(this,arguments)})),v({name:"list_media_files",description:"List media files in a specific box with filtering options",inputSchema:{box_id:Jt().describe("Media box ID"),include_types:ea(Jt()).optional().describe('Filter by file types (e.g., ["image", "video", "audio"])'),user_tags:ea(Jt()).optional().describe("Filter by user tags"),limit:Zt().optional().default(50).describe("Maximum number of files to return"),offset:Zt().optional().default(0).describe("Number of files to skip")},permission:"query_media_flow"},(m=O(function*(e){var t=e.box_id,a=e.include_types,n=e.user_tags,r=e.limit,i=e.offset;return qd(yield A.mediaFiles({boxId:t,includeTypes:a,userTags:n,limit:r,offset:i}))}),function(e){return m.apply(this,arguments)})),v({name:"get_media_file_meta",description:"Get detailed information about a specific media file",inputSchema:{file_id:Jt().describe("Media file ID")},permission:"query_media_flow"},(f=O(function*(e){var t=e.file_id;return qd(yield A.mediaFile({fileId:t}))}),function(e){return f.apply(this,arguments)})),v({name:"media_box_upload",description:"Upload a file to a media box from URL or base64 data",inputSchema:{box_id:Jt().describe("Target media box ID"),name:Jt().describe("File name"),description:Jt().optional().default("").describe("File description"),file_type:aa(["image","video","audio","file"]).describe("File type"),source_url:Jt().optional().describe("URL to download the file from"),base64_data:Jt().optional().describe("Base64 encoded file data"),user_tags:ea(Jt()).optional().default([]).describe("User-defined tags for the file")},permission:"write_media_flow"},(_=O(function*(e){var t=e.box_id,a=e.name,n=e.description,r=e.source_url,i=e.base64_data,o=e.file_type,s=e.user_tags;if(!r&&!i)throw new Error("Either source_url or base64_data must be provided");if(r&&i)throw new Error("Provide either source_url OR base64_data, not both");var p=r?null:"application/octet-stream",l=r?yield(0,Qd.Ay)(r,{agent:pu(r)}).then(function(e){return p=e.headers.get("content-type"),e.blob()}):new Blob([Kd.Buffer.from(i,"base64")],{type:p}),d=yield A.requestFileUpload({name:a,description:n,boxId:t,fileType:g?o.toUpperCase():o,contentType:p,userTags:s,meta:{}}),u=JSON.parse(null==d?void 0:d.meta.uploadInfo),c=new FormData;c.append("file",l),c.append("Content-Type",p),c.append("AWSAccessKeyId",u.AWSAccessKeyId),c.append("Signature",u.Signature),c.append("Policy",u.Policy),c.append("acl",u.acl),c.append("key",u.key);var m=yield(0,Qd.Ay)(u.url,{method:"POST",body:c}).then(function(e){return e.ok}).catch(function(){return!1});return qd({file_id:d.id,upload_success:m,upload_info:{content_type:p,file_type:o,source_type:r?"url":"base64",processing_note:"File will be processed automatically. Use get_media_file to check processing status."}})}),function(e){return _.apply(this,arguments)})),v({name:"update_media_file_meta",description:"Update media file information",inputSchema:{file_id:Jt().describe("Media file ID"),name:Jt().optional().describe("New file name"),description:Jt().optional().describe("New file description"),user_tags:ea(Jt()).optional().describe("New user tags")},permission:"write_media_flow"},(h=O(function*(e){var t=e.file_id,a=e.name,n=e.description,r=e.user_tags;return qd(yield A.updateMediaFile({fileId:t,name:a,description:n,userTags:r,requestUploadAgain:!1}))}),function(e){return h.apply(this,arguments)})),v({name:"copy_media_files",description:"Copy media files from one box to another",inputSchema:{from_box_id:Jt().describe("Source media box ID"),to_box_id:Jt().describe("Target media box ID"),file_ids:ea(Jt()).describe("Array of media file IDs to copy")},permission:"write_media_flow"},(E=O(function*(e){var t=e.from_box_id,a=e.to_box_id,n=e.file_ids;return qd(yield A.copyMediaFiles({fromBoxId:t,toBoxId:a,list:n}))}),function(e){return E.apply(this,arguments)})),v({name:"delete_media_files",description:"Delete specific media files from a box",inputSchema:{box_id:Jt().describe("Media box ID"),file_ids:ea(Jt()).describe("Array of media file IDs to delete")},permission:"write_media_flow"},(y=O(function*(e){var t=e.box_id,a=e.file_ids;return qd(yield A.deleteMediaFiles({boxId:t,list:a}))}),function(e){return y.apply(this,arguments)})),v({name:"cleanup_media_box",description:"Delete all files in a media box, optionally filtered by type",inputSchema:{box_id:Jt().describe("Media box ID"),include_types:ea(Jt()).optional().describe('Only delete files of these types (e.g., ["image", "video"])')},permission:"write_media_flow"},(T=O(function*(e){var t=e.box_id,a=e.include_types;if("deleteMediaBoxFiles"in A)return qd(yield A.deleteMediaBoxFiles({boxId:t,includeTypes:a}));var n=yield A.mediaFiles({boxId:t,includeTypes:a});return qd(yield A.deleteMediaFiles({boxId:t,list:n.map(function(e){return e.id})}))}),function(e){return T.apply(this,arguments)})),e.tool("calculate_grid_layout","Calculate grid layout and pixel conversions for different device resolutions",{device_width:Zt().describe("Device width in pixels"),device_height:Zt().describe("Device height in pixels"),app_grid_width:Zt().describe("Application grid width").optional().default(96),app_grid_height:Zt().describe("Application grid height").optional().default(54)},(R=O(function*(e){var t,a,n=e.device_width,r=e.device_height,i=e.app_grid_width,o=e.app_grid_height,s={deviceBrickWidth:(t=n)/(a=t/i),deviceBrickHeight:r/a,deviceBrickUnit:a},p=function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:96,n=e/a;return t>e&&(n=t/a),{deviceBrickWidth:Math.round(e/n),deviceBrickHeight:Math.round(t/n),deviceBrickUnit:n}}(n,r,i);return qd({device_resolution:{width:n,height:r,aspect_ratio:(n/r).toFixed(2)},current_grid:{width:i,height:o,unit_size_px:s.deviceBrickUnit.toFixed(2),total_pixels:{width:s.deviceBrickWidth.toFixed(2),height:s.deviceBrickHeight.toFixed(2)}},recommended_grid:{width:p.deviceBrickWidth,height:p.deviceBrickHeight,unit_size_px:p.deviceBrickUnit.toFixed(2),note:"Optimized for device aspect ratio"}})}),function(e){return R.apply(this,arguments)})),e.tool("create_item","Use this tool to create new item that you can put in application configuration",{type:aa(["subspace","canvas","brick","generator","property_bank","property_bank_calc","property_bank_command","animation","state_group","automation_map"]).describe("Item type"),title:Jt().describe("Item title"),template_key:Jt().optional().describe("Template key for brick or generator")},Th),e.tool("getting_started","Get documentation content for getting started",{},O(function*(){return qd(nc)}))}var gh="2.24.0-beta.4";function vh(){return vh=O(function*(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).token||process.env.BRICKS_API_TOKEN;if(!e)throw console.error("Error: API token is required"),console.error("Please provide a token via options or set BRICKS_API_TOKEN environment variable"),new Error("API token is required");var t=Ud({queryStringParameters:{token:e}});if(!t.success)throw console.error("Error: Invalid BRICKS_API_TOKEN"),console.error(t.message),new Error("Invalid BRICKS_API_TOKEN");var a,n=new Id({name:hh,version:gh}),r=Object.assign({},t,{client:_h(Eh.bricks,t.token,t.tokenType)});(a=n).prompt("getting-started","Getting started with BRICKS",{},O(function*(){return{messages:[{role:"user",content:{type:"text",text:'Welcome to BRICKS — start here.\n\nBefore doing any complex work (application design, deployments, etc.),\nalways consult the official docs rather than guessing.\n\nIMPORTANT: BRICKS users interact through a GUI editor, not raw config files.\nNever show users JSON config details, schema fields, or technical implementation.\nFocus on user-friendly descriptions of what the app will do and how it will look.\n\nGolden rules for working with BRICKS:\n1) Read before you act\n - Open these resources first, then proceed:\n - `getting-started` — overview & architecture\n - `config-schema` — canonical schema for apps, subspaces, bricks, generators, etc.\n - `components-index` — available bricks/generators\n2) Source of truth\n - Rely on the docs above; do not invent fields not present in the schema\n3) No guessing\n - If names, constraints, or device details are missing, ask to fetch them first\n4) Plan then execute\n - Propose a clear step-by-step plan and wait for approval before writing or mutating data\n5) User-friendly communication\n - Describe features in terms of what users see and do, not technical config\n - Use visual/functional language: "text display", "button", "screen transition"\n - Avoid exposing JSON, IDs, or schema details to end users\n\nBRICKS essentials:\n- Applications: interactive digital signage experiences\n- Devices: deployment targets (screens/players)\n- Modules: Reusable module across applications\n- Grid system: default 96×54; 1 unit = device_width/96 (e.g., 20px at 1920×1080)\n- Key primitives: Subspaces, Canvas, Bricks, Generators, Property Banks (Data)\n\nQuick actions:\n- "Create a new application" → use the `create-application` prompt\n- "Deploy an application to a device" → use the `deploy-to-device` prompt\n\nTry asking:\n- "Draft a plan to create an app with a text display and deploy it; ask any missing questions first"'}}]}})),a.prompt("create-application","Create a new BRICKS application with guided setup",{app_name:Jt().describe("Name for the new application"),description:Jt().describe("Short description for the new application").optional()},function(){var e=O(function*(e){var t=(null==e?void 0:e.app_name)||"New Application",a=(null==e?void 0:e.description)||"";return{messages:[{role:"user",content:{type:"text",text:`Help me create a new BRICKS application called "${t}".\n\n${a?`Goal: ${a}`:""}\n\nIMPORTANT: Users see a visual GUI editor, not raw config. Describe features in user-friendly terms:\n- "text display" not "BRICK_TEXT"\n- "image" not "BRICK_IMAGE"\n- "canvas name" not "CANVAS_xxx"\n- "data storage" not "PROPERTY_BANK"\n- Focus on what users see and do, not technical implementation\n\nHow we'll proceed (no guessing, schema-first):\n1) Confirm intent\n - Restate objectives and success criteria in 1–3 bullets\n2) Consult docs (as needed)\n - getting-started, config-schema, components-index\n - Ensure proposed fields exist in the schema\n3) Ask missing questions before changes\n - Target device(s) and resolution(s)\n - Layout needs (pages/screens), content types, data sources\n - Localization, scheduling, or interaction needs\n4) Propose a minimal viable design (After confirming intent)\n - App structure: screens → visual elements\n - Initial component selection with rationale\n - Grid usage: default 96×54 (≈20px at 1920×1080)\n5) Produce a schema-valid skeleton (no side effects yet)\n - Include only fields defined by config-schema\n - Use clear placeholders for text/assets/URLs/ids\n\nWhat I'll produce first:\n- Short recap of requirements\n- Clarifying questions (only what's necessary)\n- High-level architecture plan\n- Minimal config skeleton that validates against the schema`}}]}});return function(t){return e.apply(this,arguments)}}()),function(e){e.resource("getting-started-docs","file://docs/getting-started.md",{mimeType:"text/markdown",title:"Getting Started with BRICKS",description:"Comprehensive guide to BRICKS architecture, concepts, and development workflow"},O(function*(){return qd(Hd,{uri:"file://docs/getting-started.md",mimeType:"text/markdown"})}))}(n),Rh(n,r);var i=new Fd;try{yield n.connect(i),console.error("BRICKS MCP Server running on STDIO"),console.error(`Server: ${hh} v${gh}`),console.error(`Token Type: ${t.tokenType}`),console.error(`Permissions: ${t.tokenInfo.permissions.join(", ")}`),console.error("Ready to accept requests...")}catch(e){throw console.error("Failed to start MCP server:",e),e}}),vh.apply(this,arguments)}var Oh=new P("mcp").description("MCP server management");Oh.command("start").description("Start the BRICKS MCP server in STDIO mode").option("-t, --token <token>","API token (overrides saved token)").action(function(){var e=O(function*(e){var t=(0,V.getCurrentProfile)(),a=e.token||(0,V.getToken)(t);a||(console.error(M.Ay.red("Error: No API token found.")),console.error(M.Ay.gray("Please login first with: bricks auth login <passcode>")),console.error(M.Ay.gray("Or provide a token with: bricks mcp start --token <token>")),process.exit(1));try{yield function(){return vh.apply(this,arguments)}({token:a})}catch(e){console.error(M.Ay.red(`Failed to start MCP server: ${e.message}`)),process.exit(1)}});return function(t){return e.apply(this,arguments)}}());var Nh=function(){var e=O(function*(){if(b.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.24.0-beta.4").enablePositionalOptions(),b.addCommand(U),b.addCommand(te),b.addCommand(se),b.addCommand(le),b.addCommand(me),b.addCommand(Ee),b.addCommand(ve),b.addCommand(Oh),b.command("interactive").alias("i").description("Start interactive mode with Ink UI").action(O(function*(){try{(0,(yield c.e(612).then(c.bind(c,9612))).runInteractiveMode)()}catch(e){console.error(M.Ay.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}})),b.command("workspace").alias("ws").description("Show current workspace information").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e){var t=yield Promise.resolve().then(c.bind(c,8765)),a=t.getToken,n=t.getBaseUrl,r=t.getCurrentProfile,i=(yield Promise.resolve().then(c.bind(c,7742))).createClient,o=(yield Promise.resolve().then(c.bind(c,9790))).default,s=a(r());s||(console.error(M.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var p=o("Fetching workspace info...").start();try{var l,d,u=i(n(),s),m=yield u.workspace();if(p.stop(),e.json)return void console.log(JSON.stringify(m,null,2));console.log(M.Ay.bold("\nWorkspace Information")),console.log("─".repeat(60)),console.log(`Name: ${M.Ay.green(m.name)}`),console.log(`ID: ${M.Ay.gray(m._id)}`),console.log(`Description: ${m.description||M.Ay.gray("N/A")}`),console.log(`\n${M.Ay.bold("Data")}`),console.log(`Remote Update: ${null!=(l=m.bank)&&l.enable_remote_update?M.Ay.green("Enabled"):M.Ay.gray("Disabled")}`),console.log(`Spacename: ${(null==(d=m.bank)?void 0:d.spacename)||M.Ay.gray("N/A")}`),console.log("─".repeat(60))}catch(e){p.fail(`Failed to get workspace: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),b.on("--help",function(){console.log(""),console.log(M.Ay.bold("Examples:")),console.log(""),console.log(M.Ay.gray(" # Login with a one-time passcode (recommended)")),console.log(" $ bricks auth login <passcode>"),console.log(""),console.log(M.Ay.gray(" # List all devices")),console.log(" $ bricks device list"),console.log(""),console.log(M.Ay.gray(" # Monitor devices in real-time")),console.log(" $ bricks device monitor"),console.log(""),console.log(M.Ay.gray(" # Control a device")),console.log(" $ bricks device refresh <device-id>"),console.log(" $ bricks device control <device-id> clear-cache"),console.log(""),console.log(M.Ay.gray(" # Bind a new device")),console.log(' $ bricks device bind <passcode> -n "My Device"'),console.log(""),console.log(M.Ay.gray(" # List applications")),console.log(" $ bricks app list"),console.log(""),console.log(M.Ay.gray(" # Start interactive mode")),console.log(" $ bricks interactive"),console.log(""),console.log(M.Ay.gray(" # Change API endpoint")),console.log(" $ bricks config endpoint beta"),console.log(""),console.log(M.Ay.gray("Get workspace token from BRICKS Controller:")),console.log(M.Ay.cyan(" https://control.bricks.tools")),console.log(M.Ay.gray(" Go to Workspace Settings > API Token"))}),0===process.argv.slice(2).length)try{return void(0,(yield c.e(612).then(c.bind(c,9612))).runInteractiveMode)()}catch(e){console.error(M.Ay.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}yield b.parseAsync(process.argv)});return function(){return e.apply(this,arguments)}}();const bh=Nh;export{bh as default,Nh as run};
3069
+ `,ch={query:"query",mutation:"mutate"},mh=(e,t,a)=>([n,r])=>{if(e[n])throw new Error(`Overwriting client.${n}`);e[n]=async(i,o={})=>{let s,p;const l={[t]:r,variables:i,...o};if(a&&(l.variables={...a,...l.variables}),o.readQuery?s=e.readQuery(l):o.writeQuery?e.writeQuery({...l,data:o.writeQuery}):({data:s,errors:p}=await e[ch[t]](l)),p)throw new Error(p.map(e=>e.message).join("\n"));return s?s[n]:null}},fh=e=>{const t=(({endpoint:e="http://localhost:3002",accessToken:t,boxId:a,passcode:n,enableSubscription:r=!0,enableRetry:i=!0,subscriptionOnConnectionOrError:o,onNetworkError:s}={})=>{const p=a&&n;let l=`${e}/api/graphql`;return p&&(l=`${e}/api/graphql_with_passcode`),x_({endpointURL:l,subscriptionEndpointURL:l.replace("http:","ws:"),accessToken:t,enableSubscription:!p&&r,enableRetry:i,subscriptionOnConnectionOrError:o,onNetworkError:s})})(e);if(e.boxId&&e.passcode){t.type="passcode",t.queries=g,t.mutations=v;const a={boxId:e.boxId,passcode:e.passcode};Object.entries(g).forEach(mh(t,"query",a)),Object.entries(v).forEach(mh(t,"mutation",a)),t.listenBoxChanged=(e,n)=>t.subscribe({query:uh,variables:{...a,...e}}).subscribe({next:async({data:e})=>{await n(null,e.mediaBoxChanged)},error(e){n(e)}})}else t.accessToken=e.accessToken,t.type="token",t.queries=T,t.mutations=R,Object.entries(T).forEach(mh(t,"query")),Object.entries(R).forEach(mh(t,"mutation")),t.listenBoxChanged=(e,a)=>t.subscribe({query:nh,variables:e}).subscribe({next:async({data:e})=>{await a(null,e.mediaBoxChanged)},error(e){a(e)}});return t};function _h(e,t,a){switch(a){case"user":return new pf(e,t);case"workspace":return new Wf(e,t);default:throw new Error(`Invalid token type: ${a}.`)}}process.env.STAGE,process.env.URL_BASE;var hh="bricks-mcp",Eh={bricks:process.env.BRICKS_API_SERVER||"https://display-beta.bricks.tools",media:process.env.MEDIA_API_SERVER||"https://media-beta.bricks.tools"},yh=(process.env.AUTH0_DOMAIN,process.env.CACHE_URL,c(1639));const Th=function(e){var t,a,n=e.type,r=e.title,i=e.template_key,o=(0,yh.makeId)(n);switch(n){case"subspace":t={title:r,layout:{width:"number",height:"number"},root_canvas_id:"CANVAS_<UUID>",canvas_map:{},brick_map:{},animation_map:{},generator_map:{},property_bank_map:{},property_bank_calc_map:{}},a={"canvas_map.CANVAS_<UUID>.item_list":[{type:"subspace",subspace_id:"SUBSPACE_<UUID>",$note:"If not a root subspace, it can be linked to canvas in other subspace"}]};break;case"canvas":var s=Ju(Xu.canvas);t={title:r,item_list:[],property:{$definitions:Object.fromEntries(Object.entries(s.propTypes).map(function(e){var t=X(e,2),a=t[0],n=t[1];return[a,Object.assign({},n,{description:s.brickPropDescriptions[a]})]}))},event_map:{$definitions:Object.fromEntries(Object.entries(s.eventTypes).map(function(e){var t=X(e,1)[0];return[t,{description:s.brickEventDescriptions[t]}]}))}},a={property_bank_map:Wd({},(0,yh.makeId)("property_bank"),{title:`Canvas ID: ${r}`,type:"string",value:o,routing:"read-only",kind:"auto-generated-item-id",idType:"canvas"})};break;case"brick":var p=Ju(Xu.components.Basic),l=Ju(Xu.brickMapping[i]);if(!l)throw new Error(`Brick ${i} not found`);var d=Object.assign({},l,{propTypes:Object.assign({},p.propTypes,l.propTypes),brickPropDescriptions:Object.assign({},p.brickPropDescriptions,l.brickPropDescriptions),eventTypes:Object.assign({},p.eventTypes,l.eventTypes),brickEventDescriptions:Object.assign({},p.brickEventDescriptions,l.brickEventDescriptions)});t={title:r,template_key:i,property:{$definitions:Object.fromEntries(Object.entries(d.propTypes).map(function(e){var t=X(e,2),a=t[0],n=t[1];return[a,Object.assign({},n,{description:d.brickPropDescriptions[a]})]}))},event_map:{$definitions:Object.fromEntries(Object.entries(d.eventTypes).map(function(e){var t=X(e,1)[0];return[t,{description:d.brickEventDescriptions[t]}]}))},outlet:{$definitions:Object.fromEntries(Object.entries(d.outletTypes).map(function(e){var t=X(e,1)[0];return[t,{description:d.brickOutletDescriptions[t]}]}))},state_group:{"BRICK_STATE_GROUP_<UUID>":{}}},a={canvas_map:{"CANVAS_<UUID WHICH NEED DISPLAY THIS BRICK>":{item_list:[{type:"brick",brick_id:o,frame:{x:"number",y:"number",width:"number",height:"number",standby_mode:"custom|top|left|right|bottom",standby_delay:"number",standby_easing:{default:{method:"ease",duration:"number"}}}}]}}};break;case"state_group":t={title:r,description:"State Group Description",conds:[{type:"property_bank|inner_state",key:"PROPERTY_BANK#<Data Node ID>|[current_canvas|BRICK_<OUTLET NAME>]|",method:"==|!=|>|>=|<|<=",value:"value_to_compare"}],override:{property:!1,event:!1,outlet:!1},commented:!1,break:!1,property:{},outlet:{},animation:{}};case"generator":var u=Ju(Xu.generatorMapping[i]);if(!u)throw new Error(`Generator ${i} not found`);t={title:r,template_key:i,property:{$definitions:Object.fromEntries(Object.entries(u.propTypes).map(function(e){var t=X(e,2),a=t[0],n=t[1];return[a,Object.assign({},n,{description:u.brickPropDescriptions[a]})]}))},event_map:{$definitions:Object.fromEntries(Object.entries(u.eventTypes).map(function(e){var t=X(e,1)[0];return[t,{description:u.brickEventDescriptions[t]}]}))},outlet:{$definitions:Object.fromEntries(Object.entries(u.outletTypes).map(function(e){var t=X(e,1)[0];return[t,{description:u.brickOutletDescriptions[t]}]}))}};break;case"animation":t={title:r,type:"timing|decay|spring",property:"opacity|transform.translateX|transform.scale|etc",config:{$note:"Config for the animation"},compose_type:"parallel|sequence",item_list:[{animation_id:"ANIMATION_<SUB ANIMATION UUID>"}]};break;case"property_bank":t={title:r,description:"Property Bank Description",linkedFrom:"SUBSPACE_<UUID WHICH IS CROSS SUBSPACE>",type:"string|number|bool|object|array|any",kind:"color|datetime|id|media-resource-*|lottie-file-uri",unit:"grid|px|ms",routing:"read-only|default",value:"fit-to-type",event_map:{$note:`Available events: ${Object.keys(Xu.propertyBank.eventTypes).join(", ")}`},local_sync:{update_mode:"all|main-only|minor-only|dont-sync"},$remote_update_additional:{$note:"Configure remote update behavior",enable_remote_update:!0,bank_type:"create|create-device-specific"}};break;case"property_bank_command":break;case"property_bank_calc":var c=(0,yh.makeId)("property_bank_command"),m=(0,yh.makeId)("property_bank_command"),f=(0,yh.makeId)("property_bank_command"),_="const { arg_name } = inputs;\n\nreturn { arg_name };";t={title:r,map:Wd(Wd(Wd(Wd(Wd(Wd({$note:"Required, actual implementation","PROPERTY_BANK_DATA_NODE_<UUID>":{type:"data-node",properties:{},in:{change:null},out:{value:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID>",port:"value"}]},$note:"Use this to input data to the sandbox"},"PROPERTY_BANK_COMMAND_NODE_<UUID FIRST>":{type:"command-node-object",title:"Command: OBJECT_SET",properties:{command:"OBJECT_SET",args:{path:"arg_name"}},in:{obj:null,path:null,value:[{id:"PROPERTY_BANK_DATA_NODE_<UUID>",port:"value"}]},out:{result:[{id:`PROPERTY_BANK_COMMAND_NODE_<UUID NEXT> | ${c}`,port:"obj | inputs"}]}},"PROPERTY_BANK_COMMAND_NODE_<UUID SECOND>":{type:"command-node-object",title:"Command: OBJECT_SET",properties:{command:"OBJECT_SET",args:{path:"arg_name"}},in:{obj:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID PREVIOUS>",port:"result"}],path:null,value:[{id:"PROPERTY_BANK_DATA_NODE_<UUID SECOND>",port:"value"}]},out:{result:[{id:`PROPERTY_BANK_COMMAND_NODE_<UUID NEXT> | ${c}`,port:"obj | inputs"}]}}},c,{type:"command-node-sandbox",title:"Command: SANDBOX_RUN_JAVASCRIPT",properties:{command:"SANDBOX_RUN_JAVASCRIPT",args:{code:_,enable_async:!1}},in:{code:null,inputs:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID FINAL>",port:"result"}]},out:{result:[{id:f,port:"result"},{id:m,port:"result"}]}}),f,{type:"command-node-sandbox",title:"Command: SANDBOX_GET_ERROR",properties:{command:"SANDBOX_GET_ERROR"},in:{result:[{id:c,port:"result"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE ERROR>",port:"change"}],$note:"Set `result` as null if there is no error"}}),m,{type:"command-node-sandbox",title:"Command: SANDBOX_GET_RETURN_VALUE",properties:{command:"SANDBOX_GET_RETURN_VALUE"},in:{result:[{id:c,port:"result"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT> | PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT> | null",port:"change"}]}}),"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT>",{type:"data-node",properties:{},in:{change:[{id:m,port:"result"}]},out:{value:null},$note:"Put full result into data node"}),"PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT>",{type:"command-node-object",title:"Command: OBJECT_GET",properties:{command:"OBJECT_GET",args:{path:"obj_key"}},in:{obj:[{id:m,port:"obj"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>",port:"change"}]},$note:"Parse result object into data node"}),"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>",{type:"data-node",properties:{},in:{change:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT>",port:"result"}]},out:{value:null},$note:"Put partial result into data node"}),editor_info:{},type:"script",script_config:{title:r,enable_async:!1,inputs:{"PROPERTY_BANK_DATA_NODE_<UUID>":"arg_name"},disabled_triggers:{},error:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE ERROR> | null",output:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT> | null",outputs:{obj_key:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>"},code:_,$note:"Required, info for GUI editor"}}}return qd({id:o,example:t,extraInfo:a})};function Rh(e,t){var a,n,r,i,o,s,p,l,d,u,c,m,f,_,h,E,y,T,R,g="user"===t.tokenType,v=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(a,n){var r=a.name,i=a.description,o=a.inputSchema,s=a.permission;rc(t,s)&&e.tool(r,i,o,n)}}(e,t),N=function(e){return Object.assign({},e,g?{workspace_id:Jt().describe("Workspace ID")}:{})},b=t.client,A=g?function(e){var t=e.endpoint,a=e.accessToken;if(!t)throw new Error("Media API endpoint is required");if(!a)throw new Error("Access token is required");return fh({endpoint:t,accessToken:a,enableSubscription:!1,enableRetry:!0})}({endpoint:Eh.media,accessToken:t.token}):b;g&&e.tool("list_workspaces","List all workspaces",{},O(function*(){return qd(yield b.workspaces())})),v({name:"get_workspace_overview",description:"Get comprehensive overview of the BRICKS workspace including stats and summary",inputSchema:N({}),permission:"info"},function(){var e=O(function*(e){var t,a,n,r,i,o=e.workspace_id,s=yield Promise.all([b.workspace({id:o}),b.applications({workspaceId:o,paginate:{limit:50,offset:0}}),b.modules({workspaceId:o,paginate:{limit:50,offset:0}}),b.devices({workspaceId:o,paginate:{limit:50,offset:0}}),g?A.mediaWorkspace({workspaceId:o}).catch(function(){return null}):A.mediaWorkspace().catch(function(){return null}),g?A.mediaBoxes({workspaceId:o}).catch(function(){return[]}):A.mediaBoxes().catch(function(){return[]})]),p=X(s,6),l=p[0],d=p[1],u=p[2],c=p[3],m=p[4],f=p[5];if(!l)throw new Error("Authentication failed, please check your token");return qd({workspace:l,stats:{applications:null!=(t=null==d?void 0:d.length)?t:"No permission",modules:null!=(a=null==u?void 0:u.length)?a:"No permission",devices:null!=(n=null==c?void 0:c.length)?n:"No permission",running_apps:null!=(r=null==d?void 0:d.filter(function(e){var t;return null==(t=e.status)?void 0:t.running}).length)?r:"No permission",media_boxes:null!=(i=null==f?void 0:f.length)?i:"No permission",media_enabled:!!m,notes:"Note: The stats are based on the first 50 applications, modules, and devices in the workspace."},recent_activity:{latest_apps:(null==d?void 0:d.slice(0,5).map(function(e){var t;return{id:e._id,name:e.name,status:null!=(t=e.status)&&t.running?"running":"stopped",last_update:e.last_modify_datetime}}))||[]},media_info:m?{workspace_id:m.id,name:m.name,size_used:m.size,size_limit:m.sizeLimit,boxes:(null==f?void 0:f.slice(0,5).map(function(e){return{id:e.id,name:e.name,size:e.size,description:e.description}}))||[]}:{enabled:!1,note:"Media workspace is not enabled for this workspace"}})});return function(t){return e.apply(this,arguments)}}()),v({name:"get_applications",description:"List all applications in the workspace",inputSchema:N({limit:Zt().describe("Maximum number of applications to return").optional().default(50),offset:Zt().describe("Number of applications to skip").optional().default(0)}),permission:"query_application"},function(){var e=O(function*(e){var t=e.workspace_id,a=e.limit,n=void 0===a?50:a,r=e.offset,i=void 0===r?0:r;return qd(yield b.applications({workspaceId:t,paginate:{limit:n,offset:i}}))});return function(t){return e.apply(this,arguments)}}()),v({name:"get_application",description:"Get detailed info and config of a specific application",inputSchema:N({id:Jt().describe("Application ID")}),permission:"query_application"},function(){var e=O(function*(e){var t=e.workspace_id,a=e.id;return qd(yield b.application({workspaceId:t,id:a}))});return function(t){return e.apply(this,arguments)}}()),v({name:"get_modules",description:"List all modules in the workspace",inputSchema:N({limit:Zt().describe("Maximum number of modules to return").optional().default(50),offset:Zt().describe("Number of modules to skip").optional().default(0)}),permission:"query_module"},function(){var e=O(function*(e){var t=e.workspace_id,a=e.limit,n=void 0===a?50:a,r=e.offset,i=void 0===r?0:r;return qd(yield b.modules({workspaceId:t,paginate:{limit:n,offset:i}}))});return function(t){return e.apply(this,arguments)}}()),v({name:"get_module",description:"Get detailed info and config of a specific module",inputSchema:N({id:Jt().describe("Module ID")}),permission:"query_module"},function(){var e=O(function*(e){var t=e.workspace_id,a=e.id;return qd(yield b.module({workspaceId:t,id:a}))});return function(t){return e.apply(this,arguments)}}()),v({name:"update_module_info",description:"Update a specific module info",inputSchema:N({id:Jt().describe("Module ID"),name:Jt().describe("Module name"),description:Jt().describe("Module description")}),permission:"update_module"},(a=O(function*(e){var t=e.workspace_id,a=e.id,n=e.name,r=e.description;return qd(yield b.updateModule({workspaceId:t,id:a,name:n,description:r}))}),function(e){return a.apply(this,arguments)})),v({name:"update_module_config",description:"Update a specific module configuration",inputSchema:N({id:Jt().describe("Module ID"),config:ta({}).passthrough().describe("New configuration object, see file://docs/config-schema.md for schema reference")}),permission:"update_module"},(n=O(function*(e){var t=e.workspace_id,a=e.id,n=e.config,r=yield Qu(n);if(!r.valid)throw new Error(`Config validation failed: ${r.errors.join(", ")}`);return qd(yield b.updateModule({workspaceId:t,id:a,config:JSON.stringify(n),validateConfig:!0}))}),function(e){return n.apply(this,arguments)})),v({name:"get_devices",description:"List all devices in the workspace",inputSchema:N({limit:Zt().describe("Maximum number of devices to return").optional().default(50),offset:Zt().describe("Number of devices to skip").optional().default(0)}),permission:"query_device"},(r=O(function*(e){var t=e.workspace_id,a=e.limit,n=void 0===a?50:a,r=e.offset,i=void 0===r?0:r;return qd(yield b.devices({workspaceId:t,paginate:{limit:n,offset:i}}))}),function(e){return r.apply(this,arguments)})),v({name:"create_application",description:"Create a new BRICKS application with default grid layout",inputSchema:N({name:Jt().describe("Application name"),description:Jt().describe("Application description").optional(),grid_width:Zt().describe("Grid width in units").optional().default(96),grid_height:Zt().describe("Grid height in units").optional().default(54)}),permission:"create_application"},(i=O(function*(e){var t=e.workspace_id,a=e.name,n=e.description,r=e.grid_width,i=e.grid_height;return qd(yield b.createApplication({workspaceId:t,name:a,description:n,gridWidth:r,gridHeight:i}))}),function(e){return i.apply(this,arguments)})),v({name:"update_application_info",description:"Update application info",inputSchema:{id:Jt().describe("Application ID"),name:Jt().describe("Application name"),description:Jt().describe("Application description")},permission:"update_application"},(o=O(function*(e){var t=e.id,a=e.name,n=e.description;return qd(yield b.updateApplication({id:t,name:a,description:n}))}),function(e){return o.apply(this,arguments)})),v({name:"update_application_config",description:"Update application configuration with validation",inputSchema:{id:Jt().describe("Application ID"),config:ta({}).passthrough().describe("New application configuration. Please read `getting-started` for BRICKS concepts before changing")},permission:"update_application"},(s=O(function*(e){var t=e.id,a=e.config,n=yield Qu(a);if(!n.valid)throw new Error(`Config validation failed: ${n.errors.join(", ")}`);return qd(yield b.updateApplication({id:t,config:JSON.stringify(a)}))}),function(e){return s.apply(this,arguments)})),v({name:"bind_application",description:"Bind application to device with viewport configuration",inputSchema:{app_id:Jt().describe("Application ID"),viewports:ea(ta({device_id:Jt().describe("Device ID"),x:Zt().describe("X coordinate"),y:Zt().describe("Y coordinate"),width:Zt().describe("Width"),height:Zt().describe("Height"),rotate:Zt().describe("Rotation"),rotateType:Jt().describe("Rotation type")})).describe("Viewport configuration")},permission:"bind_application"},(p=O(function*(e){var t=e.app_id,a=e.viewports;return qd(yield b.bindApplication({id:t,bind_devices:a.map(function(e){return e.device_id}),device_frames:a.reduce(function(e,t){return Object.assign({},e,Wd({},t.device_id,{x:t.x,y:t.y,width:t.width,height:t.height,rotate:t.rotate,rotateType:t.rotateType}))},{})}))}),function(e){return p.apply(this,arguments)})),v({name:"unbind_application",description:"Unbind application from device",inputSchema:{app_id:Jt().describe("Application ID"),device_id:Jt().describe("Device ID")},permission:"bind_application"},(l=O(function*(e){var t=e.app_id,a=e.device_id;return qd(yield b.bindApplication({id:t,unbindDevices:[a]}))}),function(e){return l.apply(this,arguments)})),g&&v({name:"list_media_workspaces",description:"List all media workspaces",inputSchema:{},permission:"query_media_flow"},O(function*(){return qd(yield A.mediaWorkspaces())})),v({name:"get_media_workspace",description:"Get media workspace information and status",inputSchema:N({}),permission:"query_media_flow"},(d=O(function*(e){var t=e.workspace_id;return qd(yield A.mediaWorkspace({workspaceId:t}))}),function(e){return d.apply(this,arguments)})),v({name:"list_media_boxes",description:"List all media boxes in the workspace",inputSchema:N({}),permission:"query_media_flow"},(u=O(function*(e){var t=e.workspace_id;return qd(yield A.mediaBoxes({workspaceId:t}))}),function(e){return u.apply(this,arguments)})),v({name:"get_media_box",description:"Get detailed information about a specific media box",inputSchema:{box_id:Jt().describe("Media box ID")},permission:"query_media_flow"},(c=O(function*(e){var t=e.box_id;return qd(yield A.mediaBox({boxId:t}))}),function(e){return c.apply(this,arguments)})),v({name:"list_media_files",description:"List media files in a specific box with filtering options",inputSchema:{box_id:Jt().describe("Media box ID"),include_types:ea(Jt()).optional().describe('Filter by file types (e.g., ["image", "video", "audio"])'),user_tags:ea(Jt()).optional().describe("Filter by user tags"),limit:Zt().optional().default(50).describe("Maximum number of files to return"),offset:Zt().optional().default(0).describe("Number of files to skip")},permission:"query_media_flow"},(m=O(function*(e){var t=e.box_id,a=e.include_types,n=e.user_tags,r=e.limit,i=e.offset;return qd(yield A.mediaFiles({boxId:t,includeTypes:a,userTags:n,limit:r,offset:i}))}),function(e){return m.apply(this,arguments)})),v({name:"get_media_file_meta",description:"Get detailed information about a specific media file",inputSchema:{file_id:Jt().describe("Media file ID")},permission:"query_media_flow"},(f=O(function*(e){var t=e.file_id;return qd(yield A.mediaFile({fileId:t}))}),function(e){return f.apply(this,arguments)})),v({name:"media_box_upload",description:"Upload a file to a media box from URL or base64 data",inputSchema:{box_id:Jt().describe("Target media box ID"),name:Jt().describe("File name"),description:Jt().optional().default("").describe("File description"),file_type:aa(["image","video","audio","file"]).describe("File type"),source_url:Jt().optional().describe("URL to download the file from"),base64_data:Jt().optional().describe("Base64 encoded file data"),user_tags:ea(Jt()).optional().default([]).describe("User-defined tags for the file")},permission:"write_media_flow"},(_=O(function*(e){var t=e.box_id,a=e.name,n=e.description,r=e.source_url,i=e.base64_data,o=e.file_type,s=e.user_tags;if(!r&&!i)throw new Error("Either source_url or base64_data must be provided");if(r&&i)throw new Error("Provide either source_url OR base64_data, not both");var p=r?null:"application/octet-stream",l=r?yield(0,Qd.Ay)(r,{agent:pu(r)}).then(function(e){return p=e.headers.get("content-type"),e.blob()}):new Blob([Kd.Buffer.from(i,"base64")],{type:p}),d=yield A.requestFileUpload({name:a,description:n,boxId:t,fileType:g?o.toUpperCase():o,contentType:p,userTags:s,meta:{}}),u=JSON.parse(null==d?void 0:d.meta.uploadInfo),c=new FormData;c.append("file",l),c.append("Content-Type",p),c.append("AWSAccessKeyId",u.AWSAccessKeyId),c.append("Signature",u.Signature),c.append("Policy",u.Policy),c.append("acl",u.acl),c.append("key",u.key);var m=yield(0,Qd.Ay)(u.url,{method:"POST",body:c}).then(function(e){return e.ok}).catch(function(){return!1});return qd({file_id:d.id,upload_success:m,upload_info:{content_type:p,file_type:o,source_type:r?"url":"base64",processing_note:"File will be processed automatically. Use get_media_file to check processing status."}})}),function(e){return _.apply(this,arguments)})),v({name:"update_media_file_meta",description:"Update media file information",inputSchema:{file_id:Jt().describe("Media file ID"),name:Jt().optional().describe("New file name"),description:Jt().optional().describe("New file description"),user_tags:ea(Jt()).optional().describe("New user tags")},permission:"write_media_flow"},(h=O(function*(e){var t=e.file_id,a=e.name,n=e.description,r=e.user_tags;return qd(yield A.updateMediaFile({fileId:t,name:a,description:n,userTags:r,requestUploadAgain:!1}))}),function(e){return h.apply(this,arguments)})),v({name:"copy_media_files",description:"Copy media files from one box to another",inputSchema:{from_box_id:Jt().describe("Source media box ID"),to_box_id:Jt().describe("Target media box ID"),file_ids:ea(Jt()).describe("Array of media file IDs to copy")},permission:"write_media_flow"},(E=O(function*(e){var t=e.from_box_id,a=e.to_box_id,n=e.file_ids;return qd(yield A.copyMediaFiles({fromBoxId:t,toBoxId:a,list:n}))}),function(e){return E.apply(this,arguments)})),v({name:"delete_media_files",description:"Delete specific media files from a box",inputSchema:{box_id:Jt().describe("Media box ID"),file_ids:ea(Jt()).describe("Array of media file IDs to delete")},permission:"write_media_flow"},(y=O(function*(e){var t=e.box_id,a=e.file_ids;return qd(yield A.deleteMediaFiles({boxId:t,list:a}))}),function(e){return y.apply(this,arguments)})),v({name:"cleanup_media_box",description:"Delete all files in a media box, optionally filtered by type",inputSchema:{box_id:Jt().describe("Media box ID"),include_types:ea(Jt()).optional().describe('Only delete files of these types (e.g., ["image", "video"])')},permission:"write_media_flow"},(T=O(function*(e){var t=e.box_id,a=e.include_types;if("deleteMediaBoxFiles"in A)return qd(yield A.deleteMediaBoxFiles({boxId:t,includeTypes:a}));var n=yield A.mediaFiles({boxId:t,includeTypes:a});return qd(yield A.deleteMediaFiles({boxId:t,list:n.map(function(e){return e.id})}))}),function(e){return T.apply(this,arguments)})),e.tool("calculate_grid_layout","Calculate grid layout and pixel conversions for different device resolutions",{device_width:Zt().describe("Device width in pixels"),device_height:Zt().describe("Device height in pixels"),app_grid_width:Zt().describe("Application grid width").optional().default(96),app_grid_height:Zt().describe("Application grid height").optional().default(54)},(R=O(function*(e){var t,a,n=e.device_width,r=e.device_height,i=e.app_grid_width,o=e.app_grid_height,s={deviceBrickWidth:(t=n)/(a=t/i),deviceBrickHeight:r/a,deviceBrickUnit:a},p=function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:96,n=e/a;return t>e&&(n=t/a),{deviceBrickWidth:Math.round(e/n),deviceBrickHeight:Math.round(t/n),deviceBrickUnit:n}}(n,r,i);return qd({device_resolution:{width:n,height:r,aspect_ratio:(n/r).toFixed(2)},current_grid:{width:i,height:o,unit_size_px:s.deviceBrickUnit.toFixed(2),total_pixels:{width:s.deviceBrickWidth.toFixed(2),height:s.deviceBrickHeight.toFixed(2)}},recommended_grid:{width:p.deviceBrickWidth,height:p.deviceBrickHeight,unit_size_px:p.deviceBrickUnit.toFixed(2),note:"Optimized for device aspect ratio"}})}),function(e){return R.apply(this,arguments)})),e.tool("create_item","Use this tool to create new item that you can put in application configuration",{type:aa(["subspace","canvas","brick","generator","property_bank","property_bank_calc","property_bank_command","animation","state_group","automation_map"]).describe("Item type"),title:Jt().describe("Item title"),template_key:Jt().optional().describe("Template key for brick or generator")},Th),e.tool("getting_started","Get documentation content for getting started",{},O(function*(){return qd(nc)}))}var gh="2.24.0-beta.6";function vh(){return vh=O(function*(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).token||process.env.BRICKS_API_TOKEN;if(!e)throw console.error("Error: API token is required"),console.error("Please provide a token via options or set BRICKS_API_TOKEN environment variable"),new Error("API token is required");var t=Ud({queryStringParameters:{token:e}});if(!t.success)throw console.error("Error: Invalid BRICKS_API_TOKEN"),console.error(t.message),new Error("Invalid BRICKS_API_TOKEN");var a,n=new Id({name:hh,version:gh}),r=Object.assign({},t,{client:_h(Eh.bricks,t.token,t.tokenType)});(a=n).prompt("getting-started","Getting started with BRICKS",{},O(function*(){return{messages:[{role:"user",content:{type:"text",text:'Welcome to BRICKS — start here.\n\nBefore doing any complex work (application design, deployments, etc.),\nalways consult the official docs rather than guessing.\n\nIMPORTANT: BRICKS users interact through a GUI editor, not raw config files.\nNever show users JSON config details, schema fields, or technical implementation.\nFocus on user-friendly descriptions of what the app will do and how it will look.\n\nGolden rules for working with BRICKS:\n1) Read before you act\n - Open these resources first, then proceed:\n - `getting-started` — overview & architecture\n - `config-schema` — canonical schema for apps, subspaces, bricks, generators, etc.\n - `components-index` — available bricks/generators\n2) Source of truth\n - Rely on the docs above; do not invent fields not present in the schema\n3) No guessing\n - If names, constraints, or device details are missing, ask to fetch them first\n4) Plan then execute\n - Propose a clear step-by-step plan and wait for approval before writing or mutating data\n5) User-friendly communication\n - Describe features in terms of what users see and do, not technical config\n - Use visual/functional language: "text display", "button", "screen transition"\n - Avoid exposing JSON, IDs, or schema details to end users\n\nBRICKS essentials:\n- Applications: interactive digital signage experiences\n- Devices: deployment targets (screens/players)\n- Modules: Reusable module across applications\n- Grid system: default 96×54; 1 unit = device_width/96 (e.g., 20px at 1920×1080)\n- Key primitives: Subspaces, Canvas, Bricks, Generators, Property Banks (Data)\n\nQuick actions:\n- "Create a new application" → use the `create-application` prompt\n- "Deploy an application to a device" → use the `deploy-to-device` prompt\n\nTry asking:\n- "Draft a plan to create an app with a text display and deploy it; ask any missing questions first"'}}]}})),a.prompt("create-application","Create a new BRICKS application with guided setup",{app_name:Jt().describe("Name for the new application"),description:Jt().describe("Short description for the new application").optional()},function(){var e=O(function*(e){var t=(null==e?void 0:e.app_name)||"New Application",a=(null==e?void 0:e.description)||"";return{messages:[{role:"user",content:{type:"text",text:`Help me create a new BRICKS application called "${t}".\n\n${a?`Goal: ${a}`:""}\n\nIMPORTANT: Users see a visual GUI editor, not raw config. Describe features in user-friendly terms:\n- "text display" not "BRICK_TEXT"\n- "image" not "BRICK_IMAGE"\n- "canvas name" not "CANVAS_xxx"\n- "data storage" not "PROPERTY_BANK"\n- Focus on what users see and do, not technical implementation\n\nHow we'll proceed (no guessing, schema-first):\n1) Confirm intent\n - Restate objectives and success criteria in 1–3 bullets\n2) Consult docs (as needed)\n - getting-started, config-schema, components-index\n - Ensure proposed fields exist in the schema\n3) Ask missing questions before changes\n - Target device(s) and resolution(s)\n - Layout needs (pages/screens), content types, data sources\n - Localization, scheduling, or interaction needs\n4) Propose a minimal viable design (After confirming intent)\n - App structure: screens → visual elements\n - Initial component selection with rationale\n - Grid usage: default 96×54 (≈20px at 1920×1080)\n5) Produce a schema-valid skeleton (no side effects yet)\n - Include only fields defined by config-schema\n - Use clear placeholders for text/assets/URLs/ids\n\nWhat I'll produce first:\n- Short recap of requirements\n- Clarifying questions (only what's necessary)\n- High-level architecture plan\n- Minimal config skeleton that validates against the schema`}}]}});return function(t){return e.apply(this,arguments)}}()),function(e){e.resource("getting-started-docs","file://docs/getting-started.md",{mimeType:"text/markdown",title:"Getting Started with BRICKS",description:"Comprehensive guide to BRICKS architecture, concepts, and development workflow"},O(function*(){return qd(Hd,{uri:"file://docs/getting-started.md",mimeType:"text/markdown"})}))}(n),Rh(n,r);var i=new Fd;try{yield n.connect(i),console.error("BRICKS MCP Server running on STDIO"),console.error(`Server: ${hh} v${gh}`),console.error(`Token Type: ${t.tokenType}`),console.error(`Permissions: ${t.tokenInfo.permissions.join(", ")}`),console.error("Ready to accept requests...")}catch(e){throw console.error("Failed to start MCP server:",e),e}}),vh.apply(this,arguments)}var Oh=new P("mcp").description("MCP server management");Oh.command("start").description("Start the BRICKS MCP server in STDIO mode").option("-t, --token <token>","API token (overrides saved token)").action(function(){var e=O(function*(e){var t=(0,V.getCurrentProfile)(),a=e.token||(0,V.getToken)(t);a||(console.error(M.Ay.red("Error: No API token found.")),console.error(M.Ay.gray("Please login first with: bricks auth login <passcode>")),console.error(M.Ay.gray("Or provide a token with: bricks mcp start --token <token>")),process.exit(1));try{yield function(){return vh.apply(this,arguments)}({token:a})}catch(e){console.error(M.Ay.red(`Failed to start MCP server: ${e.message}`)),process.exit(1)}});return function(t){return e.apply(this,arguments)}}());var Nh=function(){var e=O(function*(){if(b.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.24.0-beta.6").enablePositionalOptions(),b.addCommand(U),b.addCommand(te),b.addCommand(se),b.addCommand(le),b.addCommand(me),b.addCommand(Ee),b.addCommand(ve),b.addCommand(Oh),b.command("interactive").alias("i").description("Start interactive mode with Ink UI").action(O(function*(){try{(0,(yield c.e(612).then(c.bind(c,9612))).runInteractiveMode)()}catch(e){console.error(M.Ay.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}})),b.command("workspace").alias("ws").description("Show current workspace information").option("-j, --json","Output as JSON").action(function(){var e=O(function*(e){var t=yield Promise.resolve().then(c.bind(c,8765)),a=t.getToken,n=t.getBaseUrl,r=t.getCurrentProfile,i=(yield Promise.resolve().then(c.bind(c,7742))).createClient,o=(yield Promise.resolve().then(c.bind(c,9790))).default,s=a(r());s||(console.error(M.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var p=o("Fetching workspace info...").start();try{var l,d,u=i(n(),s),m=yield u.workspace();if(p.stop(),e.json)return void console.log(JSON.stringify(m,null,2));console.log(M.Ay.bold("\nWorkspace Information")),console.log("─".repeat(60)),console.log(`Name: ${M.Ay.green(m.name)}`),console.log(`ID: ${M.Ay.gray(m._id)}`),console.log(`Description: ${m.description||M.Ay.gray("N/A")}`),console.log(`\n${M.Ay.bold("Data")}`),console.log(`Remote Update: ${null!=(l=m.bank)&&l.enable_remote_update?M.Ay.green("Enabled"):M.Ay.gray("Disabled")}`),console.log(`Spacename: ${(null==(d=m.bank)?void 0:d.spacename)||M.Ay.gray("N/A")}`),console.log("─".repeat(60))}catch(e){p.fail(`Failed to get workspace: ${e.message}`),process.exit(1)}});return function(t){return e.apply(this,arguments)}}()),b.on("--help",function(){console.log(""),console.log(M.Ay.bold("Examples:")),console.log(""),console.log(M.Ay.gray(" # Login with a one-time passcode (recommended)")),console.log(" $ bricks auth login <passcode>"),console.log(""),console.log(M.Ay.gray(" # List all devices")),console.log(" $ bricks device list"),console.log(""),console.log(M.Ay.gray(" # Monitor devices in real-time")),console.log(" $ bricks device monitor"),console.log(""),console.log(M.Ay.gray(" # Control a device")),console.log(" $ bricks device refresh <device-id>"),console.log(" $ bricks device control <device-id> clear-cache"),console.log(""),console.log(M.Ay.gray(" # Bind a new device")),console.log(' $ bricks device bind <passcode> -n "My Device"'),console.log(""),console.log(M.Ay.gray(" # List applications")),console.log(" $ bricks app list"),console.log(""),console.log(M.Ay.gray(" # Start interactive mode")),console.log(" $ bricks interactive"),console.log(""),console.log(M.Ay.gray(" # Change API endpoint")),console.log(" $ bricks config endpoint beta"),console.log(""),console.log(M.Ay.gray("Get workspace token from BRICKS Controller:")),console.log(M.Ay.cyan(" https://control.bricks.tools")),console.log(M.Ay.gray(" Go to Workspace Settings > API Token"))}),0===process.argv.slice(2).length)try{return void(0,(yield c.e(612).then(c.bind(c,9612))).runInteractiveMode)()}catch(e){console.error(M.Ay.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}yield b.parseAsync(process.argv)});return function(){return e.apply(this,arguments)}}();const bh=Nh;export{bh as default,Nh as run};