castle-web-cli 0.4.104 → 0.4.105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/agent-failures.d.ts
CHANGED
|
@@ -11,6 +11,12 @@ export interface AgentFailure {
|
|
|
11
11
|
}
|
|
12
12
|
export declare function failureForStatus(status: number, body: string, model?: string): AgentFailure | undefined;
|
|
13
13
|
export declare function classifyProviderError(text: string | undefined, model?: string): AgentFailure | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Record the reader's IANA zone. Junk is ignored rather than stored: an invalid
|
|
16
|
+
* zone makes toLocaleTimeString throw, and the one place that formatting runs is
|
|
17
|
+
* the error path, which must not fail.
|
|
18
|
+
*/
|
|
19
|
+
export declare function setReaderTimeZone(zone: string): void;
|
|
14
20
|
export declare function failureCopy(opts: {
|
|
15
21
|
failure: AgentFailure;
|
|
16
22
|
spawnedTasks: boolean;
|
package/dist/agent-failures.js
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
// what's wrong and points at settings / Castle.
|
|
11
11
|
// limit - Castle's daily AI allowance for this user is spent. Nothing to
|
|
12
12
|
// fix in the session and nothing to retry until the reset, so the
|
|
13
|
-
// copy gives the time and the one way
|
|
13
|
+
// copy gives the time (see setReaderTimeZone) and the one way
|
|
14
|
+
// around it (own credential).
|
|
14
15
|
// transient - the provider was busy or broke. NOT auto-retried either (see
|
|
15
16
|
// below), but the copy invites the user to send again.
|
|
16
17
|
// no-work - the model answered instead of working. Config is fine; the
|
|
@@ -98,6 +99,41 @@ export function classifyProviderError(text, model) {
|
|
|
98
99
|
function quoted(model) {
|
|
99
100
|
return model ? `"${model}"` : "the model this session is set to";
|
|
100
101
|
}
|
|
102
|
+
// The zone the person reading the copy is in, as the shell reported it on
|
|
103
|
+
// connect. Module state rather than a parameter because it is a property of the
|
|
104
|
+
// one reader this serve has, not of any particular failure, and every call site
|
|
105
|
+
// would otherwise thread it through a ctx that has no other reason to know.
|
|
106
|
+
let readerTimeZone;
|
|
107
|
+
/**
|
|
108
|
+
* Record the reader's IANA zone. Junk is ignored rather than stored: an invalid
|
|
109
|
+
* zone makes toLocaleTimeString throw, and the one place that formatting runs is
|
|
110
|
+
* the error path, which must not fail.
|
|
111
|
+
*/
|
|
112
|
+
export function setReaderTimeZone(zone) {
|
|
113
|
+
try {
|
|
114
|
+
new Intl.DateTimeFormat(undefined, { timeZone: zone });
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
readerTimeZone = zone;
|
|
120
|
+
}
|
|
121
|
+
// The reset is a Pacific midnight and this process runs on the sandbox's clock
|
|
122
|
+
// (UTC), so a server-local time is wrong for every reader. Format in the zone
|
|
123
|
+
// the shell reported; with none reported, name the zone we did use rather than
|
|
124
|
+
// print a bare time that reads as local and isn't.
|
|
125
|
+
function resetsClause(atMs) {
|
|
126
|
+
if (!atMs)
|
|
127
|
+
return "";
|
|
128
|
+
const time = new Date(atMs).toLocaleTimeString(undefined, {
|
|
129
|
+
hour: "numeric",
|
|
130
|
+
minute: "2-digit",
|
|
131
|
+
...(readerTimeZone
|
|
132
|
+
? { timeZone: readerTimeZone }
|
|
133
|
+
: { timeZoneName: "short" }),
|
|
134
|
+
});
|
|
135
|
+
return ` -- resets ${time}`;
|
|
136
|
+
}
|
|
101
137
|
// Plain-language copy for a failed run. Deliberately ONE table rather than a
|
|
102
138
|
// router copy and a task copy: the sentences would be near-identical, and the
|
|
103
139
|
// duplicate-detection gate (jscpd, threshold 0) is right to reject that.
|
|
@@ -140,12 +176,8 @@ export function failureCopy(opts) {
|
|
|
140
176
|
switch (opts.failure.kind) {
|
|
141
177
|
case "config":
|
|
142
178
|
return `${configCopy(opts.failure)}${tasksNote}`;
|
|
143
|
-
case "limit":
|
|
144
|
-
|
|
145
|
-
? ` -- resets ${new Date(opts.failure.resetAtMs).toLocaleString()}`
|
|
146
|
-
: "";
|
|
147
|
-
return `Daily Castle AI limit reached${resets}. Runs on your own API key or login aren't limited.${tasksNote}`;
|
|
148
|
-
}
|
|
179
|
+
case "limit":
|
|
180
|
+
return `Daily Castle AI limit reached${resetsClause(opts.failure.resetAtMs)}. Runs on your own API key or login aren't limited.${tasksNote}`;
|
|
149
181
|
case "transient":
|
|
150
182
|
return `OpenRouter is busy right now and I couldn't get through. Send that again in a moment.${tasksNote}`;
|
|
151
183
|
case "no-work":
|
package/dist/agent.js
CHANGED
|
@@ -23,7 +23,7 @@ import { WebSocketServer } from "ws";
|
|
|
23
23
|
import { rawDataToString } from "./ide.js";
|
|
24
24
|
import { buildRouterPrompt, buildTaskPrompt, userTurnInstruction, CLAUDE_TASK_SYSTEM_REMINDER, } from "./agent-prompts.js";
|
|
25
25
|
import { checkOpenrouterKey, checkOpenrouterModel, openrouterCatalogEntry, primeOpenrouterCatalog, } from "./openrouter-catalog.js";
|
|
26
|
-
import { classifyProviderError, failureCopy, } from "./agent-failures.js";
|
|
26
|
+
import { classifyProviderError, failureCopy, setReaderTimeZone, } from "./agent-failures.js";
|
|
27
27
|
import { fetchBudget, meteringHeaders, newAgentSessionId, reportCursorRun, withCustomHeaders, } from "./metering.js";
|
|
28
28
|
import { anthropicKeyHelperCommand, claudeHasSavedLogin, resolveAnthropicAuth, userKey, ANTHROPIC_CREDENTIAL_ENV, ANTHROPIC_PROXY_ENV, CASTLE_USER_KEYS_PATH, } from "./byo-auth.js";
|
|
29
29
|
import { runAgentNative } from "./native/loop.js";
|
|
@@ -41,12 +41,14 @@ export const AGENT_MODEL_CAPS_PREFIX = "/__castle/agent/model-caps";
|
|
|
41
41
|
const DEFAULT_SETTINGS = {
|
|
42
42
|
router: "claude",
|
|
43
43
|
tasks: "claude",
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
|
|
44
|
+
// Both roles run the claude CLI routed through OpenRouter at the slug below.
|
|
45
|
+
// Note this takes the Anthropic credential out of play entirely: a role on
|
|
46
|
+
// "openrouter" resolves OpenRouter auth, so a user's `claude /login` or
|
|
47
|
+
// ANTHROPIC_API_KEY no longer applies (see buildAgentInvocation).
|
|
48
|
+
routerClaudeModel: "openrouter",
|
|
49
|
+
tasksClaudeModel: "openrouter",
|
|
48
50
|
// Free-form -- change to any OpenRouter slug.
|
|
49
|
-
routerOpenrouterModel: "openai/gpt-5.6-
|
|
51
|
+
routerOpenrouterModel: "openai/gpt-5.6-terra",
|
|
50
52
|
tasksOpenrouterModel: "openai/gpt-5.6-terra",
|
|
51
53
|
// Both roles think at "medium": the operator stays snappy (the user waits
|
|
52
54
|
// on every operator turn), and task agents' multi-turn tool loops don't pay
|
|
@@ -60,10 +62,10 @@ const DEFAULT_SETTINGS = {
|
|
|
60
62
|
// which matters for tool-calling fidelity over long loops).
|
|
61
63
|
routerRouting: "nitro",
|
|
62
64
|
tasksRouting: "exacto",
|
|
63
|
-
// Operator pins OpenAI's priority (low-latency SLA) tier
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
65
|
+
// Operator pins OpenAI's priority (low-latency SLA) tier; harmless with a
|
|
66
|
+
// slug that lacks it since the pin falls back when the tag doesn't exist
|
|
67
|
+
// (allow_fallbacks). Tasks stay on auto: high-volume background turns
|
|
68
|
+
// should ride the cheapest available capacity.
|
|
67
69
|
routerProviderTier: "openai/priority",
|
|
68
70
|
tasksProviderTier: "",
|
|
69
71
|
};
|
|
@@ -72,16 +74,14 @@ function normalizeBackend(value) {
|
|
|
72
74
|
? value
|
|
73
75
|
: null;
|
|
74
76
|
}
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return normalizeBackend(value);
|
|
84
|
-
}
|
|
77
|
+
// Bump to force every deck onto the current DEFAULT_SETTINGS once, discarding
|
|
78
|
+
// what users had chosen: a stored file below this epoch has ALL of its setting
|
|
79
|
+
// fields dropped on load (see loadAgentSettings). Bump ONLY when a default
|
|
80
|
+
// change is meant to override existing choices -- an ordinary one needs no
|
|
81
|
+
// bump, since sparse storage already reaches anyone who never set that field.
|
|
82
|
+
// The wipe is also what retires older file shapes, so a migration for one is
|
|
83
|
+
// only worth writing if it must survive the epoch that introduces it.
|
|
84
|
+
const SETTINGS_EPOCH = 1;
|
|
85
85
|
function normalizeClaudeModel(value) {
|
|
86
86
|
return value === "sonnet" ||
|
|
87
87
|
value === "opus" ||
|
|
@@ -141,6 +141,60 @@ function normalizeProviderTier(value) {
|
|
|
141
141
|
return null;
|
|
142
142
|
return trimmed;
|
|
143
143
|
}
|
|
144
|
+
// Every setting's validator, keyed the same as AgentSettings, so load and save
|
|
145
|
+
// iterate one list rather than repeating the field names per direction.
|
|
146
|
+
const SETTING_NORMALIZERS = {
|
|
147
|
+
router: normalizeBackend,
|
|
148
|
+
tasks: normalizeBackend,
|
|
149
|
+
routerClaudeModel: normalizeClaudeModel,
|
|
150
|
+
tasksClaudeModel: normalizeClaudeModel,
|
|
151
|
+
routerOpenrouterModel: normalizeOpenrouterModel,
|
|
152
|
+
tasksOpenrouterModel: normalizeOpenrouterModel,
|
|
153
|
+
routerReasoningEffort: normalizeReasoningEffort,
|
|
154
|
+
tasksReasoningEffort: normalizeReasoningEffort,
|
|
155
|
+
routerRouting: normalizeRoutingMode,
|
|
156
|
+
tasksRouting: normalizeRoutingMode,
|
|
157
|
+
routerProviderTier: normalizeProviderTier,
|
|
158
|
+
tasksProviderTier: normalizeProviderTier,
|
|
159
|
+
};
|
|
160
|
+
const SETTING_KEYS = Object.keys(SETTING_NORMALIZERS);
|
|
161
|
+
// Sparse ON PURPOSE: only fields that DIFFER from the current defaults are
|
|
162
|
+
// stored, so "absent" means "follow the default" and a later default change
|
|
163
|
+
// reaches every deck that never set that field. Writing the full object
|
|
164
|
+
// instead (as this once did) froze all 12 settings the first time a user
|
|
165
|
+
// touched any one of them, pinning models nobody had chosen.
|
|
166
|
+
//
|
|
167
|
+
// The flip side, accepted: re-selecting the value that is currently the
|
|
168
|
+
// default stores nothing, so that deck moves when the default moves. Nothing
|
|
169
|
+
// is lost relative to the old behavior -- applyAgentSettings already
|
|
170
|
+
// early-returns on a no-op change, so that click never persisted anything.
|
|
171
|
+
function serializeAgentSettings(settings) {
|
|
172
|
+
const out = { settingsEpoch: SETTINGS_EPOCH };
|
|
173
|
+
for (const key of SETTING_KEYS) {
|
|
174
|
+
if (settings[key] !== DEFAULT_SETTINGS[key])
|
|
175
|
+
out[key] = settings[key];
|
|
176
|
+
}
|
|
177
|
+
return JSON.stringify(out, null, 2) + "\n";
|
|
178
|
+
}
|
|
179
|
+
function loadAgentSettings(settingsPath) {
|
|
180
|
+
const stored = readJsonFile(settingsPath);
|
|
181
|
+
const storedEpoch = typeof stored?.settingsEpoch === "number" ? stored.settingsEpoch : 0;
|
|
182
|
+
// A stale file is ignored, not rewritten: leaving it means the wipe is a
|
|
183
|
+
// pure read-side decision that repeats harmlessly until the user's next real
|
|
184
|
+
// change overwrites it in the sparse shape. A newer epoch (a downgraded CLI
|
|
185
|
+
// reading a file from a newer one) is honored rather than wiped.
|
|
186
|
+
if (!stored || storedEpoch < SETTINGS_EPOCH)
|
|
187
|
+
return { ...DEFAULT_SETTINGS };
|
|
188
|
+
const overrides = {};
|
|
189
|
+
for (const key of SETTING_KEYS) {
|
|
190
|
+
if (!(key in stored))
|
|
191
|
+
continue;
|
|
192
|
+
const value = SETTING_NORMALIZERS[key](stored[key]);
|
|
193
|
+
if (value !== null)
|
|
194
|
+
overrides[key] = value;
|
|
195
|
+
}
|
|
196
|
+
return { ...DEFAULT_SETTINGS, ...overrides };
|
|
197
|
+
}
|
|
144
198
|
// Base for OpenRouter's Anthropic-compatible endpoint (confirmed current, 2026: it
|
|
145
199
|
// accepts the standard Anthropic Messages API shape -- text/tool-use/extended-thinking
|
|
146
200
|
// -- for ANY OpenRouter model slug, not just Anthropic ones), which the claude CLI
|
|
@@ -2974,7 +3028,7 @@ function applyAgentSettings(incoming, ctx) {
|
|
|
2974
3028
|
}
|
|
2975
3029
|
if (changes.length === 0)
|
|
2976
3030
|
return;
|
|
2977
|
-
fs.writeFileSync(ctx.settingsPath,
|
|
3031
|
+
fs.writeFileSync(ctx.settingsPath, serializeAgentSettings(settings));
|
|
2978
3032
|
// The value is saved and broadcast IMMEDIATELY -- validation never gates a
|
|
2979
3033
|
// write. The verdict follows in a second frame once the catalog answers.
|
|
2980
3034
|
ctx.broadcast({ type: "settings", settings });
|
|
@@ -3448,59 +3502,7 @@ export function createAgentServer(opts) {
|
|
|
3448
3502
|
// Which CLI backs the router and the task agents -- independently
|
|
3449
3503
|
// switchable from the settings popover, persisted next to the chat state.
|
|
3450
3504
|
const settingsPath = path.join(agentDir, "settings.json");
|
|
3451
|
-
|
|
3452
|
-
// types no longer admit (backend "openrouter", single openrouterModel /
|
|
3453
|
-
// claudeModel) -- every field goes through a normalizer/migrator below.
|
|
3454
|
-
const storedSettings = readJsonFile(settingsPath);
|
|
3455
|
-
// Three legacy shapes migrate on load, chained oldest-first (rewritten in
|
|
3456
|
-
// the new shape on the next settings change):
|
|
3457
|
-
// - a single `openrouterModel` (pre per-role split) seeds BOTH per-role
|
|
3458
|
-
// slug fields;
|
|
3459
|
-
// - a single shared `claudeModel` (pre per-role split) seeds BOTH per-role
|
|
3460
|
-
// claude-model fields;
|
|
3461
|
-
// - backend value "openrouter" ON A ROLE (pre-smith: it meant that role
|
|
3462
|
-
// ran claude-via-OpenRouter) becomes backend "claude" + THAT role's
|
|
3463
|
-
// claude model "openrouter" -- exactly that behavior today, and now
|
|
3464
|
-
// per-role: one legacy openrouter role no longer drags the other role's
|
|
3465
|
-
// model along.
|
|
3466
|
-
const legacyOpenrouterModel = normalizeOpenrouterModel(storedSettings?.openrouterModel);
|
|
3467
|
-
const legacySharedClaudeModel = normalizeClaudeModel(storedSettings?.claudeModel);
|
|
3468
|
-
const roleClaudeModel = (role) => {
|
|
3469
|
-
// A stored per-role value wins; a legacy openrouter BACKEND on this role
|
|
3470
|
-
// forces "openrouter" (those two never coexist in one file -- per-role
|
|
3471
|
-
// fields postdate the openrouter backend's removal); else the legacy
|
|
3472
|
-
// shared claudeModel, else the default.
|
|
3473
|
-
return (normalizeClaudeModel(storedSettings?.[`${role}ClaudeModel`]) ??
|
|
3474
|
-
(storedSettings?.[role] === "openrouter"
|
|
3475
|
-
? "openrouter"
|
|
3476
|
-
: (legacySharedClaudeModel ?? DEFAULT_SETTINGS[`${role}ClaudeModel`])));
|
|
3477
|
-
};
|
|
3478
|
-
const settings = {
|
|
3479
|
-
router: migrateStoredBackend(storedSettings?.router) ?? DEFAULT_SETTINGS.router,
|
|
3480
|
-
tasks: migrateStoredBackend(storedSettings?.tasks) ?? DEFAULT_SETTINGS.tasks,
|
|
3481
|
-
routerClaudeModel: roleClaudeModel("router"),
|
|
3482
|
-
tasksClaudeModel: roleClaudeModel("tasks"),
|
|
3483
|
-
routerOpenrouterModel: normalizeOpenrouterModel(storedSettings?.routerOpenrouterModel) ??
|
|
3484
|
-
legacyOpenrouterModel ??
|
|
3485
|
-
DEFAULT_SETTINGS.routerOpenrouterModel,
|
|
3486
|
-
tasksOpenrouterModel: normalizeOpenrouterModel(storedSettings?.tasksOpenrouterModel) ??
|
|
3487
|
-
legacyOpenrouterModel ??
|
|
3488
|
-
DEFAULT_SETTINGS.tasksOpenrouterModel,
|
|
3489
|
-
routerReasoningEffort: normalizeReasoningEffort(storedSettings?.routerReasoningEffort) ??
|
|
3490
|
-
DEFAULT_SETTINGS.routerReasoningEffort,
|
|
3491
|
-
tasksReasoningEffort: normalizeReasoningEffort(storedSettings?.tasksReasoningEffort) ??
|
|
3492
|
-
DEFAULT_SETTINGS.tasksReasoningEffort,
|
|
3493
|
-
routerRouting: normalizeRoutingMode(storedSettings?.routerRouting) ??
|
|
3494
|
-
DEFAULT_SETTINGS.routerRouting,
|
|
3495
|
-
tasksRouting: normalizeRoutingMode(storedSettings?.tasksRouting) ??
|
|
3496
|
-
DEFAULT_SETTINGS.tasksRouting,
|
|
3497
|
-
// Provider tier: "" is valid (auto), so keep a normalized "" over the
|
|
3498
|
-
// default rather than treating it as absent.
|
|
3499
|
-
routerProviderTier: normalizeProviderTier(storedSettings?.routerProviderTier) ??
|
|
3500
|
-
DEFAULT_SETTINGS.routerProviderTier,
|
|
3501
|
-
tasksProviderTier: normalizeProviderTier(storedSettings?.tasksProviderTier) ??
|
|
3502
|
-
DEFAULT_SETTINGS.tasksProviderTier,
|
|
3503
|
-
};
|
|
3505
|
+
const settings = loadAgentSettings(settingsPath);
|
|
3504
3506
|
const usageFeed = createUsageFeed({
|
|
3505
3507
|
broadcast,
|
|
3506
3508
|
hasClients: () => clients.size > 0,
|
|
@@ -3623,6 +3625,9 @@ export function createAgentServer(opts) {
|
|
|
3623
3625
|
else if (msg.type === "set-settings") {
|
|
3624
3626
|
applySettings(msg);
|
|
3625
3627
|
}
|
|
3628
|
+
else if (msg.type === "client-timezone" && typeof msg.timeZone === "string") {
|
|
3629
|
+
setReaderTimeZone(msg.timeZone);
|
|
3630
|
+
}
|
|
3626
3631
|
});
|
|
3627
3632
|
socket.on("close", () => {
|
|
3628
3633
|
clients.delete(socket);
|
|
@@ -7,7 +7,7 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
|
7
7
|
Error generating stack: `+e.message+`
|
|
8
8
|
`+e.stack}return{value:e,source:t,stack:i,digest:null}}function Ls(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Rs(e,t){try{console.error(t.value)}catch(e){setTimeout(function(){throw e})}}var zs=typeof WeakMap==`function`?WeakMap:Map;function Bs(e,t,n){n=fo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){_l||(_l=!0,vl=r),Rs(e,t)},n}function Vs(e,t,n){n=fo(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r==`function`){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Rs(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch==`function`&&(n.callback=function(){Rs(e,t),typeof r!=`function`&&(yl===null?yl=new Set([this]):yl.add(this));var n=t.stack;this.componentDidCatch(t.value,{componentStack:n===null?``:n})}),n}function Hs(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new zs;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=eu.bind(null,e,t,n),t.then(e,e))}function Us(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t===null?!0:t.dehydrated!==null),t)return e;e=e.return}while(e!==null);return null}function Ws(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=fo(-1,1),t.tag=2,po(n,t,1))),n.lanes|=1),e)}var Gs=C.ReactCurrentOwner,Ks=!1;function qs(e,t,n,r){t.child=e===null?Ja(t,null,n,r):qa(t,e.child,n,r)}function Js(e,t,n,r,i){n=n.render;var a=t.ref;return no(t,i),r=Uo(e,t,n,r,a,i),n=Wo(),e!==null&&!Ks?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,mc(e,t,i)):(ja&&n&&Da(t),t.flags|=1,qs(e,t,r,i),t.child)}function Ys(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!cu(a)&&a.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=a,Xs(e,t,a,r,i)):(e=du(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,(e.lanes&i)===0){var o=a.memoizedProps;if(n=n.compare,n=n===null?Lr:n,n(o,r)&&e.ref===t.ref)return mc(e,t,i)}return t.flags|=1,e=uu(a,r),e.ref=t.ref,e.return=t,t.child=e}function Xs(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Lr(a,r)&&e.ref===t.ref)if(Ks=!1,t.pendingProps=r=a,(e.lanes&i)!==0)e.flags&131072&&(Ks=!0);else return t.lanes=e.lanes,mc(e,t,i)}return $s(e,t,n,r,i)}function Zs(e,t,n){var r=t.pendingProps,i=r.children,a=e===null?null:e.memoizedState;if(r.mode===`hidden`)if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},ea(ol,al),al|=n;else{if(!(n&1073741824))return e=a===null?n:a.baseLanes|n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,ea(ol,al),al|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a===null?n:a.baseLanes,ea(ol,al),al|=r}else a===null?r=n:(r=a.baseLanes|n,t.memoizedState=null),ea(ol,al),al|=r;return qs(e,t,i,n),t.child}function Qs(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function $s(e,t,n,r,i){var a=aa(n)?ia:na.current;return a=I(t,a),no(t,i),n=Uo(e,t,n,r,a,i),r=Wo(),e!==null&&!Ks?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,mc(e,t,i)):(ja&&r&&Da(t),t.flags|=1,qs(e,t,n,i),t.child)}function ec(e,t,n,r,i){if(aa(n)){var a=!0;ca(t)}else a=!1;if(no(t,i),t.stateNode===null)pc(e,t),Ns(t,n,r),Fs(t,n,r,i),r=!0;else if(e===null){var o=t.stateNode,s=t.memoizedProps;o.props=s;var c=o.context,l=n.contextType;typeof l==`object`&&l?l=ro(l):(l=aa(n)?ia:na.current,l=I(t,l));var u=n.getDerivedStateFromProps,d=typeof u==`function`||typeof o.getSnapshotBeforeUpdate==`function`;d||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==r||c!==l)&&Ps(t,o,r,l),co=!1;var f=t.memoizedState;o.state=f,go(t,r,o,i),c=t.memoizedState,s!==r||f!==c||ra.current||co?(typeof u==`function`&&(As(t,n,u,r),c=t.memoizedState),(s=co||Ms(t,n,s,r,f,c,l))?(d||typeof o.UNSAFE_componentWillMount!=`function`&&typeof o.componentWillMount!=`function`||(typeof o.componentWillMount==`function`&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount==`function`&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount==`function`&&(t.flags|=4194308)):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=l,r=s):(typeof o.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,uo(e,t),s=t.memoizedProps,l=t.type===t.elementType?s:ks(t.type,s),o.props=l,d=t.pendingProps,f=o.context,c=n.contextType,typeof c==`object`&&c?c=ro(c):(c=aa(n)?ia:na.current,c=I(t,c));var p=n.getDerivedStateFromProps;(u=typeof p==`function`||typeof o.getSnapshotBeforeUpdate==`function`)||typeof o.UNSAFE_componentWillReceiveProps!=`function`&&typeof o.componentWillReceiveProps!=`function`||(s!==d||f!==c)&&Ps(t,o,r,c),co=!1,f=t.memoizedState,o.state=f,go(t,r,o,i);var m=t.memoizedState;s!==d||f!==m||ra.current||co?(typeof p==`function`&&(As(t,n,p,r),m=t.memoizedState),(l=co||Ms(t,n,l,r,f,m,c)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!=`function`&&typeof o.componentWillUpdate!=`function`||(typeof o.componentWillUpdate==`function`&&o.componentWillUpdate(r,m,c),typeof o.UNSAFE_componentWillUpdate==`function`&&o.UNSAFE_componentWillUpdate(r,m,c)),typeof o.componentDidUpdate==`function`&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=m),o.props=r,o.state=m,o.context=c,r=l):(typeof o.componentDidUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!=`function`||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return tc(e,t,n,r,a,i)}function tc(e,t,n,r,i,a){Qs(e,t);var o=(t.flags&128)!=0;if(!r&&!o)return i&&la(t,n,!1),mc(e,t,a);r=t.stateNode,Gs.current=t;var s=o&&typeof n.getDerivedStateFromError!=`function`?null:r.render();return t.flags|=1,e!==null&&o?(t.child=qa(t,e.child,null,a),t.child=qa(t,null,s,a)):qs(e,t,s,a),t.memoizedState=r.state,i&&la(t,n,!0),t.child}function nc(e){var t=e.stateNode;t.pendingContext?oa(e,t.pendingContext,t.pendingContext!==t.context):t.context&&oa(e,t.context,!1),Co(e,t.containerInfo)}function rc(e,t,n,r,i){return Ba(),Va(i),t.flags|=256,qs(e,t,n,r),t.child}var ic={dehydrated:null,treeContext:null,retryLane:0};function ac(e){return{baseLanes:e,cachePool:null,transitions:null}}function oc(e,t,n){var r=t.pendingProps,i=Do.current,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(i&2)!=0),s?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),ea(Do,i&1),e===null)return Ia(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data===`$!`?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,a?(r=t.mode,a=t.child,o={mode:`hidden`,children:o},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=o):a=pu(o,r,0,null),e=fu(e,r,n,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=ac(n),t.memoizedState=ic,e):sc(t,o));if(i=e.memoizedState,i!==null&&(s=i.dehydrated,s!==null))return lc(e,t,o,r,s,i,n);if(a){a=r.fallback,o=t.mode,i=e.child,s=i.sibling;var c={mode:`hidden`,children:r.children};return!(o&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=uu(i,c),r.subtreeFlags=i.subtreeFlags&14680064),s===null?(a=fu(a,o,n,null),a.flags|=2):a=uu(s,a),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,o=e.child.memoizedState,o=o===null?ac(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},a.memoizedState=o,a.childLanes=e.childLanes&~n,t.memoizedState=ic,r}return a=e.child,e=a.sibling,r=uu(a,{mode:`visible`,children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function sc(e,t){return t=pu({mode:`visible`,children:t},e.mode,0,null),t.return=e,e.child=t}function cc(e,t,n,r){return r!==null&&Va(r),qa(t,e.child,null,n),e=sc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function lc(e,t,n,i,a,o,s){if(n)return t.flags&256?(t.flags&=-257,i=Ls(Error(r(422))),cc(e,t,s,i)):t.memoizedState===null?(o=i.fallback,a=t.mode,i=pu({mode:`visible`,children:i.children},a,0,null),o=fu(o,a,s,null),o.flags|=2,i.return=t,o.return=t,i.sibling=o,t.child=i,t.mode&1&&qa(t,e.child,null,s),t.child.memoizedState=ac(s),t.memoizedState=ic,o):(t.child=e.child,t.flags|=128,null);if(!(t.mode&1))return cc(e,t,s,null);if(a.data===`$!`){if(i=a.nextSibling&&a.nextSibling.dataset,i)var c=i.dgst;return i=c,o=Error(r(419)),i=Ls(o,i,void 0),cc(e,t,s,i)}if(c=(s&e.childLanes)!==0,Ks||c){if(i=nl,i!==null){switch(s&-s){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=(a&(i.suspendedLanes|s))===0?a:0,a!==0&&a!==o.retryLane&&(o.retryLane=a,so(e,a),kl(i,e,a,-1))}return Ul(),i=Ls(Error(r(421))),cc(e,t,s,i)}return a.data===`$?`?(t.flags|=128,t.child=e.child,t=nu.bind(null,e),a._reactRetry=t,null):(e=o.treeContext,Aa=Ri(a.nextSibling),ka=t,ja=!0,Ma=null,e!==null&&(ba[xa++]=Ca,ba[xa++]=wa,ba[xa++]=Sa,Ca=e.id,wa=e.overflow,Sa=t),t=sc(t,i.children),t.flags|=4096,t)}function uc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),to(e.return,t,n)}function dc(e,t,n,r,i){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailMode=i)}function fc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;if(qs(e,t,r.children,n),r=Do.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&uc(e,n,t);else if(e.tag===19)uc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(ea(Do,r),!(t.mode&1))t.memoizedState=null;else switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&Oo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),dc(t,!1,i,n,a);break;case`backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Oo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}dc(t,!0,n,null,a);break;case`together`:dc(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function pc(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function mc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),ll|=t.lanes,(n&t.childLanes)===0)return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=uu(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=uu(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function hc(e,t,n){switch(t.tag){case 3:nc(t),Ba();break;case 5:To(t);break;case 1:aa(t.type)&&ca(t);break;case 4:Co(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;ea(Ya,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(ea(Do,Do.current&1),e=mc(e,t,n),e===null?null:e.sibling):oc(e,t,n):(ea(Do,Do.current&1),t.flags|=128,null);ea(Do,Do.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return fc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),ea(Do,Do.current),r)break;return null;case 22:case 23:return t.lanes=0,Zs(e,t,n)}return mc(e,t,n)}var gc=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},_c=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,So(yo.current);var o=null;switch(n){case`input`:i=be(e,i),r=be(e,r),o=[];break;case`select`:i=j({},i,{value:void 0}),r=j({},r,{value:void 0}),o=[];break;case`textarea`:i=Oe(e,i),r=Oe(e,r),o=[];break;default:typeof i.onClick!=`function`&&typeof r.onClick==`function`&&(e.onclick=Oi)}Ve(n,r);var s;for(u in n=null,i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u===`style`){var c=i[u];for(s in c)c.hasOwnProperty(s)&&(n||={},n[s]=``)}else u!==`dangerouslySetInnerHTML`&&u!==`children`&&u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&u!==`autoFocus`&&(a.hasOwnProperty(u)?o||=[]:(o||=[]).push(u,null));for(u in r){var l=r[u];if(c=i?.[u],r.hasOwnProperty(u)&&l!==c&&(l!=null||c!=null))if(u===`style`)if(c){for(s in c)!c.hasOwnProperty(s)||l&&l.hasOwnProperty(s)||(n||={},n[s]=``);for(s in l)l.hasOwnProperty(s)&&c[s]!==l[s]&&(n||={},n[s]=l[s])}else n||(o||=[],o.push(u,n)),n=l;else u===`dangerouslySetInnerHTML`?(l=l?l.__html:void 0,c=c?c.__html:void 0,l!=null&&c!==l&&(o||=[]).push(u,l)):u===`children`?typeof l!=`string`&&typeof l!=`number`||(o||=[]).push(u,``+l):u!==`suppressContentEditableWarning`&&u!==`suppressHydrationWarning`&&(a.hasOwnProperty(u)?(l!=null&&u===`onScroll`&&mi(`scroll`,e),o||c===l||(o=[])):(o||=[]).push(u,l))}n&&(o||=[]).push(`style`,n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}},vc=function(e,t,n,r){n!==r&&(t.flags|=4)};function yc(e,t){if(!ja)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function bc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function xc(e,t,n){var i=t.pendingProps;switch(Oa(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return bc(t),null;case 1:return aa(t.type)&&L(),bc(t),null;case 3:return i=t.stateNode,wo(),F(ra),F(na),Ao(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(e===null||e.child===null)&&(Ra(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ma!==null&&(Nl(Ma),Ma=null))),bc(t),null;case 5:Eo(t);var o=So(xo.current);if(n=t.type,e!==null&&t.stateNode!=null)_c(e,t,n,i,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!i){if(t.stateNode===null)throw Error(r(166));return bc(t),null}if(e=So(yo.current),Ra(t)){i=t.stateNode,n=t.type;var s=t.memoizedProps;switch(i[Vi]=t,i[Hi]=s,e=(t.mode&1)!=0,n){case`dialog`:mi(`cancel`,i),mi(`close`,i);break;case`iframe`:case`object`:case`embed`:mi(`load`,i);break;case`video`:case`audio`:for(o=0;o<ui.length;o++)mi(ui[o],i);break;case`source`:mi(`error`,i);break;case`img`:case`image`:case`link`:mi(`error`,i),mi(`load`,i);break;case`details`:mi(`toggle`,i);break;case`input`:xe(i,s),mi(`invalid`,i);break;case`select`:i._wrapperState={wasMultiple:!!s.multiple},mi(`invalid`,i);break;case`textarea`:ke(i,s),mi(`invalid`,i)}for(var c in Ve(n,s),o=null,s)if(s.hasOwnProperty(c)){var l=s[c];c===`children`?typeof l==`string`?i.textContent!==l&&(!0!==s.suppressHydrationWarning&&Di(i.textContent,l,e),o=[`children`,l]):typeof l==`number`&&i.textContent!==``+l&&(!0!==s.suppressHydrationWarning&&Di(i.textContent,l,e),o=[`children`,``+l]):a.hasOwnProperty(c)&&l!=null&&c===`onScroll`&&mi(`scroll`,i)}switch(n){case`input`:_e(i),we(i,s,!0);break;case`textarea`:_e(i),je(i);break;case`select`:case`option`:break;default:typeof s.onClick==`function`&&(i.onclick=Oi)}i=o,t.updateQueue=i,i!==null&&(t.flags|=4)}else{c=o.nodeType===9?o:o.ownerDocument,e===`http://www.w3.org/1999/xhtml`&&(e=Me(n)),e===`http://www.w3.org/1999/xhtml`?n===`script`?(e=c.createElement(`div`),e.innerHTML=`<script><\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[Vi]=t,e[Hi]=i,gc(e,t,!1,!1),t.stateNode=e;a:{switch(c=He(n,i),n){case`dialog`:mi(`cancel`,e),mi(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:mi(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;o<ui.length;o++)mi(ui[o],e);o=i;break;case`source`:mi(`error`,e),o=i;break;case`img`:case`image`:case`link`:mi(`error`,e),mi(`load`,e),o=i;break;case`details`:mi(`toggle`,e),o=i;break;case`input`:xe(e,i),o=be(e,i),mi(`invalid`,e);break;case`option`:o=i;break;case`select`:e._wrapperState={wasMultiple:!!i.multiple},o=j({},i,{value:void 0}),mi(`invalid`,e);break;case`textarea`:ke(e,i),o=Oe(e,i),mi(`invalid`,e);break;default:o=i}for(s in Ve(n,o),l=o,l)if(l.hasOwnProperty(s)){var u=l[s];s===`style`?ze(e,u):s===`dangerouslySetInnerHTML`?(u=u?u.__html:void 0,u!=null&&Fe(e,u)):s===`children`?typeof u==`string`?(n!==`textarea`||u!==``)&&Ie(e,u):typeof u==`number`&&Ie(e,``+u):s!==`suppressContentEditableWarning`&&s!==`suppressHydrationWarning`&&s!==`autoFocus`&&(a.hasOwnProperty(s)?u!=null&&s===`onScroll`&&mi(`scroll`,e):u!=null&&S(e,s,u,c))}switch(n){case`input`:_e(e),we(e,i,!1);break;case`textarea`:_e(e),je(e);break;case`option`:i.value!=null&&e.setAttribute(`value`,``+me(i.value));break;case`select`:e.multiple=!!i.multiple,s=i.value,s==null?i.defaultValue!=null&&De(e,!!i.multiple,i.defaultValue,!0):De(e,!!i.multiple,s,!1);break;default:typeof o.onClick==`function`&&(e.onclick=Oi)}switch(n){case`button`:case`input`:case`select`:case`textarea`:i=!!i.autoFocus;break a;case`img`:i=!0;break a;default:i=!1}}i&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return bc(t),null;case 6:if(e&&t.stateNode!=null)vc(e,t,e.memoizedProps,i);else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(n=So(xo.current),So(yo.current),Ra(t)){if(i=t.stateNode,n=t.memoizedProps,i[Vi]=t,(s=i.nodeValue!==n)&&(e=ka,e!==null))switch(e.tag){case 3:Di(i.nodeValue,n,(e.mode&1)!=0);break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&Di(i.nodeValue,n,(e.mode&1)!=0)}s&&(t.flags|=4)}else i=(n.nodeType===9?n:n.ownerDocument).createTextNode(i),i[Vi]=t,t.stateNode=i}return bc(t),null;case 13:if(F(Do),i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(ja&&Aa!==null&&t.mode&1&&!(t.flags&128))za(),Ba(),t.flags|=98560,s=!1;else if(s=Ra(t),i!==null&&i.dehydrated!==null){if(e===null){if(!s)throw Error(r(318));if(s=t.memoizedState,s=s===null?null:s.dehydrated,!s)throw Error(r(317));s[Vi]=t}else Ba(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;bc(t),s=!1}else Ma!==null&&(Nl(Ma),Ma=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(i=i!==null,i!==(e!==null&&e.memoizedState!==null)&&i&&(t.child.flags|=8192,t.mode&1&&(e===null||Do.current&1?sl===0&&(sl=3):Ul())),t.updateQueue!==null&&(t.flags|=4),bc(t),null);case 4:return wo(),e===null&&_i(t.stateNode.containerInfo),bc(t),null;case 10:return eo(t.type._context),bc(t),null;case 17:return aa(t.type)&&L(),bc(t),null;case 19:if(F(Do),s=t.memoizedState,s===null)return bc(t),null;if(i=(t.flags&128)!=0,c=s.rendering,c===null)if(i)yc(s,!1);else{if(sl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(c=Oo(e),c!==null){for(t.flags|=128,yc(s,!1),i=c.updateQueue,i!==null&&(t.updateQueue=i,t.flags|=4),t.subtreeFlags=0,i=n,n=t.child;n!==null;)s=n,e=i,s.flags&=14680066,c=s.alternate,c===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=c.childLanes,s.lanes=c.lanes,s.child=c.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=c.memoizedProps,s.memoizedState=c.memoizedState,s.updateQueue=c.updateQueue,s.type=c.type,e=c.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return ea(Do,Do.current&1|2),t.child}e=e.sibling}s.tail!==null&&St()>hl&&(t.flags|=128,i=!0,yc(s,!1),t.lanes=4194304)}else{if(!i)if(e=Oo(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),yc(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!ja)return bc(t),null}else 2*St()-s.renderingStartTime>hl&&n!==1073741824&&(t.flags|=128,i=!0,yc(s,!1),t.lanes=4194304);s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(bc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=St(),t.sibling=null,n=Do.current,ea(Do,i?n&1|2:n&1),t);case 22:case 23:return zl(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?al&1073741824&&(bc(t),t.subtreeFlags&6&&(t.flags|=8192)):bc(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function Sc(e,t){switch(Oa(t),t.tag){case 1:return aa(t.type)&&L(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return wo(),F(ra),F(na),Ao(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Eo(t),null;case 13:if(F(Do),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Ba()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return F(Do),null;case 4:return wo(),null;case 10:return eo(t.type._context),null;case 22:case 23:return zl(),null;case 24:return null;default:return null}}var Cc=!1,wc=!1,Tc=typeof WeakSet==`function`?WeakSet:Set,R=null;function Ec(e,t){var n=e.ref;if(n!==null)if(typeof n==`function`)try{n(null)}catch(n){$l(e,t,n)}else n.current=null}function Dc(e,t,n){try{n()}catch(n){$l(e,t,n)}}var Oc=!1;function kc(e,t){if(ki=xn,e=Vr(),Hr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Ai={focusedElem:e,selectionRange:n},xn=!1,R=t;R!==null;)if(t=R,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,R=e;else for(;R!==null;){t=R;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:ks(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){$l(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,R=e;break}R=t.return}return h=Oc,Oc=!1,h}function Ac(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&Dc(t,n,a)}i=i.next}while(i!==r)}}function jc(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Mc(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function Nc(e){var t=e.alternate;t!==null&&(e.alternate=null,Nc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Vi],delete t[Hi],delete t[Wi],delete t[Gi],delete t[Ki])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Pc(e){return e.tag===5||e.tag===3||e.tag===4}function Fc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Pc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ic(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Oi));else if(r!==4&&(e=e.child,e!==null))for(Ic(e,t,n),e=e.sibling;e!==null;)Ic(e,t,n),e=e.sibling}function Lc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Lc(e,t,n),e=e.sibling;e!==null;)Lc(e,t,n),e=e.sibling}var Rc=null,zc=!1;function Bc(e,t,n){for(n=n.child;n!==null;)Vc(e,t,n),n=n.sibling}function Vc(e,t,n){if(At&&typeof At.onCommitFiberUnmount==`function`)try{At.onCommitFiberUnmount(kt,n)}catch{}switch(n.tag){case 5:wc||Ec(n,t);case 6:var r=Rc,i=zc;Rc=null,Bc(e,t,n),Rc=r,zc=i,Rc!==null&&(zc?(e=Rc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Rc.removeChild(n.stateNode));break;case 18:Rc!==null&&(zc?(e=Rc,n=n.stateNode,e.nodeType===8?Li(e.parentNode,n):e.nodeType===1&&Li(e,n),yn(e)):Li(Rc,n.stateNode));break;case 4:r=Rc,i=zc,Rc=n.stateNode.containerInfo,zc=!0,Bc(e,t,n),Rc=r,zc=i;break;case 0:case 11:case 14:case 15:if(!wc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&Dc(n,t,o),i=i.next}while(i!==r)}Bc(e,t,n);break;case 1:if(!wc&&(Ec(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){$l(n,t,e)}Bc(e,t,n);break;case 21:Bc(e,t,n);break;case 22:n.mode&1?(wc=(r=wc)||n.memoizedState!==null,Bc(e,t,n),wc=r):Bc(e,t,n);break;default:Bc(e,t,n)}}function Hc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Tc),t.forEach(function(t){var r=ru.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function Uc(e,t){var n=t.deletions;if(n!==null)for(var i=0;i<n.length;i++){var a=n[i];try{var o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 5:Rc=c.stateNode,zc=!1;break a;case 3:Rc=c.stateNode.containerInfo,zc=!0;break a;case 4:Rc=c.stateNode.containerInfo,zc=!0;break a}c=c.return}if(Rc===null)throw Error(r(160));Vc(o,s,a),Rc=null,zc=!1;var l=a.alternate;l!==null&&(l.return=null),a.return=null}catch(e){$l(a,t,e)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Wc(t,e),t=t.sibling}function Wc(e,t){var n=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Uc(t,e),Gc(e),i&4){try{Ac(3,e,e.return),jc(3,e)}catch(t){$l(e,e.return,t)}try{Ac(5,e,e.return)}catch(t){$l(e,e.return,t)}}break;case 1:Uc(t,e),Gc(e),i&512&&n!==null&&Ec(n,n.return);break;case 5:if(Uc(t,e),Gc(e),i&512&&n!==null&&Ec(n,n.return),e.flags&32){var a=e.stateNode;try{Ie(a,``)}catch(t){$l(e,e.return,t)}}if(i&4&&(a=e.stateNode,a!=null)){var o=e.memoizedProps,s=n===null?o:n.memoizedProps,c=e.type,l=e.updateQueue;if(e.updateQueue=null,l!==null)try{c===`input`&&o.type===`radio`&&o.name!=null&&Se(a,o),He(c,s);var u=He(c,o);for(s=0;s<l.length;s+=2){var d=l[s],f=l[s+1];d===`style`?ze(a,f):d===`dangerouslySetInnerHTML`?Fe(a,f):d===`children`?Ie(a,f):S(a,d,f,u)}switch(c){case`input`:Ce(a,o);break;case`textarea`:Ae(a,o);break;case`select`:var p=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!o.multiple;var m=o.value;m==null?p!==!!o.multiple&&(o.defaultValue==null?De(a,!!o.multiple,o.multiple?[]:``,!1):De(a,!!o.multiple,o.defaultValue,!0)):De(a,!!o.multiple,m,!1)}a[Hi]=o}catch(t){$l(e,e.return,t)}}break;case 6:if(Uc(t,e),Gc(e),i&4){if(e.stateNode===null)throw Error(r(162));a=e.stateNode,o=e.memoizedProps;try{a.nodeValue=o}catch(t){$l(e,e.return,t)}}break;case 3:if(Uc(t,e),Gc(e),i&4&&n!==null&&n.memoizedState.isDehydrated)try{yn(t.containerInfo)}catch(t){$l(e,e.return,t)}break;case 4:Uc(t,e),Gc(e);break;case 13:Uc(t,e),Gc(e),a=e.child,a.flags&8192&&(o=a.memoizedState!==null,a.stateNode.isHidden=o,!o||a.alternate!==null&&a.alternate.memoizedState!==null||(ml=St())),i&4&&Hc(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(wc=(u=wc)||d,Uc(t,e),wc=u):Uc(t,e),Gc(e),i&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(R=e,d=e.child;d!==null;){for(f=R=d;R!==null;){switch(p=R,m=p.child,p.tag){case 0:case 11:case 14:case 15:Ac(4,p,p.return);break;case 1:Ec(p,p.return);var h=p.stateNode;if(typeof h.componentWillUnmount==`function`){i=p,n=p.return;try{t=i,h.props=t.memoizedProps,h.state=t.memoizedState,h.componentWillUnmount()}catch(e){$l(i,n,e)}}break;case 5:Ec(p,p.return);break;case 22:if(p.memoizedState!==null){Yc(f);continue}}m===null?Yc(f):(m.return=p,R=m)}d=d.sibling}a:for(d=null,f=e;;){if(f.tag===5){if(d===null){d=f;try{a=f.stateNode,u?(o=a.style,typeof o.setProperty==`function`?o.setProperty(`display`,`none`,`important`):o.display=`none`):(c=f.stateNode,l=f.memoizedProps.style,s=l!=null&&l.hasOwnProperty(`display`)?l.display:null,c.style.display=Re(`display`,s))}catch(t){$l(e,e.return,t)}}}else if(f.tag===6){if(d===null)try{f.stateNode.nodeValue=u?``:f.memoizedProps}catch(t){$l(e,e.return,t)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break a;for(;f.sibling===null;){if(f.return===null||f.return===e)break a;d===f&&(d=null),f=f.return}d===f&&(d=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:Uc(t,e),Gc(e),i&4&&Hc(e);break;case 21:break;default:Uc(t,e),Gc(e)}}function Gc(e){var t=e.flags;if(t&2){try{a:{for(var n=e.return;n!==null;){if(Pc(n)){var i=n;break a}n=n.return}throw Error(r(160))}switch(i.tag){case 5:var a=i.stateNode;i.flags&32&&(Ie(a,``),i.flags&=-33),Lc(e,Fc(e),a);break;case 3:case 4:var o=i.stateNode.containerInfo;Ic(e,Fc(e),o);break;default:throw Error(r(161))}}catch(t){$l(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Kc(e,t,n){R=e,qc(e,t,n)}function qc(e,t,n){for(var r=(e.mode&1)!=0;R!==null;){var i=R,a=i.child;if(i.tag===22&&r){var o=i.memoizedState!==null||Cc;if(!o){var s=i.alternate,c=s!==null&&s.memoizedState!==null||wc;s=Cc;var l=wc;if(Cc=o,(wc=c)&&!l)for(R=i;R!==null;)o=R,c=o.child,o.tag===22&&o.memoizedState!==null||c===null?Xc(i):(c.return=o,R=c);for(;a!==null;)R=a,qc(a,t,n),a=a.sibling;R=i,Cc=s,wc=l}Jc(e,t,n)}else i.subtreeFlags&8772&&a!==null?(a.return=i,R=a):Jc(e,t,n)}}function Jc(e){for(;R!==null;){var t=R;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:wc||jc(5,t);break;case 1:var i=t.stateNode;if(t.flags&4&&!wc)if(n===null)i.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:ks(t.type,n.memoizedProps);i.componentDidUpdate(a,n.memoizedState,i.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&_o(t,o,i);break;case 3:var s=t.updateQueue;if(s!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}_o(t,s,n)}break;case 5:var c=t.stateNode;if(n===null&&t.flags&4){n=c;var l=t.memoizedProps;switch(t.type){case`button`:case`input`:case`select`:case`textarea`:l.autoFocus&&n.focus();break;case`img`:l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var f=d.dehydrated;f!==null&&yn(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}wc||t.flags&512&&Mc(t)}catch(e){$l(t,t.return,e)}}if(t===e){R=null;break}if(n=t.sibling,n!==null){n.return=t.return,R=n;break}R=t.return}}function Yc(e){for(;R!==null;){var t=R;if(t===e){R=null;break}var n=t.sibling;if(n!==null){n.return=t.return,R=n;break}R=t.return}}function Xc(e){for(;R!==null;){var t=R;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{jc(4,t)}catch(e){$l(t,n,e)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount==`function`){var i=t.return;try{r.componentDidMount()}catch(e){$l(t,i,e)}}var a=t.return;try{Mc(t)}catch(e){$l(t,a,e)}break;case 5:var o=t.return;try{Mc(t)}catch(e){$l(t,o,e)}}}catch(e){$l(t,t.return,e)}if(t===e){R=null;break}var s=t.sibling;if(s!==null){s.return=t.return,R=s;break}R=t.return}}var Zc=Math.ceil,Qc=C.ReactCurrentDispatcher,$c=C.ReactCurrentOwner,el=C.ReactCurrentBatchConfig,tl=0,nl=null,rl=null,il=0,al=0,ol=$i(0),sl=0,cl=null,ll=0,ul=0,dl=0,fl=null,pl=null,ml=0,hl=1/0,gl=null,_l=!1,vl=null,yl=null,bl=!1,xl=null,Sl=0,Cl=0,wl=null,Tl=-1,El=0;function Dl(){return tl&6?St():Tl===-1?Tl=St():Tl}function Ol(e){return e.mode&1?tl&2&&il!==0?il&-il:Ha.transition===null?(e=Jt,e===0?(e=window.event,e=e===void 0?16:Dn(e.type),e):e):(El===0&&(El=Ut()),El):1}function kl(e,t,n,i){if(50<Cl)throw Cl=0,wl=null,Error(r(185));Gt(e,n,i),(!(tl&2)||e!==nl)&&(e===nl&&(!(tl&2)&&(ul|=n),sl===4&&Fl(e,il)),Al(e,i),n===1&&tl===0&&!(t.mode&1)&&(hl=St()+500,da&&ha()))}function Al(e,t){var n=e.callbackNode;Vt(e,t);var r=zt(e,e===nl?il:0);if(r===0)n!==null&&yt(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&yt(n),t===1)e.tag===0?ma(Il.bind(null,e)):pa(Il.bind(null,e)),Fi(function(){!(tl&6)&&ha()}),n=null;else{switch(Yt(r)){case 1:n=wt;break;case 4:n=Tt;break;case 16:n=Et;break;case 536870912:n=Ot;break;default:n=Et}n=au(n,jl.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function jl(e,t){if(Tl=-1,El=0,tl&6)throw Error(r(327));var n=e.callbackNode;if(Zl()&&e.callbackNode!==n)return null;var i=zt(e,e===nl?il:0);if(i===0)return null;if(i&30||(i&e.expiredLanes)!==0||t)t=Wl(e,i);else{t=i;var a=tl;tl|=2;var o=Hl();(nl!==e||il!==t)&&(gl=null,hl=St()+500,Bl(e,t));do try{Kl();break}catch(t){Vl(e,t)}while(1);$a(),Qc.current=o,tl=a,rl===null?(nl=null,il=0,t=sl):t=0}if(t!==0){if(t===2&&(a=Ht(e),a!==0&&(i=a,t=Ml(e,a))),t===1)throw n=cl,Bl(e,0),Fl(e,i),Al(e,St()),n;if(t===6)Fl(e,i);else{if(a=e.current.alternate,!(i&30)&&!Pl(a)&&(t=Wl(e,i),t===2&&(o=Ht(e),o!==0&&(i=o,t=Ml(e,o))),t===1))throw n=cl,Bl(e,0),Fl(e,i),Al(e,St()),n;switch(e.finishedWork=a,e.finishedLanes=i,t){case 0:case 1:throw Error(r(345));case 2:Yl(e,pl,gl);break;case 3:if(Fl(e,i),(i&130023424)===i&&(t=ml+500-St(),10<t)){if(zt(e,0)!==0)break;if(a=e.suspendedLanes,(a&i)!==i){Dl(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Mi(Yl.bind(null,e,pl,gl),t);break}Yl(e,pl,gl);break;case 4:if(Fl(e,i),(i&4194240)===i)break;for(t=e.eventTimes,a=-1;0<i;){var s=31-Mt(i);o=1<<s,s=t[s],s>a&&(a=s),i&=~o}if(i=a,i=St()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*Zc(i/1960))-i,10<i){e.timeoutHandle=Mi(Yl.bind(null,e,pl,gl),i);break}Yl(e,pl,gl);break;case 5:Yl(e,pl,gl);break;default:throw Error(r(329))}}}return Al(e,St()),e.callbackNode===n?jl.bind(null,e):null}function Ml(e,t){var n=fl;return e.current.memoizedState.isDehydrated&&(Bl(e,t).flags|=256),e=Wl(e,t),e!==2&&(t=pl,pl=n,t!==null&&Nl(t)),e}function Nl(e){pl===null?pl=e:pl.push.apply(pl,e)}function Pl(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Ir(a(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Fl(e,t){for(t&=~dl,t&=~ul,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Mt(t),r=1<<n;e[n]=-1,t&=~r}}function Il(e){if(tl&6)throw Error(r(327));Zl();var t=zt(e,0);if(!(t&1))return Al(e,St()),null;var n=Wl(e,t);if(e.tag!==0&&n===2){var i=Ht(e);i!==0&&(t=i,n=Ml(e,i))}if(n===1)throw n=cl,Bl(e,0),Fl(e,t),Al(e,St()),n;if(n===6)throw Error(r(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Yl(e,pl,gl),Al(e,St()),null}function Ll(e,t){var n=tl;tl|=1;try{return e(t)}finally{tl=n,tl===0&&(hl=St()+500,da&&ha())}}function Rl(e){xl!==null&&xl.tag===0&&!(tl&6)&&Zl();var t=tl;tl|=1;var n=el.transition,r=Jt;try{if(el.transition=null,Jt=1,e)return e()}finally{Jt=r,el.transition=n,tl=t,!(tl&6)&&ha()}}function zl(){al=ol.current,F(ol)}function Bl(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Ni(n)),rl!==null)for(n=rl.return;n!==null;){var r=n;switch(Oa(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&L();break;case 3:wo(),F(ra),F(na),Ao();break;case 5:Eo(r);break;case 4:wo();break;case 13:F(Do);break;case 19:F(Do);break;case 10:eo(r.type._context);break;case 22:case 23:zl()}n=n.return}if(nl=e,rl=e=uu(e.current,null),il=al=t,sl=0,cl=null,dl=ul=ll=0,pl=fl=null,io!==null){for(t=0;t<io.length;t++)if(n=io[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,a=n.pending;if(a!==null){var o=a.next;a.next=i,r.next=o}n.pending=r}io=null}return e}function Vl(e,t){do{var n=rl;try{if($a(),jo.current=Ts,Lo){for(var i=Po.memoizedState;i!==null;){var a=i.queue;a!==null&&(a.pending=null),i=i.next}Lo=!1}if(No=0,Io=Fo=Po=null,Ro=!1,zo=0,$c.current=null,n===null||n.return===null){sl=1,cl=t,rl=null;break}a:{var o=e,s=n.return,c=n,l=t;if(t=il,c.flags|=32768,typeof l==`object`&&l&&typeof l.then==`function`){var u=l,d=c,f=d.tag;if(!(d.mode&1)&&(f===0||f===11||f===15)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var m=Us(s);if(m!==null){m.flags&=-257,Ws(m,s,c,o,t),m.mode&1&&Hs(o,u,t),t=m,l=u;var h=t.updateQueue;if(h===null){var g=new Set;g.add(l),t.updateQueue=g}else h.add(l);break a}else{if(!(t&1)){Hs(o,u,t),Ul();break a}l=Error(r(426))}}else if(ja&&c.mode&1){var _=Us(s);if(_!==null){!(_.flags&65536)&&(_.flags|=256),Ws(_,s,c,o,t),Va(Is(l,c));break a}}o=l=Is(l,c),sl!==4&&(sl=2),fl===null?fl=[o]:fl.push(o),o=s;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var v=Bs(o,l,t);ho(o,v);break a;case 1:c=l;var y=o.type,b=o.stateNode;if(!(o.flags&128)&&(typeof y.getDerivedStateFromError==`function`||b!==null&&typeof b.componentDidCatch==`function`&&(yl===null||!yl.has(b)))){o.flags|=65536,t&=-t,o.lanes|=t;var x=Vs(o,c,t);ho(o,x);break a}}o=o.return}while(o!==null)}Jl(n)}catch(e){t=e,rl===n&&n!==null&&(rl=n=n.return);continue}break}while(1)}function Hl(){var e=Qc.current;return Qc.current=Ts,e===null?Ts:e}function Ul(){(sl===0||sl===3||sl===2)&&(sl=4),nl===null||!(ll&268435455)&&!(ul&268435455)||Fl(nl,il)}function Wl(e,t){var n=tl;tl|=2;var i=Hl();(nl!==e||il!==t)&&(gl=null,Bl(e,t));do try{Gl();break}catch(t){Vl(e,t)}while(1);if($a(),tl=n,Qc.current=i,rl!==null)throw Error(r(261));return nl=null,il=0,sl}function Gl(){for(;rl!==null;)ql(rl)}function Kl(){for(;rl!==null&&!bt();)ql(rl)}function ql(e){var t=iu(e.alternate,e,al);e.memoizedProps=e.pendingProps,t===null?Jl(e):rl=t,$c.current=null}function Jl(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=Sc(n,t),n!==null){n.flags&=32767,rl=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{sl=6,rl=null;return}}else if(n=xc(n,t,al),n!==null){rl=n;return}if(t=t.sibling,t!==null){rl=t;return}rl=t=e}while(t!==null);sl===0&&(sl=5)}function Yl(e,t,n){var r=Jt,i=el.transition;try{el.transition=null,Jt=1,Xl(e,t,n,r)}finally{el.transition=i,Jt=r}return null}function Xl(e,t,n,i){do Zl();while(xl!==null);if(tl&6)throw Error(r(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(r(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(Kt(e,o),e===nl&&(rl=nl=null,il=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||bl||(bl=!0,au(Et,function(){return Zl(),null})),o=(n.flags&15990)!=0,n.subtreeFlags&15990||o){o=el.transition,el.transition=null;var s=Jt;Jt=1;var c=tl;tl|=4,$c.current=null,kc(e,n),Wc(n,e),Ur(Ai),xn=!!ki,Ai=ki=null,e.current=n,Kc(n,e,a),xt(),tl=c,Jt=s,el.transition=o}else e.current=n;if(bl&&(bl=!1,xl=e,Sl=a),o=e.pendingLanes,o===0&&(yl=null),jt(n.stateNode,i),Al(e,St()),t!==null)for(i=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],i(a.value,{componentStack:a.stack,digest:a.digest});if(_l)throw _l=!1,e=vl,vl=null,e;return Sl&1&&e.tag!==0&&Zl(),o=e.pendingLanes,o&1?e===wl?Cl++:(Cl=0,wl=e):Cl=0,ha(),null}function Zl(){if(xl!==null){var e=Yt(Sl),t=el.transition,n=Jt;try{if(el.transition=null,Jt=16>e?16:e,xl===null)var i=!1;else{if(e=xl,xl=null,Sl=0,tl&6)throw Error(r(331));var a=tl;for(tl|=4,R=e.current;R!==null;){var o=R,s=o.child;if(R.flags&16){var c=o.deletions;if(c!==null){for(var l=0;l<c.length;l++){var u=c[l];for(R=u;R!==null;){var d=R;switch(d.tag){case 0:case 11:case 15:Ac(8,d,o)}var f=d.child;if(f!==null)f.return=d,R=f;else for(;R!==null;){d=R;var p=d.sibling,m=d.return;if(Nc(d),d===u){R=null;break}if(p!==null){p.return=m,R=p;break}R=m}}}var h=o.alternate;if(h!==null){var g=h.child;if(g!==null){h.child=null;do{var _=g.sibling;g.sibling=null,g=_}while(g!==null)}}R=o}}if(o.subtreeFlags&2064&&s!==null)s.return=o,R=s;else b:for(;R!==null;){if(o=R,o.flags&2048)switch(o.tag){case 0:case 11:case 15:Ac(9,o,o.return)}var v=o.sibling;if(v!==null){v.return=o.return,R=v;break b}R=o.return}}var y=e.current;for(R=y;R!==null;){s=R;var b=s.child;if(s.subtreeFlags&2064&&b!==null)b.return=s,R=b;else b:for(s=y;R!==null;){if(c=R,c.flags&2048)try{switch(c.tag){case 0:case 11:case 15:jc(9,c)}}catch(e){$l(c,c.return,e)}if(c===s){R=null;break b}var x=c.sibling;if(x!==null){x.return=c.return,R=x;break b}R=c.return}}if(tl=a,ha(),At&&typeof At.onPostCommitFiberRoot==`function`)try{At.onPostCommitFiberRoot(kt,e)}catch{}i=!0}return i}finally{Jt=n,el.transition=t}}return!1}function Ql(e,t,n){t=Is(n,t),t=Bs(e,t,1),e=po(e,t,1),t=Dl(),e!==null&&(Gt(e,1,t),Al(e,t))}function $l(e,t,n){if(e.tag===3)Ql(e,e,n);else for(;t!==null;){if(t.tag===3){Ql(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(yl===null||!yl.has(r))){e=Is(n,e),e=Vs(t,e,1),t=po(t,e,1),e=Dl(),t!==null&&(Gt(t,1,e),Al(t,e));break}}t=t.return}}function eu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Dl(),e.pingedLanes|=e.suspendedLanes&n,nl===e&&(il&n)===n&&(sl===4||sl===3&&(il&130023424)===il&&500>St()-ml?Bl(e,0):dl|=n),Al(e,t)}function tu(e,t){t===0&&(e.mode&1?(t=Lt,Lt<<=1,!(Lt&130023424)&&(Lt=4194304)):t=1);var n=Dl();e=so(e,t),e!==null&&(Gt(e,t,n),Al(e,n))}function nu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),tu(e,n)}function ru(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),tu(e,n)}var iu=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ra.current)Ks=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Ks=!1,hc(e,t,n);Ks=!!(e.flags&131072)}else Ks=!1,ja&&t.flags&1048576&&Ea(t,ya,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;pc(e,t),e=t.pendingProps;var a=I(t,na.current);no(t,n),a=Uo(null,t,i,e,a,n);var o=Wo();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,aa(i)?(o=!0,ca(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,lo(t),a.updater=js,t.stateNode=a,a._reactInternals=t,Fs(t,i,e,n),t=tc(null,t,i,!0,o,n)):(t.tag=0,ja&&o&&Da(t),qs(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(pc(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=lu(i),e=ks(i,e),a){case 0:t=$s(null,t,i,e,n);break a;case 1:t=ec(null,t,i,e,n);break a;case 11:t=Js(null,t,i,e,n);break a;case 14:t=Ys(null,t,i,ks(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ks(i,a),$s(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ks(i,a),ec(e,t,i,a,n);case 3:a:{if(nc(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,uo(e,t),go(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated)if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Is(Error(r(423)),t),t=rc(e,t,i,n,a);break a}else if(i!==a){a=Is(Error(r(424)),t),t=rc(e,t,i,n,a);break a}else for(Aa=Ri(t.stateNode.containerInfo.firstChild),ka=t,ja=!0,Ma=null,n=Ja(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ba(),i===a){t=mc(e,t,n);break a}qs(e,t,i,n)}t=t.child}return t;case 5:return To(t),e===null&&Ia(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,ji(i,a)?s=null:o!==null&&ji(i,o)&&(t.flags|=32),Qs(e,t),qs(e,t,s,n),t.child;case 6:return e===null&&Ia(t),null;case 13:return oc(e,t,n);case 4:return Co(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=qa(t,null,i,n):qs(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ks(i,a),Js(e,t,i,a,n);case 7:return qs(e,t,t.pendingProps,n),t.child;case 8:return qs(e,t,t.pendingProps.children,n),t.child;case 12:return qs(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,ea(Ya,i._currentValue),i._currentValue=s,o!==null)if(Ir(o.value,s)){if(o.children===a.children&&!ra.current){t=mc(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=fo(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),to(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),to(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}qs(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,no(t,n),a=ro(a),i=i(a),t.flags|=1,qs(e,t,i,n),t.child;case 14:return i=t.type,a=ks(i,t.pendingProps),a=ks(i.type,a),Ys(e,t,i,a,n);case 15:return Xs(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ks(i,a),pc(e,t),t.tag=1,aa(i)?(e=!0,ca(t)):e=!1,no(t,n),Ns(t,i,a),Fs(t,i,a,n),tc(null,t,i,!0,e,n);case 19:return fc(e,t,n);case 22:return Zs(e,t,n)}throw Error(r(156,t.tag))};function au(e,t){return vt(e,t)}function ou(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function su(e,t,n,r){return new ou(e,t,n,r)}function cu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function lu(e){if(typeof e==`function`)return cu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===O)return 11;if(e===A)return 14}return 2}function uu(e,t){var n=e.alternate;return n===null?(n=su(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function du(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)cu(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case te:return fu(n.children,a,o,t);case T:s=8,a|=8;break;case ne:return e=su(12,n,t,a|2),e.elementType=ne,e.lanes=o,e;case re:return e=su(13,n,t,a),e.elementType=re,e.lanes=o,e;case k:return e=su(19,n,t,a),e.elementType=k,e.lanes=o,e;case ae:return pu(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case E:s=10;break a;case D:s=9;break a;case O:s=11;break a;case A:s=14;break a;case ie:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=su(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function fu(e,t,n,r){return e=su(7,e,r,t),e.lanes=n,e}function pu(e,t,n,r){return e=su(22,e,r,t),e.elementType=ae,e.lanes=n,e.stateNode={isHidden:!1},e}function mu(e,t,n){return e=su(6,e,null,t),e.lanes=n,e}function hu(e,t,n){return t=su(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function gu(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Wt(0),this.expirationTimes=Wt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Wt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function _u(e,t,n,r,i,a,o,s,c){return e=new gu(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=su(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},lo(a),e}function vu(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ee,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}function yu(e){if(!e)return ta;e=e._reactInternals;a:{if(ft(e)!==e||e.tag!==1)throw Error(r(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break a;case 1:if(aa(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break a}}t=t.return}while(t!==null);throw Error(r(171))}if(e.tag===1){var n=e.type;if(aa(n))return sa(e,n,t)}return t}function bu(e,t,n,r,i,a,o,s,c){return e=_u(n,r,!0,e,i,a,o,s,c),e.context=yu(null),n=e.current,r=Dl(),i=Ol(n),a=fo(r,i),a.callback=t??null,po(n,a,i),e.current.lanes=i,Gt(e,i,r),Al(e,r),e}function xu(e,t,n,r){var i=t.current,a=Dl(),o=Ol(i);return n=yu(n),t.context===null?t.context=n:t.pendingContext=n,t=fo(a,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=po(i,t,o),e!==null&&(kl(e,i,o,a),mo(e,i,o)),o}function Su(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Cu(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function wu(e,t){Cu(e,t),(e=e.alternate)&&Cu(e,t)}function Tu(){return null}var Eu=typeof reportError==`function`?reportError:function(e){console.error(e)};function Du(e){this._internalRoot=e}Ou.prototype.render=Du.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(r(409));xu(e,t,null,null)},Ou.prototype.unmount=Du.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Rl(function(){xu(null,e,null,null)}),t[Ui]=null}};function Ou(e){this._internalRoot=e}Ou.prototype.unstable_scheduleHydration=function(e){if(e){var t=$t();e={blockedOn:null,target:e,priority:t};for(var n=0;n<ln.length&&t!==0&&t<ln[n].priority;n++);ln.splice(n,0,e),n===0&&mn(e)}};function ku(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Au(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==` react-mount-point-unstable `))}function ju(){}function Mu(e,t,n,r,i){if(i){if(typeof r==`function`){var a=r;r=function(){var e=Su(o);a.call(e)}}var o=bu(t,r,e,0,null,!1,!1,``,ju);return e._reactRootContainer=o,e[Ui]=o.current,_i(e.nodeType===8?e.parentNode:e),Rl(),o}for(;i=e.lastChild;)e.removeChild(i);if(typeof r==`function`){var s=r;r=function(){var e=Su(c);s.call(e)}}var c=_u(e,0,!1,null,null,!1,!1,``,ju);return e._reactRootContainer=c,e[Ui]=c.current,_i(e.nodeType===8?e.parentNode:e),Rl(function(){xu(t,c,n,r)}),c}function Nu(e,t,n,r,i){var a=n._reactRootContainer;if(a){var o=a;if(typeof i==`function`){var s=i;i=function(){var e=Su(o);s.call(e)}}xu(t,o,e,i)}else o=Mu(n,t,e,i,r);return Su(o)}Xt=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Rt(t.pendingLanes);n!==0&&(qt(t,n|1),Al(t,St()),!(tl&6)&&(hl=St()+500,ha()))}break;case 13:Rl(function(){var t=so(e,1);t!==null&&kl(t,e,1,Dl())}),wu(e,1)}},Zt=function(e){if(e.tag===13){var t=so(e,134217728);t!==null&&kl(t,e,134217728,Dl()),wu(e,134217728)}},Qt=function(e){if(e.tag===13){var t=Ol(e),n=so(e,t);n!==null&&kl(n,e,t,Dl()),wu(e,t)}},$t=function(){return Jt},en=function(e,t){var n=Jt;try{return Jt=e,t()}finally{Jt=n}},Ge=function(e,t,n){switch(t){case`input`:if(Ce(e,n),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name=`+JSON.stringify(``+t)+`][type="radio"]`),t=0;t<n.length;t++){var i=n[t];if(i!==e&&i.form===e.form){var a=Xi(i);if(!a)throw Error(r(90));ve(i),Ce(i,a)}}}break;case`textarea`:Ae(e,n);break;case`select`:t=n.value,t!=null&&De(e,!!n.multiple,t,!1)}},Ze=Ll,Qe=Rl;var Pu={usingClientEntryPoint:!1,Events:[Ji,Yi,Xi,Ye,Xe,Ll]},Fu={findFiberByHostInstance:qi,bundleType:0,version:`18.3.1`,rendererPackageName:`react-dom`},Iu={bundleType:Fu.bundleType,version:Fu.version,rendererPackageName:Fu.rendererPackageName,rendererConfig:Fu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=gt(e),e===null?null:e.stateNode},findFiberByHostInstance:Fu.findFiberByHostInstance||Tu,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:`18.3.1-next-f1338f8080-20240426`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Lu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Lu.isDisabled&&Lu.supportsFiber)try{kt=Lu.inject(Iu),At=Lu}catch{}}e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Pu,e.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!ku(t))throw Error(r(200));return vu(e,t,null,n)},e.createRoot=function(e,t){if(!ku(e))throw Error(r(299));var n=!1,i=``,a=Eu;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(i=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=_u(e,1,!1,null,null,n,!1,i,a),e[Ui]=t.current,_i(e.nodeType===8?e.parentNode:e),new Du(t)},e.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=gt(t),e=e===null?null:e.stateNode,e},e.flushSync=function(e){return Rl(e)},e.hydrate=function(e,t,n){if(!Au(t))throw Error(r(200));return Nu(null,e,t,!0,n)},e.hydrateRoot=function(e,t,n){if(!ku(e))throw Error(r(405));var i=n!=null&&n.hydratedSources||null,a=!1,o=``,s=Eu;if(n!=null&&(!0===n.unstable_strictMode&&(a=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(s=n.onRecoverableError)),t=bu(t,null,e,1,n??null,a,!1,o,s),e[Ui]=t.current,_i(e),i)for(e=0;e<i.length;e++)n=i[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new Ou(t)},e.render=function(e,t,n){if(!Au(t))throw Error(r(200));return Nu(null,e,t,!1,n)},e.unmountComponentAtNode=function(e){if(!Au(e))throw Error(r(40));return e._reactRootContainer?(Rl(function(){Nu(null,null,e,!1,function(){e._reactRootContainer=null,e[Ui]=null})}),!0):!1},e.unstable_batchedUpdates=Ll,e.unstable_renderSubtreeIntoContainer=function(e,t,n,i){if(!Au(n))throw Error(r(200));if(e==null||e._reactInternals===void 0)throw Error(r(38));return Nu(e,t,n,!1,i)},e.version=`18.3.1-next-f1338f8080-20240426`})),m=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=m();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),g=c(u()),_=h(),v=class{},y=class extends v{constructor(e,t,n){super(),this.viewId=e,this.groupId=t,this.panelId=n}},b=class extends v{constructor(e,t){super(),this.viewId=e,this.paneId=t}},x=class e{constructor(){}static getInstance(){return e.INSTANCE}hasData(e){return e&&e===this.proto}clearData(e){this.hasData(e)&&(this.proto=void 0,this.data=void 0)}getData(e){if(this.hasData(e))return this.data}setData(e,t){t&&(this.data=e,this.proto=t)}};x.INSTANCE=new x;function S(){let e=x.getInstance();if(e.hasData(y.prototype))return e.getData(y.prototype)[0]}function C(){let e=x.getInstance();if(e.hasData(b.prototype))return e.getData(b.prototype)[0]}var w;(function(e){e.any=(...e)=>t=>{let n=e.map(e=>e(t));return{dispose:()=>{n.forEach(e=>{e.dispose()})}}}})(w||={});var ee=class{constructor(){this._defaultPrevented=!1}get defaultPrevented(){return this._defaultPrevented}preventDefault(){this._defaultPrevented=!0}},te=class{constructor(){this._isAccepted=!1}get isAccepted(){return this._isAccepted}accept(){this._isAccepted=!0}},T=class{constructor(){this.events=new Map}get size(){return this.events.size}add(e,t){this.events.set(e,t)}delete(e){this.events.delete(e)}clear(){this.events.clear()}},ne=class e{static create(){return new e(Error().stack??``)}constructor(e){this.value=e}print(){console.warn(`dockview: stacktrace`,this.value)}},E=class{constructor(e,t){this.callback=e,this.stacktrace=t}},D=class e{static setLeakageMonitorEnabled(t){t!==e.ENABLE_TRACKING&&e.MEMORY_LEAK_WATCHER.clear(),e.ENABLE_TRACKING=t}get value(){return this._last}constructor(e){this.options=e,this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=t=>{this.options?.replay&&this._last!==void 0&&t(this._last);let n=new E(t,e.ENABLE_TRACKING?ne.create():void 0);return this._listeners.push(n),{dispose:()=>{let t=this._listeners.indexOf(n);t>-1?this._listeners.splice(t,1):e.ENABLE_TRACKING}}},e.ENABLE_TRACKING&&e.MEMORY_LEAK_WATCHER.add(this._event,ne.create())),this._event}fire(e){this.options?.replay&&(this._last=e);for(let t of this._listeners)t.callback(e)}dispose(){this._disposed||(this._disposed=!0,this._listeners.length>0&&(e.ENABLE_TRACKING&&queueMicrotask(()=>{for(let e of this._listeners)console.warn(`dockview: stacktrace`,e.stacktrace?.print())}),this._listeners=[]),e.ENABLE_TRACKING&&this._event&&e.MEMORY_LEAK_WATCHER.delete(this._event))}};D.ENABLE_TRACKING=!1,D.MEMORY_LEAK_WATCHER=new T;function O(e,t,n,r){return e.addEventListener(t,n,r),{dispose:()=>{e.removeEventListener(t,n,r)}}}var re=class{constructor(){this._onFired=new D,this._currentFireCount=0,this._queued=!1,this.onEvent=e=>{let t=this._currentFireCount;return this._onFired.event(()=>{this._currentFireCount>t&&e()})}}fire(){this._currentFireCount++,!this._queued&&(this._queued=!0,queueMicrotask(()=>{this._queued=!1,this._onFired.fire()}))}dispose(){this._onFired.dispose()}},k;(function(e){e.NONE={dispose:()=>{}};function t(e){return{dispose:()=>{e()}}}e.from=t})(k||={});var A=class{get isDisposed(){return this._isDisposed}constructor(...e){this._isDisposed=!1,this._disposables=e}addDisposables(...e){e.forEach(e=>this._disposables.push(e))}dispose(){this._isDisposed||(this._isDisposed=!0,this._disposables.forEach(e=>e.dispose()),this._disposables=[])}},ie=class{constructor(){this._disposable=k.NONE}set value(e){this._disposable&&this._disposable.dispose(),this._disposable=e}dispose(){this._disposable&&=(this._disposable.dispose(),k.NONE)}},ae=class extends A{constructor(e){super(),this._onDidChange=new D,this.onDidChange=this._onDidChange.event,this._value=null,this.addDisposables(this._onDidChange,oe(e,e=>{this._value={hasScrollX:e.target.scrollWidth>e.target.clientWidth,hasScrollY:e.target.scrollHeight>e.target.clientHeight},this._onDidChange.fire(this._value)}))}};function oe(e,t){let n=new ResizeObserver(e=>{requestAnimationFrame(()=>{let n=e[0];t(n)})});return n.observe(e),{dispose:()=>{n.unobserve(e),n.disconnect()}}}var se=(e,...t)=>{for(let n of t)e.classList.contains(n)&&e.classList.remove(n)},j=(e,...t)=>{for(let n of t)e.classList.contains(n)||e.classList.add(n)},M=(e,t,n)=>{let r=e.classList.contains(t);n&&!r&&e.classList.add(t),!n&&r&&e.classList.remove(t)};function ce(e,t){for(;e;){if(e===t)return!0;e=e.parentNode}return!1}function le(e){return new ue(e)}var ue=class extends A{constructor(e){super(),this._onDidFocus=new D,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new D,this.onDidBlur=this._onDidBlur.event,this.addDisposables(this._onDidFocus,this._onDidBlur);let t=ce(document.activeElement,e),n=!1,r=()=>{n=!1,t||(t=!0,this._onDidFocus.fire())},i=()=>{t&&(n=!0,window.setTimeout(()=>{n&&(n=!1,t=!1,this._onDidBlur.fire())},0))};this._refreshStateHandler=()=>{ce(document.activeElement,e)!==t&&(t?i():r())},this.addDisposables(O(e,`focus`,r,!0)),this.addDisposables(O(e,`blur`,i,!0))}refreshState(){this._refreshStateHandler()}},de=`dv-quasiPreventDefault`;function fe(e){e[de]=!0}function pe(e){return e[de]}function me(e,t){let n=Array.from(t);for(let t of n){if(t.href){let n=e.createElement(`link`);n.href=t.href,n.type=t.type,n.rel=`stylesheet`,e.head.appendChild(n)}let n=[];try{t.cssRules&&(n=Array.from(t.cssRules).map(e=>e.cssText))}catch{}for(let t of n){let n=e.createElement(`style`);n.appendChild(e.createTextNode(t)),e.head.appendChild(n)}}}function he(e){let{left:t,top:n,width:r,height:i}=e.getBoundingClientRect();return{left:t+window.scrollX,top:n+window.scrollY,width:r,height:i}}function ge(e){let t=e;for(;t?.parentNode;)if(t.parentNode===document)return!0;else t=t.parentNode instanceof DocumentFragment?t.parentNode.host:t.parentNode;return!1}function _e(e,t){e.setAttribute(`data-testid`,t)}function ve(e){let t=[];function n(r){if(r.nodeType===Node.ELEMENT_NODE){e.includes(r.tagName)&&t.push(r),r.shadowRoot&&n(r.shadowRoot);for(let e of r.children)n(e)}}return n(document.documentElement),t}function ye(e=document){let t=ve([`IFRAME`,`WEBVIEW`]),n=new WeakMap;for(let e of t)n.set(e,e.style.pointerEvents),e.style.pointerEvents=`none`;return{release:()=>{for(let e of t)e.style.pointerEvents=n.get(e)??`auto`;t.splice(0,t.length)}}}function be(e){function t(e){let t=[];for(let n=0;n<e.classList.length;n++)t.push(e.classList.item(n));return t}let n,r=e;for(;r!==null&&(n=t(r).find(e=>e.startsWith(`dockview-theme-`)),typeof n!=`string`);)r=r.parentElement;return n}var xe=class{constructor(e){this.element=e,this._classNames=[]}setClassNames(e){for(let e of this._classNames)M(this.element,e,!1);this._classNames=e.split(` `).filter(e=>e.trim().length>0);for(let e of this._classNames)M(this.element,e,!0)}},Se=100;function Ce(e,t){let n=he(e),r=he(t);return!(n.left<r.left||n.left+n.width>r.left+r.width)}function we(e){let t=new D,n=e.screenX,r=e.screenY,i,a=()=>{if(e.closed)return;let o=e.screenX,s=e.screenY;(o!==n||s!==r)&&(clearTimeout(i),i=setTimeout(()=>{t.fire()},Se),n=o,r=s),requestAnimationFrame(a)};return a(),t}function Te(e,t){let n;return new A(O(e,`resize`,()=>{clearTimeout(n),n=setTimeout(()=>{t()},Se)}))}function Ee(e,t,n={buffer:10}){let r=n.buffer,i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),o=0,s=0,c=i.left-a.left,l=i.top-a.top,u=i.bottom-a.bottom,d=i.right-a.right;c<r?o=r-c:d>r&&(o=-r-d),l<r?s=r-l:u>r&&(s=-u-r),(o!==0||s!==0)&&(e.style.transform=`translate(${o}px, ${s}px)`)}function De(e){let t=e;for(;t&&(t.style.zIndex===`auto`||t.style.zIndex===``);)t=t.parentElement;return t}function Oe(e){if(e.length===0)throw Error(`Invalid tail call`);return[e.slice(0,e.length-1),e[e.length-1]]}function ke(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Ae(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.unshift(t))}function je(e,t){let n=e.indexOf(t);n>-1&&(e.splice(n,1),e.push(t))}function Me(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(t(r))return n}return-1}function Ne(e,t){let n=e.findIndex(e=>e===t);return n>-1?(e.splice(n,1),!0):!1}var Pe=(e,t,n)=>t>n?t:Math.min(n,Math.max(e,t)),Fe=()=>{let e=1;return{next:()=>(e++).toString()}},Ie=(e,t)=>{let n=[];if(typeof t!=`number`&&(t=e,e=0),e<=t)for(let r=e;r<t;r++)n.push(r);else for(let r=e;r>t;r--)n.push(r);return n},Le=class{set size(e){this._size=e}get size(){return this._size}get cachedVisibleSize(){return this._cachedVisibleSize}get visible(){return this._cachedVisibleSize===void 0}get minimumSize(){return this.visible?this.view.minimumSize:0}get viewMinimumSize(){return this.view.minimumSize}get maximumSize(){return this.visible?this.view.maximumSize:0}get viewMaximumSize(){return this.view.maximumSize}get priority(){return this.view.priority}get snap(){return!!this.view.snap}set enabled(e){this.container.style.pointerEvents=e?``:`none`}constructor(e,t,n,r){this.container=e,this.view=t,this.disposable=r,this._cachedVisibleSize=void 0,typeof n==`number`?(this._size=n,this._cachedVisibleSize=void 0,e.classList.add(`visible`)):(this._size=0,this._cachedVisibleSize=n.cachedVisibleSize)}setVisible(e,t){e!==this.visible&&(e?(this.size=Pe(this._cachedVisibleSize??0,this.viewMinimumSize,this.viewMaximumSize),this._cachedVisibleSize=void 0):(this._cachedVisibleSize=typeof t==`number`?t:this.size,this.size=0),this.container.classList.toggle(`visible`,e),this.view.setVisible&&this.view.setVisible(e))}dispose(){return this.disposable.dispose(),this.view}},N;(function(e){e.HORIZONTAL=`HORIZONTAL`,e.VERTICAL=`VERTICAL`})(N||={});var Re;(function(e){e[e.MAXIMUM=0]=`MAXIMUM`,e[e.MINIMUM=1]=`MINIMUM`,e[e.DISABLED=2]=`DISABLED`,e[e.ENABLED=3]=`ENABLED`})(Re||={});var ze;(function(e){e.Low=`low`,e.High=`high`,e.Normal=`normal`})(ze||={});var Be;(function(e){e.Distribute={type:`distribute`};function t(e){return{type:`split`,index:e}}e.Split=t;function n(e){return{type:`invisible`,cachedVisibleSize:e}}e.Invisible=n})(Be||={});var Ve=class{get contentSize(){return this._contentSize}get size(){return this._size}set size(e){this._size=e}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get length(){return this.viewItems.length}get proportions(){return this._proportions?[...this._proportions]:void 0}get orientation(){return this._orientation}set orientation(e){this._orientation=e;let t=this.size;this.size=this.orthogonalSize,this.orthogonalSize=t,se(this.element,`dv-horizontal`,`dv-vertical`),this.element.classList.add(this.orientation==N.HORIZONTAL?`dv-horizontal`:`dv-vertical`)}get minimumSize(){return this.viewItems.reduce((e,t)=>e+t.minimumSize,0)}get maximumSize(){return this.length===0?1/0:this.viewItems.reduce((e,t)=>e+t.maximumSize,0)}get startSnappingEnabled(){return this._startSnappingEnabled}set startSnappingEnabled(e){this._startSnappingEnabled!==e&&(this._startSnappingEnabled=e,this.updateSashEnablement())}get endSnappingEnabled(){return this._endSnappingEnabled}set endSnappingEnabled(e){this._endSnappingEnabled!==e&&(this._endSnappingEnabled=e,this.updateSashEnablement())}get disabled(){return this._disabled}set disabled(e){this._disabled=e,M(this.element,`dv-splitview-disabled`,e)}get margin(){return this._margin}set margin(e){this._margin=e,M(this.element,`dv-splitview-has-margin`,e!==0)}constructor(e,t){this.container=e,this.viewItems=[],this.sashes=[],this._size=0,this._orthogonalSize=0,this._contentSize=0,this._proportions=void 0,this._startSnappingEnabled=!0,this._endSnappingEnabled=!0,this._disabled=!1,this._margin=0,this._onDidSashEnd=new D,this.onDidSashEnd=this._onDidSashEnd.event,this._onDidAddView=new D,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new D,this.onDidRemoveView=this._onDidRemoveView.event,this.resize=(e,t,n=this.viewItems.map(e=>e.size),r,i,a=-1/0,o=1/0,s,c)=>{if(e<0||e>this.viewItems.length)return 0;let l=Ie(e,-1),u=Ie(e+1,this.viewItems.length);if(i)for(let e of i)Ae(l,e),Ae(u,e);if(r)for(let e of r)je(l,e),je(u,e);let d=l.map(e=>this.viewItems[e]),f=l.map(e=>n[e]),p=u.map(e=>this.viewItems[e]),m=u.map(e=>n[e]),h=l.reduce((e,t)=>e+this.viewItems[t].minimumSize-n[t],0),g=l.reduce((e,t)=>e+this.viewItems[t].maximumSize-n[t],0),_=u.length===0?1/0:u.reduce((e,t)=>e+n[t]-this.viewItems[t].minimumSize,0),v=u.length===0?-1/0:u.reduce((e,t)=>e+n[t]-this.viewItems[t].maximumSize,0),y=Math.max(h,v),b=Math.min(_,g),x=!1;if(s){let e=this.viewItems[s.index],n=t>=s.limitDelta;x=n!==e.visible,e.setVisible(n,s.size)}if(!x&&c){let e=this.viewItems[c.index],n=t<c.limitDelta;x=n!==e.visible,e.setVisible(n,c.size)}if(x)return this.resize(e,t,n,r,i,a,o);let S=Pe(t,y,b),C=0,w=S;for(let e=0;e<d.length;e++){let t=d[e],n=Pe(f[e]+w,t.minimumSize,t.maximumSize),r=n-f[e];C+=r,w-=r,t.size=n}let ee=C;for(let e=0;e<p.length;e++){let t=p[e],n=Pe(m[e]-ee,t.minimumSize,t.maximumSize),r=n-m[e];ee+=r,t.size=n}return t},this._orientation=t.orientation??N.VERTICAL,this.element=this.createContainer(),this.margin=t.margin??0,this.proportionalLayout=t.proportionalLayout===void 0?!0:!!t.proportionalLayout,this.viewContainer=this.createViewContainer(),this.sashContainer=this.createSashContainer(),this.element.appendChild(this.sashContainer),this.element.appendChild(this.viewContainer),this.container.appendChild(this.element),this.style(t.styles),t.descriptor&&(this._size=t.descriptor.size,t.descriptor.views.forEach((e,t)=>{let n=e.visible===void 0||e.visible?e.size:{type:`invisible`,cachedVisibleSize:e.size},r=e.view;this.addView(r,n,t,!0)}),this._contentSize=this.viewItems.reduce((e,t)=>e+t.size,0),this.saveProportions())}style(e){e?.separatorBorder===`transparent`?(se(this.element,`dv-separator-border`),this.element.style.removeProperty(`--dv-separator-border`)):(j(this.element,`dv-separator-border`),e?.separatorBorder&&this.element.style.setProperty(`--dv-separator-border`,e.separatorBorder))}isViewVisible(e){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);return this.viewItems[e].visible}setViewVisible(e,t){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);let n=this.viewItems[e];n.setVisible(t,n.size),this.distributeEmptySpace(e),this.layoutViews(),this.saveProportions()}getViewSize(e){return e<0||e>=this.viewItems.length?-1:this.viewItems[e].size}resizeView(e,t){if(e<0||e>=this.viewItems.length)return;let n=Ie(this.viewItems.length).filter(t=>t!==e),r=[...n.filter(e=>this.viewItems[e].priority===ze.Low),e],i=n.filter(e=>this.viewItems[e].priority===ze.High),a=this.viewItems[e];t=Math.round(t),t=Pe(t,a.minimumSize,Math.min(a.maximumSize,this._size)),a.size=t,this.relayout(r,i)}getViews(){return this.viewItems.map(e=>e.view)}onDidChange(e,t){let n=this.viewItems.indexOf(e);if(n<0||n>=this.viewItems.length)return;t=typeof t==`number`?t:e.size,t=Pe(t,e.minimumSize,e.maximumSize),e.size=t;let r=Ie(this.viewItems.length).filter(e=>e!==n),i=[...r.filter(e=>this.viewItems[e].priority===ze.Low),n],a=r.filter(e=>this.viewItems[e].priority===ze.High);this.relayout([...i,n],a)}addView(e,t={type:`distribute`},n=this.viewItems.length,r){let i=document.createElement(`div`);i.className=`dv-view`,i.appendChild(e.element);let a;a=typeof t==`number`?t:t.type===`split`?this.getViewSize(t.index)/2:t.type===`invisible`?{cachedVisibleSize:t.cachedVisibleSize}:e.minimumSize;let o=e.onDidChange(e=>this.onDidChange(s,e.size)),s=new Le(i,e,a,{dispose:()=>{o.dispose(),this.viewContainer.removeChild(i)}});if(n===this.viewItems.length?this.viewContainer.appendChild(i):this.viewContainer.insertBefore(i,this.viewContainer.children.item(n)),this.viewItems.splice(n,0,s),this.viewItems.length>1){let e=document.createElement(`div`);e.className=`dv-sash`;let t=t=>{for(let e of this.viewItems)e.enabled=!1;let n=ye(),r=this._orientation===N.HORIZONTAL?t.clientX:t.clientY,i=Me(this.sashes,t=>t.container===e),a=this.viewItems.map(e=>e.size),o,s,c=Ie(i,-1),l=Ie(i+1,this.viewItems.length),u=c.reduce((e,t)=>e+(this.viewItems[t].minimumSize-a[t]),0),d=c.reduce((e,t)=>e+(this.viewItems[t].viewMaximumSize-a[t]),0),f=l.length===0?1/0:l.reduce((e,t)=>e+(a[t]-this.viewItems[t].minimumSize),0),p=l.length===0?-1/0:l.reduce((e,t)=>e+(a[t]-this.viewItems[t].viewMaximumSize),0),m=Math.max(u,p),h=Math.min(f,d),g=this.findFirstSnapIndex(c),_=this.findFirstSnapIndex(l);if(typeof g==`number`){let e=this.viewItems[g],t=Math.floor(e.viewMinimumSize/2);o={index:g,limitDelta:e.visible?m-t:m+t,size:e.size}}if(typeof _==`number`){let e=this.viewItems[_],t=Math.floor(e.viewMinimumSize/2);s={index:_,limitDelta:e.visible?h+t:h-t,size:e.size}}let v=e=>{let t=(this._orientation===N.HORIZONTAL?e.clientX:e.clientY)-r;this.resize(i,t,a,void 0,void 0,m,h,o,s),this.distributeEmptySpace(),this.layoutViews()},y=()=>{for(let e of this.viewItems)e.enabled=!0;n.release(),this.saveProportions(),document.removeEventListener(`pointermove`,v),document.removeEventListener(`pointerup`,y),document.removeEventListener(`pointercancel`,y),document.removeEventListener(`contextmenu`,y),this._onDidSashEnd.fire(void 0)};document.addEventListener(`pointermove`,v),document.addEventListener(`pointerup`,y),document.addEventListener(`pointercancel`,y),document.addEventListener(`contextmenu`,y)};e.addEventListener(`pointerdown`,t);let n={container:e,disposable:()=>{e.removeEventListener(`pointerdown`,t),this.sashContainer.removeChild(e)}};this.sashContainer.appendChild(e),this.sashes.push(n)}r||this.relayout([n]),!r&&typeof t!=`number`&&t.type===`distribute`&&this.distributeViewSizes(),this._onDidAddView.fire(e)}distributeViewSizes(){let e=[],t=0;for(let n of this.viewItems)n.maximumSize-n.minimumSize>0&&(e.push(n),t+=n.size);let n=Math.floor(t/e.length);for(let t of e)t.size=Pe(n,t.minimumSize,t.maximumSize);let r=Ie(this.viewItems.length),i=r.filter(e=>this.viewItems[e].priority===ze.Low),a=r.filter(e=>this.viewItems[e].priority===ze.High);this.relayout(i,a)}removeView(e,t,n=!1){let r=this.viewItems.splice(e,1)[0];if(r.dispose(),this.viewItems.length>=1){let t=Math.max(e-1,0);this.sashes.splice(t,1)[0].disposable()}return n||this.relayout(),t&&t.type===`distribute`&&this.distributeViewSizes(),this._onDidRemoveView.fire(r.view),r.view}getViewCachedVisibleSize(e){if(e<0||e>=this.viewItems.length)throw Error(`Index out of bounds`);return this.viewItems[e].cachedVisibleSize}moveView(e,t){let n=this.getViewCachedVisibleSize(e),r=n===void 0?this.getViewSize(e):Be.Invisible(n),i=this.removeView(e,void 0,!0);this.addView(i,r,t)}layout(e,t){let n=Math.max(this.size,this._contentSize);if(this.size=e,this.orthogonalSize=t,this.proportions){let t=0;for(let n=0;n<this.viewItems.length;n++){let r=this.viewItems[n],i=this.proportions[n];typeof i==`number`?t+=i:e-=r.size}for(let n=0;n<this.viewItems.length;n++){let r=this.viewItems[n],i=this.proportions[n];typeof i==`number`&&t>0&&(r.size=Pe(Math.round(i*e/t),r.minimumSize,r.maximumSize))}}else{let t=Ie(this.viewItems.length),r=t.filter(e=>this.viewItems[e].priority===ze.Low),i=t.filter(e=>this.viewItems[e].priority===ze.High);this.resize(this.viewItems.length-1,e-n,void 0,r,i)}this.distributeEmptySpace(),this.layoutViews()}relayout(e,t){let n=this.viewItems.reduce((e,t)=>e+t.size,0);this.resize(this.viewItems.length-1,this._size-n,void 0,e,t),this.distributeEmptySpace(),this.layoutViews(),this.saveProportions()}distributeEmptySpace(e){let t=this.viewItems.reduce((e,t)=>e+t.size,0),n=this.size-t,r=Ie(this.viewItems.length-1,-1),i=r.filter(e=>this.viewItems[e].priority===ze.Low),a=r.filter(e=>this.viewItems[e].priority===ze.High);for(let e of a)Ae(r,e);for(let e of i)je(r,e);typeof e==`number`&&je(r,e);for(let e=0;n!==0&&e<r.length;e++){let t=this.viewItems[r[e]],i=Pe(t.size+n,t.minimumSize,t.maximumSize),a=i-t.size;n-=a,t.size=i}}saveProportions(){this.proportionalLayout&&this._contentSize>0&&(this._proportions=this.viewItems.map(e=>e.visible?e.size/this._contentSize:void 0))}layoutViews(){if(this._contentSize=this.viewItems.reduce((e,t)=>e+t.size,0),this.updateSashEnablement(),this.viewItems.length===0)return;let e=this.viewItems.filter(e=>e.visible),t=Math.max(0,e.length-1),n=this.margin*t/Math.max(1,e.length),r=0,i=[],a=this.viewItems.reduce((e,t,n)=>{let r=t.visible?1:0;return n===0?e.push(r):e.push(e[n-1]+r),e},[]);this.viewItems.forEach((e,o)=>{r+=this.viewItems[o].size,i.push(r);let s=e.visible?e.size-n:0,c=Math.max(0,a[o]-1),l=o===0||c===0?0:i[o-1]+c/t*n;if(o<this.viewItems.length-1){let t=e.visible?l+s-4/2+this.margin/2:l;this._orientation===N.HORIZONTAL&&(this.sashes[o].container.style.left=`${t}px`,this.sashes[o].container.style.top=`0px`),this._orientation===N.VERTICAL&&(this.sashes[o].container.style.left=`0px`,this.sashes[o].container.style.top=`${t}px`)}this._orientation===N.HORIZONTAL&&(e.container.style.width=`${s}px`,e.container.style.left=`${l}px`,e.container.style.top=``,e.container.style.height=``),this._orientation===N.VERTICAL&&(e.container.style.height=`${s}px`,e.container.style.top=`${l}px`,e.container.style.width=``,e.container.style.left=``),e.view.layout(e.size-n,this._orthogonalSize)})}findFirstSnapIndex(e){for(let t of e){let e=this.viewItems[t];if(e.visible&&e.snap)return t}for(let t of e){let e=this.viewItems[t];if(e.visible&&e.maximumSize-e.minimumSize>0)return;if(!e.visible&&e.snap)return t}}updateSashEnablement(){let e=!1,t=this.viewItems.map(t=>e=t.size-t.minimumSize>0||e);e=!1;let n=this.viewItems.map(t=>e=t.maximumSize-t.size>0||e),r=[...this.viewItems].reverse();e=!1;let i=r.map(t=>e=t.size-t.minimumSize>0||e).reverse();e=!1;let a=r.map(t=>e=t.maximumSize-t.size>0||e).reverse(),o=0;for(let e=0;e<this.sashes.length;e++){let r=this.sashes[e],s=this.viewItems[e];o+=s.size;let c=!(t[e]&&a[e+1]),l=!(n[e]&&i[e+1]);if(c&&l){let n=Ie(e,-1),a=Ie(e+1,this.viewItems.length),s=this.findFirstSnapIndex(n),c=this.findFirstSnapIndex(a),l=typeof s==`number`&&!this.viewItems[s].visible,u=typeof c==`number`&&!this.viewItems[c].visible;l&&i[e]&&(o>0||this.startSnappingEnabled)?this.updateSash(r,Re.MINIMUM):u&&t[e]&&(o<this._contentSize||this.endSnappingEnabled)?this.updateSash(r,Re.MAXIMUM):this.updateSash(r,Re.DISABLED)}else c&&!l?this.updateSash(r,Re.MINIMUM):!c&&l?this.updateSash(r,Re.MAXIMUM):this.updateSash(r,Re.ENABLED)}}updateSash(e,t){M(e.container,`dv-disabled`,t===Re.DISABLED),M(e.container,`dv-enabled`,t===Re.ENABLED),M(e.container,`dv-maximum`,t===Re.MAXIMUM),M(e.container,`dv-minimum`,t===Re.MINIMUM)}createViewContainer(){let e=document.createElement(`div`);return e.className=`dv-view-container`,e}createSashContainer(){let e=document.createElement(`div`);return e.className=`dv-sash-container`,e}createContainer(){let e=document.createElement(`div`);return e.className=`dv-split-view-container ${this._orientation===N.HORIZONTAL?`dv-horizontal`:`dv-vertical`}`,e}dispose(){this._onDidSashEnd.dispose(),this._onDidAddView.dispose(),this._onDidRemoveView.dispose();for(let e=0;e<this.element.children.length;e++)if(this.element.children.item(e)===this.element){this.element.removeChild(this.element);break}for(let e of this.viewItems)e.dispose();this.element.remove()}},He=Object.keys({orientation:void 0,descriptor:void 0,proportionalLayout:void 0,styles:void 0,margin:void 0,disableAutoResizing:void 0,className:void 0}),Ue=class extends A{get onDidAddView(){return this.splitview.onDidAddView}get onDidRemoveView(){return this.splitview.onDidRemoveView}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get orientation(){return this.splitview.orientation}get size(){return this.splitview.size}get orthogonalSize(){return this.splitview.orthogonalSize}constructor(e,t){super(),this.paneItems=[],this.skipAnimation=!1,this._onDidChange=new D,this.onDidChange=this._onDidChange.event,this._orientation=t.orientation??N.VERTICAL,this.element=document.createElement(`div`),this.element.className=`dv-pane-container`,e.appendChild(this.element),this.splitview=new Ve(this.element,{orientation:this._orientation,proportionalLayout:!1,descriptor:t.descriptor}),this.getPanes().forEach(e=>{let t=new A(e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)})),n={pane:e,disposable:{dispose:()=>{t.dispose()}}};this.paneItems.push(n),e.orthogonalSize=this.splitview.orthogonalSize}),this.addDisposables(this._onDidChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire(void 0)}),this.splitview.onDidAddView(()=>{this._onDidChange.fire()}),this.splitview.onDidRemoveView(()=>{this._onDidChange.fire()}))}setViewVisible(e,t){this.splitview.setViewVisible(e,t)}addPane(e,t,n=this.splitview.length,r=!1){let i=e.onDidChangeExpansionState(()=>{this.setupAnimation(),this._onDidChange.fire(void 0)}),a={pane:e,disposable:{dispose:()=>{i.dispose()}}};this.paneItems.splice(n,0,a),e.orthogonalSize=this.splitview.orthogonalSize,this.splitview.addView(e,t,n,r)}getViewSize(e){return this.splitview.getViewSize(e)}getPanes(){return this.splitview.getViews()}removePane(e,t={skipDispose:!1}){let n=this.paneItems.splice(e,1)[0];return this.splitview.removeView(e),t.skipDispose||(n.disposable.dispose(),n.pane.dispose()),n}moveView(e,t){if(e===t)return;let n=this.removePane(e,{skipDispose:!0});this.skipAnimation=!0;try{this.addPane(n.pane,n.pane.size,t,!1)}finally{this.skipAnimation=!1}}layout(e,t){this.splitview.layout(e,t)}setupAnimation(){this.skipAnimation||(this.animationTimer&&=(clearTimeout(this.animationTimer),void 0),j(this.element,`dv-animated`),this.animationTimer=setTimeout(()=>{this.animationTimer=void 0,se(this.element,`dv-animated`)},200))}dispose(){super.dispose(),this.animationTimer&&=(clearTimeout(this.animationTimer),void 0),this.paneItems.forEach(e=>{e.disposable.dispose(),e.pane.dispose()}),this.paneItems=[],this.splitview.dispose(),this.element.remove()}},We=class{get minimumWidth(){return this.view.minimumWidth}get maximumWidth(){return this.view.maximumWidth}get minimumHeight(){return this.view.minimumHeight}get maximumHeight(){return this.view.maximumHeight}get priority(){return this.view.priority}get snap(){return this.view.snap}get minimumSize(){return this.orientation===N.HORIZONTAL?this.minimumHeight:this.minimumWidth}get maximumSize(){return this.orientation===N.HORIZONTAL?this.maximumHeight:this.maximumWidth}get minimumOrthogonalSize(){return this.orientation===N.HORIZONTAL?this.minimumWidth:this.minimumHeight}get maximumOrthogonalSize(){return this.orientation===N.HORIZONTAL?this.maximumWidth:this.maximumHeight}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get element(){return this.view.element}get width(){return this.orientation===N.HORIZONTAL?this.orthogonalSize:this.size}get height(){return this.orientation===N.HORIZONTAL?this.size:this.orthogonalSize}constructor(e,t,n,r=0){this.view=e,this.orientation=t,this._onDidChange=new D,this.onDidChange=this._onDidChange.event,this._orthogonalSize=n,this._size=r,this._disposable=this.view.onDidChange(e=>{e?this._onDidChange.fire({size:this.orientation===N.VERTICAL?e.width:e.height,orthogonalSize:this.orientation===N.VERTICAL?e.height:e.width}):this._onDidChange.fire({})})}setVisible(e){this.view.setVisible&&this.view.setVisible(e)}layout(e,t){this._size=e,this._orthogonalSize=t,this.view.layout(this.width,this.height)}dispose(){this._onDidChange.dispose(),this._disposable.dispose()}},Ge=class e extends A{get width(){return this.orientation===N.HORIZONTAL?this.size:this.orthogonalSize}get height(){return this.orientation===N.HORIZONTAL?this.orthogonalSize:this.size}get minimumSize(){return this.children.length===0?0:Math.max(...this.children.map((e,t)=>this.splitview.isViewVisible(t)?e.minimumOrthogonalSize:0))}get maximumSize(){return Math.min(...this.children.map((e,t)=>this.splitview.isViewVisible(t)?e.maximumOrthogonalSize:1/0))}get minimumOrthogonalSize(){return this.splitview.minimumSize}get maximumOrthogonalSize(){return this.splitview.maximumSize}get orthogonalSize(){return this._orthogonalSize}get size(){return this._size}get minimumWidth(){return this.orientation===N.HORIZONTAL?this.minimumOrthogonalSize:this.minimumSize}get minimumHeight(){return this.orientation===N.HORIZONTAL?this.minimumSize:this.minimumOrthogonalSize}get maximumWidth(){return this.orientation===N.HORIZONTAL?this.maximumOrthogonalSize:this.maximumSize}get maximumHeight(){return this.orientation===N.HORIZONTAL?this.maximumSize:this.maximumOrthogonalSize}get priority(){if(this.children.length===0)return ze.Normal;let e=this.children.map(e=>e.priority===void 0?ze.Normal:e.priority);return e.some(e=>e===ze.High)?ze.High:e.some(e=>e===ze.Low)?ze.Low:ze.Normal}get disabled(){return this.splitview.disabled}set disabled(e){this.splitview.disabled=e}get margin(){return this.splitview.margin}set margin(t){this.splitview.margin=t,this.children.forEach(n=>{n instanceof e&&(n.margin=t)})}constructor(e,t,n,r,i,a,o,s){if(super(),this.orientation=e,this.proportionalLayout=t,this.styles=n,this._childrenDisposable=k.NONE,this.children=[],this._onDidChange=new D,this.onDidChange=this._onDidChange.event,this._onDidVisibilityChange=new D,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._orthogonalSize=i,this._size=r,this.element=document.createElement(`div`),this.element.className=`dv-branch-node`,!s)this.splitview=new Ve(this.element,{orientation:this.orientation,proportionalLayout:t,styles:n,margin:o}),this.splitview.layout(this.size,this.orthogonalSize);else{let e={views:s.map(e=>({view:e.node,size:e.node.size,visible:e.node instanceof We&&e.visible!==void 0?e.visible:!0})),size:this.orthogonalSize};this.children=s.map(e=>e.node),this.splitview=new Ve(this.element,{orientation:this.orientation,descriptor:e,proportionalLayout:t,styles:n,margin:o})}this.disabled=a,this.addDisposables(this._onDidChange,this._onDidVisibilityChange,this.splitview.onDidSashEnd(()=>{this._onDidChange.fire({})})),this.setupChildrenEvents()}setVisible(e){}isChildVisible(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.isViewVisible(e)}setChildVisible(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);if(this.splitview.isViewVisible(e)===t)return;let n=this.splitview.contentSize===0;this.splitview.setViewVisible(e,t);let r=this.splitview.contentSize===0;(t&&n||!t&&r)&&this._onDidVisibilityChange.fire({visible:t})}moveChild(e,t){if(e===t)return;if(e<0||e>=this.children.length)throw Error(`Invalid from index`);e<t&&t--,this.splitview.moveView(e,t);let n=this._removeChild(e);this._addChild(n,t)}getChildSize(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.getViewSize(e)}resizeChild(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);this.splitview.resizeView(e,t)}layout(e,t){this._size=t,this._orthogonalSize=e,this.splitview.layout(t,e)}addChild(e,t,n,r){if(n<0||n>this.children.length)throw Error(`Invalid index`);this.splitview.addView(e,t,n,r),this._addChild(e,n)}getChildCachedVisibleSize(e){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.getViewCachedVisibleSize(e)}removeChild(e,t){if(e<0||e>=this.children.length)throw Error(`Invalid index`);return this.splitview.removeView(e,t),this._removeChild(e)}_addChild(e,t){this.children.splice(t,0,e),this.setupChildrenEvents()}_removeChild(e){let[t]=this.children.splice(e,1);return this.setupChildrenEvents(),t}setupChildrenEvents(){this._childrenDisposable.dispose(),this._childrenDisposable=new A(w.any(...this.children.map(e=>e.onDidChange))(e=>{this._onDidChange.fire({size:e.orthogonalSize})}),...this.children.map((t,n)=>t instanceof e?t.onDidVisibilityChange(({visible:e})=>{this.setChildVisible(n,e)}):k.NONE))}dispose(){this._childrenDisposable.dispose(),this.splitview.dispose(),this.children.forEach(e=>e.dispose()),super.dispose()}};function Ke(e,t){if(e instanceof We)return e;if(e instanceof Ge)return Ke(e.children[t?e.children.length-1:0],t);throw Error(`invalid node`)}function qe(e,t,n){if(e instanceof Ge){let r=new Ge(e.orientation,e.proportionalLayout,e.styles,t,n,e.disabled,e.margin);for(let t=e.children.length-1;t>=0;t--){let n=e.children[t];r.addChild(qe(n,n.size,n.orthogonalSize),n.size,0,!0)}return r}else return new We(e.view,e.orientation,n)}function Je(e,t,n){if(e instanceof Ge){let r=new Ge(et(e.orientation),e.proportionalLayout,e.styles,t,n,e.disabled,e.margin),i=0;for(let a=e.children.length-1;a>=0;a--){let o=e.children[a],s=o instanceof Ge?o.orthogonalSize:o.size,c=e.size===0?0:Math.round(t*s/e.size);i+=c,a===0&&(c+=t-i),r.addChild(Je(o,n,c),c,0,!0)}return r}else return new We(e.view,et(e.orientation),n)}function Ye(e){let t=e.parentElement;if(!t)throw Error(`Invalid grid element`);let n=t.firstElementChild,r=0;for(;n!==e&&n!==t.lastElementChild&&n;)n=n.nextElementSibling,r++;return r}function Xe(e){let t=e.parentElement;if(!t)throw Error(`Invalid grid element`);if(/\bdv-grid-view\b/.test(t.className))return[];let n=Ye(t),r=t.parentElement.parentElement.parentElement;return[...Xe(r),n]}function Ze(e,t,n){if($e(e,t)===Qe(n)){let[e,r]=Oe(t),i=r;return(n===`right`||n===`bottom`)&&(i+=1),[...e,i]}else{let e=n===`right`||n===`bottom`?1:0;return[...t,e]}}function Qe(e){return e===`top`||e===`bottom`?N.VERTICAL:N.HORIZONTAL}function $e(e,t){return t.length%2==0?et(e):e}var et=e=>e===N.HORIZONTAL?N.VERTICAL:N.HORIZONTAL;function tt(e){return!!e.children}var nt=(e,t)=>{let n=t===N.VERTICAL?e.box.width:e.box.height;return tt(e)?{type:`branch`,data:e.children.map(e=>nt(e,et(t))),size:n}:typeof e.cachedVisibleSize==`number`?{type:`leaf`,data:e.view.toJSON(),size:e.cachedVisibleSize,visible:!1}:{type:`leaf`,data:e.view.toJSON(),size:n}},rt=class{get length(){return this._root?this._root.children.length:0}get orientation(){return this.root.orientation}set orientation(e){if(this.root.orientation===e)return;let{size:t,orthogonalSize:n}=this.root;this.root=Je(this.root,n,t),this.root.layout(t,n)}get width(){return this.root.width}get height(){return this.root.height}get minimumWidth(){return this.root.minimumWidth}get minimumHeight(){return this.root.minimumHeight}get maximumWidth(){return this.root.maximumHeight}get maximumHeight(){return this.root.maximumHeight}get locked(){return this._locked}set locked(e){this._locked=e;let t=[this.root];for(;t.length>0;){let n=t.pop();n instanceof Ge&&(n.disabled=e,t.push(...n.children))}}get margin(){return this._margin}set margin(e){this._margin=e,this.root.margin=e}maximizedView(){return this._maximizedNode?.leaf.view}hasMaximizedView(){return this._maximizedNode!==void 0}maximizeView(e){let t=Xe(e.element),[n,r]=this.getNode(t);if(!(r instanceof We)||this._maximizedNode?.leaf===r)return;this.hasMaximizedView()&&this.exitMaximizedView(),nt(this.getView(),this.orientation);let i=[];function a(e,t){for(let n=0;n<e.children.length;n++){let r=e.children[n];r instanceof We?r!==t&&(e.isChildVisible(n)?e.setChildVisible(n,!1):i.push(r)):a(r,t)}}a(this.root,r),this._maximizedNode={leaf:r,hiddenOnMaximize:i},this._onDidMaximizedNodeChange.fire({view:r.view,isMaximized:!0})}exitMaximizedView(){if(!this._maximizedNode)return;let e=this._maximizedNode.hiddenOnMaximize;function t(n){for(let r=n.children.length-1;r>=0;r--){let i=n.children[r];i instanceof We?e.includes(i)||n.setChildVisible(r,!0):t(i)}}t(this.root);let n=this._maximizedNode.leaf;this._maximizedNode=void 0,this._onDidMaximizedNodeChange.fire({view:n.view,isMaximized:!1})}serialize(){let e=this.maximizedView(),t;e&&(t=Xe(e.element)),this.hasMaximizedView()&&this.exitMaximizedView();let n={root:nt(this.getView(),this.orientation),width:this.width,height:this.height,orientation:this.orientation};return t&&(n.maximizedNode={location:t}),e&&this.maximizeView(e),n}dispose(){this.disposable.dispose(),this._onDidChange.dispose(),this._onDidMaximizedNodeChange.dispose(),this._onDidViewVisibilityChange.dispose(),this.root.dispose(),this._maximizedNode=void 0,this.element.remove()}clear(){let e=this.root.orientation;this.root=new Ge(e,this.proportionalLayout,this.styles,this.root.size,this.root.orthogonalSize,this.locked,this.margin)}deserialize(e,t){let n=e.orientation,r=n===N.VERTICAL?e.height:e.width;if(this._deserialize(e.root,n,t,r),this.layout(e.width,e.height),e.maximizedNode){let t=e.maximizedNode.location,[n,r]=this.getNode(t);if(!(r instanceof We))return;this.maximizeView(r.view)}}_deserialize(e,t,n,r){this.root=this._deserializeNode(e,t,n,r)}_deserializeNode(e,t,n,r){var i;let a;if(e.type===`branch`){let i=e.data.map(r=>({node:this._deserializeNode(r,et(t),n,e.size),visible:r.visible}));a=new Ge(t,this.proportionalLayout,this.styles,e.size,r,this.locked,this.margin,i)}else{let o=n.fromJSON(e);typeof e.visible==`boolean`&&((i=o.setVisible)==null||i.call(o,e.visible)),a=new We(o,t,r,e.size)}return a}get root(){return this._root}set root(e){let t=this._root;t&&(t.dispose(),this._maximizedNode=void 0,this.element.removeChild(t.element)),this._root=e,this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}normalize(){if(!this._root||this._root.children.length!==1)return;let e=this.root,t=e.children[0];if(t instanceof We)return;e.element.remove();let n=e.removeChild(0);e.dispose(),n.dispose(),this._root=qe(t,t.size,t.orthogonalSize),this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}insertOrthogonalSplitviewAtRoot(){if(!this._root)return;let e=this.root;if(e.element.remove(),this._root=new Ge(et(e.orientation),this.proportionalLayout,this.styles,this.root.orthogonalSize,this.root.size,this.locked,this.margin),e.children.length!==0)if(e.children.length===1){let t=e.children[0];e.removeChild(0).dispose(),e.dispose(),this._root.addChild(Je(t,t.orthogonalSize,t.size),Be.Distribute,0)}else this._root.addChild(e,Be.Distribute,0);this.element.appendChild(this._root.element),this.disposable.value=this._root.onDidChange(e=>{this._onDidChange.fire(e)})}next(e){return this.progmaticSelect(e)}previous(e){return this.progmaticSelect(e,!0)}getView(e){let t=e?this.getNode(e)[1]:this.root;return this._getViews(t,this.orientation)}_getViews(e,t,n){let r={height:e.height,width:e.width};if(e instanceof We)return{box:r,view:e.view,cachedVisibleSize:n};let i=[];for(let n=0;n<e.children.length;n++){let r=e.children[n],a=e.getChildCachedVisibleSize(n);i.push(this._getViews(r,et(t),a))}return{box:r,children:i}}progmaticSelect(e,t=!1){let[n,r]=this.getNode(e);if(!(r instanceof We))throw Error(`invalid location`);for(let r=n.length-1;r>-1;r--){let i=n[r],a=e[r]||0;if(t?a-1>-1:a+1<i.children.length)return Ke(i.children[t?a-1:a+1],t)}return Ke(this.root,t)}constructor(e,t,n,r,i){this.proportionalLayout=e,this.styles=t,this._locked=!1,this._margin=0,this._maximizedNode=void 0,this.disposable=new ie,this._onDidChange=new D,this.onDidChange=this._onDidChange.event,this._onDidViewVisibilityChange=new D,this.onDidViewVisibilityChange=this._onDidViewVisibilityChange.event,this._onDidMaximizedNodeChange=new D,this.onDidMaximizedNodeChange=this._onDidMaximizedNodeChange.event,this.element=document.createElement(`div`),this.element.className=`dv-grid-view`,this._locked=r??!1,this._margin=i??0,this.root=new Ge(n,e,t,0,0,this.locked,this.margin)}isViewVisible(e){let[t,n]=Oe(e),[,r]=this.getNode(t);if(!(r instanceof Ge))throw Error(`Invalid from location`);return r.isChildVisible(n)}setViewVisible(e,t){this.hasMaximizedView()&&this.exitMaximizedView();let[n,r]=Oe(e),[,i]=this.getNode(n);if(!(i instanceof Ge))throw Error(`Invalid from location`);this._onDidViewVisibilityChange.fire(),i.setChildVisible(r,t)}moveView(e,t,n){this.hasMaximizedView()&&this.exitMaximizedView();let[,r]=this.getNode(e);if(!(r instanceof Ge))throw Error(`Invalid location`);r.moveChild(t,n)}addView(e,t,n){this.hasMaximizedView()&&this.exitMaximizedView();let[r,i]=Oe(n),[a,o]=this.getNode(r);if(o instanceof Ge){let n=new We(e,et(o.orientation),o.orthogonalSize);o.addChild(n,t,i)}else{let[n,...s]=[...a].reverse(),[c,...l]=[...r].reverse(),u=0,d=n.getChildCachedVisibleSize(c);typeof d==`number`&&(u=Be.Invisible(d)),n.removeChild(c).dispose();let f=new Ge(o.orientation,this.proportionalLayout,this.styles,o.size,o.orthogonalSize,this.locked,this.margin);n.addChild(f,o.size,c);let p=new We(o.view,n.orientation,o.size);f.addChild(p,u,0),typeof t!=`number`&&t.type===`split`&&(t={type:`split`,index:0});let m=new We(e,n.orientation,o.size);f.addChild(m,t,i)}}remove(e,t){let n=Xe(e.element);return this.removeView(n,t)}removeView(e,t){this.hasMaximizedView()&&this.exitMaximizedView();let[n,r]=Oe(e),[i,a]=this.getNode(n);if(!(a instanceof Ge))throw Error(`Invalid location`);let o=a.children[r];if(!(o instanceof We))throw Error(`Invalid location`);if(a.removeChild(r,t),o.dispose(),a.children.length!==1)return o.view;let s=a.children[0];if(i.length===0)return s instanceof We?o.view:(a.removeChild(0,t),this.root=s,o.view);let[c,...l]=[...i].reverse(),[u,...d]=[...n].reverse(),f=a.isChildVisible(0);a.removeChild(0,t);let p=c.children.map((e,t)=>c.getChildSize(t));if(c.removeChild(u,t).dispose(),s instanceof Ge){p.splice(u,1,...s.children.map(e=>e.size));for(let e=0;e<s.children.length;e++){let t=s.children[e];c.addChild(t,t.size,u+e)}for(;s.children.length>0;)s.removeChild(0)}else{let e=new We(s.view,et(s.orientation),s.size),t=f?s.orthogonalSize:Be.Invisible(s.orthogonalSize);c.addChild(e,t,u)}s.dispose();for(let e=0;e<p.length;e++)c.resizeChild(e,p[e]);return o.view}layout(e,t){let[n,r]=this.root.orientation===N.HORIZONTAL?[t,e]:[e,t];this.root.layout(n,r)}getNode(e,t=this.root,n=[]){if(e.length===0)return[n,t];if(!(t instanceof Ge))throw Error(`Invalid location`);let[r,...i]=e;if(r<0||r>=t.children.length)throw Error(`Invalid location`);let a=t.children[r];return n.push(t),this.getNode(i,a,n)}},it=Object.keys({disableAutoResizing:void 0,proportionalLayout:void 0,orientation:void 0,hideBorders:void 0,className:void 0}),at=class extends A{get element(){return this._element}get disableResizing(){return this._disableResizing}set disableResizing(e){this._disableResizing=e}constructor(e,t=!1){super(),this._disableResizing=t,this._element=e,this.addDisposables(oe(this._element,e=>{if(this.isDisposed||this.disableResizing||!this._element.offsetParent||!ge(this._element))return;let{width:t,height:n}=e.contentRect;this.layout(t,n)}))}},ot=Fe();function st(e){switch(e){case`left`:return`left`;case`right`:return`right`;case`above`:return`top`;case`below`:return`bottom`;default:return`center`}}var ct=class extends at{get id(){return this._id}get size(){return this._groups.size}get groups(){return Array.from(this._groups.values()).map(e=>e.value)}get width(){return this.gridview.width}get height(){return this.gridview.height}get minimumHeight(){return this.gridview.minimumHeight}get maximumHeight(){return this.gridview.maximumHeight}get minimumWidth(){return this.gridview.minimumWidth}get maximumWidth(){return this.gridview.maximumWidth}get activeGroup(){return this._activeGroup}get locked(){return this.gridview.locked}set locked(e){this.gridview.locked=e}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._id=ot.next(),this._groups=new Map,this._onDidRemove=new D,this.onDidRemove=this._onDidRemove.event,this._onDidAdd=new D,this.onDidAdd=this._onDidAdd.event,this._onDidMaximizedChange=new D,this.onDidMaximizedChange=this._onDidMaximizedChange.event,this._onDidActiveChange=new D,this.onDidActiveChange=this._onDidActiveChange.event,this._bufferOnDidLayoutChange=new re,this.onDidLayoutChange=this._bufferOnDidLayoutChange.onEvent,this._onDidViewVisibilityChangeMicroTaskQueue=new re,this.onDidViewVisibilityChangeMicroTaskQueue=this._onDidViewVisibilityChangeMicroTaskQueue.onEvent,this.element.style.height=`100%`,this.element.style.width=`100%`,this._classNames=new xe(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this.gridview=new rt(!!t.proportionalLayout,t.styles,t.orientation,t.locked,t.margin),this.gridview.locked=!!t.locked,this.element.appendChild(this.gridview.element),this.layout(0,0,!0),this.addDisposables(this.gridview.onDidMaximizedNodeChange(e=>{this._onDidMaximizedChange.fire({panel:e.view,isMaximized:e.isMaximized})}),this.gridview.onDidViewVisibilityChange(()=>this._onDidViewVisibilityChangeMicroTaskQueue.fire()),this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.layout(this.width,this.height,!0)}),k.from(()=>{var e;(e=this.element.parentElement)==null||e.removeChild(this.element)}),this.gridview.onDidChange(()=>{this._bufferOnDidLayoutChange.fire()}),w.any(this.onDidAdd,this.onDidRemove,this.onDidActiveChange)(()=>{this._bufferOnDidLayoutChange.fire()}),this._onDidMaximizedChange,this._onDidViewVisibilityChangeMicroTaskQueue,this._bufferOnDidLayoutChange)}setVisible(e,t){this.gridview.setViewVisible(Xe(e.element),t),this._bufferOnDidLayoutChange.fire()}isVisible(e){return this.gridview.isViewVisible(Xe(e.element))}updateOptions(e){e.proportionalLayout,e.orientation&&(this.gridview.orientation=e.orientation),`styles`in e,`disableResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),`locked`in e&&(this.locked=e.locked??!1),`margin`in e&&(this.gridview.margin=e.margin??0),`className`in e&&this._classNames.setClassNames(e.className??``)}maximizeGroup(e){this.gridview.maximizeView(e),this.doSetGroupActive(e)}isMaximizedGroup(e){return this.gridview.maximizedView()===e}exitMaximizedGroup(){this.gridview.exitMaximizedView()}hasMaximizedGroup(){return this.gridview.hasMaximizedView()}doAddGroup(e,t=[0],n){this.gridview.addView(e,n??Be.Distribute,t),this._onDidAdd.fire(e)}doRemoveGroup(e,t){if(!this._groups.has(e.id))throw Error(`invalid operation`);let n=this._groups.get(e.id),r=this.gridview.remove(e,Be.Distribute);if(n&&!t?.skipDispose&&(n.disposable.dispose(),n.value.dispose(),this._groups.delete(e.id),this._onDidRemove.fire(e)),!t?.skipActive&&this._activeGroup===e){let e=Array.from(this._groups.values());this.doSetGroupActive(e.length>0?e[0].value:void 0)}return r}getPanel(e){return this._groups.get(e)?.value}doSetGroupActive(e){this._activeGroup!==e&&(this._activeGroup&&this._activeGroup.setActive(!1),e&&e.setActive(!0),this._activeGroup=e,this._onDidActiveChange.fire(e))}removeGroup(e){this.doRemoveGroup(e)}moveToNext(e){if(e||={},!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}let t=Xe(e.group.element),n=this.gridview.next(t)?.view;this.doSetGroupActive(n)}moveToPrevious(e){if(e||={},!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}let t=Xe(e.group.element),n=this.gridview.previous(t)?.view;this.doSetGroupActive(n)}layout(e,t,n){(n||e!==this.width||t!==this.height)&&(this.gridview.element.style.height=`${t}px`,this.gridview.element.style.width=`${e}px`,this.gridview.layout(e,t))}dispose(){this._onDidActiveChange.dispose(),this._onDidAdd.dispose(),this._onDidRemove.dispose();for(let e of this.groups)e.dispose();this.gridview.dispose(),super.dispose()}},lt=class{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get length(){return this.component.length}get orientation(){return this.component.orientation}get panels(){return this.component.panels}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}constructor(e){this.component=e}removePanel(e,t){this.component.removePanel(e,t)}focus(){this.component.focus()}getPanel(e){return this.component.getPanel(e)}layout(e,t){return this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},ut=class{get minimumSize(){return this.component.minimumSize}get maximumSize(){return this.component.maximumSize}get width(){return this.component.width}get height(){return this.component.height}get panels(){return this.component.panels}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidAddView(){return this.component.onDidAddView}get onDidRemoveView(){return this.component.onDidRemoveView}get onDidDrop(){return this.component.onDidDrop}get onUnhandledDragOverEvent(){return this.component.onUnhandledDragOverEvent}constructor(e){this.component=e}removePanel(e){this.component.removePanel(e)}getPanel(e){return this.component.getPanel(e)}movePanel(e,t){this.component.movePanel(e,t)}focus(){this.component.focus()}layout(e,t){this.component.layout(e,t)}addPanel(e){return this.component.addPanel(e)}fromJSON(e){this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},dt=class{get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidAddPanel(){return this.component.onDidAddGroup}get onDidRemovePanel(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActiveGroupChange}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get panels(){return this.component.groups}get orientation(){return this.component.orientation}set orientation(e){this.component.updateOptions({orientation:e})}constructor(e){this.component=e}focus(){this.component.focus()}layout(e,t,n=!1){this.component.layout(e,t,n)}addPanel(e){return this.component.addPanel(e)}removePanel(e,t){this.component.removePanel(e,t)}movePanel(e,t){this.component.movePanel(e,t)}getPanel(e){return this.component.getPanel(e)}fromJSON(e){return this.component.fromJSON(e)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},ft=class{get id(){return this.component.id}get width(){return this.component.width}get height(){return this.component.height}get minimumHeight(){return this.component.minimumHeight}get maximumHeight(){return this.component.maximumHeight}get minimumWidth(){return this.component.minimumWidth}get maximumWidth(){return this.component.maximumWidth}get size(){return this.component.size}get totalPanels(){return this.component.totalPanels}get onDidActiveGroupChange(){return this.component.onDidActiveGroupChange}get onDidAddGroup(){return this.component.onDidAddGroup}get onDidRemoveGroup(){return this.component.onDidRemoveGroup}get onDidActivePanelChange(){return this.component.onDidActivePanelChange}get onDidAddPanel(){return this.component.onDidAddPanel}get onDidRemovePanel(){return this.component.onDidRemovePanel}get onDidMovePanel(){return this.component.onDidMovePanel}get onDidLayoutFromJSON(){return this.component.onDidLayoutFromJSON}get onDidLayoutChange(){return this.component.onDidLayoutChange}get onDidDrop(){return this.component.onDidDrop}get onWillDrop(){return this.component.onWillDrop}get onWillShowOverlay(){return this.component.onWillShowOverlay}get onWillDragGroup(){return this.component.onWillDragGroup}get onWillDragPanel(){return this.component.onWillDragPanel}get onUnhandledDragOverEvent(){return this.component.onUnhandledDragOverEvent}get onDidPopoutGroupSizeChange(){return this.component.onDidPopoutGroupSizeChange}get onDidPopoutGroupPositionChange(){return this.component.onDidPopoutGroupPositionChange}get onDidOpenPopoutWindowFail(){return this.component.onDidOpenPopoutWindowFail}get panels(){return this.component.panels}get groups(){return this.component.groups}get activePanel(){return this.component.activePanel}get activeGroup(){return this.component.activeGroup}constructor(e){this.component=e}focus(){this.component.focus()}getPanel(e){return this.component.getGroupPanel(e)}layout(e,t,n=!1){this.component.layout(e,t,n)}addPanel(e){return this.component.addPanel(e)}removePanel(e){this.component.removePanel(e)}addGroup(e){return this.component.addGroup(e)}closeAllGroups(){return this.component.closeAllGroups()}removeGroup(e){this.component.removeGroup(e)}getGroup(e){return this.component.getPanel(e)}addFloatingGroup(e,t){return this.component.addFloatingGroup(e,t)}fromJSON(e,t){this.component.fromJSON(e,t)}toJSON(){return this.component.toJSON()}clear(){this.component.clear()}moveToNext(e){this.component.moveToNext(e)}moveToPrevious(e){this.component.moveToPrevious(e)}maximizeGroup(e){this.component.maximizeGroup(e.group)}hasMaximizedGroup(){return this.component.hasMaximizedGroup()}exitMaximizedGroup(){this.component.exitMaximizedGroup()}get onDidMaximizedGroupChange(){return this.component.onDidMaximizedGroupChange}addPopoutGroup(e,t){return this.component.addPopoutGroup(e,t)}updateOptions(e){this.component.updateOptions(e)}dispose(){this.component.dispose()}},pt=class extends A{constructor(e,t){super(),this.el=e,this.disabled=t,this.dataDisposable=new ie,this.pointerEventsDisposable=new ie,this._onDragStart=new D,this.onDragStart=this._onDragStart.event,this.addDisposables(this._onDragStart,this.dataDisposable,this.pointerEventsDisposable),this.configure()}setDisabled(e){this.disabled=e}isCancelled(e){return!1}configure(){this.addDisposables(this._onDragStart,O(this.el,`dragstart`,e=>{if(e.defaultPrevented||this.isCancelled(e)||this.disabled){e.preventDefault();return}let t=ye();this.pointerEventsDisposable.value={dispose:()=>{t.release()}},this.el.classList.add(`dv-dragged`),setTimeout(()=>this.el.classList.remove(`dv-dragged`),0),this.dataDisposable.value=this.getData(e),this._onDragStart.fire(e),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.items.length>0||e.dataTransfer.setData(`text/plain`,``))}),O(this.el,`dragend`,()=>{this.pointerEventsDisposable.dispose(),setTimeout(()=>{this.dataDisposable.dispose()},0)}))}},mt=class extends A{constructor(e,t){super(),this.element=e,this.callbacks=t,this.target=null,this.registerListeners()}onDragEnter(e){this.target=e.target,this.callbacks.onDragEnter(e)}onDragOver(e){e.preventDefault(),this.callbacks.onDragOver&&this.callbacks.onDragOver(e)}onDragLeave(e){this.target===e.target&&(this.target=null,this.callbacks.onDragLeave(e))}onDragEnd(e){this.target=null,this.callbacks.onDragEnd(e)}onDrop(e){this.callbacks.onDrop(e)}registerListeners(){this.addDisposables(O(this.element,`dragenter`,e=>{this.onDragEnter(e)},!0)),this.addDisposables(O(this.element,`dragover`,e=>{this.onDragOver(e)},!0)),this.addDisposables(O(this.element,`dragleave`,e=>{this.onDragLeave(e)})),this.addDisposables(O(this.element,`dragend`,e=>{this.onDragEnd(e)})),this.addDisposables(O(this.element,`drop`,e=>{this.onDrop(e)}))}};function ht(e,t){let{top:n,left:r,width:i,height:a}=t,o=`${Math.round(n)}px`,s=`${Math.round(r)}px`,c=`${Math.round(i)}px`,l=`${Math.round(a)}px`;e.style.top=o,e.style.left=s,e.style.width=c,e.style.height=l,e.style.visibility=`visible`,(!e.style.transform||e.style.transform===``)&&(e.style.transform=`translate3d(0, 0, 0)`)}function gt(e,t){let{top:n,left:r,width:i,height:a}=t;e.style.top=n,e.style.left=r,e.style.width=i,e.style.height=a,e.style.visibility=`visible`,(!e.style.transform||e.style.transform===``)&&(e.style.transform=`translate3d(0, 0, 0)`)}function _t(e,t){let{top:n,left:r,width:i,height:a}=t,o=`${Math.round(n)}px`,s=`${Math.round(r)}px`,c=`${Math.round(i)}px`,l=`${Math.round(a)}px`;return e.style.top!==o||e.style.left!==s||e.style.width!==c||e.style.height!==l}var vt=class extends ee{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}constructor(e){super(),this.options=e}};function yt(e){switch(e){case`above`:return`top`;case`below`:return`bottom`;case`left`:return`left`;case`right`:return`right`;case`within`:return`center`;default:throw Error(`invalid direction '${e}'`)}}function bt(e){switch(e){case`top`:return`above`;case`bottom`:return`below`;case`left`:return`left`;case`right`:return`right`;case`center`:return`within`;default:throw Error(`invalid position '${e}'`)}}var xt={value:20,type:`percentage`},St={value:50,type:`percentage`},Ct=100,wt=100,Tt=class e extends A{get disabled(){return this._disabled}set disabled(e){this._disabled=e}get state(){return this._state}constructor(t,n){super(),this.element=t,this.options=n,this._onDrop=new D,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new D,this.onWillShowOverlay=this._onWillShowOverlay.event,this._disabled=!1,this._acceptedTargetZonesSet=new Set(this.options.acceptedTargetZones),this.dnd=new mt(this.element,{onDragEnter:()=>{var e,t;(t=(e=this.options).getOverrideTarget?.call(e))==null||t.getElements()},onDragOver:t=>{var n,r;e.ACTUAL_TARGET=this;let i=(n=this.options).getOverrideTarget?.call(n);if(this._acceptedTargetZonesSet.size===0){if(i)return;this.removeDropTarget();return}let a=(r=this.options).getOverlayOutline?.call(r)??this.element,o=a.offsetWidth,s=a.offsetHeight;if(o===0||s===0)return;let c=t.currentTarget.getBoundingClientRect(),l=(t.clientX??0)-c.left,u=(t.clientY??0)-c.top,d=this.calculateQuadrant(this._acceptedTargetZonesSet,l,u,o,s);if(this.isAlreadyUsed(t)||d===null){this.removeDropTarget();return}if(!this.options.canDisplayOverlay(t,d)){if(i)return;this.removeDropTarget();return}let f=new vt({nativeEvent:t,position:d});if(this._onWillShowOverlay.fire(f),f.defaultPrevented){this.removeDropTarget();return}this.markAsUsed(t),i||this.targetElement||(this.targetElement=document.createElement(`div`),this.targetElement.className=`dv-drop-target-dropzone`,this.overlayElement=document.createElement(`div`),this.overlayElement.className=`dv-drop-target-selection`,this._state=`center`,this.targetElement.appendChild(this.overlayElement),a.classList.add(`dv-drop-target`),a.append(this.targetElement)),this.toggleClasses(d,o,s),this._state=d},onDragLeave:()=>{var e;(e=this.options).getOverrideTarget?.call(e)||this.removeDropTarget()},onDragEnd:t=>{var n;let r=(n=this.options).getOverrideTarget?.call(n);r&&e.ACTUAL_TARGET===this&&this._state&&(t.stopPropagation(),this._onDrop.fire({position:this._state,nativeEvent:t})),this.removeDropTarget(),r?.clear()},onDrop:e=>{var t,n;e.preventDefault();let r=this._state;this.removeDropTarget(),(n=(t=this.options).getOverrideTarget?.call(t))==null||n.clear(),r&&(e.stopPropagation(),this._onDrop.fire({position:r,nativeEvent:e}))}}),this.addDisposables(this._onDrop,this._onWillShowOverlay,this.dnd)}setTargetZones(e){this._acceptedTargetZonesSet=new Set(e)}setOverlayModel(e){this.options.overlayModel=e}dispose(){this.removeDropTarget(),super.dispose()}markAsUsed(t){t[e.USED_EVENT_ID]=!0}isAlreadyUsed(t){let n=t[e.USED_EVENT_ID];return typeof n==`boolean`&&n}toggleClasses(e,t,n){var r,i;let a=(r=this.options).getOverrideTarget?.call(r);if(!a&&!this.overlayElement)return;let o=t<Ct,s=n<wt,c=e===`left`,l=e===`right`,u=e===`top`,d=e===`bottom`,f=!o&&l,p=!o&&c,m=!s&&u,h=!s&&d,g=1,_=this.options.overlayModel?.size??St;if(_.type===`percentage`?g=Pe(_.value,0,100)/100:((f||p)&&(g=Pe(0,_.value,t)/t),(m||h)&&(g=Pe(0,_.value,n)/n)),a){let r=(i=this.options).getOverlayOutline?.call(i)??this.element,s=r.getBoundingClientRect(),_=a.getElements(void 0,r),v=_.root,y=_.overlay,b=v.getBoundingClientRect(),x=s.top-b.top,S=s.left-b.left,C={top:x,left:S,width:t,height:n};if(f?(C.left=S+t*(1-g),C.width=t*g):p?C.width=t*g:m?C.height=n*g:h&&(C.top=x+n*(1-g),C.height=n*g),o&&c&&(C.width=4),o&&l&&(C.left=S+t-4,C.width=4),!_t(y,C))return;ht(y,C),y.className=`dv-drop-target-anchor${this.options.className?` ${this.options.className}`:``}`,M(y,`dv-drop-target-left`,c),M(y,`dv-drop-target-right`,l),M(y,`dv-drop-target-top`,u),M(y,`dv-drop-target-bottom`,d),M(y,`dv-drop-target-center`,e===`center`),_.changed&&(M(y,`dv-drop-target-anchor-container-changed`,!0),setTimeout(()=>{M(y,`dv-drop-target-anchor-container-changed`,!1)},10));return}if(!this.overlayElement)return;let v={top:`0px`,left:`0px`,width:`100%`,height:`100%`};f?(v.left=`${100*(1-g)}%`,v.width=`${100*g}%`):p?v.width=`${100*g}%`:m?v.height=`${100*g}%`:h&&(v.top=`${100*(1-g)}%`,v.height=`${100*g}%`),gt(this.overlayElement,v),M(this.overlayElement,`dv-drop-target-small-vertical`,s),M(this.overlayElement,`dv-drop-target-small-horizontal`,o),M(this.overlayElement,`dv-drop-target-left`,c),M(this.overlayElement,`dv-drop-target-right`,l),M(this.overlayElement,`dv-drop-target-top`,u),M(this.overlayElement,`dv-drop-target-bottom`,d),M(this.overlayElement,`dv-drop-target-center`,e===`center`)}calculateQuadrant(e,t,n,r,i){let a=this.options.overlayModel?.activationSize??xt;return a.type===`percentage`?Et(e,t,n,r,i,a.value):Dt(e,t,n,r,i,a.value)}removeDropTarget(){var e;this.targetElement&&(this._state=void 0,(e=this.targetElement.parentElement)==null||e.classList.remove(`dv-drop-target`),this.targetElement.remove(),this.targetElement=void 0,this.overlayElement=void 0)}};Tt.USED_EVENT_ID=`__dockview_droptarget_event_is_used__`;function Et(e,t,n,r,i,a){let o=100*t/r,s=100*n/i;return e.has(`left`)&&o<a?`left`:e.has(`right`)&&o>100-a?`right`:e.has(`top`)&&s<a?`top`:e.has(`bottom`)&&s>100-a?`bottom`:e.has(`center`)?`center`:null}function Dt(e,t,n,r,i,a){return e.has(`left`)&&t<a?`left`:e.has(`right`)&&t>r-a?`right`:e.has(`top`)&&n<a?`top`:e.has(`bottom`)&&n>i-a?`bottom`:e.has(`center`)?`center`:null}var Ot=Object.keys({disableAutoResizing:void 0,disableDnd:void 0,className:void 0}),kt=class extends te{constructor(e,t,n,r){super(),this.nativeEvent=e,this.position=t,this.getData=n,this.panel=r}},At=class extends ee{constructor(){super()}},jt=class extends A{get isFocused(){return this._isFocused}get isActive(){return this._isActive}get isVisible(){return this._isVisible}get width(){return this._width}get height(){return this._height}constructor(e,t){super(),this.id=e,this.component=t,this._isFocused=!1,this._isActive=!1,this._isVisible=!0,this._width=0,this._height=0,this._parameters={},this.panelUpdatesDisposable=new ie,this._onDidDimensionChange=new D,this.onDidDimensionsChange=this._onDidDimensionChange.event,this._onDidChangeFocus=new D,this.onDidFocusChange=this._onDidChangeFocus.event,this._onWillFocus=new D,this.onWillFocus=this._onWillFocus.event,this._onDidVisibilityChange=new D,this.onDidVisibilityChange=this._onDidVisibilityChange.event,this._onWillVisibilityChange=new D,this.onWillVisibilityChange=this._onWillVisibilityChange.event,this._onDidActiveChange=new D,this.onDidActiveChange=this._onDidActiveChange.event,this._onActiveChange=new D,this.onActiveChange=this._onActiveChange.event,this._onDidParametersChange=new D,this.onDidParametersChange=this._onDidParametersChange.event,this.addDisposables(this.onDidFocusChange(e=>{this._isFocused=e.isFocused}),this.onDidActiveChange(e=>{this._isActive=e.isActive}),this.onDidVisibilityChange(e=>{this._isVisible=e.isVisible}),this.onDidDimensionsChange(e=>{this._width=e.width,this._height=e.height}),this.panelUpdatesDisposable,this._onDidDimensionChange,this._onDidChangeFocus,this._onDidVisibilityChange,this._onDidActiveChange,this._onWillFocus,this._onActiveChange,this._onWillFocus,this._onWillVisibilityChange,this._onDidParametersChange)}getParameters(){return this._parameters}initialize(e){this.panelUpdatesDisposable.value=this._onDidParametersChange.event(t=>{this._parameters=t,e.update({params:t})})}setVisible(e){this._onWillVisibilityChange.fire({isVisible:e})}setActive(){this._onActiveChange.fire()}updateParameters(e){this._onDidParametersChange.fire(e)}},Mt=class extends jt{constructor(e,t){super(e,t),this._onDidConstraintsChangeInternal=new D,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new D({replay:!0}),this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new D,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}},Nt=class extends Mt{set pane(e){this._pane=e}constructor(e,t){super(e,t),this._onDidExpansionChange=new D({replay:!0}),this.onDidExpansionChange=this._onDidExpansionChange.event,this._onMouseEnter=new D({}),this.onMouseEnter=this._onMouseEnter.event,this._onMouseLeave=new D({}),this.onMouseLeave=this._onMouseLeave.event,this.addDisposables(this._onDidExpansionChange,this._onMouseEnter,this._onMouseLeave)}setExpanded(e){var t;(t=this._pane)==null||t.setExpanded(e)}get isExpanded(){return!!this._pane?.isExpanded()}},Pt=class extends A{get element(){return this._element}get width(){return this._width}get height(){return this._height}get params(){return this._params?.params}constructor(e,t,n){super(),this.id=e,this.component=t,this.api=n,this._height=0,this._width=0,this._element=document.createElement(`div`),this._element.tabIndex=-1,this._element.style.outline=`none`,this._element.style.height=`100%`,this._element.style.width=`100%`,this._element.style.overflow=`hidden`;let r=le(this._element);this.addDisposables(this.api,r.onDidFocus(()=>{this.api._onDidChangeFocus.fire({isFocused:!0})}),r.onDidBlur(()=>{this.api._onDidChangeFocus.fire({isFocused:!1})}),r)}focus(){let e=new At;this.api._onWillFocus.fire(e),!e.defaultPrevented&&this._element.focus()}layout(e,t){this._width=e,this._height=t,this.api._onDidDimensionChange.fire({width:e,height:t}),this.part&&this._params&&this.part.update(this._params.params)}init(e){this._params=e,this.part=this.getComponent()}update(e){var t;this._params=Object.assign(Object.assign({},this._params),{params:Object.assign(Object.assign({},this._params?.params),e.params)});for(let t of Object.keys(e.params))e.params[t]===void 0&&delete this._params.params[t];(t=this.part)==null||t.update({params:this._params.params})}toJSON(){let e=this._params?.params??{};return{id:this.id,component:this.component,params:Object.keys(e).length>0?e:void 0}}dispose(){var e;this.api.dispose(),(e=this.part)==null||e.dispose(),super.dispose()}},Ft=class extends Pt{set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){return this.headerSize+(this.isExpanded()?this._minimumBodySize:0)}get maximumSize(){return this.headerSize+(this.isExpanded()?this._maximumBodySize:0)}get size(){return this._size}get orthogonalSize(){return this._orthogonalSize}set orthogonalSize(e){this._orthogonalSize=e}get minimumBodySize(){return this._minimumBodySize}set minimumBodySize(e){this._minimumBodySize=typeof e==`number`?e:0}get maximumBodySize(){return this._maximumBodySize}set maximumBodySize(e){this._maximumBodySize=typeof e==`number`?e:1/0}get headerVisible(){return this._headerVisible}set headerVisible(e){this._headerVisible=e,this.header.style.display=e?``:`none`}constructor(e){super(e.id,e.component,new Nt(e.id,e.component)),this._onDidChangeExpansionState=new D({replay:!0}),this.onDidChangeExpansionState=this._onDidChangeExpansionState.event,this._onDidChange=new D,this.onDidChange=this._onDidChange.event,this._orthogonalSize=0,this._size=0,this._isExpanded=!1,this.api.pane=this,this.api.initialize(this),this.headerSize=e.headerSize,this.headerComponent=e.headerComponent,this._minimumBodySize=e.minimumBodySize,this._maximumBodySize=e.maximumBodySize,this._isExpanded=e.isExpanded,this._headerVisible=e.isHeaderVisible,this._onDidChangeExpansionState.fire(this.isExpanded()),this._orientation=e.orientation,this.element.classList.add(`dv-pane`),this.addDisposables(this.api.onWillVisibilityChange(e=>{let{isVisible:t}=e,{accessor:n}=this._params;n.setVisible(this,t)}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({size:e.size})}),O(this.element,`mouseenter`,e=>{this.api._onMouseEnter.fire(e)}),O(this.element,`mouseleave`,e=>{this.api._onMouseLeave.fire(e)})),this.addDisposables(this._onDidChangeExpansionState,this.onDidChangeExpansionState(e=>{this.api._onDidExpansionChange.fire({isExpanded:e})}),this.api.onDidFocusChange(e=>{this.header&&(e.isFocused?j(this.header,`focused`):se(this.header,`focused`))})),this.renderOnce()}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}isExpanded(){return this._isExpanded}setExpanded(e){this._isExpanded!==e&&(this._isExpanded=e,e?(this.animationTimer&&clearTimeout(this.animationTimer),this.body&&this.element.appendChild(this.body)):this.animationTimer=setTimeout(()=>{var e;(e=this.body)==null||e.remove()},200),this._onDidChange.fire(e?{size:this.width}:{}),this._onDidChangeExpansionState.fire(e))}layout(e,t){this._size=e,this._orthogonalSize=t;let[n,r]=this.orientation===N.HORIZONTAL?[e,t]:[t,e];super.layout(n,r)}init(e){var t,n;super.init(e),typeof e.minimumBodySize==`number`&&(this.minimumBodySize=e.minimumBodySize),typeof e.maximumBodySize==`number`&&(this.maximumBodySize=e.maximumBodySize),this.bodyPart=this.getBodyComponent(),this.headerPart=this.getHeaderComponent(),this.bodyPart.init(Object.assign(Object.assign({},e),{api:this.api})),this.headerPart.init(Object.assign(Object.assign({},e),{api:this.api})),(t=this.body)==null||t.append(this.bodyPart.element),(n=this.header)==null||n.append(this.headerPart.element),typeof e.isExpanded==`boolean`&&this.setExpanded(e.isExpanded)}toJSON(){let e=this._params;return Object.assign(Object.assign({},super.toJSON()),{headerComponent:this.headerComponent,title:e.title})}renderOnce(){this.header=document.createElement(`div`),this.header.tabIndex=0,this.header.className=`dv-pane-header`,this.header.style.height=`${this.headerSize}px`,this.header.style.lineHeight=`${this.headerSize}px`,this.header.style.minHeight=`${this.headerSize}px`,this.header.style.maxHeight=`${this.headerSize}px`,this.element.appendChild(this.header),this.body=document.createElement(`div`),this.body.className=`dv-pane-body`,this.element.appendChild(this.body)}getComponent(){return{update:e=>{var t,n;(t=this.bodyPart)==null||t.update({params:e}),(n=this.headerPart)==null||n.update({params:e})},dispose:()=>{var e,t;(e=this.bodyPart)==null||e.dispose(),(t=this.headerPart)==null||t.dispose()}}}},It=class extends Ft{constructor(e){super({id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,isHeaderVisible:!0,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this._onDidDrop=new D,this.onDidDrop=this._onDidDrop.event,this._onUnhandledDragOverEvent=new D,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this.accessor=e.accessor,this.addDisposables(this._onDidDrop,this._onUnhandledDragOverEvent),e.disableDnd||this.initDragFeatures()}initDragFeatures(){if(!this.header)return;let e=this.id,t=this.accessor.id;this.header.draggable=!0,this.handler=new class extends pt{getData(){return x.getInstance().setData([new b(t,e)],b.prototype),{dispose:()=>{x.getInstance().clearData(b.prototype)}}}}(this.header),this.target=new Tt(this.element,{acceptedTargetZones:[`top`,`bottom`],overlayModel:{activationSize:{type:`percentage`,value:50}},canDisplayOverlay:(e,t)=>{let n=C();if(n&&n.paneId!==this.id&&n.viewId===this.accessor.id)return!0;let r=new kt(e,t,C,this);return this._onUnhandledDragOverEvent.fire(r),r.isAccepted}}),this.addDisposables(this._onDidDrop,this.handler,this.target,this.target.onDrop(e=>{this.onDrop(e)}))}onDrop(e){let t=C();if(!t||t.viewId!==this.accessor.id){this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,api:new ut(this.accessor),getData:C}));return}let n=this._params.containerApi,r=t.paneId,i=n.getPanel(r);if(!i){this._onDidDrop.fire(Object.assign(Object.assign({},e),{panel:this,getData:C,api:new ut(this.accessor)}));return}let a=n.panels,o=a.indexOf(i),s=n.panels.indexOf(this);(e.position===`left`||e.position===`top`)&&(s=Math.max(0,s-1)),(e.position===`right`||e.position===`bottom`)&&(o>s&&s++,s=Math.min(a.length-1,s)),n.movePanel(o,s)}},Lt=class extends A{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this.disposable=new ie,this._onDidFocus=new D,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new D,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement(`div`),this._element.className=`dv-content-container`,this._element.tabIndex=-1,this.addDisposables(this._onDidFocus,this._onDidBlur);let n=t.dropTargetContainer;this.dropTarget=new Tt(this.element,{getOverlayOutline:()=>e.options.theme?.dndPanelOverlay===`group`?this.element.parentElement:null,className:`dv-drop-target-content`,acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],canDisplayOverlay:(e,t)=>{if(this.group.locked===`no-drop-target`||this.group.locked&&t===`center`)return!1;let n=S();return!n&&e.shiftKey&&this.group.location.type!==`floating`?!1:n&&n.viewId===this.accessor.id?!0:this.group.canDisplayOverlay(e,t,`content`)},getOverrideTarget:n?()=>n.model:void 0}),this.addDisposables(this.dropTarget)}show(){this.element.style.display=``}hide(){this.element.style.display=`none`}renderPanel(e,t={asActive:!0}){let n=t.asActive||this.panel&&this.group.isPanelActive(this.panel);this.panel&&this.panel.view.content.element.parentElement===this._element&&this._element.removeChild(this.panel.view.content.element),this.panel=e;let r;switch(e.api.renderer){case`onlyWhenVisible`:this.group.renderContainer.detatch(e),this.panel&&n&&this._element.appendChild(this.panel.view.content.element),r=this._element;break;case`always`:e.view.content.element.parentElement===this._element&&this._element.removeChild(e.view.content.element),r=this.group.renderContainer.attach({panel:e,referenceContainer:this});break;default:throw Error(`dockview: invalid renderer type '${e.api.renderer}'`)}if(n){let e=le(r);this.focusTracker=e;let t=new A;t.addDisposables(e,e.onDidFocus(()=>this._onDidFocus.fire()),e.onDidBlur(()=>this._onDidBlur.fire())),this.disposable.value=t}}openPanel(e){this.panel!==e&&this.renderPanel(e)}layout(e,t){}closePanel(){var e;this.panel&&this.panel.api.renderer===`onlyWhenVisible`&&((e=this.panel.view.content.element.parentElement)==null||e.removeChild(this.panel.view.content.element)),this.panel=void 0}dispose(){this.disposable.dispose(),super.dispose()}refreshFocusState(){this.focusTracker?.refreshState&&this.focusTracker.refreshState()}};function Rt(e,t,n){j(t,`dv-dragged`),t.style.top=`-9999px`,document.body.appendChild(t),e.setDragImage(t,n?.x??0,n?.y??0),setTimeout(()=>{se(t,`dv-dragged`),t.remove()},0)}var zt=class extends pt{constructor(e,t,n,r,i){super(e,i),this.accessor=t,this.group=n,this.panel=r,this.panelTransfer=x.getInstance()}getData(e){return this.panelTransfer.setData([new y(this.accessor.id,this.group.id,this.panel.id)],y.prototype),{dispose:()=>{this.panelTransfer.clearData(y.prototype)}}}},Bt=class extends A{get element(){return this._element}constructor(e,t,n){super(),this.panel=e,this.accessor=t,this.group=n,this.content=void 0,this._onPointDown=new D,this.onPointerDown=this._onPointDown.event,this._onDropped=new D,this.onDrop=this._onDropped.event,this._onDragStart=new D,this.onDragStart=this._onDragStart.event,this._element=document.createElement(`div`),this._element.className=`dv-tab`,this._element.tabIndex=0,this._element.draggable=!this.accessor.options.disableDnd,M(this.element,`dv-inactive-tab`,!0),this.dragHandler=new zt(this._element,this.accessor,this.group,this.panel,!!this.accessor.options.disableDnd),this.dropTarget=new Tt(this._element,{acceptedTargetZones:[`left`,`right`],overlayModel:{activationSize:{value:50,type:`percentage`}},canDisplayOverlay:(e,t)=>{if(this.group.locked)return!1;let n=S();return n&&this.accessor.id===n.viewId?!0:this.group.model.canDisplayOverlay(e,t,`tab`)},getOverrideTarget:()=>n.model.dropTargetContainer?.model}),this.onWillShowOverlay=this.dropTarget.onWillShowOverlay,this.addDisposables(this._onPointDown,this._onDropped,this._onDragStart,this.dragHandler.onDragStart(e=>{if(e.dataTransfer){let t=getComputedStyle(this.element),n=this.element.cloneNode(!0);Array.from(t).forEach(e=>n.style.setProperty(e,t.getPropertyValue(e),t.getPropertyPriority(e))),n.style.position=`absolute`,Rt(e.dataTransfer,n,{y:-10,x:30})}this._onDragStart.fire(e)}),this.dragHandler,O(this._element,`pointerdown`,e=>{this._onPointDown.fire(e)}),this.dropTarget.onDrop(e=>{this._onDropped.fire(e)}),this.dropTarget)}setActive(e){M(this.element,`dv-active-tab`,e),M(this.element,`dv-inactive-tab`,!e)}setContent(e){this.content&&this._element.removeChild(this.content.element),this.content=e,this._element.appendChild(this.content.element)}updateDragAndDropState(){this._element.draggable=!this.accessor.options.disableDnd,this.dragHandler.setDisabled(!!this.accessor.options.disableDnd)}dispose(){super.dispose()}},Vt=class{get kind(){return this.options.kind}get nativeEvent(){return this.event.nativeEvent}get position(){return this.event.position}get defaultPrevented(){return this.event.defaultPrevented}get panel(){return this.options.panel}get api(){return this.options.api}get group(){return this.options.group}preventDefault(){this.event.preventDefault()}getData(){return this.options.getData()}constructor(e,t){this.event=e,this.options=t}},Ht=class extends pt{constructor(e,t,n,r){super(e,r),this.accessor=t,this.group=n,this.panelTransfer=x.getInstance(),this.addDisposables(O(e,`pointerdown`,e=>{e.shiftKey&&fe(e)},!0))}isCancelled(e){return this.group.api.location.type===`floating`&&!e.shiftKey}getData(e){let t=e.dataTransfer;this.panelTransfer.setData([new y(this.accessor.id,this.group.id,null)],y.prototype);let n=window.getComputedStyle(this.el),r=n.getPropertyValue(`--dv-activegroup-visiblepanel-tab-background-color`),i=n.getPropertyValue(`--dv-activegroup-visiblepanel-tab-color`);if(t){let e=document.createElement(`div`);e.style.backgroundColor=r,e.style.color=i,e.style.padding=`2px 8px`,e.style.height=`24px`,e.style.fontSize=`11px`,e.style.lineHeight=`20px`,e.style.borderRadius=`12px`,e.style.position=`absolute`,e.style.pointerEvents=`none`,e.style.top=`-9999px`,e.textContent=`Multiple Panels (${this.group.size})`,Rt(t,e,{y:-10,x:30})}return{dispose:()=>{this.panelTransfer.clearData(y.prototype)}}}},Ut=class extends A{get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this._onDrop=new D,this.onDrop=this._onDrop.event,this._onDragStart=new D,this.onDragStart=this._onDragStart.event,this._element=document.createElement(`div`),this._element.className=`dv-void-container`,this._element.draggable=!this.accessor.options.disableDnd,M(this._element,`dv-draggable`,!this.accessor.options.disableDnd),this.addDisposables(this._onDrop,this._onDragStart,O(this._element,`pointerdown`,()=>{this.accessor.doSetGroupActive(this.group)})),this.handler=new Ht(this._element,e,t,!!this.accessor.options.disableDnd),this.dropTarget=new Tt(this._element,{acceptedTargetZones:[`center`],canDisplayOverlay:(e,n)=>{let r=S();return r&&this.accessor.id===r.viewId?!0:t.model.canDisplayOverlay(e,n,`header_space`)},getOverrideTarget:()=>t.model.dropTargetContainer?.model}),this.onWillShowOverlay=this.dropTarget.onWillShowOverlay,this.addDisposables(this.handler,this.handler.onDragStart(e=>{this._onDragStart.fire(e)}),this.dropTarget.onDrop(e=>{this._onDrop.fire(e)}),this.dropTarget)}updateDragAndDropState(){this._element.draggable=!this.accessor.options.disableDnd,M(this._element,`dv-draggable`,!this.accessor.options.disableDnd),this.handler.setDisabled(!!this.accessor.options.disableDnd)}},Wt=class e extends A{get element(){return this._element}constructor(t){super(),this.scrollableElement=t,this._scrollLeft=0,this._element=document.createElement(`div`),this._element.className=`dv-scrollable`,this._horizontalScrollbar=document.createElement(`div`),this._horizontalScrollbar.className=`dv-scrollbar-horizontal`,this.element.appendChild(t),this.element.appendChild(this._horizontalScrollbar),this.addDisposables(O(this.element,`wheel`,t=>{this._scrollLeft+=t.deltaY*e.MouseWheelSpeed,this.calculateScrollbarStyles()}),O(this._horizontalScrollbar,`pointerdown`,e=>{e.preventDefault(),M(this.element,`dv-scrollable-scrolling`,!0);let t=e.clientX,n=this._scrollLeft,r=e=>{let r=e.clientX-t,{clientWidth:i}=this.element,{scrollWidth:a}=this.scrollableElement;this._scrollLeft=n+r/(i/a),this.calculateScrollbarStyles()},i=()=>{M(this.element,`dv-scrollable-scrolling`,!1),document.removeEventListener(`pointermove`,r),document.removeEventListener(`pointerup`,i),document.removeEventListener(`pointercancel`,i)};document.addEventListener(`pointermove`,r),document.addEventListener(`pointerup`,i),document.addEventListener(`pointercancel`,i)}),O(this.element,`scroll`,()=>{this.calculateScrollbarStyles()}),O(this.scrollableElement,`scroll`,()=>{this._scrollLeft=this.scrollableElement.scrollLeft,this.calculateScrollbarStyles()}),oe(this.element,()=>{M(this.element,`dv-scrollable-resizing`,!0),this._animationTimer&&clearTimeout(this._animationTimer),this._animationTimer=setTimeout(()=>{clearTimeout(this._animationTimer),M(this.element,`dv-scrollable-resizing`,!1)},500),this.calculateScrollbarStyles()}))}calculateScrollbarStyles(){let{clientWidth:e}=this.element,{scrollWidth:t}=this.scrollableElement;if(t>e){let n=e/t*e;this._horizontalScrollbar.style.width=`${n}px`,this._scrollLeft=Pe(this._scrollLeft,0,this.scrollableElement.scrollWidth-e),this.scrollableElement.scrollLeft=this._scrollLeft;let r=this._scrollLeft/(t-e);this._horizontalScrollbar.style.left=`${(e-n)*r}px`}else this._horizontalScrollbar.style.width=`0px`,this._horizontalScrollbar.style.left=`0px`,this._scrollLeft=0}};Wt.MouseWheelSpeed=1;var Gt=class extends A{get showTabsOverflowControl(){return this._showTabsOverflowControl}set showTabsOverflowControl(e){if(this._showTabsOverflowControl!=e&&(this._showTabsOverflowControl=e,e)){let e=new ae(this._tabsList);this._observerDisposable.value=new A(e,e.onDidChange(e=>{let t=e.hasScrollX||e.hasScrollY;this.toggleDropdown({reset:!t})}),O(this._tabsList,`scroll`,()=>{this.toggleDropdown({reset:!1})}))}}get element(){return this._element}get panels(){return this._tabs.map(e=>e.value.panel.id)}get size(){return this._tabs.length}get tabs(){return this._tabs.map(e=>e.value)}constructor(e,t,n){if(super(),this.group=e,this.accessor=t,this._observerDisposable=new ie,this._tabs=[],this.selectedIndex=-1,this._showTabsOverflowControl=!1,this._onTabDragStart=new D,this.onTabDragStart=this._onTabDragStart.event,this._onDrop=new D,this.onDrop=this._onDrop.event,this._onWillShowOverlay=new D,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onOverflowTabsChange=new D,this.onOverflowTabsChange=this._onOverflowTabsChange.event,this._tabsList=document.createElement(`div`),this._tabsList.className=`dv-tabs-container dv-horizontal`,this.showTabsOverflowControl=n.showTabsOverflowControl,t.options.scrollbars===`native`)this._element=this._tabsList;else{let e=new Wt(this._tabsList);this._element=e.element,this.addDisposables(e)}this.addDisposables(this._onOverflowTabsChange,this._observerDisposable,this._onWillShowOverlay,this._onDrop,this._onTabDragStart,O(this.element,`pointerdown`,e=>{e.defaultPrevented||e.button===0&&this.accessor.doSetGroupActive(this.group)}),k.from(()=>{for(let{value:e,disposable:t}of this._tabs)t.dispose(),e.dispose();this._tabs=[]}))}indexOf(e){return this._tabs.findIndex(t=>t.value.panel.id===e)}isActive(e){return this.selectedIndex>-1&&this._tabs[this.selectedIndex].value===e}setActivePanel(e){let t=0;for(let n of this._tabs){let r=e.id===n.value.panel.id;if(n.value.setActive(r),r){let e=n.value.element,r=e.parentElement;(t<r.scrollLeft||t+e.clientWidth>r.scrollLeft+r.clientWidth)&&(r.scrollLeft=t)}t+=n.value.element.clientWidth}}openPanel(e,t=this._tabs.length){if(this._tabs.find(t=>t.value.panel.id===e.id))return;let n=new Bt(e,this.accessor,this.group);n.setContent(e.view.tab);let r={value:n,disposable:new A(n.onDragStart(t=>{this._onTabDragStart.fire({nativeEvent:t,panel:e})}),n.onPointerDown(t=>{if(t.defaultPrevented)return;let r=!this.accessor.options.disableFloatingGroups,i=this.group.api.location.type===`floating`&&this.size===1;if(r&&!i&&t.shiftKey){t.preventDefault();let e=this.accessor.getGroupPanel(n.panel.id),{top:r,left:i}=n.element.getBoundingClientRect(),{top:a,left:o}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(e,{x:i-o,y:r-a,inDragMode:!0});return}switch(t.button){case 0:this.group.activePanel!==e&&this.group.model.openPanel(e);break}}),n.onDrop(e=>{this._onDrop.fire({event:e.nativeEvent,index:this._tabs.findIndex(e=>e.value===n)})}),n.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new Vt(e,{kind:`tab`,panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:S}))}))};this.addTab(r,t)}delete(e){let t=this.indexOf(e),{value:n,disposable:r}=this._tabs.splice(t,1)[0];r.dispose(),n.dispose(),n.element.remove()}addTab(e,t=this._tabs.length){if(t<0||t>this._tabs.length)throw Error(`invalid location`);this._tabsList.insertBefore(e.value.element,this._tabsList.children[t]),this._tabs=[...this._tabs.slice(0,t),e,...this._tabs.slice(t)],this.selectedIndex<0&&(this.selectedIndex=t)}toggleDropdown(e){let t=e.reset?[]:this._tabs.filter(e=>!Ce(e.value.element,this._tabsList)).map(e=>e.value.panel.id);this._onOverflowTabsChange.fire({tabs:t,reset:e.reset})}updateDragAndDropState(){for(let e of this._tabs)e.value.updateDragAndDropState()}},Kt=e=>{let t=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);t.setAttributeNS(null,`height`,e.height),t.setAttributeNS(null,`width`,e.width),t.setAttributeNS(null,`viewBox`,e.viewbox),t.setAttributeNS(null,`aria-hidden`,`false`),t.setAttributeNS(null,`focusable`,`false`),t.classList.add(`dv-svg`);let n=document.createElementNS(`http://www.w3.org/2000/svg`,`path`);return n.setAttributeNS(null,`d`,e.path),t.appendChild(n),t},qt=()=>Kt({width:`11`,height:`11`,viewbox:`0 0 28 28`,path:`M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z`}),Jt=()=>Kt({width:`11`,height:`11`,viewbox:`0 0 24 15`,path:`M12 14.15L0 2.15L2.15 0L12 9.9L21.85 0.0499992L24 2.2L12 14.15Z`}),Yt=()=>Kt({width:`11`,height:`11`,viewbox:`0 0 15 25`,path:`M2.15 24.1L0 21.95L9.9 12.05L0 2.15L2.15 0L14.2 12.05L2.15 24.1Z`});function Xt(){let e=document.createElement(`div`);e.className=`dv-tabs-overflow-dropdown-default`;let t=document.createElement(`span`);t.textContent=``;let n=Yt();return e.appendChild(n),e.appendChild(t),{element:e,update:e=>{t.textContent=`${e.tabs}`}}}var Zt=class extends A{get onTabDragStart(){return this.tabs.onTabDragStart}get panels(){return this.tabs.panels}get size(){return this.tabs.size}get hidden(){return this._hidden}set hidden(e){this._hidden=e,this.element.style.display=e?`none`:``}get element(){return this._element}constructor(e,t){super(),this.accessor=e,this.group=t,this._hidden=!1,this.dropdownPart=null,this._overflowTabs=[],this._dropdownDisposable=new ie,this._onDrop=new D,this.onDrop=this._onDrop.event,this._onGroupDragStart=new D,this.onGroupDragStart=this._onGroupDragStart.event,this._onWillShowOverlay=new D,this.onWillShowOverlay=this._onWillShowOverlay.event,this._element=document.createElement(`div`),this._element.className=`dv-tabs-and-actions-container`,M(this._element,`dv-full-width-single-tab`,this.accessor.options.singleTabMode===`fullwidth`),this.rightActionsContainer=document.createElement(`div`),this.rightActionsContainer.className=`dv-right-actions-container`,this.leftActionsContainer=document.createElement(`div`),this.leftActionsContainer.className=`dv-left-actions-container`,this.preActionsContainer=document.createElement(`div`),this.preActionsContainer.className=`dv-pre-actions-container`,this.tabs=new Gt(t,e,{showTabsOverflowControl:!e.options.disableTabsOverflowList}),this.voidContainer=new Ut(this.accessor,this.group),this._element.appendChild(this.preActionsContainer),this._element.appendChild(this.tabs.element),this._element.appendChild(this.leftActionsContainer),this._element.appendChild(this.voidContainer.element),this._element.appendChild(this.rightActionsContainer),this.addDisposables(this.tabs.onDrop(e=>this._onDrop.fire(e)),this.tabs.onWillShowOverlay(e=>this._onWillShowOverlay.fire(e)),e.onDidOptionsChange(()=>{this.tabs.showTabsOverflowControl=!e.options.disableTabsOverflowList}),this.tabs.onOverflowTabsChange(e=>{this.toggleDropdown(e)}),this.tabs,this._onWillShowOverlay,this._onDrop,this._onGroupDragStart,this.voidContainer,this.voidContainer.onDragStart(e=>{this._onGroupDragStart.fire({nativeEvent:e,group:this.group})}),this.voidContainer.onDrop(e=>{this._onDrop.fire({event:e.nativeEvent,index:this.tabs.size})}),this.voidContainer.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new Vt(e,{kind:`header_space`,panel:this.group.activePanel,api:this.accessor.api,group:this.group,getData:S}))}),O(this.voidContainer.element,`pointerdown`,e=>{if(!e.defaultPrevented&&!this.accessor.options.disableFloatingGroups&&e.shiftKey&&this.group.api.location.type!==`floating`){e.preventDefault();let{top:t,left:n}=this.element.getBoundingClientRect(),{top:r,left:i}=this.accessor.element.getBoundingClientRect();this.accessor.addFloatingGroup(this.group,{x:n-i+20,y:t-r+20,inDragMode:!0})}}))}show(){this.hidden||(this.element.style.display=``)}hide(){this._element.style.display=`none`}setRightActionsElement(e){this.rightActions!==e&&(this.rightActions&&=(this.rightActions.remove(),void 0),e&&(this.rightActionsContainer.appendChild(e),this.rightActions=e))}setLeftActionsElement(e){this.leftActions!==e&&(this.leftActions&&=(this.leftActions.remove(),void 0),e&&(this.leftActionsContainer.appendChild(e),this.leftActions=e))}setPrefixActionsElement(e){this.preActions!==e&&(this.preActions&&=(this.preActions.remove(),void 0),e&&(this.preActionsContainer.appendChild(e),this.preActions=e))}isActive(e){return this.tabs.isActive(e)}indexOf(e){return this.tabs.indexOf(e)}setActive(e){}delete(e){this.tabs.delete(e),this.updateClassnames()}setActivePanel(e){this.tabs.setActivePanel(e)}openPanel(e,t=this.tabs.size){this.tabs.openPanel(e,t),this.updateClassnames()}closePanel(e){this.delete(e.id)}updateClassnames(){M(this._element,`dv-single-tab`,this.size===1)}toggleDropdown(e){let t=e.reset?[]:e.tabs;if(this._overflowTabs=t,this._overflowTabs.length>0&&this.dropdownPart){this.dropdownPart.update({tabs:t.length});return}if(this._overflowTabs.length===0){this._dropdownDisposable.dispose();return}let n=document.createElement(`div`);n.className=`dv-tabs-overflow-dropdown-root`;let r=Xt();r.update({tabs:t.length}),this.dropdownPart=r,n.appendChild(r.element),this.rightActionsContainer.prepend(n),this._dropdownDisposable.value=new A(k.from(()=>{var e,t;n.remove(),(t=(e=this.dropdownPart)?.dispose)==null||t.call(e),this.dropdownPart=null}),O(n,`pointerdown`,e=>{e.preventDefault()},{capture:!0}),O(n,`click`,e=>{let t=document.createElement(`div`);t.style.overflow=`auto`,t.className=`dv-tabs-overflow-container`;for(let e of this.tabs.tabs.filter(e=>this._overflowTabs.includes(e.panel.id))){let n=this.group.panels.find(t=>t===e.panel),r=n.view.createTabRenderer(`headerOverflow`).element,i=document.createElement(`div`);M(i,`dv-tab`,!0),M(i,`dv-active-tab`,n.api.isActive),M(i,`dv-inactive-tab`,!n.api.isActive),i.addEventListener(`click`,t=>{this.accessor.popupService.close(),!t.defaultPrevented&&(e.element.scrollIntoView(),e.panel.api.setActive())}),i.appendChild(r),t.appendChild(i)}let r=De(n);this.accessor.popupService.openPopover(t,{x:e.clientX,y:e.clientY,zIndex:r?.style.zIndex?`calc(${r.style.zIndex} * 2)`:void 0})}))}updateDragAndDropState(){this.tabs.updateDragAndDropState(),this.voidContainer.updateDragAndDropState()}},Qt=class extends te{constructor(e,t,n,r,i){super(),this.nativeEvent=e,this.target=t,this.position=n,this.getData=r,this.group=i}},$t=Object.keys({disableAutoResizing:void 0,hideBorders:void 0,singleTabMode:void 0,disableFloatingGroups:void 0,floatingGroupBounds:void 0,popoutUrl:void 0,defaultRenderer:void 0,debug:void 0,rootOverlayModel:void 0,locked:void 0,disableDnd:void 0,className:void 0,noPanelsOverlay:void 0,dndEdges:void 0,theme:void 0,disableTabsOverflowList:void 0,scrollbars:void 0});function en(e){return!!e.referencePanel}function tn(e){return!!e.referenceGroup}function nn(e){return!!e.referencePanel}function rn(e){return!!e.referenceGroup}var an=class extends ee{get nativeEvent(){return this.options.nativeEvent}get position(){return this.options.position}get panel(){return this.options.panel}get group(){return this.options.group}get api(){return this.options.api}constructor(e){super(),this.options=e}getData(){return this.options.getData()}},on=class extends an{get kind(){return this._kind}constructor(e){super(e),this._kind=e.kind}},sn=class extends A{get element(){throw Error(`dockview: not supported`)}get activePanel(){return this._activePanel}get locked(){return this._locked}set locked(e){this._locked=e,M(this.container,`dv-locked-groupview`,e===`no-drop-target`||e)}get isActive(){return this._isGroupActive}get panels(){return this._panels}get size(){return this._panels.length}get isEmpty(){return this._panels.length===0}get hasWatermark(){return!!(this.watermark&&this.container.contains(this.watermark.element))}get header(){return this.tabsContainer}get isContentFocused(){return document.activeElement?ce(document.activeElement,this.contentContainer.element):!1}get location(){return this._location}set location(e){switch(this._location=e,M(this.container,`dv-groupview-floating`,!1),M(this.container,`dv-groupview-popout`,!1),e.type){case`grid`:this.contentContainer.dropTarget.setTargetZones([`top`,`bottom`,`left`,`right`,`center`]);break;case`floating`:this.contentContainer.dropTarget.setTargetZones([`center`]),this.contentContainer.dropTarget.setTargetZones(e?[`center`]:[`top`,`bottom`,`left`,`right`,`center`]),M(this.container,`dv-groupview-floating`,!0);break;case`popout`:this.contentContainer.dropTarget.setTargetZones([`center`]),M(this.container,`dv-groupview-popout`,!0);break}this.groupPanel.api._onDidLocationChange.fire({location:this.location})}constructor(e,t,n,r,i){super(),this.container=e,this.accessor=t,this.id=n,this.options=r,this.groupPanel=i,this._isGroupActive=!1,this._locked=!1,this._location={type:`grid`},this.mostRecentlyUsed=[],this._overwriteRenderContainer=null,this._overwriteDropTargetContainer=null,this._onDidChange=new D,this.onDidChange=this._onDidChange.event,this._width=0,this._height=0,this._panels=[],this._panelDisposables=new Map,this._onMove=new D,this.onMove=this._onMove.event,this._onDidDrop=new D,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new D,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new D,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onTabDragStart=new D,this.onTabDragStart=this._onTabDragStart.event,this._onGroupDragStart=new D,this.onGroupDragStart=this._onGroupDragStart.event,this._onDidAddPanel=new D,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPanelTitleChange=new D,this.onDidPanelTitleChange=this._onDidPanelTitleChange.event,this._onDidPanelParametersChange=new D,this.onDidPanelParametersChange=this._onDidPanelParametersChange.event,this._onDidRemovePanel=new D,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidActivePanelChange=new D,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onUnhandledDragOverEvent=new D,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,M(this.container,`dv-groupview`,!0),this._api=new ft(this.accessor),this.tabsContainer=new Zt(this.accessor,this.groupPanel),this.contentContainer=new Lt(this.accessor,this),e.append(this.tabsContainer.element,this.contentContainer.element),this.header.hidden=!!r.hideHeader,this.locked=r.locked??!1,this.addDisposables(this._onTabDragStart,this._onGroupDragStart,this._onWillShowOverlay,this.tabsContainer.onTabDragStart(e=>{this._onTabDragStart.fire(e)}),this.tabsContainer.onGroupDragStart(e=>{this._onGroupDragStart.fire(e)}),this.tabsContainer.onDrop(e=>{this.handleDropEvent(`header`,e.event,`center`,e.index)}),this.contentContainer.onDidFocus(()=>{this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.onDidBlur(()=>{}),this.contentContainer.dropTarget.onDrop(e=>{this.handleDropEvent(`content`,e.nativeEvent,e.position)}),this.tabsContainer.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(e)}),this.contentContainer.dropTarget.onWillShowOverlay(e=>{this._onWillShowOverlay.fire(new Vt(e,{kind:`content`,panel:this.activePanel,api:this._api,group:this.groupPanel,getData:S}))}),this._onMove,this._onDidChange,this._onDidDrop,this._onWillDrop,this._onDidAddPanel,this._onDidRemovePanel,this._onDidActivePanelChange,this._onUnhandledDragOverEvent,this._onDidPanelTitleChange,this._onDidPanelParametersChange)}focusContent(){this.contentContainer.element.focus()}set renderContainer(e){this.panels.forEach(e=>{this.renderContainer.detatch(e)}),this._overwriteRenderContainer=e,this.panels.forEach(e=>{this.rerender(e)})}get renderContainer(){return this._overwriteRenderContainer??this.accessor.overlayRenderContainer}set dropTargetContainer(e){this._overwriteDropTargetContainer=e}get dropTargetContainer(){return this._overwriteDropTargetContainer??this.accessor.rootDropTargetContainer}initialize(){this.options.panels&&this.options.panels.forEach(e=>{this.doAddPanel(e)}),this.options.activePanel&&this.openPanel(this.options.activePanel),this.setActive(this.isActive,!0),this.updateContainer(),this.accessor.options.createRightHeaderActionComponent&&(this._rightHeaderActions=this.accessor.options.createRightHeaderActionComponent(this.groupPanel),this.addDisposables(this._rightHeaderActions),this._rightHeaderActions.init({containerApi:this._api,api:this.groupPanel.api,group:this.groupPanel}),this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element)),this.accessor.options.createLeftHeaderActionComponent&&(this._leftHeaderActions=this.accessor.options.createLeftHeaderActionComponent(this.groupPanel),this.addDisposables(this._leftHeaderActions),this._leftHeaderActions.init({containerApi:this._api,api:this.groupPanel.api,group:this.groupPanel}),this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element)),this.accessor.options.createPrefixHeaderActionComponent&&(this._prefixHeaderActions=this.accessor.options.createPrefixHeaderActionComponent(this.groupPanel),this.addDisposables(this._prefixHeaderActions),this._prefixHeaderActions.init({containerApi:this._api,api:this.groupPanel.api,group:this.groupPanel}),this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element))}rerender(e){this.contentContainer.renderPanel(e,{asActive:!1})}indexOf(e){return this.tabsContainer.indexOf(e.id)}toJSON(){let e={views:this.tabsContainer.panels,activeView:this._activePanel?.id,id:this.id};return this.locked!==!1&&(e.locked=this.locked),this.header.hidden&&(e.hideHeader=!0),e}moveToNext(e){e||={},e.panel||=this.activePanel;let t=e.panel?this.panels.indexOf(e.panel):-1,n;if(t<this.panels.length-1)n=t+1;else if(!e.suppressRoll)n=0;else return;this.openPanel(this.panels[n])}moveToPrevious(e){if(e||={},e.panel||=this.activePanel,!e.panel)return;let t=this.panels.indexOf(e.panel),n;if(t>0)n=t-1;else if(!e.suppressRoll)n=this.panels.length-1;else return;this.openPanel(this.panels[n])}containsPanel(e){return this.panels.includes(e)}init(e){}update(e){}focus(){var e;(e=this._activePanel)==null||e.focus()}openPanel(e,t={}){(typeof t.index!=`number`||t.index>this.panels.length)&&(t.index=this.panels.length);let n=!!t.skipSetActive;if(e.updateParentGroup(this.groupPanel,{skipSetActive:t.skipSetActive}),this.doAddPanel(e,t.index,{skipSetActive:n}),this._activePanel===e){this.contentContainer.renderPanel(e,{asActive:!0});return}n||this.doSetActivePanel(e),t.skipSetGroupActive||this.accessor.doSetGroupActive(this.groupPanel),t.skipSetActive||this.updateContainer()}removePanel(e,t={skipSetActive:!1}){let n=typeof e==`string`?e:e.id,r=this._panels.find(e=>e.id===n);if(!r)throw Error(`invalid operation`);return this._removePanel(r,t)}closeAllPanels(){if(this.panels.length>0){let e=[...this.panels];for(let t of e)this.doClose(t)}else this.accessor.removeGroup(this.groupPanel)}closePanel(e){this.doClose(e)}doClose(e){let t=this.panels.length===1&&this.accessor.groups.length===1;this.accessor.removePanel(e,t&&this.accessor.options.noPanelsOverlay===`emptyGroup`?{removeEmptyGroup:!1}:void 0)}isPanelActive(e){return this._activePanel===e}updateActions(e){this.tabsContainer.setRightActionsElement(e)}setActive(e,t=!1){!t&&this.isActive===e||(this._isGroupActive=e,M(this.container,`dv-active-group`,e),M(this.container,`dv-inactive-group`,!e),this.tabsContainer.setActive(this.isActive),!this._activePanel&&this.panels.length>0&&this.doSetActivePanel(this.panels[0]),this.updateContainer())}layout(e,t){this._width=e,this._height=t,this.contentContainer.layout(this._width,this._height),this._activePanel?.layout&&this._activePanel.layout(this._width,this._height)}_removePanel(e,t){let n=this._activePanel===e;if(this.doRemovePanel(e),n&&this.panels.length>0){let e=this.mostRecentlyUsed[0];this.openPanel(e,{skipSetActive:t.skipSetActive,skipSetGroupActive:t.skipSetActiveGroup})}return this._activePanel&&this.panels.length===0&&this.doSetActivePanel(void 0),t.skipSetActive||this.updateContainer(),e}doRemovePanel(e){let t=this.panels.indexOf(e);if(this._activePanel===e&&this.contentContainer.closePanel(),this.tabsContainer.delete(e.id),this._panels.splice(t,1),this.mostRecentlyUsed.includes(e)){let t=this.mostRecentlyUsed.indexOf(e);this.mostRecentlyUsed.splice(t,1)}let n=this._panelDisposables.get(e.id);n&&(n.dispose(),this._panelDisposables.delete(e.id)),this._onDidRemovePanel.fire({panel:e})}doAddPanel(e,t=this.panels.length,n={skipSetActive:!1}){let r=this._panels.indexOf(e)>-1;this.tabsContainer.show(),this.contentContainer.show(),this.tabsContainer.openPanel(e,t),n.skipSetActive||this.contentContainer.openPanel(e),!r&&(this.updateMru(e),this.panels.splice(t,0,e),this._panelDisposables.set(e.id,new A(e.api.onDidTitleChange(e=>this._onDidPanelTitleChange.fire(e)),e.api.onDidParametersChange(e=>this._onDidPanelParametersChange.fire(e)))),this._onDidAddPanel.fire({panel:e}))}doSetActivePanel(e){this._activePanel!==e&&(this._activePanel=e,e&&(this.tabsContainer.setActivePanel(e),this.contentContainer.openPanel(e),e.layout(this._width,this._height),this.updateMru(e),this.contentContainer.refreshFocusState(),this._onDidActivePanelChange.fire({panel:e})))}updateMru(e){this.mostRecentlyUsed.includes(e)&&this.mostRecentlyUsed.splice(this.mostRecentlyUsed.indexOf(e),1),this.mostRecentlyUsed=[e,...this.mostRecentlyUsed]}updateContainer(){var e,t;if(this.panels.forEach(e=>e.runEvents()),this.isEmpty&&!this.watermark){let e=this.accessor.createWatermarkComponent();e.init({containerApi:this._api,group:this.groupPanel}),this.watermark=e,O(this.watermark.element,`pointerdown`,()=>{this.isActive||this.accessor.doSetGroupActive(this.groupPanel)}),this.contentContainer.element.appendChild(this.watermark.element)}!this.isEmpty&&this.watermark&&(this.watermark.element.remove(),(t=(e=this.watermark).dispose)==null||t.call(e),this.watermark=void 0)}canDisplayOverlay(e,t,n){let r=new Qt(e,n,t,S,this.accessor.getPanel(this.id));return this._onUnhandledDragOverEvent.fire(r),r.isAccepted}handleDropEvent(e,t,n,r){if(this.locked===`no-drop-target`)return;function i(){switch(e){case`header`:return typeof r==`number`?`tab`:`header_space`;case`content`:return`content`}}let a=typeof r==`number`?this.panels[r]:void 0,o=new on({nativeEvent:t,position:n,panel:a,getData:()=>S(),kind:i(),group:this.groupPanel,api:this._api});if(this._onWillDrop.fire(o),o.defaultPrevented)return;let s=S();if(s&&s.viewId===this.accessor.id){if(e===`content`&&s.groupId===this.id&&(n===`center`||s.panelId===null)||e===`header`&&s.groupId===this.id&&s.panelId===null)return;if(s.panelId===null){let{groupId:e}=s;this._onMove.fire({target:n,groupId:e,index:r});return}if(this.tabsContainer.indexOf(s.panelId)!==-1&&this.tabsContainer.size===1)return;let{groupId:t,panelId:i}=s;if(this.id===t&&!n&&this.tabsContainer.indexOf(i)===r)return;this._onMove.fire({target:n,groupId:s.groupId,itemId:s.panelId,index:r})}else this._onDidDrop.fire(new an({nativeEvent:t,position:n,panel:a,getData:()=>S(),group:this.groupPanel,api:this._api}))}updateDragAndDropState(){this.tabsContainer.updateDragAndDropState()}dispose(){var e,t,n;super.dispose(),(e=this.watermark)==null||e.element.remove(),(n=(t=this.watermark)?.dispose)==null||n.call(t),this.watermark=void 0;for(let e of this.panels)e.dispose();this.tabsContainer.dispose(),this.contentContainer.dispose()}},cn=class extends jt{constructor(e,t,n){super(e,t),this._onDidConstraintsChangeInternal=new D,this.onDidConstraintsChangeInternal=this._onDidConstraintsChangeInternal.event,this._onDidConstraintsChange=new D,this.onDidConstraintsChange=this._onDidConstraintsChange.event,this._onDidSizeChange=new D,this.onDidSizeChange=this._onDidSizeChange.event,this.addDisposables(this._onDidConstraintsChangeInternal,this._onDidConstraintsChange,this._onDidSizeChange),n&&this.initialize(n)}setConstraints(e){this._onDidConstraintsChangeInternal.fire(e)}setSize(e){this._onDidSizeChange.fire(e)}},ln=class extends Pt{get priority(){return this._priority}get snap(){return this._snap}get minimumWidth(){return this.__minimumWidth()}get minimumHeight(){return this.__minimumHeight()}get maximumHeight(){return this.__maximumHeight()}get maximumWidth(){return this.__maximumWidth()}__minimumWidth(){let e=typeof this._minimumWidth==`function`?this._minimumWidth():this._minimumWidth;return e!==this._evaluatedMinimumWidth&&(this._evaluatedMinimumWidth=e,this.updateConstraints()),e}__maximumWidth(){let e=typeof this._maximumWidth==`function`?this._maximumWidth():this._maximumWidth;return e!==this._evaluatedMaximumWidth&&(this._evaluatedMaximumWidth=e,this.updateConstraints()),e}__minimumHeight(){let e=typeof this._minimumHeight==`function`?this._minimumHeight():this._minimumHeight;return e!==this._evaluatedMinimumHeight&&(this._evaluatedMinimumHeight=e,this.updateConstraints()),e}__maximumHeight(){let e=typeof this._maximumHeight==`function`?this._maximumHeight():this._maximumHeight;return e!==this._evaluatedMaximumHeight&&(this._evaluatedMaximumHeight=e,this.updateConstraints()),e}get isActive(){return this.api.isActive}get isVisible(){return this.api.isVisible}constructor(e,t,n,r){super(e,t,r??new cn(e,t)),this._evaluatedMinimumWidth=0,this._evaluatedMaximumWidth=2**53-1,this._evaluatedMinimumHeight=0,this._evaluatedMaximumHeight=2**53-1,this._minimumWidth=0,this._minimumHeight=0,this._maximumWidth=2**53-1,this._maximumHeight=2**53-1,this._snap=!1,this._onDidChange=new D,this.onDidChange=this._onDidChange.event,typeof n?.minimumWidth==`number`&&(this._minimumWidth=n.minimumWidth),typeof n?.maximumWidth==`number`&&(this._maximumWidth=n.maximumWidth),typeof n?.minimumHeight==`number`&&(this._minimumHeight=n.minimumHeight),typeof n?.maximumHeight==`number`&&(this._maximumHeight=n.maximumHeight),this.api.initialize(this),this.addDisposables(this.api.onWillVisibilityChange(e=>{let{isVisible:t}=e,{accessor:n}=this._params;n.setVisible(this,t)}),this.api.onActiveChange(()=>{let{accessor:e}=this._params;e.doSetGroupActive(this)}),this.api.onDidConstraintsChangeInternal(e=>{(typeof e.minimumWidth==`number`||typeof e.minimumWidth==`function`)&&(this._minimumWidth=e.minimumWidth),(typeof e.minimumHeight==`number`||typeof e.minimumHeight==`function`)&&(this._minimumHeight=e.minimumHeight),(typeof e.maximumWidth==`number`||typeof e.maximumWidth==`function`)&&(this._maximumWidth=e.maximumWidth),(typeof e.maximumHeight==`number`||typeof e.maximumHeight==`function`)&&(this._maximumHeight=e.maximumHeight)}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({height:e.height,width:e.width})}),this._onDidChange)}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}init(e){e.maximumHeight&&(this._maximumHeight=e.maximumHeight),e.minimumHeight&&(this._minimumHeight=e.minimumHeight),e.maximumWidth&&(this._maximumWidth=e.maximumWidth),e.minimumWidth&&(this._minimumWidth=e.minimumWidth),this._priority=e.priority,this._snap=!!e.snap,super.init(e),typeof e.isVisible==`boolean`&&this.setVisible(e.isVisible)}updateConstraints(){this.api._onDidConstraintsChange.fire({minimumWidth:this._evaluatedMinimumWidth,maximumWidth:this._evaluatedMaximumWidth,minimumHeight:this._evaluatedMinimumHeight,maximumHeight:this._evaluatedMaximumHeight})}toJSON(){let e=super.toJSON(),t=e=>e===2**53-1?void 0:e,n=e=>e<=0?void 0:e;return Object.assign(Object.assign({},e),{minimumHeight:n(this.minimumHeight),maximumHeight:t(this.maximumHeight),minimumWidth:n(this.minimumWidth),maximumWidth:t(this.maximumWidth),snap:this.snap,priority:this.priority})}},un=`dockview: DockviewGroupPanelApiImpl not initialized`,dn=class extends cn{get location(){if(!this._group)throw Error(un);return this._group.model.location}constructor(e,t){super(e,`__dockviewgroup__`),this.accessor=t,this._onDidLocationChange=new D,this.onDidLocationChange=this._onDidLocationChange.event,this._onDidActivePanelChange=new D,this.onDidActivePanelChange=this._onDidActivePanelChange.event,this.addDisposables(this._onDidLocationChange,this._onDidActivePanelChange,this._onDidVisibilityChange.event(e=>{e.isVisible&&this._pendingSize&&(super.setSize(this._pendingSize),this._pendingSize=void 0)}))}setSize(e){this._pendingSize=Object.assign({},e),super.setSize(e)}close(){if(this._group)return this.accessor.removeGroup(this._group)}getWindow(){return this.location.type===`popout`?this.location.getWindow():window}moveTo(e){if(!this._group)throw Error(un);let t=e.group??this.accessor.addGroup({direction:bt(e.position??`right`),skipSetActive:e.skipSetActive??!1});this.accessor.moveGroupOrPanel({from:{groupId:this._group.id},to:{group:t,position:e.group?e.position??`center`:`center`,index:e.index},skipSetActive:e.skipSetActive})}maximize(){if(!this._group)throw Error(un);this.location.type===`grid`&&this.accessor.maximizeGroup(this._group)}isMaximized(){if(!this._group)throw Error(un);return this.accessor.isMaximizedGroup(this._group)}exitMaximized(){if(!this._group)throw Error(un);this.isMaximized()&&this.accessor.exitMaximizedGroup()}initialize(e){this._group=e}},fn=100,pn=100,mn=class extends ln{get minimumWidth(){if(typeof this._explicitConstraints.minimumWidth==`number`)return this._explicitConstraints.minimumWidth;let e=this.activePanel?.minimumWidth;return typeof e==`number`?e:super.__minimumWidth()}get minimumHeight(){if(typeof this._explicitConstraints.minimumHeight==`number`)return this._explicitConstraints.minimumHeight;let e=this.activePanel?.minimumHeight;return typeof e==`number`?e:super.__minimumHeight()}get maximumWidth(){if(typeof this._explicitConstraints.maximumWidth==`number`)return this._explicitConstraints.maximumWidth;let e=this.activePanel?.maximumWidth;return typeof e==`number`?e:super.__maximumWidth()}get maximumHeight(){if(typeof this._explicitConstraints.maximumHeight==`number`)return this._explicitConstraints.maximumHeight;let e=this.activePanel?.maximumHeight;return typeof e==`number`?e:super.__maximumHeight()}get panels(){return this._model.panels}get activePanel(){return this._model.activePanel}get size(){return this._model.size}get model(){return this._model}get locked(){return this._model.locked}set locked(e){this._model.locked=e}get header(){return this._model.header}constructor(e,t,n){super(t,`groupview_default`,{minimumHeight:n.constraints?.minimumHeight??pn,minimumWidth:n.constraints?.minimumWidth??fn,maximumHeight:n.constraints?.maximumHeight,maximumWidth:n.constraints?.maximumWidth},new dn(t,e)),this._explicitConstraints={},this.api.initialize(this),this._model=new sn(this.element,e,t,n,this),this.addDisposables(this.model.onDidActivePanelChange(e=>{this.api._onDidActivePanelChange.fire(e)}),this.api.onDidConstraintsChangeInternal(e=>{e.minimumWidth!==void 0&&(this._explicitConstraints.minimumWidth=typeof e.minimumWidth==`function`?e.minimumWidth():e.minimumWidth),e.minimumHeight!==void 0&&(this._explicitConstraints.minimumHeight=typeof e.minimumHeight==`function`?e.minimumHeight():e.minimumHeight),e.maximumWidth!==void 0&&(this._explicitConstraints.maximumWidth=typeof e.maximumWidth==`function`?e.maximumWidth():e.maximumWidth),e.maximumHeight!==void 0&&(this._explicitConstraints.maximumHeight=typeof e.maximumHeight==`function`?e.maximumHeight():e.maximumHeight)}))}focus(){this.api.isActive||this.api.setActive(),super.focus()}initialize(){this._model.initialize()}setActive(e){super.setActive(e),this.model.setActive(e)}layout(e,t){super.layout(e,t),this.model.layout(e,t)}getComponent(){return this._model}toJSON(){return this.model.toJSON()}},hn={name:`dark`,className:`dockview-theme-dark`},gn={name:`light`,className:`dockview-theme-light`},_n={name:`abyss`,className:`dockview-theme-abyss`},vn=class extends cn{get location(){return this.group.api.location}get title(){return this.panel.title}get isGroupActive(){return this.group.isActive}get renderer(){return this.panel.renderer}set group(e){let t=this._group;this._group!==e&&(this._group=e,this._onDidGroupChange.fire({}),this.setupGroupEventListeners(t),this._onDidLocationChange.fire({location:this.group.api.location}))}get group(){return this._group}get tabComponent(){return this._tabComponent}constructor(e,t,n,r,i){super(e.id,r),this.panel=e,this.accessor=n,this._onDidTitleChange=new D,this.onDidTitleChange=this._onDidTitleChange.event,this._onDidActiveGroupChange=new D,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._onDidGroupChange=new D,this.onDidGroupChange=this._onDidGroupChange.event,this._onDidRendererChange=new D,this.onDidRendererChange=this._onDidRendererChange.event,this._onDidLocationChange=new D,this.onDidLocationChange=this._onDidLocationChange.event,this.groupEventsDisposable=new ie,this._tabComponent=i,this.initialize(e),this._group=t,this.setupGroupEventListeners(),this.addDisposables(this.groupEventsDisposable,this._onDidRendererChange,this._onDidTitleChange,this._onDidGroupChange,this._onDidActiveGroupChange,this._onDidLocationChange)}getWindow(){return this.group.api.getWindow()}moveTo(e){this.accessor.moveGroupOrPanel({from:{groupId:this._group.id,panelId:this.panel.id},to:{group:e.group??this._group,position:e.group?e.position??`center`:`center`,index:e.index},skipSetActive:e.skipSetActive})}setTitle(e){this.panel.setTitle(e)}setRenderer(e){this.panel.setRenderer(e)}close(){this.group.model.closePanel(this.panel)}maximize(){this.group.api.maximize()}isMaximized(){return this.group.api.isMaximized()}exitMaximized(){this.group.api.exitMaximized()}setupGroupEventListeners(e){let t=e?.isActive??!1;this.groupEventsDisposable.value=new A(this.group.api.onDidVisibilityChange(e=>{let t=!e.isVisible&&this.isVisible,n=e.isVisible&&!this.isVisible,r=this.group.model.isPanelActive(this.panel);(t||n&&r)&&this._onDidVisibilityChange.fire(e)}),this.group.api.onDidLocationChange(e=>{this.group===this.panel.group&&this._onDidLocationChange.fire(e)}),this.group.api.onDidActiveChange(()=>{this.group===this.panel.group&&t!==this.isGroupActive&&(t=this.isGroupActive,this._onDidActiveGroupChange.fire({isActive:this.isGroupActive}))}))}},yn=class extends A{get params(){return this._params}get title(){return this._title}get group(){return this._group}get renderer(){return this._renderer??this.accessor.renderer}get minimumWidth(){return this._minimumWidth}get minimumHeight(){return this._minimumHeight}get maximumWidth(){return this._maximumWidth}get maximumHeight(){return this._maximumHeight}constructor(e,t,n,r,i,a,o,s){super(),this.id=e,this.accessor=r,this.containerApi=i,this.view=o,this._renderer=s.renderer,this._group=a,this._minimumWidth=s.minimumWidth,this._minimumHeight=s.minimumHeight,this._maximumWidth=s.maximumWidth,this._maximumHeight=s.maximumHeight,this.api=new vn(this,this._group,r,t,n),this.addDisposables(this.api.onActiveChange(()=>{r.setActivePanel(this)}),this.api.onDidSizeChange(e=>{this.group.api.setSize(e)}),this.api.onDidRendererChange(()=>{this.group.model.rerender(this)}))}init(e){this._params=e.params,this.view.init(Object.assign(Object.assign({},e),{api:this.api,containerApi:this.containerApi})),this.setTitle(e.title)}focus(){let e=new At;this.api._onWillFocus.fire(e),!e.defaultPrevented&&(this.api.isActive||this.api.setActive())}toJSON(){return{id:this.id,contentComponent:this.view.contentComponent,tabComponent:this.view.tabComponent,params:Object.keys(this._params||{}).length>0?this._params:void 0,title:this.title,renderer:this._renderer,minimumHeight:this._minimumHeight,maximumHeight:this._maximumHeight,minimumWidth:this._minimumWidth,maximumWidth:this._maximumWidth}}setTitle(e){e!==this.title&&(this._title=e,this.api._onDidTitleChange.fire({title:e}))}setRenderer(e){e!==this.renderer&&(this._renderer=e,this.api._onDidRendererChange.fire({renderer:e}))}update(e){this._params=Object.assign(Object.assign({},this._params??{}),e.params);for(let t of Object.keys(e.params))e.params[t]===void 0&&delete this._params[t];this.view.update({params:this._params})}updateFromStateModel(e){this._maximumHeight=e.maximumHeight,this._minimumHeight=e.minimumHeight,this._maximumWidth=e.maximumWidth,this._minimumWidth=e.minimumWidth,this.update({params:e.params??{}}),this.setTitle(e.title??this.id),this.setRenderer(e.renderer??this.accessor.renderer)}updateParentGroup(e,t){this._group=e,this.api.group=this._group;let n=this._group.model.isPanelActive(this),r=this.group.api.isActive&&n;t?.skipSetActive||this.api.isActive!==r&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&n}),this.api.isVisible!==n&&this.api._onDidVisibilityChange.fire({isVisible:n})}runEvents(){let e=this._group.model.isPanelActive(this),t=this.group.api.isActive&&e;this.api.isActive!==t&&this.api._onDidActiveChange.fire({isActive:this.group.api.isActive&&e}),this.api.isVisible!==e&&this.api._onDidVisibilityChange.fire({isVisible:e})}layout(e,t){this.api._onDidDimensionChange.fire({width:e,height:t}),this.view.layout(e,t)}dispose(){this.api.dispose(),this.view.dispose()}},bn=class extends A{get element(){return this._element}constructor(){super(),this._element=document.createElement(`div`),this._element.className=`dv-default-tab`,this._content=document.createElement(`div`),this._content.className=`dv-default-tab-content`,this.action=document.createElement(`div`),this.action.className=`dv-default-tab-action`,this.action.appendChild(qt()),this._element.appendChild(this._content),this._element.appendChild(this.action),this.render()}init(e){this._title=e.title,this.addDisposables(e.api.onDidTitleChange(e=>{this._title=e.title,this.render()}),O(this.action,`pointerdown`,e=>{e.preventDefault()}),O(this.action,`click`,t=>{t.defaultPrevented||(t.preventDefault(),e.api.close())})),this.render()}render(){this._content.textContent!==this._title&&(this._content.textContent=this._title??``)}},xn=class{get content(){return this._content}get tab(){return this._tab}constructor(e,t,n,r){this.accessor=e,this.id=t,this.contentComponent=n,this.tabComponent=r,this._content=this.createContentComponent(this.id,n),this._tab=this.createTabComponent(this.id,r)}createTabRenderer(e){var t;let n=this.createTabComponent(this.id,this.tabComponent);return this._params&&n.init(Object.assign(Object.assign({},this._params),{tabLocation:e})),this._updateEvent&&((t=n.update)==null||t.call(n,this._updateEvent)),n}init(e){this._params=e,this.content.init(e),this.tab.init(Object.assign(Object.assign({},e),{tabLocation:`header`}))}layout(e,t){var n,r;(r=(n=this.content).layout)==null||r.call(n,e,t)}update(e){var t,n,r,i;this._updateEvent=e,(n=(t=this.content).update)==null||n.call(t,e),(i=(r=this.tab).update)==null||i.call(r,e)}dispose(){var e,t,n,r;(t=(e=this.content).dispose)==null||t.call(e),(r=(n=this.tab).dispose)==null||r.call(n)}createContentComponent(e,t){return this.accessor.options.createComponent({id:e,name:t})}createTabComponent(e,t){let n=t??this.accessor.options.defaultTabComponent;if(n){if(this.accessor.options.createTabComponent)return this.accessor.options.createTabComponent({id:e,name:n})||new bn;console.warn(`dockview: tabComponent '${t}' was not found. falling back to the default tab.`)}return new bn}},Sn=class{constructor(e){this.accessor=e}fromJSON(e,t){let n=e.id,r=e.params,i=e.title,a=e.view,o=a?a.content.id:e.contentComponent??`unknown`,s=a?a.tab?.id:e.tabComponent,c=new xn(this.accessor,n,o,s),l=new yn(n,o,s,this.accessor,new ft(this.accessor),t,c,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return l.init({title:i??n,params:r??{}}),l}},Cn=class extends A{get element(){return this._element}constructor(){super(),this._element=document.createElement(`div`),this._element.className=`dv-watermark`}init(e){}},wn=new class{constructor(){this._orderedList=[]}push(e){this._orderedList=[...this._orderedList.filter(t=>t!==e),e],this.update()}destroy(e){this._orderedList=this._orderedList.filter(t=>t!==e),this.update()}update(){for(let e=0;e<this._orderedList.length;e++)this._orderedList[e].setAttribute(`aria-level`,`${e}`),this._orderedList[e].style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2})`}},Tn=class e extends A{set minimumInViewportWidth(e){this.options.minimumInViewportWidth=e}set minimumInViewportHeight(e){this.options.minimumInViewportHeight=e}get element(){return this._element}get isVisible(){return this._isVisible}constructor(e){super(),this.options=e,this._element=document.createElement(`div`),this._onDidChange=new D,this.onDidChange=this._onDidChange.event,this._onDidChangeEnd=new D,this.onDidChangeEnd=this._onDidChangeEnd.event,this.addDisposables(this._onDidChange,this._onDidChangeEnd),this._element.className=`dv-resize-container`,this._isVisible=!0,this.setupResize(`top`),this.setupResize(`bottom`),this.setupResize(`left`),this.setupResize(`right`),this.setupResize(`topleft`),this.setupResize(`topright`),this.setupResize(`bottomleft`),this.setupResize(`bottomright`),this._element.appendChild(this.options.content),this.options.container.appendChild(this._element),this.setBounds(Object.assign(Object.assign(Object.assign(Object.assign({height:this.options.height,width:this.options.width},`top`in this.options&&{top:this.options.top}),`bottom`in this.options&&{bottom:this.options.bottom}),`left`in this.options&&{left:this.options.left}),`right`in this.options&&{right:this.options.right})),wn.push(this._element)}setVisible(e){e!==this.isVisible&&(this._isVisible=e,M(this.element,`dv-hidden`,!this.isVisible))}bringToFront(){wn.push(this._element)}setBounds(e={}){typeof e.height==`number`&&(this._element.style.height=`${e.height}px`),typeof e.width==`number`&&(this._element.style.width=`${e.width}px`),`top`in e&&typeof e.top==`number`&&(this._element.style.top=`${e.top}px`,this._element.style.bottom=`auto`,this.verticalAlignment=`top`),`bottom`in e&&typeof e.bottom==`number`&&(this._element.style.bottom=`${e.bottom}px`,this._element.style.top=`auto`,this.verticalAlignment=`bottom`),`left`in e&&typeof e.left==`number`&&(this._element.style.left=`${e.left}px`,this._element.style.right=`auto`,this.horiziontalAlignment=`left`),`right`in e&&typeof e.right==`number`&&(this._element.style.right=`${e.right}px`,this._element.style.left=`auto`,this.horiziontalAlignment=`right`);let t=this.options.container.getBoundingClientRect(),n=this._element.getBoundingClientRect(),r=Math.max(0,this.getMinimumWidth(n.width)),i=Math.max(0,this.getMinimumHeight(n.height));if(this.verticalAlignment===`top`){let e=Pe(n.top-t.top,-i,Math.max(0,t.height-n.height+i));this._element.style.top=`${e}px`,this._element.style.bottom=`auto`}if(this.verticalAlignment===`bottom`){let e=Pe(t.bottom-n.bottom,-i,Math.max(0,t.height-n.height+i));this._element.style.bottom=`${e}px`,this._element.style.top=`auto`}if(this.horiziontalAlignment===`left`){let e=Pe(n.left-t.left,-r,Math.max(0,t.width-n.width+r));this._element.style.left=`${e}px`,this._element.style.right=`auto`}if(this.horiziontalAlignment===`right`){let e=Pe(t.right-n.right,-r,Math.max(0,t.width-n.width+r));this._element.style.right=`${e}px`,this._element.style.left=`auto`}this._onDidChange.fire()}toJSON(){let e=this.options.container.getBoundingClientRect(),t=this._element.getBoundingClientRect(),n={};return this.verticalAlignment===`top`?n.top=parseFloat(this._element.style.top):this.verticalAlignment===`bottom`?n.bottom=parseFloat(this._element.style.bottom):n.top=t.top-e.top,this.horiziontalAlignment===`left`?n.left=parseFloat(this._element.style.left):this.horiziontalAlignment===`right`?n.right=parseFloat(this._element.style.right):n.left=t.left-e.left,n.width=t.width,n.height=t.height,n}setupDrag(e,t={inDragMode:!1}){let n=new ie,r=()=>{let e=null,t=ye();n.value=new A({dispose:()=>{t.release()}},O(window,`pointermove`,t=>{let n=this.options.container.getBoundingClientRect(),r=t.clientX-n.left,i=t.clientY-n.top;M(this._element,`dv-resize-container-dragging`,!0);let a=this._element.getBoundingClientRect();e===null&&(e={x:t.clientX-a.left,y:t.clientY-a.top});let o=Math.max(0,this.getMinimumWidth(a.width)),s=Math.max(0,this.getMinimumHeight(a.height)),c=Pe(i-e.y,-s,Math.max(0,n.height-a.height+s)),l=Pe(e.y-i+n.height-a.height,-s,Math.max(0,n.height-a.height+s)),u=Pe(r-e.x,-o,Math.max(0,n.width-a.width+o)),d=Pe(e.x-r+n.width-a.width,-o,Math.max(0,n.width-a.width+o)),f={};c<=l?f.top=c:f.bottom=l,u<=d?f.left=u:f.right=d,this.setBounds(f)}),O(window,`pointerup`,()=>{M(this._element,`dv-resize-container-dragging`,!1),n.dispose(),this._onDidChangeEnd.fire()}))};this.addDisposables(n,O(e,`pointerdown`,e=>{if(e.defaultPrevented){e.preventDefault();return}pe(e)||r()}),O(this.options.content,`pointerdown`,e=>{e.defaultPrevented||pe(e)||e.shiftKey&&r()}),O(this.options.content,`pointerdown`,()=>{wn.push(this._element)},!0)),t.inDragMode&&r()}setupResize(t){let n=document.createElement(`div`);n.className=`dv-resize-handle-${t}`,this._element.appendChild(n);let r=new ie;this.addDisposables(r,O(n,`pointerdown`,n=>{n.preventDefault();let i=null,a=ye();r.value=new A(O(window,`pointermove`,n=>{let r=this.options.container.getBoundingClientRect(),a=this._element.getBoundingClientRect(),o=n.clientY-r.top,s=n.clientX-r.left;i===null&&(i={originalY:o,originalHeight:a.height,originalX:s,originalWidth:a.width});let c,l,u,d,f,p,m=()=>{c=Pe(o,0,i.originalY+i.originalHeight>r.height?Math.max(0,r.height-e.MINIMUM_HEIGHT):Math.max(0,i.originalY+i.originalHeight-e.MINIMUM_HEIGHT)),u=i.originalY+i.originalHeight-c,l=r.height-c-u},h=()=>{c=i.originalY-i.originalHeight;let t=c<0&&typeof this.options.minimumInViewportHeight==`number`?-c+this.options.minimumInViewportHeight:e.MINIMUM_HEIGHT,n=r.height-Math.max(0,c);u=Pe(o-c,t,n),l=r.height-c-u},g=()=>{d=Pe(s,0,i.originalX+i.originalWidth>r.width?Math.max(0,r.width-e.MINIMUM_WIDTH):Math.max(0,i.originalX+i.originalWidth-e.MINIMUM_WIDTH)),p=i.originalX+i.originalWidth-d,f=r.width-d-p},_=()=>{d=i.originalX-i.originalWidth;let t=d<0&&typeof this.options.minimumInViewportWidth==`number`?-d+this.options.minimumInViewportWidth:e.MINIMUM_WIDTH,n=r.width-Math.max(0,d);p=Pe(s-d,t,n),f=r.width-d-p};switch(t){case`top`:m();break;case`bottom`:h();break;case`left`:g();break;case`right`:_();break;case`topleft`:m(),g();break;case`topright`:m(),_();break;case`bottomleft`:h(),g();break;case`bottomright`:h(),_();break}let v={};c<=l?v.top=c:v.bottom=l,d<=f?v.left=d:v.right=f,v.height=u,v.width=p,this.setBounds(v)}),{dispose:()=>{a.release()}},O(window,`pointerup`,()=>{r.dispose(),this._onDidChangeEnd.fire()}))}))}getMinimumWidth(e){return typeof this.options.minimumInViewportWidth==`number`?e-this.options.minimumInViewportWidth:0}getMinimumHeight(e){return typeof this.options.minimumInViewportHeight==`number`?e-this.options.minimumInViewportHeight:0}dispose(){wn.destroy(this._element),this._element.remove(),super.dispose()}};Tn.MINIMUM_HEIGHT=20,Tn.MINIMUM_WIDTH=20;var En=class extends A{constructor(e,t){super(),this.group=e,this.overlay=t,this.addDisposables(t)}position(e){this.overlay.setBounds(e)}},Dn={left:100,top:100,width:300,height:300},On=class{constructor(){this.cache=new Map,this.currentFrameId=0,this.rafId=null}getPosition(e){let t=this.cache.get(e);if(t&&t.frameId===this.currentFrameId)return t.rect;this.scheduleFrameUpdate();let n=he(e);return this.cache.set(e,{rect:n,frameId:this.currentFrameId}),n}invalidate(){this.currentFrameId++}scheduleFrameUpdate(){this.rafId||=requestAnimationFrame(()=>{this.currentFrameId++,this.rafId=null})}};function kn(){let e=document.createElement(`div`);return e.tabIndex=-1,e}var An=class extends A{constructor(e,t){super(),this.element=e,this.accessor=t,this.map={},this._disposed=!1,this.positionCache=new On,this.pendingUpdates=new Set,this.addDisposables(k.from(()=>{for(let e of Object.values(this.map))e.disposable.dispose(),e.destroy.dispose();this._disposed=!0}))}updateAllPositions(){if(!this._disposed){this.positionCache.invalidate();for(let e of Object.values(this.map))e.panel.api.isVisible&&e.resize&&e.resize()}}detatch(e){if(this.map[e.api.id]){let{disposable:t,destroy:n}=this.map[e.api.id];return t.dispose(),n.dispose(),delete this.map[e.api.id],!0}return!1}attach(e){let{panel:t,referenceContainer:n}=e;if(!this.map[t.api.id]){let e=kn();e.className=`dv-render-overlay`,this.map[t.api.id]={panel:t,disposable:k.NONE,destroy:k.NONE,element:e}}let r=this.map[t.api.id].element;t.view.content.element.parentElement!==r&&r.appendChild(t.view.content.element),r.parentElement!==this.element&&this.element.appendChild(r);let i=()=>{let e=t.api.id;this.pendingUpdates.has(e)||(this.pendingUpdates.add(e),requestAnimationFrame(()=>{if(this.pendingUpdates.delete(e),this.isDisposed||!this.map[e])return;let i=this.positionCache.getPosition(n.element),a=this.positionCache.getPosition(this.element),o=i.left-a.left,s=i.top-a.top,c=i.width,l=i.height;r.style.left=`${o}px`,r.style.top=`${s}px`,r.style.width=`${c}px`,r.style.height=`${l}px`,M(r,`dv-render-overlay-float`,t.group.api.location.type===`floating`)}))},a=()=>{t.api.isVisible&&(this.positionCache.invalidate(),i()),r.style.display=t.api.isVisible?``:`none`},o=new ie,s=()=>{t.api.location.type===`floating`?queueMicrotask(()=>{let e=this.accessor.floatingGroups.find(e=>e.group===t.api.group);if(!e)return;let n=e.overlay.element,i=()=>{let e=Number(n.getAttribute(`aria-level`));r.style.zIndex=`calc(var(--dv-overlay-z-index, 999) + ${e*2+1})`},a=new MutationObserver(()=>{i()});o.value=k.from(()=>a.disconnect()),a.observe(n,{attributeFilter:[`aria-level`],attributes:!0}),i()}):r.style.zIndex=``},c=new A(o,new mt(r,{onDragEnd:e=>{n.dropTarget.dnd.onDragEnd(e)},onDragEnter:e=>{n.dropTarget.dnd.onDragEnter(e)},onDragLeave:e=>{n.dropTarget.dnd.onDragLeave(e)},onDrop:e=>{n.dropTarget.dnd.onDrop(e)},onDragOver:e=>{n.dropTarget.dnd.onDragOver(e)}}),t.api.onDidVisibilityChange(()=>{a()}),t.api.onDidDimensionsChange(()=>{t.api.isVisible&&i()}),t.api.onDidLocationChange(()=>{s()}));return this.map[t.api.id].destroy=k.from(()=>{var e;t.view.content.element.parentElement===r&&r.removeChild(t.view.content.element),(e=r.parentElement)==null||e.removeChild(r)}),s(),queueMicrotask(()=>{this.isDisposed||a()}),this.map[t.api.id].disposable.dispose(),this.map[t.api.id].disposable=c,this.map[t.api.id].resize=i,r}},jn=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Mn=class extends A{get window(){return this._window?.value??null}constructor(e,t,n){super(),this.target=e,this.className=t,this.options=n,this._onWillClose=new D,this.onWillClose=this._onWillClose.event,this._onDidClose=new D,this.onDidClose=this._onDidClose.event,this._window=null,this.addDisposables(this._onWillClose,this._onDidClose,{dispose:()=>{this.close()}})}dimensions(){if(!this._window)return null;let e=this._window.value.screenX;return{top:this._window.value.screenY,left:e,width:this._window.value.innerWidth,height:this._window.value.innerHeight}}close(){var e,t;this._window&&(this._onWillClose.fire(),(t=(e=this.options).onWillClose)==null||t.call(e,{id:this.target,window:this._window.value}),this._window.disposable.dispose(),this._window=null,this._onDidClose.fire())}open(){var e,t;return jn(this,void 0,void 0,function*(){if(this._window)throw Error(`instance of popout window is already open`);let n=`${this.options.url}`,r=Object.entries({top:this.options.top,left:this.options.left,width:this.options.width,height:this.options.height}).map(([e,t])=>`${e}=${t}`).join(`,`),i=window.open(n,this.target,r);if(!i)return null;let a=new A;this._window={value:i,disposable:a},a.addDisposables(k.from(()=>{i.close()}),O(window,`beforeunload`,()=>{this.close()}));let o=this.createPopoutWindowContainer();return this.className&&o.classList.add(this.className),(t=(e=this.options).onDidOpen)==null||t.call(e,{id:this.target,window:i}),new Promise((e,t)=>{i.addEventListener(`unload`,e=>{}),i.addEventListener(`load`,()=>{try{let t=i.document;t.title=document.title,t.body.appendChild(o),me(t,window.document.styleSheets),O(i,`beforeunload`,()=>{this.close()}),e(o)}catch(e){t(e)}})})})}createPopoutWindowContainer(){let e=document.createElement(`div`);return e.classList.add(`dv-popout-window`),e.id=`dv-popout-window`,e.style.position=`absolute`,e.style.width=`100%`,e.style.height=`100%`,e.style.top=`0px`,e.style.left=`0px`,e}},Nn=class extends A{constructor(e){super(),this.accessor=e,this.init()}init(){let e=new Set,t=new Set;this.addDisposables(this.accessor.onDidAddPanel(t=>{if(e.has(t.api.id))throw Error(`dockview: Invalid event sequence. [onDidAddPanel] called for panel ${t.api.id} but panel already exists`);e.add(t.api.id)}),this.accessor.onDidRemovePanel(t=>{if(e.has(t.api.id))e.delete(t.api.id);else throw Error(`dockview: Invalid event sequence. [onDidRemovePanel] called for panel ${t.api.id} but panel does not exists`)}),this.accessor.onDidAddGroup(e=>{if(t.has(e.api.id))throw Error(`dockview: Invalid event sequence. [onDidAddGroup] called for group ${e.api.id} but group already exists`);t.add(e.api.id)}),this.accessor.onDidRemoveGroup(e=>{if(t.has(e.api.id))t.delete(e.api.id);else throw Error(`dockview: Invalid event sequence. [onDidRemoveGroup] called for group ${e.api.id} but group does not exists`)}))}},Pn=class extends A{constructor(e){super(),this.root=e,this._active=null,this._activeDisposable=new ie,this._element=document.createElement(`div`),this._element.className=`dv-popover-anchor`,this._element.style.position=`relative`,this.root.prepend(this._element),this.addDisposables(k.from(()=>{this.close()}),this._activeDisposable)}openPopover(e,t){this.close();let n=document.createElement(`div`);n.style.position=`absolute`,n.style.zIndex=t.zIndex??`var(--dv-overlay-z-index)`,n.appendChild(e);let r=this._element.getBoundingClientRect(),i=r.left,a=r.top;n.style.top=`${t.y-a}px`,n.style.left=`${t.x-i}px`,this._element.appendChild(n),this._active=n,this._activeDisposable.value=new A(O(window,`pointerdown`,e=>{let t=e.target;if(!(t instanceof HTMLElement))return;let r=t;for(;r&&r!==n;)r=r?.parentElement??null;r||this.close()})),requestAnimationFrame(()=>{Ee(n,this.root)})}close(){this._active&&=(this._active.remove(),this._activeDisposable.dispose(),null)}},Fn=class extends A{get disabled(){return this._disabled}set disabled(e){var t;this.disabled!==e&&(this._disabled=e,e&&((t=this.model)==null||t.clear()))}get model(){if(!this.disabled)return{clear:()=>{var e;this._model&&((e=this._model.root.parentElement)==null||e.removeChild(this._model.root)),this._model=void 0},exists:()=>!!this._model,getElements:(e,t)=>{let n=this._outline!==t;if(this._outline=t,this._model)return this._model.changed=n,this._model;let r=this.createContainer(),i=this.createAnchor();if(this._model={root:r,overlay:i,changed:n},r.appendChild(i),this.element.appendChild(r),e?.target instanceof HTMLElement){let t=e.target.getBoundingClientRect(),n=this.element.getBoundingClientRect();i.style.left=`${t.left-n.left}px`,i.style.top=`${t.top-n.top}px`}return this._model}}}constructor(e,t){super(),this.element=e,this._disabled=!1,this._disabled=t.disabled,this.addDisposables(k.from(()=>{var e;(e=this.model)==null||e.clear()}))}createContainer(){let e=document.createElement(`div`);return e.className=`dv-drop-target-container`,e}createAnchor(){let e=document.createElement(`div`);return e.className=`dv-drop-target-anchor`,e.style.visibility=`hidden`,e}},In={activationSize:{type:`pixels`,value:10},size:{type:`pixels`,value:20}};function Ln(e){let t=e.from.activePanel;[...e.from.panels].map(t=>{let n=e.from.model.removePanel(t);return e.from.model.renderContainer.detatch(t),n}).forEach(n=>{e.to.model.openPanel(n,{skipSetActive:t!==n,skipSetGroupActive:!0})})}var Rn=class extends ct{get orientation(){return this.gridview.orientation}get totalPanels(){return this.panels.length}get panels(){return this.groups.flatMap(e=>e.panels)}get options(){return this._options}get activePanel(){let e=this.activeGroup;if(e)return e.activePanel}get renderer(){return this.options.defaultRenderer??`onlyWhenVisible`}get api(){return this._api}get floatingGroups(){return this._floatingGroups}get popoutRestorationPromise(){return this._popoutRestorationPromise}constructor(e,t){super(e,{proportionalLayout:!0,orientation:N.HORIZONTAL,styles:t.hideBorders?{separatorBorder:`transparent`}:void 0,disableAutoResizing:t.disableAutoResizing,locked:t.locked,margin:t.theme?.gap??0,className:t.className}),this.nextGroupId=Fe(),this._deserializer=new Sn(this),this._watermark=null,this._onWillDragPanel=new D,this.onWillDragPanel=this._onWillDragPanel.event,this._onWillDragGroup=new D,this.onWillDragGroup=this._onWillDragGroup.event,this._onDidDrop=new D,this.onDidDrop=this._onDidDrop.event,this._onWillDrop=new D,this.onWillDrop=this._onWillDrop.event,this._onWillShowOverlay=new D,this.onWillShowOverlay=this._onWillShowOverlay.event,this._onUnhandledDragOverEvent=new D,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this._onDidRemovePanel=new D,this.onDidRemovePanel=this._onDidRemovePanel.event,this._onDidAddPanel=new D,this.onDidAddPanel=this._onDidAddPanel.event,this._onDidPopoutGroupSizeChange=new D,this.onDidPopoutGroupSizeChange=this._onDidPopoutGroupSizeChange.event,this._onDidPopoutGroupPositionChange=new D,this.onDidPopoutGroupPositionChange=this._onDidPopoutGroupPositionChange.event,this._onDidOpenPopoutWindowFail=new D,this.onDidOpenPopoutWindowFail=this._onDidOpenPopoutWindowFail.event,this._onDidLayoutFromJSON=new D,this.onDidLayoutFromJSON=this._onDidLayoutFromJSON.event,this._onDidActivePanelChange=new D({replay:!0}),this.onDidActivePanelChange=this._onDidActivePanelChange.event,this._onDidMovePanel=new D,this.onDidMovePanel=this._onDidMovePanel.event,this._onDidMaximizedGroupChange=new D,this.onDidMaximizedGroupChange=this._onDidMaximizedGroupChange.event,this._floatingGroups=[],this._popoutGroups=[],this._popoutRestorationPromise=Promise.resolve(),this._onDidRemoveGroup=new D,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new D,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidOptionsChange=new D,this.onDidOptionsChange=this._onDidOptionsChange.event,this._onDidActiveGroupChange=new D,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._moving=!1,this._options=t,this.popupService=new Pn(this.element),this._themeClassnames=new xe(this.element),this._api=new ft(this),this.rootDropTargetContainer=new Fn(this.element,{disabled:!0}),this.overlayRenderContainer=new An(this.gridview.element,this),this._rootDropTarget=new Tt(this.element,{className:`dv-drop-target-edge`,canDisplayOverlay:(e,t)=>{let n=S();if(n)return n.viewId===this.id?t===`center`?this.gridview.length===0:!0:!1;if(t===`center`&&this.gridview.length!==0)return!1;let r=new Qt(e,`edge`,t,S);return this._onUnhandledDragOverEvent.fire(r),r.isAccepted},acceptedTargetZones:[`top`,`bottom`,`left`,`right`,`center`],overlayModel:t.rootOverlayModel??In,getOverrideTarget:()=>this.rootDropTargetContainer?.model}),this.updateDropTargetModel(t),M(this.gridview.element,`dv-dockview`,!0),M(this.element,`dv-debug`,!!t.debug),this.updateTheme(),this.updateWatermark(),t.debug&&this.addDisposables(new Nn(this)),this.addDisposables(this.rootDropTargetContainer,this.overlayRenderContainer,this._onWillDragPanel,this._onWillDragGroup,this._onWillShowOverlay,this._onDidActivePanelChange,this._onDidAddPanel,this._onDidRemovePanel,this._onDidLayoutFromJSON,this._onDidDrop,this._onWillDrop,this._onDidMovePanel,this._onDidMovePanel.event(()=>{this.debouncedUpdateAllPositions()}),this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this._onUnhandledDragOverEvent,this._onDidMaximizedGroupChange,this._onDidOptionsChange,this._onDidPopoutGroupSizeChange,this._onDidPopoutGroupPositionChange,this._onDidOpenPopoutWindowFail,this.onDidViewVisibilityChangeMicroTaskQueue(()=>{this.updateWatermark()}),this.onDidAdd(e=>{this._moving||this._onDidAddGroup.fire(e)}),this.onDidRemove(e=>{this._moving||this._onDidRemoveGroup.fire(e)}),this.onDidActiveChange(e=>{this._moving||this._onDidActiveGroupChange.fire(e)}),this.onDidMaximizedChange(e=>{this._onDidMaximizedGroupChange.fire({group:e.panel,isMaximized:e.isMaximized})}),w.any(this.onDidAdd,this.onDidRemove)(()=>{this.updateWatermark()}),w.any(this.onDidAddPanel,this.onDidRemovePanel,this.onDidAddGroup,this.onDidRemove,this.onDidMovePanel,this.onDidActivePanelChange,this.onDidPopoutGroupPositionChange,this.onDidPopoutGroupSizeChange)(()=>{this._bufferOnDidLayoutChange.fire()}),k.from(()=>{for(let e of[...this._floatingGroups])e.dispose();for(let e of[...this._popoutGroups])e.disposable.dispose()}),this._rootDropTarget,this._rootDropTarget.onWillShowOverlay(e=>{this.gridview.length>0&&e.position===`center`||this._onWillShowOverlay.fire(new Vt(e,{kind:`edge`,panel:void 0,api:this._api,group:void 0,getData:S}))}),this._rootDropTarget.onDrop(e=>{let t=new on({nativeEvent:e.nativeEvent,position:e.position,panel:void 0,api:this._api,group:void 0,getData:S,kind:`edge`});if(this._onWillDrop.fire(t),t.defaultPrevented)return;let n=S();n?this.moveGroupOrPanel({from:{groupId:n.groupId,panelId:n.panelId??void 0},to:{group:this.orthogonalize(e.position),position:`center`}}):this._onDidDrop.fire(new an({nativeEvent:e.nativeEvent,position:e.position,panel:void 0,api:this._api,group:void 0,getData:S}))}),this._rootDropTarget)}setVisible(e,t){switch(e.api.location.type){case`grid`:super.setVisible(e,t);break;case`floating`:{let n=this.floatingGroups.find(t=>t.group===e);n&&(n.overlay.setVisible(t),e.api._onDidVisibilityChange.fire({isVisible:t}));break}case`popout`:console.warn(`dockview: You cannot hide a group that is in a popout window`);break}}addPopoutGroup(e,t){if(e instanceof yn&&e.group.size===1)return this.addPopoutGroup(e.group,t);let n=be(this.gridview.element),r=this.element;function i(){return t?.position?t.position:e instanceof mn?e.element.getBoundingClientRect():e.group?e.group.element.getBoundingClientRect():r.getBoundingClientRect()}let a=i(),o=t?.overridePopoutGroup?.id??this.getNextGroupId(),s=new Mn(`${this.id}-${o}`,n??``,{url:t?.popoutUrl??this.options?.popoutUrl??`/popout.html`,left:window.screenX+a.left,top:window.screenY+a.top,width:a.width,height:a.height,onDidOpen:t?.onDidOpen,onWillClose:t?.onWillClose}),c=new A(s,s.onDidClose(()=>{c.dispose()}));return s.open().then(n=>{if(s.isDisposed)return!1;let r=t?.referenceGroup?t.referenceGroup:e instanceof yn?e.group:e,i=e.api.location.type,a=r.element.parentElement!==null,l;if(a?t?.overridePopoutGroup?l=t.overridePopoutGroup:(l=this.createGroup({id:o}),n&&this._onDidAddGroup.fire(l)):l=r,n===null)return console.error(`dockview: failed to create popout. perhaps you need to allow pop-ups for this website`),c.dispose(),this._onDidOpenPopoutWindowFail.fire(),this.movingLock(()=>Ln({from:l,to:r})),r.api.isVisible||r.api.setVisible(!0),!1;let u=document.createElement(`div`);u.className=`dv-overlay-render-container`;let d=new An(u,this);l.model.renderContainer=d,l.layout(s.window.innerWidth,s.window.innerHeight);let f;if(!t?.overridePopoutGroup&&a)if(e instanceof yn)this.movingLock(()=>{let t=r.model.removePanel(e);l.model.openPanel(t)});else switch(this.movingLock(()=>Ln({from:r,to:l})),i){case`grid`:r.api.setVisible(!1);break;case`floating`:case`popout`:f=this._floatingGroups.find(t=>t.group.api.id===e.api.id)?.overlay.toJSON(),this.removeGroup(r);break}n.classList.add(`dv-dockview`),n.style.overflow=`hidden`,n.appendChild(u),n.appendChild(l.element);let p=document.createElement(`div`),m=new Fn(p,{disabled:this.rootDropTargetContainer.disabled});n.appendChild(p),l.model.dropTargetContainer=m,l.model.location={type:`popout`,getWindow:()=>s.window,popoutUrl:t?.popoutUrl},a&&e.api.location.type===`grid`&&e.api.setVisible(!1),this.doSetGroupAndPanelActive(l),c.addDisposables(l.api.onDidActiveChange(e=>{var t;e.isActive&&((t=s.window)==null||t.focus())}),l.api.onWillFocus(()=>{var e;(e=s.window)==null||e.focus()}));let h,g=a&&r&&this.getPanel(r.id),_={window:s,popoutGroup:l,referenceGroup:g?r.id:void 0,disposable:{dispose:()=>(c.dispose(),h)}},v=we(s.window);return c.addDisposables(v,Te(s.window,()=>{this._onDidPopoutGroupSizeChange.fire({width:s.window.innerWidth,height:s.window.innerHeight,group:l})}),v.event(()=>{this._onDidPopoutGroupPositionChange.fire({screenX:s.window.screenX,screenY:s.window.screenX,group:l})}),O(s.window,`resize`,()=>{l.layout(s.window.innerWidth,s.window.innerHeight)}),d,k.from(()=>{if(!this.isDisposed){if(a&&this.getPanel(r.id))this.movingLock(()=>Ln({from:l,to:r})),r.api.isVisible||r.api.setVisible(!0),this.getPanel(l.id)&&this.doRemoveGroup(l,{skipPopoutAssociated:!0});else if(this.getPanel(l.id)){if(l.model.renderContainer=this.overlayRenderContainer,l.model.dropTargetContainer=this.rootDropTargetContainer,h=l,!this._popoutGroups.find(e=>e.popoutGroup===l))return;f?this.addFloatingGroup(l,{height:f.height,width:f.width,position:f}):(this.doRemoveGroup(l,{skipDispose:!0,skipActive:!0,skipPopoutReturn:!0}),l.model.location={type:`grid`},this.movingLock(()=>{this.doAddGroup(l,[0])})),this.doSetGroupAndPanelActive(l)}}})),this._popoutGroups.push(_),this.updateWatermark(),!0}).catch(e=>(console.error(`dockview: failed to create popout.`,e),!1))}addFloatingGroup(e,t){let n;if(e instanceof yn)n=this.createGroup(),this._onDidAddGroup.fire(n),this.movingLock(()=>this.removePanel(e,{removeEmptyGroup:!0,skipDispose:!0,skipSetActiveGroup:!0})),this.movingLock(()=>n.model.openPanel(e,{skipSetGroupActive:!0}));else{n=e;let r=this._popoutGroups.find(e=>e.popoutGroup===n)?.referenceGroup,i=r?this.getPanel(r):void 0;typeof t?.skipRemoveGroup==`boolean`&&t.skipRemoveGroup||(i?(this.movingLock(()=>Ln({from:e,to:i})),this.doRemoveGroup(e,{skipPopoutReturn:!0,skipPopoutAssociated:!0}),this.doRemoveGroup(i,{skipDispose:!0}),n=i):this.doRemoveGroup(e,{skipDispose:!0,skipPopoutReturn:!0,skipPopoutAssociated:!1}))}function r(){if(t?.position){let e={};return`left`in t.position?e.left=Math.max(t.position.left,0):`right`in t.position?e.right=Math.max(t.position.right,0):e.left=Dn.left,`top`in t.position?e.top=Math.max(t.position.top,0):`bottom`in t.position?e.bottom=Math.max(t.position.bottom,0):e.top=Dn.top,typeof t.width==`number`?e.width=Math.max(t.width,0):e.width=Dn.width,typeof t.height==`number`?e.height=Math.max(t.height,0):e.height=Dn.height,e}return{left:typeof t?.x==`number`?Math.max(t.x,0):Dn.left,top:typeof t?.y==`number`?Math.max(t.y,0):Dn.top,width:typeof t?.width==`number`?Math.max(t.width,0):Dn.width,height:typeof t?.height==`number`?Math.max(t.height,0):Dn.height}}let i=r(),a=new Tn(Object.assign(Object.assign({container:this.gridview.element,content:n.element},i),{minimumInViewportWidth:this.options.floatingGroupBounds===`boundedWithinViewport`?void 0:this.options.floatingGroupBounds?.minimumWidthWithinViewport??100,minimumInViewportHeight:this.options.floatingGroupBounds===`boundedWithinViewport`?void 0:this.options.floatingGroupBounds?.minimumHeightWithinViewport??100})),o=n.element.querySelector(`.dv-void-container`);if(!o)throw Error(`dockview: failed to find drag handle`);a.setupDrag(o,{inDragMode:typeof t?.inDragMode==`boolean`?t.inDragMode:!1});let s=new En(n,a),c=new A(n.api.onDidActiveChange(e=>{e.isActive&&a.bringToFront()}),oe(n.element,e=>{let{width:t,height:r}=e.contentRect;n.layout(t,r)}));s.addDisposables(a.onDidChange(()=>{n.layout(n.width,n.height)}),a.onDidChangeEnd(()=>{this._bufferOnDidLayoutChange.fire()}),n.onDidChange(e=>{a.setBounds({height:e?.height,width:e?.width})}),{dispose:()=>{c.dispose(),Ne(this._floatingGroups,s),n.model.location={type:`grid`},this.updateWatermark()}}),this._floatingGroups.push(s),n.model.location={type:`floating`},t?.skipActiveGroup||this.doSetGroupAndPanelActive(n),this.updateWatermark()}orthogonalize(e,t){switch(this.gridview.normalize(),e){case`top`:case`bottom`:this.gridview.orientation===N.HORIZONTAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;case`left`:case`right`:this.gridview.orientation===N.VERTICAL&&this.gridview.insertOrthogonalSplitviewAtRoot();break;default:break}switch(e){case`top`:case`left`:case`center`:return this.createGroupAtLocation([0],void 0,t);case`bottom`:case`right`:return this.createGroupAtLocation([this.gridview.length],void 0,t);default:throw Error(`dockview: unsupported position ${e}`)}}updateOptions(e){if(super.updateOptions(e),`floatingGroupBounds`in e)for(let t of this._floatingGroups){switch(e.floatingGroupBounds){case`boundedWithinViewport`:t.overlay.minimumInViewportHeight=void 0,t.overlay.minimumInViewportWidth=void 0;break;case void 0:t.overlay.minimumInViewportHeight=100,t.overlay.minimumInViewportWidth=100;break;default:t.overlay.minimumInViewportHeight=e.floatingGroupBounds?.minimumHeightWithinViewport,t.overlay.minimumInViewportWidth=e.floatingGroupBounds?.minimumWidthWithinViewport}t.overlay.setBounds()}this.updateDropTargetModel(e);let t=this.options.disableDnd;this._options=Object.assign(Object.assign({},this.options),e),t!==this.options.disableDnd&&this.updateDragAndDropState(),`theme`in e&&this.updateTheme(),this.layout(this.gridview.width,this.gridview.height,!0)}layout(e,t,n){if(super.layout(e,t,n),this._floatingGroups)for(let e of this._floatingGroups)e.overlay.setBounds()}updateDragAndDropState(){for(let e of this.groups)e.model.updateDragAndDropState()}focus(){var e;(e=this.activeGroup)==null||e.focus()}getGroupPanel(e){return this.panels.find(t=>t.id===e)}setActivePanel(e){e.group.model.openPanel(e),this.doSetGroupAndPanelActive(e.group)}moveToNext(e={}){if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[e.group.panels.length-1]){e.group.model.moveToNext({suppressRoll:!0});return}let t=Xe(e.group.element),n=this.gridview.next(t)?.view;this.doSetGroupAndPanelActive(n)}moveToPrevious(e={}){if(!e.group){if(!this.activeGroup)return;e.group=this.activeGroup}if(e.includePanel&&e.group&&e.group.activePanel!==e.group.panels[0]){e.group.model.moveToPrevious({suppressRoll:!0});return}let t=Xe(e.group.element),n=this.gridview.previous(t)?.view;n&&this.doSetGroupAndPanelActive(n)}toJSON(){let e=this.gridview.serialize(),t=this.panels.reduce((e,t)=>(e[t.id]=t.toJSON(),e),{}),n=this._floatingGroups.map(e=>({data:e.group.toJSON(),position:e.overlay.toJSON()})),r=this._popoutGroups.map(e=>({data:e.popoutGroup.toJSON(),gridReferenceGroup:e.referenceGroup,position:e.window.dimensions(),url:e.popoutGroup.api.location.type===`popout`?e.popoutGroup.api.location.popoutUrl:void 0})),i={grid:e,panels:t,activeGroup:this.activeGroup?.id};return n.length>0&&(i.floatingGroups=n),r.length>0&&(i.popoutGroups=r),i}fromJSON(e,t){let n=new Map,r;if(t?.reuseExistingPanels){r=this.createGroup(),this._groups.delete(r.api.id);let t=Object.keys(e.panels);for(let e of this.panels)t.includes(e.api.id)&&n.set(e.api.id,e);this.movingLock(()=>{Array.from(n.values()).forEach(e=>{this.moveGroupOrPanel({from:{groupId:e.api.group.api.id,panelId:e.api.id},to:{group:r,position:`center`},keepEmptyGroups:!0})})})}if(this.clear(),typeof e!=`object`||!e)throw Error(`dockview: serialized layout must be a non-null object`);let{grid:i,panels:a,activeGroup:o}=e;if(i.root.type!==`branch`||!Array.isArray(i.root.data))throw Error(`dockview: root must be of type branch`);try{let t=this.width,s=this.height,c=e=>{let{id:t,locked:i,hideHeader:o,views:s,activeView:c}=e;if(typeof t!=`string`)throw Error(`dockview: group id must be of type string`);let l=this.createGroup({id:t,locked:!!i,hideHeader:!!o});this._onDidAddGroup.fire(l);let u=[];for(let e of s){let t=n.get(e);if(r&&t)this.movingLock(()=>{r.model.removePanel(t)}),u.push(t),t.updateFromStateModel(a[e]);else{let t=this._deserializer.fromJSON(a[e],l);u.push(t)}}for(let e=0;e<s.length;e++){let t=u[e],r=typeof c==`string`&&c===t.id;n.has(t.api.id)?this.movingLock(()=>{l.model.openPanel(t,{skipSetActive:!r,skipSetGroupActive:!0})}):l.model.openPanel(t,{skipSetActive:!r,skipSetGroupActive:!0})}return!l.activePanel&&l.panels.length>0&&l.model.openPanel(l.panels[l.panels.length-1],{skipSetGroupActive:!0}),l};this.gridview.deserialize(i,{fromJSON:e=>c(e.data)}),this.layout(t,s,!0);let l=e.floatingGroups??[];for(let e of l){let{data:t,position:n}=e,r=c(t);this.addFloatingGroup(r,{position:n,width:n.width,height:n.height,skipRemoveGroup:!0,inDragMode:!1})}let u=e.popoutGroups??[],d=[];u.forEach((e,t)=>{let{data:n,position:r,gridReferenceGroup:i,url:a}=e,o=c(n),s=new Promise(e=>{setTimeout(()=>{this.addPopoutGroup(o,{position:r??void 0,overridePopoutGroup:i?o:void 0,referenceGroup:i?this.getPanel(i):void 0,popoutUrl:a}),e()},t*100)});d.push(s)}),this._popoutRestorationPromise=Promise.all(d).then(()=>void 0);for(let e of this._floatingGroups)e.overlay.setBounds();if(typeof o==`string`){let e=this.getPanel(o);e&&this.doSetGroupAndPanelActive(e)}}catch(e){console.error(`dockview: failed to deserialize layout. Reverting changes`,e);for(let e of this.groups)for(let t of e.panels)this.removePanel(t,{removeEmptyGroup:!1,skipDispose:!1});for(let e of this.groups)e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e);for(let e of[...this._floatingGroups])e.dispose();throw this.clear(),e}this.updateWatermark(),this.debouncedUpdateAllPositions(),this._onDidLayoutFromJSON.fire()}clear(){let e=Array.from(this._groups.values()).map(e=>e.value),t=!!this.activeGroup;for(let t of e)this.removeGroup(t,{skipActive:!0});t&&this.doSetGroupAndPanelActive(void 0),this.gridview.clear()}closeAllGroups(){for(let e of this._groups.entries()){let[t,n]=e;n.value.model.closeAllPanels()}}addPanel(e){if(this.panels.find(t=>t.id===e.id))throw Error(`dockview: panel with id ${e.id} already exists`);let t;if(e.position&&e.floating)throw Error(`dockview: you can only provide one of: position, floating as arguments to .addPanel(...)`);let n={width:e.initialWidth,height:e.initialHeight},r;if(e.position)if(en(e.position)){let n=typeof e.position.referencePanel==`string`?this.getGroupPanel(e.position.referencePanel):e.position.referencePanel;if(r=e.position.index,!n)throw Error(`dockview: referencePanel '${e.position.referencePanel}' does not exist`);t=this.findGroup(n)}else if(tn(e.position)){if(t=typeof e.position.referenceGroup==`string`?this._groups.get(e.position.referenceGroup)?.value:e.position.referenceGroup,r=e.position.index,!t)throw Error(`dockview: referenceGroup '${e.position.referenceGroup}' does not exist`)}else{let t=this.orthogonalize(yt(e.position.direction)),i=this.createPanel(e,t);return t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(t),t.api.setSize({height:n?.height,width:n?.width}),i}else t=this.activeGroup;let i;if(t){let a=st(e.position?.direction||`within`);if(e.floating){let t=this.createGroup();this._onDidAddGroup.fire(t);let n=typeof e.floating==`object`&&e.floating!==null?e.floating:{};this.addFloatingGroup(t,Object.assign(Object.assign({},n),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),i=this.createPanel(e,t),t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r})}else if(t.api.location.type===`floating`||a===`center`)i=this.createPanel(e,t),t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),t.api.setSize({width:n?.width,height:n?.height}),e.inactive||this.doSetGroupAndPanelActive(t);else{let o=Xe(t.element),s=Ze(this.gridview.orientation,o,a),c=this.createGroupAtLocation(s,this.orientationAtLocation(s)===N.VERTICAL?n?.height:n?.width);i=this.createPanel(e,c),c.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(c)}}else if(e.floating){let t=this.createGroup();this._onDidAddGroup.fire(t);let n=typeof e.floating==`object`&&e.floating!==null?e.floating:{};this.addFloatingGroup(t,Object.assign(Object.assign({},n),{inDragMode:!1,skipRemoveGroup:!0,skipActiveGroup:!0})),i=this.createPanel(e,t),t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r})}else{let t=this.createGroupAtLocation([0],this.gridview.orientation===N.VERTICAL?n?.height:n?.width);i=this.createPanel(e,t),t.model.openPanel(i,{skipSetActive:e.inactive,skipSetGroupActive:e.inactive,index:r}),e.inactive||this.doSetGroupAndPanelActive(t)}return i}removePanel(e,t={removeEmptyGroup:!0}){let n=e.group;if(!n)throw Error(`dockview: cannot remove panel ${e.id}. it's missing a group.`);n.model.removePanel(e,{skipSetActiveGroup:t.skipSetActiveGroup}),t.skipDispose||(e.group.model.renderContainer.detatch(e),e.dispose()),n.size===0&&t.removeEmptyGroup&&this.removeGroup(n,{skipActive:t.skipSetActiveGroup})}createWatermarkComponent(){return this.options.createWatermarkComponent?this.options.createWatermarkComponent():new Cn}updateWatermark(){var e,t;if(this.groups.filter(e=>e.api.location.type===`grid`&&e.api.isVisible).length===0){if(!this._watermark){this._watermark=this.createWatermarkComponent(),this._watermark.init({containerApi:new ft(this)});let e=document.createElement(`div`);e.className=`dv-watermark-container`,_e(e,`watermark-component`),e.appendChild(this._watermark.element),this.gridview.element.appendChild(e)}}else this._watermark&&=(this._watermark.element.parentElement.remove(),(t=(e=this._watermark).dispose)==null||t.call(e),null)}addGroup(e){if(e){let t;if(nn(e)){let n=typeof e.referencePanel==`string`?this.panels.find(t=>t.id===e.referencePanel):e.referencePanel;if(!n)throw Error(`dockview: reference panel ${e.referencePanel} does not exist`);if(t=this.findGroup(n),!t)throw Error(`dockview: reference group for reference panel ${e.referencePanel} does not exist`)}else if(rn(e)){if(t=typeof e.referenceGroup==`string`?this._groups.get(e.referenceGroup)?.value:e.referenceGroup,!t)throw Error(`dockview: reference group ${e.referenceGroup} does not exist`)}else{let t=this.orthogonalize(yt(e.direction),e);return e.skipSetActive||this.doSetGroupAndPanelActive(t),t}let n=st(e.direction||`within`),r=Xe(t.element),i=Ze(this.gridview.orientation,r,n),a=this.createGroup(e),o=this.getLocationOrientation(i)===N.VERTICAL?e.initialHeight:e.initialWidth;return this.doAddGroup(a,i,o),e.skipSetActive||this.doSetGroupAndPanelActive(a),a}else{let t=this.createGroup(e);return this.doAddGroup(t),this.doSetGroupAndPanelActive(t),t}}getLocationOrientation(e){return e.length%2==0&&this.gridview.orientation===N.HORIZONTAL?N.HORIZONTAL:N.VERTICAL}removeGroup(e,t){this.doRemoveGroup(e,t)}doRemoveGroup(e,t){let n=[...e.panels];if(!t?.skipDispose)for(let e of n)this.removePanel(e,{removeEmptyGroup:!1,skipDispose:t?.skipDispose??!1});let r=this.activePanel;if(e.api.location.type===`floating`){let n=this._floatingGroups.find(t=>t.group===e);if(n){if(t?.skipDispose||(n.group.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)),Ne(this._floatingGroups,n),n.dispose(),!t?.skipActive&&this._activeGroup===e){let e=Array.from(this._groups.values());this.doSetGroupAndPanelActive(e.length>0?e[0].value:void 0)}return n.group}throw Error(`dockview: failed to find floating group`)}if(e.api.location.type===`popout`){let n=this._popoutGroups.find(t=>t.popoutGroup===e);if(n){if(!t?.skipDispose){if(!t?.skipPopoutAssociated){let e=n.referenceGroup?this.getPanel(n.referenceGroup):void 0;e&&e.panels.length===0&&this.removeGroup(e)}n.popoutGroup.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e)}Ne(this._popoutGroups,n);let r=n.disposable.dispose();if(!t?.skipPopoutReturn&&r&&(this.doAddGroup(r,[0]),this.doSetGroupAndPanelActive(r)),!t?.skipActive&&this._activeGroup===e){let e=Array.from(this._groups.values());this.doSetGroupAndPanelActive(e.length>0?e[0].value:void 0)}return this.updateWatermark(),n.popoutGroup}throw Error(`dockview: failed to find popout group`)}let i=super.doRemoveGroup(e,t);return t?.skipActive||this.activePanel!==r&&this._onDidActivePanelChange.fire(this.activePanel),i}debouncedUpdateAllPositions(){this._updatePositionsFrameId!==void 0&&cancelAnimationFrame(this._updatePositionsFrameId),this._updatePositionsFrameId=requestAnimationFrame(()=>{this._updatePositionsFrameId=void 0,this.overlayRenderContainer.updateAllPositions()})}movingLock(e){let t=this._moving;try{return this._moving=!0,e()}finally{this._moving=t}}moveGroupOrPanel(e){let t=e.to.group,n=e.from.groupId,r=e.from.panelId,i=e.to.position,a=e.to.index,o=n?this._groups.get(n)?.value:void 0;if(!o)throw Error(`dockview: Failed to find group id ${n}`);if(r===void 0){this.moveGroup({from:{group:o},to:{group:t,position:i},skipSetActive:e.skipSetActive});return}if(!i||i===`center`){let n=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!n)throw Error(`dockview: No panel with id ${r}`);!e.keepEmptyGroups&&o.model.size===0&&this.doRemoveGroup(o,{skipActive:!0});let i=t.model.size===0;this.movingLock(()=>t.model.openPanel(n,{index:a,skipSetActive:(e.skipSetActive??!1)&&!i,skipSetGroupActive:!0})),e.skipSetActive||this.doSetGroupAndPanelActive(t),this._onDidMovePanel.fire({panel:n,from:o})}else{let e=Xe(t.element),n=Ze(this.gridview.orientation,e,i);if(o.size<2){let[e,a]=Oe(n);if(o.api.location.type===`grid`){let[t,n]=Oe(Xe(o.element));if(ke(t,e)){this.gridview.moveView(t,n,a),this._onDidMovePanel.fire({panel:this.getGroupPanel(r),from:o});return}}if(o.api.location.type===`popout`){let e=this._popoutGroups.find(e=>e.popoutGroup===o),t=this.movingLock(()=>e.popoutGroup.model.removePanel(e.popoutGroup.panels[0],{skipSetActive:!0,skipSetActiveGroup:!0}));this.doRemoveGroup(o,{skipActive:!0});let i=this.createGroupAtLocation(n);this.movingLock(()=>i.model.openPanel(t,{skipSetActive:!0})),this.doSetGroupAndPanelActive(i),this._onDidMovePanel.fire({panel:this.getGroupPanel(r),from:o});return}let s=this.movingLock(()=>this.doRemoveGroup(o,{skipActive:!0,skipDispose:!0})),c=Xe(t.element),l=Ze(this.gridview.orientation,c,i);this.movingLock(()=>this.doAddGroup(s,l)),this.doSetGroupAndPanelActive(s),this._onDidMovePanel.fire({panel:this.getGroupPanel(r),from:o})}else{let t=this.movingLock(()=>o.model.removePanel(r,{skipSetActive:!1,skipSetActiveGroup:!0}));if(!t)throw Error(`dockview: No panel with id ${r}`);let n=Ze(this.gridview.orientation,e,i),a=this.createGroupAtLocation(n);this.movingLock(()=>a.model.openPanel(t,{skipSetGroupActive:!0})),this.doSetGroupAndPanelActive(a),this._onDidMovePanel.fire({panel:t,from:o})}}}moveGroup(e){let t=e.from.group,n=e.to.group,r=e.to.position;if(r===`center`){let r=t.activePanel,i=this.movingLock(()=>[...t.panels].map(e=>t.model.removePanel(e.id,{skipSetActive:!0})));t?.model.size===0&&this.doRemoveGroup(t,{skipActive:!0}),this.movingLock(()=>{for(let e of i)n.model.openPanel(e,{skipSetActive:e!==r,skipSetGroupActive:!0})}),e.skipSetActive===!0&&this.activePanel||this.doSetGroupAndPanelActive(n)}else{switch(t.api.location.type){case`grid`:this.gridview.removeView(Xe(t.element));break;case`floating`:{let e=this._floatingGroups.find(e=>e.group===t);if(!e)throw Error(`dockview: failed to find floating group`);e.dispose();break}case`popout`:{let e=this._popoutGroups.find(e=>e.popoutGroup===t);if(!e)throw Error(`dockview: failed to find popout group`);let r=this._popoutGroups.indexOf(e);if(r>=0&&this._popoutGroups.splice(r,1),e.referenceGroup){let t=this.getPanel(e.referenceGroup);t&&!t.api.isVisible&&this.doRemoveGroup(t,{skipActive:!0})}e.window.dispose(),n.api.location.type===`grid`?(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,t.model.location={type:`grid`}):n.api.location.type===`floating`&&(t.model.renderContainer=this.overlayRenderContainer,t.model.dropTargetContainer=this.rootDropTargetContainer,t.model.location={type:`floating`});break}}if(n.api.location.type===`grid`){let e=Xe(n.element),i=Ze(this.gridview.orientation,e,r),a;switch(this.gridview.orientation){case N.VERTICAL:a=e.length%2==0?t.api.width:t.api.height;break;case N.HORIZONTAL:a=e.length%2==0?t.api.height:t.api.width;break}this.gridview.addView(t,a,i)}else if(n.api.location.type===`floating`){let e=this._floatingGroups.find(e=>e.group===n);if(e){let n=e.overlay.toJSON(),r,i;r=`left`in n?n.left+50:`right`in n?Math.max(0,n.right-n.width-50):50,i=`top`in n?n.top+50:`bottom`in n?Math.max(0,n.bottom-n.height-50):50,this.addFloatingGroup(t,{height:n.height,width:n.width,position:{left:r,top:i}})}}}if(t.panels.forEach(e=>{this._onDidMovePanel.fire({panel:e,from:t})}),this.debouncedUpdateAllPositions(),e.skipSetActive===!1){let e=n??t;this.doSetGroupAndPanelActive(e)}}doSetGroupActive(e){super.doSetGroupActive(e);let t=this.activePanel;!this._moving&&t!==this._onDidActivePanelChange.value&&this._onDidActivePanelChange.fire(t)}doSetGroupAndPanelActive(e){super.doSetGroupActive(e);let t=this.activePanel;e&&this.hasMaximizedGroup()&&!this.isMaximizedGroup(e)&&this.exitMaximizedGroup(),!this._moving&&t!==this._onDidActivePanelChange.value&&this._onDidActivePanelChange.fire(t)}getNextGroupId(){let e=this.nextGroupId.next();for(;this._groups.has(e);)e=this.nextGroupId.next();return e}createGroup(e){e||={};let t=e?.id;if(t&&this._groups.has(e.id)&&(console.warn(`dockview: Duplicate group id ${e?.id}. reassigning group id to avoid errors`),t=void 0),!t)for(t=this.nextGroupId.next();this._groups.has(t);)t=this.nextGroupId.next();let n=new mn(this,t,e);if(n.init({params:{},accessor:this}),!this._groups.has(n.id)){let e=new A(n.model.onTabDragStart(e=>{this._onWillDragPanel.fire(e)}),n.model.onGroupDragStart(e=>{this._onWillDragGroup.fire(e)}),n.model.onMove(e=>{let{groupId:t,itemId:r,target:i,index:a}=e;this.moveGroupOrPanel({from:{groupId:t,panelId:r},to:{group:n,position:i,index:a}})}),n.model.onDidDrop(e=>{this._onDidDrop.fire(e)}),n.model.onWillDrop(e=>{this._onWillDrop.fire(e)}),n.model.onWillShowOverlay(e=>{if(this.options.disableDnd){e.preventDefault();return}this._onWillShowOverlay.fire(e)}),n.model.onUnhandledDragOverEvent(e=>{this._onUnhandledDragOverEvent.fire(e)}),n.model.onDidAddPanel(e=>{this._moving||this._onDidAddPanel.fire(e.panel)}),n.model.onDidRemovePanel(e=>{this._moving||this._onDidRemovePanel.fire(e.panel)}),n.model.onDidActivePanelChange(e=>{this._moving||e.panel===this.activePanel&&this._onDidActivePanelChange.value!==e.panel&&this._onDidActivePanelChange.fire(e.panel)}),w.any(n.model.onDidPanelTitleChange,n.model.onDidPanelParametersChange)(()=>{this._bufferOnDidLayoutChange.fire()}));this._groups.set(n.id,{value:n,disposable:e})}return n.initialize(),n}createPanel(e,t){let n=e.component,r=e.tabComponent??this.options.defaultTabComponent,i=new xn(this,e.id,n,r),a=new yn(e.id,n,r,this,this._api,t,i,{renderer:e.renderer,minimumWidth:e.minimumWidth,minimumHeight:e.minimumHeight,maximumWidth:e.maximumWidth,maximumHeight:e.maximumHeight});return a.init({title:e.title??e.id,params:e?.params??{}}),a}createGroupAtLocation(e,t,n){let r=this.createGroup(n);return this.doAddGroup(r,e,t),r}findGroup(e){return Array.from(this._groups.values()).find(t=>t.value.model.containsPanel(e))?.value}orientationAtLocation(e){let t=this.gridview.orientation;return e.length%2==1?t:et(t)}updateDropTargetModel(e){`dndEdges`in e&&(this._rootDropTarget.disabled=typeof e.dndEdges==`boolean`&&e.dndEdges===!1,typeof e.dndEdges==`object`&&e.dndEdges!==null?this._rootDropTarget.setOverlayModel(e.dndEdges):this._rootDropTarget.setOverlayModel(In)),`rootOverlayModel`in e&&this.updateDropTargetModel({dndEdges:e.dndEdges})}updateTheme(){let e=this._options.theme??_n;switch(this._themeClassnames.setClassNames(e.className),this.gridview.margin=e.gap??0,e.dndOverlayMounting){case`absolute`:this.rootDropTargetContainer.disabled=!1;break;default:this.rootDropTargetContainer.disabled=!0;break}}},zn=class extends ct{get orientation(){return this.gridview.orientation}set orientation(e){this.gridview.orientation=e}get options(){return this._options}get deserializer(){return this._deserializer}set deserializer(e){this._deserializer=e}constructor(e,t){super(e,{proportionalLayout:t.proportionalLayout??!0,orientation:t.orientation,styles:t.hideBorders?{separatorBorder:`transparent`}:void 0,disableAutoResizing:t.disableAutoResizing,className:t.className}),this._onDidLayoutfromJSON=new D,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidRemoveGroup=new D,this.onDidRemoveGroup=this._onDidRemoveGroup.event,this._onDidAddGroup=new D,this.onDidAddGroup=this._onDidAddGroup.event,this._onDidActiveGroupChange=new D,this.onDidActiveGroupChange=this._onDidActiveGroupChange.event,this._options=t,this.addDisposables(this._onDidAddGroup,this._onDidRemoveGroup,this._onDidActiveGroupChange,this.onDidAdd(e=>{this._onDidAddGroup.fire(e)}),this.onDidRemove(e=>{this._onDidRemoveGroup.fire(e)}),this.onDidActiveChange(e=>{this._onDidActiveGroupChange.fire(e)}))}updateOptions(e){super.updateOptions(e);let t=typeof e.orientation==`string`&&this.gridview.orientation!==e.orientation;this._options=Object.assign(Object.assign({},this.options),e),t&&(this.gridview.orientation=e.orientation),this.layout(this.gridview.width,this.gridview.height,!0)}removePanel(e){this.removeGroup(e)}toJSON(){return{grid:this.gridview.serialize(),activePanel:this.activeGroup?.id}}setVisible(e,t){this.gridview.setViewVisible(Xe(e.element),t)}setActive(e){this._groups.forEach((t,n)=>{t.value.setActive(e===t.value)})}focus(){var e;(e=this.activeGroup)==null||e.focus()}fromJSON(e){this.clear();let{grid:t,activePanel:n}=e;try{let e=[],r=this.width,i=this.height;if(this.gridview.deserialize(t,{fromJSON:t=>{let{data:n}=t,r=this.options.createComponent({id:n.id,name:n.component});return e.push(()=>r.init({params:n.params,minimumWidth:n.minimumWidth,maximumWidth:n.maximumWidth,minimumHeight:n.minimumHeight,maximumHeight:n.maximumHeight,priority:n.priority,snap:!!n.snap,accessor:this,isVisible:t.visible})),this._onDidAddGroup.fire(r),this.registerPanel(r),r}}),this.layout(r,i,!0),e.forEach(e=>e()),typeof n==`string`){let e=this.getPanel(n);e&&this.doSetGroupActive(e)}}catch(e){for(let e of this.groups)e.dispose(),this._groups.delete(e.id),this._onDidRemoveGroup.fire(e);throw this.clear(),e}this._onDidLayoutfromJSON.fire()}clear(){let e=this.activeGroup,t=Array.from(this._groups.values());for(let e of t)e.disposable.dispose(),this.doRemoveGroup(e.value,{skipActive:!0});e&&this.doSetGroupActive(void 0),this.gridview.clear()}movePanel(e,t){let n,r=this.gridview.remove(e),i=this._groups.get(t.reference)?.value;if(!i)throw Error(`reference group ${t.reference} does not exist`);let a=st(t.direction);if(a===`center`)throw Error(`${a} not supported as an option`);{let e=Xe(i.element);n=Ze(this.gridview.orientation,e,a)}this.doAddGroup(r,n,t.size)}addPanel(e){let t=e.location??[0];if(e.position?.referencePanel){let n=this._groups.get(e.position.referencePanel)?.value;if(!n)throw Error(`reference group ${e.position.referencePanel} does not exist`);let r=st(e.position.direction);if(r===`center`)throw Error(`${r} not supported as an option`);{let e=Xe(n.element);t=Ze(this.gridview.orientation,e,r)}}let n=this.options.createComponent({id:e.id,name:e.component});return n.init({params:e.params??{},minimumWidth:e.minimumWidth,maximumWidth:e.maximumWidth,minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight,priority:e.priority,snap:!!e.snap,accessor:this,isVisible:!0}),this.doAddGroup(n,t,e.size),this.registerPanel(n),this.doSetGroupActive(n),n}registerPanel(e){let t=new A(e.api.onDidFocusChange(t=>{t.isFocused&&this._groups.forEach(t=>{let n=t.value;n===e?n.setActive(!0):n.setActive(!1)})}));this._groups.set(e.id,{value:e,disposable:t})}moveGroup(e,t,n){let r=this.getPanel(t);if(!r)throw Error(`invalid operation`);let i=Xe(e.element),[a,o]=Oe(Ze(this.gridview.orientation,i,n)),[s,c]=Oe(Xe(r.element));if(ke(s,a)){this.gridview.moveView(s,c,o);return}let l=this.doRemoveGroup(r,{skipActive:!0,skipDispose:!0}),u=Xe(e.element),d=Ze(this.gridview.orientation,u,n);this.doAddGroup(l,d)}removeGroup(e){super.removeGroup(e)}dispose(){super.dispose(),this._onDidLayoutfromJSON.dispose()}},Bn=class extends at{get panels(){return this.splitview.getViews()}get options(){return this._options}get length(){return this._panels.size}get orientation(){return this.splitview.orientation}get splitview(){return this._splitview}set splitview(e){this._splitview&&this._splitview.dispose(),this._splitview=e,this._splitviewChangeDisposable.value=new A(this._splitview.onDidSashEnd(()=>{this._onDidLayoutChange.fire(void 0)}),this._splitview.onDidAddView(e=>this._onDidAddView.fire(e)),this._splitview.onDidRemoveView(e=>this._onDidRemoveView.fire(e)))}get minimumSize(){return this.splitview.minimumSize}get maximumSize(){return this.splitview.maximumSize}get height(){return this.splitview.orientation===N.HORIZONTAL?this.splitview.orthogonalSize:this.splitview.size}get width(){return this.splitview.orientation===N.HORIZONTAL?this.splitview.size:this.splitview.orthogonalSize}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._splitviewChangeDisposable=new ie,this._panels=new Map,this._onDidLayoutfromJSON=new D,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidAddView=new D,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new D,this.onDidRemoveView=this._onDidRemoveView.event,this._onDidLayoutChange=new D,this.onDidLayoutChange=this._onDidLayoutChange.event,this.element.style.height=`100%`,this.element.style.width=`100%`,this._classNames=new xe(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this._options=t,this.splitview=new Ve(this.element,t),this.addDisposables(this._onDidAddView,this._onDidLayoutfromJSON,this._onDidRemoveView,this._onDidLayoutChange)}updateOptions(e){`className`in e&&this._classNames.setClassNames(e.className??``),`disableResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),typeof e.orientation==`string`&&(this.splitview.orientation=e.orientation),this._options=Object.assign(Object.assign({},this.options),e),this.splitview.layout(this.splitview.size,this.splitview.orthogonalSize)}focus(){var e;(e=this._activePanel)==null||e.focus()}movePanel(e,t){this.splitview.moveView(e,t)}setVisible(e,t){let n=this.panels.indexOf(e);this.splitview.setViewVisible(n,t)}setActive(e,t){this._activePanel=e,this.panels.filter(t=>t!==e).forEach(e=>{e.api._onDidActiveChange.fire({isActive:!1}),t||e.focus()}),e.api._onDidActiveChange.fire({isActive:!0}),t||e.focus()}removePanel(e,t){let n=this._panels.get(e.id);if(!n)throw Error(`unknown splitview panel ${e.id}`);n.dispose(),this._panels.delete(e.id);let r=this.panels.findIndex(t=>t===e);this.splitview.removeView(r,t).dispose();let i=this.panels;i.length>0&&this.setActive(i[i.length-1])}getPanel(e){return this.panels.find(t=>t.id===e)}addPanel(e){if(this._panels.has(e.id))throw Error(`panel ${e.id} already exists`);let t=this.options.createComponent({id:e.id,name:e.component});t.orientation=this.splitview.orientation,t.init({params:e.params??{},minimumSize:e.minimumSize,maximumSize:e.maximumSize,snap:e.snap,priority:e.priority,accessor:this});let n=typeof e.size==`number`?e.size:Be.Distribute,r=typeof e.index==`number`?e.index:void 0;return this.splitview.addView(t,n,r),this.doAddView(t),this.setActive(t),t}layout(e,t){let[n,r]=this.splitview.orientation===N.HORIZONTAL?[e,t]:[t,e];this.splitview.layout(n,r)}doAddView(e){let t=e.api.onDidFocusChange(t=>{t.isFocused&&this.setActive(e,!0)});this._panels.set(e.id,t)}toJSON(){return{views:this.splitview.getViews().map((e,t)=>({size:this.splitview.getViewSize(t),data:e.toJSON(),snap:!!e.snap,priority:e.priority})),activeView:this._activePanel?.id,size:this.splitview.size,orientation:this.splitview.orientation}}fromJSON(e){this.clear();let{views:t,orientation:n,size:r,activeView:i}=e,a=[],o=this.width,s=this.height;if(this.splitview=new Ve(this.element,{orientation:n,proportionalLayout:this.options.proportionalLayout,descriptor:{size:r,views:t.map(e=>{let t=e.data;if(this._panels.has(t.id))throw Error(`panel ${t.id} already exists`);let r=this.options.createComponent({id:t.id,name:t.component});return a.push(()=>{r.init({params:t.params??{},minimumSize:t.minimumSize,maximumSize:t.maximumSize,snap:e.snap,priority:e.priority,accessor:this})}),r.orientation=n,this.doAddView(r),setTimeout(()=>{this._onDidAddView.fire(r)},0),{size:e.size,view:r}})}}),this.layout(o,s),a.forEach(e=>e()),typeof i==`string`){let e=this.getPanel(i);e&&this.setActive(e)}this._onDidLayoutfromJSON.fire()}clear(){for(let e of this._panels.values())e.dispose();for(this._panels.clear();this.splitview.length>0;)this.splitview.removeView(0,Be.Distribute,!0).dispose()}dispose(){for(let e of this._panels.values())e.dispose();this._panels.clear();let e=this.splitview.getViews();this._splitviewChangeDisposable.dispose(),this.splitview.dispose();for(let t of e)t.dispose();this.element.remove(),super.dispose()}},Vn=class extends A{get element(){return this._element}constructor(){super(),this._expandedIcon=Jt(),this._collapsedIcon=Yt(),this.disposable=new ie,this.apiRef={api:null},this._element=document.createElement(`div`),this.element.className=`dv-default-header`,this._content=document.createElement(`span`),this._expander=document.createElement(`div`),this._expander.className=`dv-pane-header-icon`,this.element.appendChild(this._expander),this.element.appendChild(this._content),this.addDisposables(O(this._element,`click`,()=>{var e;(e=this.apiRef.api)==null||e.setExpanded(!this.apiRef.api.isExpanded)}))}init(e){this.apiRef.api=e.api,this._content.textContent=e.title,this.updateIcon(),this.disposable.value=e.api.onDidExpansionChange(()=>{this.updateIcon()})}updateIcon(){let e=!!this.apiRef.api?.isExpanded;M(this._expander,`collapsed`,!e),e?(this._expander.contains(this._collapsedIcon)&&this._collapsedIcon.remove(),this._expander.contains(this._expandedIcon)||this._expander.appendChild(this._expandedIcon)):(this._expander.contains(this._expandedIcon)&&this._expandedIcon.remove(),this._expander.contains(this._collapsedIcon)||this._expander.appendChild(this._collapsedIcon))}update(e){}dispose(){this.disposable.dispose(),super.dispose()}},Hn=Fe(),Un=22,Wn=0,Gn=2**53-1,Kn=class extends It{constructor(e){super({accessor:e.accessor,id:e.id,component:e.component,headerComponent:e.headerComponent,orientation:e.orientation,isExpanded:e.isExpanded,disableDnd:e.disableDnd,headerSize:e.headerSize,minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize}),this.options=e}getBodyComponent(){return this.options.body}getHeaderComponent(){return this.options.header}},qn=class extends at{get id(){return this._id}get panels(){return this.paneview.getPanes()}set paneview(e){this._paneview=e,this._disposable.value=new A(this._paneview.onDidChange(()=>{this._onDidLayoutChange.fire(void 0)}),this._paneview.onDidAddView(e=>this._onDidAddView.fire(e)),this._paneview.onDidRemoveView(e=>this._onDidRemoveView.fire(e)))}get paneview(){return this._paneview}get minimumSize(){return this.paneview.minimumSize}get maximumSize(){return this.paneview.maximumSize}get height(){return this.paneview.orientation===N.HORIZONTAL?this.paneview.orthogonalSize:this.paneview.size}get width(){return this.paneview.orientation===N.HORIZONTAL?this.paneview.size:this.paneview.orthogonalSize}get options(){return this._options}constructor(e,t){super(document.createElement(`div`),t.disableAutoResizing),this._id=Hn.next(),this._disposable=new ie,this._viewDisposables=new Map,this._onDidLayoutfromJSON=new D,this.onDidLayoutFromJSON=this._onDidLayoutfromJSON.event,this._onDidLayoutChange=new D,this.onDidLayoutChange=this._onDidLayoutChange.event,this._onDidDrop=new D,this.onDidDrop=this._onDidDrop.event,this._onDidAddView=new D,this.onDidAddView=this._onDidAddView.event,this._onDidRemoveView=new D,this.onDidRemoveView=this._onDidRemoveView.event,this._onUnhandledDragOverEvent=new D,this.onUnhandledDragOverEvent=this._onUnhandledDragOverEvent.event,this.element.style.height=`100%`,this.element.style.width=`100%`,this.addDisposables(this._onDidLayoutChange,this._onDidLayoutfromJSON,this._onDidDrop,this._onDidAddView,this._onDidRemoveView,this._onUnhandledDragOverEvent),this._classNames=new xe(this.element),this._classNames.setClassNames(t.className??``),e.appendChild(this.element),this._options=t,this.paneview=new Ue(this.element,{orientation:N.VERTICAL}),this.addDisposables(this._disposable)}setVisible(e,t){let n=this.panels.indexOf(e);this.paneview.setViewVisible(n,t)}focus(){}updateOptions(e){`className`in e&&this._classNames.setClassNames(e.className??``),`disableResizing`in e&&(this.disableResizing=e.disableAutoResizing??!1),this._options=Object.assign(Object.assign({},this.options),e)}addPanel(e){let t=this.options.createComponent({id:e.id,name:e.component}),n;e.headerComponent&&this.options.createHeaderComponent&&(n=this.options.createHeaderComponent({id:e.id,name:e.headerComponent})),n||=new Vn;let r=new Kn({id:e.id,component:e.component,headerComponent:e.headerComponent,header:n,body:t,orientation:N.VERTICAL,isExpanded:!!e.isExpanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:e.headerSize??Un,minimumBodySize:Wn,maximumBodySize:Gn});this.doAddPanel(r);let i=typeof e.size==`number`?e.size:Be.Distribute,a=typeof e.index==`number`?e.index:void 0;return r.init({params:e.params??{},minimumBodySize:e.minimumBodySize,maximumBodySize:e.maximumBodySize,isExpanded:e.isExpanded,title:e.title,containerApi:new ut(this),accessor:this}),this.paneview.addPane(r,i,a),r.orientation=this.paneview.orientation,r}removePanel(e){let t=this.panels.findIndex(t=>t===e);this.paneview.removePane(t),this.doRemovePanel(e)}movePanel(e,t){this.paneview.moveView(e,t)}getPanel(e){return this.panels.find(t=>t.id===e)}layout(e,t){let[n,r]=this.paneview.orientation===N.HORIZONTAL?[e,t]:[t,e];this.paneview.layout(n,r)}toJSON(){let e=e=>e===2**53-1||e===1/0?void 0:e,t=e=>e<=0?void 0:e;return{views:this.paneview.getPanes().map((n,r)=>({size:this.paneview.getViewSize(r),data:n.toJSON(),minimumSize:t(n.minimumBodySize),maximumSize:e(n.maximumBodySize),headerSize:n.headerSize,expanded:n.isExpanded()})),size:this.paneview.size}}fromJSON(e){this.clear();let{views:t,size:n}=e,r=[],i=this.width,a=this.height;this.paneview=new Ue(this.element,{orientation:N.VERTICAL,descriptor:{size:n,views:t.map(e=>{let t=e.data,n=this.options.createComponent({id:t.id,name:t.component}),i;t.headerComponent&&this.options.createHeaderComponent&&(i=this.options.createHeaderComponent({id:t.id,name:t.headerComponent})),i||=new Vn;let a=new Kn({id:t.id,component:t.component,headerComponent:t.headerComponent,header:i,body:n,orientation:N.VERTICAL,isExpanded:!!e.expanded,disableDnd:!!this.options.disableDnd,accessor:this,headerSize:e.headerSize??Un,minimumBodySize:e.minimumSize??Wn,maximumBodySize:e.maximumSize??Gn});return this.doAddPanel(a),r.push(()=>{a.init({params:t.params??{},minimumBodySize:e.minimumSize,maximumBodySize:e.maximumSize,title:t.title,isExpanded:!!e.expanded,containerApi:new ut(this),accessor:this}),a.orientation=this.paneview.orientation}),setTimeout(()=>{this._onDidAddView.fire(a)},0),{size:e.size,view:a}})}}),this.layout(i,a),r.forEach(e=>e()),this._onDidLayoutfromJSON.fire()}clear(){for(let[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.paneview.dispose()}doAddPanel(e){let t=new A(e.onDidDrop(e=>{this._onDidDrop.fire(e)}),e.onUnhandledDragOverEvent(e=>{this._onUnhandledDragOverEvent.fire(e)}));this._viewDisposables.set(e.id,t)}doRemovePanel(e){let t=this._viewDisposables.get(e.id);t&&(t.dispose(),this._viewDisposables.delete(e.id))}dispose(){super.dispose();for(let[e,t]of this._viewDisposables.entries())t.dispose();this._viewDisposables.clear(),this.element.remove(),this.paneview.dispose()}},Jn=class extends Pt{get priority(){return this._priority}set orientation(e){this._orientation=e}get orientation(){return this._orientation}get minimumSize(){let e=typeof this._minimumSize==`function`?this._minimumSize():this._minimumSize;return e!==this._evaluatedMinimumSize&&(this._evaluatedMinimumSize=e,this.updateConstraints()),e}get maximumSize(){let e=typeof this._maximumSize==`function`?this._maximumSize():this._maximumSize;return e!==this._evaluatedMaximumSize&&(this._evaluatedMaximumSize=e,this.updateConstraints()),e}get snap(){return this._snap}constructor(e,t){super(e,t,new Mt(e,t)),this._evaluatedMinimumSize=0,this._evaluatedMaximumSize=1/0,this._minimumSize=0,this._maximumSize=1/0,this._snap=!1,this._onDidChange=new D,this.onDidChange=this._onDidChange.event,this.api.initialize(this),this.addDisposables(this._onDidChange,this.api.onWillVisibilityChange(e=>{let{isVisible:t}=e,{accessor:n}=this._params;n.setVisible(this,t)}),this.api.onActiveChange(()=>{let{accessor:e}=this._params;e.setActive(this)}),this.api.onDidConstraintsChangeInternal(e=>{(typeof e.minimumSize==`number`||typeof e.minimumSize==`function`)&&(this._minimumSize=e.minimumSize),(typeof e.maximumSize==`number`||typeof e.maximumSize==`function`)&&(this._maximumSize=e.maximumSize),this.updateConstraints()}),this.api.onDidSizeChange(e=>{this._onDidChange.fire({size:e.size})}))}setVisible(e){this.api._onDidVisibilityChange.fire({isVisible:e})}setActive(e){this.api._onDidActiveChange.fire({isActive:e})}layout(e,t){let[n,r]=this.orientation===N.HORIZONTAL?[e,t]:[t,e];super.layout(n,r)}init(e){super.init(e),this._priority=e.priority,e.minimumSize&&(this._minimumSize=e.minimumSize),e.maximumSize&&(this._maximumSize=e.maximumSize),e.snap&&(this._snap=e.snap)}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{minimumSize:(e=>e<=0?void 0:e)(this.minimumSize),maximumSize:(e=>e===2**53-1||e===1/0?void 0:e)(this.maximumSize)})}updateConstraints(){this.api._onDidConstraintsChange.fire({maximumSize:this._evaluatedMaximumSize,minimumSize:this._evaluatedMinimumSize})}};function Yn(e,t){return new Rn(e,t).api}function Xn(e,t){return new lt(new Bn(e,t))}function Zn(e,t){return new dt(new zn(e,t))}function Qn(e,t){return new ut(new qn(e,t))}var $n=c(m()),er=(e,t)=>{let[n,r]=g.useState(),i=g.useRef(e.componentProps);return g.useImperativeHandle(t,()=>({update:e=>{i.current=Object.assign(Object.assign({},i.current),e),r(Date.now())}}),[]),g.createElement(e.component,i.current)};er.displayName=`DockviewReactJsBridge`;var tr=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),nr=g.createContext({}),rr=class{constructor(e,t,n,r,i){this.parent=e,this.portalStore=t,this.component=n,this.parameters=r,this.context=i,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw Error(`invalid operation: resource is already disposed`);this.componentInstance?this.componentInstance.update(e):this._initialProps=Object.assign(Object.assign({},this._initialProps),e)}createPortal(){if(this.disposed)throw Error(`invalid operation: resource is already disposed`);if(!ar(this.component))throw Error(`Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components`);let e=g.createElement(g.forwardRef(er),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?g.createElement(nr.Provider,{value:this.context},e):e,n=$n.createPortal(t,this.parent,tr.next());this.ref={portal:n,disposable:this.portalStore.addPortal(n)}}dispose(){var e;(e=this.ref)==null||e.disposable.dispose(),this.disposed=!0}},ir=()=>{let[e,t]=g.useState([]);return g.useDebugValue(`Portal count: ${e.length}`),[e,g.useCallback(e=>{t(t=>[...t,e]);let n=!1;return k.from(()=>{if(n)throw Error(`invalid operation: resource already disposed`);n=!0,t(t=>t.filter(t=>t!==e))})},[])]};function ar(e){return typeof e==`function`||!!e?.$$typeof}var or=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._onDidFocus=new D,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new D,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}focus(){}init(e){this.part=new rr(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;(t=this.part)==null||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),(e=this.part)==null||e.dispose()}},sr=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}focus(){}init(e){this.part=new rr(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;(t=this.part)==null||t.update({params:e.params})}layout(e,t){}dispose(){var e;(e=this.part)==null||e.dispose()}},cr=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.part=new rr(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t;this.parameters&&(this.parameters.params=e.params),(t=this.part)==null||t.update({params:this.parameters?.params??{}})}layout(e,t){}dispose(){var e;(e=this.part)==null||e.dispose()}},lr=class{get element(){return this._element}get part(){return this._part}constructor(e,t,n){this.component=e,this.reactPortalStore=t,this._group=n,this.mutableDisposable=new ie,this._element=document.createElement(`div`),this._element.className=`dv-react-part`,this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.mutableDisposable.value=new A(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),e.api.onDidActiveChange(()=>{this.updateGroupActive()})),this._part=new rr(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group})}dispose(){var e;this.mutableDisposable.dispose(),(e=this._part)==null||e.dispose()}update(e){var t;(t=this._part)==null||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}};function ur(e,t){return e?n=>new lr(e,t,n):void 0}var dr=`props.defaultTabComponent`;function fr(e){return $t.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var pr=g.forwardRef((e,t)=>{let n=g.useRef(null),r=g.useRef(),[i,a]=ir();g.useImperativeHandle(t,()=>n.current,[]);let o=g.useRef({});return g.useEffect(()=>{let t={};$t.forEach(n=>{let r=n,i=e[r];r in e&&i!==o.current[r]&&(t[r]=i)}),r.current&&r.current.updateOptions(t),o.current=e},$t.map(t=>e[t])),g.useEffect(()=>{if(!n.current)return;let t=e.tabComponents??{};e.defaultTabComponent&&(t[dr]=e.defaultTabComponent);let i={createLeftHeaderActionComponent:ur(e.leftHeaderActionsComponent,{addPortal:a}),createRightHeaderActionComponent:ur(e.rightHeaderActionsComponent,{addPortal:a}),createPrefixHeaderActionComponent:ur(e.prefixHeaderActionsComponent,{addPortal:a}),createComponent:t=>new or(t.id,e.components[t.name],{addPortal:a}),createTabComponent(e){return new sr(e.id,t[e.name],{addPortal:a})},createWatermarkComponent:e.watermarkComponent?()=>new cr(`watermark`,e.watermarkComponent,{addPortal:a}):void 0,defaultTabComponent:e.defaultTabComponent?dr:void 0},o=Yn(n.current,Object.assign(Object.assign({},fr(e)),i)),{clientWidth:s,clientHeight:c}=n.current;return o.layout(s,c),e.onReady&&e.onReady({api:o}),r.current=o,()=>{r.current=void 0,o.dispose()}},[]),g.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onDidDrop(t=>{e.onDidDrop&&e.onDidDrop(t)});return()=>{t.dispose()}},[e.onDidDrop]),g.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onWillDrop(t=>{e.onWillDrop&&e.onWillDrop(t)});return()=>{t.dispose()}},[e.onWillDrop]),g.useEffect(()=>{r.current&&r.current.updateOptions({createComponent:t=>new or(t.id,e.components[t.name],{addPortal:a})})},[e.components]),g.useEffect(()=>{if(!r.current)return;let t=e.tabComponents??{};e.defaultTabComponent&&(t[dr]=e.defaultTabComponent),r.current.updateOptions({defaultTabComponent:e.defaultTabComponent?dr:void 0,createTabComponent(e){return new sr(e.id,t[e.name],{addPortal:a})}})},[e.tabComponents,e.defaultTabComponent]),g.useEffect(()=>{r.current&&r.current.updateOptions({createWatermarkComponent:e.watermarkComponent?()=>new cr(`watermark`,e.watermarkComponent,{addPortal:a}):void 0})},[e.watermarkComponent]),g.useEffect(()=>{r.current&&r.current.updateOptions({createRightHeaderActionComponent:ur(e.rightHeaderActionsComponent,{addPortal:a})})},[e.rightHeaderActionsComponent]),g.useEffect(()=>{r.current&&r.current.updateOptions({createLeftHeaderActionComponent:ur(e.leftHeaderActionsComponent,{addPortal:a})})},[e.leftHeaderActionsComponent]),g.useEffect(()=>{r.current&&r.current.updateOptions({createPrefixHeaderActionComponent:ur(e.prefixHeaderActionsComponent,{addPortal:a})})},[e.prefixHeaderActionsComponent]),g.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});pr.displayName=`DockviewComponent`;var mr=()=>g.createElement(`svg`,{height:`11`,width:`11`,viewBox:`0 0 28 28`,"aria-hidden":`false`,focusable:!1,className:`dv-svg`},g.createElement(`path`,{d:`M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z`})),hr=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};function gr(e){let[t,n]=g.useState(e.title);return g.useEffect(()=>{let r=e.onDidTitleChange(e=>{n(e.title)});return t!==e.title&&n(e.title),()=>{r.dispose()}},[e]),t}var _r=e=>{var{api:t,containerApi:n,params:r,hideClose:i,closeActionOverride:a,onPointerDown:o,onPointerUp:s,onPointerLeave:c,tabLocation:l}=e,u=hr(e,[`api`,`containerApi`,`params`,`hideClose`,`closeActionOverride`,`onPointerDown`,`onPointerUp`,`onPointerLeave`,`tabLocation`]);let d=gr(t),f=g.useRef(!1),p=g.useCallback(e=>{e.preventDefault(),a?a():t.close()},[t,a]),m=g.useCallback(e=>{e.preventDefault()},[]),h=g.useCallback(e=>{f.current=e.button===1,o?.(e)},[o]),_=g.useCallback(e=>{f&&e.button===1&&!i&&(f.current=!1,p(e)),s?.(e)},[s,p,i]),v=g.useCallback(e=>{f.current=!1,c?.(e)},[c]);return g.createElement(`div`,Object.assign({"data-testid":`dockview-dv-default-tab`},u,{onPointerDown:h,onPointerUp:_,onPointerLeave:v,className:`dv-default-tab`}),g.createElement(`span`,{className:`dv-default-tab-content`},d),!i&&g.createElement(`div`,{className:`dv-default-tab-action`,onPointerDown:m,onClick:p},g.createElement(mr,null)))},vr=class extends Jn{constructor(e,t,n,r){super(e,t),this.reactComponent=n,this.reactPortalStore=r}getComponent(){return new rr(this.element,this.reactPortalStore,this.reactComponent,{params:this._params?.params??{},api:this.api,containerApi:new lt(this._params.accessor)})}};function yr(e){return He.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var br=g.forwardRef((e,t)=>{let n=g.useRef(null),r=g.useRef(),[i,a]=ir();g.useImperativeHandle(t,()=>n.current,[]);let o=g.useRef({});return g.useEffect(()=>{let t={};He.forEach(n=>{let r=n,i=e[r];r in e&&i!==o.current[r]&&(t[r]=i)}),r.current&&r.current.updateOptions(t),o.current=e},He.map(t=>e[t])),g.useEffect(()=>{if(!n.current)return()=>{};let t=Xn(n.current,Object.assign(Object.assign({},yr(e)),{createComponent:t=>new vr(t.id,t.name,e.components[t.name],{addPortal:a})})),{clientWidth:i,clientHeight:o}=n.current;return t.layout(i,o),e.onReady&&e.onReady({api:t}),r.current=t,()=>{r.current=void 0,t.dispose()}},[]),g.useEffect(()=>{r.current&&r.current.updateOptions({createComponent:t=>new vr(t.id,t.name,e.components[t.name],{addPortal:a})})},[e.components]),g.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});br.displayName=`SplitviewComponent`;var xr=class extends ln{constructor(e,t,n,r){super(e,t),this.reactComponent=n,this.reactPortalStore=r}getComponent(){return new rr(this.element,this.reactPortalStore,this.reactComponent,{params:this._params?.params??{},api:this.api,containerApi:new dt(this._params.accessor)})}};function Sr(e){return it.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var Cr=g.forwardRef((e,t)=>{let n=g.useRef(null),r=g.useRef(),[i,a]=ir();g.useImperativeHandle(t,()=>n.current,[]);let o=g.useRef({});return g.useEffect(()=>{let t={};it.forEach(n=>{let r=n,i=e[r];r in e&&i!==o.current[r]&&(t[r]=i)}),r.current&&r.current.updateOptions(t),o.current=e},it.map(t=>e[t])),g.useEffect(()=>{if(!n.current)return()=>{};let t=Zn(n.current,Object.assign(Object.assign({},Sr(e)),{createComponent:t=>new xr(t.id,t.name,e.components[t.name],{addPortal:a})})),{clientWidth:i,clientHeight:o}=n.current;return t.layout(i,o),e.onReady&&e.onReady({api:t}),r.current=t,()=>{r.current=void 0,t.dispose()}},[]),g.useEffect(()=>{r.current&&r.current.updateOptions({createComponent:t=>new xr(t.id,t.name,e.components[t.name],{addPortal:a})})},[e.components]),g.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});Cr.displayName=`GridviewComponent`;var wr=class{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement(`div`),this._element.style.height=`100%`,this._element.style.width=`100%`}init(e){this.part=new rr(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;(t=this.part)==null||t.update(e.params)}dispose(){var e;(e=this.part)==null||e.dispose()}};function Tr(e){return Ot.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}var Er=g.forwardRef((e,t)=>{let n=g.useRef(null),r=g.useRef(),[i,a]=ir();g.useImperativeHandle(t,()=>n.current,[]);let o=g.useRef({});return g.useEffect(()=>{let t={};Ot.forEach(n=>{let r=n,i=e[r];r in e&&i!==o.current[r]&&(t[r]=i)}),r.current&&r.current.updateOptions(t),o.current=e},Ot.map(t=>e[t])),g.useEffect(()=>{if(!n.current)return()=>{};let t=e.headerComponents??{},i=Qn(n.current,Object.assign(Object.assign({},Tr(e)),{createComponent:t=>new wr(t.id,e.components[t.name],{addPortal:a}),createHeaderComponent:e=>new wr(e.id,t[e.name],{addPortal:a})})),{clientWidth:o,clientHeight:s}=n.current;return i.layout(o,s),e.onReady&&e.onReady({api:i}),r.current=i,()=>{r.current=void 0,i.dispose()}},[]),g.useEffect(()=>{r.current&&r.current.updateOptions({createComponent:t=>new wr(t.id,e.components[t.name],{addPortal:a})})},[e.components]),g.useEffect(()=>{if(!r.current)return;let t=e.headerComponents??{};r.current.updateOptions({createHeaderComponent:e=>new wr(e.id,t[e.name],{addPortal:a})})},[e.headerComponents]),g.useEffect(()=>{if(!r.current)return()=>{};let t=r.current.onDidDrop(t=>{e.onDidDrop&&e.onDidDrop(t)});return()=>{t.dispose()}},[e.onDidDrop]),g.createElement(`div`,{style:{height:`100%`,width:`100%`},ref:n},i)});Er.displayName=`PaneviewComponent`;var Dr=[`done`,`failed`,`interrupted`];function Or(e,t,n,r,i,a,o,s,c){if(e.type===`hello`){let l=e.thinking??{};t(()=>(e.messages??[]).map(e=>{let t=l[e.id];return t?{...e,thinking:t.text,thinkingMs:t.ms}:e})),n(()=>e.tasks??[]),r(()=>e.feeds??{}),e.settings&&i(()=>e.settings??{}),a(()=>e.settingsWarnings??{}),o(e.running===!0,e.queued??[]),s(e.usage??null),c()}else if(e.type===`usage`)s(e.usage??null);else if(e.type===`router-state`)o(e.running===!0,e.queued??[]);else if(e.type===`message-picker`&&e.id)t(t=>t.map(t=>t.id===e.id?{...t,pickerAnswers:e.pickerAnswers??{}}:t));else if(e.type===`task-feed`&&e.id){let t=e.id,n=e.entry??``;r(e=>({...e,[t]:[...(e[t]??[]).slice(-79),n]}))}else if(e.type===`settings`&&e.settings){let t=e.settings;i(e=>({...e,...t})),e.settingsWarnings&&a(()=>e.settingsWarnings??{})}else if(e.type===`message-add`&&e.message){let n=e.message;t(e=>[...e,n])}else if(e.type===`message-delta`&&e.id)t(t=>t.map(t=>t.id===e.id?{...t,text:t.text+(e.delta??``),taskIds:e.taskIds??t.taskIds}:t));else if(e.type===`message-thinking-delta`&&e.id){let n=Date.now();t(t=>t.map(t=>t.id===e.id?{...t,thinking:(t.thinking??``)+(e.delta??``),thinkingStartAt:t.thinkingStartAt??n,thinkingMs:t.thinkingStartAt?n-t.thinkingStartAt:0}:t))}else if(e.type===`message-activity`&&e.id)t(t=>t.map(t=>t.id===e.id?{...t,activity:e.activity??null}:t));else if(e.type===`message-done`&&e.id){let n=e.errorVerbose??e.errorDetail;e.status===`error`&&n&&console.error(`[castle] agent turn failed:
|
|
9
9
|
%s`,n),t(t=>t.map(t=>t.id===e.id?{...t,text:e.text??``,status:e.status??`done`,activity:null,interrupted:e.interrupted===!0,errorDetail:e.errorDetail,taskIds:e.taskIds??t.taskIds}:t))}else if(e.type===`task-update`&&e.task){let t=e.task;t.status===`failed`&&t.errorDetail&&console.error(`[castle] task %s failed:
|
|
10
|
-
%s`,t.title,t.errorDetail),n(e=>(e.some(e=>e.id===t.id)?e.map(e=>e.id===t.id?t:e):[...e,t]).sort((e,t)=>e.createdAt.localeCompare(t.createdAt))),Dr.includes(t.status)&&r(e=>{if(!(t.id in e))return e;let n={...e};return delete n[t.id],n})}}function kr(){let[e,t]=g.useState([]),[n,r]=g.useState([]),[i,a]=g.useState({}),[o,s]=g.useState({}),[c,l]=g.useState({}),[u,d]=g.useState(null),[f,p]=g.useState({running:!1,queued:[]}),[m,h]=g.useState(!1),_=g.useRef(()=>void 0),v=g.useCallback((e,t)=>{p({running:e,queued:t})},[]);return g.useEffect(()=>{let e=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/__castle/agent`,n=null,i=!0,o=500,c=[];_.current=e=>{let t=JSON.stringify(e);n&&n.readyState===WebSocket.OPEN?n.send(t):c.push(t)};let u=()=>{if(!i||document.visibilityState===`hidden`)return;let f=new WebSocket(e);n=f,f.addEventListener(`open`,()=>{for(o=500;c.length>0&&f.readyState===f.OPEN;){let e=c.shift();e&&f.send(e)}}),f.addEventListener(`message`,e=>{try{Or(JSON.parse(String(e.data)),t,r,a,s,l,v,d,()=>h(!0))}catch{}}),f.addEventListener(`close`,()=>{n===f&&(n=null,i&&(window.setTimeout(u,o),o=Math.min(o*2,15e3)))})},f=()=>{document.visibilityState!==`hidden`&&!n&&u()};return document.addEventListener(`visibilitychange`,f),u(),()=>{i=!1,document.removeEventListener(`visibilitychange`,f),n?.close()}},[v]),{messages:e,tasks:n,feeds:i,settings:o,settingsWarnings:c,usage:u,running:f.running,queued:f.queued,booted:m,sendUserMessage:(e,t)=>_.current({type:`user-message`,text:e,images:t}),ackTask:(e,t)=>_.current({type:`task-ack`,id:e,rejected:t}),setSetting:(e,t)=>_.current({type:`set-settings`,[e]:t}),interrupt:()=>_.current({type:`interrupt`}),cancelQueued:e=>_.current({type:`cancel-queued`,index:e}),submitPicker:(e,t,n)=>_.current({type:`picker-choice`,id:e,answers:t,text:n})}}function Ar(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var jr=Ar();function Mr(e){jr=e}var Nr={exec:()=>null};function Pr(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function P(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Ir.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Fr=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),Ir={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Pr(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Pr(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Pr(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Pr(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Pr(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:Pr(e=>RegExp(`^ {0,${e}}>`))},Lr=/^(?:[ \t]*(?:\n|$))+/,Rr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,zr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Br=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Vr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Hr=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ur=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Wr=P(Ur).replace(/bull/g,Hr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Gr=P(Ur).replace(/bull/g,Hr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Kr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,qr=/^[^\n]+/,Jr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Yr=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Jr).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Xr=P(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Hr).getRegex(),Zr=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Qr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$r=P(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Qr).replace(`tag`,Zr).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ei=P(Kr).replace(`hr`,Br).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Zr).getRegex(),ti={blockquote:P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,ei).getRegex(),code:Rr,def:Yr,fences:zr,heading:Vr,hr:Br,html:$r,lheading:Wr,list:Xr,newline:Lr,paragraph:ei,table:Nr,text:qr},ni=P(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Br).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Zr).getRegex(),ri={...ti,lheading:Gr,table:ni,paragraph:P(Kr).replace(`hr`,Br).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,ni).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Zr).getRegex()},ii={...ti,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Qr).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Nr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(Kr).replace(`hr`,Br).replace(`heading`,` *#{1,6} *[^
|
|
10
|
+
%s`,t.title,t.errorDetail),n(e=>(e.some(e=>e.id===t.id)?e.map(e=>e.id===t.id?t:e):[...e,t]).sort((e,t)=>e.createdAt.localeCompare(t.createdAt))),Dr.includes(t.status)&&r(e=>{if(!(t.id in e))return e;let n={...e};return delete n[t.id],n})}}function kr(){let[e,t]=g.useState([]),[n,r]=g.useState([]),[i,a]=g.useState({}),[o,s]=g.useState({}),[c,l]=g.useState({}),[u,d]=g.useState(null),[f,p]=g.useState({running:!1,queued:[]}),[m,h]=g.useState(!1),_=g.useRef(()=>void 0),v=g.useCallback((e,t)=>{p({running:e,queued:t})},[]);return g.useEffect(()=>{let e=`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}/__castle/agent`,n=null,i=!0,o=500,c=[];_.current=e=>{let t=JSON.stringify(e);n&&n.readyState===WebSocket.OPEN?n.send(t):c.push(t)};let u=()=>{if(!i||document.visibilityState===`hidden`)return;let f=new WebSocket(e);n=f,f.addEventListener(`open`,()=>{for(o=500,f.send(JSON.stringify({type:`client-timezone`,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone}));c.length>0&&f.readyState===f.OPEN;){let e=c.shift();e&&f.send(e)}}),f.addEventListener(`message`,e=>{try{Or(JSON.parse(String(e.data)),t,r,a,s,l,v,d,()=>h(!0))}catch{}}),f.addEventListener(`close`,()=>{n===f&&(n=null,i&&(window.setTimeout(u,o),o=Math.min(o*2,15e3)))})},f=()=>{document.visibilityState!==`hidden`&&!n&&u()};return document.addEventListener(`visibilitychange`,f),u(),()=>{i=!1,document.removeEventListener(`visibilitychange`,f),n?.close()}},[v]),{messages:e,tasks:n,feeds:i,settings:o,settingsWarnings:c,usage:u,running:f.running,queued:f.queued,booted:m,sendUserMessage:(e,t)=>_.current({type:`user-message`,text:e,images:t}),ackTask:(e,t)=>_.current({type:`task-ack`,id:e,rejected:t}),setSetting:(e,t)=>_.current({type:`set-settings`,[e]:t}),interrupt:()=>_.current({type:`interrupt`}),cancelQueued:e=>_.current({type:`cancel-queued`,index:e}),submitPicker:(e,t,n)=>_.current({type:`picker-choice`,id:e,answers:t,text:n})}}function Ar(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var jr=Ar();function Mr(e){jr=e}var Nr={exec:()=>null};function Pr(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function P(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Ir.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Fr=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),Ir={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Pr(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Pr(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Pr(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Pr(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Pr(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:Pr(e=>RegExp(`^ {0,${e}}>`))},Lr=/^(?:[ \t]*(?:\n|$))+/,Rr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,zr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Br=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Vr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Hr=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ur=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Wr=P(Ur).replace(/bull/g,Hr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Gr=P(Ur).replace(/bull/g,Hr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Kr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,qr=/^[^\n]+/,Jr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Yr=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Jr).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Xr=P(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Hr).getRegex(),Zr=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Qr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$r=P(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Qr).replace(`tag`,Zr).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ei=P(Kr).replace(`hr`,Br).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Zr).getRegex(),ti={blockquote:P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,ei).getRegex(),code:Rr,def:Yr,fences:zr,heading:Vr,hr:Br,html:$r,lheading:Wr,list:Xr,newline:Lr,paragraph:ei,table:Nr,text:qr},ni=P(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Br).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Zr).getRegex(),ri={...ti,lheading:Gr,table:ni,paragraph:P(Kr).replace(`hr`,Br).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,ni).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Zr).getRegex()},ii={...ti,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Qr).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Nr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(Kr).replace(`hr`,Br).replace(`heading`,` *#{1,6} *[^
|
|
11
11
|
]`).replace(`lheading`,Wr).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},ai=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,oi=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,si=/^( {2,}|\\)\n(?!\s*$)/,ci=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,li=/[\p{P}\p{S}]/u,ui=/[\s\p{P}\p{S}]/u,di=/[^\s\p{P}\p{S}]/u,fi=P(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,ui).getRegex(),pi=/(?!~)[\p{P}\p{S}]/u,mi=/(?!~)[\s\p{P}\p{S}]/u,hi=/(?:[^\s\p{P}\p{S}]|~)/u,gi=P(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Fr?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),_i=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,vi=P(_i,`u`).replace(/punct/g,li).getRegex(),yi=P(_i,`u`).replace(/punct/g,pi).getRegex(),bi=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,xi=P(bi,`gu`).replace(/notPunctSpace/g,di).replace(/punctSpace/g,ui).replace(/punct/g,li).getRegex(),Si=P(bi,`gu`).replace(/notPunctSpace/g,hi).replace(/punctSpace/g,mi).replace(/punct/g,pi).getRegex(),Ci=P(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,di).replace(/punctSpace/g,ui).replace(/punct/g,li).getRegex(),wi=P(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,li).getRegex(),Ti=P(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,di).replace(/punctSpace/g,ui).replace(/punct/g,li).getRegex(),Ei=P(/\\(punct)/,`gu`).replace(/punct/g,li).getRegex(),Di=P(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Oi=P(Qr).replace(`(?:-->|$)`,`-->`).getRegex(),ki=P(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Oi).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Ai=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,ji=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Ai).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Mi=P(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Ai).replace(`ref`,Jr).getRegex(),Ni=P(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Jr).getRegex(),Pi=P(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Mi).replace(`nolink`,Ni).getRegex(),Fi=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ii={_backpedal:Nr,anyPunctuation:Ei,autolink:Di,blockSkip:gi,br:si,code:oi,del:Nr,delLDelim:Nr,delRDelim:Nr,emStrongLDelim:vi,emStrongRDelimAst:xi,emStrongRDelimUnd:Ci,escape:ai,link:ji,nolink:Ni,punctuation:fi,reflink:Mi,reflinkSearch:Pi,tag:ki,text:ci,url:Nr},Li={...Ii,link:P(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Ai).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Ai).getRegex()},Ri={...Ii,emStrongRDelimAst:Si,emStrongLDelim:yi,delLDelim:wi,delRDelim:Ti,url:P(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Fi).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:P(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Fi).getRegex()},zi={...Ri,br:P(si).replace(`{2,}`,`*`).getRegex(),text:P(Ri.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Bi={normal:ti,gfm:ri,pedantic:ii},Vi={normal:Ii,gfm:Ri,breaks:zi,pedantic:Li},Hi={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Ui=e=>Hi[e];function Wi(e,t){if(t){if(Ir.escapeTest.test(e))return e.replace(Ir.escapeReplace,Ui)}else if(Ir.escapeTestNoEncode.test(e))return e.replace(Ir.escapeReplaceNoEncode,Ui);return e}function Gi(e){try{e=encodeURI(e).replace(Ir.percentDecode,`%`)}catch{return null}return e}function Ki(e,t){let n=e.replace(Ir.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Ir.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(Ir.slashPipe,`|`);return n}function qi(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Ji(e){let t=e.split(`
|
|
12
12
|
`),n=t.length-1;for(;n>=0&&Ir.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
13
13
|
`)}function Yi(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Xi(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Zi(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function Qi(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
package/dist/shell/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Castle Editor</title>
|
|
7
|
-
<script type="module" crossorigin src="/__castle/ide/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/__castle/ide/assets/index-B7nQarKK.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/__castle/ide/assets/index-DIcWN-RS.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|