@page-agent/page-controller 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,3 @@
1
- import { Motion } from 'ai-motion';
2
-
3
1
  declare interface ActionResult {
4
2
  success: boolean;
5
3
  message: string;
@@ -141,7 +139,12 @@ export declare class PageController extends EventTarget {
141
139
  private lastTimeUpdate;
142
140
  /** Visual mask overlay for blocking user interaction during automation */
143
141
  private mask;
142
+ private maskReady;
144
143
  constructor(config?: PageControllerConfig);
144
+ /**
145
+ * Initialize mask asynchronously (dynamic import to avoid CSS loading in Node)
146
+ */
147
+ private initMask;
145
148
  /**
146
149
  * Get current page URL
147
150
  */
@@ -202,12 +205,12 @@ export declare class PageController extends EventTarget {
202
205
  * Show the visual mask overlay.
203
206
  * Only works if enableMask was set to true in config.
204
207
  */
205
- showMask(): void;
208
+ showMask(): Promise<void>;
206
209
  /**
207
210
  * Hide the visual mask overlay.
208
211
  * Only works if enableMask was set to true in config.
209
212
  */
210
- hideMask(): void;
213
+ hideMask(): Promise<void>;
211
214
  /**
212
215
  * Dispose and clean up resources
213
216
  */
@@ -223,18 +226,6 @@ export declare interface PageControllerConfig extends dom.DomConfig {
223
226
  enableMask?: boolean;
224
227
  }
225
228
 
226
- export declare class SimulatorMask {
227
- #private;
228
- wrapper: HTMLDivElement;
229
- motion: Motion;
230
- constructor();
231
- setCursorPosition(x: number, y: number): void;
232
- triggerClickAnimation(): void;
233
- show(): void;
234
- hide(): void;
235
- dispose(): void;
236
- }
237
-
238
229
  declare interface TextDomNode {
239
230
  type: 'TEXT_NODE';
240
231
  text: string;
@@ -0,0 +1,251 @@
1
+ (function() {
2
+ "use strict";
3
+ try {
4
+ if (typeof document != "undefined") {
5
+ var elementStyle = document.createElement("style");
6
+ elementStyle.appendChild(document.createTextNode("._wrapper_1oy2s_1 {\n position: fixed;\n inset: 0;\n z-index: 2147483641; /* 确保在所有元素之上,除了 panel */\n /* pointer-events: none; */\n cursor: not-allowed;\n overflow: hidden;\n\n display: none;\n}\n/* AI 光标样式 */\n._cursor_1vrf3_2 {\n position: absolute;\n width: var(--cursor-size, 75px);\n height: var(--cursor-size, 75px);\n pointer-events: none;\n z-index: 10000;\n transform: translate(-30%, -30%);\n\n animation: _cursor-enter_1vrf3_1 300ms ease-out forwards;\n}\n\n._cursorBorder_1vrf3_13 {\n position: absolute;\n inset: 0;\n background: linear-gradient(45deg, rgb(57, 182, 255), rgb(189, 69, 251));\n mask-image: url(https://img.alicdn.com/imgextra/i1/O1CN01YHLVYR1LvqWIyo5kH_!!6000000001362-2-tps-202-202.png);\n mask-size: 100% 100%;\n mask-repeat: no-repeat;\n animation: _cursor-breathe_1vrf3_1 2s ease-in-out infinite;\n}\n\n._cursorFilling_1vrf3_23 {\n position: absolute;\n inset: 0;\n background: url(https://img.alicdn.com/imgextra/i3/O1CN01JZOqOS1Tu1sIKbPLW_!!6000000002441-2-tps-202-202.png);\n background-size: 100% 100%;\n background-repeat: no-repeat;\n}\n\n._cursorRipple_1vrf3_31 {\n position: absolute;\n inset: 0;\n pointer-events: none;\n}\n\n._cursor_1vrf3_2._clicking_1vrf3_37 ._cursorRipple_1vrf3_31::after {\n content: '';\n position: absolute;\n width: 100%;\n height: 100%;\n left: -30%;\n top: -30%;\n border: 4px solid rgba(57, 182, 255, 1);\n border-radius: 50%;\n animation: _cursor-ripple_1vrf3_1 300ms ease-out forwards;\n}\n\n/* 光标动画关键帧 */\n@keyframes _cursor-breathe_1vrf3_1 {\n 0%,\n 100% {\n transform: scale(1);\n opacity: 0.9;\n }\n 50% {\n transform: scale(1.05);\n opacity: 1;\n }\n}\n\n@keyframes _cursor-rotate_1vrf3_1 {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\n@keyframes _cursor-enter_1vrf3_1 {\n 0% {\n transform: translate(-30%, -30%) scale(0.5);\n opacity: 0;\n }\n 100% {\n transform: translate(-30%, -30%) scale(1);\n opacity: 1;\n }\n}\n\n@keyframes _cursor-ripple_1vrf3_1 {\n 0% {\n transform: scale(0);\n opacity: 1;\n }\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n}"));
7
+ document.head.appendChild(elementStyle);
8
+ }
9
+ } catch (e) {
10
+ console.error("vite-plugin-css-injected-by-js", e);
11
+ }
12
+ })();
13
+ var __defProp = Object.defineProperty;
14
+ var __typeError = (msg) => {
15
+ throw TypeError(msg);
16
+ };
17
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
18
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
19
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
20
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
21
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
22
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
23
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
24
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
25
+ var _cursor, _currentCursorX, _currentCursorY, _targetCursorX, _targetCursorY, _SimulatorMask_instances, createCursor_fn, moveCursorToTarget_fn;
26
+ import { Motion } from "ai-motion";
27
+ function hasDarkModeClass() {
28
+ const DEFAULT_DARK_MODE_CLASSES = ["dark", "dark-mode", "theme-dark", "night", "night-mode"];
29
+ const htmlElement = document.documentElement;
30
+ const bodyElement = document.body || document.documentElement;
31
+ for (const className of DEFAULT_DARK_MODE_CLASSES) {
32
+ if (htmlElement.classList.contains(className) || bodyElement?.classList.contains(className)) {
33
+ return true;
34
+ }
35
+ }
36
+ const darkThemeAttribute = htmlElement.getAttribute("data-theme");
37
+ if (darkThemeAttribute?.toLowerCase().includes("dark")) {
38
+ return true;
39
+ }
40
+ return false;
41
+ }
42
+ __name(hasDarkModeClass, "hasDarkModeClass");
43
+ function parseRgbColor(colorString) {
44
+ const rgbMatch = /rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(colorString);
45
+ if (!rgbMatch) {
46
+ return null;
47
+ }
48
+ return {
49
+ r: parseInt(rgbMatch[1]),
50
+ g: parseInt(rgbMatch[2]),
51
+ b: parseInt(rgbMatch[3])
52
+ };
53
+ }
54
+ __name(parseRgbColor, "parseRgbColor");
55
+ function isColorDark(colorString, threshold = 128) {
56
+ if (!colorString || colorString === "transparent" || colorString.startsWith("rgba(0, 0, 0, 0)")) {
57
+ return false;
58
+ }
59
+ const rgb = parseRgbColor(colorString);
60
+ if (!rgb) {
61
+ return false;
62
+ }
63
+ const luminance = 0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b;
64
+ return luminance < threshold;
65
+ }
66
+ __name(isColorDark, "isColorDark");
67
+ function isBackgroundDark() {
68
+ const htmlStyle = window.getComputedStyle(document.documentElement);
69
+ const bodyStyle = window.getComputedStyle(document.body || document.documentElement);
70
+ const htmlBgColor = htmlStyle.backgroundColor;
71
+ const bodyBgColor = bodyStyle.backgroundColor;
72
+ if (isColorDark(bodyBgColor)) {
73
+ return true;
74
+ } else if (bodyBgColor === "transparent" || bodyBgColor.startsWith("rgba(0, 0, 0, 0)")) {
75
+ return isColorDark(htmlBgColor);
76
+ }
77
+ return false;
78
+ }
79
+ __name(isBackgroundDark, "isBackgroundDark");
80
+ function isPageDark() {
81
+ try {
82
+ if (hasDarkModeClass()) {
83
+ return true;
84
+ }
85
+ if (isBackgroundDark()) {
86
+ return true;
87
+ }
88
+ return false;
89
+ } catch (error) {
90
+ console.warn("Error determining if page is dark:", error);
91
+ return false;
92
+ }
93
+ }
94
+ __name(isPageDark, "isPageDark");
95
+ const wrapper = "_wrapper_1oy2s_1";
96
+ const styles = {
97
+ wrapper
98
+ };
99
+ const cursor = "_cursor_1vrf3_2";
100
+ const cursorBorder = "_cursorBorder_1vrf3_13";
101
+ const cursorFilling = "_cursorFilling_1vrf3_23";
102
+ const cursorRipple = "_cursorRipple_1vrf3_31";
103
+ const clicking = "_clicking_1vrf3_37";
104
+ const cursorStyles = {
105
+ cursor,
106
+ cursorBorder,
107
+ cursorFilling,
108
+ cursorRipple,
109
+ clicking
110
+ };
111
+ const _SimulatorMask = class _SimulatorMask {
112
+ constructor() {
113
+ __privateAdd(this, _SimulatorMask_instances);
114
+ __publicField(this, "wrapper", document.createElement("div"));
115
+ __publicField(this, "motion", new Motion({
116
+ mode: isPageDark() ? "dark" : "light",
117
+ styles: {
118
+ position: "absolute",
119
+ inset: "0"
120
+ }
121
+ }));
122
+ __privateAdd(this, _cursor, document.createElement("div"));
123
+ __privateAdd(this, _currentCursorX, 0);
124
+ __privateAdd(this, _currentCursorY, 0);
125
+ __privateAdd(this, _targetCursorX, 0);
126
+ __privateAdd(this, _targetCursorY, 0);
127
+ this.wrapper.id = "page-agent-runtime_simulator-mask";
128
+ this.wrapper.className = styles.wrapper;
129
+ this.wrapper.setAttribute("data-browser-use-ignore", "true");
130
+ this.wrapper.appendChild(this.motion.element);
131
+ this.motion.autoResize(this.wrapper);
132
+ this.wrapper.addEventListener("click", (e) => {
133
+ e.stopPropagation();
134
+ e.preventDefault();
135
+ });
136
+ this.wrapper.addEventListener("mousedown", (e) => {
137
+ e.stopPropagation();
138
+ e.preventDefault();
139
+ });
140
+ this.wrapper.addEventListener("mouseup", (e) => {
141
+ e.stopPropagation();
142
+ e.preventDefault();
143
+ });
144
+ this.wrapper.addEventListener("mousemove", (e) => {
145
+ e.stopPropagation();
146
+ e.preventDefault();
147
+ });
148
+ this.wrapper.addEventListener("wheel", (e) => {
149
+ e.stopPropagation();
150
+ e.preventDefault();
151
+ });
152
+ this.wrapper.addEventListener("keydown", (e) => {
153
+ e.stopPropagation();
154
+ e.preventDefault();
155
+ });
156
+ this.wrapper.addEventListener("keyup", (e) => {
157
+ e.stopPropagation();
158
+ e.preventDefault();
159
+ });
160
+ __privateMethod(this, _SimulatorMask_instances, createCursor_fn).call(this);
161
+ document.body.appendChild(this.wrapper);
162
+ __privateMethod(this, _SimulatorMask_instances, moveCursorToTarget_fn).call(this);
163
+ window.addEventListener("PageAgent::MovePointerTo", (event) => {
164
+ const { x, y } = event.detail;
165
+ this.setCursorPosition(x, y);
166
+ });
167
+ window.addEventListener("PageAgent::ClickPointer", (event) => {
168
+ this.triggerClickAnimation();
169
+ });
170
+ }
171
+ setCursorPosition(x, y) {
172
+ __privateSet(this, _targetCursorX, x);
173
+ __privateSet(this, _targetCursorY, y);
174
+ }
175
+ triggerClickAnimation() {
176
+ __privateGet(this, _cursor).classList.remove(cursorStyles.clicking);
177
+ void __privateGet(this, _cursor).offsetHeight;
178
+ __privateGet(this, _cursor).classList.add(cursorStyles.clicking);
179
+ }
180
+ show() {
181
+ this.motion.start();
182
+ this.motion.fadeIn();
183
+ this.wrapper.style.display = "block";
184
+ __privateSet(this, _currentCursorX, window.innerWidth / 2);
185
+ __privateSet(this, _currentCursorY, window.innerHeight / 2);
186
+ __privateSet(this, _targetCursorX, __privateGet(this, _currentCursorX));
187
+ __privateSet(this, _targetCursorY, __privateGet(this, _currentCursorY));
188
+ __privateGet(this, _cursor).style.left = `${__privateGet(this, _currentCursorX)}px`;
189
+ __privateGet(this, _cursor).style.top = `${__privateGet(this, _currentCursorY)}px`;
190
+ }
191
+ hide() {
192
+ this.motion.fadeOut();
193
+ this.motion.pause();
194
+ __privateGet(this, _cursor).classList.remove(cursorStyles.clicking);
195
+ setTimeout(() => {
196
+ this.wrapper.style.display = "none";
197
+ }, 800);
198
+ }
199
+ dispose() {
200
+ this.motion.dispose();
201
+ this.wrapper.remove();
202
+ }
203
+ };
204
+ _cursor = new WeakMap();
205
+ _currentCursorX = new WeakMap();
206
+ _currentCursorY = new WeakMap();
207
+ _targetCursorX = new WeakMap();
208
+ _targetCursorY = new WeakMap();
209
+ _SimulatorMask_instances = new WeakSet();
210
+ createCursor_fn = /* @__PURE__ */ __name(function() {
211
+ __privateGet(this, _cursor).className = cursorStyles.cursor;
212
+ const rippleContainer = document.createElement("div");
213
+ rippleContainer.className = cursorStyles.cursorRipple;
214
+ __privateGet(this, _cursor).appendChild(rippleContainer);
215
+ const fillingLayer = document.createElement("div");
216
+ fillingLayer.className = cursorStyles.cursorFilling;
217
+ __privateGet(this, _cursor).appendChild(fillingLayer);
218
+ const borderLayer = document.createElement("div");
219
+ borderLayer.className = cursorStyles.cursorBorder;
220
+ __privateGet(this, _cursor).appendChild(borderLayer);
221
+ this.wrapper.appendChild(__privateGet(this, _cursor));
222
+ }, "#createCursor");
223
+ moveCursorToTarget_fn = /* @__PURE__ */ __name(function() {
224
+ const newX = __privateGet(this, _currentCursorX) + (__privateGet(this, _targetCursorX) - __privateGet(this, _currentCursorX)) * 0.2;
225
+ const newY = __privateGet(this, _currentCursorY) + (__privateGet(this, _targetCursorY) - __privateGet(this, _currentCursorY)) * 0.2;
226
+ const xDistance = Math.abs(newX - __privateGet(this, _targetCursorX));
227
+ if (xDistance > 0) {
228
+ if (xDistance < 2) {
229
+ __privateSet(this, _currentCursorX, __privateGet(this, _targetCursorX));
230
+ } else {
231
+ __privateSet(this, _currentCursorX, newX);
232
+ }
233
+ __privateGet(this, _cursor).style.left = `${__privateGet(this, _currentCursorX)}px`;
234
+ }
235
+ const yDistance = Math.abs(newY - __privateGet(this, _targetCursorY));
236
+ if (yDistance > 0) {
237
+ if (yDistance < 2) {
238
+ __privateSet(this, _currentCursorY, __privateGet(this, _targetCursorY));
239
+ } else {
240
+ __privateSet(this, _currentCursorY, newY);
241
+ }
242
+ __privateGet(this, _cursor).style.top = `${__privateGet(this, _currentCursorY)}px`;
243
+ }
244
+ requestAnimationFrame(() => __privateMethod(this, _SimulatorMask_instances, moveCursorToTarget_fn).call(this));
245
+ }, "#moveCursorToTarget");
246
+ __name(_SimulatorMask, "SimulatorMask");
247
+ let SimulatorMask = _SimulatorMask;
248
+ export {
249
+ SimulatorMask
250
+ };
251
+ //# sourceMappingURL=SimulatorMask-BiVNIB3r.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimulatorMask-BiVNIB3r.js","sources":["../../src/mask/checkDarkMode.ts","../../src/mask/SimulatorMask.ts"],"sourcesContent":["/**\n * Checks for common dark mode CSS classes on the html or body elements.\n * @returns {boolean} - True if a common dark mode class is found.\n */\nfunction hasDarkModeClass() {\n\tconst DEFAULT_DARK_MODE_CLASSES = ['dark', 'dark-mode', 'theme-dark', 'night', 'night-mode']\n\n\tconst htmlElement = document.documentElement\n\tconst bodyElement = document.body || document.documentElement // can be null in some cases\n\n\t// Check class names on <html> and <body>\n\tfor (const className of DEFAULT_DARK_MODE_CLASSES) {\n\t\tif (htmlElement.classList.contains(className) || bodyElement?.classList.contains(className)) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\t// Some sites use data attributes\n\tconst darkThemeAttribute = htmlElement.getAttribute('data-theme')\n\tif (darkThemeAttribute?.toLowerCase().includes('dark')) {\n\t\treturn true\n\t}\n\n\treturn false\n}\n\n/**\n * Parses an RGB or RGBA color string and returns an object with r, g, b properties.\n * @param {string} colorString - e.g., \"rgb(34, 34, 34)\" or \"rgba(0, 0, 0, 0.5)\"\n * @returns {{r: number, g: number, b: number}|null}\n */\nfunction parseRgbColor(colorString: string) {\n\tconst rgbMatch = /rgba?\\((\\d+),\\s*(\\d+),\\s*(\\d+)/.exec(colorString)\n\tif (!rgbMatch) {\n\t\treturn null // Not a valid rgb/rgba string\n\t}\n\treturn {\n\t\tr: parseInt(rgbMatch[1]),\n\t\tg: parseInt(rgbMatch[2]),\n\t\tb: parseInt(rgbMatch[3]),\n\t}\n}\n\n/**\n * Determines if a color is \"dark\" based on its calculated luminance.\n * @param {string} colorString - The CSS color string (e.g., \"rgb(50, 50, 50)\").\n * @param {number} threshold - A value between 0 and 255. Colors with luminance below this will be considered dark. Default is 128.\n * @returns {boolean} - True if the color is considered dark.\n */\nfunction isColorDark(colorString: string, threshold = 128) {\n\tif (!colorString || colorString === 'transparent' || colorString.startsWith('rgba(0, 0, 0, 0)')) {\n\t\treturn false // Transparent is not dark\n\t}\n\n\tconst rgb = parseRgbColor(colorString)\n\tif (!rgb) {\n\t\treturn false // Could not parse color\n\t}\n\n\t// Calculate perceived luminance using the standard formula\n\tconst luminance = 0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b\n\n\treturn luminance < threshold\n}\n\n/**\n * Checks the background color of the body element to determine if the page is dark.\n * @returns {boolean}\n */\nfunction isBackgroundDark() {\n\t// We check both <html> and <body> because some pages set the color on <html>\n\tconst htmlStyle = window.getComputedStyle(document.documentElement)\n\tconst bodyStyle = window.getComputedStyle(document.body || document.documentElement)\n\n\t// Get background colors\n\tconst htmlBgColor = htmlStyle.backgroundColor\n\tconst bodyBgColor = bodyStyle.backgroundColor\n\n\t// The body's background might be transparent, in which case we should\n\t// fall back to the html element's background.\n\tif (isColorDark(bodyBgColor)) {\n\t\treturn true\n\t} else if (bodyBgColor === 'transparent' || bodyBgColor.startsWith('rgba(0, 0, 0, 0)')) {\n\t\treturn isColorDark(htmlBgColor)\n\t}\n\n\treturn false\n}\n\n/**\n * A comprehensive function to determine if the page is currently in a dark theme.\n * It combines class checking and background color analysis.\n * @returns {boolean} - True if the page is likely dark.\n */\nexport function isPageDark() {\n\ttry {\n\t\t// Strategy 1: Check for common dark mode classes\n\t\tif (hasDarkModeClass()) {\n\t\t\treturn true\n\t\t}\n\n\t\t// Strategy 2: Analyze the computed background color\n\t\tif (isBackgroundDark()) {\n\t\t\treturn true\n\t\t}\n\n\t\t// @TODO add more checks here, e.g., analyzing text color,\n\t\t// or checking the background of major layout elements like <main> or #app.\n\n\t\treturn false\n\t} catch (error) {\n\t\tconsole.warn('Error determining if page is dark:', error)\n\t\treturn false\n\t}\n}\n","import { Motion } from 'ai-motion'\n\nimport { isPageDark } from './checkDarkMode'\n\nimport styles from './SimulatorMask.module.css'\nimport cursorStyles from './cursor.module.css'\n\nexport class SimulatorMask {\n\twrapper = document.createElement('div')\n\tmotion = new Motion({\n\t\tmode: isPageDark() ? 'dark' : 'light',\n\t\tstyles: {\n\t\t\tposition: 'absolute',\n\t\t\tinset: '0',\n\t\t},\n\t})\n\n\t#cursor = document.createElement('div')\n\n\t#currentCursorX = 0\n\t#currentCursorY = 0\n\n\t#targetCursorX = 0\n\t#targetCursorY = 0\n\n\tconstructor() {\n\t\tthis.wrapper.id = 'page-agent-runtime_simulator-mask'\n\t\tthis.wrapper.className = styles.wrapper\n\t\tthis.wrapper.setAttribute('data-browser-use-ignore', 'true')\n\n\t\tthis.wrapper.appendChild(this.motion.element)\n\t\tthis.motion.autoResize(this.wrapper)\n\n\t\t// Capture all mouse, keyboard, and wheel events\n\t\tthis.wrapper.addEventListener('click', (e) => {\n\t\t\te.stopPropagation()\n\t\t\te.preventDefault()\n\t\t})\n\t\tthis.wrapper.addEventListener('mousedown', (e) => {\n\t\t\te.stopPropagation()\n\t\t\te.preventDefault()\n\t\t})\n\t\tthis.wrapper.addEventListener('mouseup', (e) => {\n\t\t\te.stopPropagation()\n\t\t\te.preventDefault()\n\t\t})\n\t\tthis.wrapper.addEventListener('mousemove', (e) => {\n\t\t\te.stopPropagation()\n\t\t\te.preventDefault()\n\t\t})\n\t\tthis.wrapper.addEventListener('wheel', (e) => {\n\t\t\te.stopPropagation()\n\t\t\te.preventDefault()\n\t\t})\n\t\tthis.wrapper.addEventListener('keydown', (e) => {\n\t\t\te.stopPropagation()\n\t\t\te.preventDefault()\n\t\t})\n\t\tthis.wrapper.addEventListener('keyup', (e) => {\n\t\t\te.stopPropagation()\n\t\t\te.preventDefault()\n\t\t})\n\n\t\t// Create AI cursor\n\t\tthis.#createCursor()\n\t\t// this.show()\n\n\t\tdocument.body.appendChild(this.wrapper)\n\n\t\tthis.#moveCursorToTarget()\n\n\t\twindow.addEventListener('PageAgent::MovePointerTo', (event: Event) => {\n\t\t\tconst { x, y } = (event as CustomEvent).detail\n\t\t\tthis.setCursorPosition(x, y)\n\t\t})\n\n\t\twindow.addEventListener('PageAgent::ClickPointer', (event: Event) => {\n\t\t\tthis.triggerClickAnimation()\n\t\t})\n\t}\n\n\t#createCursor() {\n\t\tthis.#cursor.className = cursorStyles.cursor\n\n\t\t// Create ripple effect container\n\t\tconst rippleContainer = document.createElement('div')\n\t\trippleContainer.className = cursorStyles.cursorRipple\n\t\tthis.#cursor.appendChild(rippleContainer)\n\n\t\t// Create filling layer\n\t\tconst fillingLayer = document.createElement('div')\n\t\tfillingLayer.className = cursorStyles.cursorFilling\n\t\tthis.#cursor.appendChild(fillingLayer)\n\n\t\t// Create border layer\n\t\tconst borderLayer = document.createElement('div')\n\t\tborderLayer.className = cursorStyles.cursorBorder\n\t\tthis.#cursor.appendChild(borderLayer)\n\n\t\tthis.wrapper.appendChild(this.#cursor)\n\t}\n\n\t#moveCursorToTarget() {\n\t\tconst newX = this.#currentCursorX + (this.#targetCursorX - this.#currentCursorX) * 0.2\n\t\tconst newY = this.#currentCursorY + (this.#targetCursorY - this.#currentCursorY) * 0.2\n\n\t\tconst xDistance = Math.abs(newX - this.#targetCursorX)\n\t\tif (xDistance > 0) {\n\t\t\tif (xDistance < 2) {\n\t\t\t\tthis.#currentCursorX = this.#targetCursorX\n\t\t\t} else {\n\t\t\t\tthis.#currentCursorX = newX\n\t\t\t}\n\t\t\tthis.#cursor.style.left = `${this.#currentCursorX}px`\n\t\t}\n\n\t\tconst yDistance = Math.abs(newY - this.#targetCursorY)\n\t\tif (yDistance > 0) {\n\t\t\tif (yDistance < 2) {\n\t\t\t\tthis.#currentCursorY = this.#targetCursorY\n\t\t\t} else {\n\t\t\t\tthis.#currentCursorY = newY\n\t\t\t}\n\t\t\tthis.#cursor.style.top = `${this.#currentCursorY}px`\n\t\t}\n\n\t\trequestAnimationFrame(() => this.#moveCursorToTarget())\n\t}\n\n\tsetCursorPosition(x: number, y: number) {\n\t\tthis.#targetCursorX = x\n\t\tthis.#targetCursorY = y\n\t}\n\n\ttriggerClickAnimation() {\n\t\tthis.#cursor.classList.remove(cursorStyles.clicking)\n\t\t// Force reflow to restart animation\n\t\tvoid this.#cursor.offsetHeight\n\t\tthis.#cursor.classList.add(cursorStyles.clicking)\n\t}\n\n\tshow() {\n\t\tthis.motion.start()\n\t\tthis.motion.fadeIn()\n\n\t\tthis.wrapper.style.display = 'block'\n\n\t\t// Initialize cursor position\n\t\tthis.#currentCursorX = window.innerWidth / 2\n\t\tthis.#currentCursorY = window.innerHeight / 2\n\t\tthis.#targetCursorX = this.#currentCursorX\n\t\tthis.#targetCursorY = this.#currentCursorY\n\t\tthis.#cursor.style.left = `${this.#currentCursorX}px`\n\t\tthis.#cursor.style.top = `${this.#currentCursorY}px`\n\t}\n\n\thide() {\n\t\tthis.motion.fadeOut()\n\t\tthis.motion.pause()\n\n\t\tthis.#cursor.classList.remove(cursorStyles.clicking)\n\n\t\tsetTimeout(() => {\n\t\t\tthis.wrapper.style.display = 'none'\n\t\t}, 800) // Match the animation duration\n\t}\n\n\tdispose() {\n\t\tthis.motion.dispose()\n\t\tthis.wrapper.remove()\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,SAAS,mBAAmB;AAC3B,QAAM,4BAA4B,CAAC,QAAQ,aAAa,cAAc,SAAS,YAAY;AAE3F,QAAM,cAAc,SAAS;AAC7B,QAAM,cAAc,SAAS,QAAQ,SAAS;AAG9C,aAAW,aAAa,2BAA2B;AAClD,QAAI,YAAY,UAAU,SAAS,SAAS,KAAK,aAAa,UAAU,SAAS,SAAS,GAAG;AAC5F,aAAO;AAAA,IACR;AAAA,EACD;AAGA,QAAM,qBAAqB,YAAY,aAAa,YAAY;AAChE,MAAI,oBAAoB,YAAA,EAAc,SAAS,MAAM,GAAG;AACvD,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AApBS;AA2BT,SAAS,cAAc,aAAqB;AAC3C,QAAM,WAAW,iCAAiC,KA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AAa,YAAY,aAAa;AACtC,qBAAK,SAAQ,YAAY,YAAY;AAGrC,QAAM,cAAc,SAAS,cAAc,KAAK;AAChD,cAAY,YAAY,aAAa;AACrC,qBAAK,SAAQ,YAAY,WAAW;AAEpC,OAAK,QAAQ,YAAY,mBAAK,QAAO;AACtC,GAnBA;AAqBA,wBAAA,kCAAsB;AACrB,QAAM,OAAO,mBAAK,oBAAmB,mBAAK,kBAAiB,mBAAK,oBAAmB;AACnF,QAAM,OAAO,mBAAK,oBAAmB,mBAAK,kBAAiB,mBAAK,oBAAmB;AAEnF,QAAM,YAAY,KAAK,IAAI,OAAO,mBAAK,eAAc;AACrD,MAAI,YAAY,GAAG;AAClB,QAAI,YAAY,GAAG;AAClB,yBAAK,iBAAkB,mBAAK;AAAA,IAC7B,OAAO;AACN,yBAAK,iBAAkB;AAAA,IACxB;AACA,uBAAK,SAAQ,MAAM,OAAO,GAAG,mBAAK,gBAAe;AAAA,EAClD;AAEA,QAAM,YAAY,KAAK,IAAI,OAAO,mBAAK,eAAc;AACrD,MAAI,YAAY,GAAG;AAClB,QAAI,YAAY,GAAG;AAClB,yBAAK,iBAAkB,mBAAK;AAAA,IAC7B,OAAO;AACN,yBAAK,iBAAkB;AAAA,IACxB;AACA,uBAAK,SAAQ,MAAM,MAAM,GAAG,mBAAK,gBAAe;AAAA,EACjD;AAEA,wBAAsB,MAAM,sBAAK,iDAAL,UAA0B;AACvD,GAzBA;AA/F0B;AAApB,IAAM,gBAAN;"}
@@ -1,29 +1,5 @@
1
- (function() {
2
- "use strict";
3
- try {
4
- if (typeof document != "undefined") {
5
- var elementStyle = document.createElement("style");
6
- elementStyle.appendChild(document.createTextNode("._wrapper_1oy2s_1 {\n position: fixed;\n inset: 0;\n z-index: 2147483641; /* 确保在所有元素之上,除了 panel */\n /* pointer-events: none; */\n cursor: not-allowed;\n overflow: hidden;\n\n display: none;\n}\n/* AI 光标样式 */\n._cursor_1vrf3_2 {\n position: absolute;\n width: var(--cursor-size, 75px);\n height: var(--cursor-size, 75px);\n pointer-events: none;\n z-index: 10000;\n transform: translate(-30%, -30%);\n\n animation: _cursor-enter_1vrf3_1 300ms ease-out forwards;\n}\n\n._cursorBorder_1vrf3_13 {\n position: absolute;\n inset: 0;\n background: linear-gradient(45deg, rgb(57, 182, 255), rgb(189, 69, 251));\n mask-image: url(https://img.alicdn.com/imgextra/i1/O1CN01YHLVYR1LvqWIyo5kH_!!6000000001362-2-tps-202-202.png);\n mask-size: 100% 100%;\n mask-repeat: no-repeat;\n animation: _cursor-breathe_1vrf3_1 2s ease-in-out infinite;\n}\n\n._cursorFilling_1vrf3_23 {\n position: absolute;\n inset: 0;\n background: url(https://img.alicdn.com/imgextra/i3/O1CN01JZOqOS1Tu1sIKbPLW_!!6000000002441-2-tps-202-202.png);\n background-size: 100% 100%;\n background-repeat: no-repeat;\n}\n\n._cursorRipple_1vrf3_31 {\n position: absolute;\n inset: 0;\n pointer-events: none;\n}\n\n._cursor_1vrf3_2._clicking_1vrf3_37 ._cursorRipple_1vrf3_31::after {\n content: '';\n position: absolute;\n width: 100%;\n height: 100%;\n left: -30%;\n top: -30%;\n border: 4px solid rgba(57, 182, 255, 1);\n border-radius: 50%;\n animation: _cursor-ripple_1vrf3_1 300ms ease-out forwards;\n}\n\n/* 光标动画关键帧 */\n@keyframes _cursor-breathe_1vrf3_1 {\n 0%,\n 100% {\n transform: scale(1);\n opacity: 0.9;\n }\n 50% {\n transform: scale(1.05);\n opacity: 1;\n }\n}\n\n@keyframes _cursor-rotate_1vrf3_1 {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\n@keyframes _cursor-enter_1vrf3_1 {\n 0% {\n transform: translate(-30%, -30%) scale(0.5);\n opacity: 0;\n }\n 100% {\n transform: translate(-30%, -30%) scale(1);\n opacity: 1;\n }\n}\n\n@keyframes _cursor-ripple_1vrf3_1 {\n 0% {\n transform: scale(0);\n opacity: 1;\n }\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n}"));
7
- document.head.appendChild(elementStyle);
8
- }
9
- } catch (e) {
10
- console.error("vite-plugin-css-injected-by-js", e);
11
- }
12
- })();
13
1
  var __defProp = Object.defineProperty;
14
- var __typeError = (msg) => {
15
- throw TypeError(msg);
16
- };
17
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
18
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
19
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
20
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
21
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
22
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
23
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
24
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
25
- var _cursor, _currentCursorX, _currentCursorY, _targetCursorX, _targetCursorY, _SimulatorMask_instances, createCursor_fn, moveCursorToTarget_fn;
26
- import { Motion } from "ai-motion";
27
3
  async function waitFor(seconds) {
28
4
  await new Promise((resolve) => setTimeout(resolve, seconds * 1e3));
29
5
  }
@@ -1723,227 +1699,6 @@ function getPageInfo() {
1723
1699
  };
1724
1700
  }
1725
1701
  __name(getPageInfo, "getPageInfo");
1726
- function hasDarkModeClass() {
1727
- const DEFAULT_DARK_MODE_CLASSES = ["dark", "dark-mode", "theme-dark", "night", "night-mode"];
1728
- const htmlElement = document.documentElement;
1729
- const bodyElement = document.body || document.documentElement;
1730
- for (const className of DEFAULT_DARK_MODE_CLASSES) {
1731
- if (htmlElement.classList.contains(className) || bodyElement?.classList.contains(className)) {
1732
- return true;
1733
- }
1734
- }
1735
- const darkThemeAttribute = htmlElement.getAttribute("data-theme");
1736
- if (darkThemeAttribute?.toLowerCase().includes("dark")) {
1737
- return true;
1738
- }
1739
- return false;
1740
- }
1741
- __name(hasDarkModeClass, "hasDarkModeClass");
1742
- function parseRgbColor(colorString) {
1743
- const rgbMatch = /rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(colorString);
1744
- if (!rgbMatch) {
1745
- return null;
1746
- }
1747
- return {
1748
- r: parseInt(rgbMatch[1]),
1749
- g: parseInt(rgbMatch[2]),
1750
- b: parseInt(rgbMatch[3])
1751
- };
1752
- }
1753
- __name(parseRgbColor, "parseRgbColor");
1754
- function isColorDark(colorString, threshold = 128) {
1755
- if (!colorString || colorString === "transparent" || colorString.startsWith("rgba(0, 0, 0, 0)")) {
1756
- return false;
1757
- }
1758
- const rgb = parseRgbColor(colorString);
1759
- if (!rgb) {
1760
- return false;
1761
- }
1762
- const luminance = 0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b;
1763
- return luminance < threshold;
1764
- }
1765
- __name(isColorDark, "isColorDark");
1766
- function isBackgroundDark() {
1767
- const htmlStyle = window.getComputedStyle(document.documentElement);
1768
- const bodyStyle = window.getComputedStyle(document.body || document.documentElement);
1769
- const htmlBgColor = htmlStyle.backgroundColor;
1770
- const bodyBgColor = bodyStyle.backgroundColor;
1771
- if (isColorDark(bodyBgColor)) {
1772
- return true;
1773
- } else if (bodyBgColor === "transparent" || bodyBgColor.startsWith("rgba(0, 0, 0, 0)")) {
1774
- return isColorDark(htmlBgColor);
1775
- }
1776
- return false;
1777
- }
1778
- __name(isBackgroundDark, "isBackgroundDark");
1779
- function isPageDark() {
1780
- try {
1781
- if (hasDarkModeClass()) {
1782
- return true;
1783
- }
1784
- if (isBackgroundDark()) {
1785
- return true;
1786
- }
1787
- return false;
1788
- } catch (error) {
1789
- console.warn("Error determining if page is dark:", error);
1790
- return false;
1791
- }
1792
- }
1793
- __name(isPageDark, "isPageDark");
1794
- const wrapper = "_wrapper_1oy2s_1";
1795
- const styles = {
1796
- wrapper
1797
- };
1798
- const cursor = "_cursor_1vrf3_2";
1799
- const cursorBorder = "_cursorBorder_1vrf3_13";
1800
- const cursorFilling = "_cursorFilling_1vrf3_23";
1801
- const cursorRipple = "_cursorRipple_1vrf3_31";
1802
- const clicking = "_clicking_1vrf3_37";
1803
- const cursorStyles = {
1804
- cursor,
1805
- cursorBorder,
1806
- cursorFilling,
1807
- cursorRipple,
1808
- clicking
1809
- };
1810
- const _SimulatorMask = class _SimulatorMask {
1811
- constructor() {
1812
- __privateAdd(this, _SimulatorMask_instances);
1813
- __publicField(this, "wrapper", document.createElement("div"));
1814
- __publicField(this, "motion", new Motion({
1815
- mode: isPageDark() ? "dark" : "light",
1816
- styles: {
1817
- position: "absolute",
1818
- inset: "0"
1819
- }
1820
- }));
1821
- __privateAdd(this, _cursor, document.createElement("div"));
1822
- __privateAdd(this, _currentCursorX, 0);
1823
- __privateAdd(this, _currentCursorY, 0);
1824
- __privateAdd(this, _targetCursorX, 0);
1825
- __privateAdd(this, _targetCursorY, 0);
1826
- this.wrapper.id = "page-agent-runtime_simulator-mask";
1827
- this.wrapper.className = styles.wrapper;
1828
- this.wrapper.setAttribute("data-browser-use-ignore", "true");
1829
- this.wrapper.appendChild(this.motion.element);
1830
- this.motion.autoResize(this.wrapper);
1831
- this.wrapper.addEventListener("click", (e) => {
1832
- e.stopPropagation();
1833
- e.preventDefault();
1834
- });
1835
- this.wrapper.addEventListener("mousedown", (e) => {
1836
- e.stopPropagation();
1837
- e.preventDefault();
1838
- });
1839
- this.wrapper.addEventListener("mouseup", (e) => {
1840
- e.stopPropagation();
1841
- e.preventDefault();
1842
- });
1843
- this.wrapper.addEventListener("mousemove", (e) => {
1844
- e.stopPropagation();
1845
- e.preventDefault();
1846
- });
1847
- this.wrapper.addEventListener("wheel", (e) => {
1848
- e.stopPropagation();
1849
- e.preventDefault();
1850
- });
1851
- this.wrapper.addEventListener("keydown", (e) => {
1852
- e.stopPropagation();
1853
- e.preventDefault();
1854
- });
1855
- this.wrapper.addEventListener("keyup", (e) => {
1856
- e.stopPropagation();
1857
- e.preventDefault();
1858
- });
1859
- __privateMethod(this, _SimulatorMask_instances, createCursor_fn).call(this);
1860
- document.body.appendChild(this.wrapper);
1861
- __privateMethod(this, _SimulatorMask_instances, moveCursorToTarget_fn).call(this);
1862
- window.addEventListener("PageAgent::MovePointerTo", (event) => {
1863
- const { x, y } = event.detail;
1864
- this.setCursorPosition(x, y);
1865
- });
1866
- window.addEventListener("PageAgent::ClickPointer", (event) => {
1867
- this.triggerClickAnimation();
1868
- });
1869
- }
1870
- setCursorPosition(x, y) {
1871
- __privateSet(this, _targetCursorX, x);
1872
- __privateSet(this, _targetCursorY, y);
1873
- }
1874
- triggerClickAnimation() {
1875
- __privateGet(this, _cursor).classList.remove(cursorStyles.clicking);
1876
- void __privateGet(this, _cursor).offsetHeight;
1877
- __privateGet(this, _cursor).classList.add(cursorStyles.clicking);
1878
- }
1879
- show() {
1880
- this.motion.start();
1881
- this.motion.fadeIn();
1882
- this.wrapper.style.display = "block";
1883
- __privateSet(this, _currentCursorX, window.innerWidth / 2);
1884
- __privateSet(this, _currentCursorY, window.innerHeight / 2);
1885
- __privateSet(this, _targetCursorX, __privateGet(this, _currentCursorX));
1886
- __privateSet(this, _targetCursorY, __privateGet(this, _currentCursorY));
1887
- __privateGet(this, _cursor).style.left = `${__privateGet(this, _currentCursorX)}px`;
1888
- __privateGet(this, _cursor).style.top = `${__privateGet(this, _currentCursorY)}px`;
1889
- }
1890
- hide() {
1891
- this.motion.fadeOut();
1892
- this.motion.pause();
1893
- __privateGet(this, _cursor).classList.remove(cursorStyles.clicking);
1894
- setTimeout(() => {
1895
- this.wrapper.style.display = "none";
1896
- }, 800);
1897
- }
1898
- dispose() {
1899
- this.motion.dispose();
1900
- this.wrapper.remove();
1901
- }
1902
- };
1903
- _cursor = new WeakMap();
1904
- _currentCursorX = new WeakMap();
1905
- _currentCursorY = new WeakMap();
1906
- _targetCursorX = new WeakMap();
1907
- _targetCursorY = new WeakMap();
1908
- _SimulatorMask_instances = new WeakSet();
1909
- createCursor_fn = /* @__PURE__ */ __name(function() {
1910
- __privateGet(this, _cursor).className = cursorStyles.cursor;
1911
- const rippleContainer = document.createElement("div");
1912
- rippleContainer.className = cursorStyles.cursorRipple;
1913
- __privateGet(this, _cursor).appendChild(rippleContainer);
1914
- const fillingLayer = document.createElement("div");
1915
- fillingLayer.className = cursorStyles.cursorFilling;
1916
- __privateGet(this, _cursor).appendChild(fillingLayer);
1917
- const borderLayer = document.createElement("div");
1918
- borderLayer.className = cursorStyles.cursorBorder;
1919
- __privateGet(this, _cursor).appendChild(borderLayer);
1920
- this.wrapper.appendChild(__privateGet(this, _cursor));
1921
- }, "#createCursor");
1922
- moveCursorToTarget_fn = /* @__PURE__ */ __name(function() {
1923
- const newX = __privateGet(this, _currentCursorX) + (__privateGet(this, _targetCursorX) - __privateGet(this, _currentCursorX)) * 0.2;
1924
- const newY = __privateGet(this, _currentCursorY) + (__privateGet(this, _targetCursorY) - __privateGet(this, _currentCursorY)) * 0.2;
1925
- const xDistance = Math.abs(newX - __privateGet(this, _targetCursorX));
1926
- if (xDistance > 0) {
1927
- if (xDistance < 2) {
1928
- __privateSet(this, _currentCursorX, __privateGet(this, _targetCursorX));
1929
- } else {
1930
- __privateSet(this, _currentCursorX, newX);
1931
- }
1932
- __privateGet(this, _cursor).style.left = `${__privateGet(this, _currentCursorX)}px`;
1933
- }
1934
- const yDistance = Math.abs(newY - __privateGet(this, _targetCursorY));
1935
- if (yDistance > 0) {
1936
- if (yDistance < 2) {
1937
- __privateSet(this, _currentCursorY, __privateGet(this, _targetCursorY));
1938
- } else {
1939
- __privateSet(this, _currentCursorY, newY);
1940
- }
1941
- __privateGet(this, _cursor).style.top = `${__privateGet(this, _currentCursorY)}px`;
1942
- }
1943
- requestAnimationFrame(() => __privateMethod(this, _SimulatorMask_instances, moveCursorToTarget_fn).call(this));
1944
- }, "#moveCursorToTarget");
1945
- __name(_SimulatorMask, "SimulatorMask");
1946
- let SimulatorMask = _SimulatorMask;
1947
1702
  function patchReact(pageController) {
1948
1703
  const reactRootElements = document.querySelectorAll(
1949
1704
  '[data-reactroot], [data-reactid], [data-react-checksum], #root, #app, [id^="root-"], [id^="app-"], #adex-wrapper, #adex-root'
@@ -1973,14 +1728,22 @@ const _PageController = class _PageController extends EventTarget {
1973
1728
  lastTimeUpdate = 0;
1974
1729
  /** Visual mask overlay for blocking user interaction during automation */
1975
1730
  mask = null;
1731
+ maskReady = null;
1976
1732
  constructor(config = {}) {
1977
1733
  super();
1978
1734
  this.config = config;
1979
1735
  patchReact();
1980
1736
  if (config.enableMask) {
1981
- this.mask = new SimulatorMask();
1737
+ this.maskReady = this.initMask();
1982
1738
  }
1983
1739
  }
1740
+ /**
1741
+ * Initialize mask asynchronously (dynamic import to avoid CSS loading in Node)
1742
+ */
1743
+ async initMask() {
1744
+ const { SimulatorMask } = await import("./SimulatorMask-BiVNIB3r.js");
1745
+ this.mask = new SimulatorMask();
1746
+ }
1984
1747
  // ======= State Queries =======
1985
1748
  /**
1986
1749
  * Get current page URL
@@ -2183,14 +1946,16 @@ ${scrollHintAbove}`;
2183
1946
  * Show the visual mask overlay.
2184
1947
  * Only works if enableMask was set to true in config.
2185
1948
  */
2186
- showMask() {
1949
+ async showMask() {
1950
+ await this.maskReady;
2187
1951
  this.mask?.show();
2188
1952
  }
2189
1953
  /**
2190
1954
  * Hide the visual mask overlay.
2191
1955
  * Only works if enableMask was set to true in config.
2192
1956
  */
2193
- hideMask() {
1957
+ async hideMask() {
1958
+ await this.maskReady;
2194
1959
  this.mask?.hide();
2195
1960
  }
2196
1961
  /**
@@ -2209,7 +1974,6 @@ ${scrollHintAbove}`;
2209
1974
  __name(_PageController, "PageController");
2210
1975
  let PageController = _PageController;
2211
1976
  export {
2212
- PageController,
2213
- SimulatorMask
1977
+ PageController
2214
1978
  };
2215
1979
  //# sourceMappingURL=page-controller.js.map