Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

MCP backend for Ai assistant integration

Givan6c28a27e8981
diff --git a/env.php b/env.php
index d0ff3af..5c0ca3b 100755
--- a/env.php
+++ b/env.php
@@ -20,41 +20,36 @@
*
*/
-/*
-Check .sql files for changes and recompile, use on dev only
-*/
+// Check .sql files for changes and recompile, use on dev only
define('SQL_CHECK', true);
-/*
- Page cache needs web server support for maximum performance, make sure that apache has .htaccess support and nginx is configured according to included nginx.conf
- */
+// Page cache needs web server support for maximum performance, make sure that apache has .htaccess support and nginx is configured according to included nginx.conf
define('PAGE_CACHE', true);
/*
Disable on production to hide error messages, if enabled it will show detailed error messages
Warning: Enabling debug will decrease performance
*/
-defined('DEBUG') || define('DEBUG', false);
+defined('DEBUG') || define('DEBUG', true);
defined('VTPL_DEBUG') || define('VTPL_DEBUG', false);
-defined('GETTEXT') || define('GETTEXT', true);
+defined('GETTEXT') || define('GETTEXT', true);//if false gettext is emulated in php and a bit slower
-/*
-If enabled if a plugin generates an error it will be automatically disabled
-*/
+// If enabled if a plugin generates an error it will be automatically disabled
defined('DISABLE_PLUGIN_ON_ERORR') || define('DISABLE_PLUGIN_ON_ERORR', false);
//no trailing slash for subdir path
//defined('V_SUBDIR_INSTALL') || define('V_SUBDIR_INSTALL', '/vvveb');
-defined('V_SUBDIR_INSTALL') || define('V_SUBDIR_INSTALL', false);
+defined('V_SUBDIR_INSTALL') || define('V_SUBDIR_INSTALL', '');
//if shared session is enabled then user session (login) will work on all subdomains on multisite installations
defined('V_SHARED_SESSION') || define('V_SHARED_SESSION', false);
defined('LOG_SQL_QUERIES') || define('LOG_SQL_QUERIES', false);
-defined('REST') || define('REST', false);
-defined('GRAPHQL') || define('GRAPHQL', false);
+defined('REST') || define('REST', true);
+defined('GRAPHQL') || define('GRAPHQL', true);
defined('GRAPHQL_CAMELCASE') || define('GRAPHQL_CAMELCASE', true);
+defined('MCP') || define('MCP', true);
if (DEBUG) {
ini_set('display_errors', 1);
diff --git a/mcp/controller/base.php b/mcp/controller/base.php
new file mode 100755
index 0000000..20a95ab
--- /dev/null
+++ b/mcp/controller/base.php
@@ -0,0 +1,228 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\Controller;
+
+use function Vvveb\__;
+use function Vvveb\config;
+use function Vvveb\siteSettings;
+use Vvveb\System\Core\Request;
+use Vvveb\System\Core\Response;
+use Vvveb\System\Event;
+use Vvveb\System\Session;
+use Vvveb\System\Traits\Permission;
+use Vvveb\System\User\Admin;
+
+#[\AllowDynamicProperties]
+class Base {
+ use Permission;
+
+ /** @var array<string, mixed> */
+ protected array $global = [];
+
+ /**
+ * Authenticate the current admin user via HTTP or token-based auth.
+ *
+ * @return void
+ */
+ public function auth(): void {
+ $admin = Admin::current();
+
+ if (!$admin) {
+ $authMode = config('mcp.auth.mode');
+
+ if ($authMode == 'http') {
+ if (isset($_SERVER['PHP_AUTH_USER'])) {
+ $user = $_SERVER['PHP_AUTH_USER'];
+ $password = $_SERVER['PHP_AUTH_PW'] ?? '';
+ $loginData = compact('user', 'password');
+ $feedback = [];
+
+ if ($userInfo = Admin::login($loginData, [], $feedback)) {
+ } else {
+ $this->response->addHeader('WWW-Authenticate', 'Basic realm="REST Api"');
+ $this->response->addHeader('HTTP/1.0 401 Unauthorized');
+ $message = __('Auth failed!');
+
+ if (DEBUG) {
+ $message .= ' ' . ($feedback['message'] ?? '');
+ $message .= " auth.mode = $authMode";
+ }
+ $this->notFound($message, 403);
+ }
+ } else {
+ $this->response->addHeader('WWW-Authenticate', 'Basic realm="REST Api"');
+ $this->response->addHeader('HTTP/1.0 401 Unauthorized');
+ $message = __('Auth failed!');
+
+ if (DEBUG) {
+ $message .= __('No credentials!');
+ $message .= " auth.mode = $authMode";
+ }
+ $this->notFound($message, 403);
+ }
+ } else {
+ if ($authMode == 'token') {
+ $headers = getallheaders();
+ $token = $headers['Bearer'] ?? $_SERVER['HTTP_BEARER'] ?? null;
+ if (!$token) {
+ $token = $headers['Authorization'] ?? $_SERVER['HTTP_AUTHORIZATION'] ?? '';
+ $token = trim(substr($token, 6)) ?: $this->request->get['_token'] ?? false;
+ }
+
+ if ($token) {
+ $feedback = [];
+ if ($userInfo = Admin::auth($token, [], $feedback)) {
+ } else {
+ $this->response->addHeader('HTTP/1.0 401 Unauthorized');
+ $message = __('Auth failed!');
+
+ if (DEBUG) {
+ $message .= ' ' . ($feedback['message'] ?? '');
+ $message .= " auth.mode = $authMode";
+ $message .= " token = $token";
+ }
+ $this->notFound($message, 403);
+ }
+ } else {
+ $this->response->addHeader('HTTP/1.0 401 Unauthorized');
+ $message = __('Auth failed!');
+
+ if (DEBUG) {
+ $message .= __('No credentials!');
+ $message .= " auth.mode = $authMode";
+ $message .= " token = $token";
+ }
+ $this->notFound($message, 403);
+ }
+ } else {
+ //fail closed: deny any auth mode that is not explicitly enabled
+ $this->response->addHeader('HTTP/1.0 401 Unauthorized');
+ $message = __('Auth failed!');
+
+ if (DEBUG) {
+ $message .= __('No auth mode configured!');
+ $message .= " auth.mode = $authMode";
+ }
+ $this->notFound($message, 403);
+ }
+ }
+ }
+ }
+
+ /**
+ * Initialize ecommerce tax rules for the given region.
+ *
+ * @param int $countryId
+ * @param int $regionId
+ *
+ * @return void
+ */
+ protected function initEcommerce(int $countryId, int $regionId): void {
+ $tax = \Vvveb\System\Cart\Tax::getInstance();
+ $tax->setRegionRules($countryId, $regionId, 'store');
+ }
+
+ /**
+ * Initialize the MCP controller: set up request/response, authenticate, and load global settings.
+ *
+ * @return void
+ */
+ public function init(): void {
+ $this->response = Response::getInstance();
+ $this->request = Request::getInstance();
+ $this->session = Session::getInstance();
+
+ $this->response->setType('json');
+
+ if (!MCP) {
+ $this->notFound(__('MCP is disabled!'), 404);
+ }
+
+ $this->auth();
+ $site = siteSettings();
+
+ [$site] = Event::trigger(__CLASS__, __FUNCTION__, $site);
+
+ $this->global['site_id'] = SITE_ID;
+ $this->global['admin_id'] = 1;
+ $this->global['languages'] = $site['languages'] ?? [];
+ $this->global['language'] = ($site['language'] ?? '') ?: 'en';
+ $this->global['language_id'] = $this->session->get('language_id') ?? $site['language_id'] ?? 1;
+ $this->global['default_language'] = $site['language'] ?? 'en';
+ $this->global['default_language_id'] = $this->session->get('default_language_id') ?? $site['language_id'] ?? 1;
+ $this->global['default_lang_slug'] = $site['default_lang_slug'] ?? false;
+ $this->global['currency_id'] = (int)($this->session->get('currency_id') ?? $site['currency_id'] ?? 1);
+ $this->global['currency'] = $this->session->get('currency') ?? $site['currency'] ?? 'usd';
+ $this->global['currencies'] = $site['currencies'] ?? [];
+ $this->global['limit'] = 10;
+ $this->global['start'] = 0;
+ $this->global['user_id'] = false;
+ $this->global['user_group_id'] = 1;
+ $this->global['site'] = &$site;
+ $this->global['user'] = [];
+
+ $language_id = $this->global['language_id'];
+
+ if (isset($site['description'][$language_id])) {
+ $site['description'] = $site['description'][$language_id];
+ }
+
+ if (isset($site['country_id'])) {
+ $this->initEcommerce($site['country_id'], $site['region_id']);
+ }
+
+ $this->global['site'] = &$site;
+
+ [$this->global] = Event::trigger(__CLASS__, __FUNCTION__ . ':after', $this->global);
+ }
+
+ /**
+ * Call this function if the requested information was not found.
+ * Outputs a JSON-RPC error response and terminates.
+ *
+ * @param array<string, mixed>|string|null $message
+ * @param int $statusCode
+ * @param bool $service
+ *
+ * @return never
+ */
+ protected function notFound(array|string|null $message = null, int $statusCode = -32404, bool $service = false): never {
+ $this->response->setType('json');
+
+ $output = [
+ 'jsonrpc' => '2.0',
+ 'id' => '0',
+ 'error' => [
+ 'message' => $message,
+ 'code' => $statusCode,
+ ]
+ ];
+
+ $output['error']['message'] = $message;
+ $output['error']['code'] = $statusCode;
+
+ $this->response->output($output);
+
+ exit();
+ }
+}
diff --git a/mcp/controller/error403.php b/mcp/controller/error403.php
new file mode 100755
index 0000000..c6795e6
--- /dev/null
+++ b/mcp/controller/error403.php
@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\Controller;
+
+#[\AllowDynamicProperties]
+class Error403 extends Base {
+ /**
+ * Return a 403 error response for MCP.
+ *
+ * @return array{error: array{message: string, code: int}}
+ */
+ public function index(): array {
+ $this->response->setType('json');
+
+ return ['error' => ['message' => $this->view->message, 'code' => $this->view->code ?? -32403]];
+ }
+}
diff --git a/mcp/controller/error404.php b/mcp/controller/error404.php
new file mode 100755
index 0000000..a4d7d67
--- /dev/null
+++ b/mcp/controller/error404.php
@@ -0,0 +1,45 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\Controller;
+
+#[\AllowDynamicProperties]
+class Error404 extends Base {
+ /**
+ * Return a 404 error response for MCP.
+ *
+ * @return array{error: array{message: string, code: int}, file?: string}
+ */
+ public function index(): array {
+ $this->response->setType('json');
+
+ $return = ['error' => ['message' => $this->view->message ?? 'Route not found!', 'code' => $this->view->code ?? -32404]];
+
+ if (DEBUG) {
+ if (isset($this->view->file)) {
+ $return['file'] = $this->view->file;
+ }
+ }
+
+ return $return;
+ }
+}
diff --git a/mcp/controller/error500.php b/mcp/controller/error500.php
new file mode 100755
index 0000000..5c2481f
--- /dev/null
+++ b/mcp/controller/error500.php
@@ -0,0 +1,50 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\Controller;
+
+#[\AllowDynamicProperties]
+class Error500 extends Base {
+ /**
+ * Return a 500 error response for MCP.
+ *
+ * @return array<string, mixed>
+ */
+ public function index(): array {
+ $this->response->setType('json');
+
+ if (DEBUG) {
+ return [
+ 'message' => $this->view->message ?? '',
+ 'file' => $this->view->file ?? '',
+ 'line_no' => $this->view->line_no ?? '',
+ 'line' => $this->view->line ?? '',
+ 'lines' => $this->view->lines ?? '',
+ 'trace' => $this->view->trace ?? '',
+ 'codeLines' => $this->view->code ?? '',
+ 'code' => 32603,
+ ];
+ } else {
+ return ['message' => 'Internal JSON-RPC error', 'code' => 32603];
+ }
+ }
+}
diff --git a/mcp/controller/index.php b/mcp/controller/index.php
new file mode 100644
index 0000000..61029ab
--- /dev/null
+++ b/mcp/controller/index.php
@@ -0,0 +1,3673 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\Controller;
+
+use Throwable;
+use function Vvveb\config;
+use function Vvveb\humanReadable;
+use function Vvveb\rrmdir;
+use function Vvveb\sanitizeFileName;
+use function Vvveb\slugify;
+use Vvveb\System\Cache;
+use Vvveb\System\Db;
+use Vvveb\System\Event;
+use Vvveb\System\MCP;
+use Vvveb\System\Session;
+use Vvveb\System\Sites;
+use Vvveb\System\Sqlp\Sqlp;
+use Vvveb\System\Traits\Media as MediaLibraryTrait;
+use function Vvveb\url;
+
+// Routine-failure taxonomy (must load before the editor so FsError can extend it)
+require_once __DIR__ . '/../tool_error.php';
+// Integrated str_replace_editor filesystem tool
+require_once __DIR__ . '/../str_replace_editor.php';
+
+#[\AllowDynamicProperties]
+class Index extends Base {
+ use MediaLibraryTrait;
+
+ /** @var string Media library root for the file cores below. */
+ protected string $dirMedia = DIR_MEDIA;
+
+ /** @var string MCP protocol version */
+ private string $version = '2025-11-25';
+
+ /** @var int Maximum bytes returned for a single file read */
+ private const READ_MAX_BYTES = 5242880; // 5MB
+
+ /** @var int Maximum bytes written in a single write call */
+ private const WRITE_MAX_BYTES = 4194304; // 4MB
+
+ /** @var int Maximum combined stdout+stderr bytes returned by bash */
+ private const BASH_MAX_OUTPUT = 262144; // 256KB
+
+ /** @var int Maximum decoded bytes accepted by media upload (also capped by the server upload_max_filesize) */
+ private const MEDIA_UPLOAD_MAX_BYTES = 4194304; // 4MB
+
+ /** Directories never traversed by grep/glob */
+ private const SKIP_DIRS = ['.git', '.svn', 'node_modules'];
+
+ /**
+ * Map of coding harness tool names to controller methods.
+ * Tools defined in tools.php that are not listed here fall back to
+ * their execute_callback (if callable).
+ *
+ * @var array<string, string>
+ */
+ private array $toolHandlers = [
+ 'crud' => 'toolCrud',
+ 'crud_models' => 'toolCrudModels',
+ 'admin' => 'toolAdmin',
+ 'media' => 'toolMedia',
+ 'read' => 'toolRead', //fallback for str_replace_editor
+ 'write' => 'toolWrite', //fallback for str_replace_editor
+ 'glob' => 'toolGlob', //fallback for disabled bash
+ 'grep' => 'toolGrep', //fallback for disabled bash
+ 'bash' => 'toolBash', //if shell exec available
+ 'bash_sub' => 'toolBashSub', //falback if shell exec not available
+ 'powershell' => 'toolPowershell', //only available on windows
+ 'str_replace_editor' => 'toolStrReplaceEditor',
+ 'database_query' => 'toolDatabaseRunQuery',
+ ];
+
+ /**
+ * Initializes session from MCP session header.
+ */
+ public function __construct() {
+ $headers = getallheaders();
+ $sessionId = $headers['Mcp-Session-Id'] ?? $_SERVER['Mcp-Session-Id'] ?? null;
+
+ if ($sessionId) {
+ $this->session = Session::getInstance(['id' => $sessionId, 'use_cookies' => 0]);
+ }
+
+ $disable = MCP :: disabledTools();
+ $this->toolHandlers = array_diff_key($this->toolHandlers, array_flip($disable));
+ }
+
+ /**
+ * List available tools.
+ *
+ * @param array<string, mixed> $params
+ *
+ * @return array{tools: mixed}
+ */
+ public function tools_list(array $params): array {
+ $cache = Cache::getInstance();
+ $self = $this;
+ //version the key on the registry sources: a schema or handler deploy
+ //must surface immediately instead of lingering for the 3-day TTL. A
+ //stale tools-list previously hid a newly added tool for days while
+ //the files were already correct.
+ $toolsKey = 'tools-list-' . md5((string)@filemtime(__DIR__ . '/../tools.php') . "\n" . implode(',', array_keys($this->toolHandlers)) . "\n" . (config('mcp.tools.db_write', false) === true ? 'w1' : 'w0'));
+ $tools = $cache->cache(APP, $toolsKey, function() use ($self) {
+ $tools = \Vvveb\System\MCP::annotateTools(include (__DIR__ . '/../tools.php'));
+
+ $tools = array_values(array_filter(
+ $tools,
+ fn ($tool) => isset($this->toolHandlers[$tool['name'] ?? ''])
+ ));
+
+ //hide the coding harness tools entirely when disabled
+ if (config('mcp.tools.enabled', true) !== true) {
+ $tools = array_values(array_filter(
+ $tools,
+ fn ($tool) => !isset($this->toolHandlers[$tool['name'] ?? ''])
+ ));
+ }
+
+ [$tools] = Event :: trigger('MCP', 'tools/list', $tools);
+
+ return $tools;
+ }, 259200);
+
+ return ['tools' => $tools];
+ }
+
+ /**
+ * Execute a tool call.
+ *
+ * Dispatches to the matching coding harness tool handler (read, write,
+ * bash, glob, grep, database_run_query, str_replace_editor ...) or falls back to the
+ * tool's execute_callback when one is registered. Results are wrapped in
+ * an MCP tool result envelope; thrown errors are converted to isError
+ * results instead of protocol errors.
+ *
+ * @param string $method JSON-RPC method (always "tools/call")
+ * @param array<string, mixed> $params {name: string, arguments: array}
+ *
+ * @return array{content: array<int, mixed>, isError: bool, structuredContent?: mixed}
+ */
+ public function tools_call(string $method, array $params): array {
+ $name = $params['name'] ?? '';
+ $arguments = $params['arguments'] ?? [];
+
+ if ($name === '') {
+ return $this->errorResult('Missing tool name');
+ }
+
+ //master switch for the coding harness tool set
+ if (config('mcp.tools.enabled', true) !== true) {
+ return $this->errorResult('Coding tools are disabled (config mcp.tools.enabled)');
+ }
+
+ $arguments = is_array($arguments) ? $arguments : [];
+
+ try {
+ //resolve tool definition from the registry
+ $tool = null;
+
+ foreach ($this->tools_list([])['tools'] as $toolDef) {
+ if (($toolDef['name'] ?? null) === $name) {
+ $tool = $toolDef;
+ break;
+ }
+ }
+
+ if ($tool === null) {
+ return $this->errorResult("Unknown tool: $name");
+ }
+
+ $this->validateRequiredArgs($name, $arguments, $tool);
+
+ //dispatch to dedicated handler or registered callback
+ if (isset($this->toolHandlers[$name]) && method_exists($this, $this->toolHandlers[$name])) {
+ $result = $this->{$this->toolHandlers[$name]}($arguments);
+ } elseif (!empty($tool['execute_callback']) && is_callable($tool['execute_callback'])) {
+ $result = $tool['execute_callback']($arguments);
+ } else {
+ return $this->errorResult("No handler registered for tool: $name");
+ }
+
+ return $this->textResult($result);
+ } catch (Throwable $e) {
+ //Routine tool failures (missing file, bad args, unknown model)
+ //are answers, not crashes: the model gets the message alone and
+ //nothing is logged, so agent trial-and-error doesn't flood the
+ //server log. Only unexpected failures (IO/DB/environment/coding
+ //bugs) log with traces under DEBUG. (This also drops a literal
+ //'\n' separator bug - single quotes never escape.)
+ $routine = $e instanceof \McpToolError || $e instanceof \InvalidArgumentException;
+
+ if (DEBUG && !$routine) {
+ error_log('mcp tools/call ' . $name . ' failed: ' . $e::class . ': ' . $e->getMessage() . "\n" . $e->getTraceAsString());
+ }
+
+ return $this->errorResult(self::trimToolError($e->getMessage() ?: $e::class));
+ }
+ }
+
+ /* -----------------------------------------------------------------
+ * Coding harness tools
+ * ----------------------------------------------------------------- */
+
+ /**
+ * read tool: return file contents with line numbers, optionally sliced.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array{content: string, totalLines: int}
+ */
+ public function toolRead(array $args): array {
+ $path = $this->resolvePath((string)($args['path'] ?? ''));
+ $offset = max(1, (int)($args['offset'] ?? 1));
+ $limit = max(1, min(10000, (int)($args['limit'] ?? 2000)));
+
+ if (!is_file($path)) {
+ throw new \McpToolError("File not found: {$args['path']}");
+ }
+
+ $size = filesize($path);
+
+ if ($size > self::READ_MAX_BYTES) {
+ throw new \McpToolError('File exceeds max readable size (' . self::READ_MAX_BYTES . ' bytes): ' . $size);
+ }
+
+ $content = file_get_contents($path);
+
+ if ($content === false) {
+ throw new \RuntimeException("Failed reading file: {$args['path']}");
+ }
+
+ if (str_contains($content, "\0")) {
+ throw new \McpToolError('File appears to be binary and cannot be displayed as text');
+ }
+
+ $lines = preg_split('/(\r\n|\n|\r)/', $content);
+ $total = count($lines);
+ $slice = array_slice($lines, $offset - 1, $limit);
+
+ $output = '';
+
+ foreach ($slice as $i => $line) {
+ $output .= sprintf("%6d\t%s\n", $offset + $i, $line);
+ }
+
+ if ($total > $offset - 1 + count($slice)) {
+ $output .= "\n[Output truncated to $limit lines starting at line $offset. Total lines: $total. "
+ . 'Use offset/limit parameters to read more.]';
+ }
+
+ return ['content' => $output, 'totalLines' => $total];
+ }
+
+ /**
+ * write tool: create or overwrite a file, creating parent directories.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array{success: bool, bytes: int, created: bool}
+ */
+ public function toolWrite(array $args): array {
+ //target may not exist yet, only its parent directory has to
+ $path = $this->resolvePath((string)($args['path'] ?? ''), false);
+ $content = (string)($args['content'] ?? '');
+
+ if (strlen($content) > self::WRITE_MAX_BYTES) {
+ throw new \RuntimeException('Content exceeds max write size (' . self::WRITE_MAX_BYTES . ' bytes)');
+ }
+
+ $created = !is_file($path);
+ $dir = dirname($path);
+
+ if (!is_dir($dir) && !@mkdir($dir, 0755, true)) {
+ throw new \RuntimeException("Failed creating directory: $dir");
+ }
+
+ if (@file_put_contents($path, $content) === false) {
+ throw new \RuntimeException("Failed writing file: {$args['path']}");
+ }
+
+ @chmod($path, 0664 & ~umask());
+
+ return ['success' => true, 'bytes' => strlen($content), 'created' => $created];
+ }
+
+ /**
+ * bash tool: execute a shell command with timeout and output caps.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array{stdout: string, stderr: string, exitCode: int, timedOut: bool}
+ */
+ public function toolBash(array $args): array {
+ $command = trim((string)($args['command'] ?? ''));
+
+ if ($command === '') {
+ throw new \InvalidArgumentException('command must not be empty');
+ }
+
+ // bash is the native tool (proc_open). If shell_exec/proc_open are disabled,
+ // transparently fall back to the pure-PHP bash_sub (BashBox) so callers
+ // still get a result. bash_sub remains a distinct pure-PHP tool.
+ if (!MCP :: isShellAvailable()) {
+ $fallback = $this->toolBashSub($args);
+ // keep native bash response shape but indicate fallback
+ $fallback['engine'] .= ' (fallback from bash)';
+
+ return $fallback;
+ }
+
+ $timeout = max(1, min(120, (int)($args['timeout'] ?? 30)));
+ $cwd = isset($args['cwd']) && $args['cwd'] !== ''
+ ? $this->resolvePath((string)$args['cwd'], true)
+ : $this->toolRoot();
+
+ $descriptors = [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']];
+ $process = proc_open('exec /bin/bash -lc ' . escapeshellarg($command), $descriptors, $pipes, $cwd);
+
+ if (!is_resource($process)) {
+ throw new \RuntimeException('proc_open() failed — check that bash exists and open_basedir allows execution');
+ }
+
+ stream_set_blocking($pipes[1], false);
+ stream_set_blocking($pipes[2], false);
+ fclose($pipes[0]);
+
+ $deadline = microtime(true) + $timeout;
+ $stdout = '';
+ $stderr = '';
+ $timedOut = false;
+ $truncated = false;
+
+ while (true) {
+ $read = [$pipes[1], $pipes[2]];
+ $write = null;
+ $except = null;
+
+ if (stream_select($read, $write, $except, 0, 200000) === false) {
+ break;
+ }
+
+ foreach ($read as $stream) {
+ $data = fread($stream, 65536);
+
+ if ($data === false || $data === '') {
+ continue;
+ }
+
+ if ($stream === $pipes[1]) {
+ $stdout .= $data;
+ } else {
+ $stderr .= $data;
+ }
+ }
+
+ $status = proc_get_status($process);
+
+ if (strlen($stdout) + strlen($stderr) > self::BASH_MAX_OUTPUT) {
+ $truncated = true;
+ proc_terminate($process, 9);
+ break;
+ }
+
+ if (!$status['running']) {
+ break;
+ }
+
+ if (microtime(true) > $deadline) {
+ $timedOut = true;
+ proc_terminate($process, 9);
+ break;
+ }
+ }
+
+ //drain what's left in the pipes after the process ended
+ while (($line = fgets($pipes[1])) !== false) {
+ $stdout .= $line;
+ }
+
+ while (($line = fgets($pipes[2])) !== false) {
+ $stderr .= $line;
+ }
+
+ fclose($pipes[1]);
+ fclose($pipes[2]);
+
+ $exitCode = proc_close($process);
+
+ if ($timedOut) {
+ $exitCode = $exitCode ?: 124; // 124 = timeout convention
+ }
+
+ if ($truncated) {
+ $stdout = mb_strcut($stdout, 0, self::BASH_MAX_OUTPUT / 2);
+ $stderr = mb_strcut($stderr, 0, self::BASH_MAX_OUTPUT / 2);
+ $stdout .= '\n[output truncated]';
+ }
+
+ return ['stdout' => $stdout, 'stderr' => $stderr, 'exitCode' => (int)$exitCode, 'timedOut' => $timedOut];
+ }
+
+ /**
+ * bash_sub tool: sandboxed pure-PHP bash via BashBox (shipfastlabs/bashbox).
+ *
+ * Used when php shell_exec/proc_open are disabled. Every command is a PHP class,
+ * filesystem is virtualised via ReadWriteFs sandboxed to toolRoot(). No proc_open/exec/shell_exec
+ * is invoked. Falls back to native bash if BashBox is not installed but shell is available.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array{stdout: string, stderr: string, exitCode: int, timedOut: bool, engine: string, truncated?: bool}
+ */
+ public function toolBashSub(array $args): array {
+ $command = trim((string)($args['command'] ?? ''));
+ if ($command === '') {
+ throw new \InvalidArgumentException('command must not be empty');
+ }
+ $timeout = max(1, min(120, (int)($args['timeout'] ?? 30)));
+ $cwdHost = isset($args['cwd']) && $args['cwd'] !== '' ? $this->resolvePath((string)$args['cwd'], true) : $this->toolRoot();
+ $root = $this->toolRoot();
+ // virtual cwd is sandbox-relative, ReadWriteFs maps "/" -> $root
+ $virtualCwd = '/' . ltrim(substr($cwdHost, strlen($root)), '/');
+ if ($virtualCwd === '/') {
+ $virtualCwd = '/';
+ }
+ $shellAvailable = MCP :: isShellAvailable();
+ // If BashBox not available, gracefully fall back to native bash when possible
+ if (!class_exists('\\BashBox\\Bash')) {
+ if ($shellAvailable) {
+ $fallback = $this->toolBash($args);
+ $fallback['engine'] = 'native (bashbox missing)';
+
+ return $fallback;
+ }
+
+ throw new \RuntimeException('BashBox not installed (shipfastlabs/bashbox) and native shell is disabled. Run: composer require shipfastlabs/bashbox');
+ }
+
+ try {
+ $fs = new \BashBox\Filesystem\ReadWriteFs($root);
+ } catch (\Throwable $e) {
+ throw new \RuntimeException('Failed to init BashBox filesystem: ' . $e->getMessage(), 0, $e);
+ }
+ $limits = new \BashBox\Limits(
+ maxOutputSize: self::BASH_MAX_OUTPUT,
+ maxCommandCount: 10000,
+ maxLoopIterations: 10000,
+ maxStringLength: self::BASH_MAX_OUTPUT,
+ );
+ $bashOptions = new \BashBox\BashOptions(
+ fs: $fs,
+ cwd: $virtualCwd,
+ limits: $limits,
+ );
+ $bash = new \BashBox\Bash($bashOptions);
+ $execOptions = new \BashBox\ExecOptions(cwd: $virtualCwd);
+
+ // BashBox has no timeout; enforce via maxCommandCount/limits. We still respect $timeout for API parity.
+ try {
+ $result = $bash->exec($command, $execOptions);
+ } catch (\Throwable $e) {
+ return [
+ 'stdout' => '',
+ 'stderr' => 'bashbox error: ' . $e->getMessage(),
+ 'exitCode' => 127,
+ 'timedOut' => false,
+ 'engine' => 'bashbox',
+ ];
+ }
+ $stdout = $result->stdout;
+ $stderr = $result->stderr;
+ $exitCode = $result->exitCode;
+ $truncated = false;
+ if (strlen($stdout) + strlen($stderr) > self::BASH_MAX_OUTPUT) {
+ $stdout = mb_strcut($stdout, 0, (int)(self::BASH_MAX_OUTPUT / 2));
+ $stderr = mb_strcut($stderr, 0, (int)(self::BASH_MAX_OUTPUT / 2));
+ $stdout .= "\n[output truncated]";
+ $truncated = true;
+ }
+
+ return [
+ 'stdout' => $stdout,
+ 'stderr' => $stderr,
+ 'exitCode' => $exitCode,
+ 'timedOut' => false,
+ 'engine' => $shellAvailable ? 'bashbox (shell available, pure PHP)' : 'bashbox',
+ 'truncated' => $truncated,
+ ];
+ }
+
+ /**
+ * powershell tool: execute a PowerShell command (Windows-only).
+ *
+ * Native counterpart to bash for Windows servers where /bin/bash is
+ * unavailable. Prefers pwsh.exe (PowerShell 7+) and falls back to the
+ * inbox powershell.exe (Windows PowerShell 5.1). Uses a polling read
+ * loop instead of stream_select() which is socket-only on Windows.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array{stdout: string, stderr: string, exitCode: int, timedOut: bool, engine: string}
+ */
+ public function toolPowershell(array $args): array {
+ $command = trim((string)($args['command'] ?? ''));
+
+ if ($command === '') {
+ throw new \InvalidArgumentException('command must not be empty');
+ }
+
+ if (!MCP :: isShellAvailable()) {
+ throw new \RuntimeException('Native shell execution is disabled (proc_open/shell_exec disabled) — powershell tool requires proc_open');
+ }
+
+ $powershell = $this->findPowershell();
+
+ if ($powershell === null) {
+ throw new \RuntimeException('No PowerShell executable found (looked for pwsh/powershell). On Windows PowerShell is built in; on Linux/macOS install PowerShell 7 (pwsh) to use this tool.');
+ }
+
+ $timeout = max(1, min(120, (int)($args['timeout'] ?? 30)));
+ $cwd = isset($args['cwd']) && $args['cwd'] !== ''
+ ? $this->resolvePath((string)$args['cwd'], true)
+ : $this->toolRoot();
+
+ $shellCommand = '"' . $powershell . '" -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command ' . escapeshellarg($command);
+
+ $descriptors = [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']];
+ $process = proc_open($shellCommand, $descriptors, $pipes, $cwd);
+
+ if (!is_resource($process)) {
+ throw new \RuntimeException('proc_open() failed — check that PowerShell exists and open_basedir allows execution');
+ }
+
+ stream_set_blocking($pipes[1], false);
+ stream_set_blocking($pipes[2], false);
+ fclose($pipes[0]);
+
+ $deadline = microtime(true) + $timeout;
+ $stdout = '';
+ $stderr = '';
+ $timedOut = false;
+ $truncated = false;
+
+ //polling loop (no stream_select — on Windows it only supports sockets).
+ while (true) {
+ $outChunk = fread($pipes[1], 65536);
+ $errChunk = fread($pipes[2], 65536);
+
+ if ($outChunk !== false && $outChunk !== '') {
+ $stdout .= $outChunk;
+ }
+
+ if ($errChunk !== false && $errChunk !== '') {
+ $stderr .= $errChunk;
+ }
+
+ $status = proc_get_status($process);
+
+ if (strlen($stdout) + strlen($stderr) > self::BASH_MAX_OUTPUT) {
+ $truncated = true;
+ proc_terminate($process, 9);
+ break;
+ }
+
+ if (!$status['running']) {
+ break;
+ }
+
+ if (microtime(true) > $deadline) {
+ $timedOut = true;
+ proc_terminate($process, 9);
+ break;
+ }
+
+ usleep(100000); // 100ms poll interval
+ }
+
+ //drain what's left in the pipes after the process ended
+ while (($line = fgets($pipes[1])) !== false) {
+ $stdout .= $line;
+ }
+
+ while (($line = fgets($pipes[2])) !== false) {
+ $stderr .= $line;
+ }
+
+ fclose($pipes[1]);
+ fclose($pipes[2]);
+
+ $exitCode = proc_close($process);
+
+ if ($timedOut) {
+ $exitCode = $exitCode ?: 124; // 124 = timeout convention
+ }
+
+ if ($truncated) {
+ $stdout = mb_strcut($stdout, 0, self::BASH_MAX_OUTPUT / 2);
+ $stderr = mb_strcut($stderr, 0, self::BASH_MAX_OUTPUT / 2);
+ $stdout .= '\n[output truncated]';
+ }
+
+ return [
+ 'stdout' => $stdout,
+ 'stderr' => $stderr,
+ 'exitCode' => (int)$exitCode,
+ 'timedOut' => $timedOut,
+ 'engine' => basename(str_replace('\\', '/', $powershell)),
+ ];
+ }
+
+ /**
+ * Whether the server OS is Windows.
+ */
+ private function isWindows(): bool {
+ return PHP_OS_FAMILY === 'Windows' || DIRECTORY_SEPARATOR === '\\';
+ }
+
+ /**
+ * Locate a PowerShell executable.
+ *
+ * On Windows prefers pwsh.exe (PowerShell 7+) then falls back to the
+ * inbox powershell.exe (5.1). On other systems looks for pwsh/powershell
+ * (PowerShell Core). Returns the full path when resolvable via where/command -v,
+ * otherwise the bare executable name on Windows (resolved via PATH by proc_open)
+ * or null when nothing is available.
+ */
+ private function findPowershell(): ?string {
+ $candidates = $this->isWindows()
+ ? ['pwsh.exe', 'powershell.exe']
+ : ['pwsh', 'powershell'];
+
+ $disabled = array_filter(array_map('trim', explode(',', (string)ini_get('disable_functions'))));
+ $disabled = array_map('strtolower', $disabled);
+ $canShellExec = function_exists('shell_exec') && !in_array('shell_exec', $disabled, true);
+
+ if ($canShellExec) {
+ $finder = $this->isWindows() ? 'where' : 'command -v';
+ $devNull = $this->isWindows() ? 'NUL' : '/dev/null';
+
+ foreach ($candidates as $bin) {
+ $out = trim((string)@$this->shellExecQuiet("$finder $bin 2>$devNull"));
+ $first = strtok($out, "\r\n");
+
+ if ($first !== false && trim($first) !== '') {
+ return trim($first);
+ }
+ }
+ }
+
+ //shell_exec unavailable or lookup failed: on Windows fall back to the
+ //inbox executable name and let proc_open resolve it via PATH.
+ if ($this->isWindows()) {
+ return 'powershell.exe';
+ }
+
+ return null;
+ }
+
+ /**
+ * Quiet shell_exec wrapper (suppressed errors, always returns string).
+ *
+ * @param string $command
+ */
+ private function shellExecQuiet(string $command): string {
+ $result = @shell_exec($command);
+
+ return is_string($result) ? $result : '';
+ }
+
+ /**
+ * glob tool: find files by pattern relative to the site root.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array{matches: list<string>, count: int}
+ */
+ public function toolGlob(array $args): array {
+ $pattern = (string)($args['pattern'] ?? '');
+ $limit = max(1, min(5000, (int)($args['limit'] ?? 500)));
+
+ if ($pattern === '') {
+ throw new \InvalidArgumentException('pattern must not be empty');
+ }
+
+ $root = $this->toolRoot();
+
+ //normalize to a root-relative body. Absolute patterns must already
+ //sit inside the sandbox (rejected, never remapped); anything else is
+ //relative to the site root.
+ if ($pattern[0] === '/') {
+ if ($pattern !== $root && !str_starts_with($pattern, $root . '/')) {
+ throw new \McpToolError('Pattern resolves outside the site root');
+ }
+ $body = ltrim(substr($pattern, strlen($root)), '/');
+ } else {
+ $body = ltrim(str_replace('\\', '/', $pattern), '/');
+ }
+
+ //leading ./ segments are noise for matching (relative hits never
+ //carry them) but would break the recursive regex anchor
+ $body = preg_replace('#^(?:\./)+#', '', $body);
+
+ //only the static leading segments (no wildcard chars) locate the
+ //search base - the old realpath(dirname($target)) check broke on any
+ //wildcard (dirname('public/**/*') is not a real path) and rejected
+ //every relative pattern. '..' climbs above the root are rejected;
+ //deeper '..' collapse lexically exactly like resolvePath().
+ $segments = $body === '' ? [] : explode('/', $body);
+ $canonical = [];
+
+ foreach ($segments as $seg) {
+ if (strpbrk($seg, '*?[{') !== false) {
+ break;
+ }
+ if ($seg === '' || $seg === '.') {
+ continue;
+ }
+ if ($seg === '..') {
+ if (!$canonical) {
+ throw new \McpToolError('Pattern resolves outside the site root');
+ }
+ array_pop($canonical);
+ continue;
+ }
+ $canonical[] = $seg;
+ }
+
+ $baseAbs = $root . ($canonical ? '/' . implode('/', $canonical) : '');
+
+ //existing bases must really live inside the sandbox (symlink check)
+ $realBase = realpath($baseAbs);
+
+ if ($realBase !== false && $realBase !== $root && !str_starts_with($realBase, $root . '/')) {
+ throw new \McpToolError('Pattern resolves outside the site root');
+ }
+
+ $results = [];
+
+ //native glob() treats a double star as a single-level star, so
+ //double-star patterns walk recursively and match per file instead.
+ if (str_contains($body, '**')) {
+ $results = $this->globRecursive($realBase !== false ? $realBase : $baseAbs, $root, $body, $limit);
+ } else {
+ $matches = is_dir($baseAbs) ? (glob($root . '/' . $body, GLOB_BRACE | GLOB_NOSORT) ?: []) : [];
+ sort($matches);
+
+ foreach ($matches as $match) {
+ if (count($results) >= $limit) {
+ break;
+ }
+ //per-match containment: a symlinked match must not escape
+ $real = realpath($match);
+
+ if ($real === false || ($real !== $root && !str_starts_with($real, $root . '/'))) {
+ continue;
+ }
+ $results[] = ltrim(substr($real, strlen($root)), '/');
+ }
+ }
+
+ return ['matches' => $results, 'count' => count($results)];
+ }
+
+ /**
+ * Recursive double-star glob: walk $walkRoot and match each file's
+ * root-relative path against the glob body (a double star spans zero or
+ * more directories).
+ *
+ * @param string $walkRoot existing search base, already sandbox-checked
+ * @param string $root
+ * @param string $body
+ * @param int $limit
+ *
+ * @return list<string> root-relative matches, sorted, capped at $limit
+ */
+ private function globRecursive(string $walkRoot, string $root, string $body, int $limit): array {
+ $results = [];
+
+ if (!is_dir($walkRoot)) {
+ return $results;
+ }
+
+ $regex = $this->globPatternToRegex($body);
+ $prefixLen = strlen($root) + 1;
+ $iterator = new \RecursiveIteratorIterator(
+ new \RecursiveCallbackFilterIterator(
+ new \RecursiveDirectoryIterator($walkRoot, \FilesystemIterator::SKIP_DOTS),
+ fn ($current) => !$current->isDir() || !in_array($current->getFilename(), self::SKIP_DIRS, true)
+ ),
+ \RecursiveIteratorIterator::LEAVES_ONLY
+ );
+ $scanned = 0;
+
+ foreach ($iterator as $file) {
+ if (!$file instanceof \SplFileInfo || !$file->isFile()) {
+ continue;
+ }
+ if (++$scanned > 50000) {
+ break; // runaway guard on huge trees; limit already caps output
+ }
+ $rel = str_replace('\\', '/', substr($file->getPathname(), $prefixLen));
+
+ if (!preg_match($regex, $rel)) {
+ continue;
+ }
+ $results[] = $rel;
+
+ if (count($results) >= $limit) {
+ break;
+ }
+ }
+ sort($results);
+
+ return $results;
+ }
+
+ /**
+ * Translate a glob body to a PCRE pattern over /-separated relative
+ * paths: a double star plus slash spans zero or more directories, a
+ * single star never crosses /.
+ *
+ * @param string $glob
+ */
+ private function globPatternToRegex(string $glob): string {
+ $out = '';
+ $len = strlen($glob);
+ $i = 0;
+
+ while ($i < $len) {
+ $c = $glob[$i];
+
+ if ($c === '*') {
+ $run = 0;
+
+ while (($glob[$i] ?? '') === '*') {
+ $run++;
+ $i++;
+ }
+ if ($run >= 2 && ($glob[$i] ?? '') === '/') {
+ $i++;
+ $out .= '(.*/)?';
+ } elseif ($run >= 2) {
+ $out .= '.*';
+ } else {
+ $out .= '[^/]*';
+ }
+ } elseif ($c === '?') {
+ $out .= '[^/]';
+ $i++;
+ } elseif ($c === '[') {
+ //copy the character class through, translating [!...] to [^...]
+ $cls = '[';
+ $i++;
+
+ if (($glob[$i] ?? '') === '!') {
+ $cls .= '^';
+ $i++;
+ }
+ while ($i < $len && $glob[$i] !== ']') {
+ $cls .= $glob[$i] === '\\' ? '\\\\' : $glob[$i];
+ $i++;
+ }
+ $cls .= ']';
+ $i++;
+ $out .= $cls;
+ } elseif ($c === '{') {
+ //{a,b} alternation: split top-level commas, recurse per branch
+ $depth = 1;
+ $j = $i + 1;
+ $alts = [''];
+
+ while ($j < $len && $depth > 0) {
+ $ch = $glob[$j];
+
+ if ($ch === '{') {
+ $depth++;
+ $alts[count($alts) - 1] .= $ch;
+ } elseif ($ch === '}') {
+ $depth--;
+
+ if ($depth > 0) {
+ $alts[count($alts) - 1] .= $ch;
+ }
+ } elseif ($ch === ',' && $depth === 1) {
+ $alts[] = '';
+ } else {
+ $alts[count($alts) - 1] .= $ch;
+ }
+ $j++;
+ }
+ if ($depth === 0) {
+ $parts = [];
+
+ foreach ($alts as $alt) {
+ $parts[] = substr($this->globPatternToRegex($alt), 2, -2);
+ }
+ $out .= '(?:' . implode('|', $parts) . ')';
+ $i = $j;
+ } else {
+ $out .= preg_quote($c, '@');
+ $i++;
+ }
+ } else {
+ $out .= preg_quote($c, '@');
+ $i++;
+ }
+ }
+
+ return '@^' . $out . '$@';
+ }
+
+ /**
+ * grep tool: recursive regex search over text files.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array{matches: list<array{file: string, line: int, text: string}>, count: int, truncated: bool}
+ */
+ public function toolGrep(array $args): array {
+ $pattern = (string)($args['pattern'] ?? '');
+ $searchPath = (string)($args['path'] ?? '.');
+ $include = (string)($args['include'] ?? '*');
+ $ignoreCase = !empty($args['ignoreCase']);
+ $maxResults = max(1, min(1000, (int)($args['maxResults'] ?? 200)));
+
+ if ($pattern === '') {
+ throw new \InvalidArgumentException('pattern must not be empty');
+ }
+
+ $regex = '@' . str_replace('@', '\\@', $pattern) . '@' . ($ignoreCase ? 'i' : '');
+
+ if (@preg_match($regex, '') === false) {
+ throw new \InvalidArgumentException("Invalid PCRE pattern: $pattern");
+ }
+
+ $path = $this->resolvePath($searchPath);
+ $root = $this->toolRoot();
+ $matches = [];
+ $count = 0;
+ $truncated = false;
+
+ $iterator = is_dir($path)
+ ? new \RecursiveIteratorIterator(
+ new \RecursiveCallbackFilterIterator(
+ new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS),
+ fn ($current) => !$current->isDir() || !in_array($current->getFilename(), self::SKIP_DIRS, true)
+ ),
+ \RecursiveIteratorIterator::LEAVES_ONLY
+ )
+ : [$spl = new \SplFileInfo($path)];
+
+ foreach ($iterator as $file) {
+ if (!$file instanceof \SplFileInfo || !$file->isFile()) {
+ continue;
+ }
+
+ if ($include !== '*' && !fnmatch($include, $file->getFilename())) {
+ continue;
+ }
+
+ if ($file->getSize() > 524288) { // skip files over 512KB
+ continue;
+ }
+
+ $contents = @file_get_contents($file->getPathname());
+
+ if ($contents === false || str_contains($contents, "\0")) {
+ continue;
+ }
+
+ $lines = preg_split('/\r\n|\n|\r/', $contents);
+
+ foreach ($lines as $i => $line) {
+ if (@preg_match($regex, $line)) {
+ $count++;
+
+ if ($count <= $maxResults) {
+ $matches[] = [
+ 'file' => ltrim(str_replace('\\', '/', substr($file->getPathname(), strlen($root))), '/'),
+ 'line' => $i + 1,
+ 'text' => mb_strcut($line, 0, 500),
+ ];
+ }
+ }
+ }
+
+ if ($count >= $maxResults * 10) { // hard stop once far past the cap
+ $truncated = true;
+ break;
+ }
+ }
+
+ return ['matches' => $matches, 'count' => $count, 'truncated' => $count > $maxResults];
+ }
+
+ /**
+ * database_run_query tool: run SQL with prepared params against the site DB.
+ *
+ * Read-only statements are always allowed; write statements require config
+ * key mcp.tools.db_write. SELECTs without LIMIT are capped automatically.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array<string, mixed>
+ */
+ public function toolDatabaseRunQuery(array $args): array {
+ $query = trim((string)($args['query'] ?? ''));
+ $params = is_array($args['params'] ?? null) ? $args['params'] : [];
+ $maxRows = max(1, min(10000, (int)($args['maxRows'] ?? 1000)));
+
+ if ($query === '') {
+ throw new \InvalidArgumentException('query must not be empty');
+ }
+
+ //the driver binds :named placeholders; translate positional '?' marks
+ //(outside quoted strings) into :p1, :p2 ... so users can pass a plain
+ //array of values
+ if ($params) {
+ $out = '';
+ $inSingle = false;
+ $inDouble = false;
+ $index = 0;
+
+ foreach (str_split($query) as $char) {
+ if ($char === "'" && !$inDouble) {
+ $inSingle = !$inSingle;
+ } elseif ($char === '"' && !$inSingle) {
+ $inDouble = !$inDouble;
+ }
+
+ if ($char === '?' && !$inSingle && !$inDouble) {
+ $index++;
+ $out .= ':p' . $index;
+ continue;
+ }
+
+ $out .= $char;
+ }
+
+ $query = $out;
+ $bind = [];
+
+ foreach ($params as $i => $value) {
+ $bind['p' . ($i + 1)] = $value;
+ }
+
+ $params = $bind;
+ }
+
+ //strip comments before checking statement type
+ $stmtType = self::statementType($query);
+
+ $readOnlyTypes = ['SELECT', 'SHOW', 'DESCRIBE', 'DESC', 'EXPLAIN'];
+ $isReadOnly = in_array($stmtType, $readOnlyTypes, true)
+ || ($stmtType === 'WITH' && !self::containsWriteKeyword($query));
+
+ if (!$isReadOnly && config('mcp.tools.db_write', false) !== true) {
+ throw new \McpToolError("Writes are disabled - enable mcp.tools.db_write to allow $stmtType queries.");
+ }
+
+ $db = Db::getInstance();
+
+ if (!$db) {
+ throw new \RuntimeException('Database not available');
+ }
+
+ if ($stmtType === 'SELECT' && !stripos($query, ' LIMIT ')) {
+ //cap unbounded selects so a missing LIMIT cannot exhaust memory;
+ //an explicit LIMIT set by the caller is respected as-is
+ $query = rtrim($query, "; \t\r\n") . ' LIMIT ' . $maxRows;
+ }
+
+ $stmt = $db->execute($query, $params);
+
+ if ($stmt === null) {
+ throw new \RuntimeException('Query failed');
+ }
+
+ if (in_array($stmtType, $readOnlyTypes, true) || $stmtType === 'WITH') {
+ $rows = $db->fetchAll($stmt);
+ $rowCount = count($rows);
+ $truncated = $rowCount > $maxRows;
+
+ if ($truncated) {
+ $rows = array_slice($rows, 0, $maxRows);
+ }
+
+ return ['rows' => $rows, 'rowCount' => $rowCount, 'truncated' => $truncated];
+ }
+
+ return [
+ 'affectedRows' => (int)($db->affected_rows ?? 0),
+ 'insertId' => (int)($db->insert_id ?? 0),
+ 'success' => true,
+ ];
+ }
+
+ /**
+ * crud tool: map CRUD operations to admin SQL models.
+ *
+ * The model name maps to admin/sql/<engine>/<model>.sql (e.g. product,
+ * user, post, order) and the operation maps to one of its procedures
+ * (get, getAll, add, edit, delete). Reads are always allowed; writes
+ * require config key mcp.tools.db_write, mirroring the database_query tool.
+ *
+ * @param mixed $result
+ * @param mixed $columns
+ * @param array<string, mixed> $args
+ *
+ * @return array{model: string, operation: string, result: mixed}
+ */
+ /**
+ * Project result rows down to the requested columns (PHP-side: the
+ * procedures always SELECT wide). Applies recursively to nested row
+ * lists (e.g. post_content) so bodies can be dropped while names stay;
+ * scalars like counts pass through untouched. Unknown columns yield an
+ * explicit error naming real keys instead of silent empty rows.
+ * Pure, tested.
+ *
+ * @param mixed $result Model result.
+ * @param mixed $columns Wanted column names (validated as list of strings inside).
+ *
+ * @throws \InvalidArgumentException On unknown columns.
+ *
+ * @return mixed Projected result.
+ */
+ private static function crudSelectColumns(mixed $result, mixed $columns): mixed {
+ if (!is_array($columns) || !array_is_list($columns)) {
+ throw new \InvalidArgumentException("Invalid columns for tool 'crud': must be a list of column names.");
+ }
+ if ($columns === [] || !is_array($result)) {
+ return $result;
+ }
+ foreach ($columns as $column) {
+ if (!is_string($column) || !preg_match('/^[a-z][a-z0-9_]*$/', $column)) {
+ throw new \InvalidArgumentException("Invalid columns entry for tool 'crud': each must match [a-z][a-z0-9_]*.");
+ }
+ }
+ //top-level scalars (count, totals) always pass: they describe the
+ //query, not the rows. Nested levels project strictly. $matched
+ //records any column hit so unknown names error instead of silently
+ //emptying (scalar passthrough alone must not count as a hit).
+ $matched = false;
+ $project = function($rows, bool $top = false) use (&$project, $columns, &$matched) {
+ if (!is_array($rows)) {
+ return $rows;
+ }
+ if (array_is_list($rows)) {
+ return array_map(fn ($row) => $project($row, false), $rows);
+ }
+ //associative row: project known keys, recurse into nested lists
+ //(empty projected rows drop out so unknown keys vanish)
+ $out = [];
+ foreach ($rows as $key => $value) {
+ if (is_array($value)) {
+ $nested = $project($value, false);
+ if (array_is_list($nested)) {
+ $nested = array_values(array_filter($nested, fn ($row) => $row !== [] && $row !== null));
+ }
+ if ($nested !== [] || in_array($key, $columns, true)) {
+ $out[$key] = $nested;
+ }
+ } elseif ($top || in_array($key, $columns, true)) {
+ if (in_array($key, $columns, true)) {
+ $matched = true;
+ }
+ $out[$key] = $value;
+ }
+ }
+
+ return $out;
+ };
+ $projected = $project($result, true);
+ //no column hit anywhere, yet row data existed: unknown names
+ $hasRows = function($rows) use (&$hasRows): bool {
+ if (!is_array($rows)) {
+ return false;
+ }
+ if (array_is_list($rows)) {
+ foreach ($rows as $row) {
+ if ($hasRows($row)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ return true;
+ };
+ $flatten = function($rows) use (&$flatten): array {
+ if (!is_array($rows)) {
+ return [];
+ }
+ if (array_is_list($rows)) {
+ $keys = [];
+ foreach ($rows as $row) {
+ $keys = array_merge($keys, $flatten($row));
+ }
+
+ return array_values(array_unique($keys));
+ }
+ $keys = [];
+ foreach ($rows as $key => $value) {
+ $keys[] = $key;
+ $keys = array_merge($keys, $flatten($value));
+ }
+
+ return array_values(array_unique($keys));
+ };
+ if (!$matched && $hasRows($result)) {
+ throw new \InvalidArgumentException("Unknown columns for tool 'crud' (" . implode(', ', $columns) . '). Available keys include: ' . implode(', ', array_slice($flatten($result), 0, 12)) . '. Check table columns via database_query DESCRIBE.');
+ }
+
+ return $projected;
+ }
+
+ /**
+ * @param array<string, mixed> $args
+ *
+ * @return array{model: string, operation: string, result: mixed}
+ */
+ public function toolCrud(array $args): array {
+ $operation = trim((string)($args['operation'] ?? ''));
+ $params = $args['params'] ?? [];
+ $model = self::crudNormalizeModel((string)($args['model'] ?? ''));
+ $columns = $args['columns'] ?? [];
+
+ if ($columns !== [] && (!is_array($columns) || !array_is_list($columns))) {
+ throw new \InvalidArgumentException("Invalid columns for tool 'crud': must be a list of column names.");
+ }
+
+ $allowedOps = ['get', 'getAll', 'add', 'edit', 'delete'];
+
+ if (!in_array($operation, $allowedOps, true)) {
+ throw new \InvalidArgumentException("Invalid operation '$operation' for tool 'crud'. Allowed: " . implode(', ', $allowedOps));
+ }
+
+ if (!is_array($params)) {
+ throw new \InvalidArgumentException("Invalid params for tool 'crud'. params must be an object with key/value pairs.");
+ }
+
+ $sqlFile = self::crudModelFile($model);
+
+ if ($sqlFile === null) {
+ throw new \McpToolError("Unknown model: '$model'. Available models: " . implode(', ', self::crudModels()));
+ }
+
+ $procedures = array_keys(self::crudProcedures($sqlFile, false));
+
+ if ($procedures === []) {
+ throw new \McpToolError("No procedures found in model '$model'.");
+ }
+
+ if (!in_array($operation, $procedures, true)) {
+ throw new \McpToolError("Operation '$operation' not available for model '$model'. Available operations: " . implode(', ', $procedures));
+ }
+
+ //normalize wrong formats
+ if (isset($params[$model . '_content'])) {
+ if (!array_is_list($params[$model . '_content'])) {
+ if (isset($params[$model . '_content']['content'])) {
+ $params[$model . '_content'] = [$params[$model . '_content']];
+ } else {
+ //some models add extra keys like item
+ $first = array_first($params[$model . '_content']);
+ if (isset($first['content'])) {
+ $params[$model . '_content'] = [$first];
+ }
+ }
+ }
+ foreach ($params[$model . '_content'] as &$content) {
+ if (!isset($content['slug']) && isset($content['name'])) {
+ $content['slug'] = slugify($content['name']);
+ }
+ if (is_array($content)) {
+ $content += ['language_id' => $this->global['language_id']];
+ }
+ }
+ }
+
+ if (($model === 'post' || $model === 'product') && !isset($params['site_id'])) {
+ $params['site_id'] = [$this->global['site_id']];
+ }
+
+ if ($operation == 'getAll') {
+ $params += ['start' => 0, 'limit' => 5];
+ }
+
+ if ($operation == 'add') {
+ foreach ($params as $param => &$value) {
+ //content expects a multi language array if only one language is provided add to list
+ if (str_ends_with($param, '_content')) {
+ if (!array_is_list($value)) {
+ $value = [$value];
+ }
+
+ foreach ($value as &$row) {
+ if (is_array($row) && !isset($row['slug']) && isset($row['name'])) {
+ $row['slug'] = slugify($row['name']);
+ }
+ }
+ unset($row);
+ }
+ }
+ }
+ //normalize wrong formats - end
+
+ $procParams = self::crudProcedures($sqlFile, false)[$operation] ?? [];
+ $params = self::crudCoerceArrayParams($procParams, $params);
+
+ //fail fast with the calling convention: add/edit nest the record
+ //under the first ARRAY parameter (usually the model name), never as
+ //flat fields. Without this a flat call dies deep in SQL with a
+ //cryptic error; the message below carries a working example instead.
+ //Runs before the db_write gate so agents get the shape fix first.
+ $shapeError = self::crudCheckRecordParam($model, $operation, $procParams, $params);
+
+ if ($shapeError !== null) {
+ throw new \InvalidArgumentException($shapeError);
+ }
+
+ //fail fast with guidance: missing must-supply params, misshapen
+ //rows and unknown row keys are rejected here, before the db_write
+ //gate, so agents get actionable errors instead of deep SQL failures.
+ $detailParams = self::crudProcedures($sqlFile)[$operation] ?? [];
+ $validateError = self::crudValidateParams($model, $operation, $detailParams, $params);
+
+ if ($validateError !== null) {
+ throw new \InvalidArgumentException($validateError);
+ }
+
+ if (in_array($operation, ['add', 'edit', 'delete'], true) && config('mcp.tools.db_write', false) !== true) {
+ throw new \McpToolError("Writes are disabled - enable mcp.tools.db_write to allow $operation on model $model.");
+ }
+
+ $modelObj = \Vvveb\model($model);
+
+ if (!method_exists($modelObj, $operation)) {
+ throw new \McpToolError("Operation '$operation' not available for model '$model'.");
+ }
+
+ if (isset($params[$model])) {
+ $params[$model] += $this->global;
+ }
+
+ $params += $this->global;
+
+ $result = $modelObj->{$operation}($params);
+
+ if ($columns !== [] && in_array($operation, ['get', 'getAll'], true)) {
+ $result = self::crudSelectColumns($result, $columns);
+ }
+
+ return ['model' => $model, 'operation' => $operation, 'result' => $result ?? []];
+ }
+
+ /**
+ * crud_models tool: discover available CRUD models and their procedures.
+ *
+ * Without a model argument lists every model with its procedure names and
+ * which of them are callable through the crud tool. With a model argument
+ * returns each procedure with its IN parameters and crud-callability, so
+ * agents know exactly what params an operation accepts. Read-only.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array<string, mixed>
+ */
+ public function toolCrudModels(array $args): array {
+ $rawModel = trim((string)($args['model'] ?? ''));
+
+ if ($rawModel === '') {
+ $models = [];
+
+ foreach (self::crudModels() as $name) {
+ $sqlFile = self::crudModelFile($name);
+ $procedures = $sqlFile ? array_keys(self::crudProcedures($sqlFile, false)) : [];
+ $models[] = [
+ 'model' => $name,
+ 'crud' => array_values(array_intersect(['get', 'getAll', 'add', 'edit', 'delete'], $procedures)),
+ 'procedures' => $procedures,
+ ];
+ }
+
+ return ['models' => $models, 'count' => count($models)];
+ }
+
+ $model = self::crudNormalizeModel($rawModel);
+ $sqlFile = self::crudModelFile($model);
+
+ if ($sqlFile === null) {
+ throw new \McpToolError("Unknown model: '$model'. Available models: " . implode(', ', self::crudModels()));
+ }
+
+ $crudOps = ['get', 'getAll', 'add', 'edit', 'delete'];
+ $procedures = [];
+
+ foreach (self::crudProcedures($sqlFile) as $name => $params) {
+ foreach ($params as &$entry) {
+ //internal validation aid, never part of the tool schema
+ unset($entry['columns']);
+ }
+ unset($entry);
+
+ $procedures[] = ['name' => $name, 'crud' => in_array($name, $crudOps, true), 'params' => $params];
+ }
+
+ return ['model' => $model, 'procedures' => $procedures];
+ }
+
+ /**
+ * Normalize a user supplied model name (trim, CamelCase to snake_case).
+ *
+ * @param string $rawModel
+ *
+ * @throws \InvalidArgumentException on empty or malformed names
+ */
+ private static function crudNormalizeModel(string $rawModel): string {
+ //accept CamelCase too (ProductOption -> product_option)
+ $model = strtolower((string)preg_replace('/(?<!^)[A-Z]/', '_$0', trim($rawModel)));
+
+ if ($model === '' || !preg_match('/^[a-z][a-z0-9_]*$/', $model)) {
+ throw new \InvalidArgumentException("Invalid model name: '$rawModel'");
+ }
+
+ return $model;
+ }
+
+ /**
+ * Resolve the .sql definition file for a normalized model name.
+ *
+ * Uses the current DB engine directory with fallback to the canonical
+ * mysqli definitions. Returns null when the model does not exist.
+ *
+ * @param string $model
+ */
+ private static function crudModelFile(string $model): ?string {
+ $engine = defined('DB_ENGINE') ? DB_ENGINE : 'mysqli';
+ $sqlFile = DIR_ROOT . '/admin/sql/' . $engine . '/' . $model . '.sql';
+
+ if (is_file($sqlFile)) {
+ return $sqlFile;
+ }
+
+ $sqlFile = DIR_ROOT . '/admin/sql/mysqli/' . $model . '.sql';
+
+ return is_file($sqlFile) ? $sqlFile : null;
+ }
+
+ /**
+ * Parse procedure names and IN params from a .sql definition file.
+ *
+ * With $detail, each IN param also reports whether it is must-supply
+ * (`required`) and, for ROW/ROWS record params, the accepted field names
+ * (`fields`). required is derived from the procedure body: a param used
+ * in unconditional SQL must be supplied, while @IF-guarded, loop-tolerant
+ * (@EACH) or unreferenced params are safely omittable. fields are the
+ *
+ * @FILTER table columns minus auto-increment keys and keys the procedure
+ * injects itself (e.g. post_id via @result.post).
+ *
+ * @param string $sqlFile
+ * @param bool $detail
+ *
+ * @return array<string, list<array{name: string, type: string, required?: bool, fields?: list<string>, required_fields?: list<string>, columns?: list<string>}>> procedure name to IN params
+ */
+ private static function crudProcedures(string $sqlFile, bool $detail = true): array {
+ static $cache = [];
+
+ $cacheKey = $sqlFile . ($detail ? '#detail' : '');
+
+ if (isset($cache[$cacheKey])) {
+ return $cache[$cacheKey];
+ }
+
+ $procedures = [];
+ $content = (string)@file_get_contents($sqlFile);
+
+ //SqlP strips -- comments before parsing; do the same so comment
+ //text never counts as a parameter reference.
+ $stripped = (string)preg_replace('/(--.*)\s+/', '', $content);
+
+ //declaration headers contain no nested parens, and the trailing
+ //\s*BEGIN anchor disambiguates the header's closing paren.
+ //The body runs to the first END not followed by @ (same as SqlP).
+ if (preg_match_all('/(CREATE\s+)?PROCEDURE\s+([A-Za-z0-9_]+)\s*\((.*?)\)\s*BEGIN\s*(.*?)\s*END(?!\s*@)/is', $stripped, $blocks, PREG_SET_ORDER)) {
+ foreach ($blocks as $block) {
+ $params = [];
+
+ if (preg_match_all('/\bIN\s+([A-Za-z0-9_]+)\s+([A-Za-z0-9_]+)/i', $block[3], $matches, PREG_SET_ORDER)) {
+ foreach ($matches as $match) {
+ $entry = ['name' => $match[1], 'type' => strtoupper($match[2])];
+
+ if ($detail) {
+ $entry['required'] = self::crudParamRequired($match[1], $block[4]);
+ $fieldInfo = self::crudParamFields($match[1], $entry['type'], $block[4]);
+
+ if ($fieldInfo !== null) {
+ $entry['fields'] = $fieldInfo['fields'];
+
+ if ($fieldInfo['required_fields'] !== []) {
+ $entry['required_fields'] = $fieldInfo['required_fields'];
+ }
+
+ //internal only: lenient edit checks need every table
+ //column, never emitted (stripped in toolCrudModels)
+ $entry['columns'] = $fieldInfo['columns'];
+ }
+ }
+
+ $params[] = $entry;
+ }
+ }
+
+ $procedures[$block[2]] = $params;
+ }
+ }
+
+ return $cache[$sqlFile . ($detail ? '#detail' : '')] = $procedures;
+ }
+
+ /**
+ * Whether an IN param must be supplied: referenced in unconditional SQL.
+ *
+ * Params used only inside @IF guards, tolerant @EACH loops or @FILTER
+ * preprocessing (or not referenced at all) are safely omittable.
+ * :ret aliases from `:ret = @FILTER(:param, ...)` count as the param.
+ *
+ * @param string $param
+ * @param string $body
+ */
+ private static function crudParamRequired(string $param, string $body): bool {
+ $flow = [$param];
+
+ if (preg_match_all('/:([A-Za-z0-9_\.]+)\s*=\s*@FILTER\s*\(\s*:([A-Za-z0-9_\.]+)\b/', $body, $m)) {
+ foreach ($m[2] as $i => $data) {
+ if ($data === $param) {
+ $flow[] = $m[1][$i];
+ }
+ }
+ }
+
+ $probe = $body;
+
+ //peel nested @IF...END @IF blocks (innermost first)
+ do {
+ $probe = (string)preg_replace('/@IF\b(?:(?!@IF).)*?END @IF/s', '', $probe, -1, $count);
+ } while ($count > 0);
+
+ /**
+ * @EACH headers are tolerant (isset + is_array guard), @FILTER
+ * calls are preprocessing - neither proves the param is needed
+ */
+ $probe = (string)preg_replace('/@EACH\s*\(\s*:[^)]+\)/', '', $probe);
+ $probe = (string)preg_replace('/:[A-Za-z0-9_\.]+\s*=\s*@FILTER\s*\([^()]*\)/', '', $probe);
+ $probe = (string)preg_replace('/@FILTER\s*\([^()]*\)/', '', $probe);
+
+ foreach ($flow as $var) {
+ if (preg_match('/:' . preg_quote($var, '/') . '(?!\w)/', $probe)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Accepted field names for a ROW/ROWS record param, or null.
+ *
+ * Tables come from @FILTER calls on the param (following renames) or,
+ * failing that, the INSERT target of its @EACH loop. Fields are table
+ * columns minus auto-increment keys and keys the procedure injects
+ * itself (siblings of @KEYS in INSERT column lists, e.g. post_id).
+ * Emitted only when the data is row-shaped (direct @KEYS/@LIST or a
+ * row-valued @EACH loop), so flat id lists never get fields.
+ *
+ * @param string $param
+ * @param string $type
+ * @param string $body
+ *
+ * @return array{fields: list<string>, required_fields: list<string>, columns: list<string>}|null
+ * null when no table resolves; required_fields lists fields with
+ * no usable default, i.e. omitting them fails the INSERT.
+ */
+ private static function crudParamFields(string $param, string $type, string $body): ?array {
+ $flow = [$param];
+
+ if (preg_match_all('/:([A-Za-z0-9_\.]+)\s*=\s*@FILTER\s*\(\s*:([A-Za-z0-9_\.]+)\b/', $body, $m)) {
+ foreach ($m[2] as $i => $data) {
+ if ($data === $param) {
+ $flow[] = $m[1][$i];
+ }
+ }
+ }
+
+ $tables = [];
+
+ if (preg_match_all('/@FILTER\s*\(\s*:([A-Za-z0-9_\.]+)\s*,\s*([A-Za-z_]+)/', $body, $fm, PREG_SET_ORDER)) {
+ foreach ($fm as $f) {
+ //dotted children (:order.products) belong to sub-lists, not this param
+ if (in_array($f[1], $flow, true) && !in_array($f[2], $tables, true)) {
+ $tables[] = $f[2];
+ }
+ }
+ }
+
+ $rowShaped = false;
+ $loopTables = [];
+
+ foreach ($flow as $var) {
+ if (preg_match('/@(KEYS|LIST)\s*\(\s*:' . preg_quote($var, '/') . '(?!\w)/', $body)) {
+ $rowShaped = true;
+
+ break;
+ }
+ }
+
+ foreach (explode(';', $body) as $stmt) {
+ if (!preg_match('/@EACH\s*\(\s*:([A-Za-z0-9_\.]+)\s*\)/', $stmt, $em) || !in_array($em[1], $flow, true)) {
+ continue;
+ }
+
+ $hasKeys = (bool)preg_match('/@KEYS\s*\(\s*:each(?!\w)/', $stmt);
+ $hasList = (bool)preg_match('/@LIST\s*\(\s*:each(?!\w)/', $stmt) && (bool)preg_match('/:each\.\w+/', $stmt);
+
+ if ($hasKeys || $hasList) {
+ $rowShaped = true;
+
+ if (preg_match('/INSERT\s+INTO\s+["`]?([A-Za-z_][\w]*)["`]?/i', $stmt, $im) && !in_array($im[1], $loopTables, true)) {
+ $loopTables[] = $im[1];
+ }
+ }
+ }
+
+ if (!$rowShaped) {
+ return null;
+ }
+
+ if (!$tables && $loopTables) {
+ $tables = $loopTables;
+ }
+
+ if (!$tables) {
+ return null;
+ }
+
+ //columns the procedure supplies itself: siblings of @KEYS(...)
+ //in INSERT column lists - rows must not (re)supply them
+ $extras = [];
+
+ if (preg_match_all('/\(\s*@KEYS\s*\([^)]+\)([^()]*)\)/', $body, $km, PREG_SET_ORDER)) {
+ foreach ($km as $k) {
+ if (preg_match_all('/[`"]?([A-Za-z_][\w]*)[`"]?/', $k[1], $cm)) {
+ foreach ($cm[1] as $col) {
+ $extras[$col] = true;
+ }
+ }
+ }
+ }
+
+ $fields = [];
+ $requiredFields = [];
+ $columns = [];
+
+ foreach ($tables as $table) {
+ foreach (self::crudTableColumns($table) as $name => $col) {
+ if (!in_array($name, $columns, true)) {
+ $columns[] = $name;
+ }
+
+ if (isset($extras[$name]) || self::crudIsAutoColumn($col)) {
+ continue;
+ }
+
+ if (!in_array($name, $fields, true)) {
+ $fields[] = $name;
+
+ if (self::crudIsRequiredColumn($col)) {
+ $requiredFields[] = $name;
+ }
+ }
+ }
+ }
+
+ return $fields === [] ? null : ['fields' => $fields, 'required_fields' => $requiredFields, 'columns' => $columns];
+ }
+
+ /**
+ * Live column metadata for a table, keyed by column name.
+ *
+ * Same source @FILTER enforces against, so listed fields can never
+ * disagree with filtering. Empty when the table is unavailable.
+ *
+ * @param string $table
+ *
+ * @return array<string, array<string, mixed>>
+ */
+ private static function crudTableColumns(string $table): array {
+ static $cache = [];
+
+ if (array_key_exists($table, $cache)) {
+ return $cache[$table];
+ }
+
+ $columns = [];
+
+ try {
+ $prefix = defined('DB_PREFIX') ? DB_PREFIX : 'vvveb_';
+ $meta = Db::getInstance()->getColumnsMeta($prefix . $table);
+
+ if (is_array($meta)) {
+ foreach ($meta as $key => $col) {
+ if (is_array($col)) {
+ $columns[$col['name'] ?? $key] = $col;
+ }
+ }
+ }
+ } catch (\Throwable) {
+ //uninstalled plugin tables and the like: no fields
+ }
+
+ return $cache[$table] = $columns;
+ }
+
+ /**
+ * Whether a metadata column is auto-assigned on insert (and agents
+ * must therefore not supply it): mysqli EXTRA flag, pgsql serial
+ * nextval() defaults, sqlite INTEGER PRIMARY KEY rowid aliases
+ * (nullable, default-less INT columns).
+ *
+ * @param array<string, mixed> $col
+ */
+ private static function crudIsAutoColumn(array $col): bool {
+ //mysqli INFORMATION_SCHEMA EXTRA flag
+ if (($col['e'] ?? '') === 'auto_increment') {
+ return true;
+ }
+
+ //pgsql serial columns default to nextval(...)
+ if (str_starts_with((string)($col['d'] ?? ''), 'nextval')) {
+ return true;
+ }
+
+ //sqlite getColumnsMeta() exposes no pk/extra flags: an INTEGER
+ //PRIMARY KEY is a rowid alias (auto-assigned, pragma notnull = 0).
+ //Nullable default-less INTs also match, which is harmless - omitting
+ //a nullable column is always safe.
+ if (defined('DB_ENGINE') && DB_ENGINE === 'sqlite') {
+ $type = strtoupper((string)($col['t'] ?? ''));
+ $default = $col['d'] ?? null;
+
+ return str_contains($type, 'INT') && ($col['n'] ?? 1) == 0 && ($default === null || $default === '');
+ }
+
+ return false;
+ }
+
+ /**
+ * Whether omitting the column fails the INSERT: NOT NULL with no
+ * usable default (any non-null default, including '' or 0, fills the
+ * column safely). Nullability flags differ per driver (YES/NO strings
+ * vs sqlite pragma 0/1), normalized here.
+ *
+ * @param array<string, mixed> $col
+ */
+ private static function crudIsRequiredColumn(array $col): bool {
+ $n = $col['n'] ?? null;
+
+ if (defined('DB_ENGINE') && DB_ENGINE === 'sqlite') {
+ $nullable = ($n == 0);
+ } else {
+ $nullable = in_array($n, ['YES', 'yes', true, 1, '1'], true);
+ }
+
+ if ($nullable) {
+ return false;
+ }
+
+ return !array_key_exists('d', $col) || $col['d'] === null;
+ }
+
+ /**
+ * Wrap scalar values for declared ARRAY IN params in a one-item list, so
+ * delete with {"post_id": 5} or a single taxonomy id just works instead
+ * of failing inside SQL iteration. A single row object for a ROWS list
+ * param wraps the same way (one assoc becomes a one-row list). Arrays
+ * and objects pass through untouched; only real scalars are wrapped.
+ *
+ * @param list<array{name: string, type: string}> $procParams
+ * @param array<array-key, mixed> $params
+ *
+ * @return array<string, mixed>
+ */
+ private static function crudCoerceArrayParams(array $procParams, array $params): array {
+ foreach ($procParams as $p) {
+ $name = $p['name'];
+
+ if (!isset($params[$name])) {
+ continue;
+ }
+
+ $type = strtoupper($p['type']);
+
+ if ($type === 'ARRAY' && is_scalar($params[$name])) {
+ $params[$name] = [$params[$name]];
+ } elseif ($type === 'ROWS' && is_array($params[$name]) && !array_is_list($params[$name])) {
+ $params[$name] = [$params[$name]];
+ }
+ }
+
+ return $params;
+ }
+
+ /**
+ * Validate params against the procedure contract before any write.
+ *
+ * Missing must-supply params, misshapen rows and unknown row keys are
+ * rejected here with guidance instead of dying deep in SQL (silent
+ *
+ * @FILTER drops, NULL-bound filters) or corrupting data (stale ids in
+ * auto-managed keys). Unknown keys on edit rows are checked leniently
+ * against all table columns, since echoing keys back is harmless there;
+ * on add only accepted fields pass. Row required_fields apply to add
+ * only - edits merge, so partial rows are fine. Returns a guidance
+ * message when the call must not proceed, null otherwise.
+ *
+ * @param string $model
+ * @param string $operation
+ * @param list<array{name: string, type: string, required?: bool, fields?: list<string>, required_fields?: list<string>, columns?: list<string>}> $procParams
+ * @param array<array-key, mixed> $params
+ */
+ private static function crudValidateParams(string $model, string $operation, array $procParams, array $params): ?string {
+ foreach ($procParams as $p) {
+ $name = $p['name'];
+
+ if ($name === '' || empty($p['required'])) {
+ continue;
+ }
+
+ if (!array_key_exists($name, $params) || $params[$name] === null || $params[$name] === '') {
+ return "Missing required param '$name' for crud $operation on model '$model'. " .
+ 'Omit optional params you have no value for instead of sending empty strings; ' .
+ "call crud_models with {\"model\":\"$model\"} for the full contract.";
+ }
+ }
+
+ foreach ($procParams as $p) {
+ $name = $p['name'];
+ $type = strtoupper($p['type']);
+
+ if ($name === '' || ($type !== 'ROW' && $type !== 'ROWS') || !array_key_exists($name, $params)) {
+ continue;
+ }
+
+ $value = $params[$name];
+
+ if (!is_array($value)) {
+ $want = $type === 'ROWS' ? 'a list of row objects' : 'a single row object';
+
+ return "Invalid '$name' for crud $operation on model '$model': must be $want, got " . gettype($value) . '. ' .
+ "Call crud_models with {\"model\":\"$model\"} for the full contract.";
+ }
+
+ if ($type === 'ROW' && array_is_list($value)) {
+ return "Invalid '$name' for crud $operation on model '$model': must be a single row object, not a list. " .
+ "Call crud_models with {\"model\":\"$model\"} for the full contract.";
+ }
+
+ $rows = $type === 'ROWS' ? array_values($value) : [$value];
+ $fields = $p['fields'] ?? null;
+ $strict = $operation === 'add';
+ $known = $strict ? $fields : ($p['columns'] ?? $fields);
+
+ foreach ($rows as $row) {
+ if (!is_array($row)) {
+ return "Invalid '$name' for crud $operation on model '$model': each row must be an object. " .
+ "Call crud_models with {\"model\":\"$model\"} for the full contract.";
+ }
+
+ if (is_array($known)) {
+ foreach (array_keys($row) as $key) {
+ if (is_string($key) && !in_array($key, $known, true)) {
+ return self::crudUnknownFieldMessage($model, $operation, $name, (string)$key, $known, $fields, $p['columns'] ?? $fields);
+ }
+ }
+ }
+
+ if ($strict && !empty($p['required_fields'])) {
+ $absent = array_diff($p['required_fields'], array_keys($row));
+
+ //the tool slugifies name into slug on add, so a
+ //missing slug is satisfied by a present name
+ if ($absent !== [] && in_array('slug', $absent, true) && !empty($row['name'])) {
+ $absent = array_diff($absent, ['slug']);
+ }
+
+ if ($absent !== []) {
+ return "Missing required field(s) '" . implode(', ', $absent) . "' in '$name' rows for crud $operation on model '$model'. " .
+ 'Accepted fields: ' . implode(', ', (array)$fields) . '. ' .
+ "Call crud_models with {\"model\":\"$model\"} for the full contract.";
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Guidance message for an unknown row key: auto-managed keys must be
+ * omitted, otherwise suggest the closest accepted field.
+ *
+ * @param string $model
+ * @param string $operation
+ * @param string $param
+ * @param string $key
+ * @param list<string>|null $known
+ * @param list<string>|null $fields
+ * @param list<string>|null $columns
+ */
+ private static function crudUnknownFieldMessage(string $model, string $operation, string $param, string $key, ?array $known, ?array $fields, ?array $columns = null): string {
+ if (is_array($fields) && !in_array($key, $fields, true) && in_array($key, $columns ?? [], true)) {
+ return "Invalid field '$key' in '$param' rows for crud $operation on model '$model': auto-managed keys must be omitted, the procedure supplies them. " .
+ 'Accepted fields: ' . implode(', ', $fields) . '. ' .
+ "Call crud_models with {\"model\":\"$model\"} for the full contract.";
+ }
+
+ $best = null;
+ $bestDist = 4;
+
+ if (is_array($known)) {
+ foreach ($known as $candidate) {
+ $dist = levenshtein($key, (string)$candidate);
+
+ if ($dist < $bestDist) {
+ $bestDist = $dist;
+ $best = $candidate;
+ }
+ }
+ }
+
+ $hint = ($best !== null) ? " Did you mean '$best'?" : '';
+ $list = is_array($known) ? (' Accepted fields: ' . implode(', ', $known) . '.') : '';
+
+ return "Unknown field '$key' in '$param' rows for crud $operation on model '$model'." . $hint . $list . ' ' .
+ "Call crud_models with {\"model\":\"$model\"} for the full contract.";
+ }
+
+ /**
+ * Verify the add/edit record shape: the record must sit under the first
+ * ARRAY IN parameter (conventionally the model name: post, product,
+ * currency, ...; exceptions like filter->attribute or
+ * order_shipment->shipment follow the same rule via their own first
+ * ARRAY param). Returns a guidance message with a working example when
+ * the shape is wrong, null when the call may proceed. Read operations
+ * and procedures without ARRAY params are never rejected here.
+ *
+ * @param string $model
+ * @param string $operation
+ * @param list<array{name: string, type: string}> $procParams
+ * @param array<array-key, mixed> $params
+ */
+ private static function crudCheckRecordParam(string $model, string $operation, array $procParams, array $params): ?string {
+ if (!in_array($operation, ['add', 'edit'], true)) {
+ return null;
+ }
+
+ //record params are typed ROW (single) or ROWS (list); some older
+ //models type the record ARRAY, in which case scalar id lists
+ //(taxonomy_item_id, site_id, ...) must not match - they end in _id
+ $recordKey = null;
+
+ foreach ($procParams as $p) {
+ $type = strtoupper($p['type']);
+ $name = $p['name'];
+
+ if ($name === '' || ($type !== 'ROW' && $type !== 'ROWS' && $type !== 'ARRAY')) {
+ continue;
+ }
+
+ if ($type === 'ARRAY' && preg_match('/_id$/', $name)) {
+ continue;
+ }
+
+ $recordKey = $name;
+
+ break;
+ }
+
+ if ($recordKey === null || (isset($params[$recordKey]) && is_array($params[$recordKey]))) {
+ return null;
+ }
+
+ $example = ['model' => $model, 'operation' => $operation, 'params' => [$recordKey => ['slug' => 'hello', 'status' => 1]]];
+
+ foreach ($procParams as $p) {
+ if ($p['name'] === $model . '_content') {
+ $example['params'][$model . '_content'] = [['name' => 'Hello', 'content' => '...', 'language_id' => 1]];
+
+ break;
+ }
+ }
+
+ return "Invalid params for crud $operation on model '$model': the record must be nested under the '$recordKey' key, not passed as flat fields. " .
+ 'Example: ' . json_encode($example) . '. ' .
+ "Use crud_models with {\"model\":\"$model\"} for every accepted parameter (language_id/site_id default to 1); " .
+ "record field names are table columns - inspect them read-only via database_query, e.g. {\"query\":\"DESCRIBE $model\"}.";
+ }
+
+ /**
+ * List available CRUD model names (basenames of admin/sql/mysqli/*.sql).
+ *
+ * @return list<string>
+ */
+ private static function crudModels(): array {
+ $models = [];
+
+ foreach (glob(DIR_ROOT . '/admin/sql/mysqli/*.sql') ?: [] as $file) {
+ $models[] = basename($file, '.sql');
+ }
+
+ sort($models);
+
+ return $models;
+ }
+
+ /**
+ * admin tool: unified dispatcher for subsystem CRUD stubs.
+ *
+ * Routes to the themes/plugins/media/cron/cache stubs by target, passing
+ * all other arguments through. Keeps the tool registry small while each
+ * stub keeps its own per-operation validation.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array<string, mixed>
+ */
+ public function toolAdmin(array $args): array {
+ $target = trim((string)($args['target'] ?? ''));
+
+ //media stays callable here as a deprecated alias (top-level media
+ //tool is advertised instead); the admin schema no longer lists it.
+ $stubs = [
+ 'themes' => 'toolThemes',
+ 'plugins' => 'toolPlugins',
+ 'media' => 'toolMedia',
+ 'cron' => 'toolCron',
+ 'cache' => 'toolCache',
+ ];
+
+ if (!isset($stubs[$target])) {
+ throw new \InvalidArgumentException("Invalid target '$target' for tool 'admin'. Allowed: " . implode(', ', array_keys($stubs)));
+ }
+
+ $method = $stubs[$target];
+ $result = $this->$method($args);
+
+ return ['target' => $target] + $result;
+ }
+
+ /**
+ * Search the marketplace feed for themes or plugins.
+ *
+ * @param class-string $class Themes/Plugins extension class
+ * @param string $kind theme|plugin (selects slug argument and result key)
+ * @param array<string, mixed> $args
+ * @param array<string, mixed> $installed locally installed items keyed by slug
+ *
+ * @return array<string, mixed>
+ */
+ private function marketSearch(string $class, string $kind, array $args, array $installed): array {
+ $listKey = $kind . 's'; // themes|plugins
+ $query = [];
+
+ foreach (['search', 'category'] as $key) {
+ $value = trim((string)($args[$key] ?? ''));
+
+ if ($value !== '') {
+ $query[$key] = $value;
+ }
+ }
+
+ $slug = trim((string)($args[$kind] ?? ''));
+
+ if ($slug !== '') {
+ $query['slug'] = $slug;
+ }
+
+ $query['start'] = max(1, (int)($args['start'] ?? 1));
+ $query['limit'] = max(1, min(50, (int)($args['limit'] ?? 10)));
+
+ $result = $class::getMarketList($query);
+
+ if ($result === []) {
+ throw new \RuntimeException('Error contacting the marketplace feed');
+ }
+
+ $items = $result[$listKey] ?? [];
+
+ foreach ($items as &$item) {
+ $item['installed'] = isset($installed[$item['slug'] ?? '']);
+ }
+ unset($item);
+
+ return ['operation' => 'market', $listKey => $items, 'count' => $result['count'] ?? count($items)];
+ }
+
+ /**
+ * Install a theme or plugin from the marketplace by slug.
+ *
+ * Mirrors the admin Market controllers: look the slug up in the market
+ * feed, download the zip, install it and clear the list cache. Requires
+ * config key mcp.tools.db_write.
+ *
+ * @param class-string $class Themes/Plugins extension class
+ * @param string $kind theme|plugin
+ * @param string $slug
+ * @param int $siteId
+ *
+ * @return array<string, mixed>
+ */
+ private function marketInstall(string $class, string $kind, string $slug, int $siteId): array {
+ if (config('mcp.tools.db_write', false) !== true) {
+ throw new \McpToolError("Writes are disabled - enable mcp.tools.db_write to allow install on $kind $slug.");
+ }
+
+ $listKey = $kind . 's'; // themes|plugins
+ $list = $class::getMarketList(['slug' => $slug]);
+
+ if ($list === []) {
+ throw new \RuntimeException('Error contacting the marketplace feed');
+ }
+
+ $items = $list[$listKey] ?? [];
+
+ if (!$items || !isset($items[0])) {
+ throw new \RuntimeException("Extension '$slug' not found in the marketplace");
+ }
+
+ $info = $items[0];
+
+ if (empty($info['download_link'])) {
+ throw new \RuntimeException("Extension '$slug' has no download link in the marketplace");
+ }
+
+ $downloadLink = $class::marketUrl() . $info['download_link'];
+ $tempFile = $class::download($downloadLink);
+
+ if (!$tempFile) {
+ throw new \RuntimeException("Error downloading '$slug' from $downloadLink");
+ }
+
+ try {
+ //themes skip zip validation like the admin theme market controller
+ $installed = $kind === 'theme' ? $class::install($tempFile, $slug, false) : $class::install($tempFile, $slug);
+
+ if (!$installed) {
+ throw new \RuntimeException("Error installing '$slug'");
+ }
+
+ \Vvveb\System\CacheManager::clearObjectCache('vvveb', "{$listKey}_list_$siteId");
+ } finally {
+ @unlink($tempFile);
+ }
+
+ return ['operation' => 'install', $kind => $slug, 'name' => $info['name'] ?? $slug, 'success' => true];
+ }
+
+ /**
+ * Slim extension rows for list operations: slug, name and description
+ * only. Full headers (author, license, version, paths) stay available
+ * through the get operation. Map keys preserved. Pure, tested.
+ *
+ * @param array<array-key, mixed> $items
+ *
+ * @return array<string, array{slug: string, name: string, description: string, active?: bool}>
+ */
+ private static function slimExtensionList(array $items): array {
+ $out = [];
+ foreach ($items as $slug => $item) {
+ if (!is_array($item)) {
+ continue;
+ }
+ $slug = (string)($item['slug'] ?? $slug);
+ $row = [
+ 'slug' => $slug,
+ 'name' => (string)($item['name'] ?? $slug),
+ 'description' => (string)($item['description'] ?? ''),
+ ];
+ if (!empty($item['active'])) {
+ $row['active'] = true;
+ }
+ $out[$slug] = $row;
+ }
+
+ return $out;
+ }
+
+ /**
+ * Themes stub (via admin tool): CRUD for CMS themes (public/themes/<slug>).
+ *
+ * Thin wrappers around Themes::getList and Sites::setTheme: list/get are
+ * always allowed; activate/delete require config key mcp.tools.db_write.
+ * Delete refuses the active theme.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array<string, mixed>
+ */
+ private function toolThemes(array $args): array {
+ $operation = trim((string)($args['operation'] ?? ''));
+ $rawTheme = trim((string)($args['theme'] ?? ''));
+ $siteId = (int)($args['site_id'] ?? $this->global['site_id'] ?? 1);
+
+ $allowedOps = ['list', 'get', 'market', 'activate', 'install', 'delete'];
+
+ if (!in_array($operation, $allowedOps, true)) {
+ throw new \InvalidArgumentException("Invalid operation '$operation' for tool 'themes'. Allowed: " . implode(', ', $allowedOps));
+ }
+
+ if (in_array($operation, ['get', 'activate', 'install', 'delete'], true) && $rawTheme === '') {
+ throw new \InvalidArgumentException("Missing required argument 'theme' for tool 'themes' operation '$operation'");
+ }
+
+ if ($rawTheme !== '' && !preg_match('/^[A-Za-z0-9_-]+$/', $rawTheme)) {
+ throw new \InvalidArgumentException("Invalid theme name: '$rawTheme'");
+ }
+
+ $theme = \Vvveb\sanitizeFileName(basename($rawTheme));
+ $themes = \Vvveb\System\Extensions\Themes::getList($siteId, false);
+ $active = \Vvveb\System\Sites::getTheme($siteId);
+
+ if ($operation === 'list') {
+ $slim = self::slimExtensionList($themes);
+
+ return ['operation' => $operation, 'themes' => $slim, 'active' => $active, 'count' => count($slim)];
+ }
+
+ if (in_array($operation, ['get', 'activate', 'delete'], true) && !isset($themes[$theme])) {
+ throw new \McpToolError("Unknown theme: '$theme'. Available themes: " . implode(', ', array_keys($themes)));
+ }
+
+ if ($operation === 'get') {
+ return ['operation' => $operation, 'theme' => $theme, 'info' => $themes[$theme], 'active' => $active];
+ }
+
+ if ($operation === 'market') {
+ return $this->marketSearch(\Vvveb\System\Extensions\Themes::class, 'theme', $args, $themes);
+ }
+
+ if (config('mcp.tools.db_write', false) !== true) {
+ throw new \McpToolError("Writes are disabled - enable mcp.tools.db_write to allow $operation on theme $theme.");
+ }
+
+ if ($operation === 'activate') {
+ if (!\Vvveb\System\Sites::setTheme($siteId, $theme, 'index.html')) {
+ throw new \RuntimeException("Error activating theme '$theme'");
+ }
+
+ \Vvveb\System\CacheManager::clearObjectCache('site');
+ \Vvveb\System\CacheManager::clearFrontend();
+ \Vvveb\System\CacheManager::clearCompiledFiles();
+ \Vvveb\System\CacheManager::clearPageCache();
+
+ return ['operation' => $operation, 'theme' => $theme, 'active' => $theme, 'success' => true];
+ }
+
+ if ($operation === 'install') {
+ return $this->marketInstall(\Vvveb\System\Extensions\Themes::class, 'theme', $theme, $siteId);
+ }
+
+ if ($theme === $active) {
+ throw new \McpToolError("Refusing to delete the active theme '$theme'. Activate another theme first.");
+ }
+
+ $dir = DIR_THEMES . $theme;
+
+ if (!is_dir($dir) || !rrmdir($dir)) {
+ throw new \RuntimeException("Error removing theme '$theme'");
+ }
+
+ \Vvveb\System\Extensions\Themes::clearThemesCache($siteId);
+
+ return ['operation' => $operation, 'theme' => $theme, 'success' => true];
+ }
+
+ /**
+ * Plugins stub (via admin tool): CRUD for CMS plugins (plugins/<slug>).
+ *
+ * Thin wrappers around Plugins::getList/activate/deactivate/uninstall:
+ * list/get are always allowed; activate/deactivate/uninstall require
+ * config key mcp.tools.db_write.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array<string, mixed>
+ */
+ private function toolPlugins(array $args): array {
+ $operation = trim((string)($args['operation'] ?? ''));
+ $plugin = trim((string)($args['plugin'] ?? ''));
+ $category = trim((string)($args['category'] ?? ''));
+ $siteId = (int)($args['site_id'] ?? $this->global['site_id'] ?? 1);
+
+ $allowedOps = ['list', 'get', 'market', 'activate', 'deactivate', 'install', 'uninstall'];
+
+ if (!in_array($operation, $allowedOps, true)) {
+ throw new \InvalidArgumentException("Invalid operation '$operation' for tool 'plugins'. Allowed: " . implode(', ', $allowedOps));
+ }
+
+ if (!in_array($operation, ['list', 'market'], true) && $plugin === '') {
+ throw new \InvalidArgumentException("Missing required argument 'plugin' for tool 'plugins' operation '$operation'");
+ }
+
+ if ($plugin !== '' && !preg_match('/^[A-Za-z0-9_-]+$/', $plugin)) {
+ throw new \InvalidArgumentException("Invalid plugin name: '$plugin'");
+ }
+
+ $plugins = \Vvveb\System\Extensions\Plugins::getList($siteId, $category !== '' ? $category : false, false);
+
+ if ($operation === 'list') {
+ $slim = self::slimExtensionList($plugins);
+
+ return ['operation' => $operation, 'plugins' => $slim, 'count' => count($slim)];
+ }
+
+ if (!in_array($operation, ['market', 'install'], true) && !isset($plugins[$plugin])) {
+ throw new \McpToolError("Unknown plugin: '$plugin'. Available plugins: " . implode(', ', array_keys($plugins)));
+ }
+
+ if ($operation === 'get') {
+ return ['operation' => $operation, 'plugin' => $plugin, 'info' => $plugins[$plugin]];
+ }
+
+ if ($operation === 'market') {
+ return $this->marketSearch(\Vvveb\System\Extensions\Plugins::class, 'plugin', $args, $plugins);
+ }
+
+ if (config('mcp.tools.db_write', false) !== true) {
+ throw new \McpToolError("Writes are disabled - enable mcp.tools.db_write to allow $operation on plugin $plugin.");
+ }
+
+ if ($operation === 'install') {
+ return $this->marketInstall(\Vvveb\System\Extensions\Plugins::class, 'plugin', $plugin, $siteId);
+ }
+
+ if ($operation === 'activate') {
+ if (!\Vvveb\System\Extensions\Plugins::activate($plugin, $siteId)) {
+ throw new \RuntimeException("Error activating plugin '$plugin'");
+ }
+
+ \Vvveb\System\CacheManager::clearObjectCache('admin-menu');
+ \Vvveb\System\CacheManager::clearCompiledFiles();
+ \Vvveb\System\CacheManager::clearPageCache();
+
+ return ['operation' => $operation, 'plugin' => $plugin, 'success' => true];
+ }
+
+ if ($operation === 'deactivate') {
+ if (!\Vvveb\System\Extensions\Plugins::deactivate($plugin, $siteId)) {
+ throw new \RuntimeException("Error deactivating plugin '$plugin'");
+ }
+
+ \Vvveb\System\CacheManager::clearObjectCache('admin-menu');
+ \Vvveb\System\CacheManager::clearCompiledFiles();
+ \Vvveb\System\CacheManager::clearPageCache();
+
+ return ['operation' => $operation, 'plugin' => $plugin, 'success' => true];
+ }
+
+ if (!\Vvveb\System\Extensions\Plugins::uninstall($plugin, $siteId)) {
+ throw new \RuntimeException("Error removing plugin '$plugin'");
+ }
+
+ return ['operation' => $operation, 'plugin' => $plugin, 'success' => true];
+ }
+
+ /**
+ * Normalize caller-supplied media metadata into model rows.
+ *
+ * Accepts a single flat row (e.g. `['caption' => 'x']`), a list of
+ * rows, or a language-keyed map (e.g. `[1 => ['caption' => 'x']]`)
+ * and returns a list of rows each carrying a language_id and a name
+ * default derived from the file base name via humanReadable.
+ *
+ * @param string $file Media-relative file path.
+ * @param array<array-key, mixed> $content Raw metadata.
+ *
+ * @return list<array<string, mixed>> Normalized rows.
+ */
+ private function normalizeMediaContentRows(string $file, array $content): array {
+ $languageId = $this->global['language_id'] ?? $this->global['default_language_id'] ?? 1;
+ $defaultName = humanReadable((string)pathinfo(str_replace('\\', '/', $file), PATHINFO_FILENAME));
+
+ $isRowList = false;
+
+ foreach ($content as $value) {
+ if (is_array($value)) {
+ $isRowList = true;
+
+ break;
+ }
+ }
+
+ if ($isRowList) {
+ $rows = [];
+
+ foreach ($content as $key => $row) {
+ if (!is_array($row)) {
+ continue;
+ }
+
+ if (!isset($row['language_id'])) {
+ $row['language_id'] = (is_int($key) && $key > 0 && $key < 10000) ? $key : $languageId;
+ }
+
+ if (!isset($row['name']) || $row['name'] === '') {
+ $row['name'] = $defaultName;
+ }
+
+ $rows[] = $row;
+ }
+
+ if ($rows !== []) {
+ return $rows;
+ }
+ }
+
+ if (!$isRowList) {
+ $row = $content;
+
+ if (!isset($row['language_id'])) {
+ $row['language_id'] = $languageId;
+ }
+
+ if (!isset($row['name']) || $row['name'] === '') {
+ $row['name'] = $defaultName;
+ }
+
+ return [$row];
+ }
+
+ return [['name' => $defaultName, 'language_id' => $languageId]];
+ }
+
+ /**
+ * Upsert a media library metadata record by file path.
+ *
+ * Shared by the save operation and uploads carrying metadata. New
+ * records fall back to the file base name run through humanReadable
+ * when the caller supplies no explicit name.
+ *
+ * @param string $file Media-relative file path.
+ * @param array<string, mixed> $content Metadata key/value pairs.
+ * @param string|null $type MIME type for new records.
+ *
+ * @return mixed[] Model result.
+ */
+ private function upsertMediaContentRecord(string $file, array $content, ?string $type = null): array {
+ $media = \Vvveb\model('media_content');
+ $existing = $media->get(['file' => $file] + $this->global);
+ $rows = $this->normalizeMediaContentRows($file, $content);
+
+ if ($existing) {
+ $result = $media->edit(['media_id' => $existing['media_id'], 'media_content' => $rows, 'media' => []]);
+ } else {
+ $mediaRow = ['file' => $file];
+
+ if ($type !== null && $type !== '') {
+ $mediaRow['type'] = $type;
+ }
+
+ $result = $media->add(['media' => $mediaRow, 'media_content' => $rows]);
+ }
+
+ return $result ?? [];
+ }
+
+ /**
+ * Cap for decoded upload bytes: the lower of the MCP cap and the server
+ * upload_max_filesize, checked on the base64 length before allocating.
+ */
+ private function mediaUploadByteCap(): int {
+ try {
+ $serverMax = \Vvveb\parseQuantity((string)ini_get('upload_max_filesize'));
+ } catch (\Throwable $e) {
+ $serverMax = 0;
+ }
+
+ if ($serverMax > 0) {
+ return min(self::MEDIA_UPLOAD_MAX_BYTES, (int)$serverMax);
+ }
+
+ return self::MEDIA_UPLOAD_MAX_BYTES;
+ }
+
+ /**
+ * Store a base64 upload: decode to temp, run the shared file core for
+ * the full validation chain, then register the library metadata record
+ * (file base name via humanReadable, caller content merged on top).
+ *
+ * @param array<string, mixed> $args Tool arguments.
+ *
+ * @return mixed[] Upload result plus metadata record result.
+ */
+ private function toolMediaUpload(array $args): array {
+ $fileName = trim((string)($args['file_name'] ?? ''));
+ $data = (string)($args['data'] ?? '');
+ $path = trim((string)($args['path'] ?? ''));
+
+ if ($fileName === '') {
+ throw new \InvalidArgumentException("Missing required argument 'file_name' for tool 'media' operation 'upload'");
+ }
+
+ if ($data === '') {
+ throw new \InvalidArgumentException("Missing required argument 'data' (base64 file bytes) for tool 'media' operation 'upload'");
+ }
+
+ $cap = $this->mediaUploadByteCap();
+
+ if ((int)(strlen($data) * 3 / 4) > $cap) {
+ throw new \McpToolError('Upload exceeds the media tool cap, use a smaller file or url import.');
+ }
+
+ $bytes = base64_decode($data, true);
+
+ if ($bytes === false) {
+ throw new \InvalidArgumentException("Invalid argument 'data' for tool 'media' operation 'upload': not valid base64");
+ }
+
+ if (strlen($bytes) > $cap) {
+ throw new \McpToolError('Upload exceeds the media tool cap, use a smaller file or url import.');
+ }
+
+ $tmp = tempnam(sys_get_temp_dir(), 'mcp-upload-');
+
+ if ($tmp === false || file_put_contents($tmp, $bytes) === false) {
+ @unlink((string)$tmp);
+
+ throw new \RuntimeException('Could not stage upload for processing.');
+ }
+
+ $byteLen = strlen($bytes);
+ unset($bytes, $data);
+
+ try {
+ $stored = $this->storeMediaFile($tmp, $fileName, $path, [
+ 'overwrite' => (bool)($args['overwrite'] ?? false),
+ 'size' => $byteLen,
+ ]);
+ } finally {
+ @unlink($tmp);
+ }
+
+ if (!$stored['success']) {
+ return $stored;
+ }
+
+ $content = $args['media_content'] ?? null;
+
+ if (is_array($content) && $content !== []) {
+ $stored['record'] = $this->upsertMediaContentRecord($stored['file'], $content);
+ } else {
+ $stored['record'] = $this->createMediaRecord($stored['file']);
+ }
+
+ return $stored;
+ }
+
+ /**
+ * Fetch a remote file by URL into the media library: download with
+ * redirect/SSRF/size/type guards to temp, then run the exact same tail
+ * as upload (storeMediaFile validation chain plus metadata record).
+ * Sits behind the media db_write gate like upload.
+ *
+ * @param array<string, mixed> $args Tool arguments.
+ *
+ * @return mixed[] Stored-file result plus source info and optional record.
+ */
+ private function toolMediaFetch(array $args): array {
+ $url = trim((string)($args['url'] ?? ''));
+ $path = trim((string)($args['path'] ?? ''));
+ $given = trim((string)($args['file_name'] ?? ''));
+
+ if ($url === '') {
+ throw new \InvalidArgumentException("Missing required argument 'url' for tool 'media' operation 'fetch'");
+ }
+
+ $storedCap = $this->mediaUploadByteCap();
+ $transferCap = $storedCap * 4;
+ $dl = $this->mediaFetchDownload($url, $transferCap, $storedCap);
+
+ $fileName = self::mediaFetchFileName($given !== '' ? $given : null, $dl['url'], $dl['contentType']);
+
+ //a missing sub-path used to die later in storeMediaFile with a bare
+ //'Invalid upload!': create it here so fetch names its own folder
+ $this->ensureMediaPath($path);
+
+ try {
+ $stored = $this->storeMediaFile($dl['tmp'], $fileName, $path, [
+ 'overwrite' => (bool)($args['overwrite'] ?? false),
+ 'size' => $dl['size'],
+ ]);
+ } finally {
+ @unlink($dl['tmp']);
+ }
+
+ if (!$stored['success']) {
+ return $stored + ['source_url' => $dl['url']];
+ }
+
+ $stored['source_url'] = $dl['url'];
+ $stored['content_type'] = $dl['contentType'];
+
+ if (!empty($dl['note'])) {
+ $stored['note'] = $dl['note'];
+ }
+
+ $content = $args['media_content'] ?? null;
+
+ if (is_array($content) && $content !== []) {
+ $stored['record'] = $this->upsertMediaContentRecord($stored['file'], $content, $dl['contentType']);
+ } else {
+ $stored['record'] = $this->createMediaRecord($stored['file'], $dl['contentType']);
+ }
+
+ return $stored;
+ }
+
+ /**
+ * Create a missing media sub-path for fetch (nested, sandboxed).
+ * storeMediaFile only realpaths existing dirs, so without this a
+ * first-time folder fails with a bare 'Invalid upload!'. Throws
+ * McpToolError with the actual reason. Pure filesystem, tested.
+ *
+ * @param string $path
+ */
+ private function ensureMediaPath(string $path): void {
+ $path = trim(str_replace('\\', '/', $path), '/');
+
+ if ($path === '') {
+ return;
+ }
+
+ $mediaDir = rtrim($this->dirMedia, DS) . DS;
+ $current = $mediaDir;
+
+ foreach (explode('/', $path) as $segment) {
+ $segment = sanitizeFileName($segment);
+
+ if ($segment === '' || $segment === '.' || $segment === '..') {
+ throw new \McpToolError("Media fetch refused: invalid path '$path'.");
+ }
+
+ $current .= $segment . DS;
+
+ if (!is_dir($current) && !@mkdir($current, 0755)) {
+ throw new \McpToolError("Media fetch cannot create folder '$path'.");
+ }
+ }
+
+ $real = realpath($mediaDir . str_replace('/', DS, $path));
+
+ if ($real === false || !str_starts_with(rtrim($real, DS) . DS, $mediaDir)) {
+ throw new \McpToolError("Media fetch refused: path '$path' escapes the media library.");
+ }
+ }
+
+ /**
+ * Derive the library file name for a fetch: explicit file_name wins,
+ * else the URL path basename, with the extension mapped from the
+ * response Content-Type when missing. Pure (no IO) for testability.
+ *
+ * @param ?string $given
+ * @param string $url
+ * @param string $contentType
+ */
+ private static function mediaFetchFileName(?string $given, string $url, string $contentType): string {
+ if ($given !== null && $given !== '') {
+ return $given;
+ }
+
+ $base = (string)(basename((string)parse_url($url, PHP_URL_PATH)) ?: '');
+ $base = trim(urldecode($base));
+
+ if ($base === '' || $base === '.' || str_contains($base, "\0")) {
+ $base = 'fetch';
+ }
+
+ if (!str_contains(pathinfo($base, PATHINFO_BASENAME), '.')) {
+ $map = [
+ 'image/jpeg' => '.jpg', 'image/png' => '.png', 'image/gif' => '.gif',
+ 'image/webp' => '.webp', 'image/svg+xml' => '.svg', 'image/avif' => '.avif',
+ 'image/bmp' => '.bmp', 'image/x-icon' => '.ico',
+ ];
+ $base .= $map[strtolower(trim($contentType))] ?? '';
+ }
+
+ return $base;
+ }
+
+ /**
+ * Downscale an oversized raster image to fit the stored cap instead
+ * of refusing it. Returns [tmp, size, note]. GIFs refuse (resizing
+ * flattens animation, silently destroying intent); vectors and
+ * non-images never reach here. Pure filesystem + resizer, tested.
+ *
+ * @param string $tmp
+ * @param string $type
+ * @param int $cap
+ * @param string $url
+ *
+ * @return array{0: string, 1: int, 2: string|null}
+ */
+ private function mediaFetchFitImage(string $tmp, string $type, int $cap, string $url): array {
+ if ($type === 'image/gif') {
+ @unlink($tmp);
+
+ throw new \McpToolError("Media fetch of '$url' exceeds the media tool cap and is animated GIF - resize would flatten it, use a smaller file.");
+ }
+
+ $maxDim = 2048;
+
+ try {
+ $configured = config('mcp.tools.image_max_dim', 2048);
+ if (is_numeric($configured) && (int)$configured >= 256) {
+ $maxDim = min(4096, (int)$configured);
+ }
+ } catch (\Throwable $e) {
+ }
+
+ $info = @getimagesize($tmp);
+ if (!is_array($info) || $info[0] <= 0 || $info[1] <= 0) {
+ @unlink($tmp);
+
+ throw new \McpToolError("Media fetch of '$url' exceeds the media tool cap, use a smaller file.");
+ }
+
+ [$w, $h] = [(int)$info[0], (int)$info[1]];
+
+ //already small enough in pixels: same-dim quality pass instead of
+ //a pointless upscale (tiny noisy files can still exceed the cap)
+ $small = max($w, $h) <= $maxDim;
+
+ if ($w * $h > 50000000) {
+ @unlink($tmp);
+
+ throw new \McpToolError("Media fetch of '$url' is {$w}x{$h}px, too many pixels to process safely - use a smaller file.");
+ }
+
+ $out = $tmp . '.fit';
+
+ try {
+ if ($small) {
+ $tw = $w;
+ $th = $h;
+ $quality = 70;
+ } else {
+ $tw = $w >= $h ? $maxDim : 0;
+ $th = $w >= $h ? 0 : $maxDim;
+ $quality = 82;
+ }
+ if (!\Vvveb\System\Images::resize($tmp, $out, $tw, $th, 'r', $quality)) {
+ @unlink($tmp);
+
+ throw new \McpToolError("Media fetch of '$url' exceeds the media tool cap, use a smaller file.");
+ }
+ $newSize = filesize($out) ?: 0;
+ if ($newSize <= 0 || $newSize > $cap) {
+ @unlink($tmp);
+ @unlink($out);
+
+ throw new \McpToolError("Media fetch of '$url' still exceeds the media tool cap after resize, use a smaller file.");
+ }
+ } catch (\McpToolError $e) {
+ throw $e;
+ } catch (\Throwable $e) {
+ @unlink($tmp);
+ @unlink($out);
+
+ throw new \McpToolError("Media fetch of '$url' exceeds the media tool cap, use a smaller file.");
+ }
+
+ @unlink($tmp);
+ $note = "Resized {$w}x{$h} to fit the media tool cap.";
+
+ try {
+ $fit = @getimagesize($out);
+ if (is_array($fit)) {
+ $note = "Resized {$w}x{$h} to {$fit[0]}x{$fit[1]} to fit the media tool cap.";
+ }
+ } catch (\Throwable $e) {
+ }
+
+ return [$out, $newSize, $note];
+ }
+
+ /**
+ * Download a URL to temp for media fetch, with the guards upload gets
+ * plus web ones: per-hop SSRF validation (DNS-rebinding safe via
+ * CURLOPT_RESOLVE pinning, like Vvveb\download), manual redirect chain
+ * (max 4, each hop re-validated), Content-Length pre-check and an
+ * in-transfer cap, connect/total timeouts, and an image Content-Type
+ * allowlist. All routine failures throw McpToolError (no log flood).
+ *
+ * A test seam: config mcp.tools.fetch_allow_private (default false)
+ * skips the private-IP refusal so the suite can run a local fixture
+ * server. Never enable outside tests.
+ *
+ * @param string $url
+ * @param int $transferCap
+ * @param int $storedCap
+ *
+ * @return array{tmp: string, url: string, contentType: string, size: int, note: string|null}
+ */
+ private function mediaFetchDownload(string $url, int $transferCap, int $storedCap): array {
+ if (!function_exists('curl_init')) {
+ throw new \McpToolError("Media fetch needs the curl extension to download '$url'.");
+ }
+
+ $allowPrivate = config('mcp.tools.fetch_allow_private', false) === true;
+ $current = $url;
+
+ for ($hop = 0; $hop <= 4; $hop++) {
+ $ips = \Vvveb\validateUrl($current);
+
+ if (!$ips && !$allowPrivate) {
+ throw new \McpToolError("Media fetch refused '$current': URL must be public http(s) on port 80/443 with no private or reserved IP.");
+ }
+
+ $tmp = tempnam(sys_get_temp_dir(), 'mcp-fetch-');
+
+ if ($tmp === false) {
+ throw new \RuntimeException('Could not stage fetch for processing.');
+ }
+
+ $fh = fopen($tmp, 'w');
+
+ if ($fh === false) {
+ @unlink($tmp);
+
+ throw new \RuntimeException('Could not stage fetch for processing.');
+ }
+
+ $headers = [];
+ $ch = curl_init($current);
+ curl_setopt($ch, CURLOPT_FILE, $fh);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
+ //no FAILONERROR: error bodies are inspected below (bot-check
+ //detection needs the bytes); status is checked explicitly
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 15);
+ curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] ?? 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36');
+ curl_setopt($ch, CURLOPT_HTTPHEADER, ['Accept: image/avif,image/webp,image/apng,image/*,*/*;q=0.8', 'Accept-Language: en-US,en;q=0.9']);
+ curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($ch, $line) use (&$headers) {
+ $parts = explode(':', $line, 2);
+
+ if (count($parts) === 2) {
+ $headers[strtolower(trim($parts[0]))] = trim($parts[1]);
+ }
+
+ return strlen($line);
+ });
+ //transfer cap is 4x the stored cap: oversized images finish
+ //downloading so they can be resized below; absurd transfers
+ //still abort here before eating memory
+ curl_setopt($ch, CURLOPT_NOPROGRESS, false);
+ curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, fn ($ch, $dlTotal, $dlNow) => $dlNow > $transferCap ? 1 : 0);
+
+ if ($ips) {
+ curl_setopt($ch, CURLOPT_RESOLVE, $ips);
+ }
+
+ $ok = curl_exec($ch);
+ $code = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ $errno = curl_errno($ch);
+ fclose($fh);
+
+ //aborted by the progress cap (CURLE_ABORTED_BY_CALLBACK): the
+ //transfer itself was fine, the file is just too big
+ if (!$ok && $errno === 42) {
+ @unlink($tmp);
+
+ throw new \McpToolError('Fetched file exceeds the media tool cap, use a smaller file.');
+ }
+
+ //manual redirect: re-validate the next hop from scratch
+ if ($ok && in_array($code, [301, 302, 303, 307, 308], true) && isset($headers['location'])) {
+ @unlink($tmp);
+ $next = trim($headers['location']);
+
+ if ($next === '') {
+ throw new \McpToolError("Media fetch of '$url' got an empty redirect.");
+ }
+
+ //resolve relative Location against the current URL (core,
+ //RFC 3986: plain string-append gets directory resolution wrong)
+ if (!preg_match('#^https?://#i', $next)) {
+ $next = \Vvveb\resolveUrl($current, $next);
+ }
+
+ $current = $next;
+
+ continue;
+ }
+
+ if (!$ok || $code !== 200) {
+ $head = (string)@file_get_contents($tmp, false, null, 0, 4096);
+ @unlink($tmp);
+ if (\Vvveb\isChallengePage($head)) {
+ throw new \McpToolError("Media fetch of '$url' is blocked by a bot check (HTTP $code) no script can pass - open the URL in your browser and upload the file, or choose another source.");
+ }
+
+ throw new \McpToolError("Media fetch of '$url' failed (HTTP $code).");
+ }
+
+ $size = filesize($tmp) ?: 0;
+
+ if ($size <= 0) {
+ @unlink($tmp);
+
+ throw new \McpToolError('Fetched file is empty, use another source.');
+ }
+
+ $type = strtolower(trim(explode(';', $headers['content-type'] ?? '')[0]));
+ $allowed = ['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/svg+xml', 'image/avif', 'image/bmp', 'image/x-icon'];
+
+ if (!in_array($type, $allowed, true)) {
+ @unlink($tmp);
+
+ throw new \McpToolError("Media fetch of '$url' refused: Content-Type '$type' is not a supported image type.");
+ }
+
+ $fitNote = null;
+
+ if ($size > $storedCap) {
+ [$tmp, $size, $fitNote] = $this->mediaFetchFitImage($tmp, $type, $storedCap, $url);
+ }
+
+ return ['tmp' => $tmp, 'url' => $current, 'contentType' => $type, 'size' => $size, 'note' => $fitNote];
+ }
+
+ @unlink($tmp);
+
+ throw new \McpToolError("Media fetch of '$url' gave up after too many redirects.");
+ }
+
+ /**
+ * media tool: media library metadata and file operations.
+ *
+ * Top-level since its parameter set dwarfs the other admin stubs; also
+ * reachable via the admin tool (target media) as a deprecated alias.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array{operation: string, result: mixed}
+ */
+ public function toolMedia(array $args): array {
+ $operation = trim((string)($args['operation'] ?? ''));
+ $file = trim((string)($args['file'] ?? ''));
+ $content = $args['content'] ?? null;
+ $params = $args['params'] ?? [];
+
+ //scan/search report root-relative paths with a leading slash: strip
+ //it back here so file args round-trip into DB lookups and stored
+ //rows verbatim (stored format has no leading slash)
+ foreach (['file', 'path', 'newfile'] as $slashKey) {
+ if (isset($args[$slashKey]) && is_string($args[$slashKey])) {
+ $args[$slashKey] = ltrim(trim($args[$slashKey]), '/');
+ }
+ }
+
+ $file = (string)($args['file'] ?? '');
+
+ $allowedOps = ['list', 'get', 'save', 'delete', 'upload', 'fetch', 'mkdir', 'rename', 'scan'];
+
+ if (!in_array($operation, $allowedOps, true)) {
+ throw new \InvalidArgumentException("Invalid operation '$operation' for tool 'media'. Allowed: " . implode(', ', $allowedOps));
+ }
+
+ if ($operation === 'scan') {
+ $scanPath = trim((string)($args['path'] ?? ''));
+ $scanLevels = isset($args['levels']) ? max(1, min(3, (int)$args['levels'])) : 1;
+ $scanSearch = trim((string)($args['search'] ?? ''));
+ $scanLimit = isset($args['limit']) ? max(1, min(200, (int)$args['limit'])) : 200;
+ $scanStart = isset($args['start']) ? max(0, (int)$args['start']) : 0;
+
+ return ['operation' => $operation, 'result' => $this->listMedia($scanPath, $scanLevels, $scanSearch, '', $scanLimit, $scanStart)];
+ }
+
+ if (!is_array($params)) {
+ throw new \InvalidArgumentException("Invalid params for tool 'media'. params must be an object with key/value pairs.");
+ }
+
+ $media = \Vvveb\model('media_content');
+
+ if ($operation === 'list') {
+ $result = $media->getAll($params + $this->global);
+
+ return ['operation' => $operation, 'result' => $result ?? []];
+ }
+
+ if (in_array($operation, ['get', 'save'], true) && $file === '') {
+ throw new \InvalidArgumentException("Missing required argument 'file' for tool 'media' operation '$operation'");
+ }
+
+ if ($operation === 'get') {
+ $result = $media->getContent(['file' => $file] + $this->global);
+
+ return ['operation' => $operation, 'result' => $result ?? []];
+ }
+
+ if (config('mcp.tools.db_write', false) !== true) {
+ throw new \McpToolError("Writes are disabled - enable mcp.tools.db_write to allow $operation on media.");
+ }
+
+ if ($operation === 'upload') {
+ return ['operation' => $operation, 'result' => $this->toolMediaUpload($args)];
+ }
+
+ if ($operation === 'fetch') {
+ return ['operation' => $operation, 'result' => $this->toolMediaFetch($args)];
+ }
+
+ if ($operation === 'mkdir') {
+ $folder = trim((string)($args['folder'] ?? ''));
+ $path = trim((string)($args['path'] ?? ''));
+
+ if ($folder === '') {
+ throw new \InvalidArgumentException("Missing required argument 'folder' for tool 'media' operation 'mkdir'");
+ }
+
+ return ['operation' => $operation, 'result' => $this->createMediaFolder($path, $folder)];
+ }
+
+ if ($operation === 'rename') {
+ $newfile = trim((string)($args['newfile'] ?? ''));
+ $newname = trim((string)($args['newname'] ?? ''));
+
+ if ($file === '') {
+ throw new \InvalidArgumentException("Missing required argument 'file' for tool 'media' operation 'rename'");
+ }
+
+ if ($newfile === '' && $newname === '') {
+ throw new \InvalidArgumentException("Missing required argument 'newfile' or 'newname' for tool 'media' operation 'rename'");
+ }
+
+ return ['operation' => $operation, 'result' => $this->renameMediaFile($file, $newfile, $newname, (bool)($args['duplicate'] ?? false))];
+ }
+
+ if ($operation === 'save') {
+ if (!is_array($content) || $content === []) {
+ throw new \InvalidArgumentException("Missing required argument 'content' for tool 'media' operation 'save'");
+ }
+
+ return ['operation' => $operation, 'result' => $this->upsertMediaContentRecord($file, $content)];
+ }
+
+ $mediaId = $args['media_id'] ?? null;
+
+ if ($mediaId === null && $file === '') {
+ throw new \InvalidArgumentException("Missing required argument 'media_id' or 'file' for tool 'media' operation 'delete'");
+ }
+
+ $options = [];
+
+ if ($mediaId !== null) {
+ $options['media_id'] = [(int)$mediaId];
+ }
+
+ if ($file !== '') {
+ $options['file'] = [$file];
+ }
+
+ $result = $media->delete($options + $this->global);
+
+ return ['operation' => $operation, 'result' => $result ?? []];
+ }
+
+ /**
+ * Cron stub (via admin tool): CRUD for CMS cron jobs.
+ *
+ * list is always allowed; run/run_all execute job callbacks and require
+ * config key mcp.tools.db_write.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array<string, mixed>
+ */
+ private function toolCron(array $args): array {
+ $operation = trim((string)($args['operation'] ?? ''));
+ $job = trim((string)($args['job'] ?? ''));
+
+ $allowedOps = ['list', 'run', 'run_all'];
+
+ if (!in_array($operation, $allowedOps, true)) {
+ throw new \InvalidArgumentException("Invalid operation '$operation' for tool 'cron'. Allowed: " . implode(', ', $allowedOps));
+ }
+
+ $jobs = [];
+
+ foreach (\Vvveb\System\Cron::getCrons() as $priorities) {
+ foreach ($priorities as $group) {
+ foreach (array_keys($group) as $name) {
+ $jobs[] = $name;
+ }
+ }
+ }
+
+ if ($operation === 'list') {
+ return ['operation' => $operation, 'jobs' => $jobs, 'count' => count($jobs)];
+ }
+
+ if (config('mcp.tools.db_write', false) !== true) {
+ throw new \McpToolError("Writes are disabled - enable mcp.tools.db_write to allow $operation on cron.");
+ }
+
+ if ($operation === 'run') {
+ if ($job === '') {
+ throw new \InvalidArgumentException("Missing required argument 'job' for tool 'cron' operation 'run'");
+ }
+
+ if (!preg_match('/^[A-Za-z0-9_.-]+$/', $job)) {
+ throw new \InvalidArgumentException("Invalid cron job name: '$job'");
+ }
+
+ if (!in_array($job, $jobs, true)) {
+ throw new \McpToolError("Unknown cron job: '$job'. Available jobs: " . implode(', ', $jobs));
+ }
+
+ return ['operation' => $operation, 'job' => $job, 'result' => \Vvveb\System\Cron::run($job)];
+ }
+
+ return ['operation' => $operation, 'result' => \Vvveb\System\Cron::runAll()];
+ }
+
+ /**
+ * Cache stub (via admin tool): CRUD for CMS caches (mirrors admin Tools/Cache).
+ *
+ * Single clear operation with a target selector; requires config key
+ * mcp.tools.db_write.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return array{operation: string, scope: string, success: bool}
+ */
+ private function toolCache(array $args): array {
+ $operation = trim((string)($args['operation'] ?? ''));
+ $scope = trim((string)($args['scope'] ?? 'all'));
+
+ if ($operation !== 'clear') {
+ throw new \InvalidArgumentException("Invalid operation '$operation' for tool 'cache'. Allowed: clear");
+ }
+
+ $scopes = ['all', 'template', 'page', 'database', 'frontend', 'image', 'model'];
+
+ if (!in_array($scope, $scopes, true)) {
+ throw new \InvalidArgumentException("Invalid scope '$scope' for cache. Allowed: " . implode(', ', $scopes));
+ }
+
+ if (config('mcp.tools.db_write', false) !== true) {
+ throw new \McpToolError("Writes are disabled - enable mcp.tools.db_write to allow $operation on cache $scope.");
+ }
+
+ $host = trim((string)($args['host'] ?? ''));
+
+ $success = match ($scope) {
+ 'all' => \Vvveb\System\CacheManager::delete(),
+ 'template' => \Vvveb\System\CacheManager::clearCompiledFiles(),
+ 'page' => \Vvveb\System\CacheManager::clearPageCache($host !== '' ? $host : null),
+ 'database' => \Vvveb\System\CacheManager::clearObjectCache(),
+ 'frontend' => \Vvveb\System\CacheManager::clearFrontend(),
+ 'image' => \Vvveb\System\CacheManager::clearImageCache(),
+ 'model' => \Vvveb\System\CacheManager::clearModelCache(),
+ };
+
+ return ['operation' => $operation, 'scope' => $scope, 'success' => (bool)$success];
+ }
+
+ /**
+ * str_replace_editor tool: unified filesystem editor (view/create/edit — multi-edit only).
+ *
+ * Wraps the native PHP StrReplaceEditor (mcp/str_replace_editor.php) with sandbox-aware
+ * path resolution via resolvePath()/toolRoot(). All paths are sandboxed inside the
+ * installation root. Only view, create and edit (multi-edit via edits[]) are exposed;
+ * single str_replace/insert are removed in favor of the unified multi-edit.
+ *
+ * @param array<string, mixed> $args
+ *
+ * @return string|array<string, mixed>
+ */
+ public function toolStrReplaceEditor(array $args): mixed {
+ $command = (string)($args['command'] ?? '');
+ $rawPath = (string)($args['path'] ?? '');
+
+ if ($command === '') {
+ throw new \InvalidArgumentException("Missing required argument 'command' for tool 'str_replace_editor'");
+ }
+ if ($rawPath === '') {
+ throw new \InvalidArgumentException("Missing required argument 'path' for tool 'str_replace_editor'");
+ }
+ if (!in_array($command, ['view', 'create', 'edit'], true)) {
+ throw new \InvalidArgumentException("Invalid command '$command' for str_replace_editor. Allowed: view, create, edit");
+ }
+
+ // Resolve path inside sandbox. `create` may target a non-existing file, so mustExist=false.
+ // `view` may target a directory; others require a file. resolvePath validates sandbox escape.
+ $mustExist = $command !== 'create';
+ $resolved = $this->resolvePath($rawPath, $mustExist);
+
+ // StrReplaceEditor expects an absolute path that passes its own resolveTarget check.
+ // $resolved is already absolute (toolRoot + normalized relative) and sandbox-validated.
+ $cwd = $this->toolRoot();
+ $editor = new \StrReplaceEditor(null, $cwd);
+
+ $execArgs = $args;
+ $execArgs['path'] = $resolved;
+
+ // Delegate to the native editor. It returns a formatted string (file view or success+diff).
+ return $editor->execute($execArgs);
+ }
+
+ /* -----------------------------------------------------------------
+ * Tool helpers
+ * ----------------------------------------------------------------- */
+
+ /**
+ * Sandbox root for file tools (defaults to the installation root).
+ */
+ private function toolRoot(): string {
+ $root = config('mcp.tools.root', DIR_ROOT);
+ $real = realpath($root);
+
+ return $real !== false ? rtrim($real, '/') : rtrim(DIR_ROOT, '/');
+ }
+
+ /**
+ * Resolve a user supplied path inside the sandbox root.
+ *
+ * @param string $path Relative or absolute path
+ * @param bool $mustExist Require the resolved path to exist
+ *
+ * @return string Absolute real path inside the sandbox
+ */
+ private function resolvePath(string $path, bool $mustExist = true): string {
+ if ($path === '') {
+ throw new \McpToolError('Empty path');
+ }
+
+ $root = $this->toolRoot();
+ if ($path[0] === '/' && ($path === $root || str_starts_with($path, $root . '/'))) {
+ $path = substr($path, strlen($root));
+ }
+
+ //paths are always interpreted relative to the sandbox root; absolute
+ //looking paths (/etc/passwd) simply map to <root>/etc/passwd which is
+ //safer than honoring filesystem absolute paths
+ $relative = ltrim(str_replace('\\', '/', $path), '/');
+
+ //lexically normalize the path against the sandbox root; resolves '..'
+ //and '.' segments without requiring any segment to exist
+ $canonical = [];
+
+ foreach (explode('/', trim($relative, '/')) as $segment) {
+ if ($segment === '' || $segment === '.') {
+ continue;
+ }
+
+ if ($segment === '..') {
+ array_pop($canonical);
+ continue;
+ }
+
+ $canonical[] = $segment;
+ }
+
+ $resolved = $root . '/' . implode('/', $canonical);
+
+ //existing files must really live inside the sandbox (symlink check)
+ if (file_exists($resolved)) {
+ $real = realpath($resolved);
+
+ if ($real !== false && !str_starts_with($real, $root)) {
+ throw new \McpToolError("Path escapes the site root sandbox: $path");
+ }
+ } elseif ($mustExist) {
+ throw new \McpToolError("File or directory not found: $path");
+ }
+
+ return $resolved;
+ }
+
+ /**
+ * Validate arguments against the tool inputSchema required list.
+ *
+ * @param string $name
+ * @param array<string, mixed> $arguments
+ * @param array<string, mixed> $tool
+ *
+ * @return void
+ */
+ private function validateRequiredArgs(string $name, array $arguments, array $tool): void {
+ $required = $tool['inputSchema']['required'] ?? [];
+
+ foreach ((array)$required as $field) {
+ if (!isset($arguments[$field]) || $arguments[$field] === '') {
+ throw new \InvalidArgumentException("Missing required argument '$field' for tool '$name'");
+ }
+ }
+ }
+
+ /**
+ * Wrap a handler result into an MCP tool result envelope.
+ *
+ * @param mixed $result
+ *
+ * @return array{content: array<int, mixed>, isError: false, structuredContent?: mixed}
+ */
+ private function textResult($result): array {
+ //compact encoding: pretty whitespace costs ~25% on every result
+ //with zero information (humans format on read, agents never do)
+ $flags = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
+
+ if (is_string($result)) {
+ $text = $result;
+ } elseif ($this->isAckShape($result)) {
+ //pure acknowledgements (mkdir/rename): one message line for
+ //content, full detail stays in structuredContent
+ $text = (string)($result['message'] ?? '');
+ } else {
+ $text = (string)json_encode($result, $flags);
+ }
+
+ $out = [
+ 'content' => [['type' => 'text', 'text' => $text]],
+ 'isError' => false,
+ ];
+
+ if (!is_string($result)) {
+ $out['structuredContent'] = $result;
+ }
+
+ return $out;
+ }
+
+ /**
+ * Pure-ack shape: exactly success + message, nothing the caller needs
+ * verbatim (mkdir/rename confirmations). Anything richer stays whole.
+ *
+ * @param mixed $result
+ */
+ private function isAckShape(mixed $result): bool {
+ if (!is_array($result)) {
+ return false;
+ }
+
+ $keys = array_keys($result);
+
+ return count($keys) === 2 && in_array('success', $keys, true) && in_array('message', $keys, true);
+ }
+
+ /**
+ * Cap an error message for the model: some failures (DB driver dumps)
+ * run to many kilobytes, and a long error never helps the caller more
+ * than its head does. Full detail stays in the server log via DEBUG.
+ *
+ * @param string $message
+ * @param int $max
+ */
+ private static function trimToolError(string $message, int $max = 2000): string {
+ if (function_exists('mb_strlen') && function_exists('mb_substr')) {
+ if (mb_strlen($message) > $max) {
+ return mb_substr($message, 0, $max) . '… [error truncated, see server log]';
+ }
+
+ return $message;
+ }
+
+ return strlen($message) > $max ? substr($message, 0, $max) . '… [error truncated, see server log]' : $message;
+ }
+
+ /**
+ * Build an MCP error tool result.
+ *
+ * @param string $message
+ *
+ * @return array{content: array<int, mixed>, isError: true}
+ */
+ private function errorResult(string $message): array {
+ return [
+ 'content' => [['type' => 'text', 'text' => $message]],
+ 'isError' => true,
+ ];
+ }
+
+ /**
+ * Detect the leading SQL statement type ignoring comments.
+ *
+ * @param string $query
+ */
+ private static function statementType(string $query): string {
+ $clean = preg_replace('/^\s*(--[^\n]*|#[^\n]*|\/\*.*?\*\/)+/s', '', $query) ?? $query;
+
+ if (preg_match('/^\s*([a-zA-Z]+)/', $clean, $m)) {
+ return strtoupper($m[1]);
+ }
+
+ return '';
+ }
+
+ /**
+ * Check whether a WITH (CTE) query contains write statements.
+ *
+ * @param string $query
+ */
+ private static function containsWriteKeyword(string $query): bool {
+ return (bool)preg_match('/\b(INSERT|UPDATE|DELETE|REPLACE|MERGE|ALTER|CREATE|DROP|TRUNCATE|RENAME|GRANT|REVOKE|CALL|LOAD|HANDLER|DO|SET)\b/i', $query);
+ }
+
+ /**
+ * Execute a registered admin action (admin-execute-action tool).
+ *
+ * @param array<string, mixed> $params
+ *
+ * @return array{success: bool, data?: mixed, error?: string}
+ */
+ public function admin_execute_action(array $params): array {
+ $name = $params['action_name'] ?? '';
+ $args = $params['parameters'] ?? [];
+
+ if ($name === '') {
+ return ['success' => false, 'error' => 'Missing action_name'];
+ }
+
+ try {
+ [$result] = \Vvveb\System\Event::trigger('MCP', 'admin/execute', $args, $name);
+
+ return ['success' => true, 'data' => $result];
+ } catch (Throwable $e) {
+ return ['success' => false, 'error' => $e->getMessage()];
+ }
+ }
+
+ /**
+ * List available prompts.
+ *
+ * @param array<string, mixed> $params
+ *
+ * @return array{prompts: array<int, array<string, mixed>>, nextCursor: string}
+ */
+ public function prompts_list(array $params): array {
+ return [
+ 'prompts' => [
+ [
+ 'name' => 'code_review',
+ 'title' => 'Request Code Review',
+ 'description' => 'Asks the LLM to analyze code quality and suggest improvements',
+ 'arguments' => [
+ [
+ 'name' => 'code',
+ 'description' => 'The code to review',
+ 'required' => true
+ ]
+ ],
+ 'icons' => [
+ [
+ 'src' => 'https://example.com/review-icon.svg',
+ 'mimeType' => 'image/svg+xml',
+ 'sizes' => [
+ 'any'
+ ]
+ ]
+ ]
+ ]
+ ],
+ 'nextCursor' => 'next-page-cursor'
+ ];
+ }
+
+ /**
+ * Get a specific prompt.
+ *
+ * @param array<string, mixed> $params
+ *
+ * @return array{description: string, messages: array<int, array<string, mixed>>}
+ */
+ public function prompts_get(array $params): array {
+ return [
+ 'description' => 'Code review prompt',
+ 'messages' => [
+ [
+ 'role' => 'user',
+ 'content' => [
+ 'type' => 'text',
+ 'text' => 'Please review this Python code:
+ def hello():
+ print(\'world\')'
+ ]
+ ]
+ ]
+ ];
+ }
+
+ /**
+ * Handle notifications/initialized event.
+ *
+ * @param array<string, mixed> $params
+ *
+ * @return void
+ */
+ public function notifications_initialized(array $params): void {}
+
+ /**
+ * Handle delete event.
+ *
+ * @param array<string, mixed> $params
+ *
+ * @return void
+ */
+ public function delete(array $params): void {}
+
+ /**
+ * List available resources.
+ *
+ * @param array<string, mixed> $params
+ *
+ * @return array{resources: array<int, mixed>}
+ */
+ public function resources_list(array $params): array {
+ return ['resources' => []];
+ }
+
+ /**
+ * Read a resource.
+ *
+ * @param array<string, mixed> $params
+ *
+ * @return void
+ */
+ public function resources_read(array $params): void {}
+
+ /**
+ * Server discovery endpoint.
+ *
+ * @param array<string, mixed> $params
+ *
+ * @return void
+ */
+ public function server_discover(array $params): void {}
+
+ /**
+ * Initialize the MCP session and return capabilities.
+ *
+ * @return array{protocolVersion: string, capabilities: array<string, mixed>, serverInfo: array{name: string, version: string}}
+ */
+ public function initialize(): array {
+ $this->session = Session::getInstance();
+ $sessionId = $this->session->sessionId();
+ header("Mcp-Session-Id: $sessionId");
+
+ return [
+ 'protocolVersion' => $this->version,
+ 'capabilities' => [
+ 'tools' => [
+ 'listChanged' => false
+ ],
+ 'resources' => [
+ 'subscribe' => false,
+ 'listChanged' => false
+ ],
+ 'prompts' => [
+ 'listChanged' => false
+ ]
+ ],
+ 'serverInfo' => [
+ 'name' => 'Vvveb',
+ 'version' => V_VERSION
+ ]
+ ];
+ }
+
+ /**
+ * Main MCP index action: parse JSON-RPC request and dispatch to handler.
+ *
+ * @return void
+ */
+ public function index(): void {
+ $rawInput = file_get_contents('php://input');
+ $input = [];
+
+ if (($input = json_decode($rawInput, true)) === null) {
+ $this->notFound('Parse error', -32700);
+ }
+
+ $this->response->output = false;
+
+ $result = [];
+ if (isset($input['method']) && ($method = $input['method'])) {
+ $params = $input['params'] ?? [];
+
+ switch ($method) {
+ case 'initialize':
+ $result = $this->initialize();
+ break;
+ case 'tools/list':
+ $result = $this->tools_list($params);
+ break;
+ case 'notifications/initialized':
+ $this->notifications_initialized($params);
+ $result = null;
+ break;
+ case 'resources/list':
+ $result = $this->resources_list($params);
+ break;
+ case 'prompts/list':
+ $result = $this->prompts_list($params);
+ break;
+ case 'tools/call':
+ $result = $this->tools_call($method, $params);
+ break;
+ case 'server/discover':
+ $this->server_discover($params);
+ $result = null;
+ break;
+ default:
+ if (!function_exists($method)) {
+ $this->notFound('Method not found', -32601);
+ }
+ }
+ } else {
+ $this->notFound('Invalid Request', -32600);
+ }
+
+ $id = (int)($this->session->get('id') ?? 0);
+
+ $output = [
+ 'jsonrpc' => '2.0',
+ 'id' => $id,
+ 'result' => $result
+ ];
+
+ $this->session->set('id', ++$id);
+
+ echo json_encode($output, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
+
+ /*
+ $this->response->setType('json');
+ $this->response->output = true;
+ $this->response->output($output);
+ */
+ }
+}
diff --git a/mcp/controller/prompts.php b/mcp/controller/prompts.php
new file mode 100755
index 0000000..80e86a2
--- /dev/null
+++ b/mcp/controller/prompts.php
@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\Controller;
+
+#[\AllowDynamicProperties]
+class Prompts extends Base {
+ public function __construct() {}
+}
diff --git a/mcp/controller/resources.php b/mcp/controller/resources.php
new file mode 100755
index 0000000..f5e8754
--- /dev/null
+++ b/mcp/controller/resources.php
@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Vvveb\Controller;
+
+#[\AllowDynamicProperties]
+class Resources extends Base {
+ public function __construct() {}
+}
diff --git a/mcp/edit-diff.php b/mcp/edit-diff.php
new file mode 100644
index 0000000..8681765
--- /dev/null
+++ b/mcp/edit-diff.php
@@ -0,0 +1,672 @@
+<?php
+
+declare(strict_types=1);
+
+namespace CodingAgent\Tools;
+
+/**
+ * @phpstan-type EditDiffResult array{diff: string, firstChangedLine?: int|null}
+ * @phpstan-type EditDiffError array{error: string}
+ * @phpstan-type EditPreview EditDiffResult|EditDiffError
+ *
+ * @param string $content
+ */
+
+/**
+ * Split leading UTF-8 BOM (\xEF\xBB\xBF / \uFEFF).
+ *
+ * @return array{bom: string, text: string}
+ */
+function splitBom(string $content): array {
+ $bom = "\xEF\xBB\xBF";
+ if (str_starts_with($content, $bom)) {
+ return ['bom' => $bom, 'text' => substr($content, 3)];
+ }
+ // Also handle single-codepoint form if already decoded as UTF-8 string with \uFEFF
+ if (str_starts_with($content, "\u{FEFF}")) {
+ return ['bom' => "\u{FEFF}", 'text' => mb_substr($content, 1)];
+ }
+
+ return ['bom' => '', 'text' => $content];
+}
+
+function detectLineEnding(string $content): string {
+ $crlfIdx = strpos($content, "\r\n");
+ $lfIdx = strpos($content, "\n");
+ if ($lfIdx === false) {
+ return "\n";
+ }
+ if ($crlfIdx === false) {
+ return "\n";
+ }
+
+ return $crlfIdx < $lfIdx ? "\r\n" : "\n";
+}
+
+function normalizeToLF(string $text): string {
+ $text = str_replace("\r\n", "\n", $text);
+
+ return str_replace("\r", "\n", $text);
+}
+
+function restoreLineEndings(string $text, string $ending): string {
+ return $ending === "\r\n" ? str_replace("\n", "\r\n", $text) : $text;
+}
+
+/**
+ * Normalize text for fuzzy matching.
+ * - NFKC normalization
+ * - Strip trailing whitespace per line
+ * - Smart quotes → ASCII
+ * - Dashes → hyphen
+ * - Special spaces → regular space
+ *
+ * @param string $text
+ */
+function normalizeForFuzzyMatch(string $text): string {
+ // NFKC
+ if (class_exists(\Normalizer::class)) {
+ $normalized = \Normalizer::normalize($text, \Normalizer::FORM_KC);
+ if ($normalized !== false) {
+ $text = $normalized;
+ }
+ }
+
+ $lines = explode("\n", $text);
+ $lines = array_map(fn (string $line): string => rtrim($line, " \t"), $lines);
+ $text = implode("\n", $lines);
+
+ // Smart single quotes → '
+ $text = preg_replace('/[\x{2018}\x{2019}\x{201A}\x{201B}]/u', "'", $text) ?? $text;
+ // Smart double quotes → "
+ $text = preg_replace('/[\x{201C}\x{201D}\x{201E}\x{201F}]/u', '"', $text) ?? $text;
+ // Various dashes/hyphens → -
+ $text = preg_replace('/[\x{2010}\x{2011}\x{2012}\x{2013}\x{2014}\x{2015}\x{2212}]/u', '-', $text) ?? $text;
+
+ // Special spaces → regular space
+ return preg_replace('/[\x{00A0}\x{2002}-\x{200A}\x{202F}\x{205F}\x{3000}]/u', ' ', $text) ?? $text;
+}
+
+/** @return string[] each entry retains its trailing \n if present */
+function splitLinesWithEndings(string $content): array {
+ if ($content === '') {
+ return [];
+ }
+ preg_match_all('/[^\n]*\n|[^\n]+/', $content, $m);
+
+ return $m[0];
+}
+
+/** @return array<int, array{start: int, end: int}> */
+function getLineSpans(string $content): array {
+ $offset = 0;
+ $spans = [];
+ foreach (splitLinesWithEndings($content) as $line) {
+ $len = strlen($line);
+ $spans[] = ['start' => $offset, 'end' => $offset + $len];
+ $offset += $len;
+ }
+
+ return $spans;
+}
+
+/**
+ * @param array<int, array{start: int, end: int}> $lines
+ * @param array{matchIndex: int, matchLength: int} $replacement
+ *
+ * @return array{startLine: int, endLine: int}
+ */
+function getReplacementLineRange(array $lines, array $replacement): array {
+ $start = $replacement['matchIndex'];
+ $end = $replacement['matchIndex'] + $replacement['matchLength'];
+
+ $startLine = -1;
+ foreach ($lines as $i => $line) {
+ if ($start >= $line['start'] && $start < $line['end']) {
+ $startLine = $i;
+ break;
+ }
+ }
+ if ($startLine === -1) {
+ throw new \RuntimeException('Replacement range is outside the base content.');
+ }
+ $endLine = $startLine;
+ while ($endLine < count($lines) && $lines[$endLine]['end'] < $end) {
+ $endLine++;
+ }
+ if ($endLine >= count($lines)) {
+ throw new \RuntimeException('Replacement range is outside the base content.');
+ }
+
+ return ['startLine' => $startLine, 'endLine' => $endLine + 1];
+}
+
+/**
+ * @param string $content
+ * @param array<int, array{matchIndex: int, matchLength: int, newText: string}> $replacements
+ * @param int $offset
+ */
+function applyReplacements(string $content, array $replacements, int $offset = 0): string {
+ $result = $content;
+ for ($i = count($replacements) - 1; $i >= 0; $i--) {
+ $r = $replacements[$i];
+ $idx = $r['matchIndex'] - $offset;
+ $result = substr($result, 0, $idx) . $r['newText'] . substr($result, $idx + $r['matchLength']);
+ }
+
+ return $result;
+}
+
+/**
+ * Apply replacements matched against baseContent to originalContent while
+ * preserving unchanged line blocks from the original.
+ *
+ * @param string $originalContent
+ * @param string $baseContent
+ * @param array<int, array{matchIndex: int, matchLength: int, newText: string}> $replacements
+ */
+function applyReplacementsPreservingUnchangedLines(string $originalContent, string $baseContent, array $replacements): string {
+ $originalLines = splitLinesWithEndings($originalContent);
+ $baseLines = getLineSpans($baseContent);
+
+ if (count($originalLines) !== count($baseLines)) {
+ throw new \RuntimeException('Cannot preserve unchanged lines because the base content has a different line count.');
+ }
+
+ $groups = [];
+ $sorted = $replacements;
+ usort($sorted, fn ($a, $b) => $a['matchIndex'] <=> $b['matchIndex']);
+
+ foreach ($sorted as $replacement) {
+ $range = getReplacementLineRange($baseLines, $replacement);
+ $current = !empty($groups) ? $groups[count($groups) - 1] : null;
+ if ($current !== null && $range['startLine'] < $current['endLine']) {
+ $idx = count($groups) - 1;
+ $groups[$idx]['endLine'] = max($current['endLine'], $range['endLine']);
+ $groups[$idx]['replacements'][] = $replacement;
+ continue;
+ }
+ $groups[] = ['startLine' => $range['startLine'], 'endLine' => $range['endLine'], 'replacements' => [$replacement]];
+ }
+
+ $originalLineIndex = 0;
+ $result = '';
+ foreach ($groups as $group) {
+ $result .= implode('', array_slice($originalLines, $originalLineIndex, $group['startLine'] - $originalLineIndex));
+ $groupStartOffset = $baseLines[$group['startLine']]['start'];
+ $groupEndOffset = $baseLines[$group['endLine'] - 1]['end'];
+ $result .= applyReplacements(
+ substr($baseContent, $groupStartOffset, $groupEndOffset - $groupStartOffset),
+ $group['replacements'],
+ $groupStartOffset
+ );
+ $originalLineIndex = $group['endLine'];
+ }
+ $result .= implode('', array_slice($originalLines, $originalLineIndex));
+
+ return $result;
+}
+
+/**
+ * @param string $content
+ * @param string $oldText
+ *
+ * @return array{found: bool, index: int, matchLength: int, usedFuzzyMatch: bool, contentForReplacement: string}
+ */
+function fuzzyFindText(string $content, string $oldText): array {
+ $exactIndex = strpos($content, $oldText);
+ if ($exactIndex !== false) {
+ return [
+ 'found' => true,
+ 'index' => $exactIndex,
+ 'matchLength' => strlen($oldText),
+ 'usedFuzzyMatch' => false,
+ 'contentForReplacement' => $content,
+ ];
+ }
+
+ $fuzzyContent = normalizeForFuzzyMatch($content);
+ $fuzzyOldText = normalizeForFuzzyMatch($oldText);
+ $fuzzyIndex = strpos($fuzzyContent, $fuzzyOldText);
+
+ if ($fuzzyIndex === false) {
+ return [
+ 'found' => false,
+ 'index' => -1,
+ 'matchLength' => 0,
+ 'usedFuzzyMatch' => false,
+ 'contentForReplacement' => $content,
+ ];
+ }
+
+ return [
+ 'found' => true,
+ 'index' => $fuzzyIndex,
+ 'matchLength' => strlen($fuzzyOldText),
+ 'usedFuzzyMatch' => true,
+ 'contentForReplacement' => $fuzzyContent,
+ ];
+}
+
+function countOccurrences(string $content, string $oldText): int {
+ $fuzzyContent = normalizeForFuzzyMatch($content);
+ $fuzzyOldText = normalizeForFuzzyMatch($oldText);
+ if ($fuzzyOldText === '') {
+ return 0;
+ }
+
+ return substr_count($fuzzyContent, $fuzzyOldText);
+}
+
+function getNotFoundError(string $path, int $editIndex, int $totalEdits): \RuntimeException {
+ if ($totalEdits === 1) {
+ return new \RuntimeException(
+ "Could not find the exact text in {$path}. The old text must match exactly including all whitespace and newlines."
+ );
+ }
+
+ return new \RuntimeException(
+ "Could not find edits[{$editIndex}] in {$path}. The oldText must match exactly including all whitespace and newlines."
+ );
+}
+
+function getDuplicateError(string $path, int $editIndex, int $totalEdits, int $occurrences): \RuntimeException {
+ if ($totalEdits === 1) {
+ return new \RuntimeException(
+ "Found {$occurrences} occurrences of the text in {$path}. The text must be unique. Please provide more context to make it unique."
+ );
+ }
+
+ return new \RuntimeException(
+ "Found {$occurrences} occurrences of edits[{$editIndex}] in {$path}. Each oldText must be unique. Please provide more context to make it unique."
+ );
+}
+
+function getEmptyOldTextError(string $path, int $editIndex, int $totalEdits): \RuntimeException {
+ if ($totalEdits === 1) {
+ return new \RuntimeException("oldText must not be empty in {$path}.");
+ }
+
+ return new \RuntimeException("edits[{$editIndex}].oldText must not be empty in {$path}.");
+}
+
+function getNoChangeError(string $path, int $totalEdits): \RuntimeException {
+ if ($totalEdits === 1) {
+ return new \RuntimeException(
+ "No changes made to {$path}. The replacement produced identical content. This might indicate an issue with special characters or the text not existing as expected."
+ );
+ }
+
+ return new \RuntimeException("No changes made to {$path}. The replacements produced identical content.");
+}
+
+/**
+ * Apply one or more exact-text replacements to LF-normalized content.
+ *
+ * Every edit is first probed against the original content; when at least one
+ * edit only matches after fuzzy normalization (unicode quotes/dashes/spaces,
+ * trailing whitespace) all edits are matched against the fuzzy-normalized
+ * base so every offset shares one coordinate space. Uniqueness is always
+ * checked on the fuzzy-normalized base. The file content itself is normalized
+ * once up front instead of once per edit.
+ *
+ * @param string $normalizedContent
+ * @param array<int, array{oldText: string, newText: string}> $edits
+ * @param string $path
+ *
+ * @return array{baseContent: string, newContent: string}
+ */
+function applyEditsToNormalizedContent(string $normalizedContent, array $edits, string $path): array {
+ $total = count($edits);
+
+ $normalizedEdits = array_map(static fn (array $e): array => [
+ 'oldText' => normalizeToLF($e['oldText']),
+ 'newText' => normalizeToLF($e['newText']),
+ ], $edits);
+
+ foreach ($normalizedEdits as $i => $edit) {
+ if ($edit['oldText'] === '') {
+ throw getEmptyOldTextError($path, $i, $total);
+ }
+ }
+
+ // Fast-path probe: fall back to the fuzzy base only when an edit does not
+ // match the original content exactly.
+ $needsFuzzy = false;
+ foreach ($normalizedEdits as $edit) {
+ if (!str_contains($normalizedContent, $edit['oldText'])) {
+ $needsFuzzy = true;
+ break;
+ }
+ }
+
+ $replacementBaseContent = $needsFuzzy ? normalizeForFuzzyMatch($normalizedContent) : $normalizedContent;
+ // Uniqueness base, normalized once instead of once per edit.
+ $uniquenessBase = normalizeForFuzzyMatch($replacementBaseContent);
+
+ $matchedEdits = [];
+ foreach ($normalizedEdits as $i => $edit) {
+ $fuzzyOldText = normalizeForFuzzyMatch($edit['oldText']);
+
+ $index = strpos($replacementBaseContent, $edit['oldText']);
+ if ($index !== false) {
+ $matchIndex = $index;
+ $matchLength = strlen($edit['oldText']);
+ } else {
+ $fuzzyIndex = $fuzzyOldText === '' ? false : strpos($uniquenessBase, $fuzzyOldText);
+ if ($fuzzyIndex === false) {
+ throw getNotFoundError($path, $i, $total);
+ }
+ $matchIndex = $fuzzyIndex;
+ $matchLength = strlen($fuzzyOldText);
+ }
+
+ $occurrences = $fuzzyOldText === '' ? 0 : substr_count($uniquenessBase, $fuzzyOldText);
+ if ($occurrences > 1) {
+ throw getDuplicateError($path, $i, $total, $occurrences);
+ }
+
+ $matchedEdits[] = [
+ 'editIndex' => $i,
+ 'matchIndex' => $matchIndex,
+ 'matchLength' => $matchLength,
+ 'newText' => $edit['newText'],
+ ];
+ }
+
+ usort($matchedEdits, fn ($a, $b) => $a['matchIndex'] <=> $b['matchIndex']);
+ for ($i = 1; $i < count($matchedEdits); $i++) {
+ $prev = $matchedEdits[$i - 1];
+ $curr = $matchedEdits[$i];
+ if ($prev['matchIndex'] + $prev['matchLength'] > $curr['matchIndex']) {
+ throw new \RuntimeException("edits[{$prev['editIndex']}] and edits[{$curr['editIndex']}] overlap in {$path}. Merge them into one edit or target disjoint regions.");
+ }
+ }
+
+ $baseContent = $normalizedContent;
+ $newContent = $needsFuzzy
+ ? applyReplacementsPreservingUnchangedLines($normalizedContent, $replacementBaseContent, $matchedEdits)
+ : applyReplacements($replacementBaseContent, $matchedEdits);
+
+ if ($baseContent === $newContent) {
+ throw getNoChangeError($path, $total);
+ }
+
+ return ['baseContent' => $baseContent, 'newContent' => $newContent];
+}
+
+/**
+ * Generate a standard unified patch (context lines = 4).
+ *
+ * @param string $path
+ * @param string $oldContent
+ * @param string $newContent
+ * @param int $contextLines
+ */
+function generateUnifiedPatch(string $path, string $oldContent, string $newContent, int $contextLines = 4): string {
+ // Use `diff -u` style output via pure PHP when sebastian/diff is unavailable.
+ // Fallback: hand-rolled minimal unified patch.
+
+ $oldLines = explode("\n", $oldContent);
+ $newLines = explode("\n", $newContent);
+
+ // If sebastian/diff is available, prefer it
+ if (class_exists(\SebastianBergmann\Diff\Differ::class)) {
+ $builder = new \SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder("--- {$path}\n+++ {$path}\n", false);
+ $differ = new \SebastianBergmann\Diff\Differ($builder);
+
+ return $differ->diff($oldContent, $newContent);
+ }
+
+ // Minimal fallback: produce a simple patch header + line-by-line diff
+ $out = "--- {$path}\n+++ {$path}\n";
+ // Use LCS-based hunk generation if possible, otherwise naive line iteration
+ $max = max(count($oldLines), count($newLines));
+ $out .= '@@ -1,' . count($oldLines) . ' +1,' . count($newLines) . " @@\n";
+ $i = 0;
+ $j = 0;
+ while ($i < count($oldLines) || $j < count($newLines)) {
+ $o = $oldLines[$i] ?? null;
+ $n = $newLines[$j] ?? null;
+ if ($o === $n) {
+ $out .= ' ' . ($o ?? '') . "\n";
+ $i++;
+ $j++;
+ } elseif ($o !== null && $n !== null) {
+ $out .= '-' . $o . "\n";
+ $out .= '+' . $n . "\n";
+ $i++;
+ $j++;
+ } elseif ($o !== null) {
+ $out .= '-' . $o . "\n";
+ $i++;
+ } else {
+ $out .= '+' . $n . "\n";
+ $j++;
+ }
+ if ($i + $j > 20000) {
+ break;
+ } // safety cap
+ }
+
+ return $out;
+}
+
+/**
+ * Generate display-oriented diff with line numbers and context.
+ *
+ * @param string $oldContent
+ * @param string $newContent
+ * @param int $contextLines
+ *
+ * @return array{diff: string, firstChangedLine: int|null}
+ */
+function generateDiffString(string $oldContent, string $newContent, int $contextLines = 4): array {
+ $oldLines = $oldContent === '' ? [] : explode("\n", $oldContent);
+ $newLines = $newContent === '' ? [] : explode("\n", $newContent);
+
+ // Line-level diff parts via LCS.
+ $parts = diffLinesLcs($oldLines, $newLines);
+
+ $maxLineNum = max(count($oldLines), count($newLines), 1);
+ $lineNumWidth = strlen((string)$maxLineNum);
+
+ $output = [];
+ $oldLineNum = 1;
+ $newLineNum = 1;
+ $lastWasChange = false;
+ $firstChangedLine = null;
+
+ $totalParts = count($parts);
+ for ($pi = 0; $pi < $totalParts; $pi++) {
+ $part = $parts[$pi];
+ $raw = $part['value'];
+ $isAdded = $part['added'];
+ $isRemoved = $part['removed'];
+ $isContext = !$isAdded && !$isRemoved;
+
+ if ($isAdded || $isRemoved) {
+ if ($firstChangedLine === null) {
+ $firstChangedLine = $newLineNum;
+ }
+ foreach ($raw as $line) {
+ if ($isAdded) {
+ $num = str_pad((string)$newLineNum, $lineNumWidth, ' ', STR_PAD_LEFT);
+ $output[] = "+{$num} {$line}";
+ $newLineNum++;
+ } else {
+ $num = str_pad((string)$oldLineNum, $lineNumWidth, ' ', STR_PAD_LEFT);
+ $output[] = "-{$num} {$line}";
+ $oldLineNum++;
+ }
+ }
+ $lastWasChange = true;
+ } else {
+ // Context block
+ $nextIsChange = $pi + 1 < $totalParts && ($parts[$pi + 1]['added'] || $parts[$pi + 1]['removed']);
+ $hasLeadingChange = $lastWasChange;
+ $hasTrailingChange = $nextIsChange;
+
+ if ($hasLeadingChange && $hasTrailingChange) {
+ if (count($raw) <= $contextLines * 2) {
+ foreach ($raw as $line) {
+ $num = str_pad((string)$oldLineNum, $lineNumWidth, ' ', STR_PAD_LEFT);
+ $output[] = " {$num} {$line}";
+ $oldLineNum++;
+ $newLineNum++;
+ }
+ } else {
+ $leading = array_slice($raw, 0, $contextLines);
+ $trailing = array_slice($raw, -$contextLines);
+ $skipped = count($raw) - count($leading) - count($trailing);
+ foreach ($leading as $line) {
+ $num = str_pad((string)$oldLineNum, $lineNumWidth, ' ', STR_PAD_LEFT);
+ $output[] = " {$num} {$line}";
+ $oldLineNum++;
+ $newLineNum++;
+ }
+ $output[] = ' ' . str_pad('', $lineNumWidth, ' ') . ' ...';
+ $oldLineNum += $skipped;
+ $newLineNum += $skipped;
+ foreach ($trailing as $line) {
+ $num = str_pad((string)$oldLineNum, $lineNumWidth, ' ', STR_PAD_LEFT);
+ $output[] = " {$num} {$line}";
+ $oldLineNum++;
+ $newLineNum++;
+ }
+ }
+ } elseif ($hasLeadingChange) {
+ $shown = array_slice($raw, 0, $contextLines);
+ $skipped = count($raw) - count($shown);
+ foreach ($shown as $line) {
+ $num = str_pad((string)$oldLineNum, $lineNumWidth, ' ', STR_PAD_LEFT);
+ $output[] = " {$num} {$line}";
+ $oldLineNum++;
+ $newLineNum++;
+ }
+ if ($skipped > 0) {
+ $output[] = ' ' . str_pad('', $lineNumWidth, ' ') . ' ...';
+ $oldLineNum += $skipped;
+ $newLineNum += $skipped;
+ }
+ } elseif ($hasTrailingChange) {
+ $skipped = max(0, count($raw) - $contextLines);
+ if ($skipped > 0) {
+ $output[] = ' ' . str_pad('', $lineNumWidth, ' ') . ' ...';
+ $oldLineNum += $skipped;
+ $newLineNum += $skipped;
+ }
+ foreach (array_slice($raw, $skipped) as $line) {
+ $num = str_pad((string)$oldLineNum, $lineNumWidth, ' ', STR_PAD_LEFT);
+ $output[] = " {$num} {$line}";
+ $oldLineNum++;
+ $newLineNum++;
+ }
+ } else {
+ $oldLineNum += count($raw);
+ $newLineNum += count($raw);
+ }
+ $lastWasChange = false;
+ }
+ }
+
+ return ['diff' => implode("\n", $output), 'firstChangedLine' => $firstChangedLine];
+}
+
+/**
+ * Compute line-level diff parts (added/removed/context) via LCS DP.
+ *
+ * Parts strictly alternate between change runs and context runs by
+ * construction. For very large inputs the O(m*n) table is skipped and the
+ * whole files are reported as a single removed + added pair.
+ *
+ * @param string[] $a
+ * @param string[] $b
+ *
+ * @return array<int, array{value: string[], added: bool, removed: bool}>
+ */
+function diffLinesLcs(array $a, array $b): array {
+ $m = count($a);
+ $n = count($b);
+
+ // For large files cap DP to avoid O(m*n) explosion — fall back to simple scan
+ if ($m * $n > 4_000_000) {
+ // Simple fallback: treat whole files as two parts if not equal
+ if ($a === $b) {
+ return [['value' => $a, 'added' => false, 'removed' => false]];
+ }
+
+ return [
+ ['value' => $a, 'added' => false, 'removed' => true],
+ ['value' => $b, 'added' => true, 'removed' => false],
+ ];
+ }
+
+ // Build LCS table
+ $dp = array_fill(0, $m + 1, array_fill(0, $n + 1, 0));
+ for ($i = $m - 1; $i >= 0; $i--) {
+ for ($j = $n - 1; $j >= 0; $j--) {
+ if ($a[$i] === $b[$j]) {
+ $dp[$i][$j] = $dp[$i + 1][$j + 1] + 1;
+ } else {
+ $dp[$i][$j] = max($dp[$i + 1][$j], $dp[$i][$j + 1]);
+ }
+ }
+ }
+
+ // Walk to produce edit script, grouping runs by kind
+ $parts = [];
+ $i = 0;
+ $j = 0;
+ $buf = [];
+ $bufType = null; // 'context' | 'removed' | 'added'
+
+ /**
+ * @param list<string> $buf
+ * @param 'context'|'removed'|'added'|null $bufType
+ * @param list<array{value: list<string>, added: bool, removed: bool}> $parts
+ *
+ * @return array{0: list<array{value: list<string>, added: bool, removed: bool}>, 1: list<string>}
+ */
+ $flush = static function(array $buf, ?string $bufType, array $parts): array {
+ if ($buf === []) {
+ return [$parts, $buf];
+ }
+ $parts[] = match ($bufType) {
+ 'added' => ['value' => $buf, 'added' => true, 'removed' => false],
+ 'removed' => ['value' => $buf, 'added' => false, 'removed' => true],
+ default => ['value' => $buf, 'added' => false, 'removed' => false],
+ };
+
+ return [$parts, []];
+ };
+
+ while ($i < $m || $j < $n) {
+ if ($i < $m && $j < $n && $a[$i] === $b[$j]) {
+ if ($bufType !== 'context' && $bufType !== null) {
+ [$parts, $buf] = $flush($buf, $bufType, $parts);
+ }
+ $bufType = 'context';
+ $buf[] = $a[$i];
+ $i++;
+ $j++;
+ } elseif ($j < $n && ($i >= $m || $dp[$i][$j + 1] >= $dp[$i + 1][$j])) {
+ if ($bufType !== 'added') {
+ [$parts, $buf] = $flush($buf, $bufType, $parts);
+ $bufType = 'added';
+ }
+ $buf[] = $b[$j];
+ $j++;
+ } else {
+ if ($bufType !== 'removed') {
+ [$parts, $buf] = $flush($buf, $bufType, $parts);
+ $bufType = 'removed';
+ }
+ $buf[] = $a[$i];
+ $i++;
+ }
+ }
+ [$parts] = $flush($buf, $bufType, $parts);
+
+ return $parts;
+}
diff --git a/mcp/edit.php b/mcp/edit.php
new file mode 100644
index 0000000..01dadf9
--- /dev/null
+++ b/mcp/edit.php
@@ -0,0 +1,297 @@
+<?php
+
+declare(strict_types=1);
+
+namespace CodingAgent\Tools;
+
+require_once __DIR__ . '/edit-diff.php';
+
+interface EditOperations {
+ /** @throws \RuntimeException if not readable/writable */
+ public function access(string $absolutePath): void;
+
+ /** @return string raw file bytes */
+ public function readFile(string $absolutePath): string;
+
+ public function writeFile(string $absolutePath, string $content): void;
+}
+
+final class DefaultEditOperations implements EditOperations {
+ public function access(string $absolutePath): void {
+ if (!is_readable($absolutePath) || !is_writable($absolutePath)) {
+ // Match Node's fs.access error code style
+ $code = !file_exists($absolutePath) ? 'ENOENT' : 'EACCES';
+
+ throw new \RuntimeException("Could not access file: {$absolutePath}. Error code: {$code}");
+ }
+ }
+
+ public function readFile(string $absolutePath): string {
+ $data = @file_get_contents($absolutePath);
+ if ($data === false) {
+ throw new \RuntimeException("Failed to read file: {$absolutePath}");
+ }
+
+ return $data;
+ }
+
+ public function writeFile(string $absolutePath, string $content): void {
+ $result = @file_put_contents($absolutePath, $content);
+ if ($result === false) {
+ throw new \RuntimeException("Failed to write file: {$absolutePath}");
+ }
+ }
+}
+
+/**
+ * Expand ~ and resolve relative to $cwd.
+ *
+ * @param string $filePath
+ * @param string $cwd
+ */
+function resolveToCwd(string $filePath, string $cwd): string {
+ // Expand leading ~/
+ if (str_starts_with($filePath, '~/') || $filePath === '~') {
+ $home = getenv('HOME') ?: ($_SERVER['HOME'] ?? '');
+ if ($home !== '') {
+ $filePath = $home . substr($filePath, 1);
+ }
+ }
+ // Strip @ prefix used by some tools
+ if (str_starts_with($filePath, '@')) {
+ $filePath = substr($filePath, 1);
+ }
+ // Already absolute
+ if (str_starts_with($filePath, '/')) {
+ return $filePath;
+ }
+
+ return rtrim($cwd, '/') . '/' . $filePath;
+}
+
+/**
+ * Serialize file mutation operations targeting the same file.
+ * Uses per-file flock; different files run without blocking each other.
+ *
+ * @template T
+ *
+ * @param string $filePath
+ * @param callable(): T $fn
+ *
+ * @return T
+ */
+function withFileMutationQueue(string $filePath, callable $fn): mixed {
+ $resolved = realpath($filePath) ?: $filePath;
+ $lockFile = sys_get_temp_dir() . '/edit-mutex-' . md5($resolved) . '.lock';
+ $handle = fopen($lockFile, 'c');
+ if ($handle === false) {
+ // Fallback: run without lock
+ return $fn();
+ }
+
+ try {
+ flock($handle, LOCK_EX);
+
+ return $fn();
+ } finally {
+ flock($handle, LOCK_UN);
+ fclose($handle);
+ }
+}
+
+/**
+ * @param mixed $value
+ *
+ * @phpstan-assert-if-true array{oldText: string, newText: string} $value
+ */
+function isSingleEditInput(mixed $value): bool {
+ if (!is_array($value)) {
+ return false;
+ }
+
+ return isset($value['oldText'], $value['newText'])
+ && is_string($value['oldText'])
+ && is_string($value['newText']);
+}
+
+/**
+ * Normalise relaxed model output:
+ * - edits may be JSON string
+ * - edits may be single object instead of array
+ * - legacy top-level oldText/newText
+ *
+ * @param mixed $input
+ *
+ * @return array{path?: string, edits?: mixed, oldText?: mixed, newText?: mixed}
+ */
+function prepareEditArguments(mixed $input): array {
+ if (!is_array($input)) {
+ return [];
+ }
+
+ $args = $input;
+
+ if (isset($args['edits']) && is_string($args['edits'])) {
+ $parsed = json_decode($args['edits'], true);
+ if (json_last_error() === JSON_ERROR_NONE) {
+ if (is_array($parsed) && array_is_list($parsed)) {
+ $args['edits'] = $parsed;
+ } elseif (isSingleEditInput($parsed)) {
+ $args['edits'] = [$parsed];
+ }
+ }
+ } elseif (isset($args['edits']) && isSingleEditInput($args['edits'])) {
+ $args['edits'] = [$args['edits']];
+ }
+
+ // Legacy top-level oldText / newText
+ if (isset($args['oldText'], $args['newText']) && is_string($args['oldText']) && is_string($args['newText'])) {
+ $edits = isset($args['edits']) && is_array($args['edits']) ? $args['edits'] : [];
+ $edits[] = ['oldText' => $args['oldText'], 'newText' => $args['newText']];
+ unset($args['oldText'], $args['newText']);
+ $args['edits'] = $edits;
+ }
+
+ return $args;
+}
+
+/**
+ * @param array<array-key, mixed> $input
+ *
+ * @return array{path: string, edits: list<array{oldText: string, newText: string}>}
+ */
+function validateEditInput(array $input): array {
+ if (!isset($input['edits']) || !is_array($input['edits']) || count($input['edits']) === 0) {
+ throw new \InvalidArgumentException('Edit tool input is invalid. edits must contain at least one replacement.');
+ }
+ if (!isset($input['path']) || !is_string($input['path']) || $input['path'] === '') {
+ throw new \InvalidArgumentException('Edit tool input is invalid. path must be a non-empty string.');
+ }
+
+ $edits = [];
+
+ foreach ($input['edits'] as $edit) {
+ if (!is_array($edit) || !isset($edit['oldText'], $edit['newText']) || !is_string($edit['oldText']) || !is_string($edit['newText'])) {
+ throw new \InvalidArgumentException('Edit tool input is invalid. Each edit must have string oldText and newText.');
+ }
+
+ $edits[] = ['oldText' => $edit['oldText'], 'newText' => $edit['newText']];
+ }
+
+ return ['path' => $input['path'], 'edits' => $edits];
+}
+
+/**
+ * Compute preview diff without writing the file.
+ *
+ * @param string $path
+ * @param list<array{oldText: string, newText: string}> $edits
+ * @param string $cwd
+ * @param ?EditOperations $ops
+ *
+ * @return array{diff: string, firstChangedLine: int|null}|array{error: string}
+ */
+function computeEditsDiff(string $path, array $edits, string $cwd, ?EditOperations $ops = null): array {
+ $ops ??= new DefaultEditOperations();
+ $absolutePath = resolveToCwd($path, $cwd);
+
+ try {
+ try {
+ $ops->access($absolutePath);
+ } catch (\Throwable $e) {
+ // For preview allow readable-only check fallback
+ if (!is_readable($absolutePath)) {
+ return ['error' => "Could not edit file: {$path}. Error code: ENOENT."];
+ }
+ }
+ $rawContent = $ops->readFile($absolutePath);
+ ['text' => $content] = splitBom($rawContent);
+ $normalizedContent = normalizeToLF($content);
+ $result = applyEditsToNormalizedContent($normalizedContent, $edits, $path);
+
+ return generateDiffString($result['baseContent'], $result['newContent']);
+ } catch (\Throwable $e) {
+ return ['error' => $e->getMessage()];
+ }
+}
+
+final class EditToolDefinition {
+ public const NAME = 'edit';
+ public const LABEL = 'edit';
+ public const DESCRIPTION = 'Edit a single file using exact text replacement. Every edits[].oldText must match a unique, non-overlapping region of the original file. If two changes affect the same block or nearby lines, merge them into one edit instead of emitting overlapping edits. Do not include large unchanged regions just to connect distant changes.';
+
+ public function __construct(
+ private readonly string $cwd,
+ private readonly EditOperations $ops,
+ ) {}
+
+ /**
+ * Prepare / normalise raw model arguments.
+ *
+ * @param mixed $input
+ *
+ * @return array{path?: string, edits?: mixed, oldText?: mixed, newText?: mixed}
+ */
+ public function prepareArguments(mixed $input): array {
+ return prepareEditArguments($input);
+ }
+
+ /**
+ * Execute the edit.
+ *
+ * @param array{path: string, edits: list<array{oldText: string, newText: string}>} $input
+ *
+ * @return array{content: array<int, array{type: string, text: string}>, details: array{diff: string, patch: string, firstChangedLine?: int|null}}
+ */
+ public function execute(array $input): array {
+ $validated = validateEditInput($this->prepareArguments($input));
+ $path = $validated['path'];
+ $edits = $validated['edits'];
+ $absolutePath = resolveToCwd($path, $this->cwd);
+
+ return withFileMutationQueue($absolutePath, function() use ($path, $edits, $absolutePath): array {
+ // Access check
+ try {
+ $this->ops->access($absolutePath);
+ } catch (\Throwable $e) {
+ throw new \RuntimeException("Could not edit file: {$path}. {$e->getMessage()}.");
+ }
+
+ $buffer = $this->ops->readFile($absolutePath);
+ ['bom' => $bom, 'text' => $content] = splitBom($buffer);
+ $originalEnding = detectLineEnding($content);
+ $normalizedContent = normalizeToLF($content);
+
+ $result = applyEditsToNormalizedContent($normalizedContent, $edits, $path);
+ $baseContent = $result['baseContent'];
+ $newContent = $result['newContent'];
+
+ $finalContent = $bom . restoreLineEndings($newContent, $originalEnding);
+ $this->ops->writeFile($absolutePath, $finalContent);
+
+ $diffResult = generateDiffString($baseContent, $newContent);
+ $patch = generateUnifiedPatch($path, $baseContent, $newContent);
+
+ return [
+ 'content' => [
+ ['type' => 'text', 'text' => 'Successfully replaced ' . count($edits) . " block(s) in {$path}."],
+ ],
+ 'details' => [
+ 'diff' => $diffResult['diff'],
+ 'patch' => $patch,
+ 'firstChangedLine' => $diffResult['firstChangedLine'] ?? null,
+ ],
+ ];
+ });
+ }
+}
+
+/**
+ * Factory — mirrors createEditToolDefinition(cwd, options).
+ *
+ * @param string $cwd
+ * @param ?EditOperations $operations
+ */
+function createEditToolDefinition(string $cwd, ?EditOperations $operations = null): EditToolDefinition {
+ return new EditToolDefinition($cwd, $operations ?? new DefaultEditOperations());
+}
diff --git a/mcp/index.php b/mcp/index.php
new file mode 100755
index 0000000..8613511
--- /dev/null
+++ b/mcp/index.php
@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * Vvveb
+ *
+ * Copyright (C) 2022 Ziadin Givan
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+//define('DISABLE_PLUGIN_ON_ERORR', true);
+defined('APP') || define('APP', 'mcp');
+
+if (!defined('DIR_ROOT')) {
+ include __DIR__ . '/../index.php';
+}
diff --git a/mcp/str_replace_editor.php b/mcp/str_replace_editor.php
new file mode 100644
index 0000000..6d82cd6
--- /dev/null
+++ b/mcp/str_replace_editor.php
@@ -0,0 +1,380 @@
+<?php
+
+declare(strict_types=1);
+
+if (!class_exists('McpToolError')) {
+ require_once __DIR__ . '/tool_error.php';
+}
+if (file_exists(__DIR__ . '/edit.php')) {
+ require_once __DIR__ . '/edit.php';
+}
+if (file_exists(__DIR__ . '/edit-diff.php')) {
+ require_once __DIR__ . '/edit-diff.php';
+}
+
+const TRUNCATED_MESSAGE = '<response clipped><NOTE>To save on context only part of this file has been shown to you. You should retry this tool after you have searched inside the file with `grep -n` in order to find the line numbers of what you are looking for.</NOTE>';
+
+const DEFAULT_DESCRIPTION = <<<'DESC'
+ Custom editing tool for viewing, creating and editing files
+ * State is persistent across command calls and discussions with the user
+ * If `path` is a file, `view` displays the result of applying `cat -n`. If `path` is a directory, `view` lists non-hidden files and directories up to 2 levels deep
+ * The `create` command cannot be used if the specified `path` already exists as a file
+ * The `edit` command applies multiple disjoint exact replacements via `edits[].oldText`/`newText` — each oldText must match a unique non-overlapping region
+ * If a `command` generates a long output, it will be truncated and marked with `<response clipped>`
+ DESC;
+
+class FsError extends McpToolError {
+ public function __construct(
+ string $message,
+ public readonly string $fsCode = 'FS_ERROR',
+ ?Throwable $previous = null,
+ ) {
+ parent::__construct($message, 0, $previous);
+ }
+}
+
+/**
+ * Filesystem target value object.
+ */
+final class FsTarget {
+ public function __construct(
+ public readonly string $absolutePath,
+ public readonly string $displayPath,
+ ) {}
+}
+
+/**
+ * Filesystem info value object.
+ */
+final class FsInfo {
+ public function __construct(
+ /** @var 'file'|'directory'|'other' */
+ public readonly string $type,
+ public readonly ?string $version = null, // mtime hash placeholder
+ ) {}
+}
+
+function maybeTruncate(string $content, int $maxOutputChars): string {
+ return mb_strlen($content) <= $maxOutputChars
+ ? $content
+ : mb_substr($content, 0, $maxOutputChars) . TRUNCATED_MESSAGE;
+}
+
+function resolveTarget(string $path): FsTarget {
+ if (trim($path) === '') {
+ throw new InvalidArgumentException('path must be a non-empty string');
+ }
+ if (!str_starts_with($path, '/')) {
+ throw new InvalidArgumentException("The path {$path} is not an absolute path, it should start with `/`. Maybe you meant /{$path}?");
+ }
+
+ // No symlink resolution enforced here; displayPath equals absolutePath.
+ return new FsTarget($path, $path);
+}
+
+/**
+ * @param FsTarget $target
+ * @param string $command
+ *
+ * @throws FsError
+ */
+function statExisting(FsTarget $target, string $command): FsInfo {
+ $path = $target->absolutePath;
+
+ if (!file_exists($path)) {
+ throw new FsError("The path {$target->displayPath} does not exist. Please provide a valid path.", 'FS_NOT_FOUND');
+ }
+
+ $isDir = is_dir($path);
+ $isFile = is_file($path);
+
+ if ($isDir && $command !== 'view') {
+ throw new FsError("The path {$target->displayPath} is a directory and only the `view` command can be used on directories", 'FS_NOT_REGULAR_FILE');
+ }
+
+ if ($isDir) {
+ return new FsInfo('directory');
+ }
+ if ($isFile) {
+ // Use mtime as a version token
+ $version = (string)@filemtime($path);
+
+ return new FsInfo('file', $version);
+ }
+
+ return new FsInfo('other');
+}
+
+function requiredForCommand(?string $value, string $parameter, string $command, bool $allowEmpty = true): string {
+ if ($value === null) {
+ throw new InvalidArgumentException("Parameter `{$parameter}` is required for command: {$command}");
+ }
+ if (!$allowEmpty && $value === '') {
+ throw new InvalidArgumentException("Parameter `{$parameter}` is empty for command: {$command}");
+ }
+
+ return $value;
+}
+
+/**
+ * @param string $path
+ * @param string $content
+ * @param int $maxOutputChars
+ * @param array<array-key, mixed>|null $viewRange
+ */
+function formatFileView(string $path, string $content, int $maxOutputChars, ?array $viewRange = null): string {
+ $allLines = explode("\n", $content);
+ $lines = $allLines;
+ $initialLine = 1;
+ $finalLine = null;
+ $prompt = "Here's the content of {$path} with line numbers (which has a total of " . count($allLines) . ' lines)';
+
+ if ($viewRange !== null) {
+ if (
+ count($viewRange) !== 2
+ || !isset($viewRange[0], $viewRange[1])
+ || !is_int($viewRange[0])
+ || !is_int($viewRange[1])
+ ) {
+ throw new InvalidArgumentException('Invalid `view_range`. It should be a list of two integers.');
+ }
+ [$requestedInitialLine, $requestedFinalLine] = $viewRange;
+ $initialLine = $requestedInitialLine;
+ $finalLine = $requestedFinalLine;
+
+ if ($initialLine < 1 || $initialLine > count($allLines)) {
+ throw new InvalidArgumentException('Invalid `view_range`: [' . implode(', ', $viewRange) . "]. Its first element `{$initialLine}` should be within the range of lines of the file: [1, " . count($allLines) . ']');
+ }
+ if ($finalLine > count($allLines)) {
+ throw new InvalidArgumentException('Invalid `view_range`: [' . implode(', ', $viewRange) . "]. Its second element `{$finalLine}` should be smaller than the number of lines in the file: `" . count($allLines) . '`');
+ }
+ if ($finalLine !== -1 && $finalLine < $initialLine) {
+ throw new InvalidArgumentException('Invalid `view_range`: [' . implode(', ', $viewRange) . "]. Its second element `{$finalLine}` should be larger or equal than its first `{$initialLine}`");
+ }
+
+ $lines = $finalLine === -1
+ ? array_slice($allLines, $initialLine - 1)
+ : array_slice($allLines, $initialLine - 1, $finalLine - $initialLine + 1);
+
+ $prompt .= " with view_range=[{$initialLine}, {$finalLine}]";
+ }
+
+ $numbered = implode("\n", array_map(
+ fn (string $line, int $index): string => sprintf('%6d %s', $initialLine + $index, $line),
+ $lines,
+ array_keys($lines)
+ ));
+
+ return maybeTruncate("{$prompt}:\n{$numbered}\n", $maxOutputChars);
+}
+
+/**
+ * List directory up to 2 levels deep, excluding hidden / node_modules / __pycache__.
+ *
+ * @param FsTarget $target
+ * @param int $maxOutputChars
+ */
+function listDirectory(FsTarget $target, int $maxOutputChars): string {
+ /** @return string[] rows like "d\t/path" */
+ $visit = function(FsTarget $dir, int $depth) use (&$visit): array {
+ $entries = @scandir($dir->absolutePath);
+ if ($entries === false) {
+ throw new FsError("cannot list directory {$dir->displayPath}", 'FS_IO_ERROR');
+ }
+ $rows = [];
+ foreach ($entries as $name) {
+ if ($name === '.' || $name === '..') {
+ continue;
+ }
+ if (str_starts_with($name, '.') || $name === 'node_modules' || $name === '__pycache__') {
+ continue;
+ }
+ $full = rtrim($dir->absolutePath, '/') . '/' . $name;
+ $display = rtrim($dir->displayPath, '/') . '/' . $name;
+ $isDir = is_dir($full);
+ $isFile = is_file($full);
+ $type = $isDir ? 'd' : ($isFile ? 'f' : '?');
+ $rows[] = "{$type}\t{$display}";
+ if ($isDir && $depth < 2) {
+ $child = new FsTarget($full, $display);
+ $rows = array_merge($rows, $visit($child, $depth + 1));
+ }
+ }
+
+ return $rows;
+ };
+
+ $rows = array_merge(["d\t{$target->displayPath}"], $visit($target, 1));
+
+ // Binary-safe codepoint order on the display path.
+ usort($rows, static fn (string $left, string $right): int => substr($left, (int)strpos($left, "\t") + 1) <=> substr($right, (int)strpos($right, "\t") + 1));
+
+ $listing = maybeTruncate(implode("\n", $rows) . "\n", $maxOutputChars);
+
+ return "Here're the files and directories up to 2 levels deep in {$target->displayPath}, excluding hidden items, node_modules, and Python cache directories:\n{$listing}\n";
+}
+
+/**
+ * @param string $path
+ * @param array<array-key, mixed>|null $viewRange
+ * @param int $maxOutputChars
+ */
+function viewPath(string $path, ?array $viewRange, int $maxOutputChars): string {
+ $target = resolveTarget($path);
+ $info = statExisting($target, 'view');
+
+ if ($info->type === 'directory') {
+ if ($viewRange !== null) {
+ throw new InvalidArgumentException('The `view_range` parameter is not allowed when `path` points to a directory.');
+ }
+
+ return listDirectory($target, $maxOutputChars);
+ }
+
+ if ($info->type !== 'file') {
+ throw new FsError("cannot view \"{$target->displayPath}\": not a regular file or directory", 'FS_NOT_REGULAR_FILE');
+ }
+
+ $content = @file_get_contents($target->absolutePath);
+ if ($content === false) {
+ throw new FsError("cannot read file {$target->displayPath}", 'FS_IO_ERROR');
+ }
+
+ return formatFileView($target->displayPath, $content, $maxOutputChars, $viewRange);
+}
+
+function createFile(string $path, ?string $fileText): string {
+ $content = requiredForCommand($fileText, 'file_text', 'create');
+ $target = resolveTarget($path);
+
+ if (file_exists($target->absolutePath)) {
+ throw new InvalidArgumentException("File already exists at: {$target->displayPath}. Cannot overwrite files using command `create`.");
+ }
+
+ // Ensure parent directory exists
+ $dir = dirname($target->absolutePath);
+ if (!is_dir($dir) && !@mkdir($dir, 0777, true) && !is_dir($dir)) {
+ throw new FsError("cannot create parent directory for {$target->displayPath}", 'FS_IO_ERROR');
+ }
+
+ $written = @file_put_contents($target->absolutePath, $content, LOCK_EX);
+ if ($written === false) {
+ throw new FsError("failed to write {$target->displayPath}", 'FS_IO_ERROR');
+ }
+
+ return "New file created successfully at: {$target->displayPath}";
+}
+
+final class StrReplaceEditorConfig {
+ public function __construct(
+ public readonly int $maxOutputChars = 16_000,
+ public readonly string $description = DEFAULT_DESCRIPTION,
+ ) {
+ if ($maxOutputChars <= 0) {
+ throw new InvalidArgumentException('tool-str-replace-editor: maxOutputChars must be a positive safe integer');
+ }
+ if (trim($description) === '') {
+ throw new InvalidArgumentException('tool-str-replace-editor: description must be non-empty');
+ }
+ }
+}
+
+final class StrReplaceEditor {
+ private StrReplaceEditorConfig $config;
+ private mixed $editTool = null; // lazy CodingAgent\Tools\EditToolDefinition
+ private string $cwd;
+
+ public function __construct(?StrReplaceEditorConfig $config = null, ?string $cwd = null) {
+ $this->config = $config ?? new StrReplaceEditorConfig();
+ $this->cwd = $cwd ?? getcwd() ?: '/tmp';
+ }
+
+ private function getEditTool(): mixed {
+ if ($this->editTool !== null) {
+ return $this->editTool;
+ }
+ if (!class_exists('\\CodingAgent\\Tools\\EditToolDefinition')) {
+ throw new \RuntimeException('Edit tool not available: edit.php not loaded. Ensure edit.php and edit-diff.php are in the same directory.');
+ }
+ $class = '\\CodingAgent\\Tools\\EditToolDefinition';
+ // EditToolDefinition expects cwd + EditOperations; use DefaultEditOperations if available
+ $opsClass = '\\CodingAgent\\Tools\\DefaultEditOperations';
+ $ops = class_exists($opsClass) ? new $opsClass() : null;
+ $this->editTool = new $class($this->cwd, $ops);
+
+ return $this->editTool;
+ }
+
+ /**
+ * Direct multi-edit via CodingAgent\Tools engine (fuzzy, BOM, line-ending aware).
+ *
+ * @param array{path:string, edits:array<int, array{oldText:string,newText:string}>} $input
+ *
+ * @return array{content: array<int, array{type: string, text: string}>, details: array{diff: string, patch: string, firstChangedLine?: int|null}}
+ */
+ public function edit(array $input): array {
+ return $this->getEditTool()->execute($input);
+ }
+
+ /**
+ * Execute a multi-edit call and flatten the structured engine result
+ * to the string contract (message + diff).
+ *
+ * @param string $path
+ * @param mixed $edits raw `edits` argument (array, JSON string or single object)
+ */
+ private function executeEdit(string $path, mixed $edits): string {
+ // The engine normalises relaxed input itself (JSON string, single
+ // object, legacy oldText/newText) and validates `edits`.
+ $result = $this->edit(['path' => $path, 'edits' => $edits]);
+ $diff = $result['details']['diff'];
+ $msg = $result['content'][0]['text'] ?? "Edited {$path}";
+
+ return $diff !== '' ? "{$msg}\n{$diff}" : $msg;
+ }
+
+ /**
+ * Execute a tool call.
+ *
+ * @param array<array-key, mixed> $args Unvalidated tool arguments from JSON-RPC input.
+ */
+ public function execute(array $args): string {
+ $command = $args['command'] ?? throw new InvalidArgumentException('Missing required parameter: command');
+ $path = $args['path'] ?? throw new InvalidArgumentException('Missing required parameter: path');
+
+ if (!is_string($command) || !is_string($path)) {
+ throw new InvalidArgumentException('Invalid required parameters: command and path must be strings');
+ }
+
+ $viewRange = $args['view_range'] ?? null;
+
+ if ($viewRange !== null && !is_array($viewRange)) {
+ throw new InvalidArgumentException('Invalid `view_range`. It should be a list of two integers.');
+ }
+
+ $fileText = $args['file_text'] ?? null;
+
+ if ($fileText !== null && !is_string($fileText)) {
+ throw new InvalidArgumentException('Invalid `file_text`. It should be a string.');
+ }
+
+ return match ($command) {
+ 'view' => viewPath($path, $viewRange, $this->config->maxOutputChars),
+ 'create' => createFile($path, $fileText),
+ 'edit' => $this->executeEdit($path, $args['edits'] ?? null),
+ default => throw new InvalidArgumentException("Unknown command: {$command}"),
+ };
+ }
+}
+
+/*
+Example usage (uncomment to test):
+
+$editor = new StrReplaceEditor();
+echo $editor->execute(['command' => 'view', 'path' => '/tmp']);
+echo $editor->execute(['command' => 'create', 'path' => '/tmp/hello.txt', 'file_text' => "hello\nworld\n"]);
+echo $editor->execute(['command' => 'view', 'path' => '/tmp/hello.txt', 'view_range' => [1, 1]]);
+// integrated edit (multi-edit, fuzzy, BOM-aware via edit.php)
+echo $editor->execute(['command' => 'edit', 'path' => '/tmp/hello.txt', 'edits' => [['oldText' => "hello\n", 'newText' => "hey\n"], ['oldText' => "world", 'newText' => "earth"]]]);
+print_r($editor->edit(['path' => '/tmp/hello.txt', 'edits' => [['oldText' => 'hey', 'newText' => 'hello']]])); // structured result with diff/patch
+*/
diff --git a/mcp/tool_error.php b/mcp/tool_error.php
new file mode 100644
index 0000000..b8a80d3
--- /dev/null
+++ b/mcp/tool_error.php
@@ -0,0 +1,19 @@
+<?php
+
+declare(strict_types=1);
+
+/*
+Routine MCP tool failure.
+
+Throw McpToolError (instead of RuntimeException) for expected caller-side
+failures: missing files, bad arguments, unknown models/themes/plugins,
+sandbox escapes, disabled-write gates, caps. These return clean isError
+results WITHOUT hitting the server error log, so an agent's early
+trial-and-error exploration doesn't flood it.
+
+Genuine problems (IO failures, DB outages, broken environments, coding
+bugs) keep throwing RuntimeException/Error and are still logged with
+traces under DEBUG in tools_call().
+*/
+
+class McpToolError extends RuntimeException {}
diff --git a/mcp/tools.php b/mcp/tools.php
new file mode 100644
index 0000000..f0c86ed
--- /dev/null
+++ b/mcp/tools.php
@@ -0,0 +1,720 @@
+<?php
+
+$tools = [
+ /*
+ * Coding harness tools: file access, shell execution and database queries.
+ *
+ * These tools expose the local project to AI coding agents (like read/write/
+ * edit/bash in coding harnesses). All file paths are sandboxed inside the
+ * installation root (configurable via config key mcp.tools.root), database
+ * queries are restricted to read-only statements unless config key
+ * mcp.tools.db_write is enabled and every call requires MCP admin
+ * authentication (see McpBase::auth()).
+ */
+ [
+ 'name' => 'crud',
+ 'description' => 'CMS data models (post, product, user, order, ... - crud_models lists all). params keys match procedure IN names: add/edit nest the record under the model key with per-language <model>_content lists (flat fields are rejected with an example); edit merges, only supplied fields change; delete takes id arrays (scalars auto-wrapped); get/getAll take flat filters plus search/start/limit/order_by/direction, and columns trims returned fields to just names. add returns the new id plus per-list rows-written counts (content tables have no auto id). language_id/site_id default to 1, slugs auto-generated from names. Reads always allowed. Call crud_models first for exact params.',
+ 'type' => 'action',
+ 'inputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'model' => [
+ 'type' => 'string',
+ 'description' => 'Model name, e.g. product, user, post, order, category (basename of admin/sql/mysqli/<model>.sql, CamelCase also accepted)'
+ ],
+ 'operation' => [
+ 'type' => 'string',
+ 'enum' => ['get', 'getAll', 'add', 'edit', 'delete'],
+ 'description' => 'CRUD operation mapping to a model procedure: get (single record), getAll (list), add (create), edit (update), delete'
+ ],
+ 'columns' => [
+ 'type' => 'array',
+ 'items' => ['type' => 'string'],
+ 'description' => 'get/getAll only: return just these columns (e.g. ["post_id","name"] skips heavy content bodies); unknown names error with real keys'
+ ],
+ 'params' => [
+ 'type' => 'object',
+ 'description' => 'Procedure parameters keyed by IN name: nested record under the model key plus <model>_content lists for add/edit, id arrays for delete, flat scalar filters for get/getAll (see tool description for shapes)'
+ ]
+ ],
+ 'required' => ['model', 'operation'],
+ 'additionalProperties' => false
+ ],
+ 'outputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'model' => ['type' => 'string'],
+ 'operation' => ['type' => 'string'],
+ 'result' => ['description' => 'Native model procedure result (record, list with count, insert id or affected rows)']
+ ],
+ 'required' => ['model', 'operation', 'result']
+ ],
+ 'annotations' => [
+ 'readOnlyHint' => false,
+ 'destructiveHint' => true,
+ 'idempotentHint' => false,
+ 'openWorldHint' => false
+ ]
+ ],
+ [
+ 'name' => 'crud_models',
+ 'description' => 'Discover available CMS data models for the crud tool. Without arguments lists every model with its procedure names and crud-callability. With a model name returns each procedure with IN parameters (required flags, and field names for ROW/ROWS record params). Convention reminder: crud add/edit nest the record under the first ARRAY parameter (usually the model name) with translations in <model>_content lists - flat field params are rejected, and scalar ids for ARRAY params are auto-wrapped. Read-only.',
+ 'type' => 'action',
+ 'inputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'model' => [
+ 'type' => 'string',
+ 'description' => 'Optional model name (e.g. product). Omit to list all models; provide to describe one model\'s procedures and parameters.'
+ ]
+ ],
+ 'additionalProperties' => false
+ ],
+ 'outputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'models' => [
+ 'type' => 'array',
+ 'description' => 'All models (when model is omitted), each with model, crud-callable operations and all procedure names',
+ 'items' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'model' => ['type' => 'string'],
+ 'crud' => ['type' => 'array', 'items' => ['type' => 'string']],
+ 'procedures' => ['type' => 'array', 'items' => ['type' => 'string']]
+ ]
+ ]
+ ],
+ 'count' => ['type' => 'integer'],
+ 'model' => ['type' => 'string', 'description' => 'Described model (when model is provided)'],
+ 'procedures' => [
+ 'type' => 'array',
+ 'description' => 'Procedures of the model (when model is provided), each with name, crud-callability and IN parameters',
+ 'items' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'name' => ['type' => 'string'],
+ 'crud' => ['type' => 'boolean'],
+ 'params' => [
+ 'type' => 'array',
+ 'items' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'name' => ['type' => 'string'],
+ 'type' => ['type' => 'string'],
+ 'required' => ['type' => 'boolean', 'description' => 'Must-supply param; omit it only when the call makes sense without it'],
+ 'fields' => ['type' => 'array', 'description' => 'Accepted field names for ROW/ROWS record params (table columns minus auto-managed keys)', 'items' => ['type' => 'string']],
+ 'required_fields' => ['type' => 'array', 'description' => 'Fields with no usable default that omit-fails the INSERT (present only when non-empty)', 'items' => ['type' => 'string']]
+ ]
+ ]
+ ]
+ ]
+ ]
+ ]
+ ],
+ 'required' => []
+ ],
+ 'annotations' => [
+ 'readOnlyHint' => true,
+ 'destructiveHint' => false,
+ 'idempotentHint' => true,
+ 'openWorldHint' => false
+ ]
+ ],
+ [
+ 'name' => 'admin',
+ 'description' => 'Manage CMS subsystems (thin CRUD stubs). Themes: list/get/market/activate/install/delete. Plugins: list/get/market/activate/deactivate/install/uninstall. Cron: list/run/run_all. Cache: clear by scope. Media lives in its own top-level media tool. Reads are always allowed.',
+ 'type' => 'action',
+ 'inputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'target' => [
+ 'type' => 'string',
+ 'enum' => ['themes', 'plugins', 'cron', 'cache'],
+ 'description' => 'Subsystem to manage: themes, plugins, cron or cache (media has its own top-level tool)'
+ ],
+ 'operation' => [
+ 'type' => 'string',
+ 'description' => 'Subsystem operation — themes: list/get/market/activate/install/delete; plugins: list/get/market/activate/deactivate/install/uninstall; cron: list/run/run_all; cache: clear'
+ ],
+ 'theme' => [
+ 'type' => 'string',
+ 'description' => 'Theme slug, required for themes get/activate/delete'
+ ],
+ 'plugin' => [
+ 'type' => 'string',
+ 'description' => 'Plugin slug, required for plugins get/activate/deactivate/uninstall'
+ ],
+ 'category' => [
+ 'type' => 'string',
+ 'description' => 'Category filter for plugins list and market search'
+ ],
+ 'site_id' => [
+ 'type' => 'integer',
+ 'description' => 'Site id for themes/plugins, defaults to the current site'
+ ],
+ 'job' => [
+ 'type' => 'string',
+ 'description' => 'Cron job name, required for cron run. Use cron list to discover names.'
+ ],
+ 'scope' => [
+ 'type' => 'string',
+ 'enum' => ['all', 'template', 'page', 'database', 'frontend', 'image', 'model'],
+ 'default' => 'all',
+ 'description' => 'Cache scope for cache clear'
+ ],
+ 'search' => [
+ 'type' => 'string',
+ 'description' => 'Search keywords for market search'
+ ],
+ 'start' => [
+ 'type' => 'integer',
+ 'description' => 'Result offset for market search, defaults to 1'
+ ],
+ 'limit' => [
+ 'type' => 'integer',
+ 'description' => 'Result limit for market search (1-50, defaults to 10)'
+ ],
+ 'host' => [
+ 'type' => 'string',
+ 'description' => 'Host filter for cache clear with page scope'
+ ],
+ ],
+ 'required' => ['target', 'operation'],
+ 'additionalProperties' => false
+ ],
+ 'outputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'target' => ['type' => 'string'],
+ 'operation' => ['type' => 'string'],
+ 'result' => ['description' => 'Subsystem result (lists, records, job output or success flags)']
+ ],
+ 'required' => ['target', 'operation']
+ ],
+ 'annotations' => [
+ 'readOnlyHint' => false,
+ 'destructiveHint' => true,
+ 'idempotentHint' => false,
+ 'openWorldHint' => false
+ ]
+ ],
+ [
+ 'name' => 'media',
+ 'description' => 'Manage the media library. list (metadata records, filters/pagination), get (metadata for one file), save (metadata key/values), delete (by file or media_id), upload (base64, 4MB cap), fetch (image URL import, oversized rasters auto-resized), mkdir, rename (newfile path or newname), scan (folder tree: path, levels 1-3, search, paged with 0-based start/limit up to 200). Reads (list/get/scan) are always allowed.',
+ 'type' => 'action',
+ 'inputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'operation' => [
+ 'type' => 'string',
+ 'enum' => ['list', 'get', 'save', 'delete', 'upload', 'fetch', 'mkdir', 'rename', 'scan'],
+ 'description' => 'Media operation: list/get/save/delete metadata, upload file bytes, fetch image URL, mkdir folder, rename file, scan folder tree'
+ ],
+ 'file' => [
+ 'type' => 'string',
+ 'description' => 'Media file path, required for get/save/rename and one way to target delete'
+ ],
+ 'content' => [
+ 'type' => 'object',
+ 'description' => 'Metadata key/value pairs, required for save'
+ ],
+ 'media_id' => [
+ 'type' => 'integer',
+ 'description' => 'Media record id, alternative to file for delete'
+ ],
+ 'file_name' => [
+ 'type' => 'string',
+ 'description' => 'Target file name for upload (required)'
+ ],
+ 'data' => [
+ 'type' => 'string',
+ 'description' => 'Base64-encoded file bytes for upload (required, capped at 4MB decoded and the server upload_max_filesize)'
+ ],
+ 'url' => [
+ 'type' => 'string',
+ 'description' => 'Public image URL to download for fetch (required, http(s) only, redirects followed, same 4MB cap)'
+ ],
+ 'overwrite' => [
+ 'type' => 'boolean',
+ 'description' => 'Replace the existing file for upload/fetch (default false)'
+ ],
+ 'path' => [
+ 'type' => 'string',
+ 'description' => 'Media sub-path for upload/mkdir/scan (default root)'
+ ],
+ 'folder' => [
+ 'type' => 'string',
+ 'description' => 'New folder name for mkdir (required)'
+ ],
+ 'newfile' => [
+ 'type' => 'string',
+ 'description' => 'New media-relative path for rename, alternative to newname'
+ ],
+ 'newname' => [
+ 'type' => 'string',
+ 'description' => 'New file name inside the current directory for rename'
+ ],
+ 'duplicate' => [
+ 'type' => 'boolean',
+ 'description' => 'Copy instead of renaming for rename'
+ ],
+ 'levels' => [
+ 'type' => 'integer',
+ 'description' => 'Depth budget for scan (1-3, default 1)'
+ ],
+ 'params' => [
+ 'type' => 'object',
+ 'description' => 'List filters and pagination for list'
+ ],
+ 'search' => [
+ 'type' => 'string',
+ 'description' => 'Filename match for scan'
+ ],
+ 'start' => [
+ 'type' => 'integer',
+ 'description' => '0-based page offset for scan'
+ ],
+ 'limit' => [
+ 'type' => 'integer',
+ 'description' => 'Page size for scan (default 200, max 200)'
+ ],
+ ],
+ 'required' => ['operation'],
+ 'additionalProperties' => false
+ ],
+ 'outputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'operation' => ['type' => 'string'],
+ 'result' => ['description' => 'Operation result (records, folder tree page with total, or success flags)']
+ ],
+ 'required' => ['operation']
+ ],
+ 'annotations' => [
+ 'readOnlyHint' => false,
+ 'destructiveHint' => true,
+ 'idempotentHint' => false,
+ 'openWorldHint' => false
+ ]
+ ],
+ [
+ 'name' => 'read',
+ 'description' => 'Read the contents of a file relative to the site root. Supports text files; images and other binaries cannot be read. Output is truncated to 2000 lines or 50KB, whichever comes first.',
+ 'type' => 'action',
+ 'inputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'path' => [
+ 'type' => 'string',
+ 'description' => 'Path to the file to read (relative or absolute, must be inside the site root)'
+ ],
+ 'offset' => [
+ 'type' => 'integer',
+ 'description' => 'Line number to start reading from (1-indexed)',
+ 'default' => 1
+ ],
+ 'limit' => [
+ 'type' => 'integer',
+ 'description' => 'Maximum number of lines to read',
+ 'default' => 2000
+ ]
+ ],
+ 'required' => ['path'],
+ 'additionalProperties' => false
+ ],
+ 'outputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'content' => [
+ 'type' => 'string',
+ 'description' => 'File contents with line numbers'
+ ],
+ 'totalLines' => [
+ 'type' => 'integer'
+ ]
+ ],
+ 'required' => ['content']
+ ],
+ 'annotations' => [
+ 'readOnlyHint' => true,
+ 'destructiveHint' => false,
+ 'idempotentHint' => true,
+ 'openWorldHint' => false
+ ]
+ ],
+ [
+ 'name' => 'write',
+ 'description' => 'Write content to a file relative to the site root. Creates the file if it does not exist, overwrites it otherwise. Parent directories are created automatically.',
+ 'type' => 'action',
+ 'inputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'path' => [
+ 'type' => 'string',
+ 'description' => 'Path to the file to write (relative or absolute, must be inside the site root)'
+ ],
+ 'content' => [
+ 'type' => 'string',
+ 'description' => 'Content to write to the file'
+ ]
+ ],
+ 'required' => ['path', 'content'],
+ 'additionalProperties' => false
+ ],
+ 'outputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'success' => ['type' => 'boolean'],
+ 'bytes' => ['type' => 'integer'],
+ 'created' => ['type' => 'boolean', 'description' => 'True when the file did not exist before']
+ ],
+ 'required' => ['success']
+ ],
+ 'annotations' => [
+ 'readOnlyHint' => false,
+ 'destructiveHint' => true,
+ 'idempotentHint' => false,
+ 'openWorldHint' => false
+ ]
+ ],
+ [
+ 'name' => 'bash',
+ 'description' => 'Execute a bash command inside the site root directory and return stdout, stderr and exit code. Use for shell operations like ls, find, grep on files, running build tools etc.',
+ 'type' => 'action',
+ 'inputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'command' => [
+ 'type' => 'string',
+ 'description' => 'The bash command line to execute'
+ ],
+ 'timeout' => [
+ 'type' => 'integer',
+ 'description' => 'Timeout in seconds (1-120, default 30)',
+ 'default' => 30
+ ],
+ 'cwd' => [
+ 'type' => 'string',
+ 'description' => 'Working directory for the command (must be inside the site root, defaults to site root)'
+ ]
+ ],
+ 'required' => ['command'],
+ 'additionalProperties' => false
+ ],
+ 'outputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'stdout' => ['type' => 'string'],
+ 'stderr' => ['type' => 'string'],
+ 'exitCode' => ['type' => 'integer'],
+ 'timedOut' => ['type' => 'boolean']
+ ],
+ 'required' => ['stdout', 'exitCode']
+ ],
+ 'annotations' => [
+ 'readOnlyHint' => false,
+ 'destructiveHint' => true,
+ 'idempotentHint' => false,
+ 'openWorldHint' => true
+ ]
+ ],
+ [
+ 'name' => 'bash_sub',
+ 'description' => 'Pure-PHP sandboxed bash fallback when native shell functions are disabled. No system calls; filesystem virtualised to the site root. Supports pipes, redirects, variables and control flow.',
+ 'type' => 'action',
+ 'inputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'command' => [
+ 'type' => 'string',
+ 'description' => 'The bash command line to execute (pure PHP interpreter)'
+ ],
+ 'timeout' => [
+ 'type' => 'integer',
+ 'description' => 'Timeout in seconds (1-120, default 30) — enforced via execution limits in bashbox',
+ 'default' => 30
+ ],
+ 'cwd' => [
+ 'type' => 'string',
+ 'description' => 'Working directory for the command (must be inside the site root, defaults to site root)'
+ ]
+ ],
+ 'required' => ['command'],
+ 'additionalProperties' => false
+ ],
+ 'outputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'stdout' => ['type' => 'string'],
+ 'stderr' => ['type' => 'string'],
+ 'exitCode' => ['type' => 'integer'],
+ 'timedOut' => ['type' => 'boolean'],
+ 'engine' => ['type' => 'string', 'description' => 'Execution engine used (bashbox)'],
+ 'truncated' => ['type' => 'boolean']
+ ],
+ 'required' => ['stdout', 'exitCode']
+ ],
+ 'annotations' => [
+ 'readOnlyHint' => false,
+ 'destructiveHint' => true,
+ 'idempotentHint' => false,
+ 'openWorldHint' => false
+ ]
+ ],
+ [
+ 'name' => 'glob',
+ 'description' => 'Find files by matching a glob pattern (e.g. "plugins/*/plugin.php", "**/*.tpl") relative to the site root. Returns up to 500 matching paths sorted alphabetically.',
+ 'type' => 'action',
+ 'inputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'pattern' => [
+ 'type' => 'string',
+ 'description' => 'Glob pattern with optional wildcards (*, ?, [abc]) relative to the site root'
+ ],
+ 'limit' => [
+ 'type' => 'integer',
+ 'description' => 'Maximum number of results (default 500)',
+ 'default' => 500
+ ]
+ ],
+ 'required' => ['pattern'],
+ 'additionalProperties' => false
+ ],
+ 'outputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'matches' => [
+ 'type' => 'array',
+ 'items' => ['type' => 'string']
+ ],
+ 'count' => ['type' => 'integer']
+ ],
+ 'required' => ['matches']
+ ],
+ 'annotations' => [
+ 'readOnlyHint' => true,
+ 'destructiveHint' => false,
+ 'idempotentHint' => true,
+ 'openWorldHint' => false
+ ]
+ ],
+ [
+ 'name' => 'grep',
+ 'description' => 'Search file contents recursively with a regular expression. Returns matching lines with file, line number and text, skipping binary files and directories like .git/node_modules.',
+ 'type' => 'action',
+ 'inputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'pattern' => [
+ 'type' => 'string',
+ 'description' => 'PCRE regular expression to search for'
+ ],
+ 'path' => [
+ 'type' => 'string',
+ 'description' => 'Directory or file to search in (default: site root)',
+ 'default' => '.'
+ ],
+ 'include' => [
+ 'type' => 'string',
+ 'description' => 'Only search files matching this glob pattern, e.g. *.php',
+ 'default' => '*'
+ ],
+ 'ignoreCase' => [
+ 'type' => 'boolean',
+ 'description' => 'Case insensitive search',
+ 'default' => false
+ ],
+ 'maxResults' => [
+ 'type' => 'integer',
+ 'description' => 'Maximum number of matches returned (default 200)',
+ 'default' => 200
+ ]
+ ],
+ 'required' => ['pattern'],
+ 'additionalProperties' => false
+ ],
+ 'outputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'matches' => [
+ 'type' => 'array',
+ 'items' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'file' => ['type' => 'string'],
+ 'line' => ['type' => 'integer'],
+ 'text' => ['type' => 'string']
+ ]
+ ]
+ ],
+ 'count' => ['type' => 'integer'],
+ 'truncated' => ['type' => 'boolean']
+ ],
+ 'required' => ['matches']
+ ],
+ 'annotations' => [
+ 'readOnlyHint' => true,
+ 'destructiveHint' => false,
+ 'idempotentHint' => true,
+ 'openWorldHint' => false
+ ]
+ ],
+ [
+ 'name' => 'database_query',
+ 'description' => 'Run a SQL query against the site database. Positional ? placeholders are bound to the values passed in params. Read-only statements (SELECT/SHOW/DESCRIBE/EXPLAIN/WITH) are always allowed. SELECT queries without a LIMIT get one appended automatically (max 1000 rows).',
+ 'type' => 'action',
+ 'inputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'query' => [
+ 'type' => 'string',
+ 'description' => 'SQL query to execute, use ? placeholders for bound parameters'
+ ],
+ 'params' => [
+ 'type' => 'array',
+ 'description' => 'Optional positional parameter values for ? placeholders',
+ // permissive item schema (any JSON value): an empty PHP
+ // array would serialize to JSON [] which draft 2020-12
+ // rejects ($dynamicRef requires object|boolean).
+ 'items' => [
+ 'description' => 'A single bound parameter value (string, number, boolean or null)'
+ ]
+ ],
+ 'maxRows' => [
+ 'type' => 'integer',
+ 'description' => 'Row cap applied to SELECT queries without LIMIT (default 1000)',
+ 'default' => 1000
+ ]
+ ],
+ 'required' => ['query'],
+ 'additionalProperties' => false
+ ],
+ 'outputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'rows' => [
+ 'type' => 'array',
+ 'description' => 'Result rows for SELECT statements'
+ ],
+ 'rowCount' => ['type' => 'integer'],
+ 'affectedRows' => ['type' => 'integer', 'description' => 'Affected rows for write statements'],
+ 'insertId' => ['type' => 'integer', 'description' => 'Insert id for INSERT statements'],
+ 'truncated' => ['type' => 'boolean']
+ ]
+ ],
+ 'annotations' => [
+ 'readOnlyHint' => true,
+ 'destructiveHint' => false,
+ 'idempotentHint' => true,
+ 'openWorldHint' => false
+ ]
+ ],
+ [
+ 'name' => 'str_replace_editor',
+ 'description' => 'Custom editing tool for viewing, creating and editing files. State is persistent across calls. Supports commands: view / create / edit. If path is a file, view displays the result of applying cat -n; if path is a directory, view lists non-hidden files up to 2 levels deep. create cannot overwrite existing files. edit performs multiple exact replacements via edits[].oldText/newText (multi-edit only).',
+ 'type' => 'action',
+ 'inputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'command' => [
+ 'type' => 'string',
+ 'enum' => ['view', 'create', 'edit'],
+ 'description' => 'The command to run: view (read file or list directory), create (create new file), edit (multiple disjoint exact replacements via edits[])'
+ ],
+ 'path' => [
+ 'type' => 'string',
+ 'description' => 'Path to the file or directory (relative or absolute, must be inside the site root). For view, may be a directory.'
+ ],
+ 'file_text' => [
+ 'type' => 'string',
+ 'description' => 'Required for command create: content to write to the new file'
+ ],
+ 'view_range' => [
+ 'type' => 'array',
+ 'items' => ['type' => 'integer'],
+ 'description' => 'Optional for command view: [start_line, end_line] range (1-indexed, -1 for end). E.g. [1, 20]'
+ ],
+ 'edits' => [
+ 'type' => 'array',
+ 'description' => 'Required for command edit: array of {oldText, newText} — each oldText must match a unique non-overlapping region (delegates to CodingAgent\\Tools multi-edit engine)',
+ 'items' => [
+ 'type' => 'object',
+ 'required' => ['oldText', 'newText'],
+ 'properties' => [
+ 'oldText' => ['type' => 'string', 'description' => 'Exact text to replace, must be unique in file'],
+ 'newText' => ['type' => 'string', 'description' => 'Replacement text']
+ ],
+ 'additionalProperties' => false
+ ]
+ ],
+ ],
+ 'required' => ['command', 'path'],
+ 'additionalProperties' => false
+ ],
+ 'outputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'output' => ['type' => 'string', 'description' => 'Formatted file view content or success message with optional diff'],
+ 'success' => ['type' => 'boolean']
+ ]
+ ],
+ 'annotations' => [
+ 'readOnlyHint' => false,
+ 'destructiveHint' => true,
+ 'idempotentHint' => false,
+ 'openWorldHint' => false
+ ]
+ ]
+];
+
+//Windows-only: expose a native PowerShell tool when running on Windows
+//(powershell.exe on Windows PowerShell 5.1, pwsh.exe on PowerShell 7+)
+//where bash (/bin/bash) is typically unavailable.
+if (PHP_OS_FAMILY === 'Windows' || DIRECTORY_SEPARATOR === '\\') {
+ $tools[] = [
+ 'name' => 'powershell',
+ 'description' => 'Execute a PowerShell command inside the site root directory and return stdout, stderr and exit code. Windows-only alternative to bash (which needs /bin/bash). Use for shell operations like dir, Get-ChildItem, Select-String, running build tools etc.',
+ 'type' => 'action',
+ 'inputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'command' => [
+ 'type' => 'string',
+ 'description' => 'The PowerShell command line to execute'
+ ],
+ 'timeout' => [
+ 'type' => 'integer',
+ 'description' => 'Timeout in seconds (1-120, default 30)',
+ 'default' => 30
+ ],
+ 'cwd' => [
+ 'type' => 'string',
+ 'description' => 'Working directory for the command (must be inside the site root, defaults to site root)'
+ ]
+ ],
+ 'required' => ['command'],
+ 'additionalProperties' => false
+ ],
+ 'outputSchema' => [
+ 'type' => 'object',
+ 'properties' => [
+ 'stdout' => ['type' => 'string'],
+ 'stderr' => ['type' => 'string'],
+ 'exitCode' => ['type' => 'integer'],
+ 'timedOut' => ['type' => 'boolean'],
+ 'engine' => ['type' => 'string', 'description' => 'PowerShell executable used (pwsh or powershell)']
+ ],
+ 'required' => ['stdout', 'exitCode']
+ ],
+ 'annotations' => [
+ 'readOnlyHint' => false,
+ 'destructiveHint' => true,
+ 'idempotentHint' => false,
+ 'openWorldHint' => true
+ ]
+ ];
+}
+
+return $tools;
diff --git a/public/js/libs/html2canvas/html2canvas.min.js b/public/js/libs/html2canvas/html2canvas.min.js
new file mode 100755
index 0000000..aed6bfd
--- /dev/null
+++ b/public/js/libs/html2canvas/html2canvas.min.js
@@ -0,0 +1,20 @@
+/*!
+ * html2canvas 1.4.1 <https://html2canvas.hertzen.com>
+ * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
+ * Released under MIT License
+ */
+!function(A,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(A="undefined"!=typeof globalThis?globalThis:A||self).html2canvas=e()}(this,function(){"use strict";
+/*! *****************************************************************************
+ Copyright (c) Microsoft Corporation.
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted.
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ PERFORMANCE OF THIS SOFTWARE.
+ ***************************************************************************** */var r=function(A,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(A,e){A.__proto__=e}||function(A,e){for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(A[t]=e[t])})(A,e)};function A(A,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=A}r(A,e),A.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t)}var h=function(){return(h=Object.assign||function(A){for(var e,t=1,r=arguments.length;t<r;t++)for(var B in e=arguments[t])Object.prototype.hasOwnProperty.call(e,B)&&(A[B]=e[B]);return A}).apply(this,arguments)};function a(A,s,o,i){return new(o=o||Promise)(function(t,e){function r(A){try{n(i.next(A))}catch(A){e(A)}}function B(A){try{n(i.throw(A))}catch(A){e(A)}}function n(A){var e;A.done?t(A.value):((e=A.value)instanceof o?e:new o(function(A){A(e)})).then(r,B)}n((i=i.apply(A,s||[])).next())})}function H(t,r){var B,n,s,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},A={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(A[Symbol.iterator]=function(){return this}),A;function e(e){return function(A){return function(e){if(B)throw new TypeError("Generator is already executing.");for(;o;)try{if(B=1,n&&(s=2&e[0]?n.return:e[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,e[1])).done)return s;switch(n=0,(e=s?[2&e[0],s.value]:e)[0]){case 0:case 1:s=e;break;case 4:return o.label++,{value:e[1],done:!1};case 5:o.label++,n=e[1],e=[0];continue;case 7:e=o.ops.pop(),o.trys.pop();continue;default:if(!(s=0<(s=o.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){o=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){o.label=e[1];break}if(6===e[0]&&o.label<s[1]){o.label=s[1],s=e;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(e);break}s[2]&&o.ops.pop(),o.trys.pop();continue}e=r.call(t,o)}catch(A){e=[6,A],n=0}finally{B=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,A])}}}function t(A,e,t){if(t||2===arguments.length)for(var r,B=0,n=e.length;B<n;B++)!r&&B in e||((r=r||Array.prototype.slice.call(e,0,B))[B]=e[B]);return A.concat(r||e)}var d=(B.prototype.add=function(A,e,t,r){return new B(this.left+A,this.top+e,this.width+t,this.height+r)},B.fromClientRect=function(A,e){return new B(e.left+A.windowBounds.left,e.top+A.windowBounds.top,e.width,e.height)},B.fromDOMRectList=function(A,e){e=Array.from(e).find(function(A){return 0!==A.width});return e?new B(e.left+A.windowBounds.left,e.top+A.windowBounds.top,e.width,e.height):B.EMPTY},B.EMPTY=new B(0,0,0,0),B);function B(A,e,t,r){this.left=A,this.top=e,this.width=t,this.height=r}for(var f=function(A,e){return d.fromClientRect(A,e.getBoundingClientRect())},Q=function(A){for(var e=[],t=0,r=A.length;t<r;){var B,n=A.charCodeAt(t++);55296<=n&&n<=56319&&t<r?56320==(64512&(B=A.charCodeAt(t++)))?e.push(((1023&n)<<10)+(1023&B)+65536):(e.push(n),t--):e.push(n)}return e},g=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];if(String.fromCodePoint)return String.fromCodePoint.apply(String,A);var t=A.length;if(!t)return"";for(var r=[],B=-1,n="";++B<t;){var s=A[B];s<=65535?r.push(s):(s-=65536,r.push(55296+(s>>10),s%1024+56320)),(B+1===t||16384<r.length)&&(n+=String.fromCharCode.apply(String,r),r.length=0)}return n},e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="undefined"==typeof Uint8Array?[]:new Uint8Array(256),s=0;s<e.length;s++)n[e.charCodeAt(s)]=s;for(var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c="undefined"==typeof Uint8Array?[]:new Uint8Array(256),i=0;i<o.length;i++)c[o.charCodeAt(i)]=i;function w(A,e,t){return A.slice?A.slice(e,t):new Uint16Array(Array.prototype.slice.call(A,e,t))}var U=(l.prototype.get=function(A){var e;if(0<=A){if(A<55296||56319<A&&A<=65535)return e=this.index[A>>5],this.data[e=(e<<2)+(31&A)];if(A<=65535)return e=this.index[2048+(A-55296>>5)],this.data[e=(e<<2)+(31&A)];if(A<this.highStart)return e=this.index[e=2080+(A>>11)],e=this.index[e+=A>>5&63],this.data[e=(e<<2)+(31&A)];if(A<=1114111)return this.data[this.highValueIndex]}return this.errorValue},l);function l(A,e,t,r,B,n){this.initialValue=A,this.errorValue=e,this.highStart=t,this.highValueIndex=r,this.index=B,this.data=n}for(var C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u="undefined"==typeof Uint8Array?[]:new Uint8Array(256),F=0;F<C.length;F++)u[C.charCodeAt(F)]=F;function p(A,e,t,r){var B=r[t];if(Array.isArray(A)?-1!==A.indexOf(B):A===B)for(var n=t;n<=r.length;){if((o=r[++n])===e)return 1;if(o!==D)break}if(B===D)for(n=t;0<n;){var s=r[--n];if(Array.isArray(A)?-1!==A.indexOf(s):A===s)for(var o,i=t;i<=r.length;){if((o=r[++i])===e)return 1;if(o!==D)break}if(s!==D)break}}function E(A,e){for(var t=A;0<=t;){var r=e[t];if(r!==D)return r;t--}return 0}function I(t,A){var e=(B=function(A,r){void 0===r&&(r="strict");var B=[],n=[],s=[];return A.forEach(function(A,e){var t=rA.get(A);if(50<t?(s.push(!0),t-=50):s.push(!1),-1!==["normal","auto","loose"].indexOf(r)&&-1!==[8208,8211,12316,12448].indexOf(A))return n.push(e),B.push(16);if(4!==t&&11!==t)return n.push(e),31===t?B.push("strict"===r?O:q):t===AA||29===t?B.push(J):43===t?131072<=A&&A<=196605||196608<=A&&A<=262141?B.push(q):B.push(J):void B.push(t);if(0===e)return n.push(e),B.push(J);t=B[e-1];return-1===iA.indexOf(t)?(n.push(n[e-1]),B.push(t)):(n.push(e),B.push(J))}),[n,B,s]}(t,(A=A||{lineBreak:"normal",wordBreak:"normal"}).lineBreak))[0],r=B[1],B=B[2];return[e,r="break-all"===A.wordBreak||"break-word"===A.wordBreak?r.map(function(A){return-1!==[R,J,AA].indexOf(A)?q:A}):r,"keep-all"===A.wordBreak?B.map(function(A,e){return A&&19968<=t[e]&&t[e]<=40959}):void 0]}var y,K,m,L,b,D=10,v=13,x=15,M=17,S=18,T=19,G=20,O=21,V=22,k=24,R=25,N=26,P=27,X=28,J=30,Y=32,W=33,Z=34,_=35,q=37,j=38,z=39,$=40,AA=42,eA=[9001,65288],tA="×",rA=(m=function(A){var e,t,r,B,n=.75*A.length,s=A.length,o=0;"="===A[A.length-1]&&(n--,"="===A[A.length-2]&&n--);for(var n=new("undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?ArrayBuffer:Array)(n),i=Array.isArray(n)?n:new Uint8Array(n),Q=0;Q<s;Q+=4)e=c[A.charCodeAt(Q)],t=c[A.charCodeAt(Q+1)],r=c[A.charCodeAt(Q+2)],B=c[A.charCodeAt(Q+3)],i[o++]=e<<2|t>>4,i[o++]=(15&t)<<4|r>>2,i[o++]=(3&r)<<6|63&B;return n}(y="KwAAAAAAAAAACA4AUD0AADAgAAACA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IGOAdAB0gHTgfSBkgHVgfSBtIG0gbSBtIG0gbSBtIG0gbSBiwHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAdgAGAALAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAc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CGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIaQhjCGQIZQhmCGcIaAhpCGMIZAhlCGYIZwhoCGkIYwhkCGUIZghnCGgIcAh3CHoIMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIgggwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAALAcsBywHLAcsBywHLAcsBywHLAcsB4oILAcsB44I0gaWCJ4Ipgh1AHUAqgiyCHUAdQB1AHUAdQB1AHUAdQB1AHUAtwh8AXUAvwh1AMUIyQjRCNkI4AjoCHUAdQB1AO4I9gj+CAYJDgkTCS0HGwkjCYIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiCCIIIggiAAIAAAAFAAYABgAGIAXwBgAHEAdQBFAJUAogCyAKAAYABgAEIA4ABGANMA4QDxAMEBDwE1AFwBLAE6AQEBUQF4QkhCmEKoQrhCgAHIQsAB0MLAAcABwAHAAeDC6ABoAHDCwMMAAcABwAHAAdDDGMMAAcAB6MM4wwjDWMNow3jDaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAGgAaABoAEjDqABWw6bDqABpg6gAaABoAHcDvwOPA+gAaABfA/8DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DvwO/A78DpcPAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAc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AwADAAMAAwADAAMAAwADAAMAB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUA+wMVBGcMMAAwAHwBbwx1AHcMfwyHDI8MMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAYABgAJcMMAAwADAAdQB1AJ8MlQClDDAAMACtDCwHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsB7UMLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHLAcsBywHdQB1AHUAdQB1AHUAdQB1AHUAdQB1AHUAdQB1AA0EMAC9DDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAsBywHLAcsBywHLAcsBywHLQcwAMEMyAwsBywHLAcsBywHLAcsBywHLAcsBywHzAwwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwAHUAdQB1ANQM2QzhDDAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMABgAGAAYABgAGAAYABgAOkMYADxDGAA+AwADQYNYABhCWAAYAAODTAAMAAwADAAFg1gAGAAHg37AzAAMAAwADAAYABgACYNYAAsDTQNPA1gAEMNPg1LDWAAYABgAGAAYABgAGAAYABgAGAAUg1aDYsGVglhDV0NcQBnDW0NdQ15DWAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAlQCBDZUAiA2PDZcNMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAn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AA0AKwArAB4AHgAbACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAB4ABAAEAB4ABAAEABMABAArACsAKwArACsAKwArACsAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAKwArACsAKwBWAFYAVgBWAB4AHgArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AGgAaABoAGAAYAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQAEwAEACsAEwATAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABLAEsASwBLAEsASwBLAEsASwBLABoAGQAZAB4AUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQABMAUAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABABQAFAABAAEAB4ABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUAAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAFAABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQAUABQAB4AHgAYABMAUAArACsABAAbABsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAFAABAAEAAQABAAEAFAABAAEAAQAUAAEAAQABAAEAAQAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArACsAHgArAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4ABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAUAAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEAA0ADQBLAEsASwBLAEsASwBLAEsASwBLAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUAArACsAKwBQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABABQACsAKwArACsAKwArACsAKwAEACsAKwArACsAUABQACsAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUAAaABoAUABQAFAAUABQAEwAHgAbAFAAHgAEACsAKwAEAAQABAArAFAAUABQAFAAUABQACsAKwArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQACsAUABQACsAKwAEACsABAAEAAQABAAEACsAKwArACsABAAEACsAKwAEAAQABAArACsAKwAEACsAKwArACsAKwArACsAUABQAFAAUAArAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLAAQABABQAFAAUAAEAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQACsAKwAEAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAArACsAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAB4AGwArACsAKwArACsAKwArAFAABAAEAAQABAAEAAQAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAKwArACsAKwArAAQABAAEACsAKwArACsAUABQACsAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAB4AUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAAQAUAArAFAAUABQAFAAUABQACsAKwArAFAAUABQACsAUABQAFAAUAArACsAKwBQAFAAKwBQACsAUABQACsAKwArAFAAUAArACsAKwBQAFAAUAArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArAAQABAAEAAQABAArACsAKwAEAAQABAArAAQABAAEAAQAKwArAFAAKwArACsAKwArACsABAArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAHgAeAB4AHgAeAB4AGwAeACsAKwArACsAKwAEAAQABAAEAAQAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAUAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAAEACsAKwArACsAKwArACsABAAEACsAUABQAFAAKwArACsAKwArAFAAUAAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwAOAFAAUABQAFAAUABQAFAAHgBQAAQABAAEAA4AUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAKwArAAQAUAAEAAQABAAEAAQABAAEACsABAAEAAQAKwAEAAQABAAEACsAKwArACsAKwArACsABAAEACsAKwArACsAKwArACsAUAArAFAAUAAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwBQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAFAABAAEAAQABAAEAAQABAArAAQABAAEACsABAAEAAQABABQAB4AKwArACsAKwBQAFAAUAAEAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQABoAUABQAFAAUABQAFAAKwAEAAQABAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQACsAUAArACsAUABQAFAAUABQAFAAUAArACsAKwAEACsAKwArACsABAAEAAQABAAEAAQAKwAEACsABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArAAQABAAeACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAXAAqACoAKgAqACoAKgAqACsAKwArACsAGwBcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAeAEsASwBLAEsASwBLAEsASwBLAEsADQANACsAKwArACsAKwBcAFwAKwBcACsAXABcAFwAXABcACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAXAArAFwAXABcAFwAXABcAFwAXABcAFwAKgBcAFwAKgAqACoAKgAqACoAKgAqACoAXAArACsAXABcAFwAXABcACsAXAArACoAKgAqACoAKgAqACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwBcAFwAXABcAFAADgAOAA4ADgAeAA4ADgAJAA4ADgANAAkAEwATABMAEwATAAkAHgATAB4AHgAeAAQABAAeAB4AHgAeAB4AHgBLAEsASwBLAEsASwBLAEsASwBLAFAAUABQAFAAUABQAFAAUABQAFAADQAEAB4ABAAeAAQAFgARABYAEQAEAAQAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQADQAEAAQABAAEAAQADQAEAAQAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAA0ADQAeAB4AHgAeAB4AHgAEAB4AHgAeAB4AHgAeACsAHgAeAA4ADgANAA4AHgAeAB4AHgAeAAkACQArACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgBcAEsASwBLAEsASwBLAEsASwBLAEsADQANAB4AHgAeAB4AXABcAFwAXABcAFwAKgAqACoAKgBcAFwAXABcACoAKgAqAFwAKgAqACoAXABcACoAKgAqACoAKgAqACoAXABcAFwAKgAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKgAqAFwAKgBLAEsASwBLAEsASwBLAEsASwBLACoAKgAqACoAKgAqAFAAUABQAFAAUABQACsAUAArACsAKwArACsAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgBQAFAAUABQAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAKwBQACsAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsABAAEAAQAHgANAB4AHgAeAB4AHgAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUAArACsADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAWABEAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAA0ADQANAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAANAA0AKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUAArAAQABAArACsAKwArACsAKwArACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqAA0ADQAVAFwADQAeAA0AGwBcACoAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwAeAB4AEwATAA0ADQAOAB4AEwATAB4ABAAEAAQACQArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUAAEAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAHgArACsAKwATABMASwBLAEsASwBLAEsASwBLAEsASwBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAXABcAFwAXABcACsAKwArACsAKwArACsAKwArACsAKwBcAFwAXABcAFwAXABcAFwAXABcAFwAXAArACsAKwArAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAXAArACsAKwAqACoAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAArACsAHgAeAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcACoAKgAqACoAKgAqACoAKgAqACoAKwAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKwArAAQASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACoAKgAqACoAKgAqACoAXAAqACoAKgAqACoAKgArACsABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABABQAFAAUABQAFAAUABQACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwANAA0AHgANAA0ADQANAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAEAAQABAAEAAQAHgAeAB4AHgAeAB4AHgAeAB4AKwArACsABAAEAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwAeAB4AHgAeAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArAA0ADQANAA0ADQBLAEsASwBLAEsASwBLAEsASwBLACsAKwArAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAA0ADQBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUAAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArAAQABAAEAB4ABAAEAAQABAAEAAQABAAEAAQABAA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UABQAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAeAA0ADQANAA0ADQArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AUAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAB4AHgAeAB4AHgAeAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AUABQAFAAUABQAFAAUABQAFAAUABQAAQAUABQAFAABABQAFAAUABQAAQAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAeAB4AHgAeAAQAKwArACsAUABQAFAAUABQAFAAHgAeABoAHgArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAADgAOABMAEwArACsAKwArACsAKwArACsABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwANAA0ASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUAAeAB4AHgBQAA4AUABQAAQAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArAB4AWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYAFgAWABYACsAKwArAAQAHgAeAB4AHgAeAB4ADQANAA0AHgAeAB4AHgArAFAASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArAB4AHgBcAFwAXABcAFwAKgBcAFwAXABcAFwAXABcAFwAXABcAEsASwBLAEsASwBLAEsASwBLAEsAXABcAFwAXABcACsAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAFAAUABQAAQAUABQAFAAUABQAFAAUABQAAQABAArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAHgANAA0ADQBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKgAqACoAXAAqACoAKgBcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXAAqAFwAKgAqACoAXABcACoAKgBcAFwAXABcAFwAKgAqAFwAKgBcACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFwAXABcACoAKgBQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAA0ADQBQAFAAUAAEAAQAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQADQAEAAQAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAVABVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBUAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVAFUAVQBVACsAKwArACsAKwArACsAKwArACsAKwArAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAWQBZAFkAKwArACsAKwBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAWgBaAFoAKwArACsAKwAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYABgAGAAYAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAKwArACsAKwArAFYABABWAFYAVgBWAFYAVgBWAFYAVgBWAB4AVgBWAFYAVgBWAFYAVgBWAFYAVgBWAFYAVgArAFYAVgBWAFYAVgArAFYAKwBWAFYAKwBWAFYAKwBWAFYAVgBWAFYAVgBWAFYAVgBWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAEQAWAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAaAB4AKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAGAARABEAGAAYABMAEwAWABEAFAArACsAKwArACsAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACUAJQAlACUAJQAWABEAFgARABYAEQAWABEAFgARABYAEQAlACUAFgARACUAJQAlACUAJQAlACUAEQAlABEAKwAVABUAEwATACUAFgARABYAEQAWABEAJQAlACUAJQAlACUAJQAlACsAJQAbABoAJQArACsAKwArAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAcAKwATACUAJQAbABoAJQAlABYAEQAlACUAEQAlABEAJQBXAFcAVwBXAFcAVwBXAFcAVwBXABUAFQAlACUAJQATACUAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXABYAJQARACUAJQAlAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAWACUAEQAlABYAEQARABYAEQARABUAVwBRAFEAUQBRAFEAUQBRAFEAUQBRAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAEcARwArACsAVwBXAFcAVwBXAFcAKwArAFcAVwBXAFcAVwBXACsAKwBXAFcAVwBXAFcAVwArACsAVwBXAFcAKwArACsAGgAbACUAJQAlABsAGwArAB4AHgAeAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwAEAAQABAAQAB0AKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsADQANAA0AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgBQAFAAHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAAQAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAA0AUABQAFAAUAArACsAKwArAFAAUABQAFAAUABQAFAAUAANAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwAeACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAKwArAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArACsAKwBQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwANAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAB4AUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAUABQAFAAUABQAAQABAAEACsABAAEACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAKwBQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAA0ADQANAA0ADQANAA0ADQAeACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAArACsAKwArAFAAUABQAFAAUAANAA0ADQANAA0ADQAUACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsADQANAA0ADQANAA0ADQBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAB4AHgAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAAQABAAEAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArAAQABAANACsAKwBQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAB4AHgAeAB4AHgArACsAKwArACsAKwAEAAQABAAEAAQABAAEAA0ADQAeAB4AHgAeAB4AKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAQABAAEAAQABAAEAAQABAAEAAQABAAeAB4AHgANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwAeACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEACsASwBLAEsASwBLAEsASwBLAEsASwANAA0ADQANAFAABAAEAFAAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAeAA4AUAArACsAKwArACsAKwArACsAKwAEAFAAUABQAFAADQANAB4ADQAEAAQABAAEAB4ABAAEAEsASwBLAEsASwBLAEsASwBLAEsAUAAOAFAADQANAA0AKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAANAA0AHgANAA0AHgAEACsAUABQAFAAUABQAFAAUAArAFAAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAA0AKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsABAAEAAQABAArAFAAUABQAFAAUABQAFAAUAArACsAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQACsABAAEAFAABAAEAAQABAAEAAQABAArACsABAAEACsAKwAEAAQABAArACsAUAArACsAKwArACsAKwAEACsAKwArACsAKwBQAFAAUABQAFAABAAEACsAKwAEAAQABAAEAAQABAAEACsAKwArAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwArACsABAAEAAQABAAEAAQABABQAFAAUABQAA0ADQANAA0AHgBLAEsASwBLAEsASwBLAEsASwBLAA0ADQArAB4ABABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAEAAQABAAEAFAAUAAeAFAAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABAAEAAQADgANAA0AEwATAB4AHgAeAA0ADQANAA0ADQANAA0ADQANAA0ADQANAA0ADQANAFAAUABQAFAABAAEACsAKwAEAA0ADQAeAFAAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAFAAKwArACsAKwArACsAKwBLAEsASwBLAEsASwBLAEsASwBLACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAXABcAFwAKwArACoAKgAqACoAKgAqACoAKgAqACoAKgAqACoAKgAqACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBcAFwADQANAA0AKgBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAeACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAKwArAFAAKwArAFAAUABQAFAAUABQAFAAUAArAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQAKwAEAAQAKwArAAQABAAEAAQAUAAEAFAABAAEAA0ADQANACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAArACsABAAEAAQABAAEAAQABABQAA4AUAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAABAAEAAQABAAEAAQABAAEAAQABABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAFAABAAEAAQABAAOAB4ADQANAA0ADQAOAB4ABAArACsAKwArACsAKwArACsAUAAEAAQABAAEAAQABAAEAAQABAAEAAQAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAA0ADQANAFAADgAOAA4ADQANACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAEAAQABAAEACsABAAEAAQABAAEAAQABAAEAFAADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAOABMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQACsAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAArACsAKwAEACsABAAEACsABAAEAAQABAAEAAQABABQAAQAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAUABQAFAAUABQAFAAKwBQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQAKwAEAAQAKwAEAAQABAAEAAQAUAArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAABAAEAAQABAAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAB4AHgAeAB4AHgAeAB4AHgAaABoAGgAaAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArAA0AUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsADQANAA0ADQANACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABIAEgAQwBDAEMAUABQAFAAUABDAFAAUABQAEgAQwBIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAASABDAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwAJAAkACQAJAAkACQAJABYAEQArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABIAEMAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwANAA0AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArAAQABAAEAAQABAANACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEAA0ADQANAB4AHgAeAB4AHgAeAFAAUABQAFAADQAeACsAKwArACsAKwArACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArAFAAUABQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAANAA0AHgAeACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwAEAFAABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwAEAAQABAAEAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAARwBHABUARwAJACsAKwArACsAKwArACsAKwArACsAKwAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUQBRAFEAKwArACsAKwArACsAKwArACsAKwArACsAKwBRAFEAUQBRACsAKwArACsAKwArACsAKwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUAArACsAHgAEAAQADQAEAAQABAAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAAQABAAEAAQABAAeAB4AHgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAB4AHgAEAAQABAAEAAQABAAEAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQABAAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4ABAAEAAQAHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwArACsAKwArACsAKwArACsAKwArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwBQAFAAKwArAFAAKwArAFAAUAArACsAUABQAF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AAQAKwAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArAAQABAAEAAQABAAEAAQAKwAEAAQAKwAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwAEAAQABAAEAAQABAAEAFAAUABQAFAAUABQAFAAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwBQAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArABsAUABQAFAAUABQACsAKwBQAFAAUABQAFAAUABQAFAAUAAEAAQABAAEAAQABAAEACsAKwArACsAKwArACsAKwArAB4AHgAeAB4ABAAEAAQABAAEAAQABABQACsAKwArACsASwBLAEsASwBLAEsASwBLAEsASwArACsAKwArABYAFgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAGgBQAFAAUAAaAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAeAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQACsAKwBQAFAAUABQACsAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwBQAFAAKwBQACsAKwBQACsAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAKwBQACsAUAArACsAKwArACsAKwBQACsAKwArACsAUAArAFAAKwBQACsAUABQAFAAKwBQAFAAKwBQACsAKwBQACsAUAArAFAAKwBQACsAUAArAFAAUAArAFAAKwArAFAAUABQAFAAKwBQAFAAUABQAFAAUABQACsAUABQAFAAUAArAFAAUABQAFAAKwBQACsAUABQAFAAUABQAFAAUABQAFAAUAArAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAArACsAKwArACsAUABQAFAAKwBQAFAAUABQAFAAKwBQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwAeAB4AKwArACsAKwArACsAKwArACsAKwArACsAKwArAE8ATwBPAE8ATwBPAE8ATwBPAE8ATwBPAE8AJQAlACUAHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHgAeAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB4AHgAeACUAJQAlAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAdAB0AHQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAKQApACkAJQAlACUAJQAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAeAB4AJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB4AHgAlACUAJQAlACUAHgAlACUAJQAlACUAIAAgACAAJQAlACAAJQAlACAAIAAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACEAIQAhACEAIQAlACUAIAAgACUAJQAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlACUAIAAlACUAJQAlACAAIAAgACUAIAAgACAAJQAlACUAJQAlACUAJQAgACUAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAHgAlAB4AJQAeACUAJQAlACUAJQAgACUAJQAlACUAHgAlAB4AHgAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlAB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AIAAgACAAIAAgACAAJQAlACUAJQAlACUAIAAlACUAJQAlACUAJQAlACUAJQAgACAAIAAgACAAIAAgACAAIAAgACUAJQAgACAAIAAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAgACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACAAIAAlACAAIAAlACAAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAgACAAIAAlACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAJQAlAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AKwAeAB4AHgAeAB4AHgAeAB4AHgAeAB4AHgArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAEsASwBLAEsASwBLAEsASwBLAEsAKwArACsAKwArACsAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwArAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwAlACUAJQAlACUAJQAlACUAJQAlACUAVwBXACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQBXAFcAVwBXAFcAVwBXAFcAVwBXAFcAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAJQAlACUAKwAEACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArACsAKwArAA=="),L=Array.isArray(m)?function(A){for(var e=A.length,t=[],r=0;r<e;r+=4)t.push(A[r+3]<<24|A[r+2]<<16|A[r+1]<<8|A[r]);return t}(m):new Uint32Array(m),b=Array.isArray(m)?function(A){for(var e=A.length,t=[],r=0;r<e;r+=2)t.push(A[r+1]<<8|A[r]);return t}(m):new Uint16Array(m),y=w(b,12,L[4]/2),K=2===L[5]?w(b,(24+L[4])/2):(m=L,b=Math.ceil((24+L[4])/4),m.slice?m.slice(b,K):new Uint32Array(Array.prototype.slice.call(m,b,K))),new U(L[0],L[1],L[2],L[3],y,K)),BA=[J,36],nA=[1,2,3,5],sA=[D,8],oA=[P,N],iA=nA.concat(sA),QA=[j,z,$,Z,_],cA=[x,v],aA=(gA.prototype.slice=function(){return g.apply(void 0,this.codePoints.slice(this.start,this.end))},gA);function gA(A,e,t,r){this.codePoints=A,this.required="!"===e,this.start=t,this.end=r}function wA(A,e){var t=Q(A),r=(e=I(t,e))[0],B=e[1],n=e[2],s=t.length,o=0,i=0;return{next:function(){if(s<=i)return{done:!0,value:null};for(var A=tA;i<s&&(A=function(A,e,t,r,B){if(0===t[r])return tA;var n=r-1;if(Array.isArray(B)&&!0===B[n])return tA;var s=n-1,o=1+n,i=e[n],r=0<=s?e[s]:0,B=e[o];if(2===i&&3===B)return tA;if(-1!==nA.indexOf(i))return"!";if(-1!==nA.indexOf(B))return tA;if(-1!==sA.indexOf(B))return tA;if(8===E(n,e))return"÷";if(11===rA.get(A[n]))return tA;if((i===Y||i===W)&&11===rA.get(A[o]))return tA;if(7===i||7===B)return tA;if(9===i)return tA;if(-1===[D,v,x].indexOf(i)&&9===B)return tA;if(-1!==[M,S,T,k,X].indexOf(B))return tA;if(E(n,e)===V)return tA;if(p(23,V,n,e))return tA;if(p([M,S],O,n,e))return tA;if(p(12,12,n,e))return tA;if(i===D)return"÷";if(23===i||23===B)return tA;if(16===B||16===i)return"÷";if(-1!==[v,x,O].indexOf(B)||14===i)return tA;if(36===r&&-1!==cA.indexOf(i))return tA;if(i===X&&36===B)return tA;if(B===G)return tA;if(-1!==BA.indexOf(B)&&i===R||-1!==BA.indexOf(i)&&B===R)return tA;if(i===P&&-1!==[q,Y,W].indexOf(B)||-1!==[q,Y,W].indexOf(i)&&B===N)return tA;if(-1!==BA.indexOf(i)&&-1!==oA.indexOf(B)||-1!==oA.indexOf(i)&&-1!==BA.indexOf(B))return tA;if(-1!==[P,N].indexOf(i)&&(B===R||-1!==[V,x].indexOf(B)&&e[1+o]===R)||-1!==[V,x].indexOf(i)&&B===R||i===R&&-1!==[R,X,k].indexOf(B))return tA;if(-1!==[R,X,k,M,S].indexOf(B))for(var Q=n;0<=Q;){if((c=e[Q])===R)return tA;if(-1===[X,k].indexOf(c))break;Q--}if(-1!==[P,N].indexOf(B))for(var c,Q=-1!==[M,S].indexOf(i)?s:n;0<=Q;){if((c=e[Q])===R)return tA;if(-1===[X,k].indexOf(c))break;Q--}if(j===i&&-1!==[j,z,Z,_].indexOf(B)||-1!==[z,Z].indexOf(i)&&-1!==[z,$].indexOf(B)||-1!==[$,_].indexOf(i)&&B===$)return tA;if(-1!==QA.indexOf(i)&&-1!==[G,N].indexOf(B)||-1!==QA.indexOf(B)&&i===P)return tA;if(-1!==BA.indexOf(i)&&-1!==BA.indexOf(B))return tA;if(i===k&&-1!==BA.indexOf(B))return tA;if(-1!==BA.concat(R).indexOf(i)&&B===V&&-1===eA.indexOf(A[o])||-1!==BA.concat(R).indexOf(B)&&i===S)return tA;if(41===i&&41===B){for(var a=t[n],g=1;0<a&&41===e[--a];)g++;if(g%2!=0)return tA}return i===Y&&B===W?tA:"÷"}(t,B,r,++i,n))===tA;);if(A===tA&&i!==s)return{done:!0,value:null};var e=new aA(t,A,o,i);return o=i,{value:e,done:!1}}}}function UA(A){return 48<=A&&A<=57}function lA(A){return UA(A)||65<=A&&A<=70||97<=A&&A<=102}function CA(A){return 10===A||9===A||32===A}function uA(A){return 97<=(t=e=A)&&t<=122||65<=(e=e)&&e<=90||128<=A||95===A;var e,t}function FA(A){return uA(A)||UA(A)||45===A}function hA(A,e){return 92===A&&10!==e}function dA(A,e,t){return 45===A?uA(e)||hA(e,t):!!uA(A)||92===A&&10!==e}function fA(A,e,t){return 43===A||45===A?!!UA(e)||46===e&&UA(t):UA(46===A?e:A)}var HA={type:2},pA={type:3},EA={type:4},IA={type:13},yA={type:8},KA={type:21},mA={type:9},LA={type:10},bA={type:11},DA={type:12},vA={type:14},xA={type:23},MA={type:1},SA={type:25},TA={type:24},GA={type:26},OA={type:27},VA={type:28},kA={type:29},RA={type:31},NA={type:32},PA=(XA.prototype.write=function(A){this._value=this._value.concat(Q(A))},XA.prototype.read=function(){for(var A=[],e=this.consumeToken();e!==NA;)A.push(e),e=this.consumeToken();return A},XA.prototype.consumeToken=function(){var A=this.consumeCodePoint();switch(A){case 34:return this.consumeStringToken(34);case 35:var e=this.peekCodePoint(0),t=this.peekCodePoint(1),r=this.peekCodePoint(2);if(FA(e)||hA(t,r)){var B=dA(e,t,r)?2:1;return{type:5,value:this.consumeName(),flags:B}}break;case 36:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),IA;break;case 39:return this.consumeStringToken(39);case 40:return HA;case 41:return pA;case 42:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),vA;break;case 43:if(fA(A,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(A),this.consumeNumericToken();break;case 44:return EA;case 45:var r=A,B=this.peekCodePoint(0),n=this.peekCodePoint(1);if(fA(r,B,n))return this.reconsumeCodePoint(A),this.consumeNumericToken();if(dA(r,B,n))return this.reconsumeCodePoint(A),this.consumeIdentLikeToken();if(45===B&&62===n)return this.consumeCodePoint(),this.consumeCodePoint(),TA;break;case 46:if(fA(A,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(A),this.consumeNumericToken();break;case 47:if(42===this.peekCodePoint(0))for(this.consumeCodePoint();;){var s=this.consumeCodePoint();if(42===s&&47===(s=this.consumeCodePoint()))return this.consumeToken();if(-1===s)return this.consumeToken()}break;case 58:return GA;case 59:return OA;case 60:if(33===this.peekCodePoint(0)&&45===this.peekCodePoint(1)&&45===this.peekCodePoint(2))return this.consumeCodePoint(),this.consumeCodePoint(),SA;break;case 64:var n=this.peekCodePoint(0),o=this.peekCodePoint(1),i=this.peekCodePoint(2);if(dA(n,o,i))return{type:7,value:this.consumeName()};break;case 91:return VA;case 92:if(hA(A,this.peekCodePoint(0)))return this.reconsumeCodePoint(A),this.consumeIdentLikeToken();break;case 93:return kA;case 61:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),yA;break;case 123:return bA;case 125:return DA;case 117:case 85:o=this.peekCodePoint(0),i=this.peekCodePoint(1);return 43!==o||!lA(i)&&63!==i||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(A),this.consumeIdentLikeToken();case 124:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),mA;if(124===this.peekCodePoint(0))return this.consumeCodePoint(),KA;break;case 126:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),LA;break;case-1:return NA}return CA(A)?(this.consumeWhiteSpace(),RA):UA(A)?(this.reconsumeCodePoint(A),this.consumeNumericToken()):uA(A)?(this.reconsumeCodePoint(A),this.consumeIdentLikeToken()):{type:6,value:g(A)}},XA.prototype.consumeCodePoint=function(){var A=this._value.shift();return void 0===A?-1:A},XA.prototype.reconsumeCodePoint=function(A){this._value.unshift(A)},XA.prototype.peekCodePoint=function(A){return A>=this._value.length?-1:this._value[A]},XA.prototype.consumeUnicodeRangeToken=function(){for(var A=[],e=this.consumeCodePoint();lA(e)&&A.length<6;)A.push(e),e=this.consumeCodePoint();for(var t=!1;63===e&&A.length<6;)A.push(e),e=this.consumeCodePoint(),t=!0;if(t)return{type:30,start:parseInt(g.apply(void 0,A.map(function(A){return 63===A?48:A})),16),end:parseInt(g.apply(void 0,A.map(function(A){return 63===A?70:A})),16)};var r=parseInt(g.apply(void 0,A),16);if(45===this.peekCodePoint(0)&&lA(this.peekCodePoint(1))){this.consumeCodePoint();for(var e=this.consumeCodePoint(),B=[];lA(e)&&B.length<6;)B.push(e),e=this.consumeCodePoint();return{type:30,start:r,end:parseInt(g.apply(void 0,B),16)}}return{type:30,start:r,end:r}},XA.prototype.consumeIdentLikeToken=function(){var A=this.consumeName();return"url"===A.toLowerCase()&&40===this.peekCodePoint(0)?(this.consumeCodePoint(),this.consumeUrlToken()):40===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:19,value:A}):{type:20,value:A}},XA.prototype.consumeUrlToken=function(){var A=[];if(this.consumeWhiteSpace(),-1===this.peekCodePoint(0))return{type:22,value:""};var e,t=this.peekCodePoint(0);if(39===t||34===t){t=this.consumeStringToken(this.consumeCodePoint());return 0===t.type&&(this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0))?(this.consumeCodePoint(),{type:22,value:t.value}):(this.consumeBadUrlRemnants(),xA)}for(;;){var r=this.consumeCodePoint();if(-1===r||41===r)return{type:22,value:g.apply(void 0,A)};if(CA(r))return this.consumeWhiteSpace(),-1===this.peekCodePoint(0)||41===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:22,value:g.apply(void 0,A)}):(this.consumeBadUrlRemnants(),xA);if(34===r||39===r||40===r||(0<=(e=r)&&e<=8||11===e||14<=e&&e<=31||127===e))return this.consumeBadUrlRemnants(),xA;if(92===r){if(!hA(r,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),xA;A.push(this.consumeEscapedCodePoint())}else A.push(r)}},XA.prototype.consumeWhiteSpace=function(){for(;CA(this.peekCodePoint(0));)this.consumeCodePoint()},XA.prototype.consumeBadUrlRemnants=function(){for(;;){var A=this.consumeCodePoint();if(41===A||-1===A)return;hA(A,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},XA.prototype.consumeStringSlice=function(A){for(var e="";0<A;){var t=Math.min(5e4,A);e+=g.apply(void 0,this._value.splice(0,t)),A-=t}return this._value.shift(),e},XA.prototype.consumeStringToken=function(A){for(var e="",t=0;;){var r,B=this._value[t];if(-1===B||void 0===B||B===A)return{type:0,value:e+=this.consumeStringSlice(t)};if(10===B)return this._value.splice(0,t),MA;92!==B||-1!==(r=this._value[t+1])&&void 0!==r&&(10===r?(e+=this.consumeStringSlice(t),t=-1,this._value.shift()):hA(B,r)&&(e+=this.consumeStringSlice(t),e+=g(this.consumeEscapedCodePoint()),t=-1)),t++}},XA.prototype.consumeNumber=function(){var A=[],e=4;for(43!==(t=this.peekCodePoint(0))&&45!==t||A.push(this.consumeCodePoint());UA(this.peekCodePoint(0));)A.push(this.consumeCodePoint());var t=this.peekCodePoint(0),r=this.peekCodePoint(1);if(46===t&&UA(r))for(A.push(this.consumeCodePoint(),this.consumeCodePoint()),e=8;UA(this.peekCodePoint(0));)A.push(this.consumeCodePoint());t=this.peekCodePoint(0);var r=this.peekCodePoint(1),B=this.peekCodePoint(2);if((69===t||101===t)&&((43===r||45===r)&&UA(B)||UA(r)))for(A.push(this.consumeCodePoint(),this.consumeCodePoint()),e=8;UA(this.peekCodePoint(0));)A.push(this.consumeCodePoint());return[function(A){var e=0,t=1;43!==A[e]&&45!==A[e]||(45===A[e]&&(t=-1),e++);for(var r=[];UA(A[e]);)r.push(A[e++]);var B=r.length?parseInt(g.apply(void 0,r),10):0;46===A[e]&&e++;for(var n=[];UA(A[e]);)n.push(A[e++]);var s=n.length,o=s?parseInt(g.apply(void 0,n),10):0;69!==A[e]&&101!==A[e]||e++;var i=1;43!==A[e]&&45!==A[e]||(45===A[e]&&(i=-1),e++);for(var Q=[];UA(A[e]);)Q.push(A[e++]);var c=Q.length?parseInt(g.apply(void 0,Q),10):0;return t*(B+o*Math.pow(10,-s))*Math.pow(10,i*c)}(A),e]},XA.prototype.consumeNumericToken=function(){var A=this.consumeNumber(),e=A[0],t=A[1],r=this.peekCodePoint(0),B=this.peekCodePoint(1),A=this.peekCodePoint(2);return dA(r,B,A)?{type:15,number:e,flags:t,unit:this.consumeName()}:37===r?(this.consumeCodePoint(),{type:16,number:e,flags:t}):{type:17,number:e,flags:t}},XA.prototype.consumeEscapedCodePoint=function(){var A,e=this.consumeCodePoint();if(lA(e)){for(var t=g(e);lA(this.peekCodePoint(0))&&t.length<6;)t+=g(this.consumeCodePoint());CA(this.peekCodePoint(0))&&this.consumeCodePoint();var r=parseInt(t,16);return 0===r||55296<=(A=r)&&A<=57343||1114111<r?65533:r}return-1===e?65533:e},XA.prototype.consumeName=function(){for(var A="";;){var e=this.consumeCodePoint();if(FA(e))A+=g(e);else{if(!hA(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),A;A+=g(this.consumeEscapedCodePoint())}}},XA);function XA(){this._value=[]}var JA=(YA.create=function(A){var e=new PA;return e.write(A),new YA(e.read())},YA.parseValue=function(A){return YA.create(A).parseComponentValue()},YA.parseValues=function(A){return YA.create(A).parseComponentValues()},YA.prototype.parseComponentValue=function(){for(var A=this.consumeToken();31===A.type;)A=this.consumeToken();if(32===A.type)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(A);for(var e=this.consumeComponentValue();31===(A=this.consumeToken()).type;);if(32===A.type)return e;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},YA.prototype.parseComponentValues=function(){for(var A=[];;){var e=this.consumeComponentValue();if(32===e.type)return A;A.push(e),A.push()}},YA.prototype.consumeComponentValue=function(){var A=this.consumeToken();switch(A.type){case 11:case 28:case 2:return this.consumeSimpleBlock(A.type);case 19:return this.consumeFunction(A)}return A},YA.prototype.consumeSimpleBlock=function(A){for(var e={type:A,values:[]},t=this.consumeToken();;){if(32===t.type||ce(t,A))return e;this.reconsumeToken(t),e.values.push(this.consumeComponentValue()),t=this.consumeToken()}},YA.prototype.consumeFunction=function(A){for(var e={name:A.value,values:[],type:18};;){var t=this.consumeToken();if(32===t.type||3===t.type)return e;this.reconsumeToken(t),e.values.push(this.consumeComponentValue())}},YA.prototype.consumeToken=function(){var A=this._tokens.shift();return void 0===A?NA:A},YA.prototype.reconsumeToken=function(A){this._tokens.unshift(A)},YA);function YA(A){this._tokens=A}function WA(A){return 15===A.type}function ZA(A){return 17===A.type}function _A(A){return 20===A.type}function qA(A){return 0===A.type}function jA(A,e){return _A(A)&&A.value===e}function zA(A){return 31!==A.type}function $A(A){return 31!==A.type&&4!==A.type}function Ae(A){var e=[],t=[];return A.forEach(function(A){if(4===A.type){if(0===t.length)throw new Error("Error parsing function args, zero tokens for arg");return e.push(t),void(t=[])}31!==A.type&&t.push(A)}),t.length&&e.push(t),e}function ee(A){return 17===A.type||15===A.type}function te(A){return 16===A.type||ee(A)}function re(A){return 1<A.length?[A[0],A[1]]:[A[0]]}function Be(A,e,t){var r=A[0],A=A[1];return[Ue(r,e),Ue(void 0!==A?A:r,t)]}function ne(A){return 15===A.type&&("deg"===A.unit||"grad"===A.unit||"rad"===A.unit||"turn"===A.unit)}function se(A){switch(A.filter(_A).map(function(A){return A.value}).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[ae,ae];case"to top":case"bottom":return Ce(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[ae,we];case"to right":case"left":return Ce(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[we,we];case"to bottom":case"top":return Ce(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[we,ae];case"to left":case"right":return Ce(270)}return 0}function oe(A){return 0==(255&A)}function ie(A){var e=255&A,t=255&A>>8,r=255&A>>16,A=255&A>>24;return e<255?"rgba("+A+","+r+","+t+","+e/255+")":"rgb("+A+","+r+","+t+")"}function Qe(A,e){if(17===A.type)return A.number;if(16!==A.type)return 0;var t=3===e?1:255;return 3===e?A.number/100*t:Math.round(A.number/100*t)}var ce=function(A,e){return 11===e&&12===A.type||(28===e&&29===A.type||2===e&&3===A.type)},ae={type:17,number:0,flags:4},ge={type:16,number:50,flags:4},we={type:16,number:100,flags:4},Ue=function(A,e){if(16===A.type)return A.number/100*e;if(WA(A))switch(A.unit){case"rem":case"em":return 16*A.number;default:return A.number}return A.number},le=function(A,e){if(15===e.type)switch(e.unit){case"deg":return Math.PI*e.number/180;case"grad":return Math.PI/200*e.number;case"rad":return e.number;case"turn":return 2*Math.PI*e.number}throw new Error("Unsupported angle type")},Ce=function(A){return Math.PI*A/180},ue=function(A,e){if(18===e.type){var t=me[e.name];if(void 0===t)throw new Error('Attempting to parse an unsupported color function "'+e.name+'"');return t(A,e.values)}if(5===e.type){if(3===e.value.length){var r=e.value.substring(0,1),B=e.value.substring(1,2),n=e.value.substring(2,3);return Fe(parseInt(r+r,16),parseInt(B+B,16),parseInt(n+n,16),1)}if(4===e.value.length){var r=e.value.substring(0,1),B=e.value.substring(1,2),n=e.value.substring(2,3),s=e.value.substring(3,4);return Fe(parseInt(r+r,16),parseInt(B+B,16),parseInt(n+n,16),parseInt(s+s,16)/255)}if(6===e.value.length){r=e.value.substring(0,2),B=e.value.substring(2,4),n=e.value.substring(4,6);return Fe(parseInt(r,16),parseInt(B,16),parseInt(n,16),1)}if(8===e.value.length){r=e.value.substring(0,2),B=e.value.substring(2,4),n=e.value.substring(4,6),s=e.value.substring(6,8);return Fe(parseInt(r,16),parseInt(B,16),parseInt(n,16),parseInt(s,16)/255)}}if(20===e.type){e=Le[e.value.toUpperCase()];if(void 0!==e)return e}return Le.TRANSPARENT},Fe=function(A,e,t,r){return(A<<24|e<<16|t<<8|Math.round(255*r)<<0)>>>0},he=function(A,e){e=e.filter($A);if(3===e.length){var t=e.map(Qe),r=t[0],B=t[1],t=t[2];return Fe(r,B,t,1)}if(4!==e.length)return 0;e=e.map(Qe),r=e[0],B=e[1],t=e[2],e=e[3];return Fe(r,B,t,e)};function de(A,e,t){return t<0&&(t+=1),1<=t&&--t,t<1/6?(e-A)*t*6+A:t<.5?e:t<2/3?6*(e-A)*(2/3-t)+A:A}function fe(A,e){return ue(A,JA.create(e).parseComponentValue())}function He(A,e){return A=ue(A,e[0]),(e=e[1])&&te(e)?{color:A,stop:e}:{color:A,stop:null}}function pe(A,t){var e=A[0],r=A[A.length-1];null===e.stop&&(e.stop=ae),null===r.stop&&(r.stop=we);for(var B=[],n=0,s=0;s<A.length;s++){var o=A[s].stop;null!==o?(n<(o=Ue(o,t))?B.push(o):B.push(n),n=o):B.push(null)}for(var i=null,s=0;s<B.length;s++){var Q=B[s];if(null===Q)null===i&&(i=s);else if(null!==i){for(var c=s-i,a=(Q-B[i-1])/(1+c),g=1;g<=c;g++)B[i+g-1]=a*g;i=null}}return A.map(function(A,e){return{color:A.color,stop:Math.max(Math.min(1,B[e]/t),0)}})}function Ee(A,e,t){var r="number"==typeof A?A:(s=e/2,r=(n=t)/2,s=Ue((B=A)[0],e)-s,n=r-Ue(B[1],n),(Math.atan2(n,s)+2*Math.PI)%(2*Math.PI)),B=Math.abs(e*Math.sin(r))+Math.abs(t*Math.cos(r)),n=e/2,s=t/2,e=B/2,t=Math.sin(r-Math.PI/2)*e,e=Math.cos(r-Math.PI/2)*e;return[B,n-e,n+e,s-t,s+t]}function Ie(A,e){return Math.sqrt(A*A+e*e)}function ye(A,e,B,n,s){return[[0,0],[0,e],[A,0],[A,e]].reduce(function(A,e){var t=e[0],r=e[1],r=Ie(B-t,n-r);return(s?r<A.optimumDistance:r>A.optimumDistance)?{optimumCorner:e,optimumDistance:r}:A},{optimumDistance:s?1/0:-1/0,optimumCorner:null}).optimumCorner}var Ke=function(A,e){var t=e.filter($A),r=t[0],B=t[1],n=t[2],e=t[3],t=(17===r.type?Ce(r.number):le(A,r))/(2*Math.PI),A=te(B)?B.number/100:0,r=te(n)?n.number/100:0,B=void 0!==e&&te(e)?Ue(e,1):1;if(0==A)return Fe(255*r,255*r,255*r,1);n=r<=.5?r*(1+A):r+A-r*A,e=2*r-n,A=de(e,n,t+1/3),r=de(e,n,t),t=de(e,n,t-1/3);return Fe(255*A,255*r,255*t,B)},me={hsl:Ke,hsla:Ke,rgb:he,rgba:he},Le={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},be={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(A,e){return e.map(function(A){if(_A(A))switch(A.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},De={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Ke=function(t,A){var r=Ce(180),B=[];return Ae(A).forEach(function(A,e){if(0===e){e=A[0];if(20===e.type&&-1!==["top","left","right","bottom"].indexOf(e.value))return void(r=se(A));if(ne(e))return void(r=(le(t,e)+Ce(270))%Ce(360))}A=He(t,A);B.push(A)}),{angle:r,stops:B,type:1}},ve="closest-side",xe="farthest-side",Me="closest-corner",Se="farthest-corner",Te="ellipse",Ge="contain",he=function(r,A){var B=0,n=3,s=[],o=[];return Ae(A).forEach(function(A,e){var t=!0;0===e?t=A.reduce(function(A,e){if(_A(e))switch(e.value){case"center":return o.push(ge),!1;case"top":case"left":return o.push(ae),!1;case"right":case"bottom":return o.push(we),!1}else if(te(e)||ee(e))return o.push(e),!1;return A},t):1===e&&(t=A.reduce(function(A,e){if(_A(e))switch(e.value){case"circle":return B=0,!1;case Te:return!(B=1);case Ge:case ve:return n=0,!1;case xe:return!(n=1);case Me:return!(n=2);case"cover":case Se:return!(n=3)}else if(ee(e)||te(e))return(n=!Array.isArray(n)?[]:n).push(e),!1;return A},t)),t&&(A=He(r,A),s.push(A))}),{size:n,shape:B,stops:s,position:o,type:2}},Oe=function(A,e){if(22===e.type){var t={url:e.value,type:0};return A.cache.addImage(e.value),t}if(18!==e.type)throw new Error("Unsupported image type "+e.type);t=ke[e.name];if(void 0===t)throw new Error('Attempting to parse an unsupported image function "'+e.name+'"');return t(A,e.values)};var Ve,ke={"linear-gradient":function(t,A){var r=Ce(180),B=[];return Ae(A).forEach(function(A,e){if(0===e){e=A[0];if(20===e.type&&"to"===e.value)return void(r=se(A));if(ne(e))return void(r=le(t,e))}A=He(t,A);B.push(A)}),{angle:r,stops:B,type:1}},"-moz-linear-gradient":Ke,"-ms-linear-gradient":Ke,"-o-linear-gradient":Ke,"-webkit-linear-gradient":Ke,"radial-gradient":function(B,A){var n=0,s=3,o=[],i=[];return Ae(A).forEach(function(A,e){var t,r=!0;0===e&&(t=!1,r=A.reduce(function(A,e){if(t)if(_A(e))switch(e.value){case"center":return i.push(ge),A;case"top":case"left":return i.push(ae),A;case"right":case"bottom":return i.push(we),A}else(te(e)||ee(e))&&i.push(e);else if(_A(e))switch(e.value){case"circle":return n=0,!1;case Te:return!(n=1);case"at":return!(t=!0);case ve:return s=0,!1;case"cover":case xe:return!(s=1);case Ge:case Me:return!(s=2);case Se:return!(s=3)}else if(ee(e)||te(e))return(s=!Array.isArray(s)?[]:s).push(e),!1;return A},r)),r&&(A=He(B,A),o.push(A))}),{size:s,shape:n,stops:o,position:i,type:2}},"-moz-radial-gradient":he,"-ms-radial-gradient":he,"-o-radial-gradient":he,"-webkit-radial-gradient":he,"-webkit-gradient":function(r,A){var e=Ce(180),B=[],n=1;return Ae(A).forEach(function(A,e){var t,A=A[0];if(0===e){if(_A(A)&&"linear"===A.value)return void(n=1);if(_A(A)&&"radial"===A.value)return void(n=2)}18===A.type&&("from"===A.name?(t=ue(r,A.values[0]),B.push({stop:ae,color:t})):"to"===A.name?(t=ue(r,A.values[0]),B.push({stop:we,color:t})):"color-stop"!==A.name||2===(A=A.values.filter($A)).length&&(t=ue(r,A[1]),A=A[0],ZA(A)&&B.push({stop:{type:16,number:100*A.number,flags:A.flags},color:t})))}),1===n?{angle:(e+Ce(180))%Ce(360),stops:B,type:n}:{size:3,shape:0,stops:B,position:[],type:n}}},Re={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(e,A){if(0===A.length)return[];var t=A[0];return 20===t.type&&"none"===t.value?[]:A.filter(function(A){return $A(A)&&!(20===(A=A).type&&"none"===A.value||18===A.type&&!ke[A.name])}).map(function(A){return Oe(e,A)})}},Ne={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(A,e){return e.map(function(A){if(_A(A))switch(A.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},Pe={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(A,e){return Ae(e).map(function(A){return A.filter(te)}).map(re)}},Xe={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(A,e){return Ae(e).map(function(A){return A.filter(_A).map(function(A){return A.value}).join(" ")}).map(Je)}},Je=function(A){switch(A){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}};(he=Ve=Ve||{}).AUTO="auto",he.CONTAIN="contain";function Ye(A,e){return _A(A)&&"normal"===A.value?1.2*e:17===A.type?e*A.number:te(A)?Ue(A,e):e}var We,Ze,_e={name:"background-size",initialValue:"0",prefix:!(he.COVER="cover"),type:1,parse:function(A,e){return Ae(e).map(function(A){return A.filter(qe)})}},qe=function(A){return _A(A)||te(A)},he=function(A){return{name:"border-"+A+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},je=he("top"),ze=he("right"),$e=he("bottom"),At=he("left"),he=function(A){return{name:"border-radius-"+A,initialValue:"0 0",prefix:!1,type:1,parse:function(A,e){return re(e.filter(te))}}},et=he("top-left"),tt=he("top-right"),rt=he("bottom-right"),Bt=he("bottom-left"),he=function(A){return{name:"border-"+A+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(A,e){switch(e){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},nt=he("top"),st=he("right"),ot=he("bottom"),it=he("left"),he=function(A){return{name:"border-"+A+"-width",initialValue:"0",type:0,prefix:!1,parse:function(A,e){return WA(e)?e.number:0}}},Qt=he("top"),ct=he("right"),at=he("bottom"),gt=he("left"),wt={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Ut={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(A,e){return"rtl"!==e?0:1}},lt={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(A,e){return e.filter(_A).reduce(function(A,e){return A|Ct(e.value)},0)}},Ct=function(A){switch(A){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},ut={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(A,e){switch(e){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},Ft={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(A,e){return!(20===e.type&&"normal"===e.value||17!==e.type&&15!==e.type)?e.number:0}},ht={name:"line-break",initialValue:(he=We=We||{}).NORMAL="normal",prefix:!(he.STRICT="strict"),type:2,parse:function(A,e){return"strict"!==e?We.NORMAL:We.STRICT}},dt={name:"line-height",initialValue:"normal",prefix:!1,type:4},ft={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(A,e){return 20===e.type&&"none"===e.value?null:Oe(A,e)}},Ht={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(A,e){return"inside"!==e?1:0}},pt={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(A,e){switch(e){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},he=function(A){return{name:"margin-"+A,initialValue:"0",prefix:!1,type:4}},Et=he("top"),It=he("right"),yt=he("bottom"),Kt=he("left"),mt={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(A,e){return e.filter(_A).map(function(A){switch(A.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}})}},Lt={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(A,e){return"break-word"!==e?"normal":"break-word"}},he=function(A){return{name:"padding-"+A,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},bt=he("top"),Dt=he("right"),vt=he("bottom"),xt=he("left"),Mt={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(A,e){switch(e){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},St={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(A,e){switch(e){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},Tt={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(n,A){return 1===A.length&&jA(A[0],"none")?[]:Ae(A).map(function(A){for(var e={color:Le.TRANSPARENT,offsetX:ae,offsetY:ae,blur:ae},t=0,r=0;r<A.length;r++){var B=A[r];ee(B)?(0===t?e.offsetX=B:1===t?e.offsetY=B:e.blur=B,t++):e.color=ue(n,B)}return e})}},Gt={name:"text-transform",initialValue:"none",prefix:!1,type:2,parse:function(A,e){switch(e){case"uppercase":return 2;case"lowercase":return 1;case"capitalize":return 3}return 0}},Ot={name:"transform",initialValue:"none",prefix:!0,type:0,parse:function(A,e){if(20===e.type&&"none"===e.value)return null;if(18!==e.type)return null;var t=Vt[e.name];if(void 0===t)throw new Error('Attempting to parse an unsupported transform function "'+e.name+'"');return t(e.values)}},Vt={matrix:function(A){A=A.filter(function(A){return 17===A.type}).map(function(A){return A.number});return 6===A.length?A:null},matrix3d:function(A){var e=A.filter(function(A){return 17===A.type}).map(function(A){return A.number}),t=e[0],r=e[1];e[2],e[3];var B=e[4],n=e[5];e[6],e[7],e[8],e[9],e[10],e[11];var s=e[12],A=e[13];return e[14],e[15],16===e.length?[t,r,B,n,s,A]:null}},he={type:16,number:50,flags:4},kt=[he,he],Rt={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:function(A,e){e=e.filter(te);return 2!==e.length?kt:[e[0],e[1]]}},Nt={name:"visible",initialValue:"none",prefix:!1,type:2,parse:function(A,e){switch(e){case"hidden":return 1;case"collapse":return 2;default:return 0}}};(he=Ze=Ze||{}).NORMAL="normal",he.BREAK_ALL="break-all";function Pt(A,e){return 0!=(A&e)}function Xt(A,e,t){return(A=A&&A[Math.min(e,A.length-1)])?t?A.open:A.close:""}var Jt={name:"word-break",initialValue:"normal",prefix:!(he.KEEP_ALL="keep-all"),type:2,parse:function(A,e){switch(e){case"break-all":return Ze.BREAK_ALL;case"keep-all":return Ze.KEEP_ALL;default:return Ze.NORMAL}}},Yt={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:function(A,e){if(20===e.type)return{auto:!0,order:0};if(ZA(e))return{auto:!1,order:e.number};throw new Error("Invalid z-index number parsed")}},Wt=function(A,e){if(15===e.type)switch(e.unit.toLowerCase()){case"s":return 1e3*e.number;case"ms":return e.number}throw new Error("Unsupported time type")},Zt={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:function(A,e){return ZA(e)?e.number:1}},_t={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},qt={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:function(A,e){return e.filter(_A).map(function(A){switch(A.value){case"underline":return 1;case"overline":return 2;case"line-through":return 3;case"none":return 4}return 0}).filter(function(A){return 0!==A})}},jt={name:"font-family",initialValue:"",prefix:!1,type:1,parse:function(A,e){var t=[],r=[];return e.forEach(function(A){switch(A.type){case 20:case 0:t.push(A.value);break;case 17:t.push(A.number.toString());break;case 4:r.push(t.join(" ")),t.length=0}}),t.length&&r.push(t.join(" ")),r.map(function(A){return-1===A.indexOf(" ")?A:"'"+A+"'"})}},zt={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},$t={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:function(A,e){return ZA(e)?e.number:!_A(e)||"bold"!==e.value?400:700}},Ar={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:function(A,e){return e.filter(_A).map(function(A){return A.value})}},er={name:"font-style",initialValue:"normal",prefix:!1,type:2,parse:function(A,e){switch(e){case"oblique":return"oblique";case"italic":return"italic";default:return"normal"}}},tr={name:"content",initialValue:"none",type:1,prefix:!1,parse:function(A,e){if(0===e.length)return[];var t=e[0];return 20===t.type&&"none"===t.value?[]:e}},rr={name:"counter-increment",initialValue:"none",prefix:!0,type:1,parse:function(A,e){if(0===e.length)return null;var t=e[0];if(20===t.type&&"none"===t.value)return null;for(var r=[],B=e.filter(zA),n=0;n<B.length;n++){var s=B[n],o=B[n+1];20===s.type&&(o=o&&ZA(o)?o.number:1,r.push({counter:s.value,increment:o}))}return r}},Br={name:"counter-reset",initialValue:"none",prefix:!0,type:1,parse:function(A,e){if(0===e.length)return[];for(var t=[],r=e.filter(zA),B=0;B<r.length;B++){var n=r[B],s=r[B+1];_A(n)&&"none"!==n.value&&(s=s&&ZA(s)?s.number:0,t.push({counter:n.value,reset:s}))}return t}},nr={name:"duration",initialValue:"0s",prefix:!1,type:1,parse:function(e,A){return A.filter(WA).map(function(A){return Wt(e,A)})}},sr={name:"quotes",initialValue:"none",prefix:!0,type:1,parse:function(A,e){if(0===e.length)return null;var t=e[0];if(20===t.type&&"none"===t.value)return null;var r=[],B=e.filter(qA);if(B.length%2!=0)return null;for(var n=0;n<B.length;n+=2){var s=B[n].value,o=B[n+1].value;r.push({open:s,close:o})}return r}},or={name:"box-shadow",initialValue:"none",type:1,prefix:!1,parse:function(n,A){return 1===A.length&&jA(A[0],"none")?[]:Ae(A).map(function(A){for(var e={color:255,offsetX:ae,offsetY:ae,blur:ae,spread:ae,inset:!1},t=0,r=0;r<A.length;r++){var B=A[r];jA(B,"inset")?e.inset=!0:ee(B)?(0===t?e.offsetX=B:1===t?e.offsetY=B:2===t?e.blur=B:e.spread=B,t++):e.color=ue(n,B)}return e})}},ir={name:"paint-order",initialValue:"normal",prefix:!1,type:1,parse:function(A,e){var t=[];return e.filter(_A).forEach(function(A){switch(A.value){case"stroke":t.push(1);break;case"fill":t.push(0);break;case"markers":t.push(2)}}),[0,1,2].forEach(function(A){-1===t.indexOf(A)&&t.push(A)}),t}},Qr={name:"-webkit-text-stroke-color",initialValue:"currentcolor",prefix:!1,type:3,format:"color"},cr={name:"-webkit-text-stroke-width",initialValue:"0",type:0,prefix:!1,parse:function(A,e){return WA(e)?e.number:0}},ar=(gr.prototype.isVisible=function(){return 0<this.display&&0<this.opacity&&0===this.visibility},gr.prototype.isTransparent=function(){return oe(this.backgroundColor)},gr.prototype.isTransformed=function(){return null!==this.transform},gr.prototype.isPositioned=function(){return 0!==this.position},gr.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},gr.prototype.isFloating=function(){return 0!==this.float},gr.prototype.isInlineLevel=function(){return Pt(this.display,4)||Pt(this.display,33554432)||Pt(this.display,268435456)||Pt(this.display,536870912)||Pt(this.display,67108864)||Pt(this.display,134217728)},gr);function gr(A,e){this.animationDuration=lr(A,nr,e.animationDuration),this.backgroundClip=lr(A,be,e.backgroundClip),this.backgroundColor=lr(A,De,e.backgroundColor),this.backgroundImage=lr(A,Re,e.backgroundImage),this.backgroundOrigin=lr(A,Ne,e.backgroundOrigin),this.backgroundPosition=lr(A,Pe,e.backgroundPosition),this.backgroundRepeat=lr(A,Xe,e.backgroundRepeat),this.backgroundSize=lr(A,_e,e.backgroundSize),this.borderTopColor=lr(A,je,e.borderTopColor),this.borderRightColor=lr(A,ze,e.borderRightColor),this.borderBottomColor=lr(A,$e,e.borderBottomColor),this.borderLeftColor=lr(A,At,e.borderLeftColor),this.borderTopLeftRadius=lr(A,et,e.borderTopLeftRadius),this.borderTopRightRadius=lr(A,tt,e.borderTopRightRadius),this.borderBottomRightRadius=lr(A,rt,e.borderBottomRightRadius),this.borderBottomLeftRadius=lr(A,Bt,e.borderBottomLeftRadius),this.borderTopStyle=lr(A,nt,e.borderTopStyle),this.borderRightStyle=lr(A,st,e.borderRightStyle),this.borderBottomStyle=lr(A,ot,e.borderBottomStyle),this.borderLeftStyle=lr(A,it,e.borderLeftStyle),this.borderTopWidth=lr(A,Qt,e.borderTopWidth),this.borderRightWidth=lr(A,ct,e.borderRightWidth),this.borderBottomWidth=lr(A,at,e.borderBottomWidth),this.borderLeftWidth=lr(A,gt,e.borderLeftWidth),this.boxShadow=lr(A,or,e.boxShadow),this.color=lr(A,wt,e.color),this.direction=lr(A,Ut,e.direction),this.display=lr(A,lt,e.display),this.float=lr(A,ut,e.cssFloat),this.fontFamily=lr(A,jt,e.fontFamily),this.fontSize=lr(A,zt,e.fontSize),this.fontStyle=lr(A,er,e.fontStyle),this.fontVariant=lr(A,Ar,e.fontVariant),this.fontWeight=lr(A,$t,e.fontWeight),this.letterSpacing=lr(A,Ft,e.letterSpacing),this.lineBreak=lr(A,ht,e.lineBreak),this.lineHeight=lr(A,dt,e.lineHeight),this.listStyleImage=lr(A,ft,e.listStyleImage),this.listStylePosition=lr(A,Ht,e.listStylePosition),this.listStyleType=lr(A,pt,e.listStyleType),this.marginTop=lr(A,Et,e.marginTop),this.marginRight=lr(A,It,e.marginRight),this.marginBottom=lr(A,yt,e.marginBottom),this.marginLeft=lr(A,Kt,e.marginLeft),this.opacity=lr(A,Zt,e.opacity);var t=lr(A,mt,e.overflow);this.overflowX=t[0],this.overflowY=t[1<t.length?1:0],this.overflowWrap=lr(A,Lt,e.overflowWrap),this.paddingTop=lr(A,bt,e.paddingTop),this.paddingRight=lr(A,Dt,e.paddingRight),this.paddingBottom=lr(A,vt,e.paddingBottom),this.paddingLeft=lr(A,xt,e.paddingLeft),this.paintOrder=lr(A,ir,e.paintOrder),this.position=lr(A,St,e.position),this.textAlign=lr(A,Mt,e.textAlign),this.textDecorationColor=lr(A,_t,null!==(t=e.textDecorationColor)&&void 0!==t?t:e.color),this.textDecorationLine=lr(A,qt,null!==(t=e.textDecorationLine)&&void 0!==t?t:e.textDecoration),this.textShadow=lr(A,Tt,e.textShadow),this.textTransform=lr(A,Gt,e.textTransform),this.transform=lr(A,Ot,e.transform),this.transformOrigin=lr(A,Rt,e.transformOrigin),this.visibility=lr(A,Nt,e.visibility),this.webkitTextStrokeColor=lr(A,Qr,e.webkitTextStrokeColor),this.webkitTextStrokeWidth=lr(A,cr,e.webkitTextStrokeWidth),this.wordBreak=lr(A,Jt,e.wordBreak),this.zIndex=lr(A,Yt,e.zIndex)}for(var wr=function(A,e){this.content=lr(A,tr,e.content),this.quotes=lr(A,sr,e.quotes)},Ur=function(A,e){this.counterIncrement=lr(A,rr,e.counterIncrement),this.counterReset=lr(A,Br,e.counterReset)},lr=function(A,e,t){var r=new PA,t=null!=t?t.toString():e.initialValue;r.write(t);var B=new JA(r.read());switch(e.type){case 2:var n=B.parseComponentValue();return e.parse(A,_A(n)?n.value:e.initialValue);case 0:return e.parse(A,B.parseComponentValue());case 1:return e.parse(A,B.parseComponentValues());case 4:return B.parseComponentValue();case 3:switch(e.format){case"angle":return le(A,B.parseComponentValue());case"color":return ue(A,B.parseComponentValue());case"image":return Oe(A,B.parseComponentValue());case"length":var s=B.parseComponentValue();return ee(s)?s:ae;case"length-percentage":s=B.parseComponentValue();return te(s)?s:ae;case"time":return Wt(A,B.parseComponentValue())}}},Cr=function(A,e){A=function(A){switch(A.getAttribute("data-html2canvas-debug")){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}}(A);return 1===A||e===A},ur=function(A,e){this.context=A,this.textNodes=[],this.elements=[],this.flags=0,Cr(e,3),this.styles=new ar(A,window.getComputedStyle(e,null)),JB(e)&&(this.styles.animationDuration.some(function(A){return 0<A})&&(e.style.animationDuration="0s"),null!==this.styles.transform&&(e.style.transform="none")),this.bounds=f(this.context,e),Cr(e,4)&&(this.flags|=16)},Fr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",hr="undefined"==typeof Uint8Array?[]:new Uint8Array(256),dr=0;dr<Fr.length;dr++)hr[Fr.charCodeAt(dr)]=dr;function fr(A,e,t){return A.slice?A.slice(e,t):new Uint16Array(Array.prototype.slice.call(A,e,t))}var Hr=(pr.prototype.get=function(A){var e;if(0<=A){if(A<55296||56319<A&&A<=65535)return e=this.index[A>>5],this.data[e=(e<<2)+(31&A)];if(A<=65535)return e=this.index[2048+(A-55296>>5)],this.data[e=(e<<2)+(31&A)];if(A<this.highStart)return e=this.index[e=2080+(A>>11)],e=this.index[e+=A>>5&63],this.data[e=(e<<2)+(31&A)];if(A<=1114111)return this.data[this.highValueIndex]}return this.errorValue},pr);function pr(A,e,t,r,B,n){this.initialValue=A,this.errorValue=e,this.highStart=t,this.highValueIndex=r,this.index=B,this.data=n}for(var Er="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ir="undefined"==typeof Uint8Array?[]:new Uint8Array(256),yr=0;yr<Er.length;yr++)Ir[Er.charCodeAt(yr)]=yr;function Kr(A){return kr.get(A)}function mr(A){var t=function(A){for(var e=[],t=0,r=A.length;t<r;){var B,n=A.charCodeAt(t++);55296<=n&&n<=56319&&t<r?56320==(64512&(B=A.charCodeAt(t++)))?e.push(((1023&n)<<10)+(1023&B)+65536):(e.push(n),t--):e.push(n)}return e}(A),r=t.length,B=0,n=0,s=t.map(Kr);return{next:function(){if(r<=B)return{done:!0,value:null};for(var A=Rr;B<r&&(A=function(A,e){var t=e-2,r=A[t],B=A[e-1],e=A[e];if(2===B&&3===e)return Rr;if(2===B||3===B||4===B)return"÷";if(2===e||3===e||4===e)return"÷";if(B===Tr&&-1!==[Tr,Gr,Or,Vr].indexOf(e))return Rr;if(!(B!==Or&&B!==Gr||e!==Gr&&10!==e))return Rr;if((B===Vr||10===B)&&10===e)return Rr;if(13===e||5===e)return Rr;if(7===e)return Rr;if(1===B)return Rr;if(13===B&&14===e){for(;5===r;)r=A[--t];if(14===r)return Rr}if(15===B&&15===e){for(var n=0;15===r;)n++,r=A[--t];if(n%2==0)return Rr}return"÷"}(s,++B))===Rr;);if(A===Rr&&B!==r)return{done:!0,value:null};var e=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];if(String.fromCodePoint)return String.fromCodePoint.apply(String,A);var t=A.length;if(!t)return"";for(var r=[],B=-1,n="";++B<t;){var s=A[B];s<=65535?r.push(s):(s-=65536,r.push(55296+(s>>10),s%1024+56320)),(B+1===t||16384<r.length)&&(n+=String.fromCharCode.apply(String,r),r.length=0)}return n}.apply(null,t.slice(n,B));return n=B,{value:e,done:!1}}}}function Lr(A){return 0===A[0]&&255===A[1]&&0===A[2]&&255===A[3]}var br,Dr,vr,xr,Mr,Sr,Tr=8,Gr=9,Or=11,Vr=12,kr=(vr=function(A){var e,t,r,B,n=.75*A.length,s=A.length,o=0;"="===A[A.length-1]&&(n--,"="===A[A.length-2]&&n--);for(var n=new("undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?ArrayBuffer:Array)(n),i=Array.isArray(n)?n:new Uint8Array(n),Q=0;Q<s;Q+=4)e=hr[A.charCodeAt(Q)],t=hr[A.charCodeAt(Q+1)],r=hr[A.charCodeAt(Q+2)],B=hr[A.charCodeAt(Q+3)],i[o++]=e<<2|t>>4,i[o++]=(15&t)<<4|r>>2,i[o++]=(3&r)<<6|63&B;return n}(br="AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAC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FNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAI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lQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwa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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA="),xr=Array.isArray(vr)?function(A){for(var e=A.length,t=[],r=0;r<e;r+=4)t.push(A[r+3]<<24|A[r+2]<<16|A[r+1]<<8|A[r]);return t}(vr):new Uint32Array(vr),Mr=Array.isArray(vr)?function(A){for(var e=A.length,t=[],r=0;r<e;r+=2)t.push(A[r+1]<<8|A[r]);return t}(vr):new Uint16Array(vr),br=fr(Mr,12,xr[4]/2),Dr=2===xr[5]?fr(Mr,(24+xr[4])/2):(vr=xr,Mr=Math.ceil((24+xr[4])/4),vr.slice?vr.slice(Mr,Dr):new Uint32Array(Array.prototype.slice.call(vr,Mr,Dr))),new Hr(xr[0],xr[1],xr[2],xr[3],br,Dr)),Rr="×",Nr=function(A,e,t,r,B){var n="http://www.w3.org/2000/svg",s=document.createElementNS(n,"svg"),n=document.createElementNS(n,"foreignObject");return s.setAttributeNS(null,"width",A.toString()),s.setAttributeNS(null,"height",e.toString()),n.setAttributeNS(null,"width","100%"),n.setAttributeNS(null,"height","100%"),n.setAttributeNS(null,"x",t.toString()),n.setAttributeNS(null,"y",r.toString()),n.setAttributeNS(null,"externalResourcesRequired","true"),s.appendChild(n),n.appendChild(B),s},Pr=function(r){return new Promise(function(A,e){var t=new Image;t.onload=function(){return A(t)},t.onerror=e,t.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(r))})},Xr={get SUPPORT_RANGE_BOUNDS(){var A=function(A){if(A.createRange){var e=A.createRange();if(e.getBoundingClientRect){var t=A.createElement("boundtest");t.style.height="123px",t.style.display="block",A.body.appendChild(t),e.selectNode(t);e=e.getBoundingClientRect(),e=Math.round(e.height);if(A.body.removeChild(t),123===e)return!0}}return!1}(document);return Object.defineProperty(Xr,"SUPPORT_RANGE_BOUNDS",{value:A}),A},get SUPPORT_WORD_BREAKING(){var A=Xr.SUPPORT_RANGE_BOUNDS&&function(A){var e=A.createElement("boundtest");e.style.width="50px",e.style.display="block",e.style.fontSize="12px",e.style.letterSpacing="0px",e.style.wordSpacing="0px",A.body.appendChild(e);var r=A.createRange();e.innerHTML="function"==typeof"".repeat?"&#128104;".repeat(10):"";var B=e.firstChild,t=Q(B.data).map(function(A){return g(A)}),n=0,s={},t=t.every(function(A,e){r.setStart(B,n),r.setEnd(B,n+A.length);var t=r.getBoundingClientRect();n+=A.length;A=t.x>s.x||t.y>s.y;return s=t,0===e||A});return A.body.removeChild(e),t}(document);return Object.defineProperty(Xr,"SUPPORT_WORD_BREAKING",{value:A}),A},get SUPPORT_SVG_DRAWING(){var A=function(A){var e=new Image,t=A.createElement("canvas"),A=t.getContext("2d");if(!A)return!1;e.src="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";try{A.drawImage(e,0,0),t.toDataURL()}catch(A){return!1}return!0}(document);return Object.defineProperty(Xr,"SUPPORT_SVG_DRAWING",{value:A}),A},get SUPPORT_FOREIGNOBJECT_DRAWING(){var A="function"==typeof Array.from&&"function"==typeof window.fetch?function(t){var A=t.createElement("canvas"),r=100;A.width=r,A.height=r;var B=A.getContext("2d");if(!B)return Promise.reject(!1);B.fillStyle="rgb(0, 255, 0)",B.fillRect(0,0,r,r);var e=new Image,n=A.toDataURL();e.src=n;e=Nr(r,r,0,0,e);return B.fillStyle="red",B.fillRect(0,0,r,r),Pr(e).then(function(A){B.drawImage(A,0,0);var e=B.getImageData(0,0,r,r).data;B.fillStyle="red",B.fillRect(0,0,r,r);A=t.createElement("div");return A.style.backgroundImage="url("+n+")",A.style.height="100px",Lr(e)?Pr(Nr(r,r,0,0,A)):Promise.reject(!1)}).then(function(A){return B.drawImage(A,0,0),Lr(B.getImageData(0,0,r,r).data)}).catch(function(){return!1})}(document):Promise.resolve(!1);return Object.defineProperty(Xr,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:A}),A},get SUPPORT_CORS_IMAGES(){var A=void 0!==(new Image).crossOrigin;return Object.defineProperty(Xr,"SUPPORT_CORS_IMAGES",{value:A}),A},get SUPPORT_RESPONSE_TYPE(){var A="string"==typeof(new XMLHttpRequest).responseType;return Object.defineProperty(Xr,"SUPPORT_RESPONSE_TYPE",{value:A}),A},get SUPPORT_CORS_XHR(){var A="withCredentials"in new XMLHttpRequest;return Object.defineProperty(Xr,"SUPPORT_CORS_XHR",{value:A}),A},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var A=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(Xr,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:A}),A}},Jr=function(A,e){this.text=A,this.bounds=e},Yr=function(A,e){var t=e.ownerDocument;if(t){var r=t.createElement("html2canvaswrapper");r.appendChild(e.cloneNode(!0));t=e.parentNode;if(t){t.replaceChild(r,e);A=f(A,r);return r.firstChild&&t.replaceChild(r.firstChild,r),A}}return d.EMPTY},Wr=function(A,e,t){var r=A.ownerDocument;if(!r)throw new Error("Node has no owner document");r=r.createRange();return r.setStart(A,e),r.setEnd(A,e+t),r},Zr=function(A){if(Xr.SUPPORT_NATIVE_TEXT_SEGMENTATION){var e=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(e.segment(A)).map(function(A){return A.segment})}return function(A){for(var e,t=mr(A),r=[];!(e=t.next()).done;)e.value&&r.push(e.value.slice());return r}(A)},_r=function(A,e){return 0!==e.letterSpacing?Zr(A):function(A,e){if(Xr.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(t.segment(A)).map(function(A){return A.segment})}return jr(A,e)}(A,e)},qr=[32,160,4961,65792,65793,4153,4241],jr=function(A,e){for(var t,r=wA(A,{lineBreak:e.lineBreak,wordBreak:"break-word"===e.overflowWrap?"break-word":e.wordBreak}),B=[];!(t=r.next()).done;)!function(){var A,e;t.value&&(A=t.value.slice(),A=Q(A),e="",A.forEach(function(A){-1===qr.indexOf(A)?e+=g(A):(e.length&&B.push(e),B.push(g(A)),e="")}),e.length&&B.push(e))}();return B},zr=function(A,e,t){var B,n,s,o,i;this.text=$r(e.data,t.textTransform),this.textBounds=(B=A,A=this.text,s=e,A=_r(A,n=t),o=[],i=0,A.forEach(function(A){var e,t,r;n.textDecorationLine.length||0<A.trim().length?Xr.SUPPORT_RANGE_BOUNDS?1<(r=Wr(s,i,A.length).getClientRects()).length?(e=Zr(A),t=0,e.forEach(function(A){o.push(new Jr(A,d.fromDOMRectList(B,Wr(s,t+i,A.length).getClientRects()))),t+=A.length})):o.push(new Jr(A,d.fromDOMRectList(B,r))):(r=s.splitText(A.length),o.push(new Jr(A,Yr(B,s))),s=r):Xr.SUPPORT_RANGE_BOUNDS||(s=s.splitText(A.length)),i+=A.length}),o)},$r=function(A,e){switch(e){case 1:return A.toLowerCase();case 3:return A.replace(AB,eB);case 2:return A.toUpperCase();default:return A}},AB=/(^|\s|:|-|\(|\))([a-z])/g,eB=function(A,e,t){return 0<A.length?e+t.toUpperCase():A},tB=(A(rB,Sr=ur),rB);function rB(A,e){A=Sr.call(this,A,e)||this;return A.src=e.currentSrc||e.src,A.intrinsicWidth=e.naturalWidth,A.intrinsicHeight=e.naturalHeight,A.context.cache.addImage(A.src),A}var BB,nB=(A(sB,BB=ur),sB);function sB(A,e){A=BB.call(this,A,e)||this;return A.canvas=e,A.intrinsicWidth=e.width,A.intrinsicHeight=e.height,A}var oB,iB=(A(QB,oB=ur),QB);function QB(A,e){var t=oB.call(this,A,e)||this,r=new XMLSerializer,A=f(A,e);return e.setAttribute("width",A.width+"px"),e.setAttribute("height",A.height+"px"),t.svg="data:image/svg+xml,"+encodeURIComponent(r.serializeToString(e)),t.intrinsicWidth=e.width.baseVal.value,t.intrinsicHeight=e.height.baseVal.value,t.context.cache.addImage(t.svg),t}var cB,aB=(A(gB,cB=ur),gB);function gB(A,e){A=cB.call(this,A,e)||this;return A.value=e.value,A}var wB,UB=(A(lB,wB=ur),lB);function lB(A,e){A=wB.call(this,A,e)||this;return A.start=e.start,A.reversed="boolean"==typeof e.reversed&&!0===e.reversed,A}var CB,uB=[{type:15,flags:0,unit:"px",number:3}],FB=[{type:16,flags:0,number:50}],hB="checkbox",dB="radio",fB="password",HB=707406591,pB=(A(EB,CB=ur),EB);function EB(A,e){var t=CB.call(this,A,e)||this;switch(t.type=e.type.toLowerCase(),t.checked=e.checked,t.value=0===(e=(A=e).type===fB?new Array(A.value.length+1).join("•"):A.value).length?A.placeholder||"":e,t.type!==hB&&t.type!==dB||(t.styles.backgroundColor=3739148031,t.styles.borderTopColor=t.styles.borderRightColor=t.styles.borderBottomColor=t.styles.borderLeftColor=2779096575,t.styles.borderTopWidth=t.styles.borderRightWidth=t.styles.borderBottomWidth=t.styles.borderLeftWidth=1,t.styles.borderTopStyle=t.styles.borderRightStyle=t.styles.borderBottomStyle=t.styles.borderLeftStyle=1,t.styles.backgroundClip=[0],t.styles.backgroundOrigin=[0],t.bounds=(e=t.bounds).width>e.height?new d(e.left+(e.width-e.height)/2,e.top,e.height,e.height):e.width<e.height?new d(e.left,e.top+(e.height-e.width)/2,e.width,e.width):e),t.type){case hB:t.styles.borderTopRightRadius=t.styles.borderTopLeftRadius=t.styles.borderBottomRightRadius=t.styles.borderBottomLeftRadius=uB;break;case dB:t.styles.borderTopRightRadius=t.styles.borderTopLeftRadius=t.styles.borderBottomRightRadius=t.styles.borderBottomLeftRadius=FB}return t}var IB,yB=(A(KB,IB=ur),KB);function KB(A,e){A=IB.call(this,A,e)||this,e=e.options[e.selectedIndex||0];return A.value=e&&e.text||"",A}var mB,LB=(A(bB,mB=ur),bB);function bB(A,e){A=mB.call(this,A,e)||this;return A.value=e.value,A}var DB,vB=(A(xB,DB=ur),xB);function xB(A,e){var t,r,B=DB.call(this,A,e)||this;B.src=e.src,B.width=parseInt(e.width,10)||0,B.height=parseInt(e.height,10)||0,B.backgroundColor=B.styles.backgroundColor;try{e.contentWindow&&e.contentWindow.document&&e.contentWindow.document.documentElement&&(B.tree=kB(A,e.contentWindow.document.documentElement),t=e.contentWindow.document.documentElement?fe(A,getComputedStyle(e.contentWindow.document.documentElement).backgroundColor):Le.TRANSPARENT,r=e.contentWindow.document.body?fe(A,getComputedStyle(e.contentWindow.document.body).backgroundColor):Le.TRANSPARENT,B.backgroundColor=oe(t)?oe(r)?B.styles.backgroundColor:r:t)}catch(A){}return B}function MB(A){return"VIDEO"===A.tagName}function SB(A){return"STYLE"===A.tagName}function TB(A){return 0<A.tagName.indexOf("-")}var GB=["OL","UL","MENU"],OB=function(e,A,t,r){for(var B=A.firstChild;B;B=s){var n,s=B.nextSibling;PB(B)&&0<B.data.trim().length?t.textNodes.push(new zr(e,B,t.styles)):XB(B)&&(rn(B)&&B.assignedNodes?B.assignedNodes().forEach(function(A){return OB(e,A,t,r)}):(n=VB(e,B)).styles.isVisible()&&(RB(B,n,r)?n.flags|=4:NB(n.styles)&&(n.flags|=2),-1!==GB.indexOf(B.tagName)&&(n.flags|=8),t.elements.push(n),B.slot,B.shadowRoot?OB(e,B.shadowRoot,n,r):en(B)||qB(B)||tn(B)||OB(e,B,n,r)))}},VB=function(A,e){return new($B(e)?tB:zB(e)?nB:qB(e)?iB:WB(e)?aB:ZB(e)?UB:_B(e)?pB:tn(e)?yB:en(e)?LB:An(e)?vB:ur)(A,e)},kB=function(A,e){var t=VB(A,e);return t.flags|=4,OB(A,e,t,t),t},RB=function(A,e,t){return e.styles.isPositionedWithZIndex()||e.styles.opacity<1||e.styles.isTransformed()||jB(A)&&t.styles.isTransparent()},NB=function(A){return A.isPositioned()||A.isFloating()},PB=function(A){return A.nodeType===Node.TEXT_NODE},XB=function(A){return A.nodeType===Node.ELEMENT_NODE},JB=function(A){return XB(A)&&void 0!==A.style&&!YB(A)},YB=function(A){return"object"==typeof A.className},WB=function(A){return"LI"===A.tagName},ZB=function(A){return"OL"===A.tagName},_B=function(A){return"INPUT"===A.tagName},qB=function(A){return"svg"===A.tagName},jB=function(A){return"BODY"===A.tagName},zB=function(A){return"CANVAS"===A.tagName},$B=function(A){return"IMG"===A.tagName},An=function(A){return"IFRAME"===A.tagName},en=function(A){return"TEXTAREA"===A.tagName},tn=function(A){return"SELECT"===A.tagName},rn=function(A){return"SLOT"===A.tagName},Bn=(nn.prototype.getCounterValue=function(A){A=this.counters[A];return A&&A.length?A[A.length-1]:1},nn.prototype.getCounterValues=function(A){A=this.counters[A];return A||[]},nn.prototype.pop=function(A){var e=this;A.forEach(function(A){return e.counters[A].pop()})},nn.prototype.parse=function(A){var t=this,e=A.counterIncrement,A=A.counterReset,r=!0;null!==e&&e.forEach(function(A){var e=t.counters[A.counter];e&&0!==A.increment&&(r=!1,e.length||e.push(1),e[Math.max(0,e.length-1)]+=A.increment)});var B=[];return r&&A.forEach(function(A){var e=t.counters[A.counter];B.push(A.counter),(e=e||(t.counters[A.counter]=[])).push(A.reset)}),B},nn);function nn(){this.counters={}}function sn(r,A,e,B,t,n){return r<A||e<r?Fn(r,t,0<n.length):B.integers.reduce(function(A,e,t){for(;e<=r;)r-=e,A+=B.values[t];return A},"")+n}function on(A,e,t,r){for(var B="";t||A--,B=r(A)+B,e<=(A/=e)*e;);return B}function Qn(A,e,t,r,B){var n=t-e+1;return(A<0?"-":"")+(on(Math.abs(A),n,r,function(A){return g(Math.floor(A%n)+e)})+B)}function cn(A,e,t){void 0===t&&(t=". ");var r=e.length;return on(Math.abs(A),r,!1,function(A){return e[Math.floor(A%r)]})+t}function an(A,e,t,r,B,n){if(A<-9999||9999<A)return Fn(A,4,0<B.length);var s=Math.abs(A),o=B;if(0===s)return e[0]+o;for(var i=0;0<s&&i<=4;i++){var Q=s%10;0==Q&&Pt(n,1)&&""!==o?o=e[Q]+o:1<Q||1==Q&&0===i||1==Q&&1===i&&Pt(n,2)||1==Q&&1===i&&Pt(n,4)&&100<A||1==Q&&1<i&&Pt(n,8)?o=e[Q]+(0<i?t[i-1]:"")+o:1==Q&&0<i&&(o=t[i-1]+o),s=Math.floor(s/10)}return(A<0?r:"")+o}var gn,wn={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},Un={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},ln={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},Cn={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},un="마이너스",Fn=function(A,e,t){var r=t?". ":"",B=t?"、":"",n=t?", ":"",s=t?" ":"";switch(e){case 0:return"•"+s;case 1:return"◦"+s;case 2:return"◾"+s;case 5:var o=Qn(A,48,57,!0,r);return o.length<4?"0"+o:o;case 4:return cn(A,"〇一二三四五六七八九",B);case 6:return sn(A,1,3999,wn,3,r).toLowerCase();case 7:return sn(A,1,3999,wn,3,r);case 8:return Qn(A,945,969,!1,r);case 9:return Qn(A,97,122,!1,r);case 10:return Qn(A,65,90,!1,r);case 11:return Qn(A,1632,1641,!0,r);case 12:case 49:return sn(A,1,9999,Un,3,r);case 35:return sn(A,1,9999,Un,3,r).toLowerCase();case 13:return Qn(A,2534,2543,!0,r);case 14:case 30:return Qn(A,6112,6121,!0,r);case 15:return cn(A,"子丑寅卯辰巳午未申酉戌亥",B);case 16:return cn(A,"甲乙丙丁戊己庚辛壬癸",B);case 17:case 48:return an(A,"零一二三四五六七八九","十百千萬","負",B,14);case 47:return an(A,"零壹貳參肆伍陸柒捌玖","拾佰仟萬","負",B,15);case 42:return an(A,"零一二三四五六七八九","十百千萬","负",B,14);case 41:return an(A,"零壹贰叁肆伍陆柒捌玖","拾佰仟萬","负",B,15);case 26:return an(A,"〇一二三四五六七八九","十百千万","マイナス",B,0);case 25:return an(A,"零壱弐参四伍六七八九","拾百千万","マイナス",B,7);case 31:return an(A,"영일이삼사오육칠팔구","십백천만",un,n,7);case 33:return an(A,"零一二三四五六七八九","十百千萬",un,n,0);case 32:return an(A,"零壹貳參四五六七八九","拾百千",un,n,7);case 18:return Qn(A,2406,2415,!0,r);case 20:return sn(A,1,19999,Cn,3,r);case 21:return Qn(A,2790,2799,!0,r);case 22:return Qn(A,2662,2671,!0,r);case 22:return sn(A,1,10999,ln,3,r);case 23:return cn(A,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return cn(A,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return Qn(A,3302,3311,!0,r);case 28:return cn(A,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",B);case 29:return cn(A,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",B);case 34:return Qn(A,3792,3801,!0,r);case 37:return Qn(A,6160,6169,!0,r);case 38:return Qn(A,4160,4169,!0,r);case 39:return Qn(A,2918,2927,!0,r);case 40:return Qn(A,1776,1785,!0,r);case 43:return Qn(A,3046,3055,!0,r);case 44:return Qn(A,3174,3183,!0,r);case 45:return Qn(A,3664,3673,!0,r);case 46:return Qn(A,3872,3881,!0,r);default:return Qn(A,48,57,!0,r)}},hn="data-html2canvas-ignore",dn=(fn.prototype.toIFrame=function(A,r){var e=this,B=pn(A,r);if(!B.contentWindow)return Promise.reject("Unable to find iframe window");var t=A.defaultView.pageXOffset,n=A.defaultView.pageYOffset,s=B.contentWindow,o=s.document,A=In(B).then(function(){return a(e,void 0,void 0,function(){var e,t;return H(this,function(A){switch(A.label){case 0:return this.scrolledElements.forEach(bn),s&&(s.scrollTo(r.left,r.top),!/(iPad|iPhone|iPod)/g.test(navigator.userAgent)||s.scrollY===r.top&&s.scrollX===r.left||(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(s.scrollX-r.left,s.scrollY-r.top,0,0))),e=this.options.onclone,void 0===(t=this.clonedReferenceElement)?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:o.fonts&&o.fonts.ready?[4,o.fonts.ready]:[3,2];case 1:A.sent(),A.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,En(o)]:[3,4];case 3:A.sent(),A.label=4;case 4:return"function"==typeof e?[2,Promise.resolve().then(function(){return e(o,t)}).then(function(){return B})]:[2,B]}})})});return o.open(),o.write(mn(document.doctype)+"<html></html>"),Ln(this.referenceElement.ownerDocument,t,n),o.replaceChild(o.adoptNode(this.documentElement),o.documentElement),o.close(),A},fn.prototype.createElementClone=function(A){if(Cr(A,2),zB(A))return this.createCanvasClone(A);if(MB(A))return this.createVideoClone(A);if(SB(A))return this.createStyleClone(A);var e=A.cloneNode(!1);return $B(e)&&($B(A)&&A.currentSrc&&A.currentSrc!==A.src&&(e.src=A.currentSrc,e.srcset=""),"lazy"===e.loading&&(e.loading="eager")),TB(e)?this.createCustomElementClone(e):e},fn.prototype.createCustomElementClone=function(A){var e=document.createElement("html2canvascustomelement");return Kn(A.style,e),e},fn.prototype.createStyleClone=function(A){try{var e=A.sheet;if(e&&e.cssRules){var t=[].slice.call(e.cssRules,0).reduce(function(A,e){return e&&"string"==typeof e.cssText?A+e.cssText:A},""),r=A.cloneNode(!1);return r.textContent=t,r}}catch(A){if(this.context.logger.error("Unable to access cssRules property",A),"SecurityError"!==A.name)throw A}return A.cloneNode(!1)},fn.prototype.createCanvasClone=function(e){var A;if(this.options.inlineImages&&e.ownerDocument){var t=e.ownerDocument.createElement("img");try{return t.src=e.toDataURL(),t}catch(A){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}t=e.cloneNode(!1);try{t.width=e.width,t.height=e.height;var r,B,n=e.getContext("2d"),s=t.getContext("2d");return s&&(!this.options.allowTaint&&n?s.putImageData(n.getImageData(0,0,e.width,e.height),0,0):(!(r=null!==(A=e.getContext("webgl2"))&&void 0!==A?A:e.getContext("webgl"))||!1===(null==(B=r.getContextAttributes())?void 0:B.preserveDrawingBuffer)&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e),s.drawImage(e,0,0))),t}catch(A){this.context.logger.info("Unable to clone canvas as it is tainted",e)}return t},fn.prototype.createVideoClone=function(e){var A=e.ownerDocument.createElement("canvas");A.width=e.offsetWidth,A.height=e.offsetHeight;var t=A.getContext("2d");try{return t&&(t.drawImage(e,0,0,A.width,A.height),this.options.allowTaint||t.getImageData(0,0,A.width,A.height)),A}catch(A){this.context.logger.info("Unable to clone video as it is tainted",e)}A=e.ownerDocument.createElement("canvas");return A.width=e.offsetWidth,A.height=e.offsetHeight,A},fn.prototype.appendChildNode=function(A,e,t){XB(e)&&("SCRIPT"===e.tagName||e.hasAttribute(hn)||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(e))||this.options.copyStyles&&XB(e)&&SB(e)||A.appendChild(this.cloneNode(e,t))},fn.prototype.cloneChildNodes=function(A,e,t){for(var r,B=this,n=(A.shadowRoot||A).firstChild;n;n=n.nextSibling)XB(n)&&rn(n)&&"function"==typeof n.assignedNodes?(r=n.assignedNodes()).length&&r.forEach(function(A){return B.appendChildNode(e,A,t)}):this.appendChildNode(e,n,t)},fn.prototype.cloneNode=function(A,e){if(PB(A))return document.createTextNode(A.data);if(!A.ownerDocument)return A.cloneNode(!1);var t=A.ownerDocument.defaultView;if(t&&XB(A)&&(JB(A)||YB(A))){var r=this.createElementClone(A);r.style.transitionProperty="none";var B=t.getComputedStyle(A),n=t.getComputedStyle(A,":before"),s=t.getComputedStyle(A,":after");this.referenceElement===A&&JB(r)&&(this.clonedReferenceElement=r),jB(r)&&Mn(r);t=this.counters.parse(new Ur(this.context,B)),n=this.resolvePseudoContent(A,r,n,gn.BEFORE);TB(A)&&(e=!0),MB(A)||this.cloneChildNodes(A,r,e),n&&r.insertBefore(n,r.firstChild);s=this.resolvePseudoContent(A,r,s,gn.AFTER);return s&&r.appendChild(s),this.counters.pop(t),(B&&(this.options.copyStyles||YB(A))&&!An(A)||e)&&Kn(B,r),0===A.scrollTop&&0===A.scrollLeft||this.scrolledElements.push([r,A.scrollLeft,A.scrollTop]),(en(A)||tn(A))&&(en(r)||tn(r))&&(r.value=A.value),r}return A.cloneNode(!1)},fn.prototype.resolvePseudoContent=function(o,A,e,t){var i=this;if(e){var r=e.content,Q=A.ownerDocument;if(Q&&r&&"none"!==r&&"-moz-alt-content"!==r&&"none"!==e.display){this.counters.parse(new Ur(this.context,e));var c=new wr(this.context,e),a=Q.createElement("html2canvaspseudoelement");Kn(e,a),c.content.forEach(function(A){if(0===A.type)a.appendChild(Q.createTextNode(A.value));else if(22===A.type){var e=Q.createElement("img");e.src=A.value,e.style.opacity="1",a.appendChild(e)}else if(18===A.type){var t,r,B,n,s;"attr"===A.name?(e=A.values.filter(_A)).length&&a.appendChild(Q.createTextNode(o.getAttribute(e[0].value)||"")):"counter"===A.name?(B=(r=A.values.filter($A))[0],r=r[1],B&&_A(B)&&(t=i.counters.getCounterValue(B.value),s=r&&_A(r)?pt.parse(i.context,r.value):3,a.appendChild(Q.createTextNode(Fn(t,s,!1))))):"counters"===A.name&&(B=(t=A.values.filter($A))[0],s=t[1],r=t[2],B&&_A(B)&&(B=i.counters.getCounterValues(B.value),n=r&&_A(r)?pt.parse(i.context,r.value):3,s=s&&0===s.type?s.value:"",s=B.map(function(A){return Fn(A,n,!1)}).join(s),a.appendChild(Q.createTextNode(s))))}else if(20===A.type)switch(A.value){case"open-quote":a.appendChild(Q.createTextNode(Xt(c.quotes,i.quoteDepth++,!0)));break;case"close-quote":a.appendChild(Q.createTextNode(Xt(c.quotes,--i.quoteDepth,!1)));break;default:a.appendChild(Q.createTextNode(A.value))}}),a.className=Dn+" "+vn;t=t===gn.BEFORE?" "+Dn:" "+vn;return YB(A)?A.className.baseValue+=t:A.className+=t,a}}},fn.destroy=function(A){return!!A.parentNode&&(A.parentNode.removeChild(A),!0)},fn);function fn(A,e,t){if(this.context=A,this.options=t,this.scrolledElements=[],this.referenceElement=e,this.counters=new Bn,this.quoteDepth=0,!e.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(e.ownerDocument.documentElement,!1)}(he=gn=gn||{})[he.BEFORE=0]="BEFORE",he[he.AFTER=1]="AFTER";function Hn(e){return new Promise(function(A){!e.complete&&e.src?(e.onload=A,e.onerror=A):A()})}var pn=function(A,e){var t=A.createElement("iframe");return t.className="html2canvas-container",t.style.visibility="hidden",t.style.position="fixed",t.style.left="-10000px",t.style.top="0px",t.style.border="0",t.width=e.width.toString(),t.height=e.height.toString(),t.scrolling="no",t.setAttribute(hn,"true"),A.body.appendChild(t),t},En=function(A){return Promise.all([].slice.call(A.images,0).map(Hn))},In=function(B){return new Promise(function(e,A){var t=B.contentWindow;if(!t)return A("No window assigned for iframe");var r=t.document;t.onload=B.onload=function(){t.onload=B.onload=null;var A=setInterval(function(){0<r.body.childNodes.length&&"complete"===r.readyState&&(clearInterval(A),e(B))},50)}})},yn=["all","d","content"],Kn=function(A,e){for(var t=A.length-1;0<=t;t--){var r=A.item(t);-1===yn.indexOf(r)&&e.style.setProperty(r,A.getPropertyValue(r))}return e},mn=function(A){var e="";return A&&(e+="<!DOCTYPE ",A.name&&(e+=A.name),A.internalSubset&&(e+=A.internalSubset),A.publicId&&(e+='"'+A.publicId+'"'),A.systemId&&(e+='"'+A.systemId+'"'),e+=">"),e},Ln=function(A,e,t){A&&A.defaultView&&(e!==A.defaultView.pageXOffset||t!==A.defaultView.pageYOffset)&&A.defaultView.scrollTo(e,t)},bn=function(A){var e=A[0],t=A[1],A=A[2];e.scrollLeft=t,e.scrollTop=A},Dn="___html2canvas___pseudoelement_before",vn="___html2canvas___pseudoelement_after",xn='{\n content: "" !important;\n display: none !important;\n}',Mn=function(A){Sn(A,"."+Dn+":before"+xn+"\n ."+vn+":after"+xn)},Sn=function(A,e){var t=A.ownerDocument;t&&((t=t.createElement("style")).textContent=e,A.appendChild(t))},Tn=(Gn.getOrigin=function(A){var e=Gn._link;return e?(e.href=A,e.href=e.href,e.protocol+e.hostname+e.port):"about:blank"},Gn.isSameOrigin=function(A){return Gn.getOrigin(A)===Gn._origin},Gn.setContext=function(A){Gn._link=A.document.createElement("a"),Gn._origin=Gn.getOrigin(A.location.href)},Gn._origin="about:blank",Gn);function Gn(){}var On=(Vn.prototype.addImage=function(A){var e=Promise.resolve();return this.has(A)||(Yn(A)||Pn(A))&&(this._cache[A]=this.loadImage(A)).catch(function(){}),e},Vn.prototype.match=function(A){return this._cache[A]},Vn.prototype.loadImage=function(s){return a(this,void 0,void 0,function(){var e,r,t,B,n=this;return H(this,function(A){switch(A.label){case 0:return(e=Tn.isSameOrigin(s),r=!Xn(s)&&!0===this._options.useCORS&&Xr.SUPPORT_CORS_IMAGES&&!e,t=!Xn(s)&&!e&&!Yn(s)&&"string"==typeof this._options.proxy&&Xr.SUPPORT_CORS_XHR&&!r,e||!1!==this._options.allowTaint||Xn(s)||Yn(s)||t||r)?(B=s,t?[4,this.proxy(B)]:[3,2]):[2];case 1:B=A.sent(),A.label=2;case 2:return this.context.logger.debug("Added image "+s.substring(0,256)),[4,new Promise(function(A,e){var t=new Image;t.onload=function(){return A(t)},t.onerror=e,(Jn(B)||r)&&(t.crossOrigin="anonymous"),t.src=B,!0===t.complete&&setTimeout(function(){return A(t)},500),0<n._options.imageTimeout&&setTimeout(function(){return e("Timed out ("+n._options.imageTimeout+"ms) loading image")},n._options.imageTimeout)})];case 3:return[2,A.sent()]}})})},Vn.prototype.has=function(A){return void 0!==this._cache[A]},Vn.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},Vn.prototype.proxy=function(s){var o=this,i=this._options.proxy;if(!i)throw new Error("No proxy defined");var Q=s.substring(0,256);return new Promise(function(e,t){var r=Xr.SUPPORT_RESPONSE_TYPE?"blob":"text",B=new XMLHttpRequest;B.onload=function(){var A;200===B.status?"text"==r?e(B.response):((A=new FileReader).addEventListener("load",function(){return e(A.result)},!1),A.addEventListener("error",function(A){return t(A)},!1),A.readAsDataURL(B.response)):t("Failed to proxy resource "+Q+" with status code "+B.status)},B.onerror=t;var A,n=-1<i.indexOf("?")?"&":"?";B.open("GET",i+n+"url="+encodeURIComponent(s)+"&responseType="+r),"text"!=r&&B instanceof XMLHttpRequest&&(B.responseType=r),o._options.imageTimeout&&(A=o._options.imageTimeout,B.timeout=A,B.ontimeout=function(){return t("Timed out ("+A+"ms) proxying "+Q)}),B.send()})},Vn);function Vn(A,e){this.context=A,this._options=e,this._cache={}}var kn=/^data:image\/svg\+xml/i,Rn=/^data:image\/.*;base64,/i,Nn=/^data:image\/.*/i,Pn=function(A){return Xr.SUPPORT_SVG_DRAWING||!Wn(A)},Xn=function(A){return Nn.test(A)},Jn=function(A){return Rn.test(A)},Yn=function(A){return"blob"===A.substr(0,4)},Wn=function(A){return"svg"===A.substr(-3).toLowerCase()||kn.test(A)},Zn=(_n.prototype.add=function(A,e){return new _n(this.x+A,this.y+e)},_n);function _n(A,e){this.type=0,this.x=A,this.y=e}function qn(A,e,t){return new Zn(A.x+(e.x-A.x)*t,A.y+(e.y-A.y)*t)}var jn=(zn.prototype.subdivide=function(A,e){var t=qn(this.start,this.startControl,A),r=qn(this.startControl,this.endControl,A),B=qn(this.endControl,this.end,A),n=qn(t,r,A),r=qn(r,B,A),A=qn(n,r,A);return e?new zn(this.start,t,n,A):new zn(A,r,B,this.end)},zn.prototype.add=function(A,e){return new zn(this.start.add(A,e),this.startControl.add(A,e),this.endControl.add(A,e),this.end.add(A,e))},zn.prototype.reverse=function(){return new zn(this.end,this.endControl,this.startControl,this.start)},zn);function zn(A,e,t,r){this.type=1,this.start=A,this.startControl=e,this.endControl=t,this.end=r}function $n(A){return 1===A.type}var As,es=function(A){var e=A.styles,t=A.bounds,r=(C=Be(e.borderTopLeftRadius,t.width,t.height))[0],B=C[1],n=(u=Be(e.borderTopRightRadius,t.width,t.height))[0],s=u[1],o=(F=Be(e.borderBottomRightRadius,t.width,t.height))[0],i=F[1],Q=(h=Be(e.borderBottomLeftRadius,t.width,t.height))[0],c=h[1];(d=[]).push((r+n)/t.width),d.push((Q+o)/t.width),d.push((B+c)/t.height),d.push((s+i)/t.height),1<(f=Math.max.apply(Math,d))&&(r/=f,B/=f,n/=f,s/=f,o/=f,i/=f,Q/=f,c/=f);var a=t.width-n,g=t.height-i,w=t.width-o,U=t.height-c,l=e.borderTopWidth,C=e.borderRightWidth,u=e.borderBottomWidth,F=e.borderLeftWidth,h=Ue(e.paddingTop,A.bounds.width),d=Ue(e.paddingRight,A.bounds.width),f=Ue(e.paddingBottom,A.bounds.width),A=Ue(e.paddingLeft,A.bounds.width);this.topLeftBorderDoubleOuterBox=0<r||0<B?ss(t.left+F/3,t.top+l/3,r-F/3,B-l/3,As.TOP_LEFT):new Zn(t.left+F/3,t.top+l/3),this.topRightBorderDoubleOuterBox=0<r||0<B?ss(t.left+a,t.top+l/3,n-C/3,s-l/3,As.TOP_RIGHT):new Zn(t.left+t.width-C/3,t.top+l/3),this.bottomRightBorderDoubleOuterBox=0<o||0<i?ss(t.left+w,t.top+g,o-C/3,i-u/3,As.BOTTOM_RIGHT):new Zn(t.left+t.width-C/3,t.top+t.height-u/3),this.bottomLeftBorderDoubleOuterBox=0<Q||0<c?ss(t.left+F/3,t.top+U,Q-F/3,c-u/3,As.BOTTOM_LEFT):new Zn(t.left+F/3,t.top+t.height-u/3),this.topLeftBorderDoubleInnerBox=0<r||0<B?ss(t.left+2*F/3,t.top+2*l/3,r-2*F/3,B-2*l/3,As.TOP_LEFT):new Zn(t.left+2*F/3,t.top+2*l/3),this.topRightBorderDoubleInnerBox=0<r||0<B?ss(t.left+a,t.top+2*l/3,n-2*C/3,s-2*l/3,As.TOP_RIGHT):new Zn(t.left+t.width-2*C/3,t.top+2*l/3),this.bottomRightBorderDoubleInnerBox=0<o||0<i?ss(t.left+w,t.top+g,o-2*C/3,i-2*u/3,As.BOTTOM_RIGHT):new Zn(t.left+t.width-2*C/3,t.top+t.height-2*u/3),this.bottomLeftBorderDoubleInnerBox=0<Q||0<c?ss(t.left+2*F/3,t.top+U,Q-2*F/3,c-2*u/3,As.BOTTOM_LEFT):new Zn(t.left+2*F/3,t.top+t.height-2*u/3),this.topLeftBorderStroke=0<r||0<B?ss(t.left+F/2,t.top+l/2,r-F/2,B-l/2,As.TOP_LEFT):new Zn(t.left+F/2,t.top+l/2),this.topRightBorderStroke=0<r||0<B?ss(t.left+a,t.top+l/2,n-C/2,s-l/2,As.TOP_RIGHT):new Zn(t.left+t.width-C/2,t.top+l/2),this.bottomRightBorderStroke=0<o||0<i?ss(t.left+w,t.top+g,o-C/2,i-u/2,As.BOTTOM_RIGHT):new Zn(t.left+t.width-C/2,t.top+t.height-u/2),this.bottomLeftBorderStroke=0<Q||0<c?ss(t.left+F/2,t.top+U,Q-F/2,c-u/2,As.BOTTOM_LEFT):new Zn(t.left+F/2,t.top+t.height-u/2),this.topLeftBorderBox=0<r||0<B?ss(t.left,t.top,r,B,As.TOP_LEFT):new Zn(t.left,t.top),this.topRightBorderBox=0<n||0<s?ss(t.left+a,t.top,n,s,As.TOP_RIGHT):new Zn(t.left+t.width,t.top),this.bottomRightBorderBox=0<o||0<i?ss(t.left+w,t.top+g,o,i,As.BOTTOM_RIGHT):new Zn(t.left+t.width,t.top+t.height),this.bottomLeftBorderBox=0<Q||0<c?ss(t.left,t.top+U,Q,c,As.BOTTOM_LEFT):new Zn(t.left,t.top+t.height),this.topLeftPaddingBox=0<r||0<B?ss(t.left+F,t.top+l,Math.max(0,r-F),Math.max(0,B-l),As.TOP_LEFT):new Zn(t.left+F,t.top+l),this.topRightPaddingBox=0<n||0<s?ss(t.left+Math.min(a,t.width-C),t.top+l,a>t.width+C?0:Math.max(0,n-C),Math.max(0,s-l),As.TOP_RIGHT):new Zn(t.left+t.width-C,t.top+l),this.bottomRightPaddingBox=0<o||0<i?ss(t.left+Math.min(w,t.width-F),t.top+Math.min(g,t.height-u),Math.max(0,o-C),Math.max(0,i-u),As.BOTTOM_RIGHT):new Zn(t.left+t.width-C,t.top+t.height-u),this.bottomLeftPaddingBox=0<Q||0<c?ss(t.left+F,t.top+Math.min(U,t.height-u),Math.max(0,Q-F),Math.max(0,c-u),As.BOTTOM_LEFT):new Zn(t.left+F,t.top+t.height-u),this.topLeftContentBox=0<r||0<B?ss(t.left+F+A,t.top+l+h,Math.max(0,r-(F+A)),Math.max(0,B-(l+h)),As.TOP_LEFT):new Zn(t.left+F+A,t.top+l+h),this.topRightContentBox=0<n||0<s?ss(t.left+Math.min(a,t.width+F+A),t.top+l+h,a>t.width+F+A?0:n-F+A,s-(l+h),As.TOP_RIGHT):new Zn(t.left+t.width-(C+d),t.top+l+h),this.bottomRightContentBox=0<o||0<i?ss(t.left+Math.min(w,t.width-(F+A)),t.top+Math.min(g,t.height+l+h),Math.max(0,o-(C+d)),i-(u+f),As.BOTTOM_RIGHT):new Zn(t.left+t.width-(C+d),t.top+t.height-(u+f)),this.bottomLeftContentBox=0<Q||0<c?ss(t.left+F+A,t.top+U,Math.max(0,Q-(F+A)),c-(u+f),As.BOTTOM_LEFT):new Zn(t.left+F+A,t.top+t.height-(u+f))};(he=As=As||{})[he.TOP_LEFT=0]="TOP_LEFT",he[he.TOP_RIGHT=1]="TOP_RIGHT",he[he.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",he[he.BOTTOM_LEFT=3]="BOTTOM_LEFT";function ts(A){return[A.topLeftBorderBox,A.topRightBorderBox,A.bottomRightBorderBox,A.bottomLeftBorderBox]}function rs(A){return[A.topLeftPaddingBox,A.topRightPaddingBox,A.bottomRightPaddingBox,A.bottomLeftPaddingBox]}function Bs(A){return 1===A.type}function ns(A,t){return A.length===t.length&&A.some(function(A,e){return A===t[e]})}var ss=function(A,e,t,r,B){var n=(Math.sqrt(2)-1)/3*4,s=t*n,o=r*n,i=A+t,Q=e+r;switch(B){case As.TOP_LEFT:return new jn(new Zn(A,Q),new Zn(A,Q-o),new Zn(i-s,e),new Zn(i,e));case As.TOP_RIGHT:return new jn(new Zn(A,e),new Zn(A+s,e),new Zn(i,Q-o),new Zn(i,Q));case As.BOTTOM_RIGHT:return new jn(new Zn(i,e),new Zn(i,e+o),new Zn(A+s,Q),new Zn(A,Q));default:As.BOTTOM_LEFT;return new jn(new Zn(i,Q),new Zn(i-s,Q),new Zn(A,e+o),new Zn(A,e))}},os=function(A,e,t){this.offsetX=A,this.offsetY=e,this.matrix=t,this.type=0,this.target=6},is=function(A,e){this.path=A,this.target=e,this.type=1},Qs=function(A){this.opacity=A,this.type=2,this.target=6},cs=function(A){this.element=A,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]},as=(gs.prototype.getEffects=function(e){for(var A=-1===[2,3].indexOf(this.container.styles.position),t=this.parent,r=this.effects.slice(0);t;){var B,n,s=t.effects.filter(function(A){return!Bs(A)});A||0!==t.container.styles.position||!t.parent?(r.unshift.apply(r,s),A=-1===[2,3].indexOf(t.container.styles.position),0!==t.container.styles.overflowX&&(B=ts(t.curves),n=rs(t.curves),ns(B,n)||r.unshift(new is(n,6)))):r.unshift.apply(r,s),t=t.parent}return r.filter(function(A){return Pt(A.target,e)})},gs);function gs(A,e){var t,r;this.container=A,this.parent=e,this.effects=[],this.curves=new es(this.container),this.container.styles.opacity<1&&this.effects.push(new Qs(this.container.styles.opacity)),null!==this.container.styles.transform&&(e=this.container.bounds.left+this.container.styles.transformOrigin[0].number,t=this.container.bounds.top+this.container.styles.transformOrigin[1].number,r=this.container.styles.transform,this.effects.push(new os(e,t,r))),0!==this.container.styles.overflowX&&(t=ts(this.curves),r=rs(this.curves),ns(t,r)?this.effects.push(new is(t,6)):(this.effects.push(new is(t,2)),this.effects.push(new is(r,4))))}function ws(A,e){switch(e){case 0:return Hs(A.topLeftBorderBox,A.topLeftPaddingBox,A.topRightBorderBox,A.topRightPaddingBox);case 1:return Hs(A.topRightBorderBox,A.topRightPaddingBox,A.bottomRightBorderBox,A.bottomRightPaddingBox);case 2:return Hs(A.bottomRightBorderBox,A.bottomRightPaddingBox,A.bottomLeftBorderBox,A.bottomLeftPaddingBox);default:return Hs(A.bottomLeftBorderBox,A.bottomLeftPaddingBox,A.topLeftBorderBox,A.topLeftPaddingBox)}}function Us(A){var e=A.bounds,A=A.styles;return e.add(A.borderLeftWidth,A.borderTopWidth,-(A.borderRightWidth+A.borderLeftWidth),-(A.borderTopWidth+A.borderBottomWidth))}function ls(A){var e=A.styles,t=A.bounds,r=Ue(e.paddingLeft,t.width),B=Ue(e.paddingRight,t.width),n=Ue(e.paddingTop,t.width),A=Ue(e.paddingBottom,t.width);return t.add(r+e.borderLeftWidth,n+e.borderTopWidth,-(e.borderRightWidth+e.borderLeftWidth+r+B),-(e.borderTopWidth+e.borderBottomWidth+n+A))}function Cs(A,e,t){var r=(B=Es(A.styles.backgroundOrigin,e),n=A,0===B?n.bounds:(2===B?ls:Us)(n)),B=(s=Es(A.styles.backgroundClip,e),o=A,0===s?o.bounds:(2===s?ls:Us)(o)),n=ps(Es(A.styles.backgroundSize,e),t,r),s=n[0],o=n[1],t=Be(Es(A.styles.backgroundPosition,e),r.width-s,r.height-o);return[Is(Es(A.styles.backgroundRepeat,e),t,n,r,B),Math.round(r.left+t[0]),Math.round(r.top+t[1]),s,o]}function us(A){return _A(A)&&A.value===Ve.AUTO}function Fs(A){return"number"==typeof A}var hs=function(Q,c,a,g){Q.container.elements.forEach(function(A){var e=Pt(A.flags,4),t=Pt(A.flags,2),r=new as(A,Q);Pt(A.styles.display,2048)&&g.push(r);var B,n,s,o,i=Pt(A.flags,8)?[]:g;e||t?(B=e||A.styles.isPositioned()?a:c,t=new cs(r),A.styles.isPositioned()||A.styles.opacity<1||A.styles.isTransformed()?(n=A.styles.zIndex.order)<0?(s=0,B.negativeZIndex.some(function(A,e){return n>A.element.container.styles.zIndex.order?(s=e,!1):0<s}),B.negativeZIndex.splice(s,0,t)):0<n?(o=0,B.positiveZIndex.some(function(A,e){return n>=A.element.container.styles.zIndex.order?(o=e+1,!1):0<o}),B.positiveZIndex.splice(o,0,t)):B.zeroOrAutoZIndexOrTransformedOrOpacity.push(t):(A.styles.isFloating()?B.nonPositionedFloats:B.nonPositionedInlineLevel).push(t),hs(r,t,e?t:a,i)):((A.styles.isInlineLevel()?c.inlineLevel:c.nonInlineLevel).push(r),hs(r,c,a,i)),Pt(A.flags,8)&&ds(A,i)})},ds=function(A,e){for(var t=A instanceof UB?A.start:1,r=A instanceof UB&&A.reversed,B=0;B<e.length;B++){var n=e[B];n.container instanceof aB&&"number"==typeof n.container.value&&0!==n.container.value&&(t=n.container.value),n.listValue=Fn(t,n.container.styles.listStyleType,!0),t+=r?-1:1}},fs=function(A,e){var t=[];return $n(A)?t.push(A.subdivide(.5,!1)):t.push(A),$n(e)?t.push(e.subdivide(.5,!0)):t.push(e),t},Hs=function(A,e,t,r){var B=[];return $n(A)?B.push(A.subdivide(.5,!1)):B.push(A),$n(t)?B.push(t.subdivide(.5,!0)):B.push(t),$n(r)?B.push(r.subdivide(.5,!0).reverse()):B.push(r),$n(e)?B.push(e.subdivide(.5,!1).reverse()):B.push(e),B},ps=function(A,e,t){var r=e[0],B=e[1],n=e[2],s=A[0],o=A[1];if(!s)return[0,0];if(te(s)&&o&&te(o))return[Ue(s,t.width),Ue(o,t.height)];var i=Fs(n);if(_A(s)&&(s.value===Ve.CONTAIN||s.value===Ve.COVER))return Fs(n)?t.width/t.height<n!=(s.value===Ve.COVER)?[t.width,t.width/n]:[t.height*n,t.height]:[t.width,t.height];var Q=Fs(r),e=Fs(B),A=Q||e;if(us(s)&&(!o||us(o)))return Q&&e?[r,B]:i||A?A&&i?[Q?r:B*n,e?B:r/n]:[Q?r:t.width,e?B:t.height]:[t.width,t.height];if(i){var c=0,a=0;return te(s)?c=Ue(s,t.width):te(o)&&(a=Ue(o,t.height)),us(s)?c=a*n:o&&!us(o)||(a=c/n),[c,a]}c=null,a=null;if(te(s)?c=Ue(s,t.width):o&&te(o)&&(a=Ue(o,t.height)),null!==(c=null!==(a=null!==c&&(!o||us(o))?Q&&e?c/r*B:t.height:a)&&us(s)?Q&&e?a/B*r:t.width:c)&&null!==a)return[c,a];throw new Error("Unable to calculate background-size for element")},Es=function(A,e){e=A[e];return void 0===e?A[0]:e},Is=function(A,e,t,r,B){var n=e[0],s=e[1],o=t[0],i=t[1];switch(A){case 2:return[new Zn(Math.round(r.left),Math.round(r.top+s)),new Zn(Math.round(r.left+r.width),Math.round(r.top+s)),new Zn(Math.round(r.left+r.width),Math.round(i+r.top+s)),new Zn(Math.round(r.left),Math.round(i+r.top+s))];case 3:return[new Zn(Math.round(r.left+n),Math.round(r.top)),new Zn(Math.round(r.left+n+o),Math.round(r.top)),new Zn(Math.round(r.left+n+o),Math.round(r.height+r.top)),new Zn(Math.round(r.left+n),Math.round(r.height+r.top))];case 1:return[new Zn(Math.round(r.left+n),Math.round(r.top+s)),new Zn(Math.round(r.left+n+o),Math.round(r.top+s)),new Zn(Math.round(r.left+n+o),Math.round(r.top+s+i)),new Zn(Math.round(r.left+n),Math.round(r.top+s+i))];default:return[new Zn(Math.round(B.left),Math.round(B.top)),new Zn(Math.round(B.left+B.width),Math.round(B.top)),new Zn(Math.round(B.left+B.width),Math.round(B.height+B.top)),new Zn(Math.round(B.left),Math.round(B.height+B.top))]}},ys="Hidden Text",Ks=(ms.prototype.parseMetrics=function(A,e){var t=this._document.createElement("div"),r=this._document.createElement("img"),B=this._document.createElement("span"),n=this._document.body;t.style.visibility="hidden",t.style.fontFamily=A,t.style.fontSize=e,t.style.margin="0",t.style.padding="0",t.style.whiteSpace="nowrap",n.appendChild(t),r.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",r.width=1,r.height=1,r.style.margin="0",r.style.padding="0",r.style.verticalAlign="baseline",B.style.fontFamily=A,B.style.fontSize=e,B.style.margin="0",B.style.padding="0",B.appendChild(this._document.createTextNode(ys)),t.appendChild(B),t.appendChild(r);e=r.offsetTop-B.offsetTop+2;t.removeChild(B),t.appendChild(this._document.createTextNode(ys)),t.style.lineHeight="normal",r.style.verticalAlign="super";r=r.offsetTop-t.offsetTop+2;return n.removeChild(t),{baseline:e,middle:r}},ms.prototype.getMetrics=function(A,e){var t=A+" "+e;return void 0===this._data[t]&&(this._data[t]=this.parseMetrics(A,e)),this._data[t]},ms);function ms(A){this._data={},this._document=A}var Ls,he=function(A,e){this.context=A,this.options=e},bs=(A(Ds,Ls=he),Ds.prototype.applyEffects=function(A){for(var e=this;this._activeEffects.length;)this.popEffect();A.forEach(function(A){return e.applyEffect(A)})},Ds.prototype.applyEffect=function(A){this.ctx.save(),2===A.type&&(this.ctx.globalAlpha=A.opacity),0===A.type&&(this.ctx.translate(A.offsetX,A.offsetY),this.ctx.transform(A.matrix[0],A.matrix[1],A.matrix[2],A.matrix[3],A.matrix[4],A.matrix[5]),this.ctx.translate(-A.offsetX,-A.offsetY)),Bs(A)&&(this.path(A.path),this.ctx.clip()),this._activeEffects.push(A)},Ds.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},Ds.prototype.renderStack=function(e){return a(this,void 0,void 0,function(){return H(this,function(A){switch(A.label){case 0:return e.element.container.styles.isVisible()?[4,this.renderStackContent(e)]:[3,2];case 1:A.sent(),A.label=2;case 2:return[2]}})})},Ds.prototype.renderNode=function(e){return a(this,void 0,void 0,function(){return H(this,function(A){switch(A.label){case 0:return Pt(e.container.flags,16),e.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(e)]:[3,3];case 1:return A.sent(),[4,this.renderNodeContent(e)];case 2:A.sent(),A.label=3;case 3:return[2]}})})},Ds.prototype.renderTextWithLetterSpacing=function(t,A,r){var B=this;0===A?this.ctx.fillText(t.text,t.bounds.left,t.bounds.top+r):Zr(t.text).reduce(function(A,e){return B.ctx.fillText(e,A,t.bounds.top+r),A+B.ctx.measureText(e).width},t.bounds.left)},Ds.prototype.createFontStyle=function(A){var e=A.fontVariant.filter(function(A){return"normal"===A||"small-caps"===A}).join(""),t=Gs(A.fontFamily).join(", "),r=WA(A.fontSize)?""+A.fontSize.number+A.fontSize.unit:A.fontSize.number+"px";return[[A.fontStyle,e,A.fontWeight,r,t].join(" "),t,r]},Ds.prototype.renderTextNode=function(i,Q){return a(this,void 0,void 0,function(){var e,t,r,B,n,s,o=this;return H(this,function(A){return r=this.createFontStyle(Q),e=r[0],t=r[1],r=r[2],this.ctx.font=e,this.ctx.direction=1===Q.direction?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",r=this.fontMetrics.getMetrics(t,r),B=r.baseline,n=r.middle,s=Q.paintOrder,i.textBounds.forEach(function(t){s.forEach(function(A){switch(A){case 0:o.ctx.fillStyle=ie(Q.color),o.renderTextWithLetterSpacing(t,Q.letterSpacing,B);var e=Q.textShadow;e.length&&t.text.trim().length&&(e.slice(0).reverse().forEach(function(A){o.ctx.shadowColor=ie(A.color),o.ctx.shadowOffsetX=A.offsetX.number*o.options.scale,o.ctx.shadowOffsetY=A.offsetY.number*o.options.scale,o.ctx.shadowBlur=A.blur.number,o.renderTextWithLetterSpacing(t,Q.letterSpacing,B)}),o.ctx.shadowColor="",o.ctx.shadowOffsetX=0,o.ctx.shadowOffsetY=0,o.ctx.shadowBlur=0),Q.textDecorationLine.length&&(o.ctx.fillStyle=ie(Q.textDecorationColor||Q.color),Q.textDecorationLine.forEach(function(A){switch(A){case 1:o.ctx.fillRect(t.bounds.left,Math.round(t.bounds.top+B),t.bounds.width,1);break;case 2:o.ctx.fillRect(t.bounds.left,Math.round(t.bounds.top),t.bounds.width,1);break;case 3:o.ctx.fillRect(t.bounds.left,Math.ceil(t.bounds.top+n),t.bounds.width,1)}}));break;case 1:Q.webkitTextStrokeWidth&&t.text.trim().length&&(o.ctx.strokeStyle=ie(Q.webkitTextStrokeColor),o.ctx.lineWidth=Q.webkitTextStrokeWidth,o.ctx.lineJoin=window.chrome?"miter":"round",o.ctx.strokeText(t.text,t.bounds.left,t.bounds.top+B)),o.ctx.strokeStyle="",o.ctx.lineWidth=0,o.ctx.lineJoin="miter"}})}),[2]})})},Ds.prototype.renderReplacedElement=function(A,e,t){var r;t&&0<A.intrinsicWidth&&0<A.intrinsicHeight&&(r=ls(A),e=rs(e),this.path(e),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(t,0,0,A.intrinsicWidth,A.intrinsicHeight,r.left,r.top,r.width,r.height),this.ctx.restore())},Ds.prototype.renderNodeContent=function(w){return a(this,void 0,void 0,function(){var e,t,r,B,n,s,o,i,Q,c,a,g;return H(this,function(A){switch(A.label){case 0:this.applyEffects(w.getEffects(4)),e=w.container,t=w.curves,r=e.styles,B=0,n=e.textNodes,A.label=1;case 1:return B<n.length?(s=n[B],[4,this.renderTextNode(s,r)]):[3,4];case 2:A.sent(),A.label=3;case 3:return B++,[3,1];case 4:if(!(e instanceof tB))return[3,8];A.label=5;case 5:return A.trys.push([5,7,,8]),[4,this.context.cache.match(e.src)];case 6:return Q=A.sent(),this.renderReplacedElement(e,t,Q),[3,8];case 7:return A.sent(),this.context.logger.error("Error loading image "+e.src),[3,8];case 8:if(e instanceof nB&&this.renderReplacedElement(e,t,e.canvas),!(e instanceof iB))return[3,12];A.label=9;case 9:return A.trys.push([9,11,,12]),[4,this.context.cache.match(e.svg)];case 10:return Q=A.sent(),this.renderReplacedElement(e,t,Q),[3,12];case 11:return A.sent(),this.context.logger.error("Error loading svg "+e.svg.substring(0,255)),[3,12];case 12:return e instanceof vB&&e.tree?[4,new Ds(this.context,{scale:this.options.scale,backgroundColor:e.backgroundColor,x:0,y:0,width:e.width,height:e.height}).render(e.tree)]:[3,14];case 13:s=A.sent(),e.width&&e.height&&this.ctx.drawImage(s,0,0,e.width,e.height,e.bounds.left,e.bounds.top,e.bounds.width,e.bounds.height),A.label=14;case 14:if(e instanceof pB&&(i=Math.min(e.bounds.width,e.bounds.height),e.type===hB?e.checked&&(this.ctx.save(),this.path([new Zn(e.bounds.left+.39363*i,e.bounds.top+.79*i),new Zn(e.bounds.left+.16*i,e.bounds.top+.5549*i),new Zn(e.bounds.left+.27347*i,e.bounds.top+.44071*i),new Zn(e.bounds.left+.39694*i,e.bounds.top+.5649*i),new Zn(e.bounds.left+.72983*i,e.bounds.top+.23*i),new Zn(e.bounds.left+.84*i,e.bounds.top+.34085*i),new Zn(e.bounds.left+.39363*i,e.bounds.top+.79*i)]),this.ctx.fillStyle=ie(HB),this.ctx.fill(),this.ctx.restore()):e.type===dB&&e.checked&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.arc(e.bounds.left+i/2,e.bounds.top+i/2,i/4,0,2*Math.PI,!0),this.ctx.fillStyle=ie(HB),this.ctx.fill(),this.ctx.restore())),xs(e)&&e.value.length){switch(c=this.createFontStyle(r),a=c[0],i=c[1],c=this.fontMetrics.getMetrics(a,i).baseline,this.ctx.font=a,this.ctx.fillStyle=ie(r.color),this.ctx.textBaseline="alphabetic",this.ctx.textAlign=Ss(e.styles.textAlign),g=ls(e),o=0,e.styles.textAlign){case 1:o+=g.width/2;break;case 2:o+=g.width}i=g.add(o,0,0,-g.height/2+1),this.ctx.save(),this.path([new Zn(g.left,g.top),new Zn(g.left+g.width,g.top),new Zn(g.left+g.width,g.top+g.height),new Zn(g.left,g.top+g.height)]),this.ctx.clip(),this.renderTextWithLetterSpacing(new Jr(e.value,i),r.letterSpacing,c),this.ctx.restore(),this.ctx.textBaseline="alphabetic",this.ctx.textAlign="left"}if(!Pt(e.styles.display,2048))return[3,20];if(null===e.styles.listStyleImage)return[3,19];if(0!==(c=e.styles.listStyleImage).type)return[3,18];Q=void 0,c=c.url,A.label=15;case 15:return A.trys.push([15,17,,18]),[4,this.context.cache.match(c)];case 16:return Q=A.sent(),this.ctx.drawImage(Q,e.bounds.left-(Q.width+10),e.bounds.top),[3,18];case 17:return A.sent(),this.context.logger.error("Error loading list-style-image "+c),[3,18];case 18:return[3,20];case 19:w.listValue&&-1!==e.styles.listStyleType&&(a=this.createFontStyle(r)[0],this.ctx.font=a,this.ctx.fillStyle=ie(r.color),this.ctx.textBaseline="middle",this.ctx.textAlign="right",g=new d(e.bounds.left,e.bounds.top+Ue(e.styles.paddingTop,e.bounds.width),e.bounds.width,Ye(r.lineHeight,r.fontSize.number)/2+1),this.renderTextWithLetterSpacing(new Jr(w.listValue,g),r.letterSpacing,Ye(r.lineHeight,r.fontSize.number)/2+2),this.ctx.textBaseline="bottom",this.ctx.textAlign="left"),A.label=20;case 20:return[2]}})})},Ds.prototype.renderStackContent=function(C){return a(this,void 0,void 0,function(){var e,t,r,B,n,s,o,i,Q,c,a,g,w,U,l;return H(this,function(A){switch(A.label){case 0:return Pt(C.element.container.flags,16),[4,this.renderNodeBackgroundAndBorders(C.element)];case 1:A.sent(),e=0,t=C.negativeZIndex,A.label=2;case 2:return e<t.length?(l=t[e],[4,this.renderStack(l)]):[3,5];case 3:A.sent(),A.label=4;case 4:return e++,[3,2];case 5:return[4,this.renderNodeContent(C.element)];case 6:A.sent(),r=0,B=C.nonInlineLevel,A.label=7;case 7:return r<B.length?(l=B[r],[4,this.renderNode(l)]):[3,10];case 8:A.sent(),A.label=9;case 9:return r++,[3,7];case 10:n=0,s=C.nonPositionedFloats,A.label=11;case 11:return n<s.length?(l=s[n],[4,this.renderStack(l)]):[3,14];case 12:A.sent(),A.label=13;case 13:return n++,[3,11];case 14:o=0,i=C.nonPositionedInlineLevel,A.label=15;case 15:return o<i.length?(l=i[o],[4,this.renderStack(l)]):[3,18];case 16:A.sent(),A.label=17;case 17:return o++,[3,15];case 18:Q=0,c=C.inlineLevel,A.label=19;case 19:return Q<c.length?(l=c[Q],[4,this.renderNode(l)]):[3,22];case 20:A.sent(),A.label=21;case 21:return Q++,[3,19];case 22:a=0,g=C.zeroOrAutoZIndexOrTransformedOrOpacity,A.label=23;case 23:return a<g.length?(l=g[a],[4,this.renderStack(l)]):[3,26];case 24:A.sent(),A.label=25;case 25:return a++,[3,23];case 26:w=0,U=C.positiveZIndex,A.label=27;case 27:return w<U.length?(l=U[w],[4,this.renderStack(l)]):[3,30];case 28:A.sent(),A.label=29;case 29:return w++,[3,27];case 30:return[2]}})})},Ds.prototype.mask=function(A){this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.lineTo(this.canvas.width,0),this.ctx.lineTo(this.canvas.width,this.canvas.height),this.ctx.lineTo(0,this.canvas.height),this.ctx.lineTo(0,0),this.formatPath(A.slice(0).reverse()),this.ctx.closePath()},Ds.prototype.path=function(A){this.ctx.beginPath(),this.formatPath(A),this.ctx.closePath()},Ds.prototype.formatPath=function(A){var r=this;A.forEach(function(A,e){var t=$n(A)?A.start:A;0===e?r.ctx.moveTo(t.x,t.y):r.ctx.lineTo(t.x,t.y),$n(A)&&r.ctx.bezierCurveTo(A.startControl.x,A.startControl.y,A.endControl.x,A.endControl.y,A.end.x,A.end.y)})},Ds.prototype.renderRepeat=function(A,e,t,r){this.path(A),this.ctx.fillStyle=e,this.ctx.translate(t,r),this.ctx.fill(),this.ctx.translate(-t,-r)},Ds.prototype.resizeImage=function(A,e,t){if(A.width===e&&A.height===t)return A;var r=(null!==(r=this.canvas.ownerDocument)&&void 0!==r?r:document).createElement("canvas");return r.width=Math.max(1,e),r.height=Math.max(1,t),r.getContext("2d").drawImage(A,0,0,A.width,A.height,0,0,e,t),r},Ds.prototype.renderBackgroundImage=function(f){return a(this,void 0,void 0,function(){var h,e,d,t,r,B;return H(this,function(A){switch(A.label){case 0:h=f.styles.backgroundImage.length-1,e=function(e){var t,r,B,n,s,o,i,Q,c,a,g,w,U,l,C,u,F;return H(this,function(A){switch(A.label){case 0:if(0!==e.type)return[3,5];t=void 0,r=e.url,A.label=1;case 1:return A.trys.push([1,3,,4]),[4,d.context.cache.match(r)];case 2:return t=A.sent(),[3,4];case 3:return A.sent(),d.context.logger.error("Error loading background-image "+r),[3,4];case 4:return t&&(B=Cs(f,h,[t.width,t.height,t.width/t.height]),o=B[0],g=B[1],w=B[2],c=B[3],a=B[4],s=d.ctx.createPattern(d.resizeImage(t,c,a),"repeat"),d.renderRepeat(o,s,g,w)),[3,6];case 5:1===e.type?(F=Cs(f,h,[null,null,null]),o=F[0],g=F[1],w=F[2],c=F[3],a=F[4],C=Ee(e.angle,c,a),l=C[0],B=C[1],i=C[2],u=C[3],Q=C[4],(F=document.createElement("canvas")).width=c,F.height=a,C=F.getContext("2d"),n=C.createLinearGradient(B,u,i,Q),pe(e.stops,l).forEach(function(A){return n.addColorStop(A.stop,ie(A.color))}),C.fillStyle=n,C.fillRect(0,0,c,a),0<c&&0<a&&(s=d.ctx.createPattern(F,"repeat"),d.renderRepeat(o,s,g,w))):2===e.type&&(u=Cs(f,h,[null,null,null]),o=u[0],i=u[1],Q=u[2],c=u[3],a=u[4],l=0===e.position.length?[ge]:e.position,g=Ue(l[0],c),w=Ue(l[l.length-1],a),C=function(A,e,t,r,B){var n,s,o,i,Q=0,c=0;switch(A.size){case 0:0===A.shape?Q=c=Math.min(Math.abs(e),Math.abs(e-r),Math.abs(t),Math.abs(t-B)):1===A.shape&&(Q=Math.min(Math.abs(e),Math.abs(e-r)),c=Math.min(Math.abs(t),Math.abs(t-B)));break;case 2:0===A.shape?Q=c=Math.min(Ie(e,t),Ie(e,t-B),Ie(e-r,t),Ie(e-r,t-B)):1===A.shape&&(n=Math.min(Math.abs(t),Math.abs(t-B))/Math.min(Math.abs(e),Math.abs(e-r)),o=(s=ye(r,B,e,t,!0))[0],i=s[1],c=n*(Q=Ie(o-e,(i-t)/n)));break;case 1:0===A.shape?Q=c=Math.max(Math.abs(e),Math.abs(e-r),Math.abs(t),Math.abs(t-B)):1===A.shape&&(Q=Math.max(Math.abs(e),Math.abs(e-r)),c=Math.max(Math.abs(t),Math.abs(t-B)));break;case 3:0===A.shape?Q=c=Math.max(Ie(e,t),Ie(e,t-B),Ie(e-r,t),Ie(e-r,t-B)):1===A.shape&&(n=Math.max(Math.abs(t),Math.abs(t-B))/Math.max(Math.abs(e),Math.abs(e-r)),o=(s=ye(r,B,e,t,!1))[0],i=s[1],c=n*(Q=Ie(o-e,(i-t)/n)))}return Array.isArray(A.size)&&(Q=Ue(A.size[0],r),c=2===A.size.length?Ue(A.size[1],B):Q),[Q,c]}(e,g,w,c,a),F=C[0],u=C[1],0<F&&0<u&&(U=d.ctx.createRadialGradient(i+g,Q+w,0,i+g,Q+w,F),pe(e.stops,2*F).forEach(function(A){return U.addColorStop(A.stop,ie(A.color))}),d.path(o),d.ctx.fillStyle=U,F!==u?(l=f.bounds.left+.5*f.bounds.width,C=f.bounds.top+.5*f.bounds.height,F=1/(u=u/F),d.ctx.save(),d.ctx.translate(l,C),d.ctx.transform(1,0,0,u,0,0),d.ctx.translate(-l,-C),d.ctx.fillRect(i,F*(Q-C)+C,c,a*F),d.ctx.restore()):d.ctx.fill())),A.label=6;case 6:return h--,[2]}})},d=this,t=0,r=f.styles.backgroundImage.slice(0).reverse(),A.label=1;case 1:return t<r.length?(B=r[t],[5,e(B)]):[3,4];case 2:A.sent(),A.label=3;case 3:return t++,[3,1];case 4:return[2]}})})},Ds.prototype.renderSolidBorder=function(e,t,r){return a(this,void 0,void 0,function(){return H(this,function(A){return this.path(ws(r,t)),this.ctx.fillStyle=ie(e),this.ctx.fill(),[2]})})},Ds.prototype.renderDoubleBorder=function(t,r,B,n){return a(this,void 0,void 0,function(){var e;return H(this,function(A){switch(A.label){case 0:return r<3?[4,this.renderSolidBorder(t,B,n)]:[3,2];case 1:return A.sent(),[2];case 2:return e=function(A,e){switch(e){case 0:return Hs(A.topLeftBorderBox,A.topLeftBorderDoubleOuterBox,A.topRightBorderBox,A.topRightBorderDoubleOuterBox);case 1:return Hs(A.topRightBorderBox,A.topRightBorderDoubleOuterBox,A.bottomRightBorderBox,A.bottomRightBorderDoubleOuterBox);case 2:return Hs(A.bottomRightBorderBox,A.bottomRightBorderDoubleOuterBox,A.bottomLeftBorderBox,A.bottomLeftBorderDoubleOuterBox);default:return Hs(A.bottomLeftBorderBox,A.bottomLeftBorderDoubleOuterBox,A.topLeftBorderBox,A.topLeftBorderDoubleOuterBox)}}(n,B),this.path(e),this.ctx.fillStyle=ie(t),this.ctx.fill(),e=function(A,e){switch(e){case 0:return Hs(A.topLeftBorderDoubleInnerBox,A.topLeftPaddingBox,A.topRightBorderDoubleInnerBox,A.topRightPaddingBox);case 1:return Hs(A.topRightBorderDoubleInnerBox,A.topRightPaddingBox,A.bottomRightBorderDoubleInnerBox,A.bottomRightPaddingBox);case 2:return Hs(A.bottomRightBorderDoubleInnerBox,A.bottomRightPaddingBox,A.bottomLeftBorderDoubleInnerBox,A.bottomLeftPaddingBox);default:return Hs(A.bottomLeftBorderDoubleInnerBox,A.bottomLeftPaddingBox,A.topLeftBorderDoubleInnerBox,A.topLeftPaddingBox)}}(n,B),this.path(e),this.ctx.fill(),[2]}})})},Ds.prototype.renderNodeBackgroundAndBorders=function(c){return a(this,void 0,void 0,function(){var e,t,r,B,n,s,o,i,Q=this;return H(this,function(A){switch(A.label){case 0:return(this.applyEffects(c.getEffects(2)),e=c.container.styles,t=!oe(e.backgroundColor)||e.backgroundImage.length,r=[{style:e.borderTopStyle,color:e.borderTopColor,width:e.borderTopWidth},{style:e.borderRightStyle,color:e.borderRightColor,width:e.borderRightWidth},{style:e.borderBottomStyle,color:e.borderBottomColor,width:e.borderBottomWidth},{style:e.borderLeftStyle,color:e.borderLeftColor,width:e.borderLeftWidth}],B=Ms(Es(e.backgroundClip,0),c.curves),t||e.boxShadow.length)?(this.ctx.save(),this.path(B),this.ctx.clip(),oe(e.backgroundColor)||(this.ctx.fillStyle=ie(e.backgroundColor),this.ctx.fill()),[4,this.renderBackgroundImage(c.container)]):[3,2];case 1:A.sent(),this.ctx.restore(),e.boxShadow.slice(0).reverse().forEach(function(A){Q.ctx.save();var t,r,B,n,e=ts(c.curves),s=A.inset?0:1e4,o=(t=-s+(A.inset?1:-1)*A.spread.number,r=(A.inset?1:-1)*A.spread.number,B=A.spread.number*(A.inset?-2:2),n=A.spread.number*(A.inset?-2:2),e.map(function(A,e){switch(e){case 0:return A.add(t,r);case 1:return A.add(t+B,r);case 2:return A.add(t+B,r+n);case 3:return A.add(t,r+n)}return A}));A.inset?(Q.path(e),Q.ctx.clip(),Q.mask(o)):(Q.mask(e),Q.ctx.clip(),Q.path(o)),Q.ctx.shadowOffsetX=A.offsetX.number+s,Q.ctx.shadowOffsetY=A.offsetY.number,Q.ctx.shadowColor=ie(A.color),Q.ctx.shadowBlur=A.blur.number,Q.ctx.fillStyle=A.inset?ie(A.color):"rgba(0,0,0,1)",Q.ctx.fill(),Q.ctx.restore()}),A.label=2;case 2:s=n=0,o=r,A.label=3;case 3:return s<o.length?0!==(i=o[s]).style&&!oe(i.color)&&0<i.width?2!==i.style?[3,5]:[4,this.renderDashedDottedBorder(i.color,i.width,n,c.curves,2)]:[3,11]:[3,13];case 4:return A.sent(),[3,11];case 5:return 3!==i.style?[3,7]:[4,this.renderDashedDottedBorder(i.color,i.width,n,c.curves,3)];case 6:return A.sent(),[3,11];case 7:return 4!==i.style?[3,9]:[4,this.renderDoubleBorder(i.color,i.width,n,c.curves)];case 8:return A.sent(),[3,11];case 9:return[4,this.renderSolidBorder(i.color,n,c.curves)];case 10:A.sent(),A.label=11;case 11:n++,A.label=12;case 12:return s++,[3,3];case 13:return[2]}})})},Ds.prototype.renderDashedDottedBorder=function(g,w,U,l,C){return a(this,void 0,void 0,function(){var e,t,r,B,n,s,o,i,Q,c,a;return H(this,function(A){return this.ctx.save(),Q=function(A,e){switch(e){case 0:return fs(A.topLeftBorderStroke,A.topRightBorderStroke);case 1:return fs(A.topRightBorderStroke,A.bottomRightBorderStroke);case 2:return fs(A.bottomRightBorderStroke,A.bottomLeftBorderStroke);default:return fs(A.bottomLeftBorderStroke,A.topLeftBorderStroke)}}(l,U),e=ws(l,U),2===C&&(this.path(e),this.ctx.clip()),s=$n(e[0])?(t=e[0].start.x,e[0].start.y):(t=e[0].x,e[0].y),o=$n(e[1])?(r=e[1].end.x,e[1].end.y):(r=e[1].x,e[1].y),B=0===U||2===U?Math.abs(t-r):Math.abs(s-o),this.ctx.beginPath(),3===C?this.formatPath(Q):this.formatPath(e.slice(0,2)),n=w<3?3*w:2*w,s=w<3?2*w:w,3===C&&(s=n=w),o=!0,B<=2*n?o=!1:B<=2*n+s?(n*=i=B/(2*n+s),s*=i):(Q=Math.floor((B+s)/(n+s)),i=(B-Q*n)/(Q-1),s=(Q=(B-(Q+1)*n)/Q)<=0||Math.abs(s-i)<Math.abs(s-Q)?i:Q),o&&(3===C?this.ctx.setLineDash([0,n+s]):this.ctx.setLineDash([n,s])),3===C?(this.ctx.lineCap="round",this.ctx.lineWidth=w):this.ctx.lineWidth=2*w+1.1,this.ctx.strokeStyle=ie(g),this.ctx.stroke(),this.ctx.setLineDash([]),2===C&&($n(e[0])&&(c=e[3],a=e[0],this.ctx.beginPath(),this.formatPath([new Zn(c.end.x,c.end.y),new Zn(a.start.x,a.start.y)]),this.ctx.stroke()),$n(e[1])&&(c=e[1],a=e[2],this.ctx.beginPath(),this.formatPath([new Zn(c.end.x,c.end.y),new Zn(a.start.x,a.start.y)]),this.ctx.stroke())),this.ctx.restore(),[2]})})},Ds.prototype.render=function(B){return a(this,void 0,void 0,function(){return H(this,function(A){switch(A.label){case 0:return this.options.backgroundColor&&(this.ctx.fillStyle=ie(this.options.backgroundColor),this.ctx.fillRect(this.options.x,this.options.y,this.options.width,this.options.height)),t=new as(e=B,null),r=new cs(t),hs(t,r,r,e=[]),ds(t.container,e),[4,this.renderStack(r)];case 1:return A.sent(),this.applyEffects([]),[2,this.canvas]}var e,t,r})})},Ds);function Ds(A,e){A=Ls.call(this,A,e)||this;return A._activeEffects=[],A.canvas=e.canvas||document.createElement("canvas"),A.ctx=A.canvas.getContext("2d"),e.canvas||(A.canvas.width=Math.floor(e.width*e.scale),A.canvas.height=Math.floor(e.height*e.scale),A.canvas.style.width=e.width+"px",A.canvas.style.height=e.height+"px"),A.fontMetrics=new Ks(document),A.ctx.scale(A.options.scale,A.options.scale),A.ctx.translate(-e.x,-e.y),A.ctx.textBaseline="bottom",A._activeEffects=[],A.context.logger.debug("Canvas renderer initialized ("+e.width+"x"+e.height+") with scale "+e.scale),A}var vs,xs=function(A){return A instanceof LB||(A instanceof yB||A instanceof pB&&A.type!==dB&&A.type!==hB)},Ms=function(A,e){switch(A){case 0:return ts(e);case 2:return[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox];default:return rs(e)}},Ss=function(A){switch(A){case 1:return"center";case 2:return"right";default:return"left"}},Ts=["-apple-system","system-ui"],Gs=function(A){return/iPhone OS 15_(0|1)/.test(window.navigator.userAgent)?A.filter(function(A){return-1===Ts.indexOf(A)}):A},Os=(A(Vs,vs=he),Vs.prototype.render=function(t){return a(this,void 0,void 0,function(){var e;return H(this,function(A){switch(A.label){case 0:return e=Nr(this.options.width*this.options.scale,this.options.height*this.options.scale,this.options.scale,this.options.scale,t),[4,ks(e)];case 1:return e=A.sent(),this.options.backgroundColor&&(this.ctx.fillStyle=ie(this.options.backgroundColor),this.ctx.fillRect(0,0,this.options.width*this.options.scale,this.options.height*this.options.scale)),this.ctx.drawImage(e,-this.options.x*this.options.scale,-this.options.y*this.options.scale),[2,this.canvas]}})})},Vs);function Vs(A,e){A=vs.call(this,A,e)||this;return A.canvas=e.canvas||document.createElement("canvas"),A.ctx=A.canvas.getContext("2d"),A.options=e,A.canvas.width=Math.floor(e.width*e.scale),A.canvas.height=Math.floor(e.height*e.scale),A.canvas.style.width=e.width+"px",A.canvas.style.height=e.height+"px",A.ctx.scale(A.options.scale,A.options.scale),A.ctx.translate(-e.x,-e.y),A.context.logger.debug("EXPERIMENTAL ForeignObject renderer initialized ("+e.width+"x"+e.height+" at "+e.x+","+e.y+") with scale "+e.scale),A}var ks=function(r){return new Promise(function(A,e){var t=new Image;t.onload=function(){A(t)},t.onerror=e,t.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(r))})},Rs=(Ns.prototype.debug=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.debug?console.debug.apply(console,t([this.id,this.getTime()+"ms"],A)):this.info.apply(this,A))},Ns.prototype.getTime=function(){return Date.now()-this.start},Ns.prototype.info=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];this.enabled&&"undefined"!=typeof window&&window.console&&"function"==typeof console.info&&console.info.apply(console,t([this.id,this.getTime()+"ms"],A))},Ns.prototype.warn=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.warn?console.warn.apply(console,t([this.id,this.getTime()+"ms"],A)):this.info.apply(this,A))},Ns.prototype.error=function(){for(var A=[],e=0;e<arguments.length;e++)A[e]=arguments[e];this.enabled&&("undefined"!=typeof window&&window.console&&"function"==typeof console.error?console.error.apply(console,t([this.id,this.getTime()+"ms"],A)):this.info.apply(this,A))},Ns.instances={},Ns);function Ns(A){var e=A.id,A=A.enabled;this.id=e,this.enabled=A,this.start=Date.now()}var Ps=(Xs.instanceCount=1,Xs);function Xs(A,e){this.windowBounds=e,this.instanceName="#"+Xs.instanceCount++,this.logger=new Rs({id:this.instanceName,enabled:A.logging}),this.cache=null!==(e=A.cache)&&void 0!==e?e:new On(this,A)}"undefined"!=typeof window&&Tn.setContext(window);var Js=function(u,F){return a(void 0,void 0,void 0,function(){var e,t,r,B,n,s,o,i,Q,c,a,g,w,U,l,C;return H(this,function(A){switch(A.label){case 0:if(!u||"object"!=typeof u)return[2,Promise.reject("Invalid element provided as first argument")];if(!(e=u.ownerDocument))throw new Error("Element is not attached to a Document");if(!(t=e.defaultView))throw new Error("Document is not attached to a Window");return w={allowTaint:null!==(U=F.allowTaint)&&void 0!==U&&U,imageTimeout:null!==(c=F.imageTimeout)&&void 0!==c?c:15e3,proxy:F.proxy,useCORS:null!==(a=F.useCORS)&&void 0!==a&&a},U=h({logging:null===(g=F.logging)||void 0===g||g,cache:F.cache},w),c={windowWidth:null!==(c=F.windowWidth)&&void 0!==c?c:t.innerWidth,windowHeight:null!==(a=F.windowHeight)&&void 0!==a?a:t.innerHeight,scrollX:null!==(g=F.scrollX)&&void 0!==g?g:t.pageXOffset,scrollY:null!==(w=F.scrollY)&&void 0!==w?w:t.pageYOffset},a=new d(c.scrollX,c.scrollY,c.windowWidth,c.windowHeight),g=new Ps(U,a),c=null!==(w=F.foreignObjectRendering)&&void 0!==w&&w,w={allowTaint:null!==(U=F.allowTaint)&&void 0!==U&&U,onclone:F.onclone,ignoreElements:F.ignoreElements,inlineImages:c,copyStyles:c},g.logger.debug("Starting document clone with size "+a.width+"x"+a.height+" scrolled to "+-a.left+","+-a.top),U=new dn(g,u,w),(w=U.clonedReferenceElement)?[4,U.toIFrame(e,a)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return(r=A.sent(),l=jB(w)||"HTML"===w.tagName?function(A){var e=A.body,t=A.documentElement;if(!e||!t)throw new Error("Unable to get document size");A=Math.max(Math.max(e.scrollWidth,t.scrollWidth),Math.max(e.offsetWidth,t.offsetWidth),Math.max(e.clientWidth,t.clientWidth)),t=Math.max(Math.max(e.scrollHeight,t.scrollHeight),Math.max(e.offsetHeight,t.offsetHeight),Math.max(e.clientHeight,t.clientHeight));return new d(0,0,A,t)}(w.ownerDocument):f(g,w),B=l.width,n=l.height,s=l.left,o=l.top,i=Ys(g,w,F.backgroundColor),l={canvas:F.canvas,backgroundColor:i,scale:null!==(l=null!==(l=F.scale)&&void 0!==l?l:t.devicePixelRatio)&&void 0!==l?l:1,x:(null!==(l=F.x)&&void 0!==l?l:0)+s,y:(null!==(l=F.y)&&void 0!==l?l:0)+o,width:null!==(l=F.width)&&void 0!==l?l:Math.ceil(B),height:null!==(l=F.height)&&void 0!==l?l:Math.ceil(n)},c)?(g.logger.debug("Document cloned, using foreign object rendering"),[4,new Os(g,l).render(w)]):[3,3];case 2:return Q=A.sent(),[3,5];case 3:return g.logger.debug("Document cloned, element located at "+s+","+o+" with size "+B+"x"+n+" using computed rendering"),g.logger.debug("Starting DOM parsing"),C=kB(g,w),i===C.styles.backgroundColor&&(C.styles.backgroundColor=Le.TRANSPARENT),g.logger.debug("Starting renderer for element at "+l.x+","+l.y+" with size "+l.width+"x"+l.height),[4,new bs(g,l).render(C)];case 4:Q=A.sent(),A.label=5;case 5:return null!==(C=F.removeContainer)&&void 0!==C&&!C||dn.destroy(r)||g.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore"),g.logger.debug("Finished rendering"),[2,Q]}})})},Ys=function(A,e,t){var r=e.ownerDocument,B=r.documentElement?fe(A,getComputedStyle(r.documentElement).backgroundColor):Le.TRANSPARENT,n=r.body?fe(A,getComputedStyle(r.body).backgroundColor):Le.TRANSPARENT,t="string"==typeof t?fe(A,t):null===t?Le.TRANSPARENT:4294967295;return e===r.documentElement?oe(B)?oe(n)?t:n:B:t};return function(A,e){return Js(A,e=void 0===e?{}:e)}});
\ No newline at end of file