@vistagenic/vista 0.2.16 → 0.3.2

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.
Files changed (153) hide show
  1. package/bin/vista.js +184 -177
  2. package/dist/ai/agent.d.ts +37 -0
  3. package/dist/ai/agent.js +385 -0
  4. package/dist/ai/embeddings.d.ts +11 -0
  5. package/dist/ai/embeddings.js +71 -0
  6. package/dist/ai/index.d.ts +10 -0
  7. package/dist/ai/index.js +26 -0
  8. package/dist/ai/memory.d.ts +16 -0
  9. package/dist/ai/memory.js +39 -0
  10. package/dist/ai/observability.d.ts +21 -0
  11. package/dist/ai/observability.js +69 -0
  12. package/dist/ai/providers/anthropic.d.ts +2 -0
  13. package/dist/ai/providers/anthropic.js +190 -0
  14. package/dist/ai/providers/base.d.ts +7 -0
  15. package/dist/ai/providers/base.js +85 -0
  16. package/dist/ai/providers/gemini.d.ts +2 -0
  17. package/dist/ai/providers/gemini.js +194 -0
  18. package/dist/ai/providers/index.d.ts +5 -0
  19. package/dist/ai/providers/index.js +21 -0
  20. package/dist/ai/providers/mock.d.ts +8 -0
  21. package/dist/ai/providers/mock.js +77 -0
  22. package/dist/ai/providers/openai.d.ts +2 -0
  23. package/dist/ai/providers/openai.js +211 -0
  24. package/dist/ai/rag.d.ts +35 -0
  25. package/dist/ai/rag.js +110 -0
  26. package/dist/ai/react/index.d.ts +1 -0
  27. package/dist/ai/react/index.js +17 -0
  28. package/dist/ai/react/react-server.d.ts +1 -0
  29. package/dist/ai/react/react-server.js +17 -0
  30. package/dist/ai/react/use-agent.d.ts +23 -0
  31. package/dist/ai/react/use-agent.js +138 -0
  32. package/dist/ai/stream.d.ts +24 -0
  33. package/dist/ai/stream.js +109 -0
  34. package/dist/ai/tool.d.ts +11 -0
  35. package/dist/ai/tool.js +47 -0
  36. package/dist/ai/types.d.ts +117 -0
  37. package/dist/ai/types.js +5 -0
  38. package/dist/auth/core.d.ts +140 -0
  39. package/dist/auth/core.js +165 -0
  40. package/dist/auth/index.d.ts +20 -8
  41. package/dist/auth/index.js +369 -16
  42. package/dist/auth/react-server.d.ts +1 -0
  43. package/dist/auth/react-server.js +10 -0
  44. package/dist/auth/react.d.ts +18 -0
  45. package/dist/auth/react.js +71 -0
  46. package/dist/bin/build-rsc.js +602 -604
  47. package/dist/bin/build.js +389 -388
  48. package/dist/bin/deploy-output.d.ts +2 -7
  49. package/dist/bin/deploy-output.js +3 -76
  50. package/dist/bin/deploy.d.ts +7 -0
  51. package/dist/bin/deploy.js +102 -0
  52. package/dist/bin/dev-error-overlay-snippet.js +778 -552
  53. package/dist/bin/devtools-indicator-snippet.js +387 -387
  54. package/dist/bin/generate.js +510 -248
  55. package/dist/build/manifest.d.ts +169 -139
  56. package/dist/build/manifest.js +423 -367
  57. package/dist/build/rsc/client-manifest.d.ts +62 -52
  58. package/dist/build/rsc/client-manifest.js +295 -193
  59. package/dist/build/rsc/client-reference-plugin.d.ts +37 -37
  60. package/dist/build/rsc/client-reference-plugin.js +160 -160
  61. package/dist/build/rsc/native-scanner.d.ts +135 -123
  62. package/dist/build/rsc/native-scanner.js +203 -170
  63. package/dist/build/rsc/react-client-reference-manifest.d.ts +28 -22
  64. package/dist/build/rsc/react-client-reference-manifest.js +240 -219
  65. package/dist/build/rsc/rsc-renderer.d.ts +99 -99
  66. package/dist/build/rsc/rsc-renderer.js +263 -263
  67. package/dist/build/rsc/server-component-loader.d.ts +19 -19
  68. package/dist/build/rsc/server-component-loader.js +91 -91
  69. package/dist/build/rsc/server-manifest.d.ts +17 -0
  70. package/dist/build/rsc/server-manifest.js +20 -0
  71. package/dist/build/standalone.js +337 -334
  72. package/dist/build/webpack/plugins/vista-flight-plugin.js +5 -5
  73. package/dist/client/dynamic.react-server.d.ts +2 -0
  74. package/dist/client/dynamic.react-server.js +23 -0
  75. package/dist/client/link.react-server.d.ts +2 -0
  76. package/dist/client/link.react-server.js +11 -0
  77. package/dist/client/navigation.react-server.d.ts +1 -0
  78. package/dist/client/navigation.react-server.js +17 -0
  79. package/dist/client/router.react-server.d.ts +1 -0
  80. package/dist/client/router.react-server.js +17 -0
  81. package/dist/client/rsc-router.react-server.d.ts +1 -0
  82. package/dist/client/rsc-router.react-server.js +17 -0
  83. package/dist/client/script.react-server.d.ts +2 -0
  84. package/dist/client/script.react-server.js +23 -0
  85. package/dist/components/client-island.d.ts +34 -34
  86. package/dist/components/client-island.js +75 -75
  87. package/dist/config.d.ts +17 -0
  88. package/dist/config.js +60 -1
  89. package/dist/deploy/adapters/cloudflare.d.ts +2 -0
  90. package/dist/deploy/adapters/cloudflare.js +124 -0
  91. package/dist/deploy/adapters/docker.d.ts +2 -0
  92. package/dist/deploy/adapters/docker.js +112 -0
  93. package/dist/deploy/adapters/index.d.ts +15 -0
  94. package/dist/deploy/adapters/index.js +24 -0
  95. package/dist/deploy/adapters/netlify.d.ts +2 -0
  96. package/dist/deploy/adapters/netlify.js +115 -0
  97. package/dist/deploy/adapters/render.d.ts +2 -0
  98. package/dist/deploy/adapters/render.js +95 -0
  99. package/dist/deploy/adapters/vercel.d.ts +7 -0
  100. package/dist/deploy/adapters/vercel.js +164 -0
  101. package/dist/deploy/cli-runner.d.ts +8 -0
  102. package/dist/deploy/cli-runner.js +58 -0
  103. package/dist/deploy/detect.d.ts +6 -0
  104. package/dist/deploy/detect.js +77 -0
  105. package/dist/deploy/index.d.ts +24 -0
  106. package/dist/deploy/index.js +112 -0
  107. package/dist/deploy/preflight.d.ts +8 -0
  108. package/dist/deploy/preflight.js +80 -0
  109. package/dist/deploy/types.d.ts +48 -0
  110. package/dist/deploy/types.js +2 -0
  111. package/dist/deploy/utils.d.ts +18 -0
  112. package/dist/deploy/utils.js +70 -0
  113. package/dist/dev-error.d.ts +14 -0
  114. package/dist/dev-error.js +1763 -705
  115. package/dist/index.d.ts +23 -21
  116. package/dist/index.js +61 -57
  117. package/dist/server/cookie-parse.d.ts +4 -0
  118. package/dist/server/cookie-parse.js +14 -0
  119. package/dist/server/engine.js +7 -26
  120. package/dist/server/index.d.ts +109 -102
  121. package/dist/server/index.js +315 -286
  122. package/dist/server/middleware-runner.d.ts +125 -57
  123. package/dist/server/middleware-runner.js +615 -218
  124. package/dist/server/middleware-security.d.ts +36 -0
  125. package/dist/server/middleware-security.js +183 -0
  126. package/dist/server/module-compile-hook.js +695 -662
  127. package/dist/server/route-handler-registry.d.ts +65 -0
  128. package/dist/server/route-handler-registry.js +195 -0
  129. package/dist/server/route-patterns.d.ts +67 -0
  130. package/dist/server/route-patterns.js +186 -0
  131. package/dist/server/rsc-engine.js +75 -92
  132. package/dist/server/rsc-module-system.d.ts +33 -33
  133. package/dist/server/rsc-module-system.js +87 -87
  134. package/dist/server/rsc-upstream.js +892 -888
  135. package/dist/server/static-generator.js +10 -10
  136. package/dist/server/typed-api-runtime.d.ts +18 -0
  137. package/dist/server/typed-api-runtime.js +635 -507
  138. package/dist/server/vista-import-map.js +134 -123
  139. package/dist/stack/index.d.ts +34 -32
  140. package/dist/stack/index.js +49 -45
  141. package/dist/stack/server/caller.d.ts +13 -0
  142. package/dist/stack/server/caller.js +42 -0
  143. package/dist/stack/server/executor.d.ts +40 -36
  144. package/dist/stack/server/executor.js +222 -174
  145. package/dist/stack/server/index.d.ts +11 -10
  146. package/dist/stack/server/index.js +24 -23
  147. package/dist/stack/server/procedure.d.ts +20 -18
  148. package/dist/stack/server/procedure.js +66 -58
  149. package/dist/stack/server/types.d.ts +113 -100
  150. package/dist/theme/react-server.d.ts +10 -0
  151. package/dist/theme/react-server.js +16 -0
  152. package/package.json +28 -3
  153. package/LICENSE +0 -21
@@ -6,557 +6,783 @@ exports.getDevErrorOverlayBootstrapSource = getDevErrorOverlayBootstrapSource;
6
6
  * It supports Next.js-style error pagination and indicator restore.
7
7
  */
8
8
  function getDevErrorOverlayBootstrapSource() {
9
- return String.raw `
10
- (function installVistaDevErrorOverlay() {
11
- if (typeof window === 'undefined' || typeof document === 'undefined') return;
12
- if (window.__VISTA_DEV_ERROR_OVERLAY__) return;
13
-
14
- var STYLE_ID = '__vista-dev-error-overlay-style';
15
- var ROOT_ID = '__vista-dev-error-overlay';
16
- var root = null;
17
- var messageNode = null;
18
- var titleNode = null;
19
- var metaNode = null;
20
- var filesWrapNode = null;
21
- var filesNode = null;
22
- var hintsWrapNode = null;
23
- var hintsNode = null;
24
- var copyButton = null;
25
- var minimizeButton = null;
26
- var reloadButton = null;
27
- var paginationNode = null;
28
- var prevButton = null;
29
- var nextButton = null;
30
- var countNode = null;
31
- var listenersBound = false;
32
- var state = {
33
- open: false,
34
- minimized: false,
35
- entries: [],
36
- activeIndex: 0,
37
- };
38
-
39
- function getIndicator() {
40
- return window.__VISTA_DEVTOOLS_INDICATOR__;
41
- }
42
-
43
- function pad2(value) {
44
- return value < 10 ? '0' + value : String(value);
45
- }
46
-
47
- function formatTime(date) {
48
- return pad2(date.getHours()) + ':' + pad2(date.getMinutes()) + ':' + pad2(date.getSeconds());
49
- }
50
-
51
- function escapeHtml(value) {
52
- return String(value || '')
53
- .replace(/&/g, '&amp;')
54
- .replace(/</g, '&lt;')
55
- .replace(/>/g, '&gt;')
56
- .replace(/"/g, '&quot;')
57
- .replace(/'/g, '&#039;');
58
- }
59
-
60
- function highlightLine(line) {
61
- var escaped = escapeHtml(line);
62
- if (/^\s*\^+/.test(line)) {
63
- return '<span class="vista-ov-tok-caret">' + escaped + '</span>';
64
- }
65
- if (/^\s*at\s+/.test(line)) {
66
- return '<span class="vista-ov-tok-stack">' + escaped + '</span>';
67
- }
68
-
69
- var numbered = escaped.match(/^(\s*\d+)(\s*\|)(.*)$/);
70
- if (numbered) {
71
- escaped =
72
- '<span class="vista-ov-tok-line">' + numbered[1] + '</span>' + numbered[2] + numbered[3];
73
- }
74
-
75
- escaped = escaped.replace(
76
- /((?:[A-Za-z]:)?[\\/\w.@%:-]+\.(?:tsx?|jsx?|mjs|cjs|css|json|mdx?)(?::\d+(?::\d+)?)?)/g,
77
- '<span class="vista-ov-tok-path">$1</span>'
78
- );
79
- escaped = escaped.replace(
80
- /(&quot;[^&]+&quot;|&#039;[^&]+&#039;)/g,
81
- '<span class="vista-ov-tok-string">$1</span>'
82
- );
83
- escaped = escaped.replace(
84
- /(TypeError:|ReferenceError:|SyntaxError:|Error:|Cannot find module|Module not found|Build Error|Runtime Error|Hydration Error)/g,
85
- '<span class="vista-ov-tok-error">$1</span>'
86
- );
87
- return escaped;
88
- }
89
-
90
- function colorizeBlock(value) {
91
- return String(value || '')
92
- .split(/\r?\n/)
93
- .map(function (line) {
94
- return highlightLine(line);
95
- })
96
- .join('\n');
97
- }
98
-
99
- function createStyle() {
100
- if (document.getElementById(STYLE_ID)) return;
101
- var style = document.createElement('style');
102
- style.id = STYLE_ID;
103
- style.textContent = [
104
- '#' + ROOT_ID + '{position:fixed;inset:0;z-index:2147482500;display:flex;align-items:center;justify-content:center;padding:26px;}',
105
- '#' + ROOT_ID + '[hidden]{display:none;}',
106
- '#' + ROOT_ID + ' .vista-ov-backdrop{position:absolute;inset:0;background:radial-gradient(circle at top, rgba(255,90,60,0.22), rgba(7,8,11,0.93) 42%);backdrop-filter:blur(5px);}',
107
- '#' + ROOT_ID + ' .vista-ov-panel{position:relative;width:min(980px,100%);max-height:min(86vh,860px);display:flex;flex-direction:column;overflow:hidden;border-radius:15px;border:1px solid rgba(255,255,255,0.14);background:linear-gradient(180deg, rgba(25,27,32,0.97), rgba(10,12,15,0.98));box-shadow:0 32px 90px rgba(0,0,0,0.54);color:#e8ebf1;font-family:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;animation:vista-ov-in 170ms ease;}',
108
- '#' + ROOT_ID + ' .vista-ov-header{display:flex;justify-content:space-between;gap:14px;align-items:flex-start;padding:15px 17px;border-bottom:1px solid rgba(255,255,255,0.12);background:linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0));}',
109
- '#' + ROOT_ID + ' .vista-ov-head-left{min-width:0;display:flex;flex-direction:column;gap:8px;}',
110
- '#' + ROOT_ID + ' .vista-ov-top{display:flex;align-items:center;gap:10px;}',
111
- '#' + ROOT_ID + ' .vista-ov-badge{display:inline-flex;align-items:center;gap:7px;height:24px;padding:0 10px;border-radius:999px;border:1px solid rgba(248,113,113,0.5);background:rgba(248,113,113,0.14);font-size:11px;font-weight:700;letter-spacing:0.07em;text-transform:uppercase;color:#fecaca;white-space:nowrap;}',
112
- '#' + ROOT_ID + ' .vista-ov-badge-dot{width:7px;height:7px;border-radius:999px;background:#f87171;box-shadow:0 0 0 3px rgba(248,113,113,0.24);}',
113
- '#' + ROOT_ID + ' .vista-ov-pagination{display:inline-flex;align-items:center;gap:6px;padding:2px 3px;border-radius:999px;border:1px solid rgba(255,255,255,0.18);background:rgba(255,255,255,0.04);}',
114
- '#' + ROOT_ID + ' .vista-ov-page-btn{width:22px;height:22px;display:inline-flex;align-items:center;justify-content:center;border:none;border-radius:999px;background:rgba(255,255,255,0.13);color:#f8fafc;font-size:11px;line-height:1;cursor:pointer;}',
115
- '#' + ROOT_ID + ' .vista-ov-page-btn:disabled{opacity:0.35;cursor:not-allowed;}',
116
- '#' + ROOT_ID + ' .vista-ov-page-btn:not(:disabled):hover{background:rgba(255,255,255,0.22);}',
117
- '#' + ROOT_ID + ' .vista-ov-page-count{font-size:11px;font-weight:630;color:rgba(241,245,249,0.95);min-width:56px;text-align:center;font-variant-numeric:tabular-nums;}',
118
- '#' + ROOT_ID + ' .vista-ov-title{margin:0;font-size:18px;line-height:1.33;font-weight:640;letter-spacing:0.01em;color:#f8fafc;word-break:break-word;}',
119
- '#' + ROOT_ID + ' .vista-ov-meta{margin:0;font-size:12px;color:rgba(226,232,240,0.72);}',
120
- '#' + ROOT_ID + ' .vista-ov-controls{display:flex;gap:8px;align-items:center;}',
121
- '#' + ROOT_ID + ' .vista-ov-btn{width:30px;height:30px;padding:0;border-radius:9px;border:1px solid rgba(255,255,255,0.22);background:rgba(255,255,255,0.04);color:#e2e8f0;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:all 120ms ease;}',
122
- '#' + ROOT_ID + ' .vista-ov-btn:hover{background:rgba(255,255,255,0.12);border-color:rgba(255,255,255,0.38);}',
123
- '#' + ROOT_ID + ' .vista-ov-btn svg{width:14px;height:14px;display:block;}',
124
- '#' + ROOT_ID + ' .vista-ov-btn:focus-visible{outline:2px solid rgba(255,255,255,0.68);outline-offset:2px;}',
125
- '#' + ROOT_ID + ' .vista-ov-btn[data-variant="warn"]{border-color:rgba(248,113,113,0.48);color:#fecaca;background:rgba(248,113,113,0.1);}',
126
- '#' + ROOT_ID + ' .vista-ov-body{padding:16px 17px 17px;overflow:auto;display:grid;grid-template-columns:1fr;gap:11px;}',
127
- '#' + ROOT_ID + ' .vista-ov-section{border:1px solid rgba(255,255,255,0.11);border-radius:11px;background:rgba(255,255,255,0.03);padding:12px 12px;}',
128
- '#' + ROOT_ID + ' .vista-ov-section-title{margin:0 0 8px;font-size:11px;letter-spacing:0.08em;text-transform:uppercase;font-weight:700;color:rgba(226,232,240,0.76);}',
129
- '#' + ROOT_ID + ' .vista-ov-list{margin:0;padding-left:18px;display:grid;gap:6px;color:#e2e8f0;font-size:13px;line-height:1.44;}',
130
- '#' + ROOT_ID + ' .vista-ov-list code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px;background:rgba(255,255,255,0.06);padding:1px 5px;border-radius:5px;border:1px solid rgba(255,255,255,0.16);}',
131
- '#' + ROOT_ID + ' .vista-ov-pre{margin:0;font-size:12.5px;line-height:1.58;color:#f1f5f9;white-space:pre-wrap;word-break:break-word;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;}',
132
- '#' + ROOT_ID + ' .vista-ov-tok-error{color:#fca5a5;font-weight:640;}',
133
- '#' + ROOT_ID + ' .vista-ov-tok-path{color:#93c5fd;}',
134
- '#' + ROOT_ID + ' .vista-ov-tok-string{color:#86efac;}',
135
- '#' + ROOT_ID + ' .vista-ov-tok-stack{color:#cbd5e1;}',
136
- '#' + ROOT_ID + ' .vista-ov-tok-line{color:#fbbf24;}',
137
- '#' + ROOT_ID + ' .vista-ov-tok-caret{color:#f87171;font-weight:700;}',
138
- '@keyframes vista-ov-in{from{opacity:0;transform:translateY(6px) scale(0.99);}to{opacity:1;transform:translateY(0) scale(1);}}',
139
- '@media (max-width: 860px){',
140
- ' #' + ROOT_ID + '{padding:12px;}',
141
- ' #' + ROOT_ID + ' .vista-ov-header{flex-direction:column;}',
142
- ' #' + ROOT_ID + ' .vista-ov-controls{width:100%;justify-content:flex-end;}',
143
- ' #' + ROOT_ID + ' .vista-ov-title{font-size:16px;}',
144
- '}',
145
- ].join('');
146
- document.head.appendChild(style);
147
- }
148
-
149
- function ensureMounted() {
150
- createStyle();
151
- if (!root) {
152
- root = document.getElementById(ROOT_ID);
153
- }
154
- if (!root) {
155
- root = document.createElement('div');
156
- root.id = ROOT_ID;
157
- root.hidden = true;
158
- root.innerHTML = [
159
- '<div class="vista-ov-backdrop"></div>',
160
- '<section class="vista-ov-panel" role="dialog" aria-modal="true" aria-label="Vista build error overlay">',
161
- ' <header class="vista-ov-header">',
162
- ' <div class="vista-ov-head-left">',
163
- ' <div class="vista-ov-top">',
164
- ' <span class="vista-ov-badge"><span class="vista-ov-badge-dot"></span>Build Error</span>',
165
- ' <div class="vista-ov-pagination" data-vista-pagination hidden>',
166
- ' <button type="button" class="vista-ov-page-btn" data-vista-prev aria-label="Previous error">&lt;</button>',
167
- ' <span class="vista-ov-page-count" data-vista-count>1 / 1</span>',
168
- ' <button type="button" class="vista-ov-page-btn" data-vista-next aria-label="Next error">&gt;</button>',
169
- ' </div>',
170
- ' </div>',
171
- ' <h2 class="vista-ov-title" data-vista-ov-title>Build Error</h2>',
172
- ' <p class="vista-ov-meta" data-vista-ov-meta></p>',
173
- ' </div>',
174
- ' <div class="vista-ov-controls">',
175
- ' <button type="button" class="vista-ov-btn" data-vista-copy aria-label="Copy error">',
176
- ' <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><rect x="9" y="9" width="10" height="10" rx="2" stroke="currentColor" stroke-width="2"/><rect x="5" y="5" width="10" height="10" rx="2" stroke="currentColor" stroke-width="2"/></svg>',
177
- ' </button>',
178
- ' <button type="button" class="vista-ov-btn" data-vista-minimize aria-label="Minimize">',
179
- ' <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M5 12H19" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',
180
- ' </button>',
181
- ' <button type="button" class="vista-ov-btn" data-vista-reload aria-label="Reload">',
182
- ' <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M20 11A8 8 0 1 0 12 20" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M20 4V11H13" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',
183
- ' </button>',
184
- ' </div>',
185
- ' </header>',
186
- ' <div class="vista-ov-body">',
187
- ' <section class="vista-ov-section" data-vista-hints-wrap hidden>',
188
- ' <h3 class="vista-ov-section-title">Insights</h3>',
189
- ' <ul class="vista-ov-list" data-vista-hints></ul>',
190
- ' </section>',
191
- ' <section class="vista-ov-section" data-vista-files-wrap hidden>',
192
- ' <h3 class="vista-ov-section-title">Possible Files</h3>',
193
- ' <ul class="vista-ov-list" data-vista-files></ul>',
194
- ' </section>',
195
- ' <section class="vista-ov-section">',
196
- ' <h3 class="vista-ov-section-title">Message</h3>',
197
- ' <pre class="vista-ov-pre" data-vista-message></pre>',
198
- ' </section>',
199
- ' </div>',
200
- '</section>',
201
- ].join('');
202
- document.body.appendChild(root);
203
- } else if (!root.isConnected && document.body) {
204
- document.body.appendChild(root);
205
- }
206
-
207
- var backdrop = root.querySelector('.vista-ov-backdrop');
208
- messageNode = root.querySelector('[data-vista-message]');
209
- titleNode = root.querySelector('[data-vista-ov-title]');
210
- metaNode = root.querySelector('[data-vista-ov-meta]');
211
- filesWrapNode = root.querySelector('[data-vista-files-wrap]');
212
- filesNode = root.querySelector('[data-vista-files]');
213
- hintsWrapNode = root.querySelector('[data-vista-hints-wrap]');
214
- hintsNode = root.querySelector('[data-vista-hints]');
215
- copyButton = root.querySelector('[data-vista-copy]');
216
- minimizeButton = root.querySelector('[data-vista-minimize]');
217
- reloadButton = root.querySelector('[data-vista-reload]');
218
- paginationNode = root.querySelector('[data-vista-pagination]');
219
- prevButton = root.querySelector('[data-vista-prev]');
220
- nextButton = root.querySelector('[data-vista-next]');
221
- countNode = root.querySelector('[data-vista-count]');
222
-
223
- if (listenersBound) return;
224
- listenersBound = true;
225
-
226
- if (copyButton) {
227
- copyButton.addEventListener('click', function () {
228
- copyCurrentMessage();
229
- });
230
- }
231
- if (minimizeButton) {
232
- minimizeButton.addEventListener('click', function () {
233
- minimize();
234
- });
235
- }
236
- if (reloadButton) {
237
- reloadButton.addEventListener('click', function () {
238
- reloadPage();
239
- });
240
- }
241
- if (prevButton) {
242
- prevButton.addEventListener('click', function () {
243
- moveActiveIndex(-1);
244
- });
245
- }
246
- if (nextButton) {
247
- nextButton.addEventListener('click', function () {
248
- moveActiveIndex(1);
249
- });
250
- }
251
- if (backdrop) {
252
- backdrop.addEventListener('click', function () {
253
- minimize();
254
- });
255
- }
256
- if (root) {
257
- root.addEventListener('keydown', function (event) {
258
- if (event.key === 'ArrowLeft') {
259
- moveActiveIndex(-1);
260
- } else if (event.key === 'ArrowRight') {
261
- moveActiveIndex(1);
262
- } else if (event.key === 'Escape') {
263
- minimize();
264
- }
265
- });
266
- }
267
- }
268
-
269
- function normalizeMessages(input) {
270
- if (Array.isArray(input)) {
271
- return input
272
- .map(function (entry) {
273
- return typeof entry === 'string' ? entry : String(entry || '');
274
- })
275
- .filter(function (entry) {
276
- return entry.trim().length > 0;
277
- });
278
- }
279
-
280
- if (input && typeof input === 'object' && Array.isArray(input.errors)) {
281
- return normalizeMessages(input.errors);
282
- }
283
-
284
- var raw = typeof input === 'string' ? input : String(input || '');
285
- if (raw.trim().length === 0) {
286
- return [];
287
- }
288
-
289
- var splitByWebpack = raw.split(/\n(?=ERROR in\s)/g).filter(function (entry) {
290
- return entry.trim().length > 0;
291
- });
292
- if (splitByWebpack.length > 1) {
293
- return splitByWebpack;
294
- }
295
- return [raw];
296
- }
297
-
298
- function parseMessage(input) {
299
- var raw = typeof input === 'string' ? input : String(input || 'Unknown build error.');
300
- var lines = raw.split(/\r?\n/);
301
- var trimmedLines = [];
302
- for (var i = 0; i < lines.length; i += 1) {
303
- var entry = lines[i] ? lines[i].trim() : '';
304
- if (entry.length > 0) {
305
- trimmedLines.push(entry);
306
- }
307
- }
308
-
309
- var title = trimmedLines.length ? trimmedLines[0] : 'Build Error';
310
- if (title.length > 140) {
311
- title = title.slice(0, 137) + '...';
312
- }
313
-
314
- var files = [];
315
- var filePattern = /(?:[A-Za-z]:)?[\\/\w.@-]+\.(?:tsx?|jsx?|mjs|cjs|css|json|mdx?)(?::\d+(?::\d+)?)?/;
316
- for (var fileIdx = 0; fileIdx < lines.length; fileIdx += 1) {
317
- var maybeFile = lines[fileIdx].match(filePattern);
318
- if (!maybeFile) continue;
319
- var normalized = maybeFile[0].replace(/\\/g, '/');
320
- if (files.indexOf(normalized) === -1) {
321
- files.push(normalized);
322
- }
323
- if (files.length >= 5) break;
324
- }
325
-
326
- var hints = [];
327
- if (/['"]use client['"]/.test(raw)) {
328
- hints.push("Client hook detected in a Server Component. Add 'use client' to the top of that file.");
329
- }
330
- if (/Cannot find module/i.test(raw) || /Module not found/i.test(raw)) {
331
- hints.push('A module import failed to resolve. Check the import path or install the missing package.');
332
- }
333
- if (/Unexpected token/i.test(raw) || /SyntaxError/i.test(raw)) {
334
- hints.push('A syntax issue is blocking compilation. Start from the first highlighted file and fix parsing errors.');
335
- }
336
- if (/Type error/i.test(raw) || /TS\d{3,5}/i.test(raw)) {
337
- hints.push('TypeScript validation failed. Fix the first type error first to reduce cascading issues.');
338
- }
339
- if (/Structure Validation Failed/i.test(raw)) {
340
- hints.push('App structure rules failed. Verify route files, layout/page naming, and required conventions.');
341
- }
342
- if (hints.length === 0 && files.length > 0) {
343
- hints.push('Start with the first file above, then re-run after each fix.');
344
- }
345
- if (hints.length === 0) {
346
- hints.push('Resolve the top-most failure first, then reload to see remaining issues.');
347
- }
348
-
349
- return {
350
- raw: raw,
351
- title: title,
352
- files: files,
353
- hints: hints,
354
- timestamp: new Date(),
355
- };
356
- }
357
-
358
- function fillList(node, values, wrapNode) {
359
- if (!node || !wrapNode) return;
360
- while (node.firstChild) node.removeChild(node.firstChild);
361
- if (!values || values.length === 0) {
362
- wrapNode.hidden = true;
363
- return;
364
- }
365
- for (var i = 0; i < values.length; i += 1) {
366
- var item = document.createElement('li');
367
- var code = document.createElement('code');
368
- code.textContent = values[i];
369
- item.appendChild(code);
370
- node.appendChild(item);
371
- }
372
- wrapNode.hidden = false;
373
- }
374
-
375
- function fillHints(node, values, wrapNode) {
376
- if (!node || !wrapNode) return;
377
- while (node.firstChild) node.removeChild(node.firstChild);
378
- if (!values || values.length === 0) {
379
- wrapNode.hidden = true;
380
- return;
381
- }
382
- for (var i = 0; i < values.length; i += 1) {
383
- var item = document.createElement('li');
384
- item.textContent = values[i];
385
- node.appendChild(item);
386
- }
387
- wrapNode.hidden = false;
388
- }
389
-
390
- function currentEntry() {
391
- if (!state.entries || state.entries.length === 0) return null;
392
- var index = state.activeIndex;
393
- if (index < 0) index = 0;
394
- if (index > state.entries.length - 1) index = state.entries.length - 1;
395
- return state.entries[index];
396
- }
397
-
398
- function updatePagination() {
399
- var total = state.entries.length;
400
- var current = total === 0 ? 0 : state.activeIndex + 1;
401
- if (countNode) {
402
- countNode.textContent = current + ' / ' + (total || 1);
403
- }
404
- if (paginationNode) {
405
- paginationNode.hidden = total <= 1;
406
- }
407
- if (prevButton) {
408
- prevButton.disabled = state.activeIndex <= 0;
409
- }
410
- if (nextButton) {
411
- nextButton.disabled = state.activeIndex >= total - 1;
412
- }
413
- }
414
-
415
- function renderCurrent() {
416
- var parsed = currentEntry();
417
- if (!parsed || !root) return;
418
- if (titleNode) titleNode.textContent = parsed.title || 'Build Error';
419
- if (metaNode) {
420
- metaNode.textContent =
421
- 'Vista Dev Overlay | ' +
422
- formatTime(parsed.timestamp) +
423
- ' | ' +
424
- (state.activeIndex + 1) +
425
- ' of ' +
426
- state.entries.length;
427
- }
428
- if (messageNode) messageNode.innerHTML = colorizeBlock(parsed.raw);
429
- fillList(filesNode, parsed.files, filesWrapNode);
430
- fillHints(hintsNode, parsed.hints, hintsWrapNode);
431
- updatePagination();
432
- }
433
-
434
- function moveActiveIndex(offset) {
435
- if (!state.entries || state.entries.length <= 1) return;
436
- var next = state.activeIndex + offset;
437
- if (next < 0 || next >= state.entries.length) return;
438
- state.activeIndex = next;
439
- renderCurrent();
440
- }
441
-
442
- function copyCurrentMessage() {
443
- var entry = currentEntry();
444
- if (!entry) return;
445
- var text = entry.raw;
446
- if (navigator && navigator.clipboard && navigator.clipboard.writeText) {
447
- navigator.clipboard.writeText(text).catch(function () {});
448
- return;
449
- }
450
- var textarea = document.createElement('textarea');
451
- textarea.value = text;
452
- textarea.style.position = 'fixed';
453
- textarea.style.opacity = '0';
454
- textarea.style.pointerEvents = 'none';
455
- document.body.appendChild(textarea);
456
- textarea.focus();
457
- textarea.select();
458
- try {
459
- document.execCommand('copy');
460
- } catch (e) {}
461
- document.body.removeChild(textarea);
462
- }
463
-
464
- function reloadPage() {
465
- if (typeof window === 'undefined') return;
466
- window.location.reload();
467
- }
468
-
469
- function openFromState() {
470
- ensureMounted();
471
- if (!state.entries || state.entries.length === 0) return false;
472
- state.open = true;
473
- state.minimized = false;
474
- renderCurrent();
475
- if (root) root.hidden = false;
476
- var indicator = getIndicator();
477
- if (indicator && typeof indicator.clearError === 'function') {
478
- indicator.clearError();
479
- }
480
- return true;
481
- }
482
-
483
- function show(input) {
484
- ensureMounted();
485
- var messages = normalizeMessages(input);
486
- if (messages.length === 0) {
487
- return;
488
- }
489
- state.entries = messages.map(function (message) {
490
- return parseMessage(message);
491
- });
492
- state.activeIndex = 0;
493
- openFromState();
494
- }
495
-
496
- function capture(input) {
497
- ensureMounted();
498
- var messages = normalizeMessages(input);
499
- if (messages.length === 0) {
500
- return;
501
- }
502
- state.entries = messages.map(function (message) {
503
- return parseMessage(message);
504
- });
505
- state.activeIndex = 0;
506
- state.open = false;
507
- state.minimized = true;
508
- if (root) root.hidden = true;
509
- var entry = currentEntry();
510
- var indicator = getIndicator();
511
- if (indicator && typeof indicator.setError === 'function') {
512
- indicator.setError(entry ? entry.title || 'Build error' : 'Build error', state.entries.length);
513
- }
514
- }
515
-
516
- function minimize() {
517
- var entry = currentEntry();
518
- if (!entry) return false;
519
- ensureMounted();
520
- state.open = false;
521
- state.minimized = true;
522
- if (root) root.hidden = true;
523
- var indicator = getIndicator();
524
- if (indicator && typeof indicator.setError === 'function') {
525
- indicator.setError(entry.title || 'Build error', state.entries.length);
526
- }
527
- return true;
528
- }
529
-
530
- function clear() {
531
- state.open = false;
532
- state.minimized = false;
533
- state.entries = [];
534
- state.activeIndex = 0;
535
- if (root) root.hidden = true;
536
- var indicator = getIndicator();
537
- if (indicator && typeof indicator.clearError === 'function') {
538
- indicator.clearError();
539
- }
540
- }
541
-
542
- function restoreFromIndicator() {
543
- if (!state.minimized || !state.entries || state.entries.length === 0) return false;
544
- return openFromState();
545
- }
546
-
547
- window.__VISTA_DEV_ERROR_OVERLAY__ = {
548
- show: show,
549
- capture: capture,
550
- minimize: minimize,
551
- clear: clear,
552
- restoreFromIndicator: restoreFromIndicator,
553
- isOpen: function () {
554
- return state.open;
555
- },
556
- hasError: function () {
557
- return state.entries && state.entries.length > 0;
558
- },
559
- };
560
- })();
9
+ return String.raw `
10
+ (function installVistaDevErrorOverlay() {
11
+ if (typeof window === 'undefined' || typeof document === 'undefined') return;
12
+ if (window.__VISTA_DEV_ERROR_OVERLAY__) return;
13
+
14
+ var STYLE_ID = '__vista-dev-error-overlay-style';
15
+ var ROOT_ID = '__vista-dev-error-overlay';
16
+ var root = null;
17
+ var messageNode = null;
18
+ var titleNode = null;
19
+ var detailNode = null;
20
+ var filesWrapNode = null;
21
+ var filesNode = null;
22
+ var tabNameNodes = null;
23
+ var crumbsNode = null;
24
+ var statusLnNode = null;
25
+ var statusLangNode = null;
26
+ var kindNode = null;
27
+ var sourceBadgeNode = null;
28
+ var fileTabsNode = null;
29
+ var copyButton = null;
30
+ var minimizeButton = null;
31
+ var reloadButton = null;
32
+ var paginationNode = null;
33
+ var prevButton = null;
34
+ var nextButton = null;
35
+ var countNode = null;
36
+ var mainNode = null;
37
+ var panelExpandButton = null;
38
+ var listenersBound = false;
39
+ var state = {
40
+ open: false,
41
+ minimized: false,
42
+ entries: [],
43
+ activeIndex: 0,
44
+ fileTab: 0,
45
+ };
46
+
47
+ function getIndicator() {
48
+ return window.__VISTA_DEVTOOLS_INDICATOR__;
49
+ }
50
+
51
+ function escapeHtml(value) {
52
+ return String(value || '')
53
+ .replace(/&/g, '&amp;')
54
+ .replace(/</g, '&lt;')
55
+ .replace(/>/g, '&gt;')
56
+ .replace(/"/g, '&quot;')
57
+ .replace(/'/g, '&#039;');
58
+ }
59
+
60
+ function highlightSource(text) {
61
+ var html = '';
62
+ var i = 0;
63
+ var keywords = /^(import|from|function|return|const|let|var|export|default|class|extends|if|else|async|await|new|type|interface|true|false|null|undefined|typeof|void|as|of|in|for|while|switch|case|break|continue|try|catch|finally|this)\b/;
64
+ while (i < text.length) {
65
+ var ch = text.charAt(i);
66
+ if (ch === "'" || ch === '"' || ch === String.fromCharCode(96)) {
67
+ var j = i + 1;
68
+ while (j < text.length && text.charAt(j) !== ch) {
69
+ j += text.charAt(j) === '\\' ? 2 : 1;
70
+ }
71
+ html += '<span class="vista-tok-str">' + escapeHtml(text.slice(i, Math.min(j + 1, text.length))) + '</span>';
72
+ i = j + 1;
73
+ continue;
74
+ }
75
+ if (ch === '/' && text.charAt(i + 1) === '/') {
76
+ html += '<span class="vista-tok-cmt">' + escapeHtml(text.slice(i)) + '</span>';
77
+ break;
78
+ }
79
+ if (ch === '<' && /[A-Za-z/]/.test(text.charAt(i + 1) || '')) {
80
+ var tag = text.slice(i).match(/^<\/?[A-Za-z][\w.-]*/);
81
+ if (tag) {
82
+ html += '<span class="vista-tok-tag">' + escapeHtml(tag[0]) + '</span>';
83
+ i += tag[0].length;
84
+ continue;
85
+ }
86
+ }
87
+ if (/[A-Za-z_$]/.test(ch)) {
88
+ var ident = text.slice(i).match(/^[A-Za-z_$][\w$]*/);
89
+ if (ident) {
90
+ html += keywords.test(ident[0])
91
+ ? '<span class="vista-tok-kw">' + escapeHtml(ident[0]) + '</span>'
92
+ : escapeHtml(ident[0]);
93
+ i += ident[0].length;
94
+ continue;
95
+ }
96
+ }
97
+ html += escapeHtml(ch);
98
+ i += 1;
99
+ }
100
+ return html;
101
+ }
102
+
103
+ function fileBasename(file) {
104
+ var normalized = String(file || '').replace(/\\/g, '/').replace(/:\d+(?::\d+)?$/, '');
105
+ return normalized.split('/').filter(Boolean).pop() || 'untitled';
106
+ }
107
+
108
+ function fileBreadcrumb(file) {
109
+ var normalized = String(file || '').replace(/\\/g, '/').replace(/:\d+(?::\d+)?$/, '');
110
+ return normalized.split('/').filter(Boolean).join(' ') || 'Source';
111
+ }
112
+
113
+ function languageFromFile(file) {
114
+ var ext = String(file || '').replace(/:\d+(?::\d+)?$/, '').split('.').pop().toLowerCase();
115
+ if (ext === 'tsx') return 'TypeScript React';
116
+ if (ext === 'ts') return 'TypeScript';
117
+ if (ext === 'jsx') return 'JavaScript React';
118
+ if (ext === 'js' || ext === 'mjs' || ext === 'cjs') return 'JavaScript';
119
+ if (ext === 'css') return 'CSS';
120
+ if (ext === 'json') return 'JSON';
121
+ return 'Plain Text';
122
+ }
123
+
124
+ function parseFileLocation(file) {
125
+ var match = String(file || '').match(/:(\d+)(?::(\d+))?$/);
126
+ return {
127
+ line: match ? Number(match[1]) : 0,
128
+ column: match && match[2] ? Number(match[2]) : 1,
129
+ };
130
+ }
131
+
132
+ function renderIdeCode(codeFrame, errorLine, errorColumn) {
133
+ var rawLines = String(codeFrame || '').split(/\r?\n/);
134
+ var rows = [];
135
+ for (var i = 0; i < rawLines.length; i += 1) {
136
+ var line = rawLines[i];
137
+ var numbered = line.match(/^(\s*>)?\s*(\d+)\s+\|(.*)$/);
138
+ if (!numbered) continue;
139
+ var src = numbered[3];
140
+ if (src.charAt(0) === ' ') src = src.slice(1);
141
+ var isError = !!(numbered[1] && numbered[1].indexOf('>') !== -1);
142
+ var squiggleAt = -1;
143
+ var next = rawLines[i + 1] || '';
144
+ var caret = next.match(/\|(.*)$/);
145
+ if (caret && caret[1].indexOf('^') !== -1) {
146
+ var mark = caret[1];
147
+ if (mark.charAt(0) === ' ') mark = mark.slice(1);
148
+ squiggleAt = Math.max(0, mark.indexOf('^'));
149
+ isError = true;
150
+ i += 1;
151
+ }
152
+ rows.push({ n: Number(numbered[2]), text: src, error: isError, squiggleAt: squiggleAt });
153
+ }
154
+ if (!rows.length) {
155
+ return '<div class="vista-error-editor"><div class="vista-error-editor-line"><span class="vista-error-gutter"></span><span class="vista-error-source">' + highlightSource(String(codeFrame || '')) + '</span></div></div>';
156
+ }
157
+ var min = rows[0].n;
158
+ var max = rows[0].n;
159
+ var byN = {};
160
+ for (var r = 0; r < rows.length; r += 1) {
161
+ byN[rows[r].n] = rows[r];
162
+ if (rows[r].n < min) min = rows[r].n;
163
+ if (rows[r].n > max) max = rows[r].n;
164
+ }
165
+ var html = '';
166
+ for (var n = min; n <= max; n += 1) {
167
+ var row = byN[n] || { n: n, text: '', error: Number(errorLine) === n, squiggleAt: -1 };
168
+ if (row.squiggleAt < 0 && Number(errorLine) === n && errorColumn) {
169
+ row.squiggleAt = Math.max(0, Number(errorColumn) - 1);
170
+ row.error = true;
171
+ }
172
+ html += '<div class="vista-error-editor-line' + (row.error ? ' is-error' : '') + '">';
173
+ html += '<span class="vista-error-gutter">' + row.n + '</span>';
174
+ html += '<span class="vista-error-source">' + highlightSource(row.text);
175
+ if (row.squiggleAt >= 0) {
176
+ html += '<span class="vista-error-squiggle" style="width:3.2ch;margin-left:' + row.squiggleAt + 'ch"></span>';
177
+ }
178
+ html += '</span></div>';
179
+ }
180
+ return '<div class="vista-error-editor">' + html + '</div>';
181
+ }
182
+
183
+ function colorizeBlock(value) {
184
+ return renderIdeCode(value);
185
+ }
186
+
187
+ function createStyle() {
188
+ if (document.getElementById(STYLE_ID)) return;
189
+ var style = document.createElement('style');
190
+ style.id = STYLE_ID;
191
+ style.textContent = [
192
+ '#' + ROOT_ID + '{position:fixed;inset:0;z-index:2147482500;display:flex;align-items:center;justify-content:center;padding:20px;overflow:hidden;}',
193
+ '#' + ROOT_ID + '[hidden]{display:none;}',
194
+ '#' + ROOT_ID + ' .vista-ov-backdrop{position:absolute;inset:0;background:rgba(0,0,0,0.72);}',
195
+ '#' + ROOT_ID + ' .vista-ov-panel{position:relative;width:min(1180px,calc(100vw - 32px));height:min(820px,calc(100vh - 32px));display:flex;flex-direction:column;overflow:hidden;border-radius:8px;border:1px solid #2b2b2b;background:#1e1e1e;box-shadow:0 24px 80px rgba(0,0,0,0.62);color:#ededed;font-family:"Segoe UI",ui-sans-serif,system-ui,-apple-system,sans-serif;animation:vista-ov-in 160ms ease;}',
196
+ '#' + ROOT_ID + ' .vista-ov-titlebar{display:flex;align-items:center;justify-content:space-between;gap:12px;height:38px;padding:0 10px;background:#181818;border-bottom:1px solid #2b2b2b;flex-shrink:0;}',
197
+ '#' + ROOT_ID + ' .vista-ov-traffic{display:inline-flex;align-items:center;gap:6px;width:54px;}',
198
+ '#' + ROOT_ID + ' .vista-ov-traffic span{width:10px;height:10px;border-radius:999px;}',
199
+ '#' + ROOT_ID + ' .vista-ov-traffic .is-close{background:#ff5f57;}',
200
+ '#' + ROOT_ID + ' .vista-ov-traffic .is-min{background:#febc2e;}',
201
+ '#' + ROOT_ID + ' .vista-ov-traffic .is-max{background:#28c840;}',
202
+ '#' + ROOT_ID + ' .vista-ov-window-title{min-width:0;flex:1;text-align:center;color:#c6c6c6;font-size:12px;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}',
203
+ '#' + ROOT_ID + ' .vista-ov-pagination{display:inline-flex;align-items:center;gap:2px;}',
204
+ '#' + ROOT_ID + ' .vista-ov-pagination[hidden]{display:none;}',
205
+ '#' + ROOT_ID + ' .vista-ov-page-btn{width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:6px;background:transparent;color:#a1a1a1;font-size:16px;line-height:1;cursor:pointer;}',
206
+ '#' + ROOT_ID + ' .vista-ov-page-btn:disabled{opacity:0.28;cursor:default;}',
207
+ '#' + ROOT_ID + ' .vista-ov-page-btn:not(:disabled):hover{background:#171717;color:#ededed;}',
208
+ '#' + ROOT_ID + ' .vista-ov-page-count{font-size:13px;font-weight:500;color:#a1a1a1;min-width:36px;text-align:center;font-variant-numeric:tabular-nums;padding:0 4px;}',
209
+ '#' + ROOT_ID + ' .vista-ov-workbench{display:flex;flex:1;min-height:0;}',
210
+ '#' + ROOT_ID + ' .vista-ov-activity{width:48px;flex-shrink:0;display:flex;flex-direction:column;align-items:center;padding-top:8px;background:#181818;border-right:1px solid #2b2b2b;}',
211
+ '#' + ROOT_ID + ' .vista-ov-activity-item{width:48px;height:40px;display:inline-flex;align-items:center;justify-content:center;color:#ffffff;box-shadow:inset 2px 0 0 #0078d4;}',
212
+ '#' + ROOT_ID + ' .vista-ov-activity-item svg{width:22px;height:22px;display:block;}',
213
+ '#' + ROOT_ID + ' .vista-ov-main{display:flex;flex-direction:column;flex:1;min-width:0;min-height:0;}',
214
+ '#' + ROOT_ID + ' .vista-ov-tabbar{display:flex;align-items:stretch;justify-content:space-between;height:35px;background:#181818;border-bottom:1px solid #2b2b2b;flex-shrink:0;}',
215
+ '#' + ROOT_ID + ' .vista-ov-tabs{display:flex;min-width:0;overflow:hidden;scrollbar-width:none;}',
216
+ '#' + ROOT_ID + ' .vista-ov-tabs::-webkit-scrollbar{display:none;}',
217
+ '#' + ROOT_ID + ' .vista-ov-tab{display:inline-flex;align-items:center;gap:8px;height:35px;padding:0 14px;border:0;border-right:1px solid #2b2b2b;background:#1e1e1e;color:#cccccc;font-size:12px;box-shadow:inset 0 -1px 0 #0078d4;cursor:pointer;}',
218
+ '#' + ROOT_ID + ' .vista-ov-tab.is-inactive{background:#181818;color:#8b8b8b;box-shadow:none;}',
219
+ '#' + ROOT_ID + ' .vista-ov-tab svg{width:14px;height:14px;}',
220
+ '#' + ROOT_ID + ' .vista-ov-actions{display:inline-flex;gap:2px;align-items:center;}',
221
+ '#' + ROOT_ID + ' .vista-ov-btn{width:28px;height:28px;padding:0;border:0;border-radius:6px;background:transparent;color:#a1a1a1;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;}',
222
+ '#' + ROOT_ID + ' .vista-ov-btn:hover{background:#171717;color:#ededed;}',
223
+ '#' + ROOT_ID + ' .vista-ov-btn svg{width:14px;height:14px;display:block;}',
224
+ '#' + ROOT_ID + ' .vista-ov-btn:focus-visible{outline:2px solid #ededed;outline-offset:1px;}',
225
+ '#' + ROOT_ID + ' .vista-ov-crumbs{height:24px;padding:0 12px;display:flex;align-items:center;background:#1e1e1e;border-bottom:1px solid #2b2b2b;color:#8b8b8b;font-size:11px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}',
226
+ '#' + ROOT_ID + ' .vista-ov-code{display:flex;flex-direction:column;flex:1;min-height:0;background:#1e1e1e;overflow:hidden;}',
227
+ '#' + ROOT_ID + ' .vista-ov-code[hidden]{display:none;}',
228
+ '#' + ROOT_ID + ' .vista-ov-editor-host{flex:1;min-height:0;overflow:auto;}',
229
+ '#' + ROOT_ID + ' .vista-error-editor{margin:0;min-height:100%;padding:8px 0 12px;font-size:13px;line-height:20px;font-family:ui-monospace,SFMono-Regular,"Cascadia Code",Menlo,Consolas,monospace;background:#1e1e1e;}',
230
+ '#' + ROOT_ID + ' .vista-error-editor-line{display:grid;grid-template-columns:56px minmax(0,1fr);min-height:20px;}',
231
+ '#' + ROOT_ID + ' .vista-error-editor-line.is-error{background:rgba(248,81,73,0.12);}',
232
+ '#' + ROOT_ID + ' .vista-error-gutter{padding:0 12px 0 0;border-right:1px solid #2b2b2b;color:#6e7681;text-align:right;user-select:none;font-variant-numeric:tabular-nums;}',
233
+ '#' + ROOT_ID + ' .vista-error-editor-line.is-error .vista-error-gutter{color:#f85149;font-weight:600;}',
234
+ '#' + ROOT_ID + ' .vista-error-source{position:relative;padding:0 16px 0 12px;color:#d4d4d4;white-space:pre;overflow:hidden;}',
235
+ '#' + ROOT_ID + ' .vista-error-squiggle{position:absolute;left:12px;bottom:0;height:4px;width:3.2ch;background-image:url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'6\' height=\'4\' viewBox=\'0 0 6 4\'%3E%3Cpath d=\'M0 3 Q1.5 0 3 3 T6 3\' fill=\'none\' stroke=\'%23f85149\' stroke-width=\'1.4\'/%3E%3C/svg%3E");background-repeat:repeat-x;background-size:6px 4px;pointer-events:none;}',
236
+ '#' + ROOT_ID + ' .vista-tok-kw{color:#c586c0;}',
237
+ '#' + ROOT_ID + ' .vista-tok-str{color:#ce9178;}',
238
+ '#' + ROOT_ID + ' .vista-tok-cmt{color:#6a9955;font-style:italic;}',
239
+ '#' + ROOT_ID + ' .vista-tok-tag{color:#4ec9b0;}',
240
+ '#' + ROOT_ID + ' .vista-tok-num{color:#b5cea8;}',
241
+ '#' + ROOT_ID + ' .vista-ov-statusbar{display:flex;align-items:center;justify-content:space-between;gap:12px;height:22px;padding:0 10px;background:#007acc;color:#fff;font-size:12px;flex-shrink:0;}',
242
+ '#' + ROOT_ID + ' .vista-ov-panel-dock{display:flex;flex-direction:column;background:#181818;border-top:1px solid #2b2b2b;overflow:hidden;flex:0 0 auto;max-height:38%;min-height:148px;}',
243
+ '#' + ROOT_ID + ' .vista-ov-panel-tabs{display:flex;align-items:center;gap:16px;height:32px;padding:0 8px 0 12px;border-bottom:1px solid #2b2b2b;color:#bbbbbb;font-size:11px;font-weight:600;letter-spacing:0.06em;flex-shrink:0;}',
244
+ '#' + ROOT_ID + ' .vista-ov-panel-tabs .is-active{color:#fff;box-shadow:inset 0 -1px 0 #fff;padding-bottom:8px;}',
245
+ '#' + ROOT_ID + ' .vista-ov-panel-toggle{margin-left:auto;}',
246
+ '#' + ROOT_ID + ' .vista-ov-panel-toggle[hidden]{display:none;}',
247
+ '#' + ROOT_ID + ' .vista-ov-panel-toggle .vista-ide-icon-restore{display:none;}',
248
+ '#' + ROOT_ID + ' .vista-ov-main[data-panel-expanded="true"] .vista-ov-tabbar,' +
249
+ '#' + ROOT_ID + ' .vista-ov-main[data-panel-expanded="true"] .vista-ov-crumbs,' +
250
+ '#' + ROOT_ID + ' .vista-ov-main[data-panel-expanded="true"] .vista-ov-code,' +
251
+ '#' + ROOT_ID + ' .vista-ov-main[data-panel-expanded="true"] .vista-ov-statusbar{display:none;}',
252
+ '#' + ROOT_ID + ' .vista-ov-main[data-panel-expanded="true"] .vista-ov-panel-dock{flex:1;max-height:none;min-height:0;border-top:0;}',
253
+ '#' + ROOT_ID + ' .vista-ov-main[data-panel-expanded="true"] .vista-ide-icon-expand{display:none;}',
254
+ '#' + ROOT_ID + ' .vista-ov-main[data-panel-expanded="true"] .vista-ide-icon-restore{display:block;}',
255
+ '#' + ROOT_ID + ' .vista-ov-main[data-terminal="true"] .vista-ov-tabbar,' +
256
+ '#' + ROOT_ID + ' .vista-ov-main[data-terminal="true"] .vista-ov-crumbs,' +
257
+ '#' + ROOT_ID + ' .vista-ov-main[data-terminal="true"] .vista-ov-code,' +
258
+ '#' + ROOT_ID + ' .vista-ov-main[data-terminal="true"] .vista-ov-statusbar{display:none;}',
259
+ '#' + ROOT_ID + ' .vista-ov-main[data-terminal="true"] .vista-ov-panel-dock{flex:1;max-height:none;min-height:0;border-top:0;}',
260
+ '#' + ROOT_ID + ' .vista-ov-main[data-terminal="true"] .vista-ov-panel-toggle{display:none;}',
261
+ '#' + ROOT_ID + ' .vista-ov-body{flex:1;min-height:0;overflow:auto;padding:10px 14px 14px;}',
262
+ '#' + ROOT_ID + ' .vista-ov-editor-host,' + '#' + ROOT_ID + ' .vista-ov-body{scrollbar-width:thin;scrollbar-color:rgba(255,255,255,0.16) transparent;}',
263
+ '#' + ROOT_ID + ' .vista-ov-editor-host::-webkit-scrollbar,' + '#' + ROOT_ID + ' .vista-ov-body::-webkit-scrollbar{width:6px;height:6px;}',
264
+ '#' + ROOT_ID + ' .vista-ov-editor-host::-webkit-scrollbar-track,' + '#' + ROOT_ID + ' .vista-ov-body::-webkit-scrollbar-track,' +
265
+ '#' + ROOT_ID + ' .vista-ov-editor-host::-webkit-scrollbar-corner,' + '#' + ROOT_ID + ' .vista-ov-body::-webkit-scrollbar-corner{background:transparent;}',
266
+ '#' + ROOT_ID + ' .vista-ov-editor-host::-webkit-scrollbar-thumb,' + '#' + ROOT_ID + ' .vista-ov-body::-webkit-scrollbar-thumb{background-color:rgba(255,255,255,0.16);border-radius:999px;}',
267
+ '#' + ROOT_ID + ' .vista-ov-editor-host::-webkit-scrollbar-thumb:hover,' + '#' + ROOT_ID + ' .vista-ov-body::-webkit-scrollbar-thumb:hover{background-color:rgba(255,255,255,0.34);}',
268
+ '#' + ROOT_ID + ' .vista-ov-kind{margin:0;color:#f85149;font-size:12px;font-weight:600;}',
269
+ '#' + ROOT_ID + ' .vista-ov-kind.is-hydration{color:#d29922;}',
270
+ '#' + ROOT_ID + ' .vista-ov-kind.is-server{color:#58a6ff;}',
271
+ '#' + ROOT_ID + ' .vista-ov-source-badge{padding:0 7px;border-radius:999px;font-size:10px;font-weight:600;letter-spacing:0.04em;text-transform:uppercase;background:rgba(255,255,255,0.12);}',
272
+ '#' + ROOT_ID + ' .vista-ov-source-badge.is-server{background:#1f6feb;}',
273
+ '#' + ROOT_ID + ' .vista-ov-source-badge.is-hydration{background:#9e6a03;}',
274
+ '#' + ROOT_ID + ' .vista-ov-source-badge.is-client{background:#238636;}',
275
+ '#' + ROOT_ID + ' .vista-ov-title{margin:6px 0 0;font-size:13px;line-height:1.5;font-weight:500;color:#e6edf3;word-break:break-word;}',
276
+ '#' + ROOT_ID + ' .vista-ov-detail{margin:6px 0 0;font-size:12px;line-height:1.5;color:#8b949e;white-space:pre-wrap;word-break:break-word;}',
277
+ '#' + ROOT_ID + ' .vista-ov-detail[hidden]{display:none;}',
278
+ '@keyframes vista-ov-in{from{opacity:0;transform:translateY(8px) scale(0.98);}to{opacity:1;transform:translateY(0) scale(1);}}',
279
+ '@media (max-width: 720px){',
280
+ ' #' + ROOT_ID + '{padding:10px;}',
281
+ '}',
282
+ ].join('');
283
+ document.head.appendChild(style);
284
+ }
285
+
286
+ function ensureMounted() {
287
+ createStyle();
288
+ if (!root) {
289
+ root = document.getElementById(ROOT_ID);
290
+ }
291
+ if (!root) {
292
+ root = document.createElement('div');
293
+ root.id = ROOT_ID;
294
+ root.hidden = true;
295
+ root.innerHTML = [
296
+ '<div class="vista-ov-backdrop"></div>',
297
+ '<section class="vista-ov-panel" role="dialog" aria-modal="true" aria-label="Vista build error overlay">',
298
+ ' <div class="vista-ov-titlebar">',
299
+ ' <div class="vista-ov-traffic" aria-hidden="true"><span class="is-close"></span><span class="is-min"></span><span class="is-max"></span></div>',
300
+ ' <div class="vista-ov-window-title">Vista — <span data-vista-tab-name>untitled</span></div>',
301
+ ' <div class="vista-ov-actions">',
302
+ ' <button type="button" class="vista-ov-btn" data-vista-copy aria-label="Copy error">',
303
+ ' <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><rect x="9" y="9" width="10" height="10" rx="2" stroke="currentColor" stroke-width="1.6"/><rect x="5" y="5" width="10" height="10" rx="2" stroke="currentColor" stroke-width="1.6"/></svg>',
304
+ ' </button>',
305
+ ' <button type="button" class="vista-ov-btn" data-vista-minimize aria-label="Minimize">',
306
+ ' <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M5 12H19" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',
307
+ ' </button>',
308
+ ' <button type="button" class="vista-ov-btn" data-vista-reload aria-label="Reload">',
309
+ ' <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"><path d="M20 11A8 8 0 1 0 12 20" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M20 4V11H13" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>',
310
+ ' </button>',
311
+ ' <div class="vista-ov-pagination" data-vista-pagination hidden>',
312
+ ' <button type="button" class="vista-ov-page-btn" data-vista-prev aria-label="Previous error">‹</button>',
313
+ ' <span class="vista-ov-page-count" data-vista-count>1/1</span>',
314
+ ' <button type="button" class="vista-ov-page-btn" data-vista-next aria-label="Next error">›</button>',
315
+ ' </div>',
316
+ ' </div>',
317
+ ' </div>',
318
+ ' <div class="vista-ov-workbench">',
319
+ ' <aside class="vista-ov-activity" aria-hidden="true"><span class="vista-ov-activity-item"><svg viewBox="0 0 24 24" fill="none"><rect x="4" y="3" width="10" height="13" rx="1.2" stroke="currentColor" stroke-width="1.6"/><rect x="10" y="8" width="10" height="13" rx="1.2" stroke="currentColor" stroke-width="1.6"/></svg></span></aside>',
320
+ ' <div class="vista-ov-main" data-vista-ide-main>',
321
+ ' <div class="vista-ov-tabbar">',
322
+ ' <div class="vista-ov-tabs" data-vista-file-tabs><button type="button" class="vista-ov-tab" data-vista-file-tab="0"><svg viewBox="0 0 16 16" fill="none" aria-hidden="true"><rect x="3" y="2" width="10" height="12" rx="1.5" stroke="#4fc1ff" stroke-width="1.4"/><path d="M6 6h4M6 9h4M6 12h2" stroke="#4fc1ff" stroke-width="1.2" stroke-linecap="round"/></svg><span data-vista-tab-name>untitled</span></button></div>',
323
+ ' </div>',
324
+ ' <div class="vista-ov-crumbs" data-vista-crumbs>Source</div>',
325
+ ' <div class="vista-ov-code" data-vista-files-wrap>',
326
+ ' <div class="vista-ov-editor-host" data-vista-message></div>',
327
+ ' </div>',
328
+ ' <div class="vista-ov-statusbar"><span data-vista-status-ln>Ready</span><span data-vista-status-lang>Plain Text</span><span class="vista-ov-source-badge" data-vista-source-badge>Build</span><span>UTF-8</span></div>',
329
+ ' <div class="vista-ov-panel-dock">',
330
+ ' <div class="vista-ov-panel-tabs"><span class="is-active">PROBLEMS</span><span>OUTPUT</span><button type="button" class="vista-ov-btn vista-ov-panel-toggle" data-vista-panel-expand aria-label="Expand problems panel" aria-pressed="false"><svg class="vista-ide-icon-expand" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M3 6.5V3h3.5M13 6.5V3h-3.5M3 9.5V13h3.5M13 9.5V13h-3.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg><svg class="vista-ide-icon-restore" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M6.5 3v3.5H3M9.5 3v3.5H13M6.5 13V9.5H3M9.5 13V9.5H13" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg></button></div>',
331
+ ' <div class="vista-ov-body">',
332
+ ' <p class="vista-ov-kind" data-vista-ov-kind>Build Error</p>',
333
+ ' <h1 class="vista-ov-title" data-vista-ov-title>Build Error</h1>',
334
+ ' <p class="vista-ov-detail" data-vista-ov-detail hidden></p>',
335
+ ' </div>',
336
+ ' </div>',
337
+ ' </div>',
338
+ ' </div>',
339
+ '</section>',
340
+ ].join('');
341
+ document.body.appendChild(root);
342
+ } else if (!root.isConnected && document.body) {
343
+ document.body.appendChild(root);
344
+ }
345
+
346
+ var backdrop = root.querySelector('.vista-ov-backdrop');
347
+ messageNode = root.querySelector('[data-vista-message]');
348
+ titleNode = root.querySelector('[data-vista-ov-title]');
349
+ detailNode = root.querySelector('[data-vista-ov-detail]');
350
+ filesWrapNode = root.querySelector('[data-vista-files-wrap]');
351
+ tabNameNodes = root.querySelectorAll('[data-vista-tab-name]');
352
+ crumbsNode = root.querySelector('[data-vista-crumbs]');
353
+ statusLnNode = root.querySelector('[data-vista-status-ln]');
354
+ statusLangNode = root.querySelector('[data-vista-status-lang]');
355
+ kindNode = root.querySelector('[data-vista-ov-kind]');
356
+ sourceBadgeNode = root.querySelector('[data-vista-source-badge]');
357
+ fileTabsNode = root.querySelector('[data-vista-file-tabs]');
358
+ copyButton = root.querySelector('[data-vista-copy]');
359
+ minimizeButton = root.querySelector('[data-vista-minimize]');
360
+ reloadButton = root.querySelector('[data-vista-reload]');
361
+ paginationNode = root.querySelector('[data-vista-pagination]');
362
+ prevButton = root.querySelector('[data-vista-prev]');
363
+ nextButton = root.querySelector('[data-vista-next]');
364
+ countNode = root.querySelector('[data-vista-count]');
365
+ mainNode = root.querySelector('[data-vista-ide-main]');
366
+ panelExpandButton = root.querySelector('[data-vista-panel-expand]');
367
+
368
+ if (listenersBound) return;
369
+ listenersBound = true;
370
+
371
+ if (fileTabsNode) {
372
+ fileTabsNode.addEventListener('click', function (event) {
373
+ var target = event.target && event.target.closest ? event.target.closest('[data-vista-file-tab]') : null;
374
+ if (!target) return;
375
+ state.fileTab = Number(target.getAttribute('data-vista-file-tab') || 0);
376
+ renderCurrent();
377
+ });
378
+ }
379
+ if (copyButton) {
380
+ copyButton.addEventListener('click', function () {
381
+ copyCurrentMessage();
382
+ });
383
+ }
384
+ if (minimizeButton) {
385
+ minimizeButton.addEventListener('click', function () {
386
+ minimize();
387
+ });
388
+ }
389
+ if (reloadButton) {
390
+ reloadButton.addEventListener('click', function () {
391
+ reloadPage();
392
+ });
393
+ }
394
+ if (prevButton) {
395
+ prevButton.addEventListener('click', function () {
396
+ moveActiveIndex(-1);
397
+ });
398
+ }
399
+ if (nextButton) {
400
+ nextButton.addEventListener('click', function () {
401
+ moveActiveIndex(1);
402
+ });
403
+ }
404
+ if (panelExpandButton && mainNode) {
405
+ panelExpandButton.addEventListener('click', function () {
406
+ if (mainNode.getAttribute('data-terminal') === 'true') return;
407
+ var expanded = mainNode.getAttribute('data-panel-expanded') === 'true';
408
+ if (expanded) {
409
+ mainNode.removeAttribute('data-panel-expanded');
410
+ panelExpandButton.setAttribute('aria-pressed', 'false');
411
+ panelExpandButton.setAttribute('aria-label', 'Expand problems panel');
412
+ } else {
413
+ mainNode.setAttribute('data-panel-expanded', 'true');
414
+ panelExpandButton.setAttribute('aria-pressed', 'true');
415
+ panelExpandButton.setAttribute('aria-label', 'Restore problems panel');
416
+ }
417
+ });
418
+ }
419
+ if (backdrop) {
420
+ backdrop.addEventListener('click', function () {
421
+ minimize();
422
+ });
423
+ }
424
+ if (root) {
425
+ root.addEventListener('keydown', function (event) {
426
+ if (event.key === 'ArrowLeft') {
427
+ moveActiveIndex(-1);
428
+ } else if (event.key === 'ArrowRight') {
429
+ moveActiveIndex(1);
430
+ } else if (event.key === 'Escape') {
431
+ if (mainNode && mainNode.getAttribute('data-panel-expanded') === 'true' && mainNode.getAttribute('data-terminal') !== 'true') {
432
+ mainNode.removeAttribute('data-panel-expanded');
433
+ if (panelExpandButton) {
434
+ panelExpandButton.setAttribute('aria-pressed', 'false');
435
+ panelExpandButton.setAttribute('aria-label', 'Expand problems panel');
436
+ }
437
+ return;
438
+ }
439
+ minimize();
440
+ }
441
+ });
442
+ }
443
+ }
444
+
445
+ function normalizeMessages(input) {
446
+ if (Array.isArray(input)) {
447
+ return input
448
+ .map(function (entry) {
449
+ return typeof entry === 'string' ? entry : String(entry || '');
450
+ })
451
+ .filter(function (entry) {
452
+ return entry.trim().length > 0;
453
+ });
454
+ }
455
+
456
+ if (input && typeof input === 'object' && Array.isArray(input.errors)) {
457
+ return normalizeMessages(input.errors);
458
+ }
459
+
460
+ var raw = typeof input === 'string' ? input : String(input || '');
461
+ if (raw.trim().length === 0) {
462
+ return [];
463
+ }
464
+
465
+ var splitByWebpack = raw.split(/\n(?=ERROR in\s)/g).filter(function (entry) {
466
+ return entry.trim().length > 0;
467
+ });
468
+ if (splitByWebpack.length > 1) {
469
+ return splitByWebpack;
470
+ }
471
+ return [raw];
472
+ }
473
+
474
+ function parseMessage(input) {
475
+ var raw = typeof input === 'string' ? input : String(input || 'Unknown build error.');
476
+ var lines = raw.split(/\r?\n/);
477
+ var trimmedLines = [];
478
+ for (var i = 0; i < lines.length; i += 1) {
479
+ var entry = lines[i] ? lines[i].trim() : '';
480
+ if (entry.length > 0) {
481
+ trimmedLines.push(entry);
482
+ }
483
+ }
484
+
485
+ var title = trimmedLines.length ? trimmedLines[0] : 'Build Error';
486
+ if (title.length > 140) {
487
+ title = title.slice(0, 137) + '...';
488
+ }
489
+
490
+ var files = [];
491
+ var filePattern = /(?:[A-Za-z]:)?[\\/\w.@-]+\.(?:tsx?|jsx?|mjs|cjs|css|json|mdx?)(?::\d+(?::\d+)?)?/;
492
+ for (var fileIdx = 0; fileIdx < lines.length; fileIdx += 1) {
493
+ var maybeFile = lines[fileIdx].match(filePattern);
494
+ if (!maybeFile) continue;
495
+ var normalized = maybeFile[0].replace(/\\/g, '/').replace(/^\.\//, '');
496
+ if (files.indexOf(normalized) === -1) {
497
+ files.push(normalized);
498
+ }
499
+ if (files.length >= 5) break;
500
+ }
501
+
502
+ var hints = [];
503
+ if (/['"]use client['"]/.test(raw)) {
504
+ hints.push("Client hook detected in a Server Component. Add 'use client' to the top of that file.");
505
+ }
506
+ if (/Cannot find module/i.test(raw) || /Module not found/i.test(raw)) {
507
+ hints.push('A module import failed to resolve. Check the import path or install the missing package.');
508
+ }
509
+ if (/Unexpected token/i.test(raw) || /SyntaxError/i.test(raw)) {
510
+ hints.push('A syntax issue is blocking compilation. Start from the first highlighted file and fix parsing errors.');
511
+ }
512
+ if (/Type error/i.test(raw) || /TS\d{3,5}/i.test(raw)) {
513
+ hints.push('TypeScript validation failed. Fix the first type error first to reduce cascading issues.');
514
+ }
515
+ if (/Structure Validation Failed/i.test(raw)) {
516
+ hints.push('App structure rules failed. Verify route files, layout/page naming, and required conventions.');
517
+ }
518
+ if (hints.length === 0 && files.length > 0) {
519
+ hints.push('Start with the first file above, then re-run after each fix.');
520
+ }
521
+ if (hints.length === 0) {
522
+ hints.push('Resolve the top-most failure first, then reload to see remaining issues.');
523
+ }
524
+
525
+ var kind = 'build';
526
+ if (/hydration/i.test(title) || /hydration|did not match|server rendered html/i.test(raw)) {
527
+ kind = 'hydration';
528
+ } else if (/server error|flight ssr/i.test(title + ' ' + raw)) {
529
+ kind = 'server';
530
+ } else if (/runtime|unhandled promise/i.test(title)) {
531
+ kind = 'runtime';
532
+ }
533
+
534
+ return {
535
+ raw: raw,
536
+ title: title,
537
+ files: files,
538
+ hints: hints,
539
+ kind: kind,
540
+ timestamp: new Date(),
541
+ };
542
+ }
543
+
544
+ function fillList(node, values, wrapNode) {
545
+ if (!node) return;
546
+ while (node.firstChild) node.removeChild(node.firstChild);
547
+ if (!values || values.length === 0) {
548
+ if (wrapNode) wrapNode.hidden = false;
549
+ return;
550
+ }
551
+ for (var i = 0; i < values.length; i += 1) {
552
+ var item = document.createElement('li');
553
+ item.textContent = values[i];
554
+ node.appendChild(item);
555
+ }
556
+ if (wrapNode) wrapNode.hidden = false;
557
+ }
558
+
559
+ function currentEntry() {
560
+ if (!state.entries || state.entries.length === 0) return null;
561
+ var index = state.activeIndex;
562
+ if (index < 0) index = 0;
563
+ if (index > state.entries.length - 1) index = state.entries.length - 1;
564
+ return state.entries[index];
565
+ }
566
+
567
+ function updatePagination() {
568
+ var total = state.entries.length;
569
+ var current = total === 0 ? 0 : state.activeIndex + 1;
570
+ if (countNode) {
571
+ countNode.textContent = current + '/' + (total || 1);
572
+ }
573
+ if (paginationNode) {
574
+ paginationNode.hidden = total <= 1;
575
+ }
576
+ if (prevButton) {
577
+ prevButton.disabled = state.activeIndex <= 0;
578
+ }
579
+ if (nextButton) {
580
+ nextButton.disabled = state.activeIndex >= total - 1;
581
+ }
582
+ }
583
+
584
+ function entryHasCode(parsed) {
585
+ if (!parsed) return false;
586
+ if (parsed.kind === 'server' || parsed.kind === 'hydration') return false;
587
+ return /(\s*>)?\s*\d+\s+\|/.test(String(parsed.raw || ''));
588
+ }
589
+
590
+ function renderCurrent() {
591
+ var parsed = currentEntry();
592
+ if (!parsed || !root) return;
593
+ var files = parsed.files && parsed.files.length ? parsed.files : [''];
594
+ if (state.fileTab > files.length - 1) state.fileTab = 0;
595
+ var file = files[state.fileTab] || files[0] || '';
596
+ var loc = parseFileLocation(file);
597
+ var tabName = fileBasename(file);
598
+ var kind = parsed.kind || 'build';
599
+ var kindLabel = kind === 'hydration' ? 'Hydration Error' : kind === 'server' ? 'Server Error' : kind === 'runtime' ? 'Unhandled Runtime Error' : 'Build Error';
600
+ var badge = kind === 'hydration' ? 'Hydration' : kind === 'server' ? 'Server' : kind === 'runtime' ? 'Client' : 'Build';
601
+ var terminal = !entryHasCode(parsed);
602
+ var titleName = terminal ? kindLabel : tabName;
603
+ if (kindNode) {
604
+ kindNode.textContent = kindLabel;
605
+ kindNode.className = 'vista-ov-kind' + (kind === 'hydration' || kind === 'server' ? ' is-' + kind : '');
606
+ }
607
+ if (titleNode) titleNode.textContent = parsed.title || 'Build Error';
608
+ if (detailNode) {
609
+ var hintText = (parsed.hints || []).join(' ');
610
+ if (kind === 'hydration' && hintText.indexOf('HTML') === -1) {
611
+ hintText = 'Server HTML did not match the client. ' + hintText;
612
+ }
613
+ detailNode.textContent = hintText;
614
+ detailNode.hidden = hintText.length === 0;
615
+ }
616
+ if (fileTabsNode) {
617
+ var tabs = '';
618
+ for (var i = 0; i < files.length; i += 1) {
619
+ var name = fileBasename(files[i] || 'untitled');
620
+ tabs += '<button type="button" class="vista-ov-tab' + (i === state.fileTab ? '' : ' is-inactive') + '" data-vista-file-tab="' + i + '">';
621
+ tabs += '<svg viewBox="0 0 16 16" fill="none" aria-hidden="true"><rect x="3" y="2" width="10" height="12" rx="1.5" stroke="#4fc1ff" stroke-width="1.4"/><path d="M6 6h4M6 9h4M6 12h2" stroke="#4fc1ff" stroke-width="1.2" stroke-linecap="round"/></svg>';
622
+ tabs += '<span>' + escapeHtml(name) + '</span></button>';
623
+ }
624
+ fileTabsNode.innerHTML = tabs;
625
+ }
626
+ if (tabNameNodes) {
627
+ for (var t = 0; t < tabNameNodes.length; t += 1) {
628
+ if (tabNameNodes[t].closest && tabNameNodes[t].closest('[data-vista-file-tabs]')) continue;
629
+ tabNameNodes[t].textContent = titleName;
630
+ }
631
+ }
632
+ if (crumbsNode) crumbsNode.textContent = fileBreadcrumb(file);
633
+ if (statusLnNode) statusLnNode.textContent = loc.line ? ('Ln ' + loc.line + ', Col ' + loc.column) : 'Ready';
634
+ if (statusLangNode) statusLangNode.textContent = languageFromFile(file);
635
+ if (sourceBadgeNode) {
636
+ sourceBadgeNode.textContent = badge;
637
+ sourceBadgeNode.className = 'vista-ov-source-badge' + (kind === 'build' ? '' : ' is-' + (kind === 'runtime' ? 'client' : kind));
638
+ }
639
+ if (messageNode) messageNode.innerHTML = renderIdeCode(parsed.raw, loc.line, loc.column);
640
+ if (filesWrapNode) filesWrapNode.hidden = false;
641
+ if (mainNode) {
642
+ if (terminal) {
643
+ mainNode.setAttribute('data-terminal', 'true');
644
+ mainNode.removeAttribute('data-panel-expanded');
645
+ } else {
646
+ mainNode.removeAttribute('data-terminal');
647
+ }
648
+ }
649
+ if (panelExpandButton) {
650
+ panelExpandButton.hidden = terminal;
651
+ if (terminal) {
652
+ panelExpandButton.setAttribute('aria-pressed', 'false');
653
+ panelExpandButton.setAttribute('aria-label', 'Expand problems panel');
654
+ }
655
+ }
656
+ updatePagination();
657
+ }
658
+
659
+ function moveActiveIndex(offset) {
660
+ if (!state.entries || state.entries.length <= 1) return;
661
+ var next = state.activeIndex + offset;
662
+ if (next < 0 || next >= state.entries.length) return;
663
+ state.activeIndex = next;
664
+ state.fileTab = 0;
665
+ renderCurrent();
666
+ }
667
+
668
+ function copyCurrentMessage() {
669
+ var entry = currentEntry();
670
+ if (!entry) return;
671
+ var text = entry.raw;
672
+ if (navigator && navigator.clipboard && navigator.clipboard.writeText) {
673
+ navigator.clipboard.writeText(text).catch(function () {});
674
+ return;
675
+ }
676
+ var textarea = document.createElement('textarea');
677
+ textarea.value = text;
678
+ textarea.style.position = 'fixed';
679
+ textarea.style.opacity = '0';
680
+ textarea.style.pointerEvents = 'none';
681
+ document.body.appendChild(textarea);
682
+ textarea.focus();
683
+ textarea.select();
684
+ try {
685
+ document.execCommand('copy');
686
+ } catch (e) {}
687
+ document.body.removeChild(textarea);
688
+ }
689
+
690
+ function reloadPage() {
691
+ if (typeof window === 'undefined') return;
692
+ window.location.reload();
693
+ }
694
+
695
+ function openFromState() {
696
+ ensureMounted();
697
+ if (!state.entries || state.entries.length === 0) return false;
698
+ state.open = true;
699
+ state.minimized = false;
700
+ renderCurrent();
701
+ if (root) root.hidden = false;
702
+ var indicator = getIndicator();
703
+ if (indicator && typeof indicator.clearError === 'function') {
704
+ indicator.clearError();
705
+ }
706
+ return true;
707
+ }
708
+
709
+ function show(input) {
710
+ ensureMounted();
711
+ var messages = normalizeMessages(input);
712
+ if (messages.length === 0) {
713
+ return;
714
+ }
715
+ state.entries = messages.map(function (message) {
716
+ return parseMessage(message);
717
+ });
718
+ state.activeIndex = 0;
719
+ openFromState();
720
+ }
721
+
722
+ function capture(input) {
723
+ ensureMounted();
724
+ var messages = normalizeMessages(input);
725
+ if (messages.length === 0) {
726
+ return;
727
+ }
728
+ state.entries = messages.map(function (message) {
729
+ return parseMessage(message);
730
+ });
731
+ state.activeIndex = 0;
732
+ state.open = false;
733
+ state.minimized = true;
734
+ if (root) root.hidden = true;
735
+ var entry = currentEntry();
736
+ var indicator = getIndicator();
737
+ if (indicator && typeof indicator.setError === 'function') {
738
+ indicator.setError(entry ? entry.title || 'Build error' : 'Build error', state.entries.length);
739
+ }
740
+ }
741
+
742
+ function minimize() {
743
+ var entry = currentEntry();
744
+ if (!entry) return false;
745
+ ensureMounted();
746
+ state.open = false;
747
+ state.minimized = true;
748
+ if (root) root.hidden = true;
749
+ var indicator = getIndicator();
750
+ if (indicator && typeof indicator.setError === 'function') {
751
+ indicator.setError(entry.title || 'Build error', state.entries.length);
752
+ }
753
+ return true;
754
+ }
755
+
756
+ function clear() {
757
+ state.open = false;
758
+ state.minimized = false;
759
+ state.entries = [];
760
+ state.activeIndex = 0;
761
+ if (root) root.hidden = true;
762
+ var indicator = getIndicator();
763
+ if (indicator && typeof indicator.clearError === 'function') {
764
+ indicator.clearError();
765
+ }
766
+ }
767
+
768
+ function restoreFromIndicator() {
769
+ if (!state.minimized || !state.entries || state.entries.length === 0) return false;
770
+ return openFromState();
771
+ }
772
+
773
+ window.__VISTA_DEV_ERROR_OVERLAY__ = {
774
+ show: show,
775
+ capture: capture,
776
+ minimize: minimize,
777
+ clear: clear,
778
+ restoreFromIndicator: restoreFromIndicator,
779
+ isOpen: function () {
780
+ return state.open;
781
+ },
782
+ hasError: function () {
783
+ return state.entries && state.entries.length > 0;
784
+ },
785
+ };
786
+ })();
561
787
  `;
562
788
  }